View | Details | Raw Unified | Return to bug 1153 | Differences between
and this patch

Collapse All | Expand All

(-)session.c.orig (-6 / +13 lines)
Lines 2375-2382 Link Here
2375
	}
2375
	}
2376
2376
2377
	/* Set up a suitable value for the DISPLAY variable. */
2377
	/* Set up a suitable value for the DISPLAY variable. */
2378
	if (gethostname(hostname, sizeof(hostname)) < 0)
2378
	
2379
		fatal("gethostname: %.100s", strerror(errno));
2380
	/*
2379
	/*
2381
	 * auth_display must be used as the displayname when the
2380
	 * auth_display must be used as the displayname when the
2382
	 * authorization entry is added with xauth(1).  This will be
2381
	 * authorization entry is added with xauth(1).  This will be
Lines 2390-2410 Link Here
2390
		s->display = xstrdup(display);
2389
		s->display = xstrdup(display);
2391
		s->auth_display = xstrdup(auth_display);
2390
		s->auth_display = xstrdup(auth_display);
2392
	} else {
2391
	} else {
2393
#ifdef IPADDR_IN_DISPLAY
2394
		struct hostent *he;
2392
		struct hostent *he;
2395
		struct in_addr my_addr;
2393
		struct in_addr my_addr;
2396
2394
2397
		he = gethostbyname(hostname);
2395
		inet_aton(get_local_ipaddr(packet_get_connection_in()), &my_addr);
2398
		if (he == NULL) {
2396
		he = gethostbyaddr(&my_addr, sizeof(struct in_addr), AF_INET);
2397
		
2398
		if (he == NULL) { /* Try again with gethostname */
2399
			if (gethostname(hostname, sizeof(hostname)) < 0)
2400
                		fatal("gethostname: %.100s", strerror(errno));
2401
			
2402
			if ((he = gethostbyname(hostname)) == NULL) {
2399
			error("Can't get IP address for X11 DISPLAY.");
2403
			error("Can't get IP address for X11 DISPLAY.");
2400
			packet_send_debug("Can't get IP address for X11 DISPLAY.");
2404
			packet_send_debug("Can't get IP address for X11 DISPLAY.");
2401
			return 0;
2405
			return 0;
2402
		}
2406
		}
2407
		}
2408
2409
#ifdef IPADDR_IN_DISPLAY
2403
		memcpy(&my_addr, he->h_addr_list[0], sizeof(struct in_addr));
2410
		memcpy(&my_addr, he->h_addr_list[0], sizeof(struct in_addr));
2404
		snprintf(display, sizeof display, "%.50s:%u.%u", inet_ntoa(my_addr),
2411
		snprintf(display, sizeof display, "%.50s:%u.%u", inet_ntoa(my_addr),
2405
		    s->display_number, s->screen);
2412
		    s->display_number, s->screen);
2406
#else
2413
#else
2407
		snprintf(display, sizeof display, "%.400s:%u.%u", hostname,
2414
		snprintf(display, sizeof display, "%.400s:%u.%u", he->h_name,
2408
		    s->display_number, s->screen);
2415
		    s->display_number, s->screen);
2409
#endif
2416
#endif
2410
		s->display = xstrdup(display);
2417
		s->display = xstrdup(display);

Return to bug 1153