Commit 5b198763 authored by runge's avatar runge

x11vnc: FINDCREATEDISPLAY support to create X session if one cannot be found. ...

x11vnc: FINDCREATEDISPLAY support to create X session if one cannot be found.  Fix bug in java viewer.
parent 726cedb8
...@@ -1378,7 +1378,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSL ...@@ -1378,7 +1378,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSL
+} +}
diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncViewer.java diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncViewer.java
--- vnc_javasrc.orig/VncViewer.java 2004-03-04 08:34:25.000000000 -0500 --- vnc_javasrc.orig/VncViewer.java 2004-03-04 08:34:25.000000000 -0500
+++ vnc_javasrc/VncViewer.java 2006-09-23 18:36:42.000000000 -0400 +++ vnc_javasrc/VncViewer.java 2006-12-01 02:31:26.000000000 -0500
@@ -88,6 +88,14 @@ @@ -88,6 +88,14 @@
int deferCursorUpdates; int deferCursorUpdates;
int deferUpdateRequests; int deferUpdateRequests;
...@@ -1394,7 +1394,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncView ...@@ -1394,7 +1394,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncView
// Reference to this applet for inter-applet communication. // Reference to this applet for inter-applet communication.
public static java.applet.Applet refApplet; public static java.applet.Applet refApplet;
@@ -626,6 +634,51 @@ @@ -626,6 +634,53 @@
// SocketFactory. // SocketFactory.
socketFactory = readParameter("SocketFactory", false); socketFactory = readParameter("SocketFactory", false);
...@@ -1430,8 +1430,10 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncView ...@@ -1430,8 +1430,10 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncView
+ if (urlPrefix.indexOf("/") != 0) { + if (urlPrefix.indexOf("/") != 0) {
+ urlPrefix = "/" + urlPrefix; + urlPrefix = "/" + urlPrefix;
+ } + }
+ } else {
+ urlPrefix = "";
+ } + }
+ System.out.println("urlPrefix: " + urlPrefix); + System.out.println("urlPrefix: '" + urlPrefix + "'");
+ +
+ forceProxy = false; + forceProxy = false;
+ str = readParameter("forceProxy", false); + str = readParameter("forceProxy", false);
......
2006-12-09 Karl Runge <runge@karlrunge.com>
* java SSL viewer: guard against empty urlPrefix
* x11vnc: FINDCREATEDISPLAY support to create X session if
one cannot be found. close fds utility. Print VNC Viewer
is.. for find display mode. chvt(1) utility.
2006-11-23 Karl Runge <runge@karlrunge.com> 2006-11-23 Karl Runge <runge@karlrunge.com>
* prepare_x11vnc_dist.sh: make ss_vncviewer installed 755. * prepare_x11vnc_dist.sh: make ss_vncviewer installed 755.
* x11vnc: for HTTPONCE open new http port in -inetd mode. * x11vnc: for HTTPONCE open new http port in -inetd mode.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -35,6 +35,7 @@ char *xerror_string(XErrorEvent *error); ...@@ -35,6 +35,7 @@ char *xerror_string(XErrorEvent *error);
void initialize_crash_handler(void); void initialize_crash_handler(void);
void initialize_signals(void); void initialize_signals(void);
void unset_signals(void); void unset_signals(void);
void close_exec_fds(void);
int known_sigpipe_mode(char *s); int known_sigpipe_mode(char *s);
...@@ -542,6 +543,18 @@ void unset_signals(void) { ...@@ -542,6 +543,18 @@ void unset_signals(void) {
signal(SIGPIPE, SIG_DFL); signal(SIGPIPE, SIG_DFL);
} }
void close_exec_fds(void) {
int fd;
#ifdef FD_CLOEXEC
for (fd = 3; fd < 64; fd++) {
int flags = fcntl(fd, F_GETFD);
if (flags != -1) {
flags |= FD_CLOEXEC;
fcntl(fd, F_SETFD, flags);
}
}
#endif
}
int known_sigpipe_mode(char *s) { int known_sigpipe_mode(char *s) {
/* /*
......
...@@ -21,6 +21,7 @@ extern char *xerror_string(XErrorEvent *error); ...@@ -21,6 +21,7 @@ extern char *xerror_string(XErrorEvent *error);
extern void initialize_crash_handler(void); extern void initialize_crash_handler(void);
extern void initialize_signals(void); extern void initialize_signals(void);
extern void unset_signals(void); extern void unset_signals(void);
extern void close_exec_fds(void);
extern int known_sigpipe_mode(char *s); extern int known_sigpipe_mode(char *s);
#endif /* _X11VNC_CLEANUP_H */ #endif /* _X11VNC_CLEANUP_H */
...@@ -517,6 +517,8 @@ int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input, ...@@ -517,6 +517,8 @@ int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input,
rfbLog("running command:\n"); rfbLog("running command:\n");
rfbLog(" %s\n", cmd); rfbLog(" %s\n", cmd);
close_exec_fds();
if (output != NULL) { if (output != NULL) {
FILE *ph = popen(cmd, "r"); FILE *ph = popen(cmd, "r");
char line[1024]; char line[1024];
...@@ -587,7 +589,6 @@ int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input, ...@@ -587,7 +589,6 @@ int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input,
} }
} }
#else #else
/* this will still have port 5900 open */
rc = system(cmd); rc = system(cmd);
#endif #endif
got_rc: got_rc:
......
...@@ -456,6 +456,7 @@ if (0) fprintf(stderr, "run_gui: %s -- %d %d\n", gui_xdisplay, connect_to_x11vnc ...@@ -456,6 +456,7 @@ if (0) fprintf(stderr, "run_gui: %s -- %d %d\n", gui_xdisplay, connect_to_x11vnc
strcat(cmd, icon_mode_embed_id); strcat(cmd, icon_mode_embed_id);
} }
} }
close_exec_fds();
pipe = popen(cmd, "w"); pipe = popen(cmd, "w");
if (! pipe) { if (! pipe) {
fprintf(stderr, "could not run: %s\n", cmd); fprintf(stderr, "could not run: %s\n", cmd);
......
This diff is collapsed.
EXTRA_DIST=README blockdpy.c dtVncPopup rx11vnc rx11vnc.pl shm_clear ranfb.pl slide.pl vcinject.pl x11vnc_loop EXTRA_DIST=README blockdpy.c dtVncPopup rx11vnc rx11vnc.pl shm_clear ranfb.pl slide.pl vcinject.pl x11vnc_loop Xdummy
...@@ -997,6 +997,7 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p); ...@@ -997,6 +997,7 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p);
clean_up_exit(1); clean_up_exit(1);
} }
rfbLog("pipeinput: starting: \"%s\"...\n", p); rfbLog("pipeinput: starting: \"%s\"...\n", p);
close_exec_fds();
pipeinput_fh = popen(p, "w"); pipeinput_fh = popen(p, "w");
if (! pipeinput_fh) { if (! pipeinput_fh) {
......
...@@ -40,6 +40,7 @@ int parse_rotate_string(char *str, int *mode); ...@@ -40,6 +40,7 @@ int parse_rotate_string(char *str, int *mode);
int scale_round(int len, double fac); int scale_round(int len, double fac);
void initialize_screen(int *argc, char **argv, XImage *fb); void initialize_screen(int *argc, char **argv, XImage *fb);
void set_vnc_desktop_name(void); void set_vnc_desktop_name(void);
void announce(int lport, int ssl, char *iface);
static void debug_colormap(XImage *fb); static void debug_colormap(XImage *fb);
...@@ -51,7 +52,6 @@ static void initialize_snap_fb(void); ...@@ -51,7 +52,6 @@ static void initialize_snap_fb(void);
XImage *initialize_raw_fb(int); XImage *initialize_raw_fb(int);
static void initialize_clipshift(void); static void initialize_clipshift(void);
static int wait_until_mapped(Window win); static int wait_until_mapped(Window win);
static void announce(int lport, int ssl, char *iface);
static void setup_scaling(int *width_in, int *height_in); static void setup_scaling(int *width_in, int *height_in);
int rawfb_reset = -1; int rawfb_reset = -1;
...@@ -920,6 +920,7 @@ if (db) fprintf(stderr, "initialize_raw_fb reset\n"); ...@@ -920,6 +920,7 @@ if (db) fprintf(stderr, "initialize_raw_fb reset\n");
clean_up_exit(1); clean_up_exit(1);
} }
rfbLog("running command to setup rawfb: %s\n", q); rfbLog("running command to setup rawfb: %s\n", q);
close_exec_fds();
pipe = popen(q, "r"); pipe = popen(q, "r");
if (! pipe) { if (! pipe) {
rfbLogEnable(1); rfbLogEnable(1);
...@@ -2497,7 +2498,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -2497,7 +2498,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
install_passwds(); install_passwds();
} }
static void announce(int lport, int ssl, char *iface) { void announce(int lport, int ssl, char *iface) {
char *host = this_host(); char *host = this_host();
char *tvdt; char *tvdt;
......
...@@ -21,6 +21,7 @@ extern int parse_rotate_string(char *str, int *mode); ...@@ -21,6 +21,7 @@ extern int parse_rotate_string(char *str, int *mode);
extern int scale_round(int len, double fac); extern int scale_round(int len, double fac);
extern void initialize_screen(int *argc, char **argv, XImage *fb); extern void initialize_screen(int *argc, char **argv, XImage *fb);
extern void set_vnc_desktop_name(void); extern void set_vnc_desktop_name(void);
extern void announce(int lport, int ssl, char *iface);
extern int rawfb_reset; extern int rawfb_reset;
extern int rawfb_dev_video; extern int rawfb_dev_video;
......
...@@ -68,6 +68,7 @@ static int dt_cmd(char *cmd) { ...@@ -68,6 +68,7 @@ static int dt_cmd(char *cmd) {
rfbLog("running command:\n %s\n", cmd); rfbLog("running command:\n %s\n", cmd);
usr_bin_path(0); usr_bin_path(0);
close_exec_fds();
rc = system(cmd); rc = system(cmd);
usr_bin_path(1); usr_bin_path(1);
...@@ -96,6 +97,7 @@ static char *cmd_output(char *cmd) { ...@@ -96,6 +97,7 @@ static char *cmd_output(char *cmd) {
rfbLog("running pipe:\n %s\n", cmd); rfbLog("running pipe:\n %s\n", cmd);
usr_bin_path(0); usr_bin_path(0);
close_exec_fds();
p = popen(cmd, "r"); p = popen(cmd, "r");
usr_bin_path(1); usr_bin_path(1);
......
...@@ -901,6 +901,7 @@ void openssl_port(void) { ...@@ -901,6 +901,7 @@ void openssl_port(void) {
clean_up_exit(1); clean_up_exit(1);
} }
rfbLog("openssl_port: listen on port/sock %d/%d\n", port, sock); rfbLog("openssl_port: listen on port/sock %d/%d\n", port, sock);
announce(port, 1, NULL);
openssl_sock = sock; openssl_sock = sock;
openssl_port_num = port; openssl_port_num = port;
......
This diff is collapsed.
...@@ -1221,6 +1221,7 @@ void user_supplied_opts(char *opts) { ...@@ -1221,6 +1221,7 @@ void user_supplied_opts(char *opts) {
} }
extern char find_display[]; extern char find_display[];
extern char create_display[];
static XImage ximage_struct; static XImage ximage_struct;
int wait_for_client(int *argc, char** argv, int http) { int wait_for_client(int *argc, char** argv, int http) {
...@@ -1231,6 +1232,9 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1231,6 +1232,9 @@ int wait_for_client(int *argc, char** argv, int http) {
int db = 0; int db = 0;
char tmp[] = "/tmp/x11vnc-find_display.XXXXXX"; char tmp[] = "/tmp/x11vnc-find_display.XXXXXX";
int tmp_fd = -1, dt = 0; int tmp_fd = -1, dt = 0;
char *create_cmd = NULL;
char *users_list_save = NULL;
int created_disp = 0;
if (! use_dpy || strstr(use_dpy, "WAIT:") != use_dpy) { if (! use_dpy || strstr(use_dpy, "WAIT:") != use_dpy) {
return 0; return 0;
...@@ -1285,6 +1289,10 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1285,6 +1289,10 @@ int wait_for_client(int *argc, char** argv, int http) {
fprintf(stdout, "%s", find_display); fprintf(stdout, "%s", find_display);
clean_up_exit(0); clean_up_exit(0);
} }
if (!strcmp(str, "FINDCREATEDISPLAY-print")) {
fprintf(stdout, "%s", create_display);
clean_up_exit(0);
}
if (db) fprintf(stderr, "cmd: %s\n", cmd); if (db) fprintf(stderr, "cmd: %s\n", cmd);
} }
...@@ -1394,6 +1402,12 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1394,6 +1402,12 @@ int wait_for_client(int *argc, char** argv, int http) {
rfbLog("taking unixpw_client off hold.\n"); rfbLog("taking unixpw_client off hold.\n");
unixpw_client->onHold = FALSE; unixpw_client->onHold = FALSE;
} }
if (cmd && strstr(cmd, "FINDCREATEDISPLAY") == cmd) {
if (users_list && strstr(users_list, "unixpw=") == users_list) {
users_list_save = users_list;
users_list = NULL;
}
}
while (1) { while (1) {
if (shut_down) { if (shut_down) {
clean_up_exit(0); clean_up_exit(0);
...@@ -1421,7 +1435,8 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1421,7 +1435,8 @@ int wait_for_client(int *argc, char** argv, int http) {
memset(line1, 0, 1024); memset(line1, 0, 1024);
memset(line2, 0, 16384); memset(line2, 0, 16384);
if (!strcmp(cmd, "FINDDISPLAY")) { if (!strcmp(cmd, "FINDDISPLAY") ||
strstr(cmd, "FINDCREATEDISPLAY") == cmd) {
tmp_fd = mkstemp(tmp); tmp_fd = mkstemp(tmp);
if (tmp_fd < 0) { if (tmp_fd < 0) {
rfbLog("wait_for_client: open failed: %s\n", tmp); rfbLog("wait_for_client: open failed: %s\n", tmp);
...@@ -1431,6 +1446,28 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1431,6 +1446,28 @@ int wait_for_client(int *argc, char** argv, int http) {
write(tmp_fd, find_display, strlen(find_display)); write(tmp_fd, find_display, strlen(find_display));
close(tmp_fd); close(tmp_fd);
chmod(tmp, 0644); chmod(tmp, 0644);
if (strstr(cmd, "FINDCREATEDISPLAY") == cmd) {
char *opts = strchr(cmd, '-');
char st[] = "";
if (opts) {
opts++;
} else {
opts = st;
}
if (unixpw && keep_unixpw_user) {
create_cmd = (char *) malloc(strlen(tmp)
+ strlen("env USER='' /bin/sh ")
+ strlen(keep_unixpw_user) + 1 + strlen(opts) + 1);
sprintf(create_cmd, "env USER='%s' /bin/sh %s %s",
keep_unixpw_user, tmp, opts);
} else {
create_cmd = (char *) malloc(strlen(tmp)
+ strlen("/bin/sh ") + 1 + strlen(opts) + 1);
sprintf(create_cmd, "/bin/sh %s %s", tmp, opts);
}
if (db) fprintf(stderr, "create_cmd: %s\n", create_cmd);
}
cmd = (char *) malloc(strlen(tmp) + strlen("/bin/sh ") + 1); cmd = (char *) malloc(strlen(tmp) + strlen("/bin/sh ") + 1);
sprintf(cmd, "/bin/sh %s", tmp); sprintf(cmd, "/bin/sh %s", tmp);
} }
...@@ -1447,17 +1484,58 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1447,17 +1484,58 @@ int wait_for_client(int *argc, char** argv, int http) {
n = 18000; n = 18000;
res = su_verify(keep_unixpw_user, res = su_verify(keep_unixpw_user,
keep_unixpw_pass, cmd, line, &n); keep_unixpw_pass, cmd, line, &n);
strzero(keep_unixpw_user);
strzero(keep_unixpw_pass);
} }
keep_unixpw = 0;
if (db) write(2, line, n); write(2, "\n", 1);
if (! res && create_cmd) {
FILE *mt = fopen(tmp, "w");
if (! mt) {
rfbLog("wait_for_client: open failed: %s\n", tmp);
rfbLogPerror("fopen");
clean_up_exit(1);
}
fprintf(mt, "%s", create_display);
fclose(mt);
if (getuid() != 0) {
/* if not root, run as the other user... */
n = 18000;
res = su_verify(keep_unixpw_user,
keep_unixpw_pass, create_cmd, line, &n);
/*if (1) fprintf(stderr, "line: '%s'\n", line); */
} else {
FILE *p;
close_exec_fds();
rfbLog("wait_for_client: running: %s\n", create_cmd);
p = popen(create_cmd, "r");
if (! p) {
rfbLog("wait_for_client: popen failed: %s\n", create_cmd);
res = 0;
} else if (fgets(line1, 1024, p) == NULL) {
rfbLog("wait_for_client: read failed: %s\n", create_cmd);
res = 0;
} else {
n = fread(line2, 1, 16384, p);
if (pclose(p) != 0) {
res = 0;
} else {
strncpy(line, line1, 100);
memcpy(line + strlen(line1), line2, n);
if (db) fprintf(stderr, "line1: '%s'\n", line1);
n += strlen(line1);
created_disp = 1;
res = 1;
}
}
}
}
if (tmp_fd >= 0) { if (tmp_fd >= 0) {
unlink(tmp); unlink(tmp);
} }
if (db) write(2, line, n); write(2, "\n", 1);
if (! res) { if (! res) {
rfbLog("wait_for_client: cmd failed: %s\n", cmd); rfbLog("wait_for_client: cmd failed: %s\n", cmd);
unixpw_msg("No DISPLAY found.", 3); unixpw_msg("No DISPLAY found.", 3);
...@@ -1490,18 +1568,23 @@ if (db) write(2, line, n); write(2, "\n", 1); ...@@ -1490,18 +1568,23 @@ if (db) write(2, line, n); write(2, "\n", 1);
continue; continue;
} }
} }
line2[i] = q[k+j]; line2[i] = q[k+j];
i++; i++;
} }
write(2, line, 100);
fprintf(stderr, "\n");
} else { } else {
FILE *p = popen(cmd, "r"); FILE *p;
int rc;
close_exec_fds();
p = popen(cmd, "r");
if (! p) { if (! p) {
rfbLog("wait_for_client: cmd failed: %s\n", cmd); rfbLog("wait_for_client: cmd failed: %s\n", cmd);
rfbLogPerror("popen"); rfbLogPerror("popen");
if (tmp_fd >= 0) { if (tmp_fd >= 0) {
unlink(tmp); unlink(tmp);
} }
unixpw_msg("No DISPLAY found.", 3);
clean_up_exit(1); clean_up_exit(1);
} }
if (fgets(line1, 1024, p) == NULL) { if (fgets(line1, 1024, p) == NULL) {
...@@ -1510,22 +1593,71 @@ if (db) write(2, line, n); write(2, "\n", 1); ...@@ -1510,22 +1593,71 @@ if (db) write(2, line, n); write(2, "\n", 1);
if (tmp_fd >= 0) { if (tmp_fd >= 0) {
unlink(tmp); unlink(tmp);
} }
unixpw_msg("No DISPLAY found.", 3);
clean_up_exit(1); clean_up_exit(1);
} }
n = fread(line2, 1, 16384, p); n = fread(line2, 1, 16384, p);
pclose(p); rc = pclose(p);
if (create_cmd && rc != 0) {
FILE *mt = fopen(tmp, "w");
if (! mt) {
rfbLog("wait_for_client: open failed: %s\n", tmp);
rfbLogPerror("fopen");
if (tmp_fd >= 0) {
unlink(tmp);
}
clean_up_exit(1);
}
fprintf(mt, "%s", create_display);
fclose(mt);
rfbLog("wait_for_client: FINDCREATEDISPLAY cmd: %s\n", create_cmd);
p = popen(create_cmd, "r");
if (! p) {
rfbLog("wait_for_client: cmd failed: %s\n", create_cmd);
rfbLogPerror("popen");
if (tmp_fd >= 0) {
unlink(tmp);
}
clean_up_exit(1);
}
if (fgets(line1, 1024, p) == NULL) {
rfbLog("wait_for_client: read failed: %s\n", create_cmd);
rfbLogPerror("fgets");
if (tmp_fd >= 0) {
unlink(tmp);
}
clean_up_exit(1);
}
n = fread(line2, 1, 16384, p);
}
if (tmp_fd >= 0) { if (tmp_fd >= 0) {
unlink(tmp); unlink(tmp);
} }
} }
if (strstr(line1, "DISPLAY=") != line1) { if (strstr(line1, "DISPLAY=") != line1) {
rfbLog("wait_for_client: bad reply %s\n", line1); rfbLog("wait_for_client: bad reply '%s'\n", line1);
unixpw_msg("No DISPLAY found.", 3); unixpw_msg("No DISPLAY found.", 3);
clean_up_exit(1); clean_up_exit(1);
} }
if (strstr(line1, ",VT=")) {
int vt;
char *t = strstr(line1, ",VT=");
vt = atoi(t + strlen(",VT="));
*t = '\0';
if (7 <= vt && vt <= 128) {
char chvt[100];
sprintf(chvt, "chvt %d >/dev/null 2>/dev/null &", vt);
rfbLog("running: %s\n", chvt);
system(chvt);
sleep(2);
}
}
use_dpy = strdup(line1 + strlen("DISPLAY=")); use_dpy = strdup(line1 + strlen("DISPLAY="));
q = use_dpy; q = use_dpy;
while (*q != '\0') { while (*q != '\0') {
...@@ -1551,9 +1683,53 @@ if (db) write(2, line, n); write(2, "\n", 1); ...@@ -1551,9 +1683,53 @@ if (db) write(2, line, n); write(2, "\n", 1);
if (db) fprintf(stderr, "xauth_raw_len: %d\n", n); if (db) fprintf(stderr, "xauth_raw_len: %d\n", n);
} }
} }
if (users_list_save && keep_unixpw_user) {
char *user = keep_unixpw_user;
char *u = (char *)malloc(strlen(user)+1);
users_list = users_list_save;
u[0] = '\0';
if (!strcmp(users_list, "unixpw=")) {
sprintf(u, "+%s", user);
} else {
char *p, *str = strdup(users_list);
p = strtok(str + strlen("unixpw="), ",");
while (p) {
if (!strcmp(p, user)) {
sprintf(u, "+%s", user);
break;
}
p = strtok(NULL, ",");
}
free(str);
}
if (u[0] == '\0') {
rfbLog("unixpw_accept skipping switch to user: %s\n", user);
} else if (switch_user(u, 0)) {
rfbLog("unixpw_accept switched to user: %s\n", user);
} else {
rfbLog("unixpw_accept failed to switched to user: %s\n", user);
}
free(u);
}
if (unixpw) { if (unixpw) {
char str[32]; char str[32];
snprintf(str, 30, "Using DISPLAY %s", use_dpy);
if (keep_unixpw_user && keep_unixpw_pass) {
strzero(keep_unixpw_user);
strzero(keep_unixpw_pass);
keep_unixpw = 0;
}
if (created_disp) {
snprintf(str, 30, "Created DISPLAY %s", use_dpy);
} else {
snprintf(str, 30, "Using DISPLAY %s", use_dpy);
}
unixpw_msg(str, 2); unixpw_msg(str, 2);
} }
} else { } else {
...@@ -1565,6 +1741,9 @@ if (db) fprintf(stderr, "xauth_raw_len: %d\n", n); ...@@ -1565,6 +1741,9 @@ if (db) fprintf(stderr, "xauth_raw_len: %d\n", n);
if (unixpw && keep_unixpw_opts && keep_unixpw_opts[0] != '\0') { if (unixpw && keep_unixpw_opts && keep_unixpw_opts[0] != '\0') {
user_supplied_opts(keep_unixpw_opts); user_supplied_opts(keep_unixpw_opts);
} }
if (create_cmd) {
free(create_cmd);
}
return 1; return 1;
} }
......
...@@ -1126,6 +1126,7 @@ static char *guess_via_v4l_info(char *dev, int *fd) { ...@@ -1126,6 +1126,7 @@ static char *guess_via_v4l_info(char *dev, int *fd) {
sprintf(cmd, "v4l-info '%s' > %s", dev, tmp); sprintf(cmd, "v4l-info '%s' > %s", dev, tmp);
close(tmp_fd); close(tmp_fd);
close_exec_fds();
rc = system(cmd); rc = system(cmd);
if (rc != 0) { if (rc != 0) {
unlink(tmp); unlink(tmp);
......
...@@ -378,6 +378,7 @@ int pick_windowid(unsigned long *num) { ...@@ -378,6 +378,7 @@ int pick_windowid(unsigned long *num) {
rfbLog(" exiting.\n"); rfbLog(" exiting.\n");
clean_up_exit(1); clean_up_exit(1);
} }
close_exec_fds();
p = popen("xwininfo", "r"); p = popen("xwininfo", "r");
if (! p) { if (! p) {
......
.\" This file was automatically generated from x11vnc -help output. .\" This file was automatically generated from x11vnc -help output.
.TH X11VNC "1" "November 2006" "x11vnc " "User Commands" .TH X11VNC "1" "December 2006" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.8.4, lastmod: 2006-11-23 version: 0.8.4, lastmod: 2006-12-09
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -814,17 +814,29 @@ in yet). ...@@ -814,17 +814,29 @@ in yet).
.IP .IP
If the string is, e.g. WAIT:0.0 or WAIT:1, i.e. "WAIT" If the string is, e.g. WAIT:0.0 or WAIT:1, i.e. "WAIT"
in front of a normal X display, then that indicated in front of a normal X display, then that indicated
display is used. A more interesting case is like this: display is used.
.IP
One can also insert a geometry between colons, e.g.
WAIT:1280x1024:... to set the size of the display the
VNC client first attaches to since some VNC viewers
will not automatically adjust to a new framebuffer size.
.IP
A more interesting case is like this:
.IP .IP
WAIT:cmd=/usr/local/bin/find_display WAIT:cmd=/usr/local/bin/find_display
.IP .IP
in which case the command after "cmd=" is run to in which case the command after "cmd=" is run to
dynamically work out the DISPLAY and optionally the dynamically work out the DISPLAY and optionally the
XAUTHORITY data. The first line of the command output XAUTHORITY data. The first line of the command output
must be of the form DISPLAY=<xdisplay>. Any remaining must be of the form DISPLAY=<xdisplay>. On Linux
output is taken as XAUTHORITY data. It can be either if the virtual terminal is known append ",VT=n" to
of the form XAUTHORITY=<file> or raw xauthority data for this string and the
the display (e.g. "xauth extract - $DISPLAY" output). .IR chvt (1)
program will also be run.
Any remaining output is taken as XAUTHORITY data.
It can be either of the form XAUTHORITY=<file> or raw
xauthority data for the display (e.g. "xauth extract -
$DISPLAY" output).
.IP .IP
In the case of \fB-unixpw\fR (but not \fB-unixpw_nis),\fR then the In the case of \fB-unixpw\fR (but not \fB-unixpw_nis),\fR then the
above command is run as the user who just authenticated above command is run as the user who just authenticated
...@@ -879,6 +891,7 @@ script that works on most Unixes to determine a user's ...@@ -879,6 +891,7 @@ script that works on most Unixes to determine a user's
DISPLAY variable and xauthority data (see DISPLAY variable and xauthority data (see
.IR who (1) .IR who (1)
). ).
.IP
To have this default script printed to stdout (e.g. for To have this default script printed to stdout (e.g. for
customization) run with WAIT:cmd=FINDDISPLAY-print customization) run with WAIT:cmd=FINDDISPLAY-print
.IP .IP
...@@ -895,10 +908,51 @@ by client web browsers. For example: ...@@ -895,10 +908,51 @@ by client web browsers. For example:
Where /.../x11vnc is the full path to x11vnc. Where /.../x11vnc is the full path to x11vnc.
It is used in the Apache SSL-portal example (see FAQ). It is used in the Apache SSL-portal example (see FAQ).
.IP .IP
Finally, one can insert a geometry between colons, An experimental option is WAIT:cmd=FINDCREATEDISPLAY
e.g. WAIT:1280x1024:... to set the size of the display that is like FINDDISPLAY in that is uses the same method
the VNC client first attaches to since some VNC viewers to find an existing display. However, if it does not
will not automatically adjust to a new framebuffer size. find one it will try to *start* up an X server session
for the user. This is the only time x11vnc tries to
start up an X server.
.IP
By default FINDCREATEDISPLAY will try Xdummy and
then Xvfb. The Xdummy wrapper is part of the x11vnc
source code (x11vnc/misc/Xdummy) It should be available
in PATH and have run "Xdummy \fB-install"\fR once to create
the shared library. Xdummy requires root permission
and only works on Linux. Xvfb is available on most
platforms.
.IP
When x11vnc exits (i.e. user disconnects) the X server
session stays running in the background. Presumably the
FINDDISPLAY will find it next time. The user must exit
the X session in the usual way for it to terminate.
.IP
So this is a somewhat odd mode for x11vnc in that it
will start up and poll virtual X servers. This can
be used from, say,
.IR inetd (8)
to provide a means of
definitely getting a desktop (either real or virtual)
on the machine. E.g. a desktop service:
.IP
5915 stream tcp nowait root /usr/sbin/tcpd /.../x11vnc
\fB-inetd\fR \fB-q\fR \fB-http\fR \fB-ssl\fR SAVE \fB-unixpw\fR \fB-users\fR unixpw=\\
\fB-passwd\fR secret \fB-prog\fR /.../x11vnc \\
\fB-display\fR WAIT:cmd=FINDCREATEDISPLAY
.IP
Where /.../x11vnc is the full path to x11vnc.
.IP
Use WAIT:cmd=FINDCREATEDISPLAY-print to print out the
script used. You can specify the preferred order via
e.g., WAIT:cmd=FINDCREATEDISPLAY-Xdummy,Xvfb,X and/or
leave out ones you do not want. The the extra case "X"
means try to start up a real, hardware X server using
.IR xinit (1).
If there is already an X server running the
X case may only work on Linux (see
.IR startx (1)
).
.PP .PP
\fB-ssl\fR \fI[pem]\fR \fB-ssl\fR \fI[pem]\fR
.IP .IP
...@@ -2992,41 +3046,46 @@ Print debugging output for tiles, fb updates, etc. ...@@ -2992,41 +3046,46 @@ Print debugging output for tiles, fb updates, etc.
.PP .PP
\fB-snapfb\fR \fB-snapfb\fR
.IP .IP
Instead of polling the X display framebuffer (fb) for Instead of polling the X display framebuffer (fb)
changes, periodically copy all of X display fb into main for changes, periodically copy all of X display fb
memory and examine that copy for changes. Under some into main memory and examine that copy for changes.
circumstances this will improve interactive response, (This setting also applies for non-X \fB-rawfb\fR modes).
or at least make things look smoother, but in others Under some circumstances this will improve interactive
(most!) it will make the response worse. If the video response, or at least make things look smoother, but in
h/w fb is such that reading small tiles is very slow others (most!) it will make the response worse. If the
this mode could help. To keep the "framerate" up video h/w fb is such that reading small tiles is very
the screen size x bpp cannot be too large. Note that slow this mode could help. To keep the "framerate"
up the screen size x bpp cannot be too large. Note that
this mode is very wasteful of memory I/O resources this mode is very wasteful of memory I/O resources
(it makes full screen copies even if nothing changes). (it makes full screen copies even if nothing changes).
It may be of use in video capture-like applications, It may be of use in video capture-like applications,
or where window tearing is a problem. webcams, or where window tearing is a problem.
.PP .PP
\fB-rawfb\fR \fIstring\fR \fB-rawfb\fR \fIstring\fR
.IP .IP
Instead of polling X, poll the memory object specified Instead of polling X, poll the memory object specified
in \fIstring\fR. in \fIstring\fR.
.IP .IP
For shared memory segments string is of the
form: "shm:N@WxHxB" which specifies a shmid
N and framebuffer Width, Height, and Bits
per pixel.
.IP
For file polling to memory map For file polling to memory map
.IR mmap (2) .IR mmap (2)
a file use: a file use:
"map:/path/to/a/file@WxHxB", with WxHxB as above. "map:/path/to/a/file@WxHxB", with framebuffer Width,
"mmap:..." is the same. If there is trouble with mmap, Height, and Bits per pixel. "mmap:..." is the
use "file:/..." for slower same.
.IP
If there is trouble with mmap, use "file:/..."
for slower
.IR lseek (2) .IR lseek (2)
based reading. based reading. Use "snap:..."
Use "snap:..." to imply \fB-snapfb\fR mode and the "file:" to imply \fB-snapfb\fR mode and the "file:" access (this
access (this is for devices that only provide the fb is for devices that only provide the fb all at once).
all at once). .IP
For shared memory segments string is of the form:
"shm:N@WxHxB" which specifies a shmid N and with
WxHxB as above. See
.IR shmat (1)
and
.IR ipcs (1)
.IP .IP
If you do not supply a type "map" is assumed if If you do not supply a type "map" is assumed if
the file exists (see the next paragraphs for some the file exists (see the next paragraphs for some
...@@ -3053,7 +3112,7 @@ memory object. If the masks are not provided x11vnc ...@@ -3053,7 +3112,7 @@ memory object. If the masks are not provided x11vnc
guesses them based on the bpp. guesses them based on the bpp.
.IP .IP
Another optional suffix is the Bytes Per Line which in Another optional suffix is the Bytes Per Line which in
some cases is not WxHxB/4. Specify it as WxHxB-BPL some cases is not WxB/4. Specify it as WxHxB-BPL
e.g. 800x600x16-2048. This could be a normal width e.g. 800x600x16-2048. This could be a normal width
1024 at 16bpp fb, but only width 800 shows up. 1024 at 16bpp fb, but only width 800 shows up.
.IP .IP
...@@ -3095,11 +3154,11 @@ mouse and keyboard input are STILL sent to the X ...@@ -3095,11 +3154,11 @@ mouse and keyboard input are STILL sent to the X
display, this usage should be very rare, i.e. doing display, this usage should be very rare, i.e. doing
something strange with /dev/fb0. something strange with /dev/fb0.
.IP .IP
If the device is not "seekable" try reading it all If the device is not "seekable" (e.g. webcam) try
at once in full snaps via the "snap:" mode (note: reading it all at once in full snaps via the "snap:"
this is a resource hog). If you are using file: or mode (note: this is a resource hog). If you are using
map: and the device needs to be reopened for *every* file: or map: and the device needs to be reopened for
snapfb snapshot, set the environment variable: *every* snapfb snapshot, set the environment variable:
SNAPFB_RAWFB_RESET=1 as well. SNAPFB_RAWFB_RESET=1 as well.
.IP .IP
If you want x11vnc to dynamically transform a 24bpp If you want x11vnc to dynamically transform a 24bpp
......
...@@ -1580,10 +1580,15 @@ int main(int argc, char* argv[]) { ...@@ -1580,10 +1580,15 @@ int main(int argc, char* argv[]) {
use_dpy = strdup(argv[++i]); use_dpy = strdup(argv[++i]);
if (strstr(use_dpy, "WAIT")) { if (strstr(use_dpy, "WAIT")) {
extern char find_display[]; extern char find_display[];
extern char create_display[];
if (strstr(use_dpy, "cmd=FINDDISPLAY-print")) { if (strstr(use_dpy, "cmd=FINDDISPLAY-print")) {
fprintf(stdout, "%s", find_display); fprintf(stdout, "%s", find_display);
exit(0); exit(0);
} }
if (strstr(use_dpy, "cmd=FINDCREATEDISPLAY-print")) {
fprintf(stdout, "%s", create_display);
exit(0);
}
} }
} else if (!strcmp(arg, "-auth") || !strcmp(arg, "-xauth")) { } else if (!strcmp(arg, "-auth") || !strcmp(arg, "-xauth")) {
CHECK_ARGC CHECK_ARGC
......
...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; ...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.8.4 lastmod: 2006-11-23"; char lastmod[] = "0.8.4 lastmod: 2006-12-09";
/* X display info */ /* X display info */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment