[auth-options.c sshd.8]
     validate ports for permitopen key file option. add host/port
     alternative syntax for IPv6. ok markus@
This commit is contained in:
Ben Lindstrom 2001-09-12 18:03:31 +00:00
parent 62c25a43db
commit d71ba5771b
3 changed files with 25 additions and 20 deletions

View File

@ -66,6 +66,10 @@
validate ports for LocalForward/RemoteForward. validate ports for LocalForward/RemoteForward.
add host/port alternative syntax for IPv6 (like -L/-R). add host/port alternative syntax for IPv6 (like -L/-R).
ok markus@ ok markus@
- stevesk@cvs.openbsd.org 2001/08/30 20:36:34
[auth-options.c sshd.8]
validate ports for permitopen key file option. add host/port
alternative syntax for IPv6. ok markus@
20010815 20010815
- (bal) Fixed stray code in readconf.c that went in by mistake. - (bal) Fixed stray code in readconf.c that went in by mistake.
@ -6389,4 +6393,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1504 2001/09/12 18:01:59 mouring Exp $ $Id: ChangeLog,v 1.1505 2001/09/12 18:03:31 mouring Exp $

View File

@ -10,7 +10,7 @@
*/ */
#include "includes.h" #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 "packet.h"
#include "xmalloc.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 "channels.h"
#include "auth-options.h" #include "auth-options.h"
#include "servconf.h" #include "servconf.h"
#include "misc.h"
/* Flags set authorized_keys flags */ /* Flags set authorized_keys flags */
int no_port_forwarding_flag = 0; 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=\""; cp = "permitopen=\"";
if (strncasecmp(opts, cp, strlen(cp)) == 0) { if (strncasecmp(opts, cp, strlen(cp)) == 0) {
char host[256], sport[6];
u_short port; u_short port;
char *c, *ep;
char *patterns = xmalloc(strlen(opts) + 1); char *patterns = xmalloc(strlen(opts) + 1);
opts += strlen(cp); opts += strlen(cp);
@ -239,28 +240,25 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum)
} }
patterns[i] = 0; patterns[i] = 0;
opts++; opts++;
c = strchr(patterns, ':'); if (sscanf(patterns, "%255[^:]:%5[0-9]", host, sport) != 2 &&
if (c == NULL) { sscanf(patterns, "%255[^/]/%5[0-9]", host, sport) != 2) {
debug("%.100s, line %lu: permitopen: missing colon <%.100s>", debug("%.100s, line %lu: Bad permitopen specification "
file, linenum, patterns); "<%.100s>", file, linenum, patterns);
packet_send_debug("%.100s, line %lu: missing colon", packet_send_debug("%.100s, line %lu: "
file, linenum); "Bad permitopen specification", file, linenum);
xfree(patterns); xfree(patterns);
goto bad_option; goto bad_option;
} }
*c = 0; if ((port = a2port(sport)) == 0) {
c++; debug("%.100s, line %lu: Bad permitopen port <%.100s>",
port = strtol(c, &ep, 0); file, linenum, sport);
if (c == ep) { packet_send_debug("%.100s, line %lu: "
debug("%.100s, line %lu: permitopen: missing port <%.100s>", "Bad permitopen port", file, linenum);
file, linenum, patterns);
packet_send_debug("%.100s, line %lu: missing port",
file, linenum);
xfree(patterns); xfree(patterns);
goto bad_option; goto bad_option;
} }
if (options.allow_tcp_forwarding) if (options.allow_tcp_forwarding)
channel_add_permitted_opens(patterns, port); channel_add_permitted_opens(host, port);
xfree(patterns); xfree(patterns);
goto next_option; goto next_option;
} }

7
sshd.8
View File

@ -34,7 +34,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" 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 .Dd September 25, 1999
.Dt SSHD 8 .Dt SSHD 8
.Os .Os
@ -1031,7 +1031,10 @@ Prevents tty allocation (a request to allocate a pty will fail).
Limit local Limit local
.Li ``ssh -L'' .Li ``ssh -L''
port forwarding such that it may only connect to the specified host and 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 .Cm permitopen
options may be applied separated by commas. No pattern matching is options may be applied separated by commas. No pattern matching is
performed on the specified hostnames, they must be literal domains or performed on the specified hostnames, they must be literal domains or