summaryrefslogtreecommitdiffstats
path: root/x11vnc/inet.c
diff options
context:
space:
mode:
authorrunge <runge>2006-03-03 00:30:16 +0000
committerrunge <runge>2006-03-03 00:30:16 +0000
commitb03a920cb996bf61af2d9351d2fe497ea3c0c99e (patch)
treed8b88ff7a0e19659374f8f4b7d443b33adf4b4cb /x11vnc/inet.c
parentf38f67e4e9320a3e0b1472b9c4bae86fcedcbd89 (diff)
downloadlibtdevnc-b03a920cb996bf61af2d9351d2fe497ea3c0c99e.tar.gz
libtdevnc-b03a920cb996bf61af2d9351d2fe497ea3c0c99e.zip
x11vnc: more -unixpw mode. -gone popup mode. Change filexfer via -R. Tune SMALL_FOOTPRINT.
Diffstat (limited to 'x11vnc/inet.c')
-rw-r--r--x11vnc/inet.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/x11vnc/inet.c b/x11vnc/inet.c
index 6a3921b..c4433a9 100644
--- a/x11vnc/inet.c
+++ b/x11vnc/inet.c
@@ -17,7 +17,7 @@ char *get_remote_host(int sock);
char *get_local_host(int sock);
char *ident_username(rfbClientPtr client);
int find_free_port(int start, int end);
-
+int have_ssh_env(void);
static int get_port(int sock, int remote);
static char *get_host(int sock, int remote);
@@ -314,3 +314,54 @@ int find_free_port(int start, int end) {
return 0;
}
+int have_ssh_env(void) {
+ char *str, *p = getenv("SSH_CONNECTION");
+ char *rhost, *rport, *lhost, *lport;
+
+ if (! p) return 0;
+
+ str = strdup(p);
+
+ p = strtok(str, " ");
+ rhost = p;
+
+ p = strtok(NULL, " ");
+ if (! p) goto fail;
+
+ rport = p;
+
+ p = strtok(NULL, " ");
+ if (! p) goto fail;
+
+ lhost = p;
+
+ p = strtok(NULL, " ");
+ if (! p) goto fail;
+
+ lport = p;
+
+if (0) fprintf(stderr, "%d/%d - '%s' '%s'\n", atoi(rport), atoi(lport), rhost, lhost);
+
+ if (atoi(rport) < 0 || atoi(rport) > 65535) {
+ goto fail;
+ }
+ if (atoi(lport) < 0 || atoi(lport) > 65535) {
+ goto fail;
+ }
+
+ if (!strcmp(rhost, lhost)) {
+ goto fail;
+ }
+
+ free(str);
+
+ return 1;
+
+ fail:
+fprintf(stderr, "failed:\n");
+
+ free(str);
+
+ return 0;
+}
+