diff options
author | des <des@FreeBSD.org> | 2008-08-20 10:40:07 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2008-08-20 10:40:07 +0000 |
commit | f53f7dd853ea6f4eb085cdd805cf6687de1e62e6 (patch) | |
tree | 2812c593a02f4aed562281fc56e8dab42a58449a /crypto | |
parent | f01ca6138e1ee1c36dd13ef866a3ff7eb87e0c90 (diff) | |
download | FreeBSD-src-f53f7dd853ea6f4eb085cdd805cf6687de1e62e6.zip FreeBSD-src-f53f7dd853ea6f4eb085cdd805cf6687de1e62e6.tar.gz |
Use net.inet.ip.portrange.reservedhigh instead of IPPORT_RESERVED.
Submitted upstream, no reaction.
Submitted by: delphij@
MFC after: 2 weeks
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/openssh/readconf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crypto/openssh/readconf.c b/crypto/openssh/readconf.c index e87cc4d..0e271f7 100644 --- a/crypto/openssh/readconf.c +++ b/crypto/openssh/readconf.c @@ -18,6 +18,7 @@ __RCSID("$FreeBSD$"); #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> +#include <sys/sysctl.h> #include <netinet/in.h> @@ -245,7 +246,19 @@ add_local_forward(Options *options, const Forward *newfwd) Forward *fwd; #ifndef NO_IPPORT_RESERVED_CONCEPT extern uid_t original_real_uid; - if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0) + int ipport_reserved; +#ifdef __FreeBSD__ + size_t len_ipport_reserved = sizeof(ipport_reserved); + + if (sysctlbyname("net.inet.ip.portrange.reservedhigh", + &ipport_reserved, &len_ipport_reserved, NULL, 0) != 0) + ipport_reserved = IPPORT_RESERVED; + else + ipport_reserved++; +#else + ipport_reserved = IPPORT_RESERVED; +#endif + if (newfwd->listen_port < ipport_reserved && original_real_uid != 0) fatal("Privileged ports can only be forwarded by root."); #endif if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION) |