summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-10-25 00:17:08 +0000
committerDamien Miller <djm@mindrot.org>2017-10-25 12:26:13 +1100
commit35eb33fb957979e3fcbe6ea0eaee8bf4a217421a (patch)
tree6ff628a3a477e2e2c7c4757a74b06ab29d3430a2 /sshd.c
parentacf559e1cffbd1d6167cc1742729fc381069f06b (diff)
upstream commit
add sshd_config RDomain keyword to place sshd and the subsequent user session (including the shell and any TCP/IP forwardings) into the specified rdomain(4) ok markus@ Upstream-ID: be2358e86346b5cacf20d90f59f980b87d1af0f5
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