Commit dba5e098 authored by runge's avatar runge

x11vnc: -verbose, -connect_or_exit, -rfbport 0, print out SSL cert.

parent 31d3a9fa
2006-09-17 Karl Runge <runge@karlrunge.com>
* x11vnc: move some info printout to -v, -verbose mode. Add
-connect_or_exit option. Have -rfbport 0 lead to no TCP
listening. Eliminate double certificates in .pem files.
Always print SSL certificate to the screen to aid pasting.
2006-09-15 Karl Runge <runge@karlrunge.com> 2006-09-15 Karl Runge <runge@karlrunge.com>
* x11vnc: allow user set signals to ignore, clear DISPLAY in * x11vnc: allow user set signals to ignore, clear DISPLAY in
-unixpw su_verify. -rawfb none same as null. -unixpw su_verify. -rawfb none same as null.
......
This diff is collapsed.
...@@ -1587,6 +1587,9 @@ static int do_reverse_connect(char *str) { ...@@ -1587,6 +1587,9 @@ static int do_reverse_connect(char *str) {
free(host); free(host);
if (cl == NULL) { if (cl == NULL) {
if (quiet && connect_or_exit) {
rfbLogEnable(1);
}
rfbLog("reverse_connect: %s failed\n", str); rfbLog("reverse_connect: %s failed\n", str);
return 0; return 0;
} else { } else {
...@@ -1609,6 +1612,7 @@ void reverse_connect(char *str) { ...@@ -1609,6 +1612,7 @@ void reverse_connect(char *str) {
int sleep_between_host = 300; int sleep_between_host = 300;
int sleep_min = 1500, sleep_max = 4500, n_max = 5; int sleep_min = 1500, sleep_max = 4500, n_max = 5;
int n, tot, t, dt = 100, cnt = 0; int n, tot, t, dt = 100, cnt = 0;
int nclients0 = client_count;
if (unixpw_in_progress) return; if (unixpw_in_progress) return;
...@@ -1634,6 +1638,11 @@ void reverse_connect(char *str) { ...@@ -1634,6 +1638,11 @@ void reverse_connect(char *str) {
free(tmp); free(tmp);
if (cnt == 0) { if (cnt == 0) {
if (connect_or_exit) {
rfbLogEnable(1);
rfbLog("exiting under -connect_or_exit\n");
clean_up_exit(0);
}
return; return;
} }
...@@ -1652,10 +1661,24 @@ void reverse_connect(char *str) { ...@@ -1652,10 +1661,24 @@ void reverse_connect(char *str) {
t = 0; t = 0;
while (t < tot) { while (t < tot) {
rfbPE(-1);
rfbPE(-1); rfbPE(-1);
usleep(dt * 1000); usleep(dt * 1000);
t += dt; t += dt;
} }
if (connect_or_exit) {
if (client_count <= nclients0) {
for (t = 0; t < 10; t++) {
rfbPE(-1);
usleep(100 * 1000);
}
}
if (client_count <= nclients0) {
rfbLogEnable(1);
rfbLog("exiting under -connect_or_exit\n");
clean_up_exit(0);
}
}
} }
/* /*
......
...@@ -554,7 +554,9 @@ static void setup_cursors(void) { ...@@ -554,7 +554,9 @@ static void setup_cursors(void) {
int i, j, n = 0; int i, j, n = 0;
static int first = 1; static int first = 1;
rfbLog("setting up %d cursors...\n", CURS_MAX); if (verbose) {
rfbLog("setting up %d cursors...\n", CURS_MAX);
}
if (first) { if (first) {
for (i=0; i<CURS_MAX; i++) { for (i=0; i<CURS_MAX; i++) {
...@@ -814,7 +816,9 @@ static void setup_cursors(void) { ...@@ -814,7 +816,9 @@ static void setup_cursors(void) {
if (screen) { if (screen) {
UNLOCK(screen->cursorMutex); UNLOCK(screen->cursorMutex);
} }
rfbLog(" done.\n"); if (verbose) {
rfbLog(" done.\n");
}
rfbLog("\n"); rfbLog("\n");
} }
......
...@@ -345,8 +345,14 @@ void print_help(int mode) { ...@@ -345,8 +345,14 @@ void print_help(int mode) {
" If \"string\" contains \"/\" it is instead interpreted\n" " If \"string\" contains \"/\" it is instead interpreted\n"
" as a file to periodically check for new hosts.\n" " as a file to periodically check for new hosts.\n"
" The first line is read and then the file is truncated.\n" " The first line is read and then the file is truncated.\n"
" Be careful for this usage mode if x11vnc is running as\n" " Be careful about the location of this file if x11vnc\n"
" root (e.g. via gdm(1), etc).\n" " is running as root (e.g. via gdm(1), etc).\n"
"\n"
"-connect_or_exit str As with -connect, except if none of the reverse\n"
" connections succeed, then x11vnc shutdowns immediately.\n"
"\n"
" If you do not want x11vnc to listen on ANY interface\n"
" use -rfbport 0\n"
"\n" "\n"
"-vncconnect Monitor the VNC_CONNECT X property set by the standard\n" "-vncconnect Monitor the VNC_CONNECT X property set by the standard\n"
"-novncconnect VNC program vncconnect(1). When the property is\n" "-novncconnect VNC program vncconnect(1). When the property is\n"
...@@ -379,6 +385,11 @@ void print_help(int mode) { ...@@ -379,6 +385,11 @@ void print_help(int mode) {
" the -allow list (and vice versa) to avoid situations\n" " the -allow list (and vice versa) to avoid situations\n"
" where no connections (or too many) are allowed.\n" " where no connections (or too many) are allowed.\n"
"\n" "\n"
" If you do not want x11vnc to listen on ANY interface\n"
" (evidently you are using -connect or -connect_or_exit,\n"
" or plan to use remote control: -R connect:host), use\n"
" -rfbport 0\n"
"\n"
"-nolookup Do not use gethostbyname() or gethostbyaddr() to look up\n" "-nolookup Do not use gethostbyname() or gethostbyaddr() to look up\n"
" host names or IP numbers. Use this if name resolution\n" " host names or IP numbers. Use this if name resolution\n"
" is incorrectly set up and leads to long pauses as name\n" " is incorrectly set up and leads to long pauses as name\n"
...@@ -1543,8 +1554,10 @@ void print_help(int mode) { ...@@ -1543,8 +1554,10 @@ void print_help(int mode) {
"-dbg Instead of exiting after cleaning up, run a simple\n" "-dbg Instead of exiting after cleaning up, run a simple\n"
" \"debug crash shell\" when fatal errors are trapped.\n" " \"debug crash shell\" when fatal errors are trapped.\n"
"\n" "\n"
"-q Be quiet by printing less informational output to\n" "-q, -quiet Be quiet by printing less informational output to\n"
" stderr. Same as -quiet.\n" " stderr.\n"
"-v, -verbose Print out more information to stderr.\n"
"\n"
"-bg Go into the background after screen setup. Messages to\n" "-bg Go into the background after screen setup. Messages to\n"
" stderr are lost unless -o logfile is used. Something\n" " stderr are lost unless -o logfile is used. Something\n"
" like this could be useful in a script:\n" " like this could be useful in a script:\n"
......
...@@ -996,27 +996,31 @@ void switch_to_xkb_if_better(void) { ...@@ -996,27 +996,31 @@ void switch_to_xkb_if_better(void) {
XFree(keymap); XFree(keymap);
if (missing_noxkb == 0 && syms_gt_4 >= 8) { if (missing_noxkb == 0 && syms_gt_4 >= 8) {
rfbLog("XKEYBOARD: number of keysyms per keycode %d " if (! raw_fb_str) {
"is greater\n", syms_per_keycode); rfbLog("XKEYBOARD: number of keysyms per keycode %d "
rfbLog(" than 4 and %d keysyms are mapped above 4.\n", "is greater\n", syms_per_keycode);
syms_gt_4); rfbLog(" than 4 and %d keysyms are mapped above 4.\n",
rfbLog(" Automatically switching to -xkb mode.\n"); syms_gt_4);
rfbLog(" If this makes the key mapping worse you can\n"); rfbLog(" Automatically switching to -xkb mode.\n");
rfbLog(" disable it with the \"-noxkb\" option.\n"); rfbLog(" If this makes the key mapping worse you can\n");
rfbLog(" Also, remember \"-remap DEAD\" for accenting" rfbLog(" disable it with the \"-noxkb\" option.\n");
" characters.\n"); rfbLog(" Also, remember \"-remap DEAD\" for accenting"
" characters.\n");
}
use_xkb_modtweak = 1; use_xkb_modtweak = 1;
return; return;
} else if (missing_noxkb == 0) { } else if (missing_noxkb == 0) {
rfbLog("XKEYBOARD: all %d \"must have\" keysyms accounted" if (! raw_fb_str) {
" for.\n", n); rfbLog("XKEYBOARD: all %d \"must have\" keysyms accounted"
rfbLog(" Not automatically switching to -xkb mode.\n"); " for.\n", n);
rfbLog(" If some keys still cannot be typed, try using" rfbLog(" Not automatically switching to -xkb mode.\n");
" -xkb.\n"); rfbLog(" If some keys still cannot be typed, try using"
rfbLog(" Also, remember \"-remap DEAD\" for accenting" " -xkb.\n");
" characters.\n"); rfbLog(" Also, remember \"-remap DEAD\" for accenting"
" characters.\n");
}
return; return;
} }
......
...@@ -150,6 +150,7 @@ int noxrecord = 0; ...@@ -150,6 +150,7 @@ int noxrecord = 0;
char *client_connect = NULL; /* strings for -connect option */ char *client_connect = NULL; /* strings for -connect option */
char *client_connect_file = NULL; char *client_connect_file = NULL;
int connect_or_exit = 0;
int vnc_connect = 1; /* -vncconnect option */ int vnc_connect = 1; /* -vncconnect option */
int show_cursor = 1; /* show cursor shapes */ int show_cursor = 1; /* show cursor shapes */
...@@ -326,6 +327,7 @@ int debug_pointer = 0; ...@@ -326,6 +327,7 @@ int debug_pointer = 0;
int debug_keyboard = 0; int debug_keyboard = 0;
int quiet = 0; int quiet = 0;
int verbose = 0;
/* threaded vs. non-threaded (default) */ /* threaded vs. non-threaded (default) */
#if LIBVNCSERVER_HAVE_LIBPTHREAD && defined(X11VNC_THREADED) #if LIBVNCSERVER_HAVE_LIBPTHREAD && defined(X11VNC_THREADED)
...@@ -336,6 +338,7 @@ int use_threads = 0; ...@@ -336,6 +338,7 @@ int use_threads = 0;
/* info about command line opts */ /* info about command line opts */
int got_rfbport = 0; int got_rfbport = 0;
int got_rfbport_val = -1;
int got_alwaysshared = 0; int got_alwaysshared = 0;
int got_nevershared = 0; int got_nevershared = 0;
int got_cursorpos = 0; int got_cursorpos = 0;
......
...@@ -125,6 +125,7 @@ extern int noxrecord; ...@@ -125,6 +125,7 @@ extern int noxrecord;
extern char *client_connect; extern char *client_connect;
extern char *client_connect_file; extern char *client_connect_file;
extern int connect_or_exit;
extern int vnc_connect; extern int vnc_connect;
extern int show_cursor; extern int show_cursor;
...@@ -247,10 +248,12 @@ extern int debug_pointer; ...@@ -247,10 +248,12 @@ extern int debug_pointer;
extern int debug_keyboard; extern int debug_keyboard;
extern int quiet; extern int quiet;
extern int verbose;
extern int use_threads; extern int use_threads;
extern int got_rfbport; extern int got_rfbport;
extern int got_rfbport_val;
extern int got_alwaysshared; extern int got_alwaysshared;
extern int got_nevershared; extern int got_nevershared;
extern int got_cursorpos; extern int got_cursorpos;
......
...@@ -36,7 +36,9 @@ static void check_fbpm(void) { ...@@ -36,7 +36,9 @@ static void check_fbpm(void) {
" VNC clients are connected.\n"); " VNC clients are connected.\n");
} }
} else { } else {
rfbLog("X display is not capable of FBPM.\n"); if (! raw_fb_str) {
rfbLog("X display is not capable of FBPM.\n");
}
fbpm_capable = 0; fbpm_capable = 0;
} }
init_fbpm = 1; init_fbpm = 1;
...@@ -85,7 +87,9 @@ static void check_fbpm(void) { ...@@ -85,7 +87,9 @@ static void check_fbpm(void) {
#else #else
RAWFB_RET_VOID RAWFB_RET_VOID
if (! init_fbpm) { if (! init_fbpm) {
rfbLog("X FBPM extension not supported.\n"); if (! raw_fb_str) {
rfbLog("X FBPM extension not supported.\n");
}
init_fbpm = 1; init_fbpm = 1;
} }
#endif #endif
......
...@@ -467,7 +467,7 @@ void initialize_polling_images(void) { ...@@ -467,7 +467,7 @@ void initialize_polling_images(void) {
break; break;
} }
} }
if (!quiet) { if (verbose) {
if (using_shm && ! xform24to32) { if (using_shm && ! xform24to32) {
rfbLog("created %d tile_row shm polling images.\n", rfbLog("created %d tile_row shm polling images.\n",
tile_shm_count); tile_shm_count);
......
...@@ -565,7 +565,7 @@ void set_raw_fb_params(int restore) { ...@@ -565,7 +565,7 @@ void set_raw_fb_params(int restore) {
return; return;
} }
if (! quiet) { if (verbose) {
rfbLog("set_raw_fb_params: modifying settings for " rfbLog("set_raw_fb_params: modifying settings for "
"-rawfb mode.\n"); "-rawfb mode.\n");
} }
...@@ -577,7 +577,7 @@ void set_raw_fb_params(int restore) { ...@@ -577,7 +577,7 @@ void set_raw_fb_params(int restore) {
* (i.e. rawfb but also send user input to the X * (i.e. rawfb but also send user input to the X
* display, most likely using /dev/fb0 for some reason...) * display, most likely using /dev/fb0 for some reason...)
*/ */
if (! quiet) { if (verbose) {
rfbLog("rawfb: -noviewonly mode: still sending mouse and\n"); rfbLog("rawfb: -noviewonly mode: still sending mouse and\n");
rfbLog("rawfb: keyboard input to the X DISPLAY!!\n"); rfbLog("rawfb: keyboard input to the X DISPLAY!!\n");
} }
...@@ -590,50 +590,50 @@ void set_raw_fb_params(int restore) { ...@@ -590,50 +590,50 @@ void set_raw_fb_params(int restore) {
} }
#endif #endif
if (watch_selection) { if (watch_selection) {
if (! quiet) rfbLog(" rawfb: turning off " if (verbose) rfbLog(" rawfb: turning off "
"watch_selection\n"); "watch_selection\n");
watch_selection = 0; watch_selection = 0;
} }
if (watch_primary) { if (watch_primary) {
if (! quiet) rfbLog(" rawfb: turning off " if (verbose) rfbLog(" rawfb: turning off "
"watch_primary\n"); "watch_primary\n");
watch_primary = 0; watch_primary = 0;
} }
if (watch_clipboard) { if (watch_clipboard) {
if (! quiet) rfbLog(" rawfb: turning off " if (verbose) rfbLog(" rawfb: turning off "
"watch_clipboard\n"); "watch_clipboard\n");
watch_clipboard = 0; watch_clipboard = 0;
} }
if (watch_bell) { if (watch_bell) {
if (! quiet) rfbLog(" rawfb: turning off watch_bell\n"); if (verbose) rfbLog(" rawfb: turning off watch_bell\n");
watch_bell = 0; watch_bell = 0;
} }
if (no_autorepeat) { if (no_autorepeat) {
if (! quiet) rfbLog(" rawfb: turning off " if (verbose) rfbLog(" rawfb: turning off "
"no_autorepeat\n"); "no_autorepeat\n");
no_autorepeat = 0; no_autorepeat = 0;
} }
if (use_solid_bg) { if (use_solid_bg) {
if (! quiet) rfbLog(" rawfb: turning off " if (verbose) rfbLog(" rawfb: turning off "
"use_solid_bg\n"); "use_solid_bg\n");
use_solid_bg = 0; use_solid_bg = 0;
} }
multiple_cursors_mode = strdup("arrow"); multiple_cursors_mode = strdup("arrow");
} }
if (using_shm) { if (using_shm) {
if (! quiet) rfbLog(" rawfb: turning off using_shm\n"); if (verbose) rfbLog(" rawfb: turning off using_shm\n");
using_shm = 0; using_shm = 0;
} }
if (take_naps) { if (take_naps) {
if (! quiet) rfbLog(" rawfb: turning off take_naps\n"); if (verbose) rfbLog(" rawfb: turning off take_naps\n");
take_naps = 0; take_naps = 0;
} }
if (xrandr) { if (xrandr) {
if (! quiet) rfbLog(" rawfb: turning off xrandr\n"); if (verbose) rfbLog(" rawfb: turning off xrandr\n");
xrandr = 0; xrandr = 0;
} }
if (! noxrecord) { if (! noxrecord) {
if (! quiet) rfbLog(" rawfb: turning off xrecord\n"); if (verbose) rfbLog(" rawfb: turning off xrecord\n");
noxrecord = 1; noxrecord = 1;
} }
} }
...@@ -1304,16 +1304,19 @@ if (db) fprintf(stderr, "initialize_raw_fb reset\n"); ...@@ -1304,16 +1304,19 @@ if (db) fprintf(stderr, "initialize_raw_fb reset\n");
memset(raw_fb, 0xff, dpy_x * dpy_y * b/8); memset(raw_fb, 0xff, dpy_x * dpy_y * b/8);
} }
rfbLog("\n"); if (verbose) {
rfbLog("rawfb: raw_fb %p\n", raw_fb);
rfbLog(" format %d\n", raw_fb_image->format); rfbLog("\n");
rfbLog(" width %d\n", raw_fb_image->width); rfbLog("rawfb: raw_fb %p\n", raw_fb);
rfbLog(" height %d\n", raw_fb_image->height); rfbLog(" format %d\n", raw_fb_image->format);
rfbLog(" bpp %d\n", raw_fb_image->bits_per_pixel); rfbLog(" width %d\n", raw_fb_image->width);
rfbLog(" depth %d\n", raw_fb_image->depth); rfbLog(" height %d\n", raw_fb_image->height);
rfbLog(" bpl %d\n", raw_fb_image->bytes_per_line); rfbLog(" bpp %d\n", raw_fb_image->bits_per_pixel);
if (use_snapfb && snap_fb) { rfbLog(" depth %d\n", raw_fb_image->depth);
rfbLog(" snap_fb %p\n", snap_fb); rfbLog(" bpl %d\n", raw_fb_image->bytes_per_line);
if (use_snapfb && snap_fb) {
rfbLog(" snap_fb %p\n", snap_fb);
}
} }
free(str); free(str);
...@@ -2196,7 +2199,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -2196,7 +2199,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
} }
#if !SMALL_FOOTPRINT #if !SMALL_FOOTPRINT
if (!quiet) { if (verbose) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "FrameBuffer Info:\n"); fprintf(stderr, "FrameBuffer Info:\n");
fprintf(stderr, " width: %d\n", fb->width); fprintf(stderr, " width: %d\n", fb->width);
...@@ -2325,7 +2328,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -2325,7 +2328,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
} else { } else {
screen->frameBuffer = rfb_fb; screen->frameBuffer = rfb_fb;
} }
if (!quiet) { if (verbose) {
fprintf(stderr, " rfb_fb: %p\n", rfb_fb); fprintf(stderr, " rfb_fb: %p\n", rfb_fb);
fprintf(stderr, " main_fb: %p\n", main_fb); fprintf(stderr, " main_fb: %p\n", main_fb);
fprintf(stderr, " 8to24_fb: %p\n", cmap8to24_fb); fprintf(stderr, " 8to24_fb: %p\n", cmap8to24_fb);
...@@ -2399,6 +2402,9 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -2399,6 +2402,9 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
} else if (! got_rfbport) { } else if (! got_rfbport) {
screen->autoPort = TRUE; screen->autoPort = TRUE;
} else if (got_rfbport && got_rfbport_val == 0) {
screen->autoPort = FALSE;
screen->port = 0;
} }
if (! got_nevershared && ! got_alwaysshared) { if (! got_nevershared && ! got_alwaysshared) {
......
...@@ -314,6 +314,7 @@ void setup_stunnel(int rport, int *argc, char **argv) { ...@@ -314,6 +314,7 @@ void setup_stunnel(int rport, int *argc, char **argv) {
argv[i+1] = strdup(tmp); argv[i+1] = strdup(tmp);
*argc += 2; *argc += 2;
got_rfbport = 1; got_rfbport = 1;
got_rfbport_val = atoi(tmp);
} }
} }
stunnel_port = rport; stunnel_port = rport;
...@@ -710,14 +711,34 @@ void sslEncKey(char *path, int mode) { ...@@ -710,14 +711,34 @@ void sslEncKey(char *path, int mode) {
unlink(tmp); unlink(tmp);
if (! mode && cert && cert[0] != '\0') { if (! mode && cert && cert[0] != '\0') {
file = fopen(path, "a"); int got_cert = 0;
file = fopen(path, "r");
if (file == NULL) { if (file == NULL) {
rfbLog("sslEncKey: %s\n", path); rfbLog("sslEncKey: %s\n", path);
rfbLogPerror("fopen"); rfbLogPerror("fopen");
exit(1); exit(1);
} }
fprintf(file, "%s", cert); while (fgets(line, 1024, file) != NULL) {
if (strstr(line, "-----BEGIN CERTIFICATE-----")
== line) {
got_cert++;
}
if (strstr(line, "-----END CERTIFICATE-----")
== line) {
got_cert++;
}
}
fclose(file); fclose(file);
if (got_cert < 2) {
file = fopen(path, "a");
if (file == NULL) {
rfbLog("sslEncKey: %s\n", path);
rfbLogPerror("fopen");
exit(1);
}
fprintf(file, "%s", cert);
fclose(file);
}
free(cert); free(cert);
} }
......
...@@ -146,9 +146,35 @@ char *get_saved_pem(char *save, int create) { ...@@ -146,9 +146,35 @@ char *get_saved_pem(char *save, int create) {
} }
} }
return new; return new;
} else {
return strdup(path);
} }
if (! quiet) {
char line[1024];
int on = 0;
FILE *in = fopen(path, "r");
if (in != NULL) {
rfbLog("\n");
rfbLog("Using SSL Certificate:\n");
fprintf(stderr, "\n");
while (fgets(line, 1024, in) != NULL) {
if (strstr(line, "BEGIN CERTIFICATE")) {
on = 1;
}
if (on) {
fprintf(stderr, "%s", line);
}
if (strstr(line, "END CERTIFICATE")) {
on = 0;
}
if (strstr(line, "PRIVATE KEY")) {
on = 0;
}
}
fprintf(stderr, "\n");
fclose(in);
}
}
return strdup(path);
} }
static char *get_input(char *tag, char **in) { static char *get_input(char *tag, char **in) {
...@@ -441,14 +467,17 @@ static char *create_tmp_pem(char *pathin, int prompt) { ...@@ -441,14 +467,17 @@ static char *create_tmp_pem(char *pathin, int prompt) {
return NULL; return NULL;
} }
while (fgets(line, 1024, in) != NULL) { while (fgets(line, 1024, in) != NULL) {
if (strstr(line, "-----BEGIN CERTIFICATE-----")) { if (strstr(line, "BEGIN CERTIFICATE")) {
on = 1; on = 1;
} }
fprintf(out, "%s", line); fprintf(out, "%s", line);
if (on) { if (on) {
fprintf(crt, "%s", line); fprintf(crt, "%s", line);
} }
if (strstr(line, "-----END CERTIFICATE-----")) { if (strstr(line, "END CERTIFICATE")) {
on = 0;
}
if (strstr(line, "PRIVATE KEY")) {
on = 0; on = 0;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.TH X11VNC "1" "September 2006" "x11vnc " "User Commands" .TH X11VNC "1" "September 2006" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.8.3, lastmod: 2006-09-15 version: 0.8.3, lastmod: 2006-09-17
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -409,11 +409,19 @@ your environment before starting x11vnc. ...@@ -409,11 +409,19 @@ your environment before starting x11vnc.
If \fIstring\fR contains "/" it is instead interpreted If \fIstring\fR contains "/" it is instead interpreted
as a file to periodically check for new hosts. as a file to periodically check for new hosts.
The first line is read and then the file is truncated. The first line is read and then the file is truncated.
Be careful for this usage mode if x11vnc is running as Be careful about the location of this file if x11vnc
root (e.g. via is running as root (e.g. via
.IR gdm (1) .IR gdm (1)
, etc). , etc).
.PP .PP
\fB-connect_or_exit\fR \fIstr\fR
.IP
As with \fB-connect,\fR except if none of the reverse
connections succeed, then x11vnc shutdowns immediately.
.IP
If you do not want x11vnc to listen on ANY interface
use \fB-rfbport\fR 0
.PP
\fB-vncconnect,\fR \fB-novncconnect\fR \fB-vncconnect,\fR \fB-novncconnect\fR
.IP .IP
Monitor the VNC_CONNECT X property set by the standard Monitor the VNC_CONNECT X property set by the standard
...@@ -455,6 +463,11 @@ you use the remote control mechanism (-R) to change ...@@ -455,6 +463,11 @@ you use the remote control mechanism (-R) to change
the \fB-listen\fR interface you may need to manually adjust the \fB-listen\fR interface you may need to manually adjust
the \fB-allow\fR list (and vice versa) to avoid situations the \fB-allow\fR list (and vice versa) to avoid situations
where no connections (or too many) are allowed. where no connections (or too many) are allowed.
.IP
If you do not want x11vnc to listen on ANY interface
(evidently you are using \fB-connect\fR or \fB-connect_or_exit,\fR
or plan to use remote control: \fB-R\fR connect:host), use
\fB-rfbport\fR 0
.PP .PP
\fB-nolookup\fR \fB-nolookup\fR
.IP .IP
...@@ -1788,10 +1801,14 @@ Print out license information. Same as \fB-copying\fR and ...@@ -1788,10 +1801,14 @@ Print out license information. Same as \fB-copying\fR and
Instead of exiting after cleaning up, run a simple Instead of exiting after cleaning up, run a simple
"debug crash shell" when fatal errors are trapped. "debug crash shell" when fatal errors are trapped.
.PP .PP
\fB-q\fR \fB-q,\fR \fB-quiet\fR
.IP .IP
Be quiet by printing less informational output to Be quiet by printing less informational output to
stderr. Same as \fB-quiet.\fR stderr.
.PP
\fB-v,\fR \fB-verbose\fR
.IP
Print out more information to stderr.
.PP .PP
\fB-bg\fR \fB-bg\fR
.IP .IP
......
...@@ -1625,13 +1625,17 @@ int main(int argc, char* argv[]) { ...@@ -1625,13 +1625,17 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-http_ssl")) { } else if (!strcmp(arg, "-http_ssl")) {
try_http = 1; try_http = 1;
http_ssl = 1; http_ssl = 1;
} else if (!strcmp(arg, "-connect")) { } else if (!strcmp(arg, "-connect") ||
!strcmp(arg, "-connect_or_exit")) {
CHECK_ARGC CHECK_ARGC
if (strchr(argv[++i], '/')) { if (strchr(argv[++i], '/')) {
client_connect_file = strdup(argv[i]); client_connect_file = strdup(argv[i]);
} else { } else {
client_connect = strdup(argv[i]); client_connect = strdup(argv[i]);
} }
if (!strcmp(arg, "-connect_or_exit")) {
connect_or_exit = 1;
}
} else if (!strcmp(arg, "-vncconnect")) { } else if (!strcmp(arg, "-vncconnect")) {
vnc_connect = 1; vnc_connect = 1;
} else if (!strcmp(arg, "-novncconnect")) { } else if (!strcmp(arg, "-novncconnect")) {
...@@ -1887,6 +1891,8 @@ int main(int argc, char* argv[]) { ...@@ -1887,6 +1891,8 @@ int main(int argc, char* argv[]) {
crash_debug = 0; crash_debug = 0;
} else if (!strcmp(arg, "-q") || !strcmp(arg, "-quiet")) { } else if (!strcmp(arg, "-q") || !strcmp(arg, "-quiet")) {
quiet = 1; quiet = 1;
} else if (!strcmp(arg, "-v") || !strcmp(arg, "-verbose")) {
verbose = 1;
} else if (!strcmp(arg, "-bg") || !strcmp(arg, "-background")) { } else if (!strcmp(arg, "-bg") || !strcmp(arg, "-background")) {
#if LIBVNCSERVER_HAVE_SETSID #if LIBVNCSERVER_HAVE_SETSID
bg = 1; bg = 1;
...@@ -2306,7 +2312,8 @@ int main(int argc, char* argv[]) { ...@@ -2306,7 +2312,8 @@ int main(int argc, char* argv[]) {
got_deferupdate = 1; got_deferupdate = 1;
} }
if (!strcmp(arg, "-rfbport") && i < argc-1) { if (!strcmp(arg, "-rfbport") && i < argc-1) {
got_rfbport = atoi(argv[i+1]); got_rfbport = 1;
got_rfbport_val = atoi(argv[i+1]);
} }
if (!strcmp(arg, "-alwaysshared ")) { if (!strcmp(arg, "-alwaysshared ")) {
got_alwaysshared = 1; got_alwaysshared = 1;
...@@ -2710,7 +2717,6 @@ int main(int argc, char* argv[]) { ...@@ -2710,7 +2717,6 @@ int main(int argc, char* argv[]) {
if (use_stunnel) { if (use_stunnel) {
exit(1); exit(1);
} }
/* others? */
} }
if (flip_byte_order && using_shm && ! quiet) { if (flip_byte_order && using_shm && ! quiet) {
...@@ -2790,7 +2796,9 @@ int main(int argc, char* argv[]) { ...@@ -2790,7 +2796,9 @@ int main(int argc, char* argv[]) {
initialize_crash_handler(); initialize_crash_handler();
if (! quiet) { if (! quiet) {
print_settings(try_http, bg, gui_str); if (verbose) {
print_settings(try_http, bg, gui_str);
}
} else { } else {
rfbLogEnable(0); rfbLogEnable(0);
} }
...@@ -2907,7 +2915,7 @@ int main(int argc, char* argv[]) { ...@@ -2907,7 +2915,7 @@ int main(int argc, char* argv[]) {
scr = DefaultScreen(dpy); scr = DefaultScreen(dpy);
rootwin = RootWindow(dpy, scr); rootwin = RootWindow(dpy, scr);
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("\n"); rfbLog("\n");
rfbLog("------------------ USEFUL INFORMATION ------------------\n"); rfbLog("------------------ USEFUL INFORMATION ------------------\n");
} }
...@@ -2938,7 +2946,7 @@ int main(int argc, char* argv[]) { ...@@ -2938,7 +2946,7 @@ int main(int argc, char* argv[]) {
#if LIBVNCSERVER_HAVE_LIBXFIXES #if LIBVNCSERVER_HAVE_LIBXFIXES
if (! XFixesQueryExtension(dpy, &xfixes_base_event_type, &er)) { if (! XFixesQueryExtension(dpy, &xfixes_base_event_type, &er)) {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("Disabling XFIXES mode: display does not " rfbLog("Disabling XFIXES mode: display does not "
"support it.\n"); "support it.\n");
} }
...@@ -2954,7 +2962,7 @@ int main(int argc, char* argv[]) { ...@@ -2954,7 +2962,7 @@ int main(int argc, char* argv[]) {
#if LIBVNCSERVER_HAVE_LIBXDAMAGE #if LIBVNCSERVER_HAVE_LIBXDAMAGE
if (! XDamageQueryExtension(dpy, &xdamage_base_event_type, &er)) { if (! XDamageQueryExtension(dpy, &xdamage_base_event_type, &er)) {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("Disabling X DAMAGE mode: display does not " rfbLog("Disabling X DAMAGE mode: display does not "
"support it.\n"); "support it.\n");
} }
...@@ -2967,14 +2975,14 @@ int main(int argc, char* argv[]) { ...@@ -2967,14 +2975,14 @@ int main(int argc, char* argv[]) {
if (! xdamage_present) { if (! xdamage_present) {
use_xdamage = 0; use_xdamage = 0;
} }
if (! quiet && xdamage_present && use_xdamage) { if (! quiet && xdamage_present && use_xdamage && ! raw_fb_str) {
rfbLog("X DAMAGE available on display, using it for" rfbLog("X DAMAGE available on display, using it for"
" polling hints.\n"); " polling hints.\n");
rfbLog(" To disable this behavior use: " rfbLog(" To disable this behavior use: "
"'-noxdamage'\n"); "'-noxdamage'\n");
} }
if (! quiet && wireframe) { if (! quiet && wireframe && ! raw_fb_str) {
rfbLog("Wireframing: -wireframe mode is in effect for window " rfbLog("Wireframing: -wireframe mode is in effect for window "
"moves.\n"); "moves.\n");
rfbLog(" If this yields undesired behavior (poor response, " rfbLog(" If this yields undesired behavior (poor response, "
...@@ -2999,7 +3007,7 @@ int main(int argc, char* argv[]) { ...@@ -2999,7 +3007,7 @@ int main(int argc, char* argv[]) {
overlay_present = 0; overlay_present = 0;
#if defined(SOLARIS_OVERLAY) && !NO_X11 #if defined(SOLARIS_OVERLAY) && !NO_X11
if (! XQueryExtension(dpy, "SUN_OVL", &maj, &ev, &er)) { if (! XQueryExtension(dpy, "SUN_OVL", &maj, &ev, &er)) {
if (! quiet && overlay) { if (! quiet && overlay && ! raw_fb_str) {
rfbLog("Disabling -overlay: SUN_OVL " rfbLog("Disabling -overlay: SUN_OVL "
"extension not available.\n"); "extension not available.\n");
} }
...@@ -3009,7 +3017,7 @@ int main(int argc, char* argv[]) { ...@@ -3009,7 +3017,7 @@ int main(int argc, char* argv[]) {
#endif #endif
#if defined(IRIX_OVERLAY) && !NO_X11 #if defined(IRIX_OVERLAY) && !NO_X11
if (! XReadDisplayQueryExtension(dpy, &ev, &er)) { if (! XReadDisplayQueryExtension(dpy, &ev, &er)) {
if (! quiet && overlay) { if (! quiet && overlay && ! raw_fb_str) {
rfbLog("Disabling -overlay: IRIX ReadDisplay " rfbLog("Disabling -overlay: IRIX ReadDisplay "
"extension not available.\n"); "extension not available.\n");
} }
...@@ -3032,7 +3040,7 @@ int main(int argc, char* argv[]) { ...@@ -3032,7 +3040,7 @@ int main(int argc, char* argv[]) {
free(multiple_cursors_mode); free(multiple_cursors_mode);
multiple_cursors_mode = strdup("most"); multiple_cursors_mode = strdup("most");
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("XFIXES available on display, resetting" rfbLog("XFIXES available on display, resetting"
" cursor mode\n"); " cursor mode\n");
rfbLog(" to: '-cursor most'.\n"); rfbLog(" to: '-cursor most'.\n");
...@@ -3044,7 +3052,7 @@ int main(int argc, char* argv[]) { ...@@ -3044,7 +3052,7 @@ int main(int argc, char* argv[]) {
if(!strcmp(multiple_cursors_mode, "most")) { if(!strcmp(multiple_cursors_mode, "most")) {
if (xfixes_present && use_xfixes && if (xfixes_present && use_xfixes &&
overlay_cursor == 1) { overlay_cursor == 1) {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("using XFIXES for cursor " rfbLog("using XFIXES for cursor "
"drawing.\n"); "drawing.\n");
} }
...@@ -3055,7 +3063,7 @@ int main(int argc, char* argv[]) { ...@@ -3055,7 +3063,7 @@ int main(int argc, char* argv[]) {
if (overlay) { if (overlay) {
using_shm = 0; using_shm = 0;
if (flash_cmap && ! quiet) { if (flash_cmap && ! quiet && ! raw_fb_str) {
rfbLog("warning: -flashcmap may be " rfbLog("warning: -flashcmap may be "
"incompatible with -overlay\n"); "incompatible with -overlay\n");
} }
...@@ -3082,7 +3090,7 @@ int main(int argc, char* argv[]) { ...@@ -3082,7 +3090,7 @@ int main(int argc, char* argv[]) {
/* check for XTEST */ /* check for XTEST */
if (! XTestQueryExtension_wr(dpy, &ev, &er, &maj, &min)) { if (! XTestQueryExtension_wr(dpy, &ev, &er, &maj, &min)) {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("WARNING: XTEST extension not available " rfbLog("WARNING: XTEST extension not available "
"(either missing from\n"); "(either missing from\n");
rfbLog(" display or client library libXtst " rfbLog(" display or client library libXtst "
...@@ -3149,7 +3157,7 @@ int main(int argc, char* argv[]) { ...@@ -3149,7 +3157,7 @@ int main(int argc, char* argv[]) {
#if !LIBVNCSERVER_HAVE_RECORD #if !LIBVNCSERVER_HAVE_RECORD
tmpi = 0; tmpi = 0;
#endif #endif
if (! quiet && tmpi) { if (! quiet && tmpi && ! raw_fb_str) {
rfbLog("Scroll Detection: -scrollcopyrect mode is in effect " rfbLog("Scroll Detection: -scrollcopyrect mode is in effect "
"to\n"); "to\n");
rfbLog(" use RECORD extension to try to detect scrolling " rfbLog(" use RECORD extension to try to detect scrolling "
...@@ -3183,12 +3191,12 @@ int main(int argc, char* argv[]) { ...@@ -3183,12 +3191,12 @@ int main(int argc, char* argv[]) {
if (! XShmQueryExtension_wr(dpy)) { if (! XShmQueryExtension_wr(dpy)) {
xshm_present = 0; xshm_present = 0;
if (! using_shm) { if (! using_shm) {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("info: display does not support" rfbLog("info: display does not support"
" XShm.\n"); " XShm.\n");
} }
} else { } else {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("warning: XShm extension is not available.\n"); rfbLog("warning: XShm extension is not available.\n");
rfbLog("For best performance the X Display should be" rfbLog("For best performance the X Display should be"
" local. (i.e.\n"); " local. (i.e.\n");
...@@ -3212,7 +3220,7 @@ int main(int argc, char* argv[]) { ...@@ -3212,7 +3220,7 @@ int main(int argc, char* argv[]) {
initialize_xkb(); initialize_xkb();
initialize_watch_bell(); initialize_watch_bell();
if (!xkb_present && use_xkb_modtweak) { if (!xkb_present && use_xkb_modtweak) {
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("warning: disabling xkb modtweak." rfbLog("warning: disabling xkb modtweak."
" XKEYBOARD ext. not present.\n"); " XKEYBOARD ext. not present.\n");
} }
...@@ -3228,7 +3236,7 @@ int main(int argc, char* argv[]) { ...@@ -3228,7 +3236,7 @@ int main(int argc, char* argv[]) {
#if LIBVNCSERVER_HAVE_LIBXRANDR #if LIBVNCSERVER_HAVE_LIBXRANDR
if (! XRRQueryExtension(dpy, &xrandr_base_event_type, &er)) { if (! XRRQueryExtension(dpy, &xrandr_base_event_type, &er)) {
if (xrandr && ! quiet) { if (xrandr && ! quiet && ! raw_fb_str) {
rfbLog("Disabling -xrandr mode: display does not" rfbLog("Disabling -xrandr mode: display does not"
" support X RANDR.\n"); " support X RANDR.\n");
} }
...@@ -3242,7 +3250,7 @@ int main(int argc, char* argv[]) { ...@@ -3242,7 +3250,7 @@ int main(int argc, char* argv[]) {
check_pm(); check_pm();
if (! quiet) { if (! quiet && ! raw_fb_str) {
rfbLog("--------------------------------------------------------\n"); rfbLog("--------------------------------------------------------\n");
rfbLog("\n"); rfbLog("\n");
} }
...@@ -3337,9 +3345,13 @@ int main(int argc, char* argv[]) { ...@@ -3337,9 +3345,13 @@ int main(int argc, char* argv[]) {
} }
if (! inetd && ! use_openssl) { if (! inetd && ! use_openssl) {
if (! screen->port || screen->listenSock < 0) { if (! screen->port || screen->listenSock < 0) {
rfbLogEnable(1); if (got_rfbport && got_rfbport_val == 0) {
rfbLog("Error: could not obtain listening port.\n"); ;
clean_up_exit(1); } else {
rfbLogEnable(1);
rfbLog("Error: could not obtain listening port.\n");
clean_up_exit(1);
}
} }
} }
if (! quiet) { if (! quiet) {
......
...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; ...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.8.3 lastmod: 2006-09-15"; char lastmod[] = "0.8.3 lastmod: 2006-09-17";
/* X display info */ /* X display info */
......
...@@ -243,14 +243,18 @@ static void initialize_xinerama (void) { ...@@ -243,14 +243,18 @@ static void initialize_xinerama (void) {
RAWFB_RET_VOID RAWFB_RET_VOID
if (! XineramaQueryExtension(dpy, &ev, &er)) { if (! XineramaQueryExtension(dpy, &ev, &er)) {
rfbLog("Xinerama: disabling: display does not support it.\n"); if (verbose) {
rfbLog("Xinerama: disabling: display does not support it.\n");
}
xinerama = 0; xinerama = 0;
xinerama_present = 0; xinerama_present = 0;
return; return;
} }
if (! XineramaIsActive(dpy)) { if (! XineramaIsActive(dpy)) {
/* n.b. change to XineramaActive(dpy, window) someday */ /* n.b. change to XineramaActive(dpy, window) someday */
rfbLog("Xinerama: disabling: not active on display.\n"); if (verbose) {
rfbLog("Xinerama: disabling: not active on display.\n");
}
xinerama = 0; xinerama = 0;
xinerama_present = 0; xinerama_present = 0;
return; return;
...@@ -259,11 +263,15 @@ static void initialize_xinerama (void) { ...@@ -259,11 +263,15 @@ static void initialize_xinerama (void) {
/* n.b. change to XineramaGetData() someday */ /* n.b. change to XineramaGetData() someday */
xineramas = XineramaQueryScreens(dpy, &n); xineramas = XineramaQueryScreens(dpy, &n);
rfbLog("Xinerama: number of sub-screens: %d\n", n); if (verbose) {
rfbLog("Xinerama: number of sub-screens: %d\n", n);
}
if (n == 1) { if (n == 1) {
rfbLog("Xinerama: no blackouts needed (only one" if (verbose) {
" sub-screen)\n"); rfbLog("Xinerama: no blackouts needed (only one"
" sub-screen)\n");
}
XFree(xineramas); XFree(xineramas);
return; /* must be OK w/o change */ return; /* must be OK w/o change */
} }
......
...@@ -922,7 +922,7 @@ void disable_grabserver(Display *in_dpy, int change) { ...@@ -922,7 +922,7 @@ void disable_grabserver(Display *in_dpy, int change) {
if (change) { if (change) {
XTRAP_GrabControl_wr(in_dpy, False); XTRAP_GrabControl_wr(in_dpy, False);
} }
if (! didmsg) { if (! didmsg && ! raw_fb_str) {
rfbLog("GrabServer control via XTEST.\n"); rfbLog("GrabServer control via XTEST.\n");
didmsg = 1; didmsg = 1;
} }
...@@ -930,7 +930,7 @@ void disable_grabserver(Display *in_dpy, int change) { ...@@ -930,7 +930,7 @@ void disable_grabserver(Display *in_dpy, int change) {
} else { } else {
if (XTRAP_GrabControl_wr(in_dpy, True)) { if (XTRAP_GrabControl_wr(in_dpy, True)) {
ok = 1; ok = 1;
if (! didmsg) { if (! didmsg && ! raw_fb_str) {
rfbLog("Using DEC-XTRAP for protection" rfbLog("Using DEC-XTRAP for protection"
" from XGrabServer.\n"); " from XGrabServer.\n");
didmsg = 1; didmsg = 1;
...@@ -942,7 +942,7 @@ void disable_grabserver(Display *in_dpy, int change) { ...@@ -942,7 +942,7 @@ void disable_grabserver(Display *in_dpy, int change) {
if (change) { if (change) {
XTestGrabControl_wr(in_dpy, False); XTestGrabControl_wr(in_dpy, False);
} }
if (! didmsg) { if (! didmsg && ! raw_fb_str) {
rfbLog("GrabServer control via DEC-XTRAP.\n"); rfbLog("GrabServer control via DEC-XTRAP.\n");
didmsg = 1; didmsg = 1;
} }
...@@ -950,7 +950,7 @@ void disable_grabserver(Display *in_dpy, int change) { ...@@ -950,7 +950,7 @@ void disable_grabserver(Display *in_dpy, int change) {
} else { } else {
if (XTestGrabControl_wr(in_dpy, True)) { if (XTestGrabControl_wr(in_dpy, True)) {
ok = 1; ok = 1;
if (! didmsg) { if (! didmsg && ! raw_fb_str) {
rfbLog("DEC-XTRAP XGrabServer " rfbLog("DEC-XTRAP XGrabServer "
"protection not available, " "protection not available, "
"using XTEST.\n"); "using XTEST.\n");
......
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