diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | auth-options.c | 4 | ||||
-rw-r--r-- | channels.c | 33 | ||||
-rw-r--r-- | channels.h | 3 | ||||
-rw-r--r-- | servconf.c | 4 | ||||
-rw-r--r-- | sshd.8 | 7 |
6 files changed, 45 insertions, 11 deletions
@@ -1,5 +1,10 @@ | |||
1 | 2011101 | 1 | 2011101 |
2 | - (dtucker) [openbsd-compat/mktemp.c] Fix compiler warning. ok djm | 2 | - (dtucker) [openbsd-compat/mktemp.c] Fix compiler warning. ok djm |
3 | - (dtucker) OpenBSD CVS Sync | ||
4 | - dtucker@cvs.openbsd.org 2011/09/23 00:22:04 | ||
5 | [channels.c auth-options.c servconf.c channels.h sshd.8] | ||
6 | Add wildcard support to PermitOpen, allowing things like "PermitOpen | ||
7 | localhost:*". bz #1857, ok djm markus. | ||
3 | 8 | ||
4 | 20110929 | 9 | 20110929 |
5 | - (djm) [configure.ac defines.h] No need to detect sizeof(char); patch | 10 | - (djm) [configure.ac defines.h] No need to detect sizeof(char); patch |
diff --git a/auth-options.c b/auth-options.c index eae45cf2b..b3c19c1c0 100644 --- a/auth-options.c +++ b/auth-options.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth-options.c,v 1.54 2010/12/24 21:41:48 djm Exp $ */ | 1 | /* $OpenBSD: auth-options.c,v 1.55 2011/09/23 00:22:04 dtucker 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 |
@@ -341,7 +341,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) | |||
341 | goto bad_option; | 341 | goto bad_option; |
342 | } | 342 | } |
343 | host = cleanhostname(host); | 343 | host = cleanhostname(host); |
344 | if (p == NULL || (port = a2port(p)) <= 0) { | 344 | if (p == NULL || (port = permitopen_port(p)) < 0) { |
345 | debug("%.100s, line %lu: Bad permitopen port " | 345 | debug("%.100s, line %lu: Bad permitopen port " |
346 | "<%.100s>", file, linenum, p ? p : ""); | 346 | "<%.100s>", file, linenum, p ? p : ""); |
347 | auth_debug_add("%.100s, line %lu: " | 347 | auth_debug_add("%.100s, line %lu: " |
diff --git a/channels.c b/channels.c index b6663de8f..00e9af84a 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.313 2011/09/10 22:26:34 markus Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.314 2011/09/23 00:22:04 dtucker 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 |
@@ -125,6 +125,9 @@ static int num_permitted_opens = 0; | |||
125 | /* Number of permitted host/port pair in the array permitted by the admin. */ | 125 | /* Number of permitted host/port pair in the array permitted by the admin. */ |
126 | static int num_adm_permitted_opens = 0; | 126 | static int num_adm_permitted_opens = 0; |
127 | 127 | ||
128 | /* special-case port number meaning allow any port */ | ||
129 | #define FWD_PERMIT_ANY_PORT 0 | ||
130 | |||
128 | /* | 131 | /* |
129 | * If this is true, all opens are permitted. This is the case on the server | 132 | * If this is true, all opens are permitted. This is the case on the server |
130 | * on which we have to trust the client anyway, and the user could do | 133 | * on which we have to trust the client anyway, and the user could do |
@@ -3135,6 +3138,28 @@ channel_print_adm_permitted_opens(void) | |||
3135 | printf("\n"); | 3138 | printf("\n"); |
3136 | } | 3139 | } |
3137 | 3140 | ||
3141 | /* returns port number, FWD_PERMIT_ANY_PORT or -1 on error */ | ||
3142 | int | ||
3143 | permitopen_port(const char *p) | ||
3144 | { | ||
3145 | int port; | ||
3146 | |||
3147 | if (strcmp(p, "*") == 0) | ||
3148 | return FWD_PERMIT_ANY_PORT; | ||
3149 | if ((port = a2port(p)) > 0) | ||
3150 | return port; | ||
3151 | return -1; | ||
3152 | } | ||
3153 | |||
3154 | static int | ||
3155 | port_match(u_short allowedport, u_short requestedport) | ||
3156 | { | ||
3157 | if (allowedport == FWD_PERMIT_ANY_PORT || | ||
3158 | allowedport == requestedport) | ||
3159 | return 1; | ||
3160 | return 0; | ||
3161 | } | ||
3162 | |||
3138 | /* Try to start non-blocking connect to next host in cctx list */ | 3163 | /* Try to start non-blocking connect to next host in cctx list */ |
3139 | static int | 3164 | static int |
3140 | connect_next(struct channel_connect *cctx) | 3165 | connect_next(struct channel_connect *cctx) |
@@ -3237,7 +3262,7 @@ channel_connect_by_listen_address(u_short listen_port, char *ctype, char *rname) | |||
3237 | 3262 | ||
3238 | for (i = 0; i < num_permitted_opens; i++) { | 3263 | for (i = 0; i < num_permitted_opens; i++) { |
3239 | if (permitted_opens[i].host_to_connect != NULL && | 3264 | if (permitted_opens[i].host_to_connect != NULL && |
3240 | permitted_opens[i].listen_port == listen_port) { | 3265 | port_match(permitted_opens[i].listen_port, listen_port)) { |
3241 | return connect_to( | 3266 | return connect_to( |
3242 | permitted_opens[i].host_to_connect, | 3267 | permitted_opens[i].host_to_connect, |
3243 | permitted_opens[i].port_to_connect, ctype, rname); | 3268 | permitted_opens[i].port_to_connect, ctype, rname); |
@@ -3258,7 +3283,7 @@ channel_connect_to(const char *host, u_short port, char *ctype, char *rname) | |||
3258 | if (!permit) { | 3283 | if (!permit) { |
3259 | for (i = 0; i < num_permitted_opens; i++) | 3284 | for (i = 0; i < num_permitted_opens; i++) |
3260 | if (permitted_opens[i].host_to_connect != NULL && | 3285 | if (permitted_opens[i].host_to_connect != NULL && |
3261 | permitted_opens[i].port_to_connect == port && | 3286 | port_match(permitted_opens[i].port_to_connect, port) && |
3262 | strcmp(permitted_opens[i].host_to_connect, host) == 0) | 3287 | strcmp(permitted_opens[i].host_to_connect, host) == 0) |
3263 | permit = 1; | 3288 | permit = 1; |
3264 | } | 3289 | } |
@@ -3267,7 +3292,7 @@ channel_connect_to(const char *host, u_short port, char *ctype, char *rname) | |||
3267 | permit_adm = 0; | 3292 | permit_adm = 0; |
3268 | for (i = 0; i < num_adm_permitted_opens; i++) | 3293 | for (i = 0; i < num_adm_permitted_opens; i++) |
3269 | if (permitted_adm_opens[i].host_to_connect != NULL && | 3294 | if (permitted_adm_opens[i].host_to_connect != NULL && |
3270 | permitted_adm_opens[i].port_to_connect == port && | 3295 | port_match(permitted_adm_opens[i].port_to_connect, port) && |
3271 | strcmp(permitted_adm_opens[i].host_to_connect, host) | 3296 | strcmp(permitted_adm_opens[i].host_to_connect, host) |
3272 | == 0) | 3297 | == 0) |
3273 | permit_adm = 1; | 3298 | permit_adm = 1; |
diff --git a/channels.h b/channels.h index ff84ea54f..6f316c824 100644 --- a/channels.h +++ b/channels.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.h,v 1.107 2011/09/10 22:26:34 markus Exp $ */ | 1 | /* $OpenBSD: channels.h,v 1.108 2011/09/23 00:22:04 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -268,6 +268,7 @@ int channel_request_rforward_cancel(const char *host, u_short port); | |||
268 | int channel_setup_remote_fwd_listener(const char *, u_short, int *, int); | 268 | int channel_setup_remote_fwd_listener(const char *, u_short, int *, int); |
269 | int channel_cancel_rport_listener(const char *, u_short); | 269 | int channel_cancel_rport_listener(const char *, u_short); |
270 | int channel_cancel_lport_listener(const char *, u_short, int, int); | 270 | int channel_cancel_lport_listener(const char *, u_short, int, int); |
271 | int permitopen_port(const char *); | ||
271 | 272 | ||
272 | /* x11 forwarding */ | 273 | /* x11 forwarding */ |
273 | 274 | ||
diff --git a/servconf.c b/servconf.c index 91986e55d..8ec5ca0e6 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.c,v 1.222 2011/06/22 21:57:01 djm Exp $ */ | 1 | /* $OpenBSD: servconf.c,v 1.223 2011/09/23 00:22:04 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | 4 | * All rights reserved |
@@ -1341,7 +1341,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1341 | fatal("%s line %d: missing host in PermitOpen", | 1341 | fatal("%s line %d: missing host in PermitOpen", |
1342 | filename, linenum); | 1342 | filename, linenum); |
1343 | p = cleanhostname(p); | 1343 | p = cleanhostname(p); |
1344 | if (arg == NULL || (port = a2port(arg)) <= 0) | 1344 | if (arg == NULL || ((port = permitopen_port(arg)) < 0)) |
1345 | fatal("%s line %d: bad port number in " | 1345 | fatal("%s line %d: bad port number in " |
1346 | "PermitOpen", filename, linenum); | 1346 | "PermitOpen", filename, linenum); |
1347 | if (*activep && n == -1) | 1347 | if (*activep && n == -1) |
@@ -33,8 +33,8 @@ | |||
33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | .\" | 35 | .\" |
36 | .\" $OpenBSD: sshd.8,v 1.263 2011/08/02 01:22:11 djm Exp $ | 36 | .\" $OpenBSD: sshd.8,v 1.264 2011/09/23 00:22:04 dtucker Exp $ |
37 | .Dd $Mdocdate: August 2 2011 $ | 37 | .Dd $Mdocdate: September 23 2011 $ |
38 | .Dt SSHD 8 | 38 | .Dt SSHD 8 |
39 | .Os | 39 | .Os |
40 | .Sh NAME | 40 | .Sh NAME |
@@ -608,6 +608,9 @@ Multiple | |||
608 | options may be applied separated by commas. | 608 | options may be applied separated by commas. |
609 | No pattern matching is performed on the specified hostnames, | 609 | No pattern matching is performed on the specified hostnames, |
610 | they must be literal domains or addresses. | 610 | they must be literal domains or addresses. |
611 | A port specification of | ||
612 | .Cm * | ||
613 | matches any port. | ||
611 | .It Cm principals="principals" | 614 | .It Cm principals="principals" |
612 | On a | 615 | On a |
613 | .Cm cert-authority | 616 | .Cm cert-authority |