Commit 0016cd42 authored by runge's avatar runge

x11vnc: -grabalways, -forcedpms, -clientdpms, -noserverdpms, -loopbg, -svc, -xdmsvc

parent 90d96b97
2007-02-11 Karl Runge <runge@karlrunge.com>
* x11vnc: add -grabalways, -forcedpms, -clientdpms, and
-noserverdpms (ultravnc viewer) for improvements in
the still approximate server locking. Add -loopbg
and -svc, -xdmsvc aliases. Bug fix create_display.
2007-02-10 Karl Runge <runge@karlrunge.com> 2007-02-10 Karl Runge <runge@karlrunge.com>
* x11vnc: watch things like textchat, etc. more carefully * x11vnc: watch things like textchat, etc. more carefully
in unixpw state. Monitor broken XDAMAGE reports when in unixpw state. Monitor broken XDAMAGE reports when
......
This diff is collapsed.
...@@ -2377,7 +2377,9 @@ void check_new_clients(void) { ...@@ -2377,7 +2377,9 @@ void check_new_clients(void) {
return; return;
} }
if (grab_kbd || grab_ptr) { if (grab_always) {
;
} else if (grab_kbd || grab_ptr) {
static double last_force = 0.0; static double last_force = 0.0;
if (client_count != last_count || dnow() > last_force + 0.25) { if (client_count != last_count || dnow() > last_force + 0.25) {
int q = (client_count == last_count); int q = (client_count == last_count);
......
This diff is collapsed.
...@@ -356,6 +356,9 @@ int watch_fbpm = 0; ...@@ -356,6 +356,9 @@ int watch_fbpm = 0;
#endif #endif
int watch_dpms = 0; /* -dpms */ int watch_dpms = 0; /* -dpms */
int force_dpms = 0;
int client_dpms = 0;
int no_ultra_dpms = 0;
int watch_selection = 1; /* normal selection/cutbuffer maintenance */ int watch_selection = 1; /* normal selection/cutbuffer maintenance */
int watch_primary = 1; /* more dicey, poll for changes in PRIMARY */ int watch_primary = 1; /* more dicey, poll for changes in PRIMARY */
......
...@@ -261,6 +261,9 @@ extern int all_input; ...@@ -261,6 +261,9 @@ extern int all_input;
extern int watch_fbpm; extern int watch_fbpm;
extern int watch_dpms; extern int watch_dpms;
extern int force_dpms;
extern int client_dpms;
extern int no_ultra_dpms;
extern int watch_selection; extern int watch_selection;
extern int watch_primary; extern int watch_primary;
......
...@@ -123,16 +123,22 @@ void set_dpms_mode(char *mode) { ...@@ -123,16 +123,22 @@ void set_dpms_mode(char *mode) {
want = DPMSModeStandby; want = DPMSModeStandby;
} else if (!strcmp(mode, "suspend")) { } else if (!strcmp(mode, "suspend")) {
want = DPMSModeSuspend; want = DPMSModeSuspend;
} else if (!strcmp(mode, "enable")) {
DPMSEnable(dpy);
return;
} else if (!strcmp(mode, "disable")) {
DPMSDisable(dpy);
return;
} else { } else {
return; return;
} }
if (DPMSInfo(dpy, &level, &enabled)) { if (DPMSInfo(dpy, &level, &enabled)) {
char *from; char *from;
fprintf(stderr, "DPMSInfo level: %d enabled: %d\n", level, enabled);
if (enabled && level != want) { if (enabled && level != want) {
XErrorHandler old_handler = XSetErrorHandler(trap_xerror); XErrorHandler old_handler = XSetErrorHandler(trap_xerror);
trapped_xerror = 0; trapped_xerror = 0;
rfbLog("DPMSInfo level: %d enabled: %d\n", level, enabled);
if (level == DPMSModeStandby) { if (level == DPMSModeStandby) {
from = "DPMSModeStandby"; from = "DPMSModeStandby";
} else if (level == DPMSModeSuspend) { } else if (level == DPMSModeSuspend) {
...@@ -188,6 +194,14 @@ static void check_dpms(void) { ...@@ -188,6 +194,14 @@ static void check_dpms(void) {
init_dpms = 1; init_dpms = 1;
} }
if (force_dpms || (client_dpms && client_count)) {
static int last_enable = 0;
if (time(NULL) > last_enable) {
set_dpms_mode("enable");
last_enable = time(NULL);
}
set_dpms_mode("off");
}
if (! watch_dpms) { if (! watch_dpms) {
return; return;
} }
......
...@@ -3287,6 +3287,9 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -3287,6 +3287,9 @@ char *process_remote_cmd(char *cmd, int stringonly) {
goto qry; goto qry;
} }
grab_kbd = 1; grab_kbd = 1;
if (grab_always) {
adjust_grabs(1, 0);
}
rfbLog("enabled grab_kbd\n"); rfbLog("enabled grab_kbd\n");
} else if (!strcmp(p, "nograbkbd")) { } else if (!strcmp(p, "nograbkbd")) {
int orig = grab_kbd; int orig = grab_kbd;
...@@ -3303,12 +3306,16 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -3303,12 +3306,16 @@ char *process_remote_cmd(char *cmd, int stringonly) {
#endif #endif
} }
rfbLog("disabled grab_kbd\n"); rfbLog("disabled grab_kbd\n");
} else if (!strcmp(p, "grabptr")) { } else if (!strcmp(p, "grabptr")) {
if (query) { if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, grab_ptr); snprintf(buf, bufn, "ans=%s:%d", p, grab_ptr);
goto qry; goto qry;
} }
grab_ptr = 1; grab_ptr = 1;
if (grab_always) {
adjust_grabs(1, 0);
}
rfbLog("enabled grab_ptr\n"); rfbLog("enabled grab_ptr\n");
} else if (!strcmp(p, "nograbptr")) { } else if (!strcmp(p, "nograbptr")) {
int orig = grab_ptr; int orig = grab_ptr;
...@@ -3326,6 +3333,36 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -3326,6 +3333,36 @@ char *process_remote_cmd(char *cmd, int stringonly) {
} }
rfbLog("disabled grab_ptr\n"); rfbLog("disabled grab_ptr\n");
} else if (!strcmp(p, "grabalways")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, grab_always);
goto qry;
}
grab_ptr = 1;
grab_kbd = 1;
grab_always = 1;
adjust_grabs(1, 0);
rfbLog("enabled grab_always\n");
} else if (!strcmp(p, "nograbalways")) {
int orig = grab_always;
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !grab_always);
goto qry;
}
grab_ptr = 0;
grab_kbd = 0;
grab_always = 0;
if (orig && dpy) {
#if !NO_X11
X_LOCK;
XUngrabKeyboard(dpy, CurrentTime);
XUngrabPointer(dpy, CurrentTime);
X_UNLOCK;
#endif
}
adjust_grabs(0, 0);
rfbLog("disabled grab_always\n");
} else if (strstr(p, "client_input") == p) { } else if (strstr(p, "client_input") == p) {
NOTAPP NOTAPP
COLON_CHECK("client_input:") COLON_CHECK("client_input:")
...@@ -3583,6 +3620,51 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -3583,6 +3620,51 @@ char *process_remote_cmd(char *cmd, int stringonly) {
rfbLog("remote_cmd: turning on -nodpms mode.\n"); rfbLog("remote_cmd: turning on -nodpms mode.\n");
watch_dpms = 1; watch_dpms = 1;
} else if (!strcmp(p, "clientdpms")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, client_dpms);
goto qry;
}
rfbLog("remote_cmd: turning on -clientdpms mode.\n");
client_dpms = 1;
} else if (!strcmp(p, "noclientdpms")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !client_dpms);
goto qry;
}
rfbLog("remote_cmd: turning off -clientdpms mode.\n");
client_dpms = 0;
} else if (!strcmp(p, "forcedpms")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, force_dpms);
goto qry;
}
rfbLog("remote_cmd: turning on -forcedpms mode.\n");
force_dpms = 1;
} else if (!strcmp(p, "noforcedpms")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !force_dpms);
goto qry;
}
rfbLog("remote_cmd: turning off -forcedpms mode.\n");
force_dpms = 0;
} else if (!strcmp(p, "noserverdpms")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, no_ultra_dpms);
goto qry;
}
rfbLog("remote_cmd: turning on -noserverdpms mode.\n");
no_ultra_dpms = 1;
} else if (!strcmp(p, "serverdpms")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !no_ultra_dpms);
goto qry;
}
rfbLog("remote_cmd: turning off -noserverdpms mode.\n");
no_ultra_dpms = 0;
} else if (strstr(p, "fs") == p) { } else if (strstr(p, "fs") == p) {
COLON_CHECK("fs:") COLON_CHECK("fs:")
if (query) { if (query) {
......
...@@ -1458,6 +1458,24 @@ void accept_openssl(int mode) { ...@@ -1458,6 +1458,24 @@ void accept_openssl(int mode) {
} }
close(i); close(i);
} }
if (screen->listenSock >= 0) {
close(screen->listenSock);
FD_CLR(screen->listenSock,&screen->allFds);
screen->listenSock = -1;
}
if (screen->httpListenSock >= 0) {
close(screen->httpListenSock);
FD_CLR(screen->httpListenSock,&screen->allFds);
screen->httpListenSock = -1;
}
if (openssl_sock >= 0) {
close(openssl_sock);
openssl_sock = -1;
}
if (https_sock >= 0) {
close(https_sock);
https_sock = -1;
}
/* /*
* sadly, we are a long lived child and so the large * sadly, we are a long lived child and so the large
......
...@@ -869,6 +869,8 @@ char create_display[] = ...@@ -869,6 +869,8 @@ char create_display[] =
"#!/bin/sh\n" "#!/bin/sh\n"
"\n" "\n"
"#CREATE_DISPLAY_OUTPUT=/tmp/cdo.txt\n" "#CREATE_DISPLAY_OUTPUT=/tmp/cdo.txt\n"
"\n"
"CREATE_DISPLAY_OUTPUT=/tmp/cdo.$USER.txt\n"
"if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n" "if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
" if [ \"X$CREATE_DISPLAY_EXEC\" = \"X\" ]; then\n" " if [ \"X$CREATE_DISPLAY_EXEC\" = \"X\" ]; then\n"
" CREATE_DISPLAY_EXEC=1\n" " CREATE_DISPLAY_EXEC=1\n"
...@@ -1033,29 +1035,56 @@ char create_display[] = ...@@ -1033,29 +1035,56 @@ char create_display[] =
" $have_xauth -f $authfile nextract - `hostname`:$N | $have_xauth nmerge -\n" " $have_xauth -f $authfile nextract - `hostname`:$N | $have_xauth nmerge -\n"
" fi\n" " fi\n"
"\n" "\n"
" result=0\n"
" ns=4\n"
" if [ \"X$use_xdmcp_query\" = \"X1\" ]; then\n" " if [ \"X$use_xdmcp_query\" = \"X1\" ]; then\n"
" # we cannot use -nolisten tcp\n" " # we cannot use -nolisten tcp\n"
" #echo \"$* -from localhost -once -query localhost\"\n"
" #nohup $* -from localhost -once -query localhost 1>&2 &\n"
" echo \"$* -once -query localhost\" 1>&2\n" " echo \"$* -once -query localhost\" 1>&2\n"
" nohup $* -once -query localhost 1>&2 &\n" " if [ \"X$have_root\" != \"X\" ]; then\n"
" pid=$!\n" " nohup $* -once -query localhost 1>&2 &\n"
" elif [ \"X$have_startx\" != \"X\" ]; then\n" " else\n"
" echo \"$have_startx $sess -- $* -nolisten tcp -auth $authfile\" 1>&2\n" " nohup sh -c \"(sleep $ns; $* -once -query localhost -auth $authfile)\" 1>&2 &\n"
" $have_startx $sess -- $* -nolisten tcp -auth $authfile 1>&2 &\n" " ns=0\n"
" result=1\n"
" fi\n"
" pid=$!\n" " pid=$!\n"
" elif [ \"X$have_xinit\" != \"X\" ]; then\n" " elif [ \"X$have_startx\" != \"X\" -o \"X$have_xinit\" != \"X\" ]; then\n"
" echo \"$have_xinit $sess -- $* -nolisten tcp -auth $authfile\" 1>&2\n" " if [ \"X$have_startx\" != \"X\" ]; then\n"
" $have_xinit $sess -- $* -nolisten tcp -auth $authfile 1>&2 &\n" " sxcmd=$have_startx\n"
" else\n"
" sxcmd=$have_xinit\n"
" fi\n"
" echo \"$sxcmd $sess -- $* -nolisten tcp -auth $authfile\" 1>&2\n"
" if [ \"X$have_root\" != \"X\" ]; then\n"
" $sxcmd $sess -- $* -nolisten tcp -auth $authfile 1>&2 &\n"
" else\n"
" nohup sh -c \"(sleep $ns; $sxcmd $sess -- $* -nolisten tcp -auth $authfile)\" 1>&2 &\n"
" ns=0\n"
" result=1\n"
" fi\n"
" pid=$!\n" " pid=$!\n"
" else\n" " else\n"
" echo \"$* -nolisten tcp -auth $authfile\" 1>&2\n" " echo \"$* -nolisten tcp -auth $authfile\" 1>&2\n"
" nohup $* -nolisten tcp -auth $authfile 1>&2 &\n" " if [ \"X$have_root\" != \"X\" ]; then\n"
" pid=$!\n" " nohup $* -nolisten tcp -auth $authfile 1>&2 &\n"
" nohup $sess 1>&2 &\n" " pid=$!\n"
" sleep 2\n"
" nohup $sess 1>&2 &\n"
" else\n"
" nohup sh -c \"(sleep $ns; $* -nolisten tcp -auth $authfile)\" 1>&2 &\n"
" pid=$!\n"
" sleep 2\n"
" nohup sh -c \"(sleep $ns; $sess)\" 1>&2 &\n"
" ns=0\n"
" result=1\n"
" fi\n"
" fi\n" " fi\n"
" sleep 4\n" " sleep $ns\n"
" if kill -0 $pid; then\n" " if [ \"X$result\" = \"X1\" ]; then\n"
" :\n"
" elif [ -d /proc/$pid ]; then\n"
" result=1\n"
" elif kill -0 $pid; then\n"
" result=1\n" " result=1\n"
" else\n" " else\n"
" result=0\n" " result=0\n"
...@@ -1123,17 +1152,33 @@ char create_display[] = ...@@ -1123,17 +1152,33 @@ char create_display[] =
" #have_startx=$save_have_startx\n" " #have_startx=$save_have_startx\n"
"\n" "\n"
" if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n" " if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n"
" (\n" " if [ \"X$have_root\" = \"X\" ]; then\n"
" sleep 1; $have_xmodmap -display :$N -e \"keycode any = Shift_R\" \n" " nohup sh -c \"(\n"
" sleep 1; $have_xmodmap -display :$N -e \"add Shift = Shift_L Shift_R\" \n" " sleep 6;\n"
" sleep 1; $have_xmodmap -display :$N -e \"keycode any = Control_R\" \n" " $have_xmodmap -display :$N -e 'keycode any = Shift_R' \\\n"
" sleep 1; $have_xmodmap -display :$N -e \"add Control = Control_L Control_R\" \n" " -e 'add Shift = Shift_L Shift_R' \\\n"
" sleep 1; $have_xmodmap -display :$N -e \"keycode any = Alt_L\" \n" " -e 'keycode any = Control_R' \\\n"
" sleep 1; $have_xmodmap -display :$N -e \"keycode any = Alt_R\" \n" " -e 'add Control = Control_L Control_R' \\\n"
" sleep 1; $have_xmodmap -display :$N -e \"keycode any = Meta_L\" \n" " -e 'keycode any = Alt_L' \\\n"
" sleep 1; $have_xmodmap -display :$N -e \"clear Mod1\" \n" " -e 'keycode any = Alt_R' \\\n"
" sleep 1; $have_xmodmap -display :$N -e \"add Mod1 = Alt_L Alt_R Meta_L\" \n" " -e 'keycode any = Meta_L' \\\n"
" ) 1>&2 &\n" " -e 'clear Mod1' \\\n"
" -e 'add Mod1 = Alt_L Alt_R Meta_L' \\\n"
" )\" 1>&2 &\n"
" else\n"
" (\n"
" sleep 1;\n"
" $have_xmodmap -display :$N -e 'keycode any = Shift_R' \\\n"
" -e 'add Shift = Shift_L Shift_R' \\\n"
" -e 'keycode any = Control_R' \\\n"
" -e 'add Control = Control_L Control_R' \\\n"
" -e 'keycode any = Alt_L' \\\n"
" -e 'keycode any = Alt_R' \\\n"
" -e 'keycode any = Meta_L' \\\n"
" -e 'clear Mod1' \\\n"
" -e 'add Mod1 = Alt_L Alt_R Meta_L' \\\n"
" ) 1>&2 &\n"
" fi\n"
" fi\n" " fi\n"
"}\n" "}\n"
"\n" "\n"
......
...@@ -213,6 +213,7 @@ Pointer ...@@ -213,6 +213,7 @@ Pointer
=D nocursorshape =D nocursorshape
-- --
noxfixes noxfixes
cursor_drag
=GAL AlphaBlending:: =GAL AlphaBlending::
noalphablend noalphablend
alphacut: alphacut:
...@@ -257,6 +258,8 @@ Misc ...@@ -257,6 +258,8 @@ Misc
=D nobell =D nobell
nolookup nolookup
bg bg
=S loop
=S loopbg
=-C:ignore,exit sigpipe: =-C:ignore,exit sigpipe:
=0 inetd =0 inetd
...@@ -329,6 +332,10 @@ Permissions ...@@ -329,6 +332,10 @@ Permissions
timeout: timeout:
grabkbd grabkbd
grabptr grabptr
grabalways
forcedpms
clientdpms
noserverdpms
=GAL LOFF =GAL LOFF
Tuning Tuning
......
...@@ -224,6 +224,7 @@ char gui_code[] = ""; ...@@ -224,6 +224,7 @@ char gui_code[] = "";
" =D nocursorshape\n" " =D nocursorshape\n"
" --\n" " --\n"
" noxfixes\n" " noxfixes\n"
" cursor_drag\n"
" =GAL AlphaBlending::\n" " =GAL AlphaBlending::\n"
" noalphablend\n" " noalphablend\n"
" alphacut:\n" " alphacut:\n"
...@@ -268,6 +269,8 @@ char gui_code[] = ""; ...@@ -268,6 +269,8 @@ char gui_code[] = "";
" =D nobell\n" " =D nobell\n"
" nolookup\n" " nolookup\n"
" bg\n" " bg\n"
" =S loop\n"
" =S loopbg\n"
" =-C:ignore,exit sigpipe:\n" " =-C:ignore,exit sigpipe:\n"
" =0 inetd\n" " =0 inetd\n"
"\n" "\n"
...@@ -340,6 +343,10 @@ char gui_code[] = ""; ...@@ -340,6 +343,10 @@ char gui_code[] = "";
" timeout:\n" " timeout:\n"
" grabkbd\n" " grabkbd\n"
" grabptr\n" " grabptr\n"
" grabalways\n"
" forcedpms\n"
" clientdpms\n"
" noserverdpms\n"
" =GAL LOFF\n" " =GAL LOFF\n"
"\n" "\n"
"Tuning\n" "Tuning\n"
......
...@@ -558,7 +558,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int ...@@ -558,7 +558,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int
#ifndef UNIXPW_SU #ifndef UNIXPW_SU
return 0; return 0;
#else #else
int i, j, status, fd = -1, sfd, tfd, drain_size = 4096, rsize = 0; int i, j, status, fd = -1, sfd, tfd, drain_size = 65536, rsize = 0;
int slow_pw = 1; int slow_pw = 1;
char *slave, *bin_true = NULL, *bin_su = NULL; char *slave, *bin_true = NULL, *bin_su = NULL;
pid_t pid, pidw; pid_t pid, pidw;
...@@ -1542,7 +1542,7 @@ void unixpw_accept(char *user) { ...@@ -1542,7 +1542,7 @@ void unixpw_accept(char *user) {
} else if (switch_user(u, 0)) { } else if (switch_user(u, 0)) {
rfbLog("unixpw_accept switched to user: %s\n", user); rfbLog("unixpw_accept switched to user: %s\n", user);
} else { } else {
rfbLog("unixpw_accept failed to switched to user: %s\n", user); rfbLog("unixpw_accept failed to switch to user: %s\n", user);
} }
free(u); free(u);
} }
......
...@@ -1404,6 +1404,7 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1404,6 +1404,7 @@ int wait_for_client(int *argc, char** argv, int http) {
break; break;
} }
if (unixpw) { if (unixpw) {
if (! unixpw_in_progress) { if (! unixpw_in_progress) {
rfbLog("unixpw but no unixpw_in_progress\n"); rfbLog("unixpw but no unixpw_in_progress\n");
...@@ -1517,12 +1518,15 @@ if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprint ...@@ -1517,12 +1518,15 @@ if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprint
fprintf(mt, "%s", create_display); fprintf(mt, "%s", create_display);
fclose(mt); fclose(mt);
findcreatedisplay = 1;
if (getuid() != 0) { if (getuid() != 0) {
/* if not root, run as the other user... */ /* if not root, run as the other user... */
n = 18000; n = 18000;
close_exec_fds();
res = su_verify(keep_unixpw_user, res = su_verify(keep_unixpw_user,
keep_unixpw_pass, create_cmd, line, &n, nodisp); keep_unixpw_pass, create_cmd, line, &n, nodisp);
if (db) fprintf(stderr, "line: '%s'\n", line); if (db) fprintf(stderr, "c-res=%d n=%d line: '%s'\n", res, n, line);
} else { } else {
FILE *p; FILE *p;
...@@ -1633,6 +1637,8 @@ if (db) fprintf(stderr, "\n"); ...@@ -1633,6 +1637,8 @@ if (db) fprintf(stderr, "\n");
fprintf(mt, "%s", create_display); fprintf(mt, "%s", create_display);
fclose(mt); fclose(mt);
findcreatedisplay = 1;
rfbLog("wait_for_client: FINDCREATEDISPLAY cmd: %s\n", create_cmd); rfbLog("wait_for_client: FINDCREATEDISPLAY cmd: %s\n", create_cmd);
p = popen(create_cmd, "r"); p = popen(create_cmd, "r");
...@@ -1772,7 +1778,7 @@ fprintf(stderr, "\n");} ...@@ -1772,7 +1778,7 @@ fprintf(stderr, "\n");}
} else if (switch_user(u, 0)) { } else if (switch_user(u, 0)) {
rfbLog("unixpw_accept switched to user: %s\n", user); rfbLog("unixpw_accept switched to user: %s\n", user);
} else { } else {
rfbLog("unixpw_accept failed to switched to user: %s\n", user); rfbLog("unixpw_accept failed to switch to user: %s\n", user);
} }
free(u); free(u);
} }
......
This diff is collapsed.
...@@ -1302,12 +1302,16 @@ static void check_loop_mode(int argc, char* argv[]) { ...@@ -1302,12 +1302,16 @@ static void check_loop_mode(int argc, char* argv[]) {
loop_max = atoi(q+1); loop_max = atoi(q+1);
*q = '\0'; *q = '\0';
} }
if (strstr(p, "-loopbg") == p) {
set_env("X11VNC_LOOP_MODE_BG", "1");
loop_sleep = 500;
}
q = strpbrk(p, "0123456789"); q = strpbrk(p, "0123456789");
if (q) { if (q) {
loop_sleep = atoi(q); loop_sleep = atoi(q);
if (loop_sleep <= 0) { if (loop_sleep <= 0) {
loop_sleep = 10; loop_sleep = 20;
} }
} }
} }
...@@ -1528,7 +1532,6 @@ int main(int argc, char* argv[]) { ...@@ -1528,7 +1532,6 @@ int main(int argc, char* argv[]) {
int dt = 0, bg = 0; int dt = 0, bg = 0;
int got_rfbwait = 0; int got_rfbwait = 0;
int got_httpdir = 0, try_http = 0; int got_httpdir = 0, try_http = 0;
int waited_for_client = 0;
int orig_use_xdamage = use_xdamage; int orig_use_xdamage = use_xdamage;
XImage *fb0 = NULL; XImage *fb0 = NULL;
...@@ -1745,6 +1748,14 @@ int main(int argc, char* argv[]) { ...@@ -1745,6 +1748,14 @@ int main(int argc, char* argv[]) {
connect_once = 0; connect_once = 0;
} else if (strstr(arg, "-loop") == arg) { } else if (strstr(arg, "-loop") == arg) {
; /* handled above */ ; /* handled above */
#if LIBVNCSERVER_HAVE_SETSID
bg = 1;
opts_bg = bg;
#else
fprintf(stderr, "warning: -bg mode not supported.\n");
#endif
} else if (strstr(arg, "-loop") == arg) {
; /* handled above */
} else if (!strcmp(arg, "-timeout")) { } else if (!strcmp(arg, "-timeout")) {
CHECK_ARGC CHECK_ARGC
first_conn_timeout = atoi(argv[++i]); first_conn_timeout = atoi(argv[++i]);
...@@ -1792,6 +1803,10 @@ int main(int argc, char* argv[]) { ...@@ -1792,6 +1803,10 @@ int main(int argc, char* argv[]) {
grab_kbd = 1; grab_kbd = 1;
} else if (!strcmp(arg, "-grabptr")) { } else if (!strcmp(arg, "-grabptr")) {
grab_ptr = 1; grab_ptr = 1;
} else if (!strcmp(arg, "-grabalways")) {
grab_kbd = 1;
grab_ptr = 1;
grab_always = 1;
} else if (!strcmp(arg, "-viewpasswd")) { } else if (!strcmp(arg, "-viewpasswd")) {
vpw_loc = i; vpw_loc = i;
CHECK_ARGC CHECK_ARGC
...@@ -1801,6 +1816,18 @@ int main(int argc, char* argv[]) { ...@@ -1801,6 +1816,18 @@ int main(int argc, char* argv[]) {
CHECK_ARGC CHECK_ARGC
passwdfile = strdup(argv[++i]); passwdfile = strdup(argv[++i]);
got_passwdfile = 1; got_passwdfile = 1;
} else if (!strcmp(arg, "-svc") || !strcmp(arg, "-service")) {
use_dpy = strdup("WAIT:cmd=FINDCREATEDISPLAY-Xvfb");
unixpw = 1;
users_list = strdup("unixpw=");
use_openssl = 1;
openssl_pem = strdup("SAVE");
} else if (!strcmp(arg, "-xdmsvc") || !strcmp(arg, "-xdm_service")) {
use_dpy = strdup("WAIT:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp");
unixpw = 1;
users_list = strdup("unixpw=");
use_openssl = 1;
openssl_pem = strdup("SAVE");
#ifndef NO_SSL_OR_UNIXPW #ifndef NO_SSL_OR_UNIXPW
} else if (!strcmp(arg, "-unixpw_cmd") } else if (!strcmp(arg, "-unixpw_cmd")
|| !strcmp(arg, "-unixpw_cmd_unsafe")) { || !strcmp(arg, "-unixpw_cmd_unsafe")) {
...@@ -1834,6 +1861,9 @@ int main(int argc, char* argv[]) { ...@@ -1834,6 +1861,9 @@ int main(int argc, char* argv[]) {
set_env("UNIXPW_DISABLE_SSL", "1"); set_env("UNIXPW_DISABLE_SSL", "1");
set_env("UNIXPW_DISABLE_LOCALHOST", "1"); set_env("UNIXPW_DISABLE_LOCALHOST", "1");
} }
} else if (!strcmp(arg, "-nossl")) {
use_openssl = 0;
openssl_pem = NULL;
} else if (!strcmp(arg, "-ssl")) { } else if (!strcmp(arg, "-ssl")) {
use_openssl = 1; use_openssl = 1;
if (i < argc-1) { if (i < argc-1) {
...@@ -2344,6 +2374,12 @@ int main(int argc, char* argv[]) { ...@@ -2344,6 +2374,12 @@ int main(int argc, char* argv[]) {
watch_dpms = 1; watch_dpms = 1;
} else if (!strcmp(arg, "-dpms")) { } else if (!strcmp(arg, "-dpms")) {
watch_dpms = 0; watch_dpms = 0;
} else if (!strcmp(arg, "-forcedpms")) {
force_dpms = 1;
} else if (!strcmp(arg, "-clientdpms")) {
client_dpms = 1;
} else if (!strcmp(arg, "-noserverdpms")) {
no_ultra_dpms = 1;
} else if (!strcmp(arg, "-xdamage")) { } else if (!strcmp(arg, "-xdamage")) {
use_xdamage++; use_xdamage++;
} else if (!strcmp(arg, "-noxdamage")) { } else if (!strcmp(arg, "-noxdamage")) {
...@@ -2563,7 +2599,7 @@ int main(int argc, char* argv[]) { ...@@ -2563,7 +2599,7 @@ int main(int argc, char* argv[]) {
orig_use_xdamage = use_xdamage; orig_use_xdamage = use_xdamage;
if (getenv("X11VNC_LOOP_MODE")) { if (getenv("X11VNC_LOOP_MODE")) {
if (bg) { if (bg && !getenv("X11VNC_LOOP_MODE_BG")) {
if (! quiet) { if (! quiet) {
fprintf(stderr, "disabling -bg in -loop " fprintf(stderr, "disabling -bg in -loop "
"mode\n"); "mode\n");
...@@ -3210,6 +3246,13 @@ int main(int argc, char* argv[]) { ...@@ -3210,6 +3246,13 @@ int main(int argc, char* argv[]) {
scr = DefaultScreen(dpy); scr = DefaultScreen(dpy);
rootwin = RootWindow(dpy, scr); rootwin = RootWindow(dpy, scr);
if (grab_always) {
Window save = window;
window = rootwin;
adjust_grabs(1, 0);
window = save;
}
if (! quiet && ! raw_fb_str) { if (! quiet && ! raw_fb_str) {
rfbLog("\n"); rfbLog("\n");
rfbLog("------------------ USEFUL INFORMATION ------------------\n"); rfbLog("------------------ USEFUL INFORMATION ------------------\n");
...@@ -3764,6 +3807,26 @@ int main(int argc, char* argv[]) { ...@@ -3764,6 +3807,26 @@ int main(int argc, char* argv[]) {
#if LIBVNCSERVER_HAVE_FORK && LIBVNCSERVER_HAVE_SETSID #if LIBVNCSERVER_HAVE_FORK && LIBVNCSERVER_HAVE_SETSID
if (bg) { if (bg) {
if (getenv("X11VNC_LOOP_MODE_BG")) {
if (screen && screen->listenSock >= 0) {
close(screen->listenSock);
FD_CLR(screen->listenSock,&screen->allFds);
screen->listenSock = -1;
}
if (screen && screen->httpListenSock >= 0) {
close(screen->httpListenSock);
FD_CLR(screen->httpListenSock,&screen->allFds);
screen->httpListenSock = -1;
}
if (openssl_sock >= 0) {
close(openssl_sock);
openssl_sock = -1;
}
if (https_sock >= 0) {
close(https_sock);
https_sock = -1;
}
}
/* fork into the background now */ /* fork into the background now */
int p, n; int p, n;
if ((p = fork()) > 0) { if ((p = fork()) > 0) {
......
...@@ -482,6 +482,9 @@ extern int hack_val; ...@@ -482,6 +482,9 @@ extern int hack_val;
extern rfbClientPtr last_pointer_client; extern rfbClientPtr last_pointer_client;
extern rfbClientPtr latest_client; extern rfbClientPtr latest_client;
extern int waited_for_client;
extern int findcreatedisplay;
extern int client_count; extern int client_count;
extern int clients_served; extern int clients_served;
......
...@@ -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.5 lastmod: 2007-02-10"; char lastmod[] = "0.8.5 lastmod: 2007-02-11";
/* X display info */ /* X display info */
...@@ -146,6 +146,9 @@ int hack_val = 0; ...@@ -146,6 +146,9 @@ int hack_val = 0;
rfbClientPtr last_pointer_client = NULL; rfbClientPtr last_pointer_client = NULL;
rfbClientPtr latest_client = NULL; rfbClientPtr latest_client = NULL;
int waited_for_client = 0;
int findcreatedisplay = 0;
int client_count = 0; int client_count = 0;
int clients_served = 0; int clients_served = 0;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
int grab_buster = 0; int grab_buster = 0;
int grab_kbd = 0; int grab_kbd = 0;
int grab_ptr = 0; int grab_ptr = 0;
int grab_always = 0;
int sync_tod_delay = 20; int sync_tod_delay = 20;
void initialize_vnc_connect_prop(void); void initialize_vnc_connect_prop(void);
...@@ -871,6 +872,7 @@ void check_xevents(int reset) { ...@@ -871,6 +872,7 @@ void check_xevents(int reset) {
XSetErrorHandler(old_handler); XSetErrorHandler(old_handler);
trapped_xerror = 0; trapped_xerror = 0;
last_call = now;
} }
/* check for CUT_BUFFER0 and VNC_CONNECT changes: */ /* check for CUT_BUFFER0 and VNC_CONNECT changes: */
...@@ -1156,7 +1158,6 @@ void check_xevents(int reset) { ...@@ -1156,7 +1158,6 @@ void check_xevents(int reset) {
} }
X_UNLOCK; X_UNLOCK;
last_call = now;
#endif /* NO_X11 */ #endif /* NO_X11 */
} }
...@@ -1346,14 +1347,22 @@ void set_server_input(rfbClientPtr cl, int grab) { ...@@ -1346,14 +1347,22 @@ void set_server_input(rfbClientPtr cl, int grab) {
return; return;
#else #else
if (grab) { if (grab) {
if (!no_ultra_dpms) {
set_dpms_mode("enable");
set_dpms_mode("off");
force_dpms = 1;
}
process_remote_cmd("cmd=grabkbd", 0); process_remote_cmd("cmd=grabkbd", 0);
process_remote_cmd("cmd=grabptr", 0); process_remote_cmd("cmd=grabptr", 0);
set_dpms_mode("off");
} else { } else {
process_remote_cmd("cmd=nograbkbd", 0); process_remote_cmd("cmd=nograbkbd", 0);
process_remote_cmd("cmd=nograbptr", 0); process_remote_cmd("cmd=nograbptr", 0);
if (!no_ultra_dpms) {
force_dpms = 0;
}
} }
#endif #endif
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
extern int grab_buster; extern int grab_buster;
extern int grab_kbd; extern int grab_kbd;
extern int grab_ptr; extern int grab_ptr;
extern int grab_always;
extern int sync_tod_delay; extern int sync_tod_delay;
extern void initialize_vnc_connect_prop(void); extern void initialize_vnc_connect_prop(void);
......
...@@ -1042,7 +1042,7 @@ int xauth_raw(int on) { ...@@ -1042,7 +1042,7 @@ int xauth_raw(int on) {
rfbLog("could not create tmp xauth file: %s\n", tmp); rfbLog("could not create tmp xauth file: %s\n", tmp);
return 0; return 0;
} }
if (db) fprintf(stderr, "tmp: %s\n", tmp); if (db) fprintf(stderr, "XAUTHORITY tmp: %s\n", tmp);
write(tmp_fd, xauth_raw_data, xauth_raw_len); write(tmp_fd, xauth_raw_data, xauth_raw_len);
close(tmp_fd); close(tmp_fd);
if (getenv("XAUTHORITY")) { if (getenv("XAUTHORITY")) {
......
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