summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/sshd.c b/sshd.c
index 93b02b6c8..3ad106f72 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.494 2017/10/25 00:15:35 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.495 2017/10/25 00:17:08 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1368,6 +1368,31 @@ check_ip_options(struct ssh *ssh)
1368#endif /* IP_OPTIONS */ 1368#endif /* IP_OPTIONS */
1369} 1369}
1370 1370
1371/* Set the routing domain for this process */
1372static void
1373set_process_rdomain(struct ssh *ssh, const char *name)
1374{
1375 int rtable, ortable = getrtable();
1376 const char *errstr;
1377
1378 if (name == NULL)
1379 return; /* default */
1380
1381 if (strcmp(name, "%D") == 0) {
1382 /* "expands" to routing domain of connection */
1383 if ((name = ssh_packet_rdomain_in(ssh)) == NULL)
1384 return;
1385 }
1386
1387 rtable = (int)strtonum(name, 0, 255, &errstr);
1388 if (errstr != NULL) /* Shouldn't happen */
1389 fatal("Invalid routing domain \"%s\": %s", name, errstr);
1390 if (rtable != ortable && setrtable(rtable) != 0)
1391 fatal("Unable to set routing domain %d: %s",
1392 rtable, strerror(errno));
1393 debug("%s: set routing domain %d (was %d)", __func__, rtable, ortable);
1394}
1395
1371/* 1396/*
1372 * Main program for the daemon. 1397 * Main program for the daemon.
1373 */ 1398 */
@@ -1983,6 +2008,9 @@ main(int ac, char **av)
1983 cleanup_exit(255); 2008 cleanup_exit(255);
1984 } 2009 }
1985 2010
2011 if (options.routing_domain != NULL)
2012 set_process_rdomain(ssh, options.routing_domain);
2013
1986 /* 2014 /*
1987 * The rest of the code depends on the fact that 2015 * The rest of the code depends on the fact that
1988 * ssh_remote_ipaddr() caches the remote ip, even if 2016 * ssh_remote_ipaddr() caches the remote ip, even if