summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-02-05 12:11:02 +1100
committerDamien Miller <djm@mindrot.org>2002-02-05 12:11:02 +1100
commit512bccbb5a7d4c2a8fc53dad17f4a6f7a07b0474 (patch)
treee6c1ac00b446bfd6afd219941546ed59ea5dcb21 /session.c
parent3672e4bc7ac19798f169ac7374c77a460d080e4a (diff)
- stevesk@cvs.openbsd.org 2002/01/26 16:44:22
[includes.h session.c] revert code to add x11 localhost display authorization entry for hostname/unix:d and uts.nodename/unix:d if nodename was different than hostname. just add entry for unix:d instead. ok markus@
Diffstat (limited to 'session.c')
-rw-r--r--session.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/session.c b/session.c
index a5ad077c9..268d1384e 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.117 2001/12/28 14:50:54 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.118 2002/01/26 16:44:22 stevesk Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -111,7 +111,7 @@ struct Session {
111 int display_number; 111 int display_number;
112 char *display; 112 char *display;
113 int screen; 113 int screen;
114 char *auth_display[2]; 114 char *auth_display;
115 char *auth_proto; 115 char *auth_proto;
116 char *auth_data; 116 char *auth_data;
117 int single_connection; 117 int single_connection;
@@ -1390,25 +1390,16 @@ do_child(Session *s, const char *command)
1390 fprintf(stderr, 1390 fprintf(stderr,
1391 "Running %.100s add " 1391 "Running %.100s add "
1392 "%.100s %.100s %.100s\n", 1392 "%.100s %.100s %.100s\n",
1393 options.xauth_location, s->auth_display[0], 1393 options.xauth_location, s->auth_display,
1394 s->auth_proto, s->auth_data); 1394 s->auth_proto, s->auth_data);
1395 if (s->auth_display[1])
1396 fprintf(stderr,
1397 "add %.100s %.100s %.100s\n",
1398 s->auth_display[1],
1399 s->auth_proto, s->auth_data);
1400 } 1395 }
1401 snprintf(cmd, sizeof cmd, "%s -q -", 1396 snprintf(cmd, sizeof cmd, "%s -q -",
1402 options.xauth_location); 1397 options.xauth_location);
1403 f = popen(cmd, "w"); 1398 f = popen(cmd, "w");
1404 if (f) { 1399 if (f) {
1405 fprintf(f, "add %s %s %s\n", 1400 fprintf(f, "add %s %s %s\n",
1406 s->auth_display[0], s->auth_proto, 1401 s->auth_display, s->auth_proto,
1407 s->auth_data); 1402 s->auth_data);
1408 if (s->auth_display[1])
1409 fprintf(f, "add %s %s %s\n",
1410 s->auth_display[1], s->auth_proto,
1411 s->auth_data);
1412 pclose(f); 1403 pclose(f);
1413 } else { 1404 } else {
1414 fprintf(stderr, "Could not run %s\n", 1405 fprintf(stderr, "Could not run %s\n",
@@ -1907,10 +1898,8 @@ session_close(Session *s)
1907 xfree(s->term); 1898 xfree(s->term);
1908 if (s->display) 1899 if (s->display)
1909 xfree(s->display); 1900 xfree(s->display);
1910 if (s->auth_display[0]) 1901 if (s->auth_display)
1911 xfree(s->auth_display[0]); 1902 xfree(s->auth_display);
1912 if (s->auth_display[1])
1913 xfree(s->auth_display[1]);
1914 if (s->auth_data) 1903 if (s->auth_data)
1915 xfree(s->auth_data); 1904 xfree(s->auth_data);
1916 if (s->auth_proto) 1905 if (s->auth_proto)
@@ -2046,31 +2035,13 @@ session_setup_x11fwd(Session *s)
2046 * authorization entry is added with xauth(1). This will be 2035 * authorization entry is added with xauth(1). This will be
2047 * different than the DISPLAY string for localhost displays. 2036 * different than the DISPLAY string for localhost displays.
2048 */ 2037 */
2049 s->auth_display[1] = NULL;
2050 if (!options.gateway_ports) { 2038 if (!options.gateway_ports) {
2051 struct utsname uts;
2052
2053 snprintf(display, sizeof display, "localhost:%d.%d", 2039 snprintf(display, sizeof display, "localhost:%d.%d",
2054 s->display_number, s->screen); 2040 s->display_number, s->screen);
2055 snprintf(auth_display, sizeof auth_display, "%.400s/unix:%d.%d", 2041 snprintf(auth_display, sizeof auth_display, "unix:%d.%d",
2056 hostname, s->display_number, s->screen); 2042 s->display_number, s->screen);
2057 s->display = xstrdup(display); 2043 s->display = xstrdup(display);
2058 s->auth_display[0] = xstrdup(auth_display); 2044 s->auth_display = xstrdup(auth_display);
2059 /*
2060 * Xlib may use gethostbyname() or uname() hostname to
2061 * look up authorization data for FamilyLocal; see:
2062 * xc/lib/xtrans/Xtrans.c:TRANS(GetHostname)
2063 * We just add authorization entries with both
2064 * hostname and nodename if they are different.
2065 */
2066 if (uname(&uts) == -1)
2067 fatal("uname: %.100s", strerror(errno));
2068 if (strcmp(hostname, uts.nodename) != 0) {
2069 snprintf(auth_display, sizeof auth_display,
2070 "%.400s/unix:%d.%d", uts.nodename,
2071 s->display_number, s->screen);
2072 s->auth_display[1] = xstrdup(auth_display);
2073 }
2074 } else { 2045 } else {
2075#ifdef IPADDR_IN_DISPLAY 2046#ifdef IPADDR_IN_DISPLAY
2076 struct hostent *he; 2047 struct hostent *he;
@@ -2090,7 +2061,7 @@ session_setup_x11fwd(Session *s)
2090 s->display_number, s->screen); 2061 s->display_number, s->screen);
2091#endif 2062#endif
2092 s->display = xstrdup(display); 2063 s->display = xstrdup(display);
2093 s->auth_display[0] = xstrdup(display); 2064 s->auth_display = xstrdup(display);
2094 } 2065 }
2095 2066
2096 return 1; 2067 return 1;