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

Collapse All | Expand All

(-)a/channels.c (-6 / +9 lines)
Lines 148-156 static int all_opens_permitted = 0; Link Here
148
148
149
/* -- X11 forwarding */
149
/* -- X11 forwarding */
150
150
151
/* Maximum number of fake X11 displays to try. */
152
#define MAX_DISPLAYS  1000
153
154
/* Saved X11 local (client) display. */
151
/* Saved X11 local (client) display. */
155
static char *x11_saved_display = NULL;
152
static char *x11_saved_display = NULL;
156
153
Lines 3890-3896 channel_send_window_changes(void) Link Here
3890
 */
3887
 */
3891
int
3888
int
3892
x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
3889
x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
3893
    int single_connection, u_int *display_numberp, int **chanids)
3890
	int x11_max_displays, int single_connection, u_int *display_numberp,
3891
	int **chanids)
3894
{
3892
{
3895
	Channel *nc = NULL;
3893
	Channel *nc = NULL;
3896
	int display_number, sock;
3894
	int display_number, sock;
Lines 3902-3911 x11_create_display_inet(int x11_display_offset, int x11_use_localhost, Link Here
3902
	if (chanids == NULL)
3900
	if (chanids == NULL)
3903
		return -1;
3901
		return -1;
3904
3902
3903
	/* Try to bind ports starting at 6000+X11DisplayOffset */
3904
	x11_max_displays = x11_max_displays + x11_display_offset;
3905
3905
	for (display_number = x11_display_offset;
3906
	for (display_number = x11_display_offset;
3906
	    display_number < MAX_DISPLAYS;
3907
	    display_number < x11_max_displays;
3907
	    display_number++) {
3908
	    display_number++) {
3908
		port = 6000 + display_number;
3909
		port = 6000 + display_number;
3910
		if (port < 6000) /* overflow */
3911
			break;
3909
		memset(&hints, 0, sizeof(hints));
3912
		memset(&hints, 0, sizeof(hints));
3910
		hints.ai_family = IPv4or6;
3913
		hints.ai_family = IPv4or6;
3911
		hints.ai_flags = x11_use_localhost ? 0: AI_PASSIVE;
3914
		hints.ai_flags = x11_use_localhost ? 0: AI_PASSIVE;
Lines 3957-3963 x11_create_display_inet(int x11_display_offset, int x11_use_localhost, Link Here
3957
		if (num_socks > 0)
3960
		if (num_socks > 0)
3958
			break;
3961
			break;
3959
	}
3962
	}
3960
	if (display_number >= MAX_DISPLAYS) {
3963
	if (display_number >= x11_max_displays || port < 6000 ) {
3961
		error("Failed to allocate internet-domain X11 display socket.");
3964
		error("Failed to allocate internet-domain X11 display socket.");
3962
		return -1;
3965
		return -1;
3963
	}
3966
	}
(-)a/channels.h (-1 / +1 lines)
Lines 286-292 int permitopen_port(const char *); Link Here
286
286
287
void	 channel_set_x11_refuse_time(u_int);
287
void	 channel_set_x11_refuse_time(u_int);
288
int	 x11_connect_display(void);
288
int	 x11_connect_display(void);
289
int	 x11_create_display_inet(int, int, int, u_int *, int **);
289
int	 x11_create_display_inet(int, int, int, int, u_int *, int **);
290
int      x11_input_open(int, u_int32_t, void *);
290
int      x11_input_open(int, u_int32_t, void *);
291
void	 x11_request_forwarding_with_spoofing(int, const char *, const char *,
291
void	 x11_request_forwarding_with_spoofing(int, const char *, const char *,
292
	     const char *, int);
292
	     const char *, int);
(-)a/servconf.c (-1 / +11 lines)
Lines 96-101 initialize_server_options(ServerOptions *options) Link Here
96
	options->print_lastlog = -1;
96
	options->print_lastlog = -1;
97
	options->x11_forwarding = -1;
97
	options->x11_forwarding = -1;
98
	options->x11_display_offset = -1;
98
	options->x11_display_offset = -1;
99
	options->x11_max_displays = -1;
99
	options->x11_use_localhost = -1;
100
	options->x11_use_localhost = -1;
100
	options->permit_tty = -1;
101
	options->permit_tty = -1;
101
	options->permit_user_rc = -1;
102
	options->permit_user_rc = -1;
Lines 251-256 fill_default_server_options(ServerOptions *options) Link Here
251
		options->x11_forwarding = 0;
252
		options->x11_forwarding = 0;
252
	if (options->x11_display_offset == -1)
253
	if (options->x11_display_offset == -1)
253
		options->x11_display_offset = 10;
254
		options->x11_display_offset = 10;
255
	if (options->x11_max_displays == -1)
256
		options->x11_max_displays = DEFAULT_MAX_DISPLAYS;
254
	if (options->x11_use_localhost == -1)
257
	if (options->x11_use_localhost == -1)
255
		options->x11_use_localhost = 1;
258
		options->x11_use_localhost = 1;
256
	if (options->xauth_location == NULL)
259
	if (options->xauth_location == NULL)
Lines 407-413 typedef enum { Link Here
407
	sPasswordAuthentication, sKbdInteractiveAuthentication,
410
	sPasswordAuthentication, sKbdInteractiveAuthentication,
408
	sListenAddress, sAddressFamily,
411
	sListenAddress, sAddressFamily,
409
	sPrintMotd, sPrintLastLog, sIgnoreRhosts,
412
	sPrintMotd, sPrintLastLog, sIgnoreRhosts,
410
	sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
413
	sX11Forwarding, sX11DisplayOffset, sX11MaxDisplays, sX11UseLocalhost,
411
	sPermitTTY, sStrictModes, sEmptyPasswd, sTCPKeepAlive,
414
	sPermitTTY, sStrictModes, sEmptyPasswd, sTCPKeepAlive,
412
	sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
415
	sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
413
	sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
416
	sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
Lines 515-520 static struct { Link Here
515
	{ "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
518
	{ "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
516
	{ "x11forwarding", sX11Forwarding, SSHCFG_ALL },
519
	{ "x11forwarding", sX11Forwarding, SSHCFG_ALL },
517
	{ "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL },
520
	{ "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL },
521
	{ "x11maxdisplays", sX11MaxDisplays, SSHCFG_ALL },
518
	{ "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL },
522
	{ "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL },
519
	{ "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL },
523
	{ "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL },
520
	{ "strictmodes", sStrictModes, SSHCFG_GLOBAL },
524
	{ "strictmodes", sStrictModes, SSHCFG_GLOBAL },
Lines 1279-1284 process_server_config_line(ServerOptions *options, char *line, Link Here
1279
		intptr = &options->x11_display_offset;
1283
		intptr = &options->x11_display_offset;
1280
		goto parse_int;
1284
		goto parse_int;
1281
1285
1286
	case sX11MaxDisplays:
1287
		intptr = &options->x11_max_displays;
1288
		goto parse_int;
1289
1282
	case sX11UseLocalhost:
1290
	case sX11UseLocalhost:
1283
		intptr = &options->x11_use_localhost;
1291
		intptr = &options->x11_use_localhost;
1284
		goto parse_flag;
1292
		goto parse_flag;
Lines 1996-2001 copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth) Link Here
1996
	M_CP_INTOPT(fwd_opts.gateway_ports);
2004
	M_CP_INTOPT(fwd_opts.gateway_ports);
1997
	M_CP_INTOPT(fwd_opts.streamlocal_bind_unlink);
2005
	M_CP_INTOPT(fwd_opts.streamlocal_bind_unlink);
1998
	M_CP_INTOPT(x11_display_offset);
2006
	M_CP_INTOPT(x11_display_offset);
2007
	M_CP_INTOPT(x11_max_displays);
1999
	M_CP_INTOPT(x11_forwarding);
2008
	M_CP_INTOPT(x11_forwarding);
2000
	M_CP_INTOPT(x11_use_localhost);
2009
	M_CP_INTOPT(x11_use_localhost);
2001
	M_CP_INTOPT(permit_tty);
2010
	M_CP_INTOPT(permit_tty);
Lines 2252-2257 dump_config(ServerOptions *o) Link Here
2252
	dump_cfg_int(sLoginGraceTime, o->login_grace_time);
2261
	dump_cfg_int(sLoginGraceTime, o->login_grace_time);
2253
	dump_cfg_int(sKeyRegenerationTime, o->key_regeneration_time);
2262
	dump_cfg_int(sKeyRegenerationTime, o->key_regeneration_time);
2254
	dump_cfg_int(sX11DisplayOffset, o->x11_display_offset);
2263
	dump_cfg_int(sX11DisplayOffset, o->x11_display_offset);
2264
	dump_cfg_int(sX11MaxDisplays, o->x11_max_displays);
2255
	dump_cfg_int(sMaxAuthTries, o->max_authtries);
2265
	dump_cfg_int(sMaxAuthTries, o->max_authtries);
2256
	dump_cfg_int(sMaxSessions, o->max_sessions);
2266
	dump_cfg_int(sMaxSessions, o->max_sessions);
2257
	dump_cfg_int(sClientAliveInterval, o->client_alive_interval);
2267
	dump_cfg_int(sClientAliveInterval, o->client_alive_interval);
(-)a/servconf.h (+2 lines)
Lines 50-55 Link Here
50
50
51
#define DEFAULT_AUTH_FAIL_MAX	6	/* Default for MaxAuthTries */
51
#define DEFAULT_AUTH_FAIL_MAX	6	/* Default for MaxAuthTries */
52
#define DEFAULT_SESSIONS_MAX	10	/* Default for MaxSessions */
52
#define DEFAULT_SESSIONS_MAX	10	/* Default for MaxSessions */
53
#define DEFAULT_MAX_DISPLAYS	1000 /* Maximum number of fake X11 displays to try. */
53
54
54
/* Magic name for internal sftp-server */
55
/* Magic name for internal sftp-server */
55
#define INTERNAL_SFTP_NAME	"internal-sftp"
56
#define INTERNAL_SFTP_NAME	"internal-sftp"
Lines 82-87 typedef struct { Link Here
82
	int     x11_forwarding;	/* If true, permit inet (spoofing) X11 fwd. */
83
	int     x11_forwarding;	/* If true, permit inet (spoofing) X11 fwd. */
83
	int     x11_display_offset;	/* What DISPLAY number to start
84
	int     x11_display_offset;	/* What DISPLAY number to start
84
					 * searching at */
85
					 * searching at */
86
	int 	x11_max_displays; /* Number of displays to search */
85
	int     x11_use_localhost;	/* If true, use localhost for fake X11 server. */
87
	int     x11_use_localhost;	/* If true, use localhost for fake X11 server. */
86
	char   *xauth_location;	/* Location of xauth program */
88
	char   *xauth_location;	/* Location of xauth program */
87
	int	permit_tty;	/* If false, deny pty allocation */
89
	int	permit_tty;	/* If false, deny pty allocation */
(-)a/session.c (-2 / +3 lines)
Lines 2701-2708 session_setup_x11fwd(Session *s) Link Here
2701
		return 0;
2701
		return 0;
2702
	}
2702
	}
2703
	if (x11_create_display_inet(options.x11_display_offset,
2703
	if (x11_create_display_inet(options.x11_display_offset,
2704
	    options.x11_use_localhost, s->single_connection,
2704
	    options.x11_use_localhost, options.x11_max_displays,
2705
	    &s->display_number, &s->x11_chanids) == -1) {
2705
	    s->single_connection, &s->display_number, 
2706
	    &s->x11_chanids) == -1) {
2706
		debug("x11_create_display_inet failed.");
2707
		debug("x11_create_display_inet failed.");
2707
		return 0;
2708
		return 0;
2708
	}
2709
	}
(-)a/sshd_config.5 (-1 / +7 lines)
Lines 1128-1133 Available keywords are Link Here
1128
.Cm StreamLocalBindUnlink ,
1128
.Cm StreamLocalBindUnlink ,
1129
.Cm TrustedUserCAKeys ,
1129
.Cm TrustedUserCAKeys ,
1130
.Cm X11DisplayOffset ,
1130
.Cm X11DisplayOffset ,
1131
.Cm X11MaxDisplays ,
1131
.Cm X11Forwarding
1132
.Cm X11Forwarding
1132
and
1133
and
1133
.Cm X11UseLocalHost .
1134
.Cm X11UseLocalHost .
Lines 1621-1626 Specifies the first display number available for Link Here
1621
X11 forwarding.
1622
X11 forwarding.
1622
This prevents sshd from interfering with real X11 servers.
1623
This prevents sshd from interfering with real X11 servers.
1623
The default is 10.
1624
The default is 10.
1625
.It Cm X11MaxDisplays
1626
Specifies the maximum number of displays available for
1627
.Xr sshd 8 Ns 's
1628
X11 forwarding.
1629
This prevents sshd from exhausting local ports.
1630
The default is 1000.
1624
.It Cm X11Forwarding
1631
.It Cm X11Forwarding
1625
Specifies whether X11 forwarding is permitted.
1632
Specifies whether X11 forwarding is permitted.
1626
The argument must be
1633
The argument must be
1627
- 

Return to bug 2580