diff options
author | runge <runge@karlrunge.com> | 2010-04-09 20:09:15 -0400 |
---|---|---|
committer | runge <runge@karlrunge.com> | 2010-04-09 20:09:15 -0400 |
commit | 2a8ba97ec5b0f7fbfcfc8adab6732a95e95c7204 (patch) | |
tree | 7da693c36f06f4e16e8bc2b030c54b67f01d8671 /x11vnc/x11vnc.c | |
parent | 5c53ccbbe99dbf098dbb396a65b487f08315d825 (diff) | |
download | libtdevnc-2a8ba97ec5b0f7fbfcfc8adab6732a95e95c7204.tar.gz libtdevnc-2a8ba97ec5b0f7fbfcfc8adab6732a95e95c7204.zip |
x11vnc: exit(1) for -connect_or_exit failure, quiet query mode for grab_state, pointer_pos, etc. ipv6 support. STUNNEL_LISTEN for particular interface. -input_eagerly in addition to -allinput. quiet Xinerama message.
Diffstat (limited to 'x11vnc/x11vnc.c')
-rw-r--r-- | x11vnc/x11vnc.c | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c index d659651..3d91918 100644 --- a/x11vnc/x11vnc.c +++ b/x11vnc/x11vnc.c @@ -1,7 +1,7 @@ /* * x11vnc: a VNC server for X displays. * - * Copyright (C) 2002-2009 Karl J. Runge <runge@karlrunge.com> + * Copyright (C) 2002-2010 Karl J. Runge <runge@karlrunge.com> * All rights reserved. * * This file is part of x11vnc. @@ -216,9 +216,9 @@ int tsdo(int port, int lsock, int *conn) { if (db) rfbLog("tsdo: using existing csock: %d, port: %d\n", csock, port); } - rsock = rfbConnectToTcpAddr("127.0.0.1", port); + rsock = connect_tcp("127.0.0.1", port); if (rsock < 0) { - if (db) rfbLog("tsdo: rfbConnectToTcpAddr(port=%d) failed.\n", port); + if (db) rfbLog("tsdo: connect_tcp(port=%d) failed.\n", port); close(csock); return 2; } @@ -391,7 +391,8 @@ void terminal_services(char *list) { XSync(dpy, False); for (k=1; k <= 5; k++) { - socks[i] = rfbListenOnTCPPort(listen[i], htonl(INADDR_LOOPBACK)); + /* XXX ::1 fallback? */ + socks[i] = listen_tcp(listen[i], htonl(INADDR_LOOPBACK), 1); if (socks[i] >= 0) { if (db) fprintf(stderr, " listen succeeded: %d\n", listen[i]); break; @@ -601,7 +602,7 @@ if (tstk[j] != 0) fprintf(stderr, "B redir[%d][%d] = %d %s\n", i, j, tstk[j], t redir[i][j] = 0; continue; } - s = rfbConnectToTcpAddr("127.0.0.1", p); + s = connect_tcp("127.0.0.1", p); if (s < 0) { redir[i][j] = 0; if (db) fprintf(stderr, "tsdo[%d][%d] clean: connect failed: %d\n", i, j, p); @@ -646,6 +647,7 @@ void do_tsd(void) { char *cmd; int n, sz = 0; char *disp = DisplayString(dpy); + char *logfile = getenv("TS_REDIR_LOGFILE"); int db = 0; if (getenv("TS_REDIR_DEBUG")) { @@ -675,6 +677,12 @@ void do_tsd(void) { sz += strlen("-env TSD_RESTART=1") + 1; sz += strlen("</dev/null 1>/dev/null 2>&1") + 1; sz += strlen(" &") + 1; + if (logfile) { + sz += strlen(logfile); + } + if (ipv6_listen) { + sz += strlen("-6") + 1; + } cmd = (char *) malloc(sz); @@ -684,7 +692,9 @@ void do_tsd(void) { *(xauth-2) = '_'; /* yow */ } } - sprintf(cmd, "%s -display %s -tsd '%s' -env TSD_RESTART=1 </dev/null 1>/dev/null 2>&1 &", program_name, disp, prop); + sprintf(cmd, "%s -display %s -tsd '%s' -env TSD_RESTART=1 %s </dev/null 1>%s 2>&1 &", + program_name, disp, prop, ipv6_listen ? "-6" : "", + logfile ? logfile : "/dev/null" ); rfbLog("running: %s\n", cmd); #if LIBVNCSERVER_HAVE_FORK && LIBVNCSERVER_HAVE_SETSID @@ -2511,10 +2521,32 @@ int main(int argc, char* argv[]) { got_localhost = 1; continue; } + if (!strcmp(arg, "-listen6")) { + listen_str6 = strdup(argv[++i]); + continue; + } if (!strcmp(arg, "-nolookup")) { host_lookup = 0; continue; } +#if X11VNC_IPV6 + if (!strcmp(arg, "-6")) { + ipv6_listen = 1; + continue; + } + if (!strcmp(arg, "-no6")) { + ipv6_listen = 0; + continue; + } + if (!strcmp(arg, "-noipv6")) { + noipv6 = 1; + continue; + } + if (!strcmp(arg, "-noipv4")) { + noipv4 = 1; + continue; + } +#endif if (!strcmp(arg, "-input")) { CHECK_ARGC allowed_input_str = strdup(argv[++i]); @@ -3558,6 +3590,14 @@ int main(int argc, char* argv[]) { all_input = 0; continue; } + if (!strcmp(arg, "-input_eagerly")) { + handle_events_eagerly = 1; + continue; + } + if (!strcmp(arg, "-noinput_eagerly")) { + handle_events_eagerly = 0; + continue; + } if (!strcmp(arg, "-speeds")) { CHECK_ARGC speeds_str = strdup(argv[++i]); @@ -4311,6 +4351,11 @@ int main(int argc, char* argv[]) { close(n); } } + if (ipv6_listen) { + if (inetd) { + ipv6_listen = 0; + } + } if (inetd && quiet && !logfile) { int n; /* @@ -5735,9 +5780,14 @@ int main(int argc, char* argv[]) { if (! screen->port || screen->listenSock < 0) { if (got_rfbport && got_rfbport_val == 0) { ; + } else if (ipv6_listen && ipv6_listen_fd >= 0) { + rfbLog("Info: listening only on IPv6 interface.\n"); } else { rfbLogEnable(1); rfbLog("Error: could not obtain listening port.\n"); + if (!got_rfbport) { + rfbLog("If this system is IPv6-only, use the -6 option.\n"); + } clean_up_exit(1); } } @@ -5776,7 +5826,6 @@ int main(int argc, char* argv[]) { } if (screen && screen->httpListenSock >= 0) { close(screen->httpListenSock); - FD_CLR(screen->httpListenSock,&screen->allFds); screen->httpListenSock = -1; } if (openssl_sock >= 0) { @@ -5787,6 +5836,22 @@ int main(int argc, char* argv[]) { close(https_sock); https_sock = -1; } + if (openssl_sock6 >= 0) { + close(openssl_sock6); + openssl_sock6 = -1; + } + if (https_sock6 >= 0) { + close(https_sock6); + https_sock6 = -1; + } + if (ipv6_listen_fd >= 0) { + close(ipv6_listen_fd); + ipv6_listen_fd = -1; + } + if (ipv6_http_fd >= 0) { + close(ipv6_http_fd); + ipv6_http_fd = -1; + } } /* fork into the background now */ if ((p = fork()) > 0) { |