summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrunge <runge>2006-06-09 22:36:41 +0000
committerrunge <runge>2006-06-09 22:36:41 +0000
commit7a3e236390501c14b9d75d80ea88f8a3e69a337a (patch)
tree02c71ad3e894e49d6c0a591ae785bb96f4e39593
parent1776a3a55f59052bd69509c889e4370973305f0d (diff)
downloadlibtdevnc-7a3e2363.tar.gz
libtdevnc-7a3e2363.zip
x11vnc: make -display WAIT + -unixpw work on Solaris.
-rw-r--r--x11vnc/ChangeLog3
-rw-r--r--x11vnc/README18
-rw-r--r--x11vnc/unixpw.c8
-rw-r--r--x11vnc/user.c34
4 files changed, 45 insertions, 18 deletions
diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog
index ff444e9..861ca08 100644
--- a/x11vnc/ChangeLog
+++ b/x11vnc/ChangeLog
@@ -1,3 +1,6 @@
+2006-06-09 Karl Runge <runge@karlrunge.com>
+ * x11vnc: make -display WAIT + -unixpw work on Solaris.
+
2006-06-08 Karl Runge <runge@karlrunge.com>
* x11vnc: XOpenDisplay wrapper for raw xauth data, -unixpw
su_verify() to run any cmd, -users unixpw= mode. -display WAIT:...
diff --git a/x11vnc/README b/x11vnc/README
index 643bbdb..db20b5c 100644
--- a/x11vnc/README
+++ b/x11vnc/README
@@ -1,5 +1,5 @@
-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:
@@ -3329,9 +3329,9 @@ service x11vncservice
x11vnc's (see [392]this example).
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
- 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:
#!/bin/sh
@@ -3367,7 +3367,7 @@ xauth extract - "$display" 2>/dev/null
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
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).
@@ -3396,10 +3396,10 @@ exit 0
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
- required for this scheme, but it is convenient because it determines
- who the user is whose display should be sought. Otherwise the
- find_display script would have to use some scheme to work all of this
- out.
+ required for this sort of scheme, but it is convenient because it
+ determines exactly who the user is whose display should be sought.
+ Otherwise the find_display script would have to use some method to
+ work out DISPLAY, XAUTHORITY, etc.
Q-52: Can I have x11vnc restart itself after it terminates?
@@ -3436,7 +3436,7 @@ exit 0
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
- 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
entirely from the viewer-side by having the jar file there and using
diff --git a/x11vnc/unixpw.c b/x11vnc/unixpw.c
index 4bca127..fae74a5 100644
--- a/x11vnc/unixpw.c
+++ b/x11vnc/unixpw.c
@@ -546,7 +546,13 @@ if (db) fprintf(stderr, "slave is: %s fd=%d\n", slave, fd);
/* synchronize with parent: */
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);
}
/* parent */
diff --git a/x11vnc/user.c b/x11vnc/user.c
index 90e791b..aa6432e 100644
--- a/x11vnc/user.c
+++ b/x11vnc/user.c
@@ -1082,15 +1082,15 @@ int wait_for_client(int *argc, char** argv, int http) {
memset(line2, 0, 16384);
if (unixpw) {
- int res = 0, k, j;
+ int res = 0, k, j, i;
char line[18000];
memset(line, 0, 18000);
if (keep_unixpw_user && keep_unixpw_pass) {
n = 18000;
- res = su_verify(keep_unixpw_user, keep_unixpw_pass,
- cmd, line, &n);
+ res = su_verify(keep_unixpw_user,
+ keep_unixpw_pass, cmd, line, &n);
strzero(keep_unixpw_user);
strzero(keep_unixpw_pass);
}
@@ -1100,17 +1100,35 @@ int wait_for_client(int *argc, char** argv, int http) {
rfbLog("wait_for_client: cmd failed: %s\n", cmd);
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++) {
- line1[k] = line[k];
- if (line[k] == '\n') {
+ line1[k] = q[k];
+ if (q[k] == '\n') {
k++;
break;
}
}
n -= k;
- while (j < 16384) {
- line2[j] = line[k+j];
- j++;
+ i = 0;
+ for (j = 0; j < 16384; 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 {
FILE *p = popen(cmd, "r");