summaryrefslogtreecommitdiffstats
path: root/x11vnc/x11vnc.c
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/x11vnc.c')
-rw-r--r--x11vnc/x11vnc.c117
1 files changed, 91 insertions, 26 deletions
diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c
index 70cef69..e13e228 100644
--- a/x11vnc/x11vnc.c
+++ b/x11vnc/x11vnc.c
@@ -172,6 +172,7 @@ static void check_rcfile(int argc, char **argv);
static void immediate_switch_user(int argc, char* argv[]);
static void print_settings(int try_http, int bg, char *gui_str);
static void check_loop_mode(int argc, char* argv[], int force);
+static void check_appshare_mode(int argc, char* argv[]);
static int tsdo_timeout_flag;
@@ -1702,6 +1703,24 @@ static void check_loop_mode(int argc, char* argv[], int force) {
#endif
}
}
+
+extern int appshare_main(int argc, char* argv[]);
+
+static void check_appshare_mode(int argc, char* argv[]) {
+ int i;
+
+ for (i=1; i < argc; i++) {
+ char *p = argv[i];
+ if (strstr(p, "--") == p) {
+ p++;
+ }
+ if (strstr(p, "-appshare") == p) {
+ appshare_main(argc, argv);
+ exit(0);
+ }
+ }
+}
+
static void store_homedir_passwd(char *file) {
char str1[32], str2[32], *p, *h, *f;
struct stat sbuf;
@@ -1992,21 +2011,32 @@ int main(int argc, char* argv[]) {
char *got_rfbport_str = NULL;
int got_rfbport_pos = -1;
int got_tls = 0;
+ int got_inetd = 0;
+ int got_noxrandr = 0;
/* used to pass args we do not know about to rfbGetScreen(): */
int argc_vnc_max = 1024;
int argc_vnc = 1; char *argv_vnc[2048];
-
/* check for -loop mode: */
check_loop_mode(argc, argv, 0);
+ /* check for -appshare mode: */
+ check_appshare_mode(argc, argv);
+
dtime0(&x11vnc_start);
+ for (i=1; i < argc; i++) {
+ if (!strcmp(argv[i], "-inetd")) {
+ got_inetd = 1;
+ }
+ }
if (!getuid() || !geteuid()) {
started_as_root = 1;
- rfbLog("getuid: %d geteuid: %d\n", getuid(), geteuid());
+ if (0 && !got_inetd) {
+ rfbLog("getuid: %d geteuid: %d\n", getuid(), geteuid());
+ }
/* check for '-users =bob' */
immediate_switch_user(argc, argv);
@@ -2363,6 +2393,14 @@ int main(int argc, char* argv[]) {
; /* handled above */
continue;
}
+ if (strstr(arg, "-appshare") == arg) {
+ ; /* handled above */
+ continue;
+ }
+ if (strstr(arg, "-freeze_when_obscured") == arg) {
+ freeze_when_obscured = 1;
+ continue;
+ }
if (!strcmp(arg, "-timeout")) {
CHECK_ARGC
first_conn_timeout = atoi(argv[++i]);
@@ -2955,6 +2993,7 @@ int main(int argc, char* argv[]) {
if (!strcmp(arg, "-noxrandr")) {
xrandr = 0;
xrandr_maybe = 0;
+ got_noxrandr = 1;
continue;
}
if (!strcmp(arg, "-rotate")) {
@@ -3040,6 +3079,10 @@ int main(int argc, char* argv[]) {
quiet = 1;
continue;
}
+ if (!strcmp(arg, "-noquiet")) {
+ quiet = 0;
+ continue;
+ }
if (!strcmp(arg, "-v") || !strcmp(arg, "-verbose")) {
verbose = 1;
continue;
@@ -3049,7 +3092,9 @@ int main(int argc, char* argv[]) {
bg = 1;
opts_bg = bg;
#else
- fprintf(stderr, "warning: -bg mode not supported.\n");
+ if (!got_inetd) {
+ fprintf(stderr, "warning: -bg mode not supported.\n");
+ }
#endif
continue;
}
@@ -3446,8 +3491,10 @@ int main(int argc, char* argv[]) {
*p = '\0';
}
if (atoi(s) < 1 || atoi(s) > pointer_mode_max) {
- rfbLog("pointer_mode out of range 1-%d: %d\n",
- pointer_mode_max, atoi(s));
+ if (!got_inetd) {
+ rfbLog("pointer_mode out of range 1-%d: %d\n",
+ pointer_mode_max, atoi(s));
+ }
} else {
pointer_mode = atoi(s);
got_pointer_mode = pointer_mode;
@@ -3591,7 +3638,9 @@ int main(int argc, char* argv[]) {
if (!strcmp(arg, "-chatwindow")) {
chat_window = 1;
if (argc_vnc + 1 < argc_vnc_max) {
- rfbLog("setting '-rfbversion 3.6' for -chatwindow.\n");
+ if (!got_inetd) {
+ rfbLog("setting '-rfbversion 3.6' for -chatwindow.\n");
+ }
argv_vnc[argc_vnc++] = strdup("-rfbversion");
argv_vnc[argc_vnc++] = strdup("3.6");
}
@@ -3645,14 +3694,16 @@ int main(int argc, char* argv[]) {
/* we re-enable it due to threaded mode bugfixes. */
use_threads = 1;
} else {
- rfbLog("\n");
- rfbLog("The -threads mode is unstable and not tested or maintained.\n");
- rfbLog("It is disabled in the source code. If you really need\n");
- rfbLog("the feature you can reenable it at build time by setting\n");
- rfbLog("-DX11VNC_THREADED in CPPFLAGS. Or set X11VNC_THREADED=1\n");
- rfbLog("in your runtime environment.\n");
- rfbLog("\n");
- usleep(500*1000);
+ if (!got_inetd) {
+ rfbLog("\n");
+ rfbLog("The -threads mode is unstable and not tested or maintained.\n");
+ rfbLog("It is disabled in the source code. If you really need\n");
+ rfbLog("the feature you can reenable it at build time by setting\n");
+ rfbLog("-DX11VNC_THREADED in CPPFLAGS. Or set X11VNC_THREADED=1\n");
+ rfbLog("in your runtime environment.\n");
+ rfbLog("\n");
+ usleep(500*1000);
+ }
}
#endif
continue;
@@ -3931,9 +3982,11 @@ int main(int argc, char* argv[]) {
if (!strcasecmp(argv[i+1], "prompt")) {
;
} else if (!is_decimal(argv[i+1])) {
- rfbLog("Invalid -rfbport value: '%s'\n", argv[i+1]);
- rfbLog("setting it to '-1' to induce failure.\n");
- argv[i+1] = strdup("-1");
+ if (!got_inetd) {
+ rfbLog("Invalid -rfbport value: '%s'\n", argv[i+1]);
+ rfbLog("setting it to '-1' to induce failure.\n");
+ argv[i+1] = strdup("-1");
+ }
}
got_rfbport_str = strdup(argv[i+1]);
got_rfbport_pos = argc_vnc+1;
@@ -4032,7 +4085,9 @@ int main(int argc, char* argv[]) {
client_connect_file = str;
}
if (client_connect_file) {
- rfbLog("MacOS X: set -connect file to %s\n", client_connect_file);
+ if (!got_inetd) {
+ rfbLog("MacOS X: set -connect file to %s\n", client_connect_file);
+ }
}
}
}
@@ -4053,7 +4108,9 @@ int main(int argc, char* argv[]) {
rfbLog("Port prompt indicated cancel.\n");
clean_up_exit(1);
}
- rfbLog("Port prompt selected: %d\n", got_rfbport_val);
+ if (!got_inetd) {
+ rfbLog("Port prompt selected: %d\n", got_rfbport_val);
+ }
sprintf(tport, "%d", got_rfbport_val);
argv_vnc[got_rfbport_pos] = strdup(tport);
free(opts);
@@ -4117,8 +4174,9 @@ int main(int argc, char* argv[]) {
q = t + strlen(pstr);
}
logfile = new;
- if (!quiet) {
+ if (!quiet && !got_inetd) {
rfbLog("Expanded logfile to '%s'\n", new);
+
}
free(s);
}
@@ -4152,7 +4210,7 @@ int main(int argc, char* argv[]) {
q = t + strlen(pstr);
}
logfile = new;
- if (!quiet) {
+ if (!quiet && !got_inetd) {
rfbLog("Expanded logfile to '%s'\n", new);
}
free(s);
@@ -4389,7 +4447,7 @@ int main(int argc, char* argv[]) {
if (1) {
/* mix things up a little bit */
unsigned char buf[CHALLENGESIZE];
- int k, kmax = (int) (500 * rfac()) + 100;
+ int k, kmax = (int) (50 * rfac()) + 10;
for (k=0; k < kmax; k++) {
rfbRandomBytes(buf);
}
@@ -4550,6 +4608,13 @@ int main(int argc, char* argv[]) {
exit(1);
}
+ if (use_threads && !got_noxrandr) {
+ xrandr = 1;
+ if (! quiet) {
+ rfbLog("enabling -xrandr in -threads mode.\n");
+ }
+ }
+
/* fixup settings that do not make sense */
if (use_threads && nofb && cursor_pos_updates) {
@@ -4626,6 +4691,7 @@ int main(int argc, char* argv[]) {
/* increase rfbwait if threaded */
if (use_threads && ! got_rfbwait) {
+ /* ??? lower this ??? */
rfbMaxClientWait = 604800000;
}
@@ -4712,6 +4778,8 @@ int main(int argc, char* argv[]) {
X_INIT;
SCR_INIT;
CLIENT_INIT;
+ INPUT_INIT;
+ POINTER_INIT;
/* open the X display: */
@@ -5331,9 +5399,7 @@ int main(int argc, char* argv[]) {
}
#endif
- if (!getenv("X11VNC_NO_CHECK_PM")) {
- check_pm();
- }
+ check_pm();
if (! quiet && ! raw_fb_str) {
rfbLog("--------------------------------------------------------\n");
@@ -5644,4 +5710,3 @@ int main(int argc, char* argv[]) {
}
-
OpenPOWER on IntegriCloud