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
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
--- 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
@@ -0,0 +1,1726 @@
+++ vnc_javasrc/SSLSocketToMe.java 2009-08-13 09:16:42.000000000 -0400
@@ -0,0 +1,1727 @@
+/*
+ * 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
+ *
+ * This is free software; you can redistribute it and/or modify
+ * 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,
+ * 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>
* classes/ssl: java viewer now handles auth-basic proxy logins.
* 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
int len, FILE *output);
extern int check_access(char *addr);
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 */
......@@ -71,7 +71,8 @@ so, delete this exception statement from your version.
*
* This is free software; you can redistribute it and/or modify
* 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,
* 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,
* why nothing needs to be done with the modifier, see below.
*
* 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++) {
......@@ -2780,6 +2780,11 @@ void get_allowed_input(rfbClientPtr client, allowed_input_t *input) {
input->files = 0;
if (! client) {
input->keystroke = 1;
input->motion = 1;
input->button = 1;
input->clipboard = 1;
input->files = 1;
return;
}
......
......@@ -55,6 +55,8 @@ int unixpw = 0; /* -unixpw */
int unixpw_nis = 0; /* -unixpw_nis */
char *unixpw_list = NULL;
char *unixpw_cmd = NULL;
int unixpw_system_greeter = 0;
int unixpw_system_greeter_active = 0;
int use_stunnel = 0; /* -stunnel */
int stunnel_port = 0;
char *stunnel_pem = NULL;
......@@ -70,6 +72,8 @@ int vencrypt_enable_plain_login = 0;
int anontls_mode = ANONTLS_SUPPORT;
int create_fresh_dhparams = 0;
char *dhparams_file = NULL;
int http_try_it = 0;
int stunnel_http_port = 0;
int https_port_num = -1;
int https_port_redir = 0;
char *ssl_verify = NULL;
......@@ -112,6 +116,8 @@ int deny_all = 0; /* global locking of new clients */
#define REMOTE_DEFAULT 1
#endif
int accept_remote_cmds = REMOTE_DEFAULT; /* -noremote */
char *remote_prefix = NULL;
int remote_direct = 0;
int query_default = 0;
int safe_remote_only = 1; /* -unsafe */
int priv_remote = 0; /* -privremote */
......@@ -402,6 +408,7 @@ double wait_ui = 2.0;
double slow_fb = 0.0;
double xrefresh = 0.0;
int wait_bog = 1;
int extra_fbur = 1;
int defer_update = 20; /* deferUpdateTime ms to wait before sends. */
int set_defer = 1;
int got_defer = 0;
......
......@@ -55,6 +55,8 @@ extern int unixpw;
extern int unixpw_nis;
extern char *unixpw_list;
extern char *unixpw_cmd;
extern int unixpw_system_greeter;
extern int unixpw_system_greeter_active;
extern int use_stunnel;
extern int stunnel_port;
extern char *stunnel_pem;
......@@ -70,6 +72,8 @@ extern int vencrypt_enable_plain_login;
extern int anontls_mode;
extern int create_fresh_dhparams;
extern char *dhparams_file;
extern int http_try_it;
extern int stunnel_http_port;
extern int https_port_num;
extern int https_port_redir;
extern char *ssl_verify;
......@@ -100,6 +104,8 @@ extern int connect_once;
extern int got_connect_once;
extern int deny_all;
extern int accept_remote_cmds;
extern char *remote_prefix;
extern int remote_direct;
extern int query_default;
extern int safe_remote_only;
extern int priv_remote;
......@@ -307,6 +313,7 @@ extern double wait_ui;
extern double slow_fb;
extern double xrefresh;
extern int wait_bog;
extern int extra_fbur;
extern int defer_update;
extern int set_defer;
extern int got_defer;
......
......@@ -63,8 +63,8 @@ so, delete this exception statement from your version.
#define FB_REQ 0x4
#define VNC_CONNECT_MAX 16384
#define X11VNC_REMOTE_MAX 16384
#define PROP_MAX (131072L)
#define X11VNC_REMOTE_MAX 65536
#define PROP_MAX (262144L)
#define MAXN 256
......
This diff is collapsed.
......@@ -44,4 +44,7 @@ extern void http_connections(int on);
extern int remote_control_access_ok(void);
extern char *process_remote_cmd(char *cmd, int stringonly);
extern char *query_result;
#endif /* _X11VNC_REMOTE_H */
......@@ -1179,6 +1179,8 @@ static char* vnc_reflect_get_password(rfbClient* client) {
char *q, *p, *str = getenv("X11VNC_REFLECT_PASSWORD");
int len = 110;
if (client) {}
if (str) {
len += 2*strlen(str);
}
......@@ -2846,11 +2848,17 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
/* n.b. samplesPerPixel (set = 1 here) seems to be unused. */
if (create_screen) {
if (use_openssl) {
openssl_init(0);
} else if (use_stunnel) {
if (use_stunnel) {
setup_stunnel(0, argc, argv);
}
if (use_openssl) {
if (use_stunnel && enc_str && !strcmp(enc_str, "none")) {
/* emulating HTTPS oneport */
;
} else {
openssl_init(0);
}
}
screen = rfbGetScreen(argc, argv, width, height,
bits_per_color, 1, fb_bpp/8);
if (screen && http_dir) {
......@@ -3367,6 +3375,10 @@ void announce(int lport, int ssl, char *iface) {
char *host = this_host();
char *tvdt;
if (remote_direct) {
return;
}
if (! ssl) {
tvdt = "The VNC desktop is: ";
} else {
......@@ -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 *jvu;
if (enc_str && !strcmp(enc_str, "none")) {
if (enc_str && !strcmp(enc_str, "none") && !use_stunnel) {
jvu = "Java viewer URL: http";
} else if (ssl == 1) {
jvu = "Java SSL viewer URL: https";
......@@ -3442,44 +3454,91 @@ static void announce_http(int lport, int ssl, char *iface) {
}
if (host != NULL) {
if (! inetd) {
fprintf(stderr, "%s://%s:%d/\n", jvu, host, lport);
if (screen && enc_str && !strcmp(enc_str, "none")) {
fprintf(stderr, "%s://%s:%d/\n", jvu, host, screen->port);
fprintf(stderr, "%s://%s:%d/%s\n", jvu, host, lport, extra);
}
}
}
void do_announce_http(void) {
if (!screen) {
return;
}
if (remote_direct) {
return;
}
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) {
rfbLog("\n");
rfbLog("The URLs printed out below ('Java ... viewer URL') can\n");
rfbLog("be used for Java enabled Web browser connections.\n");
if (!stunnel_port && enc_str && !strcmp(enc_str, "none")) {
;
} else if (use_openssl || stunnel_port) {
rfbLog("Here are some additional possibilities:\n");
rfbLog("\n");
rfbLog("https://host:port/proxy.vnc (MUST be used if Web Proxy used)\n");
rfbLog("\n");
rfbLog("https://host:port/ultra.vnc (Use UltraVNC Java Viewer)\n");
rfbLog("https://host:port/ultraproxy.vnc (Web Proxy with UltraVNC)\n");
rfbLog("https://host:port/ultrasigned.vnc (Signed UltraVNC Filexfer)\n");
rfbLog("\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("\n");
rfbLog("Append ?GET=1 to a URL for faster loading.\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) {
if (! quiet) {
if (screen->httpListenSock > -1 && screen->httpPort) {
rfbLog("\n");
rfbLog("The URLs printed out below ('Java ... viewer URL') can\n");
rfbLog("be used for Java enabled Web browser connections.\n");
if (enc_str && !strcmp(enc_str, "none")) {
;
} else if (use_openssl || stunnel_port) {
rfbLog("Here are some additional possibilities:\n");
rfbLog("\n");
rfbLog("https://host:port/proxy.vnc (MUST be used if Web Proxy used)\n");
rfbLog("\n");
rfbLog("https://host:port/ultra.vnc (Use UltraVNC Java Viewer)\n");
rfbLog("https://host:port/ultraproxy.vnc (Web Proxy with UltraVNC)\n");
rfbLog("https://host:port/ultrasigned.vnc (Signed UltraVNC Filexfer)\n");
rfbLog("\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("\n");
}
do_mention_java_urls();
if (use_openssl) {
announce(screen->port, 1, listen_str);
......@@ -3489,24 +3548,8 @@ void set_vnc_desktop_name(void) {
if (stunnel_port) {
announce(stunnel_port, 1, NULL);
}
if (screen->httpListenSock > -1 && screen->httpPort) {
if (use_openssl) {
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);
}
}
do_announce_http();
fflush(stderr);
if (inetd) {
......@@ -3954,13 +3997,19 @@ void watch_loop(void) {
* see quickly (just 1 rfbPE will likely
* 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(-1);
rfbPE(0);
rfbPE(0);
} else {
if (extra_fbur > 0) {
int i;
for (i=0; i < extra_fbur; i++) {
rfbPE(0);
}
}
rfbPE(-1);
}
if (x11vnc_current < last_new_client + 0.5) {
......@@ -4126,6 +4175,7 @@ void watch_loop(void) {
} else {
static double last_dt = 0.0;
double xdamage_thrash = 0.4;
static int tilecut = -1;
check_cursor_changes();
......@@ -4176,8 +4226,15 @@ void watch_loop(void) {
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)
&& (tile_diffs > 4 || debug_tiles > 1)) {
&& (tile_diffs > tilecut || debug_tiles > 1)) {
double rate = (tile_x * tile_y * bpp/8 * tile_diffs) / dt;
fprintf(stderr, "============================= TILES: %d dt: %.4f"
" t: %.4f %.2f MB/s nap_ok: %d\n", tile_diffs, dt,
......@@ -4188,13 +4245,33 @@ void watch_loop(void) {
/* sleep a bit to lessen load */
wait = choose_delay(dt);
if (urgent_update) {
;
} else if (wait > 2*waitms) {
/* bog case, break it up */
nap_sleep(wait, 10);
} 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);
t2 = dnow();
idt = (int) (1000. * (t2 - t1));
if (idt > 0 && idt < wait) {
/* try to sleep the remainder */
usleep((wait - idt) * 1000);
}
}
cnt++;
......
......@@ -64,6 +64,7 @@ void selection_request(XEvent *ev, char *type);
int check_sel_direction(char *dir, char *label, char *sel, int len);
void cutbuffer_send(void);
void selection_send(XEvent *ev);
void resend_selection(char *type);
/*
......@@ -76,6 +77,9 @@ void selection_send(XEvent *ev);
static char cutbuffer_str[PROP_MAX+1];
static char primary_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
......@@ -346,7 +350,7 @@ void cutbuffer_send(void) {
if (!screen) {
return;
}
len = strlen(cutbuffer_str);
cutbuffer_len = len = strlen(cutbuffer_str);
if (check_sel_direction("send", "cutbuffer_send", 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
}
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)) {
rfbSendServerCutText(screen, selection_str, len);
}
......
......@@ -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 void cutbuffer_send(void);
extern void selection_send(XEvent *ev);
extern void resend_selection(char *type);
#endif /* _X11VNC_SELECTION_H */
......@@ -37,9 +37,11 @@ so, delete this exception statement from your version.
#include "xwrappers.h"
#include "connections.h"
#include "cleanup.h"
#include "xevents.h"
char *guess_desktop(void);
void solid_bg(int restore);
char *dbus_session(void);
static void usr_bin_path(int restore);
......@@ -550,31 +552,104 @@ static void solid_cde(char *color) {
#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) {
#if NO_X11
RAWFB_RET_VOID
if (!color) {}
return;
#else
char get_color[] = "gconftool-2 --get "
char get_color[] = "%s gconftool-2 --get "
"/desktop/gnome/background/primary_color";
char set_color[] = "gconftool-2 --set "
"/desktop/gnome/background/primary_color --type string '%s'";
char get_option[] = "gconftool-2 --get "
char set_color[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/primary_color '%s'";
char get_option[] = "%s gconftool-2 --get "
"/desktop/gnome/background/picture_options";
char set_option[] = "gconftool-2 --set "
"/desktop/gnome/background/picture_options --type string '%s'";
char set_option[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/picture_options '%s'";
#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";
char set_filename[] = "gconftool-2 --set "
"/desktop/gnome/background/picture_filename --type string '%s'";
char set_filename[] = "%s gconftool-2 --set --type string "
"/desktop/gnome/background/picture_filename '%s'";
#endif
static char *orig_color = NULL;
static char *orig_option = NULL;
char *cmd;
char *cmd, *dbus = "";
RAWFB_RET_VOID
dbus = dbus_session();
rfbLog("guessed dbus: %s\n", dbus);
if (! color) {
if (! orig_color) {
......@@ -591,14 +666,12 @@ static void solid_gnome(char *color) {
rfbLog("invalid option: %s\n", orig_option);
return;
}
cmd = (char *) malloc(strlen(set_option) - 2 +
strlen(orig_option) + 1);
sprintf(cmd, set_option, orig_option);
cmd = (char *) malloc(strlen(set_option) - 2 + strlen(orig_option) + strlen(dbus) + 1);
sprintf(cmd, set_option, dbus, orig_option);
dt_cmd(cmd);
free(cmd);
cmd = (char *) malloc(strlen(set_color) - 2 +
strlen(orig_color) + 1);
sprintf(cmd, set_color, orig_color);
cmd = (char *) malloc(strlen(set_color) - 2 + strlen(orig_color) + strlen(dbus) + 1);
sprintf(cmd, set_color, dbus, orig_color);
dt_cmd(cmd);
free(cmd);
return;
......@@ -607,7 +680,10 @@ static void solid_gnome(char *color) {
if (! orig_color) {
char *q;
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 {
orig_color = "";
}
......@@ -621,7 +697,10 @@ static void solid_gnome(char *color) {
if (! orig_option) {
char *q;
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 {
orig_color = "";
}
......@@ -636,19 +715,19 @@ static void solid_gnome(char *color) {
rfbLog("invalid color: %s\n", color);
return;
}
cmd = (char *) malloc(strlen(set_color) + strlen(color) + 1);
sprintf(cmd, set_color, color);
cmd = (char *) malloc(strlen(set_color) + strlen(color) + strlen(dbus) + 1);
sprintf(cmd, set_color, dbus, color);
dt_cmd(cmd);
free(cmd);
cmd = (char *) malloc(strlen(set_option) + strlen("none") + 1);
sprintf(cmd, set_option, "none");
cmd = (char *) malloc(strlen(set_option) + strlen("none") + strlen(dbus) + 1);
sprintf(cmd, set_option, dbus, "none");
dt_cmd(cmd);
free(cmd);
#if 0
cmd = (char *) malloc(strlen(set_filename) + strlen("none") + 1);
sprintf(cmd, set_filename, "none");
sprintf(cmd, set_filename, dbus, "none");
dt_cmd(cmd);
free(cmd);
#endif
......
......@@ -39,6 +39,7 @@ extern char *guess_desktop(void);
extern unsigned long get_pixel(char *color);
extern XImage *solid_image(char *color);
extern void solid_bg(int restore);
extern char *dbus_session(void);
extern XImage *solid_root(char *color);
extern void kde_no_animate(int restore);
extern void gnome_no_animate(void);
......
......@@ -49,7 +49,7 @@ so, delete this exception statement from your version.
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 setup_stunnel(int rport, int *argc, char **argv);
char *get_Cert_dir(char *cdir_in, char **tmp_in);
......@@ -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
char extra[] = ":/usr/sbin:/usr/local/sbin:/dist/sbin";
char *path, *p, *exe;
char *stunnel_path = NULL;
struct stat verify_buf;
struct stat crl_buf;
int status;
int status, tmp_pem = 0;
if (stunnel_pid) {
stop_stunnel();
......@@ -167,9 +167,33 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
" saved PEM.\n");
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) {
char *file = get_ssl_verify_file(ssl_verify);
if (file) {
ssl_verify = file;
}
if (stat(ssl_verify, &verify_buf) != 0) {
rfbLog("stunnel: %s does not exist.\n", ssl_verify);
clean_up_exit(1);
......@@ -245,6 +269,7 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
if (! in) {
exit(1);
}
fprintf(in, "foreground = yes\n");
fprintf(in, "pid =\n");
if (stunnel_pem) {
......@@ -263,7 +288,6 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
} else {
fprintf(in, "CAfile = %s\n", ssl_verify);
}
/* XXX double check -v 2 */
fprintf(in, "verify = 2\n");
}
fprintf(in, ";debug = 7\n\n");
......@@ -271,8 +295,24 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
fprintf(in, "accept = %d\n", stunnel_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);
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));
execlp(stunnel_path, stunnel_path, "-fd", fd, (char *) NULL);
......@@ -280,9 +320,21 @@ int start_stunnel(int stunnel_port, int x11vnc_port) {
}
free(exe);
usleep(500 * 1000);
usleep(750 * 1000);
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) {
waitpid(stunnel_pid, &status, WNOHANG);
stunnel_pid = 0;
......@@ -315,13 +367,13 @@ void stop_stunnel(void) {
}
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) {
for (i=0; i< *argc; i++) {
if (argv[i] && !strcmp(argv[i], "-rfbport")) {
if (i < *argc - 1) {
rport = atoi(argv[i+1]);
break;
}
}
}
......@@ -340,7 +392,36 @@ void setup_stunnel(int rport, int *argc, char **argv) {
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;
char tmp[30];
sprintf(tmp, "%d", xport);
......
......@@ -36,7 +36,7 @@ so, delete this exception statement from your version.
/* -- sslcmds.h -- */
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 setup_stunnel(int rport, int *argc, char **argv);
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);
extern void accept_openssl(int mode, int presock);
extern char *find_openssl_bin(void);
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 */
......@@ -271,13 +271,13 @@ char genCA[] =
" -keyout \"$DIR/CA/private/cakey.pem\" \\\n"
" -out \"$DIR/CA/cacert.pem\"\n"
"\n"
"chmod go-rwx \"$DIR/CA/private/cakey.pem\"\n"
"\n"
"if [ $? != 0 ]; then\n"
" echo \"openssl failed.\"\n"
" exit 1\n"
"fi\n"
"\n"
"chmod go-rwx \"$DIR/CA/private/cakey.pem\"\n"
"\n"
"echo \"\"\n"
"echo \"----------------------------------------------------------------------\"\n"
"echo \"Your public x11vnc CA cert is:\"\n"
......@@ -785,6 +785,10 @@ char find_display[] =
" set -xv\n"
"fi\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"
"export PATH\n"
"\n"
......@@ -1439,7 +1443,11 @@ char create_display[] =
" return\n"
" fi\n"
" if [ \"X$have_gnome_session\" != \"X\" -a \"X$FD_SESS\" = \"Xgnome\" ]; then\n"
" echo \"$have_gnome_session\"\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"
" fi\n"
" return\n"
" elif [ \"X$have_startkde\" != \"X\" -a \"X$FD_SESS\" = \"Xkde\" ]; then\n"
" echo \"$have_startkde\"\n"
......@@ -1692,8 +1700,10 @@ char create_display[] =
" DISPLAY=:$N\n"
" export DISPLAY\n"
" stmp=\"\"\n"
" noxauth=\"\"\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" sess=\"env DISPLAY=:$N $sess\"\n"
" noxauth=\"1\"\n"
" fi\n"
"\n"
" redir_daemon=\"\"\n"
......@@ -1706,27 +1716,34 @@ char create_display[] =
" touch $stmp\n"
" chmod 755 $stmp || exit 1\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 \"sleep 1\" >> $stmp\n"
" echo \"rm -f $stmp\" >> $stmp\n"
" sess=$stmp\n"
" rmf=\"$stmp\"\n"
" fi\n"
"\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" ctmp=/tmp/.xat$$`random`\n"
" ctmp=`mytmp \"$ctmp\"`\n"
" touch $ctmp\n"
" chmod 644 $ctmp || exit 1\n"
" $have_xauth -f $authfile nextract - :$N > $ctmp\n"
" su - $USER -c \"$have_xauth nmerge - < $ctmp\" 1>&2\n"
" $have_xauth -f $authfile nextract - `hostname`:$N > $ctmp\n"
" su - $USER -c \"$have_xauth nmerge - < $ctmp\" 1>&2\n"
" rm -f $ctmp\n"
" ctmp1=/tmp/.xat1_$$`random`\n"
" ctmp1=`mytmp \"$ctmp1\"`\n"
" ctmp2=/tmp/.xat2_$$`random`\n"
" ctmp2=`mytmp \"$ctmp2\"`\n"
" touch $ctmp1 $ctmp2\n"
" $have_xauth -f $authfile nextract - :$N > $ctmp1\n"
" $have_xauth -f $authfile nextract - `hostname`:$N > $ctmp2\n"
" chown $USER $ctmp1 $ctmp2\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"
" export XAUTHORITY\n"
" sess=\"/bin/su - $USER -c $sess\"\n"
" else\n"
" $have_xauth -f $authfile nextract - :$N | $have_xauth nmerge -\n"
" $have_xauth -f $authfile nextract - :$N | $have_xauth nmerge -\n"
" $have_xauth -f $authfile nextract - `hostname`:$N | $have_xauth nmerge -\n"
" fi\n"
"\n"
......@@ -1742,7 +1759,12 @@ char create_display[] =
" # we cannot use -nolisten tcp\n"
" echo \"$* -once -query localhost $FD_OPTS\" 1>&2\n"
" if [ \"X$have_root\" != \"X\" ]; then\n"
" $have_nohup $* -once -query localhost $FD_OPTS 1>&2 &\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"
" fi\n"
" else\n"
" if [ \"X$ns\" = \"X0\" ]; then\n"
" $have_nohup sh -c \"$* -once -query localhost -auth $authfile $FD_OPTS\" 1>&2 &\n"
......@@ -1754,10 +1776,10 @@ char create_display[] =
" pid=$!\n"
" sleep 10\n"
" elif [ \"X$have_startx\" != \"X\" -o \"X$have_xinit\" != \"X\" ]; then\n"
" if [ \"X$have_startx\" != \"X\" ]; then\n"
" sxcmd=$have_startx\n"
" else\n"
" if [ \"X$have_xinit\" != \"X\" ]; then\n"
" sxcmd=$have_xinit\n"
" else\n"
" sxcmd=$have_startx\n"
" fi\n"
" echo \"$sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n"
" if [ \"X$have_root\" != \"X\" ]; then\n"
......@@ -1924,12 +1946,18 @@ char create_display[] =
" sarg=\"screen\"\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"
" server $have_Xvfb :$N $sarg 0 ${geom}x${depth} +kb -cc 4\n"
" else\n"
" server $have_Xvfb :$N $sarg 0 ${geom}x${depth} +kb\n"
" # avoid DirectColor for default visual:\n"
" margs=\"$margs -cc 4\"\n"
" fi\n"
" server $have_Xvfb :$N $sarg 0 ${geom}x${depth} $margs\n"
"\n"
" if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n"
" if [ \"X$have_root\" = \"X\" ]; then\n"
......@@ -2030,6 +2058,10 @@ char create_display[] =
" cook=`cookie`\n"
" $have_xauth -f $tmp add :$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"
"}\n"
"\n"
......@@ -2117,7 +2149,7 @@ char create_display[] =
" USER=`whoami`\n"
"fi\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"
"have_root=\"\"\n"
"id0=`id`\n"
......@@ -2130,7 +2162,7 @@ char create_display[] =
" p_ok=1\n"
"fi\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"
" p2=`echo \"$prog\" | sed -e 's/-/_/g'`\n"
" eval \"have_$p2=''\"\n"
......@@ -2148,10 +2180,12 @@ char create_display[] =
" fi\n"
"done\n"
"if [ \"X$have_xterm\" = \"X\" ]; then\n"
" if [ \"X$have_konsole\" != \"X\" ]; then\n"
" have_xterm=$have_konsole\n"
" elif [ \"X$have_gnome_terminal\" != \"X\" ]; then\n"
" if [ \"X$have_gnome_terminal\" != \"X\" ]; then\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"
"\n"
......@@ -2182,9 +2216,15 @@ char create_display[] =
" if echo \"$curr_try\" | egrep '[+.-]xdmcp' > /dev/null; then\n"
" use_xdmcp_query=1\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/[+.-]redirect//'`\n"
" \n"
"\n"
" if echo \"$curr_try\" | grep -i '^Xdummy\\>' > /dev/null; then\n"
" try_Xdummy\n"
" elif echo \"$curr_try\" | grep -i '^Xvfb\\>' > /dev/null; then\n"
......
......@@ -413,6 +413,7 @@ Tuning
gaps:
grow:
fuzz:
extra_fbur:
wait_ui:
setdefer:
nowait_bog
......@@ -749,7 +750,8 @@ more) via Properties -> Advanced -> Actions -> Quit
non-standard listening port use \"host:port\".
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 {} {
}
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
}
......@@ -6261,11 +6268,11 @@ proc run_remote_cmd_via_sock {opts} {
}
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"}
flush $client_sock
catch {flush $client_sock}
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\""}
set res [string trim $res]
......@@ -6535,18 +6542,18 @@ proc do_port_prompt {} {
} else {
frame .pp.f -bd 1 -relief ridge -pady 2
}
label .pp.f.l -text "Port: "
entry .pp.f.e -width 8 -textvariable port_set
label .pp.f.l -text "Port: " -font $bfont
entry .pp.f.e -width 8 -textvariable port_set -font $ffont
global enable_ssl; set enable_ssl 0
if [info exists env(X11VNC_SSL_ENABLED)] {
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
if [info exists env(X11VNC_LOCALHOST_ENABLED)] {
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.loc .pp.f.ssl -side right
......@@ -6559,15 +6566,15 @@ proc do_port_prompt {} {
if [info exists env(X11VNC_FILETRANSFER_ENABLED)] {
set file_transfer $env(X11VNC_FILETRANSFER_ENABLED)
}
label .pp.t.l -text "File Transfer: "
radiobutton .pp.t.none -text "None" -variable file_transfer -value "none"
radiobutton .pp.t.ultra -text "UltraVNC" -variable file_transfer -value "ultra"
radiobutton .pp.t.tight -text "TightVNC" -variable file_transfer -value "tight"
label .pp.t.l -text "File Transfer: " -font $bfont
radiobutton .pp.t.none -text "None" -variable file_transfer -value "none" -font $bfont
radiobutton .pp.t.ultra -text "UltraVNC" -variable file_transfer -value "ultra" -font $bfont
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
frame .pp.o -bd 1 -relief ridge
button .pp.o.ok -text "OK" -command "set port_reply 1; destroy .pp"
button .pp.o.cancel -text "Cancel" -command "set port_reply 0; 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" -font $bfont
pack .pp.o.ok .pp.o.cancel -side left -fill x -expand 1
pack .pp.m -side top -fill x -expand 1
pack .pp.f .pp.t .pp.o -side top -fill x
......@@ -6794,6 +6801,24 @@ set sfont "-adobe-helvetica-bold-r-*-*-*-100-*-*-*-*-*-*"
set snfont "-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*"
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 ""
catch {set ls [font metrics $bfont -linespace]}
if {$ls != "" && $ls > 14} {
......@@ -6914,11 +6939,6 @@ if {"$argv" == "-spit"} {
puts ";"
exit 0
}
if {"$argv" == "-portprompt"} {
do_port_prompt
exit 0
}
set_view_variable "full"
......@@ -6977,6 +6997,19 @@ if {[info exists env(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)]} {
set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);
} else {
......@@ -7086,6 +7119,11 @@ if {[regexp -nocase {Darwin} $osname]} {
set bfont {system}
}
if {"$argv" == "-portprompt"} {
do_port_prompt
exit 0
}
#puts [exec env]
#puts "x11vnc_xdisplay: $x11vnc_xdisplay"
......
......@@ -424,6 +424,7 @@ char gui_code[] = "";
" gaps:\n"
" grow:\n"
" fuzz:\n"
" extra_fbur:\n"
" wait_ui:\n"
" setdefer:\n"
" nowait_bog\n"
......@@ -760,7 +761,8 @@ char gui_code[] = "";
" non-standard listening port use \\\"host:port\\\".\n"
"\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"
......@@ -2996,7 +2998,12 @@ char gui_code[] = "";
" }\n"
" set cache_all_query_vars $qry\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"
" return $qry\n"
"}\n"
......@@ -6272,11 +6279,11 @@ char gui_code[] = "";
" }\n"
"\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"
" flush $client_sock\n"
" catch {flush $client_sock}\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"
" set res [string trim $res]\n"
"\n"
......@@ -6546,18 +6553,18 @@ char gui_code[] = "";
" } else {\n"
" frame .pp.f -bd 1 -relief ridge -pady 2\n"
" }\n"
" label .pp.f.l -text \"Port: \"\n"
" entry .pp.f.e -width 8 -textvariable port_set\n"
" label .pp.f.l -text \"Port: \" -font $bfont\n"
" entry .pp.f.e -width 8 -textvariable port_set -font $ffont\n"
" global enable_ssl; set enable_ssl 0\n"
" if [info exists env(X11VNC_SSL_ENABLED)] {\n"
" set enable_ssl 1\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"
" if [info exists env(X11VNC_LOCALHOST_ENABLED)] {\n"
" set localhost 1\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.loc .pp.f.ssl -side right\n"
"\n"
......@@ -6570,15 +6577,15 @@ char gui_code[] = "";
" if [info exists env(X11VNC_FILETRANSFER_ENABLED)] {\n"
" set file_transfer $env(X11VNC_FILETRANSFER_ENABLED)\n"
" }\n"
" label .pp.t.l -text \"File Transfer: \"\n"
" radiobutton .pp.t.none -text \"None\" -variable file_transfer -value \"none\"\n"
" radiobutton .pp.t.ultra -text \"UltraVNC\" -variable file_transfer -value \"ultra\"\n"
" radiobutton .pp.t.tight -text \"TightVNC\" -variable file_transfer -value \"tight\"\n"
" label .pp.t.l -text \"File Transfer: \" -font $bfont\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\" -font $bfont\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"
"\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.cancel -text \"Cancel\" -command \"set port_reply 0; 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\" -font $bfont\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.f .pp.t .pp.o -side top -fill x\n"
......@@ -6805,6 +6812,24 @@ char gui_code[] = "";
"set snfont \"-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*\"\n"
"set ffont \"fixed\"\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"
"catch {set ls [font metrics $bfont -linespace]}\n"
"if {$ls != \"\" && $ls > 14} {\n"
......@@ -6925,11 +6950,6 @@ char gui_code[] = "";
" puts \";\"\n"
" exit 0\n"
"}\n"
"if {\"$argv\" == \"-portprompt\"} {\n"
" do_port_prompt\n"
" exit 0\n"
"}\n"
"\n"
"\n"
"set_view_variable \"full\"\n"
"\n"
......@@ -6988,6 +7008,19 @@ char gui_code[] = "";
" set x11vnc_gui_params \"\"\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"
" set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);\n"
"} else {\n"
......@@ -7097,6 +7130,11 @@ char gui_code[] = "";
" set bfont {system}\n"
"}\n"
"\n"
"if {\"$argv\" == \"-portprompt\"} {\n"
" do_port_prompt\n"
" exit 0\n"
"}\n"
"\n"
"#puts [exec env]\n"
"#puts \"x11vnc_xdisplay: $x11vnc_xdisplay\"\n"
"\n"
......
This diff is collapsed.
......@@ -42,7 +42,7 @@ extern void unixpw_accept(char *user);
extern void unixpw_deny(void);
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 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 cmd_verify(char *user, char *pass);
extern int unixpw_verify(char *user, char *pass);
......
......@@ -1291,13 +1291,13 @@ void user_supplied_opts(char *opts) {
if (scale_str) free(scale_str);
scale_str = strdup(p);
} else if (ok) {
if (strstr(p, "display=") == p) {
if (0 && strstr(p, "display=") == p) {
if (use_dpy) free(use_dpy);
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);
auth_file = strdup(p + strlen("auth="));
} else if (!strcmp(p, "shared")) {
} else if (0 && !strcmp(p, "shared")) {
shared = 1;
} else if (strstr(p, "scale=") == p) {
if (scale_str) free(scale_str);
......@@ -1443,8 +1443,16 @@ static void setup_fake_fb(XImage* fb_image, int w, int h, int b) {
off_y = 0;
}
void do_announce_http(void);
void do_mention_java_urls(void);
static void setup_service(void) {
if (remote_direct) {
return;
}
if (!inetd) {
do_mention_java_urls();
do_announce_http();
if (!use_openssl) {
announce(screen->port, use_openssl, NULL);
fprintf(stdout, "PORT=%d\n", screen->port);
......@@ -1564,9 +1572,12 @@ static void loop_for_connect(int did_client_connect) {
goto screen_check;
}
}
if (use_openssl && !inetd) {
check_openssl();
check_https();
if ((use_openssl || use_stunnel) && !inetd) {
int enc_none = (enc_str && !strcmp(enc_str, "none"));
if (!use_stunnel || enc_none) {
check_openssl();
check_https();
}
/*
* This is to handle an initial verify cert from viewer,
* they disconnect right after fetching the cert.
......@@ -1655,6 +1666,15 @@ static void do_unixpw_loop(void) {
unixpw_in_rfbPE = 0;
}
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);
continue;
}
......@@ -2000,7 +2020,7 @@ static char *build_create_cmd(char *cmd, int *saw_xdmcp, char *usslpeer, char *t
p++;
}
if (ok && strlen(q) < 32) {
sprintf(fdgeom, q);
sprintf(fdgeom, "%s", q);
if (!quiet) {
rfbLog("set create display geom: %s\n", fdgeom);
}
......@@ -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() {
......@@ -2242,6 +2268,10 @@ static char *get_usslpeer() {
}
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) {
char *u = (char *) malloc(strlen(usslpeer+2));
sprintf(u, "+%s", usslpeer);
......@@ -2365,11 +2395,14 @@ static int do_run_cmd(char *cmd, char *create_cmd, char *users_list_save, int cr
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;
if (unixpw_cmd != NULL) {
res = unixpw_cmd_run(keep_unixpw_user,
keep_unixpw_pass, cmd, line, &n, nodisp);
keep_unixpw_pass, cmd, line, &n);
} else {
res = su_verify(keep_unixpw_user,
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
if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprintf(stderr, "res=%d n=%d\n", res, n);}
if (! res) {
rfbLog("wait_for_client: find display cmd failed\n");
rfbLog("wait_for_client: find display cmd failed.\n");
}
if (! res && create_cmd) {
......@@ -2398,8 +2431,8 @@ if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprint
n = 18000;
close_exec_fds();
res = unixpw_cmd_run(keep_unixpw_user,
keep_unixpw_pass, create_cmd, line, &n, nodisp);
} else if (getuid() != 0) {
keep_unixpw_pass, create_cmd, line, &n);
} else if (getuid() != 0 && unixpw_system_greeter_active != 2) {
/* if not root, run as the other user... */
n = 18000;
close_exec_fds();
......@@ -2410,6 +2443,10 @@ if (db) fprintf(stderr, "c-res=%d n=%d line: '%s'\n", res, n, line);
} else {
FILE *p;
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);
p = popen(create_cmd, "r");
if (! p) {
......@@ -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);
}
}
......@@ -2533,7 +2570,7 @@ if (db) fprintf(stderr, "\n");
rc = pclose(p);
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) {
......@@ -2844,6 +2881,18 @@ int wait_for_client(int *argc, char** argv, int http) {
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();
if (ssh_str != NULL) {
......
......@@ -75,7 +75,7 @@ double dnowx(void);
double rnow(void);
double rfac(void);
void rfbPE(long usec);
int rfbPE(long usec);
void rfbCFD(long usec);
double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
......@@ -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) {
if (sscanf(str, "0x%lx", num) != 1) {
if (sscanf(str, "%lu", num) != 1) {
......@@ -450,26 +470,34 @@ double rfac(void) {
void check_allinput_rate(void) {
static double last_all_input_check = 0.0;
static int set = 0;
static int set = 0, verb = -1;
if (use_threads) {
return;
}
if (verb < 0) {
verb = 0;
if (getenv("RATE_VERB")) verb = 1;
}
if (! set) {
set = 1;
last_all_input_check = dnow();
} else {
int dt = 4;
int dt = 5;
if (x11vnc_current > last_all_input_check + dt) {
int n, nq = 0;
while ((n = rfbCheckFds(screen, 0))) {
nq += n;
}
fprintf(stderr, "nqueued: %d\n", nq);
if (0 && nq > 25 * dt) {
if (verb) fprintf(stderr, "nqueued: %d\n", nq);
if (getenv("CHECK_RATE") && nq > 18 * dt) {
double rate = nq / dt;
rfbLog("Client is sending %.1f extra requests per second for the\n", rate);
rfbLog("past %d seconds! Switching to -allpinput mode. (queued: %d)\n", dt, nq);
all_input = 1;
if (verb) rfbLog("check_allinput_rate:\n");
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;
}
}
set = 0;
}
......@@ -478,8 +506,8 @@ void check_allinput_rate(void) {
static void do_allinput(long usec) {
static double last = 0.0;
static int meas = 0;
int n, f = 1, cnt = 0;
static int meas = 0, verb = -1;
int n, f = 1, cnt = 0, m = 0;
long usec0;
double now;
if (!screen || !screen->clientHead) {
......@@ -495,21 +523,26 @@ static void do_allinput(long usec) {
if (last == 0.0) {
last = dnow();
}
if (verb < 0) {
verb = 0;
if (getenv("RATE_VERB")) verb = 1;
}
while ((n = rfbCheckFds(screen, usec)) > 0) {
if (f) {
fprintf(stderr, " *");
if (verb) fprintf(stderr, " *");
f = 0;
}
if (cnt++ > 30) {
break;
}
meas += n;
m += n;
}
fprintf(stderr, "-%d", cnt);
if (verb) fprintf(stderr, "+%d/%d", cnt, m);
now = dnow();
if (now > last + 2.0) {
double rate = meas / (now - last);
fprintf(stderr, "\n%.2f ", rate);
if (verb) fprintf(stderr, "\n allinput rate: %.2f ", rate);
meas = 0;
last = dnow();
}
......@@ -520,15 +553,16 @@ static void do_allinput(long usec) {
* checks that we are not in threaded mode.
*/
#define USEC_MAX 999999 /* libvncsever assumes < 1 second */
void rfbPE(long usec) {
int rfbPE(long usec) {
int uip0 = unixpw_in_progress;
static int check_rate = -1;
int res = 0;
if (! screen) {
return;
return res;
}
if (unixpw && unixpw_in_progress && !unixpw_in_rfbPE) {
rfbLog("unixpw_in_rfbPE: skipping rfbPE\n");
return;
return res;
}
if (debug_tiles > 2) {
......@@ -541,7 +575,11 @@ void rfbPE(long usec) {
usec = USEC_MAX;
}
if (! use_threads) {
rfbProcessEvents(screen, usec);
rfbBool r;
r = rfbProcessEvents(screen, usec);
if (r) {
res = 1;
}
}
if (unixpw && unixpw_in_progress && !uip0) {
......@@ -566,6 +604,7 @@ void rfbPE(long usec) {
if (all_input) {
do_allinput(usec);
}
return res;
}
void rfbCFD(long usec) {
......
......@@ -63,7 +63,7 @@ extern double dnowx(void);
extern double rnow(void);
extern double rfac(void);
extern void rfbPE(long usec);
extern int rfbPE(long usec);
extern void rfbCFD(long usec);
extern double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
int X2, int Y2);
......
This diff is collapsed.
......@@ -8,7 +8,8 @@
*
* This is free software; you can redistribute it and/or modify
* 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,
* 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
int p0, p, found = -1, jzero = -1;
int conn = -1;
get_prop(num, 32, atom[i]);
get_prop(num, 32, atom[i], None);
p0 = atoi(num);
for (j = TSSTK-1; j >= 0; j--) {
......@@ -654,7 +655,7 @@ void do_tsd(void) {
prop[0] = '\0';
a = XInternAtom(dpy, "TS_REDIR_LIST", False);
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);
......@@ -784,7 +785,7 @@ static void check_redir_services(void) {
a = XInternAtom(dpy, "TS_REDIR_PID", False);
if (a != None) {
prop[0] = '\0';
get_prop(prop, 512, a);
get_prop(prop, 512, a, None);
if (prop[0] != '\0') {
pid = (pid_t) atoi(prop);
}
......@@ -806,7 +807,7 @@ static void check_redir_services(void) {
prop[0] = '\0';
a = XInternAtom(dpy, "TS_REDIR", False);
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 (prop[0] == '\0') {
......@@ -1851,6 +1852,9 @@ char msg2[] =
if (quiet) {
return;
}
if (remote_direct) {
return;
}
if (nofb) {
return;
}
......@@ -1859,7 +1863,7 @@ char msg2[] =
#endif
if (ncache == 0) {
fprintf(stderr, msg2);
fprintf(stderr, "%s", msg2);
ncache0 = ncache = 0;
} else {
fprintf(stderr, msg, ncache);
......@@ -1904,6 +1908,7 @@ static void do_sleepin(char *sleep) {
}
extern int dragum(void);
extern int is_decimal(char *);
int main(int argc, char* argv[]) {
......@@ -1913,6 +1918,9 @@ int main(int argc, char* argv[]) {
int remote_sync = 0;
char *remote_cmd = NULL;
char *query_cmd = NULL;
int query_retries = 0;
double query_delay = 0.5;
char *query_match = NULL;
char *gui_str = NULL;
int got_gui_pw = 0;
int pw_loc = -1, got_passwd = 0, got_rfbauth = 0, nopw = NOPW;
......@@ -2440,6 +2448,10 @@ int main(int argc, char* argv[]) {
got_localhost = 1;
continue;
}
if (!strcmp(arg, "-unixpw_system_greeter")) {
unixpw_system_greeter = 1;
continue;
}
if (!strcmp(arg, "-unixpw_cmd")
|| !strcmp(arg, "-unixpw_cmd_unsafe")) {
CHECK_ARGC
......@@ -2693,7 +2705,11 @@ int main(int argc, char* argv[]) {
stunnel_pem = strdup(s);
}
i++;
} else {
stunnel_pem = strdup("SAVE");
}
} else {
stunnel_pem = strdup("SAVE");
}
continue;
}
......@@ -2709,7 +2725,11 @@ int main(int argc, char* argv[]) {
stunnel_pem = strdup(s);
}
i++;
} else {
stunnel_pem = strdup("SAVE");
}
} else {
stunnel_pem = strdup("SAVE");
}
continue;
}
......@@ -3397,6 +3417,11 @@ int main(int argc, char* argv[]) {
got_waitms = 1;
continue;
}
if (!strcmp(arg, "-extra_fbur")) {
CHECK_ARGC
extra_fbur = atoi(argv[++i]);
continue;
}
if (!strcmp(arg, "-wait_ui")) {
CHECK_ARGC
wait_ui = atof(argv[++i]);
......@@ -3700,17 +3725,39 @@ int main(int argc, char* argv[]) {
remote_cmd = str;
}
}
quiet = 1;
if (!getenv("QUERY_VERBOSE")) {
quiet = 1;
}
xkbcompat = 0;
continue;
}
if (!strcmp(arg, "-query") || !strcmp(arg, "-Q")) {
CHECK_ARGC
query_cmd = strdup(argv[++i]);
quiet = 1;
if (!getenv("QUERY_VERBOSE")) {
quiet = 1;
}
xkbcompat = 0;
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")) {
CHECK_ARGC
query_cmd = strdup(argv[++i]);
......@@ -3725,6 +3772,11 @@ int main(int argc, char* argv[]) {
remote_sync = 0;
continue;
}
if (!strcmp(arg, "-remote_prefix")) {
CHECK_ARGC
remote_prefix = strdup(argv[++i]);
continue;
}
if (!strcmp(arg, "-noremote")) {
accept_remote_cmds = 0;
continue;
......@@ -3784,10 +3836,23 @@ int main(int argc, char* argv[]) {
}
if (!strcmp(arg, "-rfbport") && i < argc-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_pos = argc_vnc+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 ")) {
got_alwaysshared = 1;
}
......@@ -3815,6 +3880,11 @@ int main(int argc, char* argv[]) {
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 */
uname(&UT);
......@@ -4052,8 +4122,25 @@ int main(int argc, char* argv[]) {
* similar for query_default.
*/
if (client_connect_file || query_default) {
int rc = do_remote_query(remote_cmd, query_cmd,
remote_sync, query_default);
int i, rc = 1;
for (i=0; i <= query_retries; i++) {
rc = do_remote_query(remote_cmd, query_cmd,
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(stdout);
exit(rc);
......@@ -4426,6 +4513,8 @@ int main(int argc, char* argv[]) {
}
}
http_try_it = try_http;
if (flip_byte_order && using_shm && ! quiet) {
rfbLog("warning: -flipbyte order only works with -noshm\n");
}
......@@ -4492,11 +4581,13 @@ int main(int argc, char* argv[]) {
}
if (debug_pointer || debug_keyboard) {
if (bg || quiet) {
rfbLog("disabling -bg/-q under -debug_pointer"
"/-debug_keyboard\n");
bg = 0;
quiet = 0;
if (!logfile) {
if (bg || quiet) {
rfbLog("disabling -bg/-q under -debug_pointer"
"/-debug_keyboard\n");
bg = 0;
quiet = 0;
}
}
}
......@@ -4521,7 +4612,7 @@ int main(int argc, char* argv[]) {
if (verbose) {
print_settings(try_http, bg, gui_str);
}
rfbLog("x11vnc version: %s\n", lastmod);
rfbLog("x11vnc version: %s pid: %d\n", lastmod, getpid());
} else {
rfbLogEnable(0);
}
......@@ -4728,14 +4819,38 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
window = save;
}
if (! quiet && ! raw_fb_str) {
rfbLog("\n");
rfbLog("------------------ USEFUL INFORMATION ------------------\n");
}
if (remote_cmd || query_cmd) {
int rc = do_remote_query(remote_cmd, query_cmd, remote_sync,
query_default);
if ( (remote_cmd && strstr(remote_cmd, "DIRECT:") == remote_cmd)
|| (query_cmd && strstr(query_cmd, "DIRECT:") == query_cmd )) {
/* handled below after most everything is setup. */
if (getenv("QUERY_VERBOSE")) {
quiet = 0;
} else {
quiet = 1;
remote_direct = 1;
}
if (!auto_port) {
auto_port = 5970;
}
} 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);
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);
fflush(stderr);
fflush(stdout);
......@@ -4744,6 +4859,11 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
exit(rc);
}
if (! quiet && ! raw_fb_str) {
rfbLog("\n");
rfbLog("------------------ USEFUL INFORMATION ------------------\n");
}
if (priv_remote) {
if (! remote_control_access_ok()) {
rfbLog("** Disabling remote commands in -privremote mode.\n");
......@@ -5086,7 +5206,9 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
}
#endif
check_pm();
if (!getenv("X11VNC_NO_CHECK_PM")) {
check_pm();
}
if (! quiet && ! raw_fb_str) {
rfbLog("--------------------------------------------------------\n");
......@@ -5322,6 +5444,13 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
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 (bg) {
int p, n;
......
......@@ -47,7 +47,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0;
/* 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 */
......
......@@ -56,6 +56,8 @@ int xdamage_max_area = 20000; /* pixels */
double xdamage_memory = 1.0; /* in units of NSCAN */
int xdamage_tile_count = 0, xdamage_direct_count = 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_regions = NULL;
int xdamage_ticker = 0;
......@@ -400,6 +402,7 @@ int collect_xdamage(int scancnt, int call) {
#define DUPSZ 32
int dup_x[DUPSZ], dup_y[DUPSZ], dup_w[DUPSZ], dup_h[DUPSZ];
double tm, dt;
int mark_all = 0, retries = 0, too_many = 1000, tot_ev = 0;
RAWFB_RET(0)
......@@ -443,6 +446,9 @@ int collect_xdamage(int scancnt, int call) {
X_LOCK;
if (0) XFlush_wr(dpy);
if (0) XEventsQueued(dpy, QueuedAfterFlush);
come_back_for_more:
while (XCheckTypedEvent(dpy, xdamage_base_event_type+XDamageNotify, &ev)) {
/*
* TODO max cut off time in this loop?
......@@ -450,6 +456,26 @@ if (0) XEventsQueued(dpy, QueuedAfterFlush);
* screen.
*/
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) {
break;
}
......@@ -537,12 +563,37 @@ if (0) XEventsQueued(dpy, QueuedAfterFlush);
rect_count++;
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 */
if (call == 1) {
XDamageSubtract(dpy, xdamage, None, None);
}
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) {
fb_push();
}
......@@ -726,7 +777,7 @@ void create_xdamage_if_needed(int force) {
xdamage = XDamageCreate(dpy, window, XDamageReportRawRectangles);
XDamageSubtract(dpy, xdamage, None, None);
X_UNLOCK;
rfbLog("created xdamage object: 0x%lx\n", xdamage);
rfbLog("created xdamage object: 0x%lx\n", xdamage);
}
#endif
}
......@@ -762,6 +813,9 @@ void check_xdamage_state(void) {
* Create or destroy the Damage object as needed, we don't want
* 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) {
create_xdamage_if_needed(0);
if (xdamage_scheduled_mark > 0.0 && dnow() >
......
......@@ -44,6 +44,8 @@ extern int xdamage_max_area;
extern double xdamage_memory;
extern int xdamage_tile_count, xdamage_direct_count;
extern double xdamage_scheduled_mark;
extern double xdamage_crazy_time;
extern double xdamage_crazy_delay;
extern sraRegionPtr xdamage_scheduled_mark_region;
extern sraRegionPtr *xdamage_regions;
extern int xdamage_ticker;
......
......@@ -76,7 +76,7 @@ void set_server_input(rfbClientPtr cl, int s);
void set_text_chat(rfbClientPtr cl, int l, char *t);
int get_keyboard_led_state_hook(rfbScreenInfoPtr s);
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 print_xevent_bases(void);
......@@ -212,7 +212,7 @@ static void print_xevent_bases(void) {
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;
#if !NO_X11
Atom type;
......@@ -235,9 +235,12 @@ void get_prop(char *str, int len, Atom prop) {
#else
slen = 0;
if (w == None) {
w = DefaultRootWindow(dpy);
}
do {
if (XGetWindowProperty(dpy, DefaultRootWindow(dpy),
if (XGetWindowProperty(dpy, w,
prop, nitems/4, len/16, False,
AnyPropertyType, &type, &format, &nitems, &bytes_after,
&data) == Success) {
......@@ -584,7 +587,7 @@ static void grab_buster_watch(int parent, char *dstr) {
break;
}
get_prop(propval, 128, ticker_atom);
get_prop(propval, 128, ticker_atom, None);
if (db) fprintf(stderr, "got_prop: %s\n", propval);
if (!process_watch(propval, parent, db)) {
......@@ -871,21 +874,49 @@ void check_autorepeat(void) {
}
} else {
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++) {
state[i] = 0;
}
if (use_threads) {X_LOCK;}
get_keystate(state);
if (use_threads) {X_UNLOCK;}
for (i=0; i<256; i++) {
if (state[i] != 0) {
/* better wait until all keys are up */
rfbLog("active keyboard: waiting until"
" all keys are up. key_down=%d\n", i);
return;
pressed++;
if (msgcnt < mmax || dnow() > lastmsg + mwt) {
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) {
static time_t last_msg = 0;
......@@ -1055,38 +1086,83 @@ void check_xevents(int reset) {
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 (xev.type == PropertyNotify) {
if (xev.xproperty.atom == XA_CUT_BUFFER0) {
/*
* Go retrieve CUT_BUFFER0 and send it.
*
* set_cutbuffer is a flag to try to avoid
* processing our own cutbuffer changes.
*/
if (have_clients && watch_selection
&& ! set_cutbuffer) {
cutbuffer_send();
sent_some_sel = 1;
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.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_cutbuffer = 0;
} else if (vnc_connect && vnc_connect_prop != None
&& xev.xproperty.atom == vnc_connect_prop) {
/*
* Go retrieve VNC_CONNECT string.
*/
read_vnc_connect_prop(0);
} else if (vnc_connect && x11vnc_remote_prop != None
&& xev.xproperty.atom == x11vnc_remote_prop) {
/*
* Go retrieve X11VNC_REMOTE string.
*/
read_x11vnc_remote_prop(0);
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;
}
}
set_prop_atom(xev.xproperty.atom);
}
if (got_cutbuffer) {
/*
* Go retrieve CUT_BUFFER0 and send it.
*
* set_cutbuffer is a flag to try to avoid
* processing our own cutbuffer changes.
*/
if (have_clients && watch_selection && !set_cutbuffer) {
cutbuffer_send();
sent_some_sel = 1;
}
set_cutbuffer = 0;
}
if (got_vnc_connect) {
/*
* Go retrieve VNC_CONNECT string.
*/
read_vnc_connect_prop(0);
}
if (got_x11vnc_remote) {
/*
* Go retrieve X11VNC_REMOTE string.
*/
read_x11vnc_remote_prop(0);
}
}
......@@ -1367,6 +1443,39 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) {
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)) {
return;
}
......
......@@ -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 int get_keyboard_led_state_hook(rfbScreenInfoPtr s);
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 */
......@@ -755,7 +755,6 @@ if (db) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, s
del = 0;
while (len > 0) {
n = read(raw_fb_fd, dst + del, len);
//if (db > 2) fprintf(stderr, "len: %d n: %d\n", len, n);
if (n > 0) {
del += n;
......@@ -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 (db > 1) fprintf(stderr, "bpl>sz %d %d\n", bpl, sz);
off = (off_t) (bpl - sz);
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