summaryrefslogtreecommitdiffstats
path: root/x11vnc/connections.c
diff options
context:
space:
mode:
authorrunge <runge>2006-01-11 15:01:12 +0000
committerrunge <runge>2006-01-11 15:01:12 +0000
commit57cf0cdab5480efebaf447d5675e51b0d311ceee (patch)
treecb4b1419712454d31e85bd8558ff67b2d8fdac90 /x11vnc/connections.c
parent0b7a0030acc27377b01e3afa41f672dc4d6a7561 (diff)
downloadlibtdevnc-57cf0cdab5480efebaf447d5675e51b0d311ceee.tar.gz
libtdevnc-57cf0cdab5480efebaf447d5675e51b0d311ceee.zip
x11vnc: close fd > 2 in run_user_command(), -nocmds in crash_debug, fix 64bit bug for -solid.
Diffstat (limited to 'x11vnc/connections.c')
-rw-r--r--x11vnc/connections.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/x11vnc/connections.c b/x11vnc/connections.c
index addd215..b444208 100644
--- a/x11vnc/connections.c
+++ b/x11vnc/connections.c
@@ -428,8 +428,29 @@ static int run_user_command(char *cmd, rfbClientPtr client, char *mode) {
rfbLog("running command:\n");
rfbLog(" %s\n", cmd);
- /* XXX need to close port 5900, etc.. */
+#if LIBVNCSERVER_HAVE_FORK
+ {
+ pid_t pid, pidw;
+ if ((pid = fork()) > 0) {
+ pidw = waitpid(pid, &rc, 0);
+ } else if (pid == -1) {
+ fprintf(stderr, "could not fork\n");
+ rfbLogPerror("fork");
+ rc = system(cmd);
+ } else {
+ /* this should close port 5900, etc.. */
+ int fd;
+ for (fd=3; fd<256; fd++) {
+ close(fd);
+ }
+ execlp("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL);
+ exit(1);
+ }
+ }
+#else
+ /* this will still have port 5900 open */
rc = system(cmd);
+#endif
if (rc >= 256) {
rc = rc/256;
@@ -963,7 +984,7 @@ static int action_match(char *action, int rc) {
p = strtok(s, ",");
while (p) {
if ((q = strchr(p, ':')) != NULL) {
- int in, k;
+ int in, k = 1;
*q = '\0';
q++;
if (strstr(p, "yes") == p) {
@@ -1662,6 +1683,8 @@ void start_client_info_sock(char *host_port_cookie) {
time_t oldest = 0;
int db = 0;
+ port = -1;
+
for (i = 0; i < ICON_MODE_SOCKS; i++) {
if (icon_mode_socks[i] < 0) {
next = i;