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

Collapse All | Expand All

(-)a/misc.c (-1 / +17 lines)
Lines 168-174 set_reuseaddr(int fd) Link Here
168
	return 0;
168
	return 0;
169
}
169
}
170
170
171
/* Set routing table */
171
/* Get/set routing domain */
172
char *
173
get_rdomain(int fd)
174
{
175
	int rtable;
176
	char *ret;
177
	socklen_t len = sizeof(rtable);
178
179
	if (getsockopt(fd, SOL_SOCKET, SO_RTABLE, &rtable, &len) == -1) {
180
		error("Failed to get routing domain for fd %d: %s",
181
		    fd, strerror(errno));
182
		return NULL;
183
	}
184
	xasprintf(&ret, "%d", rtable);
185
	return ret;
186
}
187
172
int
188
int
173
set_rdomain(int fd, const char *name)
189
set_rdomain(int fd, const char *name)
174
{
190
{
(-)a/misc.h (+1 lines)
Lines 49-54 int set_nonblock(int); Link Here
49
int	 unset_nonblock(int);
49
int	 unset_nonblock(int);
50
void	 set_nodelay(int);
50
void	 set_nodelay(int);
51
int	 set_reuseaddr(int);
51
int	 set_reuseaddr(int);
52
char	*get_rdomain(int);
52
int	 set_rdomain(int, const char *);
53
int	 set_rdomain(int, const char *);
53
int	 a2port(const char *);
54
int	 a2port(const char *);
54
int	 a2tun(const char *, int *);
55
int	 a2tun(const char *, int *);
(-)a/packet.c (+12 lines)
Lines 546-551 ssh_local_port(struct ssh *ssh) Link Here
546
	return ssh->local_port;
546
	return ssh->local_port;
547
}
547
}
548
548
549
/* Returns the routing domain of the input socket, or NULL if unavailable */
550
const char *
551
ssh_packet_rdomain_in(struct ssh *ssh)
552
{
553
	if (ssh->rdomain_in != NULL)
554
		return ssh->rdomain_in;
555
	if (!ssh_packet_connection_is_on_socket(ssh))
556
		return NULL;
557
	ssh->rdomain_in = get_rdomain(ssh->state->connection_in);
558
	return ssh->rdomain_in;
559
}
560
549
/* Closes the connection and clears and frees internal data structures. */
561
/* Closes the connection and clears and frees internal data structures. */
550
562
551
static void
563
static void
(-)a/packet.h (+2 lines)
Lines 47-52 struct ssh { Link Here
47
	int remote_port;
47
	int remote_port;
48
	char *local_ipaddr;
48
	char *local_ipaddr;
49
	int local_port;
49
	int local_port;
50
	char *rdomain_in;
50
51
51
	/* Optional preamble for log messages (e.g. username) */
52
	/* Optional preamble for log messages (e.g. username) */
52
	char *log_preamble;
53
	char *log_preamble;
Lines 148-153 const char *ssh_remote_ipaddr(struct ssh *); Link Here
148
int	 ssh_remote_port(struct ssh *);
149
int	 ssh_remote_port(struct ssh *);
149
const char *ssh_local_ipaddr(struct ssh *);
150
const char *ssh_local_ipaddr(struct ssh *);
150
int	 ssh_local_port(struct ssh *);
151
int	 ssh_local_port(struct ssh *);
152
const char *ssh_packet_rdomain_in(struct ssh *);
151
153
152
void	 ssh_packet_set_rekey_limits(struct ssh *, u_int64_t, u_int32_t);
154
void	 ssh_packet_set_rekey_limits(struct ssh *, u_int64_t, u_int32_t);
153
time_t	 ssh_packet_get_rekey_timeout(struct ssh *);
155
time_t	 ssh_packet_get_rekey_timeout(struct ssh *);
(-)a/servconf.c (+13 lines)
Lines 805-810 get_connection_info(int populate, int use_dns) Link Here
805
	ci.address = ssh_remote_ipaddr(ssh);
805
	ci.address = ssh_remote_ipaddr(ssh);
806
	ci.laddress = ssh_local_ipaddr(ssh);
806
	ci.laddress = ssh_local_ipaddr(ssh);
807
	ci.lport = ssh_local_port(ssh);
807
	ci.lport = ssh_local_port(ssh);
808
	ci.rdomain = ssh_packet_rdomain_in(ssh);
808
	return &ci;
809
	return &ci;
809
}
810
}
810
811
Lines 988-993 match_cfg_line(char **condition, int line, struct connection_info *ci) Link Here
988
				    ci->laddress, port, line);
989
				    ci->laddress, port, line);
989
			else
990
			else
990
				result = 0;
991
				result = 0;
992
		} else if (strcasecmp(attrib, "rdomain") == 0) {
993
			if (ci == NULL || ci->rdomain == NULL) {
994
				result = 0;
995
				continue;
996
			}
997
			if (match_pattern_list(ci->rdomain, arg, 0) != 1)
998
				result = 0;
999
			else
1000
				debug("user %.100s matched 'RDomain %.100s' at "
1001
				    "line %d", ci->rdomain, arg, line);
991
		} else {
1002
		} else {
992
			error("Unsupported Match attribute %s", attrib);
1003
			error("Unsupported Match attribute %s", attrib);
993
			return -1;
1004
			return -1;
Lines 2024-2029 int parse_server_match_testspec(struct connection_info *ci, char *spec) Link Here
2024
			ci->user = xstrdup(p + 5);
2035
			ci->user = xstrdup(p + 5);
2025
		} else if (strncmp(p, "laddr=", 6) == 0) {
2036
		} else if (strncmp(p, "laddr=", 6) == 0) {
2026
			ci->laddress = xstrdup(p + 6);
2037
			ci->laddress = xstrdup(p + 6);
2038
		} else if (strncmp(p, "rdomain=", 8) == 0) {
2039
			ci->rdomain = xstrdup(p + 8);
2027
		} else if (strncmp(p, "lport=", 6) == 0) {
2040
		} else if (strncmp(p, "lport=", 6) == 0) {
2028
			ci->lport = a2port(p + 6);
2041
			ci->lport = a2port(p + 6);
2029
			if (ci->lport == -1) {
2042
			if (ci->lport == -1) {
(-)a/servconf.h (+1 lines)
Lines 216-221 struct connection_info { Link Here
216
	const char *address; 	/* remote address */
216
	const char *address; 	/* remote address */
217
	const char *laddress;	/* local address */
217
	const char *laddress;	/* local address */
218
	int lport;		/* local port */
218
	int lport;		/* local port */
219
	const char *rdomain;	/* routing domain if available */
219
};
220
};
220
221
221
222
(-)a/sshd.c (-4 / +7 lines)
Lines 1328-1334 main(int ac, char **av) Link Here
1328
	extern int optind;
1328
	extern int optind;
1329
	int r, opt, on = 1, already_daemon, remote_port;
1329
	int r, opt, on = 1, already_daemon, remote_port;
1330
	int sock_in = -1, sock_out = -1, newsock = -1;
1330
	int sock_in = -1, sock_out = -1, newsock = -1;
1331
	const char *remote_ip;
1331
	const char *remote_ip, *rdomain;
1332
	char *fp, *line, *laddr, *logfile = NULL;
1332
	char *fp, *line, *laddr, *logfile = NULL;
1333
	int config_s[2] = { -1 , -1 };
1333
	int config_s[2] = { -1 , -1 };
1334
	u_int i, j;
1334
	u_int i, j;
Lines 1866-1875 main(int ac, char **av) Link Here
1866
	 */
1866
	 */
1867
	remote_ip = ssh_remote_ipaddr(ssh);
1867
	remote_ip = ssh_remote_ipaddr(ssh);
1868
1868
1869
	rdomain = ssh_packet_rdomain_in(ssh);
1870
1869
	/* Log the connection. */
1871
	/* Log the connection. */
1870
	laddr = get_local_ipaddr(sock_in);
1872
	laddr = get_local_ipaddr(sock_in);
1871
	verbose("Connection from %s port %d on %s port %d",
1873
	verbose("Connection from %s port %d on %s port %d%s%s",
1872
	    remote_ip, remote_port, laddr,  ssh_local_port(ssh));
1874
	    remote_ip, remote_port, laddr,  ssh_local_port(ssh),
1875
	    rdomain == NULL ? "" : " rdomain ",
1876
	    rdomain == NULL ? "" : rdomain);
1873
	free(laddr);
1877
	free(laddr);
1874
1878
1875
	/*
1879
	/*
1876
- 

Return to bug 2784