diff options
author | Kevin Steves <stevesk@cvs.openbsd.org> | 2001-08-30 20:36:35 +0000 |
---|---|---|
committer | Kevin Steves <stevesk@cvs.openbsd.org> | 2001-08-30 20:36:35 +0000 |
commit | 20ddd96e73131f036a9826b9742214cad2c0b771 (patch) | |
tree | e304688b003ac856b516e48dd01081e583af88f1 | |
parent | 25e5b8a3153eff00a7f0548b7d73d7f1d21e51f3 (diff) |
validate ports for permitopen key file option. add host/port
alternative syntax for IPv6. ok markus@
-rw-r--r-- | usr.bin/ssh/auth-options.c | 32 | ||||
-rw-r--r-- | usr.bin/ssh/sshd.8 | 7 |
2 files changed, 20 insertions, 19 deletions
diff --git a/usr.bin/ssh/auth-options.c b/usr.bin/ssh/auth-options.c index 83ef02c4244..9f90437ca37 100644 --- a/usr.bin/ssh/auth-options.c +++ b/usr.bin/ssh/auth-options.c @@ -10,7 +10,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-options.c,v 1.19 2001/06/24 05:25:09 markus Exp $"); +RCSID("$OpenBSD: auth-options.c,v 1.20 2001/08/30 20:36:34 stevesk Exp $"); #include "packet.h" #include "xmalloc.h" @@ -20,6 +20,7 @@ RCSID("$OpenBSD: auth-options.c,v 1.19 2001/06/24 05:25:09 markus Exp $"); #include "channels.h" #include "auth-options.h" #include "servconf.h" +#include "misc.h" /* Flags set authorized_keys flags */ int no_port_forwarding_flag = 0; @@ -213,8 +214,8 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) } cp = "permitopen=\""; if (strncasecmp(opts, cp, strlen(cp)) == 0) { + char host[256], sport[6]; u_short port; - char *c, *ep; char *patterns = xmalloc(strlen(opts) + 1); opts += strlen(cp); @@ -239,28 +240,25 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) } patterns[i] = 0; opts++; - c = strchr(patterns, ':'); - if (c == NULL) { - debug("%.100s, line %lu: permitopen: missing colon <%.100s>", - file, linenum, patterns); - packet_send_debug("%.100s, line %lu: missing colon", - file, linenum); + if (sscanf(patterns, "%255[^:]:%5[0-9]", host, sport) != 2 && + sscanf(patterns, "%255[^/]/%5[0-9]", host, sport) != 2) { + debug("%.100s, line %lu: Bad permitopen specification " + "<%.100s>", file, linenum, patterns); + packet_send_debug("%.100s, line %lu: " + "Bad permitopen specification", file, linenum); xfree(patterns); goto bad_option; } - *c = 0; - c++; - port = strtol(c, &ep, 0); - if (c == ep) { - debug("%.100s, line %lu: permitopen: missing port <%.100s>", - file, linenum, patterns); - packet_send_debug("%.100s, line %lu: missing port", - file, linenum); + if ((port = a2port(sport)) == 0) { + debug("%.100s, line %lu: Bad permitopen port <%.100s>", + file, linenum, sport); + packet_send_debug("%.100s, line %lu: " + "Bad permitopen port", file, linenum); xfree(patterns); goto bad_option; } if (options.allow_tcp_forwarding) - channel_add_permitted_opens(patterns, port); + channel_add_permitted_opens(host, port); xfree(patterns); goto next_option; } diff --git a/usr.bin/ssh/sshd.8 b/usr.bin/ssh/sshd.8 index 478036d2b42..981d2c311a4 100644 --- a/usr.bin/ssh/sshd.8 +++ b/usr.bin/ssh/sshd.8 @@ -34,7 +34,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: sshd.8,v 1.145 2001/08/29 23:39:40 stevesk Exp $ +.\" $OpenBSD: sshd.8,v 1.146 2001/08/30 20:36:34 stevesk Exp $ .Dd September 25, 1999 .Dt SSHD 8 .Os @@ -1023,7 +1023,10 @@ Prevents tty allocation (a request to allocate a pty will fail). Limit local .Li ``ssh -L'' port forwarding such that it may only connect to the specified host and -port. Multiple +port. +IPv6 addresses can be specified with an alternative syntax: +.Ar host/port . +Multiple .Cm permitopen options may be applied separated by commas. No pattern matching is performed on the specified hostnames, they must be literal domains or |