Commit 7a3e2363 authored by runge's avatar runge

x11vnc: make -display WAIT + -unixpw work on Solaris.

parent 1776a3a5
2006-06-09 Karl Runge <runge@karlrunge.com>
* x11vnc: make -display WAIT + -unixpw work on Solaris.
2006-06-08 Karl Runge <runge@karlrunge.com> 2006-06-08 Karl Runge <runge@karlrunge.com>
* x11vnc: XOpenDisplay wrapper for raw xauth data, -unixpw * x11vnc: XOpenDisplay wrapper for raw xauth data, -unixpw
su_verify() to run any cmd, -users unixpw= mode. -display WAIT:... su_verify() to run any cmd, -users unixpw= mode. -display WAIT:...
......
x11vnc README file Date: Thu Jun 8 18:47:45 EDT 2006 x11vnc README file Date: Thu Jun 8 23:48:35 EDT 2006
The following information is taken from these URLs: The following information is taken from these URLs:
...@@ -3329,9 +3329,9 @@ service x11vncservice ...@@ -3329,9 +3329,9 @@ service x11vncservice
x11vnc's (see [392]this example). x11vnc's (see [392]this example).
The [393]-display WAIT option waits until a VNC viewer is connected The [393]-display WAIT option waits until a VNC viewer is connected
before connecting to the X display, and can also be used to run a before attaching to the X display, and can also be used to run a
command that returns the DISPLAY and XAUTHORITY data. So one could command that returns the DISPLAY and XAUTHORITY data. So one could
supply "-display WAIT:find_display" where the script find_display supply "-display WAIT:cmd=find_display" where the script find_display
might look something like: might look something like:
#!/bin/sh #!/bin/sh
...@@ -3367,7 +3367,7 @@ xauth extract - "$display" 2>/dev/null ...@@ -3367,7 +3367,7 @@ xauth extract - "$display" 2>/dev/null
exit 0 exit 0
A some point a standard script created and will be used by default At some point a standard script like the above will be used by default
under "-display WAIT:cmd=FINDDISPLAY". The format the script returns under "-display WAIT:cmd=FINDDISPLAY". The format the script returns
is the first line is DISPLAY=:disp and any remaining lines are either is the first line is DISPLAY=:disp and any remaining lines are either
XAUTHORITY=file or raw xauth data (the above example does the latter). XAUTHORITY=file or raw xauth data (the above example does the latter).
...@@ -3396,10 +3396,10 @@ exit 0 ...@@ -3396,10 +3396,10 @@ exit 0
Note that [397]SSL is required for this mode because otherwise the Note that [397]SSL is required for this mode because otherwise the
unix password would be passed in clear text. In general -unixpw is not unix password would be passed in clear text. In general -unixpw is not
required for this scheme, but it is convenient because it determines required for this sort of scheme, but it is convenient because it
who the user is whose display should be sought. Otherwise the determines exactly who the user is whose display should be sought.
find_display script would have to use some scheme to work all of this Otherwise the find_display script would have to use some method to
out. work out DISPLAY, XAUTHORITY, etc.
Q-52: Can I have x11vnc restart itself after it terminates? Q-52: Can I have x11vnc restart itself after it terminates?
...@@ -3436,7 +3436,7 @@ exit 0 ...@@ -3436,7 +3436,7 @@ exit 0
free to customize the default index.vnc file in the classes directory. free to customize the default index.vnc file in the classes directory.
As of May/2005 the [400]-http option will try to guess where the Java As of May/2005 the [400]-http option will try to guess where the Java
classes jar file is by looking a expected locations. classes jar file is by looking in expected locations.
Also note that if you wanted to, you could also start the Java viewer Also note that if you wanted to, you could also start the Java viewer
entirely from the viewer-side by having the jar file there and using entirely from the viewer-side by having the jar file there and using
......
...@@ -546,7 +546,13 @@ if (db) fprintf(stderr, "slave is: %s fd=%d\n", slave, fd); ...@@ -546,7 +546,13 @@ if (db) fprintf(stderr, "slave is: %s fd=%d\n", slave, fd);
/* synchronize with parent: */ /* synchronize with parent: */
write(2, "C", 1); write(2, "C", 1);
execlp(bin_su, bin_su, user, "-c", bin_true, (char *) NULL); if (cmd) {
execlp(bin_su, bin_su, "-", user, "-c",
bin_true, (char *) NULL);
} else {
execlp(bin_su, bin_su, user, "-c",
bin_true, (char *) NULL);
}
exit(1); exit(1);
} }
/* parent */ /* parent */
......
...@@ -1082,15 +1082,15 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1082,15 +1082,15 @@ int wait_for_client(int *argc, char** argv, int http) {
memset(line2, 0, 16384); memset(line2, 0, 16384);
if (unixpw) { if (unixpw) {
int res = 0, k, j; int res = 0, k, j, i;
char line[18000]; char line[18000];
memset(line, 0, 18000); memset(line, 0, 18000);
if (keep_unixpw_user && keep_unixpw_pass) { if (keep_unixpw_user && keep_unixpw_pass) {
n = 18000; n = 18000;
res = su_verify(keep_unixpw_user, keep_unixpw_pass, res = su_verify(keep_unixpw_user,
cmd, line, &n); keep_unixpw_pass, cmd, line, &n);
strzero(keep_unixpw_user); strzero(keep_unixpw_user);
strzero(keep_unixpw_pass); strzero(keep_unixpw_pass);
} }
...@@ -1100,17 +1100,35 @@ int wait_for_client(int *argc, char** argv, int http) { ...@@ -1100,17 +1100,35 @@ int wait_for_client(int *argc, char** argv, int http) {
rfbLog("wait_for_client: cmd failed: %s\n", cmd); rfbLog("wait_for_client: cmd failed: %s\n", cmd);
clean_up_exit(1); clean_up_exit(1);
} }
/*
* we need to hunt for DISPLAY= since there may be
* a login banner or something at the beginning.
*/
q = strstr(line, "DISPLAY=");
if (! q) {
q = line;
}
n -= (q - line);
for (k = 0; k < 1024; k++) { for (k = 0; k < 1024; k++) {
line1[k] = line[k]; line1[k] = q[k];
if (line[k] == '\n') { if (q[k] == '\n') {
k++; k++;
break; break;
} }
} }
n -= k; n -= k;
while (j < 16384) { i = 0;
line2[j] = line[k+j]; for (j = 0; j < 16384; j++) {
j++; if (j < 16384 - 1) {
/* xauth data, assume pty added CR */
if (q[k+j] == '\r' && q[k+j+1] == '\n') {
continue;
}
}
line2[i] = q[k+j];
i++;
} }
} else { } else {
FILE *p = popen(cmd, "r"); FILE *p = popen(cmd, "r");
......
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