[openssh-commits] [openssh] 08/09: provide hooks and fallbacks for rdomain support
git+noreply at mindrot.org
git+noreply at mindrot.org
Wed Oct 25 13:12:45 AEDT 2017
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 43c29bb7cfd46bbbc61e0ffa61a11e74d49a712f
Author: Damien Miller <djm at mindrot.org>
Date: Wed Oct 25 13:10:59 2017 +1100
provide hooks and fallbacks for rdomain support
---
misc.c | 13 +++++++++++++
servconf.c | 7 +++++++
sshd.c | 15 +++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/misc.c b/misc.c
index 9b1ea4fa..2369361b 100644
--- a/misc.c
+++ b/misc.c
@@ -184,6 +184,9 @@ set_reuseaddr(int fd)
char *
get_rdomain(int fd)
{
+#if defined(HAVE_SYS_GET_RDOMAIN)
+ return sys_get_rdomain(fd);
+#elif defined(__OpenBSD__)
int rtable;
char *ret;
socklen_t len = sizeof(rtable);
@@ -195,11 +198,17 @@ get_rdomain(int fd)
}
xasprintf(&ret, "%d", rtable);
return ret;
+#else /* defined(__OpenBSD__) */
+ return NULL;
+#endif
}
int
set_rdomain(int fd, const char *name)
{
+#if defined(HAVE_SYS_SET_RDOMAIN)
+ return sys_set_rdomain(fd, name);
+#elif defined(__OpenBSD__)
int rtable;
const char *errstr;
@@ -219,6 +228,10 @@ set_rdomain(int fd, const char *name)
return -1;
}
return 0;
+#else /* defined(__OpenBSD__) */
+ error("Setting routing domain is not supported on this platform");
+ return -1;
+#endif
}
/* Characters considered whitespace in strsep calls. */
diff --git a/servconf.c b/servconf.c
index 64a86518..288ec088 100644
--- a/servconf.c
+++ b/servconf.c
@@ -735,6 +735,9 @@ add_one_listen_addr(ServerOptions *options, const char *addr,
static int
valid_rdomain(const char *name)
{
+#if defined(HAVE_SYS_VALID_RDOMAIN)
+ return valid_rdomain(name)
+#elif defined(__OpenBSD__)
const char *errstr;
long long num;
struct rt_tableinfo info;
@@ -758,6 +761,10 @@ valid_rdomain(const char *name)
return 0;
return 1;
+#else /* defined(__OpenBSD__) */
+ error("Routing domains are not supported on this platform");
+ return 0;
+#endif
}
/*
diff --git a/sshd.c b/sshd.c
index 1220309d..535cb97f 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1372,6 +1372,18 @@ check_ip_options(struct ssh *ssh)
static void
set_process_rdomain(struct ssh *ssh, const char *name)
{
+#if defined(HAVE_SYS_SET_PROCESS_RDOMAIN)
+ if (name == NULL)
+ return; /* default */
+
+ if (strcmp(name, "%D") == 0) {
+ /* "expands" to routing domain of connection */
+ if ((name = ssh_packet_rdomain_in(ssh)) == NULL)
+ return;
+ }
+ /* NB. We don't pass 'ssh' to sys_set_process_rdomain() */
+ return sys_set_process_rdomain(name);
+#elif defined(__OpenBSD__)
int rtable, ortable = getrtable();
const char *errstr;
@@ -1391,6 +1403,9 @@ set_process_rdomain(struct ssh *ssh, const char *name)
fatal("Unable to set routing domain %d: %s",
rtable, strerror(errno));
debug("%s: set routing domain %d (was %d)", __func__, rtable, ortable);
+#else /* defined(__OpenBSD__) */
+ fatal("Unable to set routing domain: not supported in this platform");
+#endif
}
/*
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list