Commit 3129ef66 authored by runge's avatar runge

Huge number of changes, see x11vnc/ChangeLog

parent 169ef3a0
...@@ -73,8 +73,8 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto ...@@ -73,8 +73,8 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto
serverMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0'); serverMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0');
diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSLSocketToMe.java diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSLSocketToMe.java
--- vnc_javasrc.orig/SSLSocketToMe.java 1969-12-31 19:00:00.000000000 -0500 --- vnc_javasrc.orig/SSLSocketToMe.java 1969-12-31 19:00:00.000000000 -0500
+++ vnc_javasrc/SSLSocketToMe.java 2009-06-19 10:23:50.000000000 -0400 +++ vnc_javasrc/SSLSocketToMe.java 2009-08-13 09:16:42.000000000 -0400
@@ -0,0 +1,1726 @@ @@ -0,0 +1,1727 @@
+/* +/*
+ * SSLSocketToMe.java: add SSL encryption to Java VNC Viewer. + * SSLSocketToMe.java: add SSL encryption to Java VNC Viewer.
+ * + *
...@@ -83,7 +83,8 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSL ...@@ -83,7 +83,8 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSL
+ * + *
+ * This is free software; you can redistribute it and/or modify + * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by + * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; version 2 of the License, or
+ * (at your option) any later version.
+ * + *
+ * This software is distributed in the hope that it will be useful, + * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of + * but WITHOUT ANY WARRANTY; without even the implied warranty of
......
2009-10-08 Karl Runge <runge@karlrunge.com>
* x11vnc: bcx_xattach/x2x desktop switching facility.
More remote control features: grab_state, ping:mystring,
grablocal, resend_cutbuffer, resend_clipboard, resend_primary,
keycode, keysym, ptr, sleep, get_xprop, set_xprop, wininfo,
pointer_pos, mouse_xy, noop, guess_dbus Add DIRECT: for
remote control w/o server. X11VNC_NO_CHECK_PM for more
quiet DIRECT: usage. Options -query_retries, -remote_prefix,
and X11VNC_SYNC_TIMEOUT for remote control. Add scripting
to remote control. ping clients during in unixpw login.
Option -unixpw_system_greeter as shortcut to XDM/GDM/etc panel.
Add clear_all, viewonly, nodisplay, to unixpw username:opts.
F1 help for options (including smaller console font).
Document FD_TAG. Eat multiple property change events in one
sitting (also PROP_DBG=1). Support more -ssl features (special
cert names, single port, client certs, etc.) in -stunnel
external SSL helper mode. Reorganize openssl code to allow
integration with stunnel features if not compiled with openssl.
X11VNC_HTTPS_VS_VNC_TIMEOUT Fix dbus session address for -solid
in gnome. Use dbus-launch in -create mode if available.
X11VNC_SKIP_DISPLAY=all in -find/-create mode. let noxauth
unset XAUTHORITY for use with su - $USER. CREATE_DISPLAY_EXEC
debugging. Add x_terminal_emulator to -create cmd search.
Option -extra_fbur to tune fb update requests tracking; make
default tracking more aggressive. RATE_VERB/CHECK_RATE env. for
fbur rate. Env. vars to set Tk gui fonts. Catch closed
socket reads/writes. Try to detect 'crazy' xdamage insertion,
e.g. from some xscreensavers (needs work.). Don't switch
on server autorepeat if any keys are pressed down to work
around Xorg server and/or gnome bug. If PATH is empty, set
it to minimal one. Fix bug with -bg and -dp/-dk printout if
logfile present.
* classes/ssl: license statement.
2009-06-18 Karl Runge <runge@karlrunge.com> 2009-06-18 Karl Runge <runge@karlrunge.com>
* classes/ssl: java viewer now handles auth-basic proxy logins. * classes/ssl: java viewer now handles auth-basic proxy logins.
* misc/enhanced_tightvnc_viewer: update ssvnc. * misc/enhanced_tightvnc_viewer: update ssvnc.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -72,5 +72,10 @@ extern int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *in ...@@ -72,5 +72,10 @@ extern int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *in
int len, FILE *output); int len, FILE *output);
extern int check_access(char *addr); extern int check_access(char *addr);
extern void client_set_net(rfbClientPtr client); extern void client_set_net(rfbClientPtr client);
extern char *get_xprop(char *prop, Window win);
extern int set_xprop(char *prop, Window win, char *value);
extern char *bcx_xattach(char *str, int *pg_init, int *kg_init);
extern void grab_state(int *ptr_grabbed, int *kbd_grabbed);
extern char *wininfo(Window win, int show_children);
#endif /* _X11VNC_CONNECTIONS_H */ #endif /* _X11VNC_CONNECTIONS_H */
...@@ -71,7 +71,8 @@ so, delete this exception statement from your version. ...@@ -71,7 +71,8 @@ so, delete this exception statement from your version.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License. * the Free Software Foundation; version 2 of the License, or (at
* your option) any later version.
* *
* This software is distributed in the hope that it will be useful, * This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
......
This diff is collapsed.
...@@ -2045,7 +2045,7 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym, ...@@ -2045,7 +2045,7 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym,
* why nothing needs to be done with the modifier, see below. * why nothing needs to be done with the modifier, see below.
* *
* sentmods[] is the corresponding keycode to use * sentmods[] is the corresponding keycode to use
* to acheive the needmods[] requirement for the bit. * to achieve the needmods[] requirement for the bit.
*/ */
for (i=0; i<8; i++) { for (i=0; i<8; i++) {
...@@ -2780,6 +2780,11 @@ void get_allowed_input(rfbClientPtr client, allowed_input_t *input) { ...@@ -2780,6 +2780,11 @@ void get_allowed_input(rfbClientPtr client, allowed_input_t *input) {
input->files = 0; input->files = 0;
if (! client) { if (! client) {
input->keystroke = 1;
input->motion = 1;
input->button = 1;
input->clipboard = 1;
input->files = 1;
return; return;
} }
......
...@@ -55,6 +55,8 @@ int unixpw = 0; /* -unixpw */ ...@@ -55,6 +55,8 @@ int unixpw = 0; /* -unixpw */
int unixpw_nis = 0; /* -unixpw_nis */ int unixpw_nis = 0; /* -unixpw_nis */
char *unixpw_list = NULL; char *unixpw_list = NULL;
char *unixpw_cmd = NULL; char *unixpw_cmd = NULL;
int unixpw_system_greeter = 0;
int unixpw_system_greeter_active = 0;
int use_stunnel = 0; /* -stunnel */ int use_stunnel = 0; /* -stunnel */
int stunnel_port = 0; int stunnel_port = 0;
char *stunnel_pem = NULL; char *stunnel_pem = NULL;
...@@ -70,6 +72,8 @@ int vencrypt_enable_plain_login = 0; ...@@ -70,6 +72,8 @@ int vencrypt_enable_plain_login = 0;
int anontls_mode = ANONTLS_SUPPORT; int anontls_mode = ANONTLS_SUPPORT;
int create_fresh_dhparams = 0; int create_fresh_dhparams = 0;
char *dhparams_file = NULL; char *dhparams_file = NULL;
int http_try_it = 0;
int stunnel_http_port = 0;
int https_port_num = -1; int https_port_num = -1;
int https_port_redir = 0; int https_port_redir = 0;
char *ssl_verify = NULL; char *ssl_verify = NULL;
...@@ -112,6 +116,8 @@ int deny_all = 0; /* global locking of new clients */ ...@@ -112,6 +116,8 @@ int deny_all = 0; /* global locking of new clients */
#define REMOTE_DEFAULT 1 #define REMOTE_DEFAULT 1
#endif #endif
int accept_remote_cmds = REMOTE_DEFAULT; /* -noremote */ int accept_remote_cmds = REMOTE_DEFAULT; /* -noremote */
char *remote_prefix = NULL;
int remote_direct = 0;
int query_default = 0; int query_default = 0;
int safe_remote_only = 1; /* -unsafe */ int safe_remote_only = 1; /* -unsafe */
int priv_remote = 0; /* -privremote */ int priv_remote = 0; /* -privremote */
...@@ -402,6 +408,7 @@ double wait_ui = 2.0; ...@@ -402,6 +408,7 @@ double wait_ui = 2.0;
double slow_fb = 0.0; double slow_fb = 0.0;
double xrefresh = 0.0; double xrefresh = 0.0;
int wait_bog = 1; int wait_bog = 1;
int extra_fbur = 1;
int defer_update = 20; /* deferUpdateTime ms to wait before sends. */ int defer_update = 20; /* deferUpdateTime ms to wait before sends. */
int set_defer = 1; int set_defer = 1;
int got_defer = 0; int got_defer = 0;
......
...@@ -55,6 +55,8 @@ extern int unixpw; ...@@ -55,6 +55,8 @@ extern int unixpw;
extern int unixpw_nis; extern int unixpw_nis;
extern char *unixpw_list; extern char *unixpw_list;
extern char *unixpw_cmd; extern char *unixpw_cmd;
extern int unixpw_system_greeter;
extern int unixpw_system_greeter_active;
extern int use_stunnel; extern int use_stunnel;
extern int stunnel_port; extern int stunnel_port;
extern char *stunnel_pem; extern char *stunnel_pem;
...@@ -70,6 +72,8 @@ extern int vencrypt_enable_plain_login; ...@@ -70,6 +72,8 @@ extern int vencrypt_enable_plain_login;
extern int anontls_mode; extern int anontls_mode;
extern int create_fresh_dhparams; extern int create_fresh_dhparams;
extern char *dhparams_file; extern char *dhparams_file;
extern int http_try_it;
extern int stunnel_http_port;
extern int https_port_num; extern int https_port_num;
extern int https_port_redir; extern int https_port_redir;
extern char *ssl_verify; extern char *ssl_verify;
...@@ -100,6 +104,8 @@ extern int connect_once; ...@@ -100,6 +104,8 @@ extern int connect_once;
extern int got_connect_once; extern int got_connect_once;
extern int deny_all; extern int deny_all;
extern int accept_remote_cmds; extern int accept_remote_cmds;
extern char *remote_prefix;
extern int remote_direct;
extern int query_default; extern int query_default;
extern int safe_remote_only; extern int safe_remote_only;
extern int priv_remote; extern int priv_remote;
...@@ -307,6 +313,7 @@ extern double wait_ui; ...@@ -307,6 +313,7 @@ extern double wait_ui;
extern double slow_fb; extern double slow_fb;
extern double xrefresh; extern double xrefresh;
extern int wait_bog; extern int wait_bog;
extern int extra_fbur;
extern int defer_update; extern int defer_update;
extern int set_defer; extern int set_defer;
extern int got_defer; extern int got_defer;
......
...@@ -63,8 +63,8 @@ so, delete this exception statement from your version. ...@@ -63,8 +63,8 @@ so, delete this exception statement from your version.
#define FB_REQ 0x4 #define FB_REQ 0x4
#define VNC_CONNECT_MAX 16384 #define VNC_CONNECT_MAX 16384
#define X11VNC_REMOTE_MAX 16384 #define X11VNC_REMOTE_MAX 65536
#define PROP_MAX (131072L) #define PROP_MAX (262144L)
#define MAXN 256 #define MAXN 256
......
This diff is collapsed.
...@@ -44,4 +44,7 @@ extern void http_connections(int on); ...@@ -44,4 +44,7 @@ extern void http_connections(int on);
extern int remote_control_access_ok(void); extern int remote_control_access_ok(void);
extern char *process_remote_cmd(char *cmd, int stringonly); extern char *process_remote_cmd(char *cmd, int stringonly);
extern char *query_result;
#endif /* _X11VNC_REMOTE_H */ #endif /* _X11VNC_REMOTE_H */
...@@ -1179,6 +1179,8 @@ static char* vnc_reflect_get_password(rfbClient* client) { ...@@ -1179,6 +1179,8 @@ static char* vnc_reflect_get_password(rfbClient* client) {
char *q, *p, *str = getenv("X11VNC_REFLECT_PASSWORD"); char *q, *p, *str = getenv("X11VNC_REFLECT_PASSWORD");
int len = 110; int len = 110;
if (client) {}
if (str) { if (str) {
len += 2*strlen(str); len += 2*strlen(str);
} }
...@@ -2846,10 +2848,16 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -2846,10 +2848,16 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
/* n.b. samplesPerPixel (set = 1 here) seems to be unused. */ /* n.b. samplesPerPixel (set = 1 here) seems to be unused. */
if (create_screen) { if (create_screen) {
if (use_stunnel) {
setup_stunnel(0, argc, argv);
}
if (use_openssl) { if (use_openssl) {
if (use_stunnel && enc_str && !strcmp(enc_str, "none")) {
/* emulating HTTPS oneport */
;
} else {
openssl_init(0); openssl_init(0);
} else if (use_stunnel) { }
setup_stunnel(0, argc, argv);
} }
screen = rfbGetScreen(argc, argv, width, height, screen = rfbGetScreen(argc, argv, width, height,
bits_per_color, 1, fb_bpp/8); bits_per_color, 1, fb_bpp/8);
...@@ -3367,6 +3375,10 @@ void announce(int lport, int ssl, char *iface) { ...@@ -3367,6 +3375,10 @@ void announce(int lport, int ssl, char *iface) {
char *host = this_host(); char *host = this_host();
char *tvdt; char *tvdt;
if (remote_direct) {
return;
}
if (! ssl) { if (! ssl) {
tvdt = "The VNC desktop is: "; tvdt = "The VNC desktop is: ";
} else { } else {
...@@ -3422,12 +3434,12 @@ void announce(int lport, int ssl, char *iface) { ...@@ -3422,12 +3434,12 @@ void announce(int lport, int ssl, char *iface) {
} }
} }
static void announce_http(int lport, int ssl, char *iface) { static void announce_http(int lport, int ssl, char *iface, char *extra) {
char *host = this_host(); char *host = this_host();
char *jvu; char *jvu;
if (enc_str && !strcmp(enc_str, "none")) { if (enc_str && !strcmp(enc_str, "none") && !use_stunnel) {
jvu = "Java viewer URL: http"; jvu = "Java viewer URL: http";
} else if (ssl == 1) { } else if (ssl == 1) {
jvu = "Java SSL viewer URL: https"; jvu = "Java SSL viewer URL: https";
...@@ -3442,28 +3454,59 @@ static void announce_http(int lport, int ssl, char *iface) { ...@@ -3442,28 +3454,59 @@ static void announce_http(int lport, int ssl, char *iface) {
} }
if (host != NULL) { if (host != NULL) {
if (! inetd) { if (! inetd) {
fprintf(stderr, "%s://%s:%d/\n", jvu, host, lport); fprintf(stderr, "%s://%s:%d/%s\n", jvu, host, lport, extra);
if (screen && enc_str && !strcmp(enc_str, "none")) {
fprintf(stderr, "%s://%s:%d/\n", jvu, host, screen->port);
}
} }
} }
} }
void set_vnc_desktop_name(void) { void do_announce_http(void) {
sprintf(vnc_desktop_name, "unknown"); if (!screen) {
if (inetd) { return;
sprintf(vnc_desktop_name, "%s/inetd-no-further-clients", }
this_host()); if (remote_direct) {
return;
} }
if (screen->port) {
if (! quiet) { if (screen->httpListenSock > -1 && screen->httpPort) {
int enc_none = (enc_str && !strcmp(enc_str, "none"));
char *SPORT = " (single port)";
if (use_openssl && ! enc_none) {
announce_http(screen->port, 1, listen_str, SPORT);
if (https_port_num >= 0) {
announce_http(https_port_num, 1,
listen_str, "");
}
announce_http(screen->httpPort, 2, listen_str, "");
} else if (use_stunnel) {
char pmsg[100];
pmsg[0] = '\0';
if (stunnel_port) {
sprintf(pmsg, "?PORT=%d", stunnel_port);
}
announce_http(screen->httpPort, 2, listen_str, pmsg);
if (stunnel_http_port > 0) {
announce_http(stunnel_http_port, 1, NULL, pmsg);
}
if (enc_none) {
strcat(pmsg, SPORT);
announce_http(stunnel_port, 1, NULL, pmsg);
}
} else {
announce_http(screen->httpPort, 0, listen_str, "");
if (enc_none) {
announce_http(screen->port, 1, NULL, SPORT);
}
}
}
}
void do_mention_java_urls(void) {
if (! quiet && screen) {
if (screen->httpListenSock > -1 && screen->httpPort) { if (screen->httpListenSock > -1 && screen->httpPort) {
rfbLog("\n"); rfbLog("\n");
rfbLog("The URLs printed out below ('Java ... viewer URL') can\n"); rfbLog("The URLs printed out below ('Java ... viewer URL') can\n");
rfbLog("be used for Java enabled Web browser connections.\n"); rfbLog("be used for Java enabled Web browser connections.\n");
if (enc_str && !strcmp(enc_str, "none")) { if (!stunnel_port && enc_str && !strcmp(enc_str, "none")) {
; ;
} else if (use_openssl || stunnel_port) { } else if (use_openssl || stunnel_port) {
rfbLog("Here are some additional possibilities:\n"); rfbLog("Here are some additional possibilities:\n");
...@@ -3476,10 +3519,26 @@ void set_vnc_desktop_name(void) { ...@@ -3476,10 +3519,26 @@ void set_vnc_desktop_name(void) {
rfbLog("\n"); rfbLog("\n");
rfbLog("Where you replace \"host:port\" with that printed below, or\n"); rfbLog("Where you replace \"host:port\" with that printed below, or\n");
rfbLog("whatever is needed to reach the host e.g. Internet IP number\n"); rfbLog("whatever is needed to reach the host e.g. Internet IP number\n");
rfbLog("\n");
rfbLog("Append ?GET=1 to a URL for faster loading.\n");
} }
} }
rfbLog("\n"); rfbLog("\n");
} }
}
void set_vnc_desktop_name(void) {
sprintf(vnc_desktop_name, "unknown");
if (inetd) {
sprintf(vnc_desktop_name, "%s/inetd-no-further-clients",
this_host());
}
if (remote_direct) {
return;
}
if (screen->port) {
do_mention_java_urls();
if (use_openssl) { if (use_openssl) {
announce(screen->port, 1, listen_str); announce(screen->port, 1, listen_str);
...@@ -3489,24 +3548,8 @@ void set_vnc_desktop_name(void) { ...@@ -3489,24 +3548,8 @@ void set_vnc_desktop_name(void) {
if (stunnel_port) { if (stunnel_port) {
announce(stunnel_port, 1, NULL); announce(stunnel_port, 1, NULL);
} }
if (screen->httpListenSock > -1 && screen->httpPort) {
if (use_openssl) { do_announce_http();
if (enc_str && !strcmp(enc_str, "none")) {
;
} else {
announce_http(screen->port, 1, listen_str);
}
if (https_port_num >= 0) {
announce_http(https_port_num, 1,
listen_str);
}
announce_http(screen->httpPort, 2, listen_str);
} else if (use_stunnel) {
announce_http(screen->httpPort, 2, listen_str);
} else {
announce_http(screen->httpPort, 0, listen_str);
}
}
fflush(stderr); fflush(stderr);
if (inetd) { if (inetd) {
...@@ -3954,13 +3997,19 @@ void watch_loop(void) { ...@@ -3954,13 +3997,19 @@ void watch_loop(void) {
* see quickly (just 1 rfbPE will likely * see quickly (just 1 rfbPE will likely
* only process the subsequent "up" event) * only process the subsequent "up" event)
*/ */
if (tm < last_keyboard_time + 0.16) { if (tm < last_keyboard_time + 0.20) {
rfbPE(0); rfbPE(0);
rfbPE(0); rfbPE(0);
rfbPE(-1); rfbPE(-1);
rfbPE(0); rfbPE(0);
rfbPE(0); rfbPE(0);
} else { } else {
if (extra_fbur > 0) {
int i;
for (i=0; i < extra_fbur; i++) {
rfbPE(0);
}
}
rfbPE(-1); rfbPE(-1);
} }
if (x11vnc_current < last_new_client + 0.5) { if (x11vnc_current < last_new_client + 0.5) {
...@@ -4126,6 +4175,7 @@ void watch_loop(void) { ...@@ -4126,6 +4175,7 @@ void watch_loop(void) {
} else { } else {
static double last_dt = 0.0; static double last_dt = 0.0;
double xdamage_thrash = 0.4; double xdamage_thrash = 0.4;
static int tilecut = -1;
check_cursor_changes(); check_cursor_changes();
...@@ -4176,8 +4226,15 @@ void watch_loop(void) { ...@@ -4176,8 +4226,15 @@ void watch_loop(void) {
last_dt = dt; last_dt = dt;
} }
if (tilecut < 0) {
if (getenv("TILECUT")) {
tilecut = atoi(getenv("TILECUT"));
}
if (tilecut < 0) tilecut = 4;
}
if ((debug_tiles || debug_scroll > 1 || debug_wireframe > 1) if ((debug_tiles || debug_scroll > 1 || debug_wireframe > 1)
&& (tile_diffs > 4 || debug_tiles > 1)) { && (tile_diffs > tilecut || debug_tiles > 1)) {
double rate = (tile_x * tile_y * bpp/8 * tile_diffs) / dt; double rate = (tile_x * tile_y * bpp/8 * tile_diffs) / dt;
fprintf(stderr, "============================= TILES: %d dt: %.4f" fprintf(stderr, "============================= TILES: %d dt: %.4f"
" t: %.4f %.2f MB/s nap_ok: %d\n", tile_diffs, dt, " t: %.4f %.2f MB/s nap_ok: %d\n", tile_diffs, dt,
...@@ -4188,13 +4245,33 @@ void watch_loop(void) { ...@@ -4188,13 +4245,33 @@ void watch_loop(void) {
/* sleep a bit to lessen load */ /* sleep a bit to lessen load */
wait = choose_delay(dt); wait = choose_delay(dt);
if (urgent_update) { if (urgent_update) {
; ;
} else if (wait > 2*waitms) { } else if (wait > 2*waitms) {
/* bog case, break it up */ /* bog case, break it up */
nap_sleep(wait, 10); nap_sleep(wait, 10);
} else { } else {
double t1, t2;
int idt;
if (extra_fbur > 0) {
int i;
for (i=0; i <= extra_fbur; i++) {
int r = rfbPE(0);
if (!r) break;
}
}
/* sometimes the sleep is too short, so measure it: */
t1 = dnow();
usleep(wait * 1000); usleep(wait * 1000);
t2 = dnow();
idt = (int) (1000. * (t2 - t1));
if (idt > 0 && idt < wait) {
/* try to sleep the remainder */
usleep((wait - idt) * 1000);
}
} }
cnt++; cnt++;
......
...@@ -64,6 +64,7 @@ void selection_request(XEvent *ev, char *type); ...@@ -64,6 +64,7 @@ void selection_request(XEvent *ev, char *type);
int check_sel_direction(char *dir, char *label, char *sel, int len); int check_sel_direction(char *dir, char *label, char *sel, int len);
void cutbuffer_send(void); void cutbuffer_send(void);
void selection_send(XEvent *ev); void selection_send(XEvent *ev);
void resend_selection(char *type);
/* /*
...@@ -76,6 +77,9 @@ void selection_send(XEvent *ev); ...@@ -76,6 +77,9 @@ void selection_send(XEvent *ev);
static char cutbuffer_str[PROP_MAX+1]; static char cutbuffer_str[PROP_MAX+1];
static char primary_str[PROP_MAX+1]; static char primary_str[PROP_MAX+1];
static char clipboard_str[PROP_MAX+1]; static char clipboard_str[PROP_MAX+1];
static int cutbuffer_len = 0;
static int primary_len = 0;
static int clipboard_len = 0;
/* /*
* An X11 (not VNC) client on the local display has requested the selection * An X11 (not VNC) client on the local display has requested the selection
...@@ -346,7 +350,7 @@ void cutbuffer_send(void) { ...@@ -346,7 +350,7 @@ void cutbuffer_send(void) {
if (!screen) { if (!screen) {
return; return;
} }
len = strlen(cutbuffer_str); cutbuffer_len = len = strlen(cutbuffer_str);
if (check_sel_direction("send", "cutbuffer_send", cutbuffer_str, len)) { if (check_sel_direction("send", "cutbuffer_send", cutbuffer_str, len)) {
rfbSendServerCutText(screen, cutbuffer_str, len); rfbSendServerCutText(screen, cutbuffer_str, len);
} }
...@@ -492,6 +496,49 @@ if (debug_sel) fprintf(stderr, "selection_send: data: '%s' dlen: %d nitems: %lu ...@@ -492,6 +496,49 @@ if (debug_sel) fprintf(stderr, "selection_send: data: '%s' dlen: %d nitems: %lu
} }
len = newlen; len = newlen;
if (ev->xselection.selection == XA_PRIMARY) {
primary_len = len;
} else if (clipboard_atom && ev->xselection.selection == clipboard_atom) {
clipboard_len = len;
}
if (check_sel_direction("send", "selection_send", selection_str, len)) {
rfbSendServerCutText(screen, selection_str, len);
}
#endif /* NO_X11 */
}
void resend_selection(char *type) {
#if NO_X11
RAWFB_RET_VOID
if (!type) {}
return;
#else
char *selection_str = "";
int len = 0;
RAWFB_RET_VOID
if (! all_clients_initialized()) {
rfbLog("selection_send: no send: uninitialized clients\n");
return; /* some clients initializing, cannot send */
}
if (unixpw_in_progress) {
return;
}
if (!screen) {
return;
}
if (!strcmp(type, "cutbuffer")) {
selection_str = cutbuffer_str;
len = cutbuffer_len;
} else if (!strcmp(type, "clipboard")) {
selection_str = clipboard_str;
len = clipboard_len;
} else if (!strcmp(type, "primary")) {
selection_str = primary_str;
len = primary_len;
}
if (check_sel_direction("send", "selection_send", selection_str, len)) { if (check_sel_direction("send", "selection_send", selection_str, len)) {
rfbSendServerCutText(screen, selection_str, len); rfbSendServerCutText(screen, selection_str, len);
} }
......
...@@ -50,5 +50,6 @@ extern void selection_request(XEvent *ev, char *type); ...@@ -50,5 +50,6 @@ extern void selection_request(XEvent *ev, char *type);
extern int check_sel_direction(char *dir, char *label, char *sel, int len); extern int check_sel_direction(char *dir, char *label, char *sel, int len);
extern void cutbuffer_send(void); extern void cutbuffer_send(void);
extern void selection_send(XEvent *ev); extern void selection_send(XEvent *ev);
extern void resend_selection(char *type);
#endif /* _X11VNC_SELECTION_H */ #endif /* _X11VNC_SELECTION_H */
...@@ -37,9 +37,11 @@ so, delete this exception statement from your version. ...@@ -37,9 +37,11 @@ so, delete this exception statement from your version.
#include "xwrappers.h" #include "xwrappers.h"
#include "connections.h" #include "connections.h"
#include "cleanup.h" #include "cleanup.h"
#include "xevents.h"
char *guess_desktop(void); char *guess_desktop(void);
void solid_bg(int restore); void solid_bg(int restore);
char *dbus_session(void);
static void usr_bin_path(int restore); static void usr_bin_path(int restore);
...@@ -550,32 +552,105 @@ static void solid_cde(char *color) { ...@@ -550,32 +552,105 @@ static void solid_cde(char *color) {
#endif /* NO_X11 */ #endif /* NO_X11 */
} }
static char _dbus_str[1100];
char *dbus_session(void) {
char *dbus_env = getenv("DBUS_SESSION_BUS_ADDRESS");
char tmp[1000];
if (dbus_env != NULL && strlen(dbus_env) > 0) {
return "";
}
#if NO_X11
return "";
#else
{
Atom dbus_prop;
Window r, w, *children;
unsigned int ui;
int rc, i;
memset(_dbus_str, 0, sizeof(_dbus_str));
X_LOCK;
dbus_prop = XInternAtom(dpy, "_DBUS_SESSION_BUS_ADDRESS", True);
X_UNLOCK;
if (dbus_prop == None) {
return "";
}
X_LOCK;
memset(tmp, 0, sizeof(tmp));
get_prop(tmp, sizeof(tmp)-1, dbus_prop, None);
X_UNLOCK;
if (strcmp(tmp, "")) {
if (!strchr(tmp, '\'')) {
sprintf(_dbus_str, "env DBUS_SESSION_BUS_ADDRESS='%s'", tmp);
return _dbus_str;
}
}
X_LOCK;
rc = XQueryTree_wr(dpy, rootwin, &r, &w, &children, &ui);
X_UNLOCK;
if (!rc || children == NULL || ui == 0) {
return "";
}
for (i=0; i < ui; i++) {
X_LOCK;
memset(tmp, 0, sizeof(tmp));
get_prop(tmp, sizeof(tmp)-1, dbus_prop, children[i]);
X_UNLOCK;
if (strcmp(tmp, "")) {
if (!strchr(tmp, '\'')) {
sprintf(_dbus_str, "env DBUS_SESSION_BUS_ADDRESS='%s'", tmp);
break;
}
}
}
X_LOCK;
XFree_wr(children);
X_UNLOCK;
return _dbus_str;
}
#endif
}
static void solid_gnome(char *color) { static void solid_gnome(char *color) {
#if NO_X11 #if NO_X11
RAWFB_RET_VOID RAWFB_RET_VOID
if (!color) {} if (!color) {}
return; return;
#else #else
char get_color[] = "gconftool-2 --get " char get_color[] = "%s gconftool-2 --get "
"/desktop/gnome/background/primary_color"; "/desktop/gnome/background/primary_color";
char set_color[] = "gconftool-2 --set " char set_color[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/primary_color --type string '%s'"; "/desktop/gnome/background/primary_color '%s'";
char get_option[] = "gconftool-2 --get " char get_option[] = "%s gconftool-2 --get "
"/desktop/gnome/background/picture_options"; "/desktop/gnome/background/picture_options";
char set_option[] = "gconftool-2 --set " char set_option[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/picture_options --type string '%s'"; "/desktop/gnome/background/picture_options '%s'";
#if 0 #if 0
char get_filename[] = "gconftool-2 --get " char get_shading[] = "%s gconftool-2 --get "
"/desktop/gnome/background/color_shading_type";
char set_shading[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/color_shading_type '%s'";
char get_filename[] = "%s gconftool-2 --get "
"/desktop/gnome/background/picture_filename"; "/desktop/gnome/background/picture_filename";
char set_filename[] = "gconftool-2 --set " char set_filename[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/picture_filename --type string '%s'"; "/desktop/gnome/background/picture_filename '%s'";
#endif #endif
static char *orig_color = NULL; static char *orig_color = NULL;
static char *orig_option = NULL; static char *orig_option = NULL;
char *cmd; char *cmd, *dbus = "";
RAWFB_RET_VOID RAWFB_RET_VOID
dbus = dbus_session();
rfbLog("guessed dbus: %s\n", dbus);
if (! color) { if (! color) {
if (! orig_color) { if (! orig_color) {
orig_color = strdup("#FFFFFF"); orig_color = strdup("#FFFFFF");
...@@ -591,14 +666,12 @@ static void solid_gnome(char *color) { ...@@ -591,14 +666,12 @@ static void solid_gnome(char *color) {
rfbLog("invalid option: %s\n", orig_option); rfbLog("invalid option: %s\n", orig_option);
return; return;
} }
cmd = (char *) malloc(strlen(set_option) - 2 + cmd = (char *) malloc(strlen(set_option) - 2 + strlen(orig_option) + strlen(dbus) + 1);
strlen(orig_option) + 1); sprintf(cmd, set_option, dbus, orig_option);
sprintf(cmd, set_option, orig_option);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
cmd = (char *) malloc(strlen(set_color) - 2 + cmd = (char *) malloc(strlen(set_color) - 2 + strlen(orig_color) + strlen(dbus) + 1);
strlen(orig_color) + 1); sprintf(cmd, set_color, dbus, orig_color);
sprintf(cmd, set_color, orig_color);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
return; return;
...@@ -607,7 +680,10 @@ static void solid_gnome(char *color) { ...@@ -607,7 +680,10 @@ static void solid_gnome(char *color) {
if (! orig_color) { if (! orig_color) {
char *q; char *q;
if (cmd_ok("dt")) { if (cmd_ok("dt")) {
orig_color = strdup(cmd_output(get_color)); cmd = (char *) malloc(strlen(get_color) + strlen(dbus) + 1);
sprintf(cmd, get_color, dbus);
orig_color = strdup(cmd_output(cmd));
free(cmd);
} else { } else {
orig_color = ""; orig_color = "";
} }
...@@ -621,7 +697,10 @@ static void solid_gnome(char *color) { ...@@ -621,7 +697,10 @@ static void solid_gnome(char *color) {
if (! orig_option) { if (! orig_option) {
char *q; char *q;
if (cmd_ok("dt")) { if (cmd_ok("dt")) {
orig_option = strdup(cmd_output(get_option)); cmd = (char *) malloc(strlen(get_option) + strlen(dbus) + 1);
sprintf(cmd, get_option, dbus);
orig_option = strdup(cmd_output(cmd));
free(cmd);
} else { } else {
orig_color = ""; orig_color = "";
} }
...@@ -636,19 +715,19 @@ static void solid_gnome(char *color) { ...@@ -636,19 +715,19 @@ static void solid_gnome(char *color) {
rfbLog("invalid color: %s\n", color); rfbLog("invalid color: %s\n", color);
return; return;
} }
cmd = (char *) malloc(strlen(set_color) + strlen(color) + 1); cmd = (char *) malloc(strlen(set_color) + strlen(color) + strlen(dbus) + 1);
sprintf(cmd, set_color, color); sprintf(cmd, set_color, dbus, color);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
cmd = (char *) malloc(strlen(set_option) + strlen("none") + 1); cmd = (char *) malloc(strlen(set_option) + strlen("none") + strlen(dbus) + 1);
sprintf(cmd, set_option, "none"); sprintf(cmd, set_option, dbus, "none");
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
#if 0 #if 0
cmd = (char *) malloc(strlen(set_filename) + strlen("none") + 1); cmd = (char *) malloc(strlen(set_filename) + strlen("none") + 1);
sprintf(cmd, set_filename, "none"); sprintf(cmd, set_filename, dbus, "none");
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
#endif #endif
......
...@@ -39,6 +39,7 @@ extern char *guess_desktop(void); ...@@ -39,6 +39,7 @@ extern char *guess_desktop(void);
extern unsigned long get_pixel(char *color); extern unsigned long get_pixel(char *color);
extern XImage *solid_image(char *color); extern XImage *solid_image(char *color);
extern void solid_bg(int restore); extern void solid_bg(int restore);
extern char *dbus_session(void);
extern XImage *solid_root(char *color); extern XImage *solid_root(char *color);
extern void kde_no_animate(int restore); extern void kde_no_animate(int restore);
extern void gnome_no_animate(void); extern void gnome_no_animate(void);
......
...@@ -49,7 +49,7 @@ so, delete this exception statement from your version. ...@@ -49,7 +49,7 @@ so, delete this exception statement from your version.
void check_stunnel(void); void check_stunnel(void);
int start_stunnel(int stunnel_port, int x11vnc_port); int start_stunnel(int stunnel_port, int x11vnc_port, int hport, int x11vnc_hport);
void stop_stunnel(void); void stop_stunnel(void);
void setup_stunnel(int rport, int *argc, char **argv); void setup_stunnel(int rport, int *argc, char **argv);
char *get_Cert_dir(char *cdir_in, char **tmp_in); char *get_Cert_dir(char *cdir_in, char **tmp_in);
...@@ -86,14 +86,14 @@ void check_stunnel(void) { ...@@ -86,14 +86,14 @@ void check_stunnel(void) {
} }
} }
int start_stunnel(int stunnel_port, int x11vnc_port) { int start_stunnel(int stunnel_port, int x11vnc_port, int hport, int x11vnc_hport) {
#ifdef SSLCMDS #ifdef SSLCMDS
char extra[] = ":/usr/sbin:/usr/local/sbin:/dist/sbin"; char extra[] = ":/usr/sbin:/usr/local/sbin:/dist/sbin";
char *path, *p, *exe; char *path, *p, *exe;
char *stunnel_path = NULL; char *stunnel_path = NULL;
struct stat verify_buf; struct stat verify_buf;
struct stat crl_buf; struct stat crl_buf;
int status; int status, tmp_pem = 0;
if (stunnel_pid) { if (stunnel_pid) {
stop_stunnel(); stop_stunnel();
...@@ -167,9 +167,33 @@ int start_stunnel(int stunnel_port, int x11vnc_port) { ...@@ -167,9 +167,33 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
" saved PEM.\n"); " saved PEM.\n");
clean_up_exit(1); clean_up_exit(1);
} }
} else if (!stunnel_pem) {
stunnel_pem = create_tmp_pem(NULL, 0);
if (! stunnel_pem) {
rfbLog("start_stunnel: could not create temporary,"
" self-signed PEM.\n");
clean_up_exit(1);
}
tmp_pem = 1;
if (getenv("X11VNC_SHOW_TMP_PEM")) {
FILE *in = fopen(stunnel_pem, "r");
if (in != NULL) {
char line[128];
fprintf(stderr, "\n");
while (fgets(line, 128, in) != NULL) {
fprintf(stderr, "%s", line);
}
fprintf(stderr, "\n");
fclose(in);
}
}
} }
if (ssl_verify) { if (ssl_verify) {
char *file = get_ssl_verify_file(ssl_verify);
if (file) {
ssl_verify = file;
}
if (stat(ssl_verify, &verify_buf) != 0) { if (stat(ssl_verify, &verify_buf) != 0) {
rfbLog("stunnel: %s does not exist.\n", ssl_verify); rfbLog("stunnel: %s does not exist.\n", ssl_verify);
clean_up_exit(1); clean_up_exit(1);
...@@ -245,6 +269,7 @@ int start_stunnel(int stunnel_port, int x11vnc_port) { ...@@ -245,6 +269,7 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
if (! in) { if (! in) {
exit(1); exit(1);
} }
fprintf(in, "foreground = yes\n"); fprintf(in, "foreground = yes\n");
fprintf(in, "pid =\n"); fprintf(in, "pid =\n");
if (stunnel_pem) { if (stunnel_pem) {
...@@ -263,7 +288,6 @@ int start_stunnel(int stunnel_port, int x11vnc_port) { ...@@ -263,7 +288,6 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
} else { } else {
fprintf(in, "CAfile = %s\n", ssl_verify); fprintf(in, "CAfile = %s\n", ssl_verify);
} }
/* XXX double check -v 2 */
fprintf(in, "verify = 2\n"); fprintf(in, "verify = 2\n");
} }
fprintf(in, ";debug = 7\n\n"); fprintf(in, ";debug = 7\n\n");
...@@ -271,18 +295,46 @@ int start_stunnel(int stunnel_port, int x11vnc_port) { ...@@ -271,18 +295,46 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
fprintf(in, "accept = %d\n", stunnel_port); fprintf(in, "accept = %d\n", stunnel_port);
fprintf(in, "connect = %d\n", x11vnc_port); fprintf(in, "connect = %d\n", x11vnc_port);
if (hport > 0 && x11vnc_hport > 0) {
fprintf(in, "\n[x11vnc_http]\n");
fprintf(in, "accept = %d\n", hport);
fprintf(in, "connect = %d\n", x11vnc_hport);
}
fflush(in); fflush(in);
rewind(in); rewind(in);
if (getenv("STUNNEL_DEBUG")) {
char line[1000];
fprintf(stderr, "\nstunnel config contents:\n\n");
while (fgets(line, sizeof(line), in) != NULL) {
fprintf(stderr, "%s", line);
}
fprintf(stderr, "\n");
rewind(in);
}
sprintf(fd, "%d", fileno(in)); sprintf(fd, "%d", fileno(in));
execlp(stunnel_path, stunnel_path, "-fd", fd, (char *) NULL); execlp(stunnel_path, stunnel_path, "-fd", fd, (char *) NULL);
exit(1); exit(1);
} }
free(exe); free(exe);
usleep(500 * 1000); usleep(750 * 1000);
waitpid(stunnel_pid, &status, WNOHANG); waitpid(stunnel_pid, &status, WNOHANG);
if (ssl_verify && strstr(ssl_verify, "/sslverify-tmp-load-")) {
/* temporary file */
usleep(1000 * 1000);
unlink(ssl_verify);
}
if (tmp_pem) {
/* temporary cert */
usleep(1500 * 1000);
unlink(stunnel_pem);
}
if (kill(stunnel_pid, 0) != 0) { if (kill(stunnel_pid, 0) != 0) {
waitpid(stunnel_pid, &status, WNOHANG); waitpid(stunnel_pid, &status, WNOHANG);
stunnel_pid = 0; stunnel_pid = 0;
...@@ -315,13 +367,13 @@ void stop_stunnel(void) { ...@@ -315,13 +367,13 @@ void stop_stunnel(void) {
} }
void setup_stunnel(int rport, int *argc, char **argv) { void setup_stunnel(int rport, int *argc, char **argv) {
int i, xport = 0; int i, xport = 0, hport = 0, xhport = 0;
if (! rport && argc && argv) { if (! rport && argc && argv) {
for (i=0; i< *argc; i++) { for (i=0; i< *argc; i++) {
if (argv[i] && !strcmp(argv[i], "-rfbport")) { if (argv[i] && !strcmp(argv[i], "-rfbport")) {
if (i < *argc - 1) { if (i < *argc - 1) {
rport = atoi(argv[i+1]); rport = atoi(argv[i+1]);
break;
} }
} }
} }
...@@ -340,7 +392,36 @@ void setup_stunnel(int rport, int *argc, char **argv) { ...@@ -340,7 +392,36 @@ void setup_stunnel(int rport, int *argc, char **argv) {
goto stunnel_fail; goto stunnel_fail;
} }
if (start_stunnel(rport, xport)) { if (https_port_num > 0) {
hport = https_port_num;
}
if (! hport && argc && argv) {
for (i=0; i< *argc; i++) {
if (argv[i] && !strcmp(argv[i], "-httpport")) {
if (i < *argc - 1) {
hport = atoi(argv[i+1]);
}
}
}
}
if (! hport && http_try_it) {
hport = find_free_port(rport-100, rport-1);
if (! hport) {
goto stunnel_fail;
}
}
if (hport) {
xhport = find_free_port(5850, 5899);
if (! xhport) {
goto stunnel_fail;
}
stunnel_http_port = hport;
}
if (start_stunnel(rport, xport, hport, xhport)) {
int tweaked = 0; int tweaked = 0;
char tmp[30]; char tmp[30];
sprintf(tmp, "%d", xport); sprintf(tmp, "%d", xport);
......
...@@ -36,7 +36,7 @@ so, delete this exception statement from your version. ...@@ -36,7 +36,7 @@ so, delete this exception statement from your version.
/* -- sslcmds.h -- */ /* -- sslcmds.h -- */
extern void check_stunnel(void); extern void check_stunnel(void);
extern int start_stunnel(int stunnel_port, int x11vnc_port); extern int start_stunnel(int stunnel_port, int x11vnc_port, int hport, int x11vnc_hport);
extern void stop_stunnel(void); extern void stop_stunnel(void);
extern void setup_stunnel(int rport, int *argc, char **argv); extern void setup_stunnel(int rport, int *argc, char **argv);
extern char *get_Cert_dir(char *cdir_in, char **tmp_in); extern char *get_Cert_dir(char *cdir_in, char **tmp_in);
......
This diff is collapsed.
...@@ -62,6 +62,8 @@ extern void ssl_helper_pid(pid_t pid, int sock); ...@@ -62,6 +62,8 @@ extern void ssl_helper_pid(pid_t pid, int sock);
extern void accept_openssl(int mode, int presock); extern void accept_openssl(int mode, int presock);
extern char *find_openssl_bin(void); extern char *find_openssl_bin(void);
extern char *get_saved_pem(char *string, int create); extern char *get_saved_pem(char *string, int create);
extern char *get_ssl_verify_file(char *str_in);
extern char *create_tmp_pem(char *path, int prompt);
#endif /* _X11VNC_SSLHELPER_H */ #endif /* _X11VNC_SSLHELPER_H */
...@@ -271,13 +271,13 @@ char genCA[] = ...@@ -271,13 +271,13 @@ char genCA[] =
" -keyout \"$DIR/CA/private/cakey.pem\" \\\n" " -keyout \"$DIR/CA/private/cakey.pem\" \\\n"
" -out \"$DIR/CA/cacert.pem\"\n" " -out \"$DIR/CA/cacert.pem\"\n"
"\n" "\n"
"chmod go-rwx \"$DIR/CA/private/cakey.pem\"\n"
"\n"
"if [ $? != 0 ]; then\n" "if [ $? != 0 ]; then\n"
" echo \"openssl failed.\"\n" " echo \"openssl failed.\"\n"
" exit 1\n" " exit 1\n"
"fi\n" "fi\n"
"\n" "\n"
"chmod go-rwx \"$DIR/CA/private/cakey.pem\"\n"
"\n"
"echo \"\"\n" "echo \"\"\n"
"echo \"----------------------------------------------------------------------\"\n" "echo \"----------------------------------------------------------------------\"\n"
"echo \"Your public x11vnc CA cert is:\"\n" "echo \"Your public x11vnc CA cert is:\"\n"
...@@ -785,6 +785,10 @@ char find_display[] = ...@@ -785,6 +785,10 @@ char find_display[] =
" set -xv\n" " set -xv\n"
"fi\n" "fi\n"
"\n" "\n"
"if [ \"X$X11VNC_SKIP_DISPLAY\" = \"Xall\" ]; then\n"
" exit 1\n"
"fi\n"
"\n"
"PATH=$PATH:/bin:/usr/bin:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/ucb\n" "PATH=$PATH:/bin:/usr/bin:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/ucb\n"
"export PATH\n" "export PATH\n"
"\n" "\n"
...@@ -1439,7 +1443,11 @@ char create_display[] = ...@@ -1439,7 +1443,11 @@ char create_display[] =
" return\n" " return\n"
" fi\n" " fi\n"
" if [ \"X$have_gnome_session\" != \"X\" -a \"X$FD_SESS\" = \"Xgnome\" ]; then\n" " if [ \"X$have_gnome_session\" != \"X\" -a \"X$FD_SESS\" = \"Xgnome\" ]; then\n"
" if [ \"X$have_dbus_launch\" != \"X\" ]; then\n"
" echo \"$have_dbus_launch --exit-with-session $have_gnome_session\"\n"
" else\n"
" echo \"$have_gnome_session\"\n" " echo \"$have_gnome_session\"\n"
" fi\n"
" return\n" " return\n"
" elif [ \"X$have_startkde\" != \"X\" -a \"X$FD_SESS\" = \"Xkde\" ]; then\n" " elif [ \"X$have_startkde\" != \"X\" -a \"X$FD_SESS\" = \"Xkde\" ]; then\n"
" echo \"$have_startkde\"\n" " echo \"$have_startkde\"\n"
...@@ -1692,8 +1700,10 @@ char create_display[] = ...@@ -1692,8 +1700,10 @@ char create_display[] =
" DISPLAY=:$N\n" " DISPLAY=:$N\n"
" export DISPLAY\n" " export DISPLAY\n"
" stmp=\"\"\n" " stmp=\"\"\n"
" noxauth=\"\"\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n" " if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" sess=\"env DISPLAY=:$N $sess\"\n" " sess=\"env DISPLAY=:$N $sess\"\n"
" noxauth=\"1\"\n"
" fi\n" " fi\n"
"\n" "\n"
" redir_daemon=\"\"\n" " redir_daemon=\"\"\n"
...@@ -1706,22 +1716,29 @@ char create_display[] = ...@@ -1706,22 +1716,29 @@ char create_display[] =
" touch $stmp\n" " touch $stmp\n"
" chmod 755 $stmp || exit 1\n" " chmod 755 $stmp || exit 1\n"
" echo \"#!/bin/sh\" > $stmp\n" " echo \"#!/bin/sh\" > $stmp\n"
" #echo \"(id; env; env | grep XAUTHORITY | sed -e 's/XAUTHORITY=//' | xargs ls -l) > /tmp/ENV.OUT.$$\" >> $stmp\n"
" if [ \"X$noxauth\" = \"X1\" ]; then\n"
" echo \"unset XAUTHORITY\" >> $stmp\n"
" fi\n"
" echo \"$sess\" >> $stmp\n" " echo \"$sess\" >> $stmp\n"
" echo \"sleep 1\" >> $stmp\n" " echo \"sleep 1\" >> $stmp\n"
" echo \"rm -f $stmp\" >> $stmp\n" " echo \"rm -f $stmp\" >> $stmp\n"
" sess=$stmp\n" " sess=$stmp\n"
" rmf=\"$stmp\"\n" " rmf=\"$stmp\"\n"
" fi\n" " fi\n"
"\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n" " if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" ctmp=/tmp/.xat$$`random`\n" " ctmp1=/tmp/.xat1_$$`random`\n"
" ctmp=`mytmp \"$ctmp\"`\n" " ctmp1=`mytmp \"$ctmp1\"`\n"
" touch $ctmp\n" " ctmp2=/tmp/.xat2_$$`random`\n"
" chmod 644 $ctmp || exit 1\n" " ctmp2=`mytmp \"$ctmp2\"`\n"
" $have_xauth -f $authfile nextract - :$N > $ctmp\n" " touch $ctmp1 $ctmp2\n"
" su - $USER -c \"$have_xauth nmerge - < $ctmp\" 1>&2\n" " $have_xauth -f $authfile nextract - :$N > $ctmp1\n"
" $have_xauth -f $authfile nextract - `hostname`:$N > $ctmp\n" " $have_xauth -f $authfile nextract - `hostname`:$N > $ctmp2\n"
" su - $USER -c \"$have_xauth nmerge - < $ctmp\" 1>&2\n" " chown $USER $ctmp1 $ctmp2\n"
" rm -f $ctmp\n" " (unset XAUTHORITY; su - $USER -c \"$have_xauth nmerge - < $ctmp1\" 1>&2)\n"
" (unset XAUTHORITY; su - $USER -c \"$have_xauth nmerge - < $ctmp2\" 1>&2)\n"
" rm -f $ctmp1 $ctmp2\n"
" XAUTHORITY=$authfile\n" " XAUTHORITY=$authfile\n"
" export XAUTHORITY\n" " export XAUTHORITY\n"
" sess=\"/bin/su - $USER -c $sess\"\n" " sess=\"/bin/su - $USER -c $sess\"\n"
...@@ -1742,7 +1759,12 @@ char create_display[] = ...@@ -1742,7 +1759,12 @@ char create_display[] =
" # we cannot use -nolisten tcp\n" " # we cannot use -nolisten tcp\n"
" echo \"$* -once -query localhost $FD_OPTS\" 1>&2\n" " echo \"$* -once -query localhost $FD_OPTS\" 1>&2\n"
" if [ \"X$have_root\" != \"X\" ]; then\n" " if [ \"X$have_root\" != \"X\" ]; then\n"
" if [ -r $authfile ]; then\n"
" $have_nohup $* -once -query localhost -auth $authfile $FD_OPTS 1>&2 &\n"
" else\n"
" # why did we have this?\n"
" $have_nohup $* -once -query localhost $FD_OPTS 1>&2 &\n" " $have_nohup $* -once -query localhost $FD_OPTS 1>&2 &\n"
" fi\n"
" else\n" " else\n"
" if [ \"X$ns\" = \"X0\" ]; then\n" " if [ \"X$ns\" = \"X0\" ]; then\n"
" $have_nohup sh -c \"$* -once -query localhost -auth $authfile $FD_OPTS\" 1>&2 &\n" " $have_nohup sh -c \"$* -once -query localhost -auth $authfile $FD_OPTS\" 1>&2 &\n"
...@@ -1754,10 +1776,10 @@ char create_display[] = ...@@ -1754,10 +1776,10 @@ char create_display[] =
" pid=$!\n" " pid=$!\n"
" sleep 10\n" " sleep 10\n"
" elif [ \"X$have_startx\" != \"X\" -o \"X$have_xinit\" != \"X\" ]; then\n" " elif [ \"X$have_startx\" != \"X\" -o \"X$have_xinit\" != \"X\" ]; then\n"
" if [ \"X$have_startx\" != \"X\" ]; then\n" " if [ \"X$have_xinit\" != \"X\" ]; then\n"
" sxcmd=$have_startx\n"
" else\n"
" sxcmd=$have_xinit\n" " sxcmd=$have_xinit\n"
" else\n"
" sxcmd=$have_startx\n"
" fi\n" " fi\n"
" echo \"$sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n" " echo \"$sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n"
" if [ \"X$have_root\" != \"X\" ]; then\n" " if [ \"X$have_root\" != \"X\" ]; then\n"
...@@ -1924,12 +1946,18 @@ char create_display[] = ...@@ -1924,12 +1946,18 @@ char create_display[] =
" sarg=\"screen\"\n" " sarg=\"screen\"\n"
" fi\n" " fi\n"
" fi\n" " fi\n"
" # remember to put server args after sarg ... to work on Solaris 9 and 10.\n" " margs=\"+kb\"\n"
"\n"
" # currently not enabled in Xvfb's we see.\n"
"# if $have_Xvfb -extension MOOMOO 2>&1 | grep -w RANDR >/dev/null; then\n"
"# margs=\"$margs +extension RANDR\"\n"
"# fi\n"
"\n"
" if [ $depth -ge 16 ]; then\n" " if [ $depth -ge 16 ]; then\n"
" server $have_Xvfb :$N $sarg 0 ${geom}x${depth} +kb -cc 4\n" " # avoid DirectColor for default visual:\n"
" else\n" " margs=\"$margs -cc 4\"\n"
" server $have_Xvfb :$N $sarg 0 ${geom}x${depth} +kb\n"
" fi\n" " fi\n"
" server $have_Xvfb :$N $sarg 0 ${geom}x${depth} $margs\n"
"\n" "\n"
" if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n" " if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n"
" if [ \"X$have_root\" = \"X\" ]; then\n" " if [ \"X$have_root\" = \"X\" ]; then\n"
...@@ -2030,6 +2058,10 @@ char create_display[] = ...@@ -2030,6 +2058,10 @@ char create_display[] =
" cook=`cookie`\n" " cook=`cookie`\n"
" $have_xauth -f $tmp add :$N . $cook 1>&2\n" " $have_xauth -f $tmp add :$N . $cook 1>&2\n"
" $have_xauth -f $tmp add `hostname`:$N . $cook 1>&2\n" " $have_xauth -f $tmp add `hostname`:$N . $cook 1>&2\n"
" if [ \"X$CREATE_DISPLAY_EXEC\" != \"X\" ]; then\n"
" ls -l $tmp 1>&2\n"
" $have_xauth -f $tmp list 1>&2\n"
" fi\n"
" echo \"$tmp\"\n" " echo \"$tmp\"\n"
"}\n" "}\n"
"\n" "\n"
...@@ -2117,7 +2149,7 @@ char create_display[] = ...@@ -2117,7 +2149,7 @@ char create_display[] =
" USER=`whoami`\n" " USER=`whoami`\n"
"fi\n" "fi\n"
"\n" "\n"
"PATH=$PATH:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/dt/bin:/opt/kde3/bin:/opt/gnome/bin:/usr/bin:/bin:/usr/sfw/bin\n" "PATH=$PATH:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/dt/bin:/opt/kde4/bin:/opt/kde3/bin:/opt/gnome/bin:/usr/bin:/bin:/usr/sfw/bin\n"
"\n" "\n"
"have_root=\"\"\n" "have_root=\"\"\n"
"id0=`id`\n" "id0=`id`\n"
...@@ -2130,7 +2162,7 @@ char create_display[] = ...@@ -2130,7 +2162,7 @@ char create_display[] =
" p_ok=1\n" " p_ok=1\n"
"fi\n" "fi\n"
"\n" "\n"
"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb Xvnc xauth xdpyinfo mcookie md5sum xmodmap startkde gnome-session blackbox fvwm2 mwm openbox twm windowmaker wmaker enlightenment metacity X Xorg XFree86 Xsun Xsession dtwm netstat nohup esddsp konsole gnome-terminal perl startxfce4 startxfce\n" "for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb Xvnc xauth xdpyinfo mcookie md5sum xmodmap startkde dbus-launch gnome-session blackbox fvwm2 mwm openbox twm windowmaker wmaker enlightenment metacity X Xorg XFree86 Xsun Xsession dtwm netstat nohup esddsp konsole gnome-terminal x-terminal-emulator perl startxfce4 startxfce\n"
"do\n" "do\n"
" p2=`echo \"$prog\" | sed -e 's/-/_/g'`\n" " p2=`echo \"$prog\" | sed -e 's/-/_/g'`\n"
" eval \"have_$p2=''\"\n" " eval \"have_$p2=''\"\n"
...@@ -2148,10 +2180,12 @@ char create_display[] = ...@@ -2148,10 +2180,12 @@ char create_display[] =
" fi\n" " fi\n"
"done\n" "done\n"
"if [ \"X$have_xterm\" = \"X\" ]; then\n" "if [ \"X$have_xterm\" = \"X\" ]; then\n"
" if [ \"X$have_konsole\" != \"X\" ]; then\n" " if [ \"X$have_gnome_terminal\" != \"X\" ]; then\n"
" have_xterm=$have_konsole\n"
" elif [ \"X$have_gnome_terminal\" != \"X\" ]; then\n"
" have_xterm=$have_gnome_terminal\n" " have_xterm=$have_gnome_terminal\n"
" elif [ \"X$have_konsole\" != \"X\" ]; then\n"
" have_xterm=$have_konsole\n"
" elif [ \"X$have_x_terminal_emulator\" != \"X\" ]; then\n"
" have_xterm=$have_x_terminal_emulator\n"
" fi\n" " fi\n"
"fi\n" "fi\n"
"\n" "\n"
...@@ -2182,9 +2216,15 @@ char create_display[] = ...@@ -2182,9 +2216,15 @@ char create_display[] =
" if echo \"$curr_try\" | egrep '[+.-]xdmcp' > /dev/null; then\n" " if echo \"$curr_try\" | egrep '[+.-]xdmcp' > /dev/null; then\n"
" use_xdmcp_query=1\n" " use_xdmcp_query=1\n"
" fi\n" " fi\n"
"\n"
" if [ \"X$X11VNC_XDM_ONLY\" = \"X1\" -a \"X$use_xdmcp_query\" = \"X0\" ]; then\n"
" echo \"SKIPPING NON-XDMCP item '$curr_try' in X11VNC_XDM_ONLY=1 mode.\" 1>&2\n"
" continue\n"
" fi\n"
" \n"
" curr_try=`echo \"$curr_try\" | sed -e 's/[+.-]xdmcp//'`\n" " curr_try=`echo \"$curr_try\" | sed -e 's/[+.-]xdmcp//'`\n"
" curr_try=`echo \"$curr_try\" | sed -e 's/[+.-]redirect//'`\n" " curr_try=`echo \"$curr_try\" | sed -e 's/[+.-]redirect//'`\n"
" \n" "\n"
" if echo \"$curr_try\" | grep -i '^Xdummy\\>' > /dev/null; then\n" " if echo \"$curr_try\" | grep -i '^Xdummy\\>' > /dev/null; then\n"
" try_Xdummy\n" " try_Xdummy\n"
" elif echo \"$curr_try\" | grep -i '^Xvfb\\>' > /dev/null; then\n" " elif echo \"$curr_try\" | grep -i '^Xvfb\\>' > /dev/null; then\n"
......
...@@ -413,6 +413,7 @@ Tuning ...@@ -413,6 +413,7 @@ Tuning
gaps: gaps:
grow: grow:
fuzz: fuzz:
extra_fbur:
wait_ui: wait_ui:
setdefer: setdefer:
nowait_bog nowait_bog
...@@ -749,7 +750,8 @@ more) via Properties -> Advanced -> Actions -> Quit ...@@ -749,7 +750,8 @@ more) via Properties -> Advanced -> Actions -> Quit
non-standard listening port use \"host:port\". non-standard listening port use \"host:port\".
Pressing \"OK\" will initiate the reverse Pressing \"OK\" will initiate the reverse
connection. Use a blank hostname to skip it. connection. Use a blank hostname to skip it, or
delete (\"X-out\") the window.
" "
...@@ -2985,7 +2987,12 @@ proc all_query_vars {} { ...@@ -2985,7 +2987,12 @@ proc all_query_vars {} {
} }
set cache_all_query_vars $qry set cache_all_query_vars $qry
#puts $qry global env
if [info exists env(TKX11VNC_PRINT_ALL_VARS)] {
puts "--------------- BEGIN ALL VARS ---------------"
puts $qry
puts "--------------- END ALL VARS ---------------"
}
return $qry return $qry
} }
...@@ -6261,11 +6268,11 @@ proc run_remote_cmd_via_sock {opts} { ...@@ -6261,11 +6268,11 @@ proc run_remote_cmd_via_sock {opts} {
} }
if {$db} {puts stderr "run_remote_cmd_via_sock: $docmd \"$str\""} if {$db} {puts stderr "run_remote_cmd_via_sock: $docmd \"$str\""}
puts $client_sock $str catch {puts $client_sock $str}
if {$db} {puts stderr "run_remote_cmd_via_sock: flush"} if {$db} {puts stderr "run_remote_cmd_via_sock: flush"}
flush $client_sock catch {flush $client_sock}
if {$db} {puts stderr "run_remote_cmd_via_sock: gets"} if {$db} {puts stderr "run_remote_cmd_via_sock: gets"}
gets $client_sock res catch {gets $client_sock res}
if {$db} {puts stderr "run_remote_cmd_via_sock: \"$res\""} if {$db} {puts stderr "run_remote_cmd_via_sock: \"$res\""}
set res [string trim $res] set res [string trim $res]
...@@ -6535,18 +6542,18 @@ proc do_port_prompt {} { ...@@ -6535,18 +6542,18 @@ proc do_port_prompt {} {
} else { } else {
frame .pp.f -bd 1 -relief ridge -pady 2 frame .pp.f -bd 1 -relief ridge -pady 2
} }
label .pp.f.l -text "Port: " label .pp.f.l -text "Port: " -font $bfont
entry .pp.f.e -width 8 -textvariable port_set entry .pp.f.e -width 8 -textvariable port_set -font $ffont
global enable_ssl; set enable_ssl 0 global enable_ssl; set enable_ssl 0
if [info exists env(X11VNC_SSL_ENABLED)] { if [info exists env(X11VNC_SSL_ENABLED)] {
set enable_ssl 1 set enable_ssl 1
} }
checkbutton .pp.f.ssl -relief raised -pady 3 -padx 3 -text "Enable SSL" -variable enable_ssl checkbutton .pp.f.ssl -relief raised -pady 3 -padx 3 -text "Enable SSL" -variable enable_ssl -font $bfont
global localhost; set localhost 0 global localhost; set localhost 0
if [info exists env(X11VNC_LOCALHOST_ENABLED)] { if [info exists env(X11VNC_LOCALHOST_ENABLED)] {
set localhost 1 set localhost 1
} }
checkbutton .pp.f.loc -relief raised -pady 3 -padx 3 -text "Listen on localhost" -variable localhost checkbutton .pp.f.loc -relief raised -pady 3 -padx 3 -text "Listen on localhost" -variable localhost -font $bfont
pack .pp.f.l .pp.f.e -side left pack .pp.f.l .pp.f.e -side left
pack .pp.f.loc .pp.f.ssl -side right pack .pp.f.loc .pp.f.ssl -side right
...@@ -6559,15 +6566,15 @@ proc do_port_prompt {} { ...@@ -6559,15 +6566,15 @@ proc do_port_prompt {} {
if [info exists env(X11VNC_FILETRANSFER_ENABLED)] { if [info exists env(X11VNC_FILETRANSFER_ENABLED)] {
set file_transfer $env(X11VNC_FILETRANSFER_ENABLED) set file_transfer $env(X11VNC_FILETRANSFER_ENABLED)
} }
label .pp.t.l -text "File Transfer: " label .pp.t.l -text "File Transfer: " -font $bfont
radiobutton .pp.t.none -text "None" -variable file_transfer -value "none" radiobutton .pp.t.none -text "None" -variable file_transfer -value "none" -font $bfont
radiobutton .pp.t.ultra -text "UltraVNC" -variable file_transfer -value "ultra" radiobutton .pp.t.ultra -text "UltraVNC" -variable file_transfer -value "ultra" -font $bfont
radiobutton .pp.t.tight -text "TightVNC" -variable file_transfer -value "tight" radiobutton .pp.t.tight -text "TightVNC" -variable file_transfer -value "tight" -font $bfont
pack .pp.t.l .pp.t.none .pp.t.ultra .pp.t.tight -side left pack .pp.t.l .pp.t.none .pp.t.ultra .pp.t.tight -side left
frame .pp.o -bd 1 -relief ridge frame .pp.o -bd 1 -relief ridge
button .pp.o.ok -text "OK" -command "set port_reply 1; destroy .pp" button .pp.o.ok -text "OK" -command "set port_reply 1; destroy .pp" -font $bfont
button .pp.o.cancel -text "Cancel" -command "set port_reply 0; destroy .pp" button .pp.o.cancel -text "Cancel" -command "set port_reply 0; destroy .pp" -font $bfont
pack .pp.o.ok .pp.o.cancel -side left -fill x -expand 1 pack .pp.o.ok .pp.o.cancel -side left -fill x -expand 1
pack .pp.m -side top -fill x -expand 1 pack .pp.m -side top -fill x -expand 1
pack .pp.f .pp.t .pp.o -side top -fill x pack .pp.f .pp.t .pp.o -side top -fill x
...@@ -6794,6 +6801,24 @@ set sfont "-adobe-helvetica-bold-r-*-*-*-100-*-*-*-*-*-*" ...@@ -6794,6 +6801,24 @@ set sfont "-adobe-helvetica-bold-r-*-*-*-100-*-*-*-*-*-*"
set snfont "-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*" set snfont "-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*"
set ffont "fixed" set ffont "fixed"
set got_helv 0
catch {
foreach fam [font families] {
if {$fam == "helvetica"} {
set got_helv 1
}
if {$fam == "Helvetica"} {
set got_helv 1
}
}
}
if {$got_helv} {
set bfont "Helvetica -12 bold"
set sfont "Helvetica -10 bold"
set snfont "Helvetica -10"
}
set ls "" set ls ""
catch {set ls [font metrics $bfont -linespace]} catch {set ls [font metrics $bfont -linespace]}
if {$ls != "" && $ls > 14} { if {$ls != "" && $ls > 14} {
...@@ -6914,11 +6939,6 @@ if {"$argv" == "-spit"} { ...@@ -6914,11 +6939,6 @@ if {"$argv" == "-spit"} {
puts ";" puts ";"
exit 0 exit 0
} }
if {"$argv" == "-portprompt"} {
do_port_prompt
exit 0
}
set_view_variable "full" set_view_variable "full"
...@@ -6977,6 +6997,19 @@ if {[info exists env(X11VNC_GUI_PARAMS)]} { ...@@ -6977,6 +6997,19 @@ if {[info exists env(X11VNC_GUI_PARAMS)]} {
set x11vnc_gui_params "" set x11vnc_gui_params ""
} }
if {[info exists env(X11VNC_FONT_BOLD)]} {
set bfont $env(X11VNC_FONT_BOLD)
}
if {[info exists env(X11VNC_FONT_BOLD_SMALL)]} {
set sfont $env(X11VNC_FONT_BOLD_SMALL)
}
if {[info exists env(X11VNC_FONT_REG_SMALL)]} {
set snfont $env(X11VNC_FONT_REG_SMALL)
}
if {[info exists env(X11VNC_FONT_FIXED)]} {
set ffont $env(X11VNC_FONT_FIXED)
}
if {[info exists env(X11VNC_CONNECT_FILE)]} { if {[info exists env(X11VNC_CONNECT_FILE)]} {
set x11vnc_connect_file $env(X11VNC_CONNECT_FILE); set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);
} else { } else {
...@@ -7086,6 +7119,11 @@ if {[regexp -nocase {Darwin} $osname]} { ...@@ -7086,6 +7119,11 @@ if {[regexp -nocase {Darwin} $osname]} {
set bfont {system} set bfont {system}
} }
if {"$argv" == "-portprompt"} {
do_port_prompt
exit 0
}
#puts [exec env] #puts [exec env]
#puts "x11vnc_xdisplay: $x11vnc_xdisplay" #puts "x11vnc_xdisplay: $x11vnc_xdisplay"
......
...@@ -424,6 +424,7 @@ char gui_code[] = ""; ...@@ -424,6 +424,7 @@ char gui_code[] = "";
" gaps:\n" " gaps:\n"
" grow:\n" " grow:\n"
" fuzz:\n" " fuzz:\n"
" extra_fbur:\n"
" wait_ui:\n" " wait_ui:\n"
" setdefer:\n" " setdefer:\n"
" nowait_bog\n" " nowait_bog\n"
...@@ -760,7 +761,8 @@ char gui_code[] = ""; ...@@ -760,7 +761,8 @@ char gui_code[] = "";
" non-standard listening port use \\\"host:port\\\".\n" " non-standard listening port use \\\"host:port\\\".\n"
"\n" "\n"
" Pressing \\\"OK\\\" will initiate the reverse\n" " Pressing \\\"OK\\\" will initiate the reverse\n"
" connection. Use a blank hostname to skip it.\n" " connection. Use a blank hostname to skip it, or\n"
" delete (\\\"X-out\\\") the window.\n"
" \n" " \n"
"\"\n" "\"\n"
"\n" "\n"
...@@ -2996,7 +2998,12 @@ char gui_code[] = ""; ...@@ -2996,7 +2998,12 @@ char gui_code[] = "";
" }\n" " }\n"
" set cache_all_query_vars $qry\n" " set cache_all_query_vars $qry\n"
"\n" "\n"
"#puts $qry\n" " global env\n"
" if [info exists env(TKX11VNC_PRINT_ALL_VARS)] {\n"
" puts \"--------------- BEGIN ALL VARS ---------------\"\n"
" puts $qry\n"
" puts \"--------------- END ALL VARS ---------------\"\n"
" }\n"
"\n" "\n"
" return $qry\n" " return $qry\n"
"}\n" "}\n"
...@@ -6272,11 +6279,11 @@ char gui_code[] = ""; ...@@ -6272,11 +6279,11 @@ char gui_code[] = "";
" }\n" " }\n"
"\n" "\n"
" if {$db} {puts stderr \"run_remote_cmd_via_sock: $docmd \\\"$str\\\"\"}\n" " if {$db} {puts stderr \"run_remote_cmd_via_sock: $docmd \\\"$str\\\"\"}\n"
" puts $client_sock $str\n" " catch {puts $client_sock $str}\n"
" if {$db} {puts stderr \"run_remote_cmd_via_sock: flush\"}\n" " if {$db} {puts stderr \"run_remote_cmd_via_sock: flush\"}\n"
" flush $client_sock\n" " catch {flush $client_sock}\n"
" if {$db} {puts stderr \"run_remote_cmd_via_sock: gets\"}\n" " if {$db} {puts stderr \"run_remote_cmd_via_sock: gets\"}\n"
" gets $client_sock res\n" " catch {gets $client_sock res}\n"
" if {$db} {puts stderr \"run_remote_cmd_via_sock: \\\"$res\\\"\"}\n" " if {$db} {puts stderr \"run_remote_cmd_via_sock: \\\"$res\\\"\"}\n"
" set res [string trim $res]\n" " set res [string trim $res]\n"
"\n" "\n"
...@@ -6546,18 +6553,18 @@ char gui_code[] = ""; ...@@ -6546,18 +6553,18 @@ char gui_code[] = "";
" } else {\n" " } else {\n"
" frame .pp.f -bd 1 -relief ridge -pady 2\n" " frame .pp.f -bd 1 -relief ridge -pady 2\n"
" }\n" " }\n"
" label .pp.f.l -text \"Port: \"\n" " label .pp.f.l -text \"Port: \" -font $bfont\n"
" entry .pp.f.e -width 8 -textvariable port_set\n" " entry .pp.f.e -width 8 -textvariable port_set -font $ffont\n"
" global enable_ssl; set enable_ssl 0\n" " global enable_ssl; set enable_ssl 0\n"
" if [info exists env(X11VNC_SSL_ENABLED)] {\n" " if [info exists env(X11VNC_SSL_ENABLED)] {\n"
" set enable_ssl 1\n" " set enable_ssl 1\n"
" }\n" " }\n"
" checkbutton .pp.f.ssl -relief raised -pady 3 -padx 3 -text \"Enable SSL\" -variable enable_ssl\n" " checkbutton .pp.f.ssl -relief raised -pady 3 -padx 3 -text \"Enable SSL\" -variable enable_ssl -font $bfont\n"
" global localhost; set localhost 0\n" " global localhost; set localhost 0\n"
" if [info exists env(X11VNC_LOCALHOST_ENABLED)] {\n" " if [info exists env(X11VNC_LOCALHOST_ENABLED)] {\n"
" set localhost 1\n" " set localhost 1\n"
" }\n" " }\n"
" checkbutton .pp.f.loc -relief raised -pady 3 -padx 3 -text \"Listen on localhost\" -variable localhost\n" " checkbutton .pp.f.loc -relief raised -pady 3 -padx 3 -text \"Listen on localhost\" -variable localhost -font $bfont\n"
" pack .pp.f.l .pp.f.e -side left\n" " pack .pp.f.l .pp.f.e -side left\n"
" pack .pp.f.loc .pp.f.ssl -side right\n" " pack .pp.f.loc .pp.f.ssl -side right\n"
"\n" "\n"
...@@ -6570,15 +6577,15 @@ char gui_code[] = ""; ...@@ -6570,15 +6577,15 @@ char gui_code[] = "";
" if [info exists env(X11VNC_FILETRANSFER_ENABLED)] {\n" " if [info exists env(X11VNC_FILETRANSFER_ENABLED)] {\n"
" set file_transfer $env(X11VNC_FILETRANSFER_ENABLED)\n" " set file_transfer $env(X11VNC_FILETRANSFER_ENABLED)\n"
" }\n" " }\n"
" label .pp.t.l -text \"File Transfer: \"\n" " label .pp.t.l -text \"File Transfer: \" -font $bfont\n"
" radiobutton .pp.t.none -text \"None\" -variable file_transfer -value \"none\"\n" " radiobutton .pp.t.none -text \"None\" -variable file_transfer -value \"none\" -font $bfont\n"
" radiobutton .pp.t.ultra -text \"UltraVNC\" -variable file_transfer -value \"ultra\"\n" " radiobutton .pp.t.ultra -text \"UltraVNC\" -variable file_transfer -value \"ultra\" -font $bfont\n"
" radiobutton .pp.t.tight -text \"TightVNC\" -variable file_transfer -value \"tight\"\n" " radiobutton .pp.t.tight -text \"TightVNC\" -variable file_transfer -value \"tight\" -font $bfont\n"
" pack .pp.t.l .pp.t.none .pp.t.ultra .pp.t.tight -side left\n" " pack .pp.t.l .pp.t.none .pp.t.ultra .pp.t.tight -side left\n"
"\n" "\n"
" frame .pp.o -bd 1 -relief ridge\n" " frame .pp.o -bd 1 -relief ridge\n"
" button .pp.o.ok -text \"OK\" -command \"set port_reply 1; destroy .pp\"\n" " button .pp.o.ok -text \"OK\" -command \"set port_reply 1; destroy .pp\" -font $bfont\n"
" button .pp.o.cancel -text \"Cancel\" -command \"set port_reply 0; destroy .pp\"\n" " button .pp.o.cancel -text \"Cancel\" -command \"set port_reply 0; destroy .pp\" -font $bfont\n"
" pack .pp.o.ok .pp.o.cancel -side left -fill x -expand 1\n" " pack .pp.o.ok .pp.o.cancel -side left -fill x -expand 1\n"
" pack .pp.m -side top -fill x -expand 1 \n" " pack .pp.m -side top -fill x -expand 1 \n"
" pack .pp.f .pp.t .pp.o -side top -fill x\n" " pack .pp.f .pp.t .pp.o -side top -fill x\n"
...@@ -6805,6 +6812,24 @@ char gui_code[] = ""; ...@@ -6805,6 +6812,24 @@ char gui_code[] = "";
"set snfont \"-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*\"\n" "set snfont \"-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*\"\n"
"set ffont \"fixed\"\n" "set ffont \"fixed\"\n"
"\n" "\n"
"set got_helv 0\n"
"catch {\n"
" foreach fam [font families] {\n"
" if {$fam == \"helvetica\"} {\n"
" set got_helv 1\n"
" }\n"
" if {$fam == \"Helvetica\"} {\n"
" set got_helv 1\n"
" }\n"
" }\n"
"}\n"
"\n"
"if {$got_helv} {\n"
" set bfont \"Helvetica -12 bold\"\n"
" set sfont \"Helvetica -10 bold\"\n"
" set snfont \"Helvetica -10\"\n"
"}\n"
"\n"
"set ls \"\"\n" "set ls \"\"\n"
"catch {set ls [font metrics $bfont -linespace]}\n" "catch {set ls [font metrics $bfont -linespace]}\n"
"if {$ls != \"\" && $ls > 14} {\n" "if {$ls != \"\" && $ls > 14} {\n"
...@@ -6925,11 +6950,6 @@ char gui_code[] = ""; ...@@ -6925,11 +6950,6 @@ char gui_code[] = "";
" puts \";\"\n" " puts \";\"\n"
" exit 0\n" " exit 0\n"
"}\n" "}\n"
"if {\"$argv\" == \"-portprompt\"} {\n"
" do_port_prompt\n"
" exit 0\n"
"}\n"
"\n"
"\n" "\n"
"set_view_variable \"full\"\n" "set_view_variable \"full\"\n"
"\n" "\n"
...@@ -6988,6 +7008,19 @@ char gui_code[] = ""; ...@@ -6988,6 +7008,19 @@ char gui_code[] = "";
" set x11vnc_gui_params \"\"\n" " set x11vnc_gui_params \"\"\n"
"}\n" "}\n"
"\n" "\n"
"if {[info exists env(X11VNC_FONT_BOLD)]} {\n"
" set bfont $env(X11VNC_FONT_BOLD)\n"
"}\n"
"if {[info exists env(X11VNC_FONT_BOLD_SMALL)]} {\n"
" set sfont $env(X11VNC_FONT_BOLD_SMALL)\n"
"}\n"
"if {[info exists env(X11VNC_FONT_REG_SMALL)]} {\n"
" set snfont $env(X11VNC_FONT_REG_SMALL)\n"
"}\n"
"if {[info exists env(X11VNC_FONT_FIXED)]} {\n"
" set ffont $env(X11VNC_FONT_FIXED)\n"
"}\n"
"\n"
"if {[info exists env(X11VNC_CONNECT_FILE)]} {\n" "if {[info exists env(X11VNC_CONNECT_FILE)]} {\n"
" set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);\n" " set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);\n"
"} else {\n" "} else {\n"
...@@ -7097,6 +7130,11 @@ char gui_code[] = ""; ...@@ -7097,6 +7130,11 @@ char gui_code[] = "";
" set bfont {system}\n" " set bfont {system}\n"
"}\n" "}\n"
"\n" "\n"
"if {\"$argv\" == \"-portprompt\"} {\n"
" do_port_prompt\n"
" exit 0\n"
"}\n"
"\n"
"#puts [exec env]\n" "#puts [exec env]\n"
"#puts \"x11vnc_xdisplay: $x11vnc_xdisplay\"\n" "#puts \"x11vnc_xdisplay: $x11vnc_xdisplay\"\n"
"\n" "\n"
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ extern void unixpw_accept(char *user); ...@@ -42,7 +42,7 @@ extern void unixpw_accept(char *user);
extern void unixpw_deny(void); extern void unixpw_deny(void);
extern void unixpw_msg(char *msg, int delay); extern void unixpw_msg(char *msg, int delay);
extern int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int nodisp); extern int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int nodisp);
extern int unixpw_cmd_run(char *user, char *pass, char *cmd, char *line, int *n, int nodisp); extern int unixpw_cmd_run(char *user, char *pass, char *cmd, char *line, int *n);
extern int crypt_verify(char *user, char *pass); extern int crypt_verify(char *user, char *pass);
extern int cmd_verify(char *user, char *pass); extern int cmd_verify(char *user, char *pass);
extern int unixpw_verify(char *user, char *pass); extern int unixpw_verify(char *user, char *pass);
......
...@@ -1291,13 +1291,13 @@ void user_supplied_opts(char *opts) { ...@@ -1291,13 +1291,13 @@ void user_supplied_opts(char *opts) {
if (scale_str) free(scale_str); if (scale_str) free(scale_str);
scale_str = strdup(p); scale_str = strdup(p);
} else if (ok) { } else if (ok) {
if (strstr(p, "display=") == p) { if (0 && strstr(p, "display=") == p) {
if (use_dpy) free(use_dpy); if (use_dpy) free(use_dpy);
use_dpy = strdup(p + strlen("display=")); use_dpy = strdup(p + strlen("display="));
} else if (strstr(p, "auth=") == p) { } else if (0 && strstr(p, "auth=") == p) {
if (auth_file) free(auth_file); if (auth_file) free(auth_file);
auth_file = strdup(p + strlen("auth=")); auth_file = strdup(p + strlen("auth="));
} else if (!strcmp(p, "shared")) { } else if (0 && !strcmp(p, "shared")) {
shared = 1; shared = 1;
} else if (strstr(p, "scale=") == p) { } else if (strstr(p, "scale=") == p) {
if (scale_str) free(scale_str); if (scale_str) free(scale_str);
...@@ -1443,8 +1443,16 @@ static void setup_fake_fb(XImage* fb_image, int w, int h, int b) { ...@@ -1443,8 +1443,16 @@ static void setup_fake_fb(XImage* fb_image, int w, int h, int b) {
off_y = 0; off_y = 0;
} }
void do_announce_http(void);
void do_mention_java_urls(void);
static void setup_service(void) { static void setup_service(void) {
if (remote_direct) {
return;
}
if (!inetd) { if (!inetd) {
do_mention_java_urls();
do_announce_http();
if (!use_openssl) { if (!use_openssl) {
announce(screen->port, use_openssl, NULL); announce(screen->port, use_openssl, NULL);
fprintf(stdout, "PORT=%d\n", screen->port); fprintf(stdout, "PORT=%d\n", screen->port);
...@@ -1564,9 +1572,12 @@ static void loop_for_connect(int did_client_connect) { ...@@ -1564,9 +1572,12 @@ static void loop_for_connect(int did_client_connect) {
goto screen_check; goto screen_check;
} }
} }
if (use_openssl && !inetd) { if ((use_openssl || use_stunnel) && !inetd) {
int enc_none = (enc_str && !strcmp(enc_str, "none"));
if (!use_stunnel || enc_none) {
check_openssl(); check_openssl();
check_https(); check_https();
}
/* /*
* This is to handle an initial verify cert from viewer, * This is to handle an initial verify cert from viewer,
* they disconnect right after fetching the cert. * they disconnect right after fetching the cert.
...@@ -1655,6 +1666,15 @@ static void do_unixpw_loop(void) { ...@@ -1655,6 +1666,15 @@ static void do_unixpw_loop(void) {
unixpw_in_rfbPE = 0; unixpw_in_rfbPE = 0;
} }
if (unixpw_in_progress) { if (unixpw_in_progress) {
static double lping = 0.0;
if (lping < dnow() + 5) {
mark_rect_as_modified(0, 0, 1, 1, 1);
lping = dnow();
}
if (time(NULL) > unixpw_last_try_time + 45) {
rfbLog("unixpw_deny: timed out waiting for reply.\n");
unixpw_deny();
}
usleep(20 * 1000); usleep(20 * 1000);
continue; continue;
} }
...@@ -2000,7 +2020,7 @@ static char *build_create_cmd(char *cmd, int *saw_xdmcp, char *usslpeer, char *t ...@@ -2000,7 +2020,7 @@ static char *build_create_cmd(char *cmd, int *saw_xdmcp, char *usslpeer, char *t
p++; p++;
} }
if (ok && strlen(q) < 32) { if (ok && strlen(q) < 32) {
sprintf(fdgeom, q); sprintf(fdgeom, "%s", q);
if (!quiet) { if (!quiet) {
rfbLog("set create display geom: %s\n", fdgeom); rfbLog("set create display geom: %s\n", fdgeom);
} }
...@@ -2203,6 +2223,12 @@ static void check_nodisplay(char **nd) { ...@@ -2203,6 +2223,12 @@ static void check_nodisplay(char **nd) {
} }
} }
} }
if (unixpw_system_greeter_active == 2) {
if (!keep_unixpw_user) {
clean_up_exit(1);
}
*nd = strdup("all");
}
} }
static char *get_usslpeer() { static char *get_usslpeer() {
...@@ -2242,6 +2268,10 @@ static char *get_usslpeer() { ...@@ -2242,6 +2268,10 @@ static char *get_usslpeer() {
} }
static void do_try_switch(char *usslpeer, char *users_list_save) { static void do_try_switch(char *usslpeer, char *users_list_save) {
if (unixpw_system_greeter_active == 2) {
rfbLog("unixpw_system_greeter: not trying switch to user '%s'\n", usslpeer ? usslpeer : "");
return;
}
if (usslpeer) { if (usslpeer) {
char *u = (char *) malloc(strlen(usslpeer+2)); char *u = (char *) malloc(strlen(usslpeer+2));
sprintf(u, "+%s", usslpeer); sprintf(u, "+%s", usslpeer);
...@@ -2365,11 +2395,14 @@ static int do_run_cmd(char *cmd, char *create_cmd, char *users_list_save, int cr ...@@ -2365,11 +2395,14 @@ static int do_run_cmd(char *cmd, char *create_cmd, char *users_list_save, int cr
memset(line, 0, 18000); memset(line, 0, 18000);
if (keep_unixpw_user && keep_unixpw_pass) { if (unixpw_system_greeter_active == 2) {
rfbLog("unixpw_system_greeter: forcing find display failure.\n");
res = 0;
} else if (keep_unixpw_user && keep_unixpw_pass) {
n = 18000; n = 18000;
if (unixpw_cmd != NULL) { if (unixpw_cmd != NULL) {
res = unixpw_cmd_run(keep_unixpw_user, res = unixpw_cmd_run(keep_unixpw_user,
keep_unixpw_pass, cmd, line, &n, nodisp); keep_unixpw_pass, cmd, line, &n);
} else { } else {
res = su_verify(keep_unixpw_user, res = su_verify(keep_unixpw_user,
keep_unixpw_pass, cmd, line, &n, nodisp); keep_unixpw_pass, cmd, line, &n, nodisp);
...@@ -2378,7 +2411,7 @@ static int do_run_cmd(char *cmd, char *create_cmd, char *users_list_save, int cr ...@@ -2378,7 +2411,7 @@ static int do_run_cmd(char *cmd, char *create_cmd, char *users_list_save, int cr
if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprintf(stderr, "res=%d n=%d\n", res, n);} if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprintf(stderr, "res=%d n=%d\n", res, n);}
if (! res) { if (! res) {
rfbLog("wait_for_client: find display cmd failed\n"); rfbLog("wait_for_client: find display cmd failed.\n");
} }
if (! res && create_cmd) { if (! res && create_cmd) {
...@@ -2398,8 +2431,8 @@ if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprint ...@@ -2398,8 +2431,8 @@ if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprint
n = 18000; n = 18000;
close_exec_fds(); close_exec_fds();
res = unixpw_cmd_run(keep_unixpw_user, res = unixpw_cmd_run(keep_unixpw_user,
keep_unixpw_pass, create_cmd, line, &n, nodisp); keep_unixpw_pass, create_cmd, line, &n);
} else if (getuid() != 0) { } else if (getuid() != 0 && unixpw_system_greeter_active != 2) {
/* if not root, run as the other user... */ /* if not root, run as the other user... */
n = 18000; n = 18000;
close_exec_fds(); close_exec_fds();
...@@ -2410,6 +2443,10 @@ if (db) fprintf(stderr, "c-res=%d n=%d line: '%s'\n", res, n, line); ...@@ -2410,6 +2443,10 @@ if (db) fprintf(stderr, "c-res=%d n=%d line: '%s'\n", res, n, line);
} else { } else {
FILE *p; FILE *p;
close_exec_fds(); close_exec_fds();
if (unixpw_system_greeter_active == 2) {
rfbLog("unixpw_system_greeter: not trying su_verify() to run\n");
rfbLog("unixpw_system_greeter: create display command.\n");
}
rfbLog("wait_for_client: running: %s\n", create_cmd); rfbLog("wait_for_client: running: %s\n", create_cmd);
p = popen(create_cmd, "r"); p = popen(create_cmd, "r");
if (! p) { if (! p) {
...@@ -2432,7 +2469,7 @@ if (db) fprintf(stderr, "line1: '%s'\n", line1); ...@@ -2432,7 +2469,7 @@ if (db) fprintf(stderr, "line1: '%s'\n", line1);
} }
} }
} }
if (res && saw_xdmcp) { if (res && saw_xdmcp && unixpw_system_greeter_active != 2) {
xdmcp_insert = strdup(keep_unixpw_user); xdmcp_insert = strdup(keep_unixpw_user);
} }
} }
...@@ -2533,7 +2570,7 @@ if (db) fprintf(stderr, "\n"); ...@@ -2533,7 +2570,7 @@ if (db) fprintf(stderr, "\n");
rc = pclose(p); rc = pclose(p);
if (rc != 0) { if (rc != 0) {
rfbLog("wait_for_client: find display cmd failed\n"); rfbLog("wait_for_client: find display cmd failed.\n");
} }
if (create_cmd && rc != 0) { if (create_cmd && rc != 0) {
...@@ -2844,6 +2881,18 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -2844,6 +2881,18 @@ int wait_for_client(int *argc, char** argv, int http) {
initialize_screen(argc, argv, fb_image); initialize_screen(argc, argv, fb_image);
if (! inetd && ! use_openssl) {
if (! screen->port || screen->listenSock < 0) {
if (got_rfbport && got_rfbport_val == 0) {
;
} else {
rfbLogEnable(1);
rfbLog("Error: could not obtain listening port.\n");
clean_up_exit(1);
}
}
}
initialize_signals(); initialize_signals();
if (ssh_str != NULL) { if (ssh_str != NULL) {
......
...@@ -75,7 +75,7 @@ double dnowx(void); ...@@ -75,7 +75,7 @@ double dnowx(void);
double rnow(void); double rnow(void);
double rfac(void); double rfac(void);
void rfbPE(long usec); int rfbPE(long usec);
void rfbCFD(long usec); void rfbCFD(long usec);
double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1, double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
...@@ -173,6 +173,26 @@ void strzero(char *str) { ...@@ -173,6 +173,26 @@ void strzero(char *str) {
} }
} }
int is_decimal(char *str) {
char *p = str;
if (p != NULL) {
int first = 1;
while (*p != '\0') {
if (first && *p == '-') {
;
} else if (isdigit((int) *p)) {
;
} else {
return 0;
}
first = 0;
p++;
}
return 1;
}
return 0;
}
int scan_hexdec(char *str, unsigned long *num) { int scan_hexdec(char *str, unsigned long *num) {
if (sscanf(str, "0x%lx", num) != 1) { if (sscanf(str, "0x%lx", num) != 1) {
if (sscanf(str, "%lu", num) != 1) { if (sscanf(str, "%lu", num) != 1) {
...@@ -450,27 +470,35 @@ double rfac(void) { ...@@ -450,27 +470,35 @@ double rfac(void) {
void check_allinput_rate(void) { void check_allinput_rate(void) {
static double last_all_input_check = 0.0; static double last_all_input_check = 0.0;
static int set = 0; static int set = 0, verb = -1;
if (use_threads) { if (use_threads) {
return; return;
} }
if (verb < 0) {
verb = 0;
if (getenv("RATE_VERB")) verb = 1;
}
if (! set) { if (! set) {
set = 1; set = 1;
last_all_input_check = dnow(); last_all_input_check = dnow();
} else { } else {
int dt = 4; int dt = 5;
if (x11vnc_current > last_all_input_check + dt) { if (x11vnc_current > last_all_input_check + dt) {
int n, nq = 0; int n, nq = 0;
while ((n = rfbCheckFds(screen, 0))) { while ((n = rfbCheckFds(screen, 0))) {
nq += n; nq += n;
} }
fprintf(stderr, "nqueued: %d\n", nq); if (verb) fprintf(stderr, "nqueued: %d\n", nq);
if (0 && nq > 25 * dt) { if (getenv("CHECK_RATE") && nq > 18 * dt) {
double rate = nq / dt; double rate = nq / dt;
rfbLog("Client is sending %.1f extra requests per second for the\n", rate); if (verb) rfbLog("check_allinput_rate:\n");
rfbLog("past %d seconds! Switching to -allpinput mode. (queued: %d)\n", dt, nq); if (verb) rfbLog("Client is sending %.1f extra requests per second for the\n", rate);
if (verb) rfbLog("past %d seconds! (queued: %d)\n", dt, nq);
if (strstr(getenv("CHECK_RATE"), "allinput") && !all_input) {
rfbLog("Switching to -allpinput mode.\n");
all_input = 1; all_input = 1;
} }
}
set = 0; set = 0;
} }
} }
...@@ -478,8 +506,8 @@ void check_allinput_rate(void) { ...@@ -478,8 +506,8 @@ void check_allinput_rate(void) {
static void do_allinput(long usec) { static void do_allinput(long usec) {
static double last = 0.0; static double last = 0.0;
static int meas = 0; static int meas = 0, verb = -1;
int n, f = 1, cnt = 0; int n, f = 1, cnt = 0, m = 0;
long usec0; long usec0;
double now; double now;
if (!screen || !screen->clientHead) { if (!screen || !screen->clientHead) {
...@@ -495,21 +523,26 @@ static void do_allinput(long usec) { ...@@ -495,21 +523,26 @@ static void do_allinput(long usec) {
if (last == 0.0) { if (last == 0.0) {
last = dnow(); last = dnow();
} }
if (verb < 0) {
verb = 0;
if (getenv("RATE_VERB")) verb = 1;
}
while ((n = rfbCheckFds(screen, usec)) > 0) { while ((n = rfbCheckFds(screen, usec)) > 0) {
if (f) { if (f) {
fprintf(stderr, " *"); if (verb) fprintf(stderr, " *");
f = 0; f = 0;
} }
if (cnt++ > 30) { if (cnt++ > 30) {
break; break;
} }
meas += n; meas += n;
m += n;
} }
fprintf(stderr, "-%d", cnt); if (verb) fprintf(stderr, "+%d/%d", cnt, m);
now = dnow(); now = dnow();
if (now > last + 2.0) { if (now > last + 2.0) {
double rate = meas / (now - last); double rate = meas / (now - last);
fprintf(stderr, "\n%.2f ", rate); if (verb) fprintf(stderr, "\n allinput rate: %.2f ", rate);
meas = 0; meas = 0;
last = dnow(); last = dnow();
} }
...@@ -520,15 +553,16 @@ static void do_allinput(long usec) { ...@@ -520,15 +553,16 @@ static void do_allinput(long usec) {
* checks that we are not in threaded mode. * checks that we are not in threaded mode.
*/ */
#define USEC_MAX 999999 /* libvncsever assumes < 1 second */ #define USEC_MAX 999999 /* libvncsever assumes < 1 second */
void rfbPE(long usec) { int rfbPE(long usec) {
int uip0 = unixpw_in_progress; int uip0 = unixpw_in_progress;
static int check_rate = -1; static int check_rate = -1;
int res = 0;
if (! screen) { if (! screen) {
return; return res;
} }
if (unixpw && unixpw_in_progress && !unixpw_in_rfbPE) { if (unixpw && unixpw_in_progress && !unixpw_in_rfbPE) {
rfbLog("unixpw_in_rfbPE: skipping rfbPE\n"); rfbLog("unixpw_in_rfbPE: skipping rfbPE\n");
return; return res;
} }
if (debug_tiles > 2) { if (debug_tiles > 2) {
...@@ -541,7 +575,11 @@ void rfbPE(long usec) { ...@@ -541,7 +575,11 @@ void rfbPE(long usec) {
usec = USEC_MAX; usec = USEC_MAX;
} }
if (! use_threads) { if (! use_threads) {
rfbProcessEvents(screen, usec); rfbBool r;
r = rfbProcessEvents(screen, usec);
if (r) {
res = 1;
}
} }
if (unixpw && unixpw_in_progress && !uip0) { if (unixpw && unixpw_in_progress && !uip0) {
...@@ -566,6 +604,7 @@ void rfbPE(long usec) { ...@@ -566,6 +604,7 @@ void rfbPE(long usec) {
if (all_input) { if (all_input) {
do_allinput(usec); do_allinput(usec);
} }
return res;
} }
void rfbCFD(long usec) { void rfbCFD(long usec) {
......
...@@ -63,7 +63,7 @@ extern double dnowx(void); ...@@ -63,7 +63,7 @@ extern double dnowx(void);
extern double rnow(void); extern double rnow(void);
extern double rfac(void); extern double rfac(void);
extern void rfbPE(long usec); extern int rfbPE(long usec);
extern void rfbCFD(long usec); extern void rfbCFD(long usec);
extern double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1, extern double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
int X2, int Y2); int X2, int Y2);
......
This diff is collapsed.
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License. * the Free Software Foundation; version 2 of the License, or (at
* your option) any later version.
* *
* This software is distributed in the hope that it will be useful, * This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -456,7 +457,7 @@ if (tstk[j] != 0) fprintf(stderr, "B redir[%d][%d] = %d %s\n", i, j, tstk[j], t ...@@ -456,7 +457,7 @@ if (tstk[j] != 0) fprintf(stderr, "B redir[%d][%d] = %d %s\n", i, j, tstk[j], t
int p0, p, found = -1, jzero = -1; int p0, p, found = -1, jzero = -1;
int conn = -1; int conn = -1;
get_prop(num, 32, atom[i]); get_prop(num, 32, atom[i], None);
p0 = atoi(num); p0 = atoi(num);
for (j = TSSTK-1; j >= 0; j--) { for (j = TSSTK-1; j >= 0; j--) {
...@@ -654,7 +655,7 @@ void do_tsd(void) { ...@@ -654,7 +655,7 @@ void do_tsd(void) {
prop[0] = '\0'; prop[0] = '\0';
a = XInternAtom(dpy, "TS_REDIR_LIST", False); a = XInternAtom(dpy, "TS_REDIR_LIST", False);
if (a != None) { if (a != None) {
get_prop(prop, 512, a); get_prop(prop, 512, a, None);
} }
if (db) fprintf(stderr, "TS_REDIR_LIST Atom: %d = '%s'\n", (int) a, prop); if (db) fprintf(stderr, "TS_REDIR_LIST Atom: %d = '%s'\n", (int) a, prop);
...@@ -784,7 +785,7 @@ static void check_redir_services(void) { ...@@ -784,7 +785,7 @@ static void check_redir_services(void) {
a = XInternAtom(dpy, "TS_REDIR_PID", False); a = XInternAtom(dpy, "TS_REDIR_PID", False);
if (a != None) { if (a != None) {
prop[0] = '\0'; prop[0] = '\0';
get_prop(prop, 512, a); get_prop(prop, 512, a, None);
if (prop[0] != '\0') { if (prop[0] != '\0') {
pid = (pid_t) atoi(prop); pid = (pid_t) atoi(prop);
} }
...@@ -806,7 +807,7 @@ static void check_redir_services(void) { ...@@ -806,7 +807,7 @@ static void check_redir_services(void) {
prop[0] = '\0'; prop[0] = '\0';
a = XInternAtom(dpy, "TS_REDIR", False); a = XInternAtom(dpy, "TS_REDIR", False);
if (a != None) { if (a != None) {
get_prop(prop, 512, a); get_prop(prop, 512, a, None);
} }
if (db) fprintf(stderr, "TS_REDIR Atom: %d = '%s'\n", (int) a, prop); if (db) fprintf(stderr, "TS_REDIR Atom: %d = '%s'\n", (int) a, prop);
if (prop[0] == '\0') { if (prop[0] == '\0') {
...@@ -1851,6 +1852,9 @@ char msg2[] = ...@@ -1851,6 +1852,9 @@ char msg2[] =
if (quiet) { if (quiet) {
return; return;
} }
if (remote_direct) {
return;
}
if (nofb) { if (nofb) {
return; return;
} }
...@@ -1859,7 +1863,7 @@ char msg2[] = ...@@ -1859,7 +1863,7 @@ char msg2[] =
#endif #endif
if (ncache == 0) { if (ncache == 0) {
fprintf(stderr, msg2); fprintf(stderr, "%s", msg2);
ncache0 = ncache = 0; ncache0 = ncache = 0;
} else { } else {
fprintf(stderr, msg, ncache); fprintf(stderr, msg, ncache);
...@@ -1904,6 +1908,7 @@ static void do_sleepin(char *sleep) { ...@@ -1904,6 +1908,7 @@ static void do_sleepin(char *sleep) {
} }
extern int dragum(void); extern int dragum(void);
extern int is_decimal(char *);
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
...@@ -1913,6 +1918,9 @@ int main(int argc, char* argv[]) { ...@@ -1913,6 +1918,9 @@ int main(int argc, char* argv[]) {
int remote_sync = 0; int remote_sync = 0;
char *remote_cmd = NULL; char *remote_cmd = NULL;
char *query_cmd = NULL; char *query_cmd = NULL;
int query_retries = 0;
double query_delay = 0.5;
char *query_match = NULL;
char *gui_str = NULL; char *gui_str = NULL;
int got_gui_pw = 0; int got_gui_pw = 0;
int pw_loc = -1, got_passwd = 0, got_rfbauth = 0, nopw = NOPW; int pw_loc = -1, got_passwd = 0, got_rfbauth = 0, nopw = NOPW;
...@@ -2440,6 +2448,10 @@ int main(int argc, char* argv[]) { ...@@ -2440,6 +2448,10 @@ int main(int argc, char* argv[]) {
got_localhost = 1; got_localhost = 1;
continue; continue;
} }
if (!strcmp(arg, "-unixpw_system_greeter")) {
unixpw_system_greeter = 1;
continue;
}
if (!strcmp(arg, "-unixpw_cmd") if (!strcmp(arg, "-unixpw_cmd")
|| !strcmp(arg, "-unixpw_cmd_unsafe")) { || !strcmp(arg, "-unixpw_cmd_unsafe")) {
CHECK_ARGC CHECK_ARGC
...@@ -2693,7 +2705,11 @@ int main(int argc, char* argv[]) { ...@@ -2693,7 +2705,11 @@ int main(int argc, char* argv[]) {
stunnel_pem = strdup(s); stunnel_pem = strdup(s);
} }
i++; i++;
} else {
stunnel_pem = strdup("SAVE");
} }
} else {
stunnel_pem = strdup("SAVE");
} }
continue; continue;
} }
...@@ -2709,7 +2725,11 @@ int main(int argc, char* argv[]) { ...@@ -2709,7 +2725,11 @@ int main(int argc, char* argv[]) {
stunnel_pem = strdup(s); stunnel_pem = strdup(s);
} }
i++; i++;
} else {
stunnel_pem = strdup("SAVE");
} }
} else {
stunnel_pem = strdup("SAVE");
} }
continue; continue;
} }
...@@ -3397,6 +3417,11 @@ int main(int argc, char* argv[]) { ...@@ -3397,6 +3417,11 @@ int main(int argc, char* argv[]) {
got_waitms = 1; got_waitms = 1;
continue; continue;
} }
if (!strcmp(arg, "-extra_fbur")) {
CHECK_ARGC
extra_fbur = atoi(argv[++i]);
continue;
}
if (!strcmp(arg, "-wait_ui")) { if (!strcmp(arg, "-wait_ui")) {
CHECK_ARGC CHECK_ARGC
wait_ui = atof(argv[++i]); wait_ui = atof(argv[++i]);
...@@ -3700,17 +3725,39 @@ int main(int argc, char* argv[]) { ...@@ -3700,17 +3725,39 @@ int main(int argc, char* argv[]) {
remote_cmd = str; remote_cmd = str;
} }
} }
if (!getenv("QUERY_VERBOSE")) {
quiet = 1; quiet = 1;
}
xkbcompat = 0; xkbcompat = 0;
continue; continue;
} }
if (!strcmp(arg, "-query") || !strcmp(arg, "-Q")) { if (!strcmp(arg, "-query") || !strcmp(arg, "-Q")) {
CHECK_ARGC CHECK_ARGC
query_cmd = strdup(argv[++i]); query_cmd = strdup(argv[++i]);
if (!getenv("QUERY_VERBOSE")) {
quiet = 1; quiet = 1;
}
xkbcompat = 0; xkbcompat = 0;
continue; continue;
} }
if (!strcmp(arg, "-query_retries")) {
char *s;
CHECK_ARGC
s = strdup(argv[++i]);
/* n[:t][/match] */
if (strchr(s, '/')) {
char *q = strchr(s, '/');
query_match = strdup(q+1);
*q = '\0';
}
if (strchr(s, ':')) {
char *q = strchr(s, ':');
query_delay = atof(q+1);
}
query_retries = atoi(s);
free(s);
continue;
}
if (!strcmp(arg, "-QD")) { if (!strcmp(arg, "-QD")) {
CHECK_ARGC CHECK_ARGC
query_cmd = strdup(argv[++i]); query_cmd = strdup(argv[++i]);
...@@ -3725,6 +3772,11 @@ int main(int argc, char* argv[]) { ...@@ -3725,6 +3772,11 @@ int main(int argc, char* argv[]) {
remote_sync = 0; remote_sync = 0;
continue; continue;
} }
if (!strcmp(arg, "-remote_prefix")) {
CHECK_ARGC
remote_prefix = strdup(argv[++i]);
continue;
}
if (!strcmp(arg, "-noremote")) { if (!strcmp(arg, "-noremote")) {
accept_remote_cmds = 0; accept_remote_cmds = 0;
continue; continue;
...@@ -3784,10 +3836,23 @@ int main(int argc, char* argv[]) { ...@@ -3784,10 +3836,23 @@ int main(int argc, char* argv[]) {
} }
if (!strcmp(arg, "-rfbport") && i < argc-1) { if (!strcmp(arg, "-rfbport") && i < argc-1) {
got_rfbport = 1; got_rfbport = 1;
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");
}
got_rfbport_str = strdup(argv[i+1]); got_rfbport_str = strdup(argv[i+1]);
got_rfbport_pos = argc_vnc+1; got_rfbport_pos = argc_vnc+1;
got_rfbport_val = atoi(argv[i+1]); got_rfbport_val = atoi(argv[i+1]);
} }
if (!strcmp(arg, "-httpport") && i < argc-1) {
if (!is_decimal(argv[i+1])) {
rfbLog("Invalid -httpport value: '%s'\n", argv[i+1]);
clean_up_exit(1);
}
}
if (!strcmp(arg, "-alwaysshared ")) { if (!strcmp(arg, "-alwaysshared ")) {
got_alwaysshared = 1; got_alwaysshared = 1;
} }
...@@ -3815,6 +3880,11 @@ int main(int argc, char* argv[]) { ...@@ -3815,6 +3880,11 @@ int main(int argc, char* argv[]) {
set_env("LIBXCB_ALLOW_SLOPPY_LOCK", "1"); set_env("LIBXCB_ALLOW_SLOPPY_LOCK", "1");
} }
if (getenv("PATH") == NULL || !strcmp(getenv("PATH"), "")) {
/* set a minimal PATH, usually only null in inetd. */
set_env("PATH", "/bin:/usr/bin");
}
/* set OS struct UT */ /* set OS struct UT */
uname(&UT); uname(&UT);
...@@ -4052,8 +4122,25 @@ int main(int argc, char* argv[]) { ...@@ -4052,8 +4122,25 @@ int main(int argc, char* argv[]) {
* similar for query_default. * similar for query_default.
*/ */
if (client_connect_file || query_default) { if (client_connect_file || query_default) {
int rc = do_remote_query(remote_cmd, query_cmd, int i, rc = 1;
for (i=0; i <= query_retries; i++) {
rc = do_remote_query(remote_cmd, query_cmd,
remote_sync, query_default); remote_sync, query_default);
if (rc == 0) {
if (query_match) {
if (query_result && strstr(query_result, query_match)) {
break;
}
rc = 1;
} else {
break;
}
}
if (i < query_retries) {
fprintf(stderr, "sleep: %.3f\n", query_delay);
usleep( (int) (query_delay * 1000 * 1000) );
}
}
fflush(stderr); fflush(stderr);
fflush(stdout); fflush(stdout);
exit(rc); exit(rc);
...@@ -4426,6 +4513,8 @@ int main(int argc, char* argv[]) { ...@@ -4426,6 +4513,8 @@ int main(int argc, char* argv[]) {
} }
} }
http_try_it = try_http;
if (flip_byte_order && using_shm && ! quiet) { if (flip_byte_order && using_shm && ! quiet) {
rfbLog("warning: -flipbyte order only works with -noshm\n"); rfbLog("warning: -flipbyte order only works with -noshm\n");
} }
...@@ -4492,6 +4581,7 @@ int main(int argc, char* argv[]) { ...@@ -4492,6 +4581,7 @@ int main(int argc, char* argv[]) {
} }
if (debug_pointer || debug_keyboard) { if (debug_pointer || debug_keyboard) {
if (!logfile) {
if (bg || quiet) { if (bg || quiet) {
rfbLog("disabling -bg/-q under -debug_pointer" rfbLog("disabling -bg/-q under -debug_pointer"
"/-debug_keyboard\n"); "/-debug_keyboard\n");
...@@ -4499,6 +4589,7 @@ int main(int argc, char* argv[]) { ...@@ -4499,6 +4589,7 @@ int main(int argc, char* argv[]) {
quiet = 0; quiet = 0;
} }
} }
}
/* initialize added_keysyms[] array to zeros */ /* initialize added_keysyms[] array to zeros */
add_keysym(NoSymbol); add_keysym(NoSymbol);
...@@ -4521,7 +4612,7 @@ int main(int argc, char* argv[]) { ...@@ -4521,7 +4612,7 @@ int main(int argc, char* argv[]) {
if (verbose) { if (verbose) {
print_settings(try_http, bg, gui_str); print_settings(try_http, bg, gui_str);
} }
rfbLog("x11vnc version: %s\n", lastmod); rfbLog("x11vnc version: %s pid: %d\n", lastmod, getpid());
} else { } else {
rfbLogEnable(0); rfbLogEnable(0);
} }
...@@ -4728,14 +4819,38 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY")); ...@@ -4728,14 +4819,38 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
window = save; window = save;
} }
if (! quiet && ! raw_fb_str) { if ( (remote_cmd && strstr(remote_cmd, "DIRECT:") == remote_cmd)
rfbLog("\n"); || (query_cmd && strstr(query_cmd, "DIRECT:") == query_cmd )) {
rfbLog("------------------ USEFUL INFORMATION ------------------\n"); /* handled below after most everything is setup. */
if (getenv("QUERY_VERBOSE")) {
quiet = 0;
} else {
quiet = 1;
remote_direct = 1;
} }
if (!auto_port) {
if (remote_cmd || query_cmd) { auto_port = 5970;
int rc = do_remote_query(remote_cmd, query_cmd, remote_sync, }
} else if (remote_cmd || query_cmd) {
int i, rc = 1;
for (i=0; i <= query_retries; i++) {
rc = do_remote_query(remote_cmd, query_cmd, remote_sync,
query_default); query_default);
if (rc == 0) {
if (query_match) {
if (query_result && strstr(query_result, query_match)) {
break;
}
rc = 1;
} else {
break;
}
}
if (i < query_retries) {
fprintf(stderr, "sleep: %.3f\n", query_delay);
usleep( (int) (query_delay * 1000 * 1000) );
}
}
XFlush_wr(dpy); XFlush_wr(dpy);
fflush(stderr); fflush(stderr);
fflush(stdout); fflush(stdout);
...@@ -4744,6 +4859,11 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY")); ...@@ -4744,6 +4859,11 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
exit(rc); exit(rc);
} }
if (! quiet && ! raw_fb_str) {
rfbLog("\n");
rfbLog("------------------ USEFUL INFORMATION ------------------\n");
}
if (priv_remote) { if (priv_remote) {
if (! remote_control_access_ok()) { if (! remote_control_access_ok()) {
rfbLog("** Disabling remote commands in -privremote mode.\n"); rfbLog("** Disabling remote commands in -privremote mode.\n");
...@@ -5086,7 +5206,9 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY")); ...@@ -5086,7 +5206,9 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
} }
#endif #endif
if (!getenv("X11VNC_NO_CHECK_PM")) {
check_pm(); check_pm();
}
if (! quiet && ! raw_fb_str) { if (! quiet && ! raw_fb_str) {
rfbLog("--------------------------------------------------------\n"); rfbLog("--------------------------------------------------------\n");
...@@ -5322,6 +5444,13 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY")); ...@@ -5322,6 +5444,13 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
ncache_beta_tester_message(); ncache_beta_tester_message();
} }
if (remote_cmd || query_cmd) {
/* This is DIRECT: case */
do_remote_query(remote_cmd, query_cmd, remote_sync, query_default);
if (getenv("SLEEP")) sleep(atoi(getenv("SLEEP")));
clean_up_exit(0);
}
#if LIBVNCSERVER_HAVE_FORK && LIBVNCSERVER_HAVE_SETSID #if LIBVNCSERVER_HAVE_FORK && LIBVNCSERVER_HAVE_SETSID
if (bg) { if (bg) {
int p, n; int p, n;
......
...@@ -47,7 +47,7 @@ int xtrap_base_event_type = 0; ...@@ -47,7 +47,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.9.9 lastmod: 2009-08-10"; char lastmod[] = "0.9.9 lastmod: 2009-10-07";
/* X display info */ /* X display info */
......
...@@ -56,6 +56,8 @@ int xdamage_max_area = 20000; /* pixels */ ...@@ -56,6 +56,8 @@ int xdamage_max_area = 20000; /* pixels */
double xdamage_memory = 1.0; /* in units of NSCAN */ double xdamage_memory = 1.0; /* in units of NSCAN */
int xdamage_tile_count = 0, xdamage_direct_count = 0; int xdamage_tile_count = 0, xdamage_direct_count = 0;
double xdamage_scheduled_mark = 0.0; double xdamage_scheduled_mark = 0.0;
double xdamage_crazy_time = 0.0;
double xdamage_crazy_delay = 300.0;
sraRegionPtr xdamage_scheduled_mark_region = NULL; sraRegionPtr xdamage_scheduled_mark_region = NULL;
sraRegionPtr *xdamage_regions = NULL; sraRegionPtr *xdamage_regions = NULL;
int xdamage_ticker = 0; int xdamage_ticker = 0;
...@@ -400,6 +402,7 @@ int collect_xdamage(int scancnt, int call) { ...@@ -400,6 +402,7 @@ int collect_xdamage(int scancnt, int call) {
#define DUPSZ 32 #define DUPSZ 32
int dup_x[DUPSZ], dup_y[DUPSZ], dup_w[DUPSZ], dup_h[DUPSZ]; int dup_x[DUPSZ], dup_y[DUPSZ], dup_w[DUPSZ], dup_h[DUPSZ];
double tm, dt; double tm, dt;
int mark_all = 0, retries = 0, too_many = 1000, tot_ev = 0;
RAWFB_RET(0) RAWFB_RET(0)
...@@ -443,6 +446,9 @@ int collect_xdamage(int scancnt, int call) { ...@@ -443,6 +446,9 @@ int collect_xdamage(int scancnt, int call) {
X_LOCK; X_LOCK;
if (0) XFlush_wr(dpy); if (0) XFlush_wr(dpy);
if (0) XEventsQueued(dpy, QueuedAfterFlush); if (0) XEventsQueued(dpy, QueuedAfterFlush);
come_back_for_more:
while (XCheckTypedEvent(dpy, xdamage_base_event_type+XDamageNotify, &ev)) { while (XCheckTypedEvent(dpy, xdamage_base_event_type+XDamageNotify, &ev)) {
/* /*
* TODO max cut off time in this loop? * TODO max cut off time in this loop?
...@@ -450,6 +456,26 @@ if (0) XEventsQueued(dpy, QueuedAfterFlush); ...@@ -450,6 +456,26 @@ if (0) XEventsQueued(dpy, QueuedAfterFlush);
* screen. * screen.
*/ */
ecount++; ecount++;
tot_ev++;
if (mark_all) {
continue;
}
if (ecount == too_many) {
int nqa = XEventsQueued(dpy, QueuedAlready);
if (nqa >= too_many) {
static double last_msg = 0.0;
tmpregion = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
sraRgnOr(reg, tmpregion);
sraRgnDestroy(tmpregion);
if (dnow() > last_msg + xdamage_crazy_delay) {
rfbLog("collect_xdamage: too many xdamage events %d+%d\n", ecount, nqa);
last_msg = dnow();
}
mark_all = 1;
}
}
if (ev.type != xdamage_base_event_type + XDamageNotify) { if (ev.type != xdamage_base_event_type + XDamageNotify) {
break; break;
} }
...@@ -537,12 +563,37 @@ if (0) XEventsQueued(dpy, QueuedAfterFlush); ...@@ -537,12 +563,37 @@ if (0) XEventsQueued(dpy, QueuedAfterFlush);
rect_count++; rect_count++;
ccount++; ccount++;
} }
if (mark_all) {
if (ecount + XEventsQueued(dpy, QueuedAlready) >= 3 * too_many && retries < 3) {
retries++;
XFlush_wr(dpy);
usleep(20 * 1000);
XFlush_wr(dpy);
ecount = 0;
goto come_back_for_more;
}
}
/* clear the whole damage region for next time. XXX check */ /* clear the whole damage region for next time. XXX check */
if (call == 1) { if (call == 1) {
XDamageSubtract(dpy, xdamage, None, None); XDamageSubtract(dpy, xdamage, None, None);
} }
X_UNLOCK; X_UNLOCK;
if (tot_ev > 20 * too_many) {
rfbLog("collect_xdamage: xdamage has gone crazy (screensaver or game?) ev: %d ret: %d\n", tot_ev, retries);
rfbLog("collect_xdamage: disabling xdamage for %d seconds.\n", (int) xdamage_crazy_delay);
destroy_xdamage_if_needed();
X_LOCK;
XSync(dpy, False);
while (XCheckTypedEvent(dpy, xdamage_base_event_type+XDamageNotify, &ev)) {
;
}
X_UNLOCK;
xdamage_crazy_time = dnow();
}
if (0 && xdamage_direct_count) { if (0 && xdamage_direct_count) {
fb_push(); fb_push();
} }
...@@ -762,6 +813,9 @@ void check_xdamage_state(void) { ...@@ -762,6 +813,9 @@ void check_xdamage_state(void) {
* Create or destroy the Damage object as needed, we don't want * Create or destroy the Damage object as needed, we don't want
* one if no clients are connected. * one if no clients are connected.
*/ */
if (xdamage_crazy_time > 0.0 && dnow() < xdamage_crazy_time + xdamage_crazy_delay) {
return;
}
if (client_count && use_xdamage) { if (client_count && use_xdamage) {
create_xdamage_if_needed(0); create_xdamage_if_needed(0);
if (xdamage_scheduled_mark > 0.0 && dnow() > if (xdamage_scheduled_mark > 0.0 && dnow() >
......
...@@ -44,6 +44,8 @@ extern int xdamage_max_area; ...@@ -44,6 +44,8 @@ extern int xdamage_max_area;
extern double xdamage_memory; extern double xdamage_memory;
extern int xdamage_tile_count, xdamage_direct_count; extern int xdamage_tile_count, xdamage_direct_count;
extern double xdamage_scheduled_mark; extern double xdamage_scheduled_mark;
extern double xdamage_crazy_time;
extern double xdamage_crazy_delay;
extern sraRegionPtr xdamage_scheduled_mark_region; extern sraRegionPtr xdamage_scheduled_mark_region;
extern sraRegionPtr *xdamage_regions; extern sraRegionPtr *xdamage_regions;
extern int xdamage_ticker; extern int xdamage_ticker;
......
...@@ -76,7 +76,7 @@ void set_server_input(rfbClientPtr cl, int s); ...@@ -76,7 +76,7 @@ void set_server_input(rfbClientPtr cl, int s);
void set_text_chat(rfbClientPtr cl, int l, char *t); void set_text_chat(rfbClientPtr cl, int l, char *t);
int get_keyboard_led_state_hook(rfbScreenInfoPtr s); int get_keyboard_led_state_hook(rfbScreenInfoPtr s);
int get_file_transfer_permitted(rfbClientPtr cl); int get_file_transfer_permitted(rfbClientPtr cl);
void get_prop(char *str, int len, Atom prop); void get_prop(char *str, int len, Atom prop, Window w);
static void initialize_xevents(int reset); static void initialize_xevents(int reset);
static void print_xevent_bases(void); static void print_xevent_bases(void);
...@@ -212,7 +212,7 @@ static void print_xevent_bases(void) { ...@@ -212,7 +212,7 @@ static void print_xevent_bases(void) {
fprintf(stderr, " SelClear=%d, Expose=%d\n", SelectionClear, Expose); fprintf(stderr, " SelClear=%d, Expose=%d\n", SelectionClear, Expose);
} }
void get_prop(char *str, int len, Atom prop) { void get_prop(char *str, int len, Atom prop, Window w) {
int i; int i;
#if !NO_X11 #if !NO_X11
Atom type; Atom type;
...@@ -235,9 +235,12 @@ void get_prop(char *str, int len, Atom prop) { ...@@ -235,9 +235,12 @@ void get_prop(char *str, int len, Atom prop) {
#else #else
slen = 0; slen = 0;
if (w == None) {
w = DefaultRootWindow(dpy);
}
do { do {
if (XGetWindowProperty(dpy, DefaultRootWindow(dpy), if (XGetWindowProperty(dpy, w,
prop, nitems/4, len/16, False, prop, nitems/4, len/16, False,
AnyPropertyType, &type, &format, &nitems, &bytes_after, AnyPropertyType, &type, &format, &nitems, &bytes_after,
&data) == Success) { &data) == Success) {
...@@ -584,7 +587,7 @@ static void grab_buster_watch(int parent, char *dstr) { ...@@ -584,7 +587,7 @@ static void grab_buster_watch(int parent, char *dstr) {
break; break;
} }
get_prop(propval, 128, ticker_atom); get_prop(propval, 128, ticker_atom, None);
if (db) fprintf(stderr, "got_prop: %s\n", propval); if (db) fprintf(stderr, "got_prop: %s\n", propval);
if (!process_watch(propval, parent, db)) { if (!process_watch(propval, parent, db)) {
...@@ -871,22 +874,50 @@ void check_autorepeat(void) { ...@@ -871,22 +874,50 @@ void check_autorepeat(void) {
} }
} else { } else {
if (idle_reset) { if (idle_reset) {
int i, state[256]; int i, state[256], didmsg = 0, pressed = 0;
int mwt = 600, mmax = 20;
static int msgcnt = 0;
static double lastmsg = 0.0;
for (i=0; i<256; i++) { for (i=0; i<256; i++) {
state[i] = 0; state[i] = 0;
} }
if (use_threads) {X_LOCK;} if (use_threads) {X_LOCK;}
get_keystate(state); get_keystate(state);
if (use_threads) {X_UNLOCK;} if (use_threads) {X_UNLOCK;}
for (i=0; i<256; i++) { for (i=0; i<256; i++) {
if (state[i] != 0) { if (state[i] != 0) {
/* better wait until all keys are up */ /* better wait until all keys are up */
rfbLog("active keyboard: waiting until" pressed++;
" all keys are up. key_down=%d\n", i); if (msgcnt < mmax || dnow() > lastmsg + mwt) {
return; char *str = "unset";
#if !NO_X11
if (use_threads) {X_LOCK;}
str = XKeysymToString(XKeycodeToKeysym(dpy, i, 0));
if (use_threads) {X_UNLOCK;}
#endif
str = str ? str : "nosymbol";
didmsg++;
rfbLog("active keyboard: waiting until "
"all keys are up. key_down=%d %s. "
"If the key is inaccessible via keyboard, "
"consider 'x11vnc -R clear_all'\n", i, str);
} }
} }
} }
if (didmsg > 0) {
msgcnt++;
if (msgcnt == mmax) {
rfbLog("active keyboard: last such "
"message for %d secs.\n", mwt);
}
lastmsg = dnow();
}
if (pressed > 0) {
return;
}
}
if (idle_reset) { if (idle_reset) {
static time_t last_msg = 0; static time_t last_msg = 0;
static int cnt = 0; static int cnt = 0;
...@@ -1055,38 +1086,83 @@ void check_xevents(int reset) { ...@@ -1055,38 +1086,83 @@ void check_xevents(int reset) {
last_call = now; last_call = now;
} }
/* check for CUT_BUFFER0 and VNC_CONNECT changes: */ /* check for CUT_BUFFER0, VNC_CONNECT, X11VNC_REMOTE changes: */
if (XCheckTypedEvent(dpy, PropertyNotify, &xev)) { if (XCheckTypedEvent(dpy, PropertyNotify, &xev)) {
int got_cutbuffer = 0;
int got_vnc_connect = 0;
int got_x11vnc_remote = 0;
static int prop_dbg = -1;
/* to avoid piling up between calls, read all PropertyNotify now */
do {
if (xev.type == PropertyNotify) { if (xev.type == PropertyNotify) {
if (xev.xproperty.atom == XA_CUT_BUFFER0) { if (xev.xproperty.atom == XA_CUT_BUFFER0) {
got_cutbuffer++;
} else if (vnc_connect && vnc_connect_prop != None
&& xev.xproperty.atom == vnc_connect_prop) {
got_vnc_connect++;
} else if (vnc_connect && x11vnc_remote_prop != None
&& xev.xproperty.atom == x11vnc_remote_prop) {
got_x11vnc_remote++;
}
set_prop_atom(xev.xproperty.atom);
}
} while (XCheckTypedEvent(dpy, PropertyNotify, &xev));
if (prop_dbg < 0) {
prop_dbg = 0;
if (getenv("PROP_DBG")) {
prop_dbg = 1;
}
}
if (prop_dbg && (got_cutbuffer > 1 || got_vnc_connect > 1 || got_x11vnc_remote > 1)) {
static double lastmsg = 0.0;
static int count = 0;
double now = dnow();
if (1 && now > lastmsg + 300.0) {
if (got_cutbuffer > 1) {
rfbLog("check_xevents: warning: %d cutbuffer events since last check.\n", got_cutbuffer);
}
if (got_vnc_connect > 1) {
rfbLog("check_xevents: warning: %d vnc_connect events since last check.\n", got_vnc_connect);
}
if (got_x11vnc_remote > 1) {
rfbLog("check_xevents: warning: %d x11vnc_remote events since last check.\n", got_x11vnc_remote);
}
count++;
if (count >= 3) {
lastmsg = now;
count = 0;
}
}
}
if (got_cutbuffer) {
/* /*
* Go retrieve CUT_BUFFER0 and send it. * Go retrieve CUT_BUFFER0 and send it.
* *
* set_cutbuffer is a flag to try to avoid * set_cutbuffer is a flag to try to avoid
* processing our own cutbuffer changes. * processing our own cutbuffer changes.
*/ */
if (have_clients && watch_selection if (have_clients && watch_selection && !set_cutbuffer) {
&& ! set_cutbuffer) {
cutbuffer_send(); cutbuffer_send();
sent_some_sel = 1; sent_some_sel = 1;
} }
set_cutbuffer = 0; set_cutbuffer = 0;
} else if (vnc_connect && vnc_connect_prop != None }
&& xev.xproperty.atom == vnc_connect_prop) { if (got_vnc_connect) {
/* /*
* Go retrieve VNC_CONNECT string. * Go retrieve VNC_CONNECT string.
*/ */
read_vnc_connect_prop(0); read_vnc_connect_prop(0);
} else if (vnc_connect && x11vnc_remote_prop != None }
&& xev.xproperty.atom == x11vnc_remote_prop) { if (got_x11vnc_remote) {
/* /*
* Go retrieve X11VNC_REMOTE string. * Go retrieve X11VNC_REMOTE string.
*/ */
read_x11vnc_remote_prop(0); read_x11vnc_remote_prop(0);
}
set_prop_atom(xev.xproperty.atom);
} }
} }
...@@ -1367,6 +1443,39 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) { ...@@ -1367,6 +1443,39 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) {
return; return;
} }
if (remote_prefix != NULL && strstr(text, remote_prefix) == text) {
char *result, *rcmd = text + strlen(remote_prefix);
char *tmp = (char *) calloc(len + 8, 1);
if (strstr(rcmd, "cmd=") != rcmd && strstr(rcmd, "qry=") != rcmd) {
strcat(tmp, "qry=");
}
strncat(tmp, rcmd, len - strlen(remote_prefix));
rfbLog("remote_prefix command: '%s'\n", tmp);
result = process_remote_cmd(tmp, 1);
if (result == NULL ) {
result = strdup("null");
} else if (!strcmp(result, "")) {
free(result);
result = strdup("none");
}
rfbLog("remote_prefix result: '%s'\n", result);
free(tmp);
tmp = (char *) calloc(strlen(remote_prefix) + strlen(result) + 1, 1);
strcat(tmp, remote_prefix);
strcat(tmp, result);
free(result);
rfbSendServerCutText(screen, tmp, strlen(tmp));
free(tmp);
return;
}
if (! check_sel_direction("recv", "xcut_receive", text, len)) { if (! check_sel_direction("recv", "xcut_receive", text, len)) {
return; return;
} }
......
...@@ -59,7 +59,7 @@ extern void set_server_input(rfbClientPtr cl, int s); ...@@ -59,7 +59,7 @@ extern void set_server_input(rfbClientPtr cl, int s);
extern void set_text_chat(rfbClientPtr cl, int l, char *t); extern void set_text_chat(rfbClientPtr cl, int l, char *t);
extern int get_keyboard_led_state_hook(rfbScreenInfoPtr s); extern int get_keyboard_led_state_hook(rfbScreenInfoPtr s);
extern int get_file_transfer_permitted(rfbClientPtr cl); extern int get_file_transfer_permitted(rfbClientPtr cl);
extern void get_prop(char *str, int len, Atom prop); extern void get_prop(char *str, int len, Atom prop, Window w);
#endif /* _X11VNC_XEVENTS_H */ #endif /* _X11VNC_XEVENTS_H */
...@@ -755,7 +755,6 @@ if (db) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, s ...@@ -755,7 +755,6 @@ if (db) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, s
del = 0; del = 0;
while (len > 0) { while (len > 0) {
n = read(raw_fb_fd, dst + del, len); n = read(raw_fb_fd, dst + del, len);
//if (db > 2) fprintf(stderr, "len: %d n: %d\n", len, n);
if (n > 0) { if (n > 0) {
del += n; del += n;
...@@ -767,7 +766,6 @@ if (db) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, s ...@@ -767,7 +766,6 @@ if (db) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, s
} }
} }
if (bpl > sz) { if (bpl > sz) {
//if (db > 1) fprintf(stderr, "bpl>sz %d %d\n", bpl, sz);
off = (off_t) (bpl - sz); off = (off_t) (bpl - sz);
lseek(raw_fb_fd, off, SEEK_CUR); lseek(raw_fb_fd, off, SEEK_CUR);
} }
......
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