diff options
author | Darren Tucker <dtucker@zip.com.au> | 2010-01-13 22:44:29 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2010-01-13 22:44:29 +1100 |
commit | 88b6fb2b55a5c8bb9aeadec185991c5bfae780c0 (patch) | |
tree | 85356ec63439554a143a9e2116f8af61d0e216d5 | |
parent | 2901e2daebe3a0890209f31d05d5bb9338cbed5b (diff) |
- djm@cvs.openbsd.org 2010/01/13 03:48:13
[servconf.c servconf.h sshd.c]
avoid run-time failures when specifying hostkeys via a relative
path by prepending the cwd in these cases; bz#1290; ok dtucker@
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | servconf.c | 20 | ||||
-rw-r--r-- | servconf.h | 3 | ||||
-rw-r--r-- | sshd.c | 5 |
4 files changed, 27 insertions, 5 deletions
@@ -22,6 +22,10 @@ | |||
22 | [sftp.c sftp-server.c sftp.1 sftp-common.c sftp-common.h] | 22 | [sftp.c sftp-server.c sftp.1 sftp-common.c sftp-common.h] |
23 | support '-h' (human-readable units) for sftp's ls command, just like | 23 | support '-h' (human-readable units) for sftp's ls command, just like |
24 | ls(1); ok dtucker@ | 24 | ls(1); ok dtucker@ |
25 | - djm@cvs.openbsd.org 2010/01/13 03:48:13 | ||
26 | [servconf.c servconf.h sshd.c] | ||
27 | avoid run-time failures when specifying hostkeys via a relative | ||
28 | path by prepending the cwd in these cases; bz#1290; ok dtucker@ | ||
25 | 29 | ||
26 | 20100112 | 30 | 20100112 |
27 | - (dtucker) OpenBSD CVS Sync | 31 | - (dtucker) OpenBSD CVS Sync |
diff --git a/servconf.c b/servconf.c index b1964e865..09296c9cf 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.c,v 1.201 2010/01/10 03:51:17 dtucker Exp $ */ | 1 | /* $OpenBSD: servconf.c,v 1.202 2010/01/13 03:48:12 djm 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 |
@@ -459,6 +459,22 @@ parse_token(const char *cp, const char *filename, | |||
459 | return sBadOption; | 459 | return sBadOption; |
460 | } | 460 | } |
461 | 461 | ||
462 | char * | ||
463 | derelativise_path(const char *path) | ||
464 | { | ||
465 | char *expanded, *ret, *cwd; | ||
466 | |||
467 | expanded = tilde_expand_filename(path, getuid()); | ||
468 | if (*expanded == '/') | ||
469 | return expanded; | ||
470 | if ((cwd = getcwd(NULL, 0)) == NULL) | ||
471 | fatal("%s: getcwd: %s", __func__, strerror(errno)); | ||
472 | xasprintf(&ret, "%s/%s", cwd, expanded); | ||
473 | xfree(cwd); | ||
474 | xfree(expanded); | ||
475 | return ret; | ||
476 | } | ||
477 | |||
462 | static void | 478 | static void |
463 | add_listen_addr(ServerOptions *options, char *addr, int port) | 479 | add_listen_addr(ServerOptions *options, char *addr, int port) |
464 | { | 480 | { |
@@ -793,7 +809,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
793 | fatal("%s line %d: missing file name.", | 809 | fatal("%s line %d: missing file name.", |
794 | filename, linenum); | 810 | filename, linenum); |
795 | if (*activep && *charptr == NULL) { | 811 | if (*activep && *charptr == NULL) { |
796 | *charptr = tilde_expand_filename(arg, getuid()); | 812 | *charptr = derelativise_path(arg); |
797 | /* increase optional counter */ | 813 | /* increase optional counter */ |
798 | if (intptr != NULL) | 814 | if (intptr != NULL) |
799 | *intptr = *intptr + 1; | 815 | *intptr = *intptr + 1; |
diff --git a/servconf.h b/servconf.h index 25a3f1b21..c9b8619cd 100644 --- a/servconf.h +++ b/servconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.h,v 1.89 2010/01/09 23:04:13 dtucker Exp $ */ | 1 | /* $OpenBSD: servconf.h,v 1.90 2010/01/13 03:48:13 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -164,5 +164,6 @@ void parse_server_match_config(ServerOptions *, const char *, const char *, | |||
164 | const char *); | 164 | const char *); |
165 | void copy_set_server_options(ServerOptions *, ServerOptions *, int); | 165 | void copy_set_server_options(ServerOptions *, ServerOptions *, int); |
166 | void dump_config(ServerOptions *); | 166 | void dump_config(ServerOptions *); |
167 | char *derelativise_path(const char *); | ||
167 | 168 | ||
168 | #endif /* SERVCONF_H */ | 169 | #endif /* SERVCONF_H */ |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshd.c,v 1.370 2010/01/09 23:04:13 dtucker Exp $ */ | 1 | /* $OpenBSD: sshd.c,v 1.371 2010/01/13 03:48:13 djm 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 |
@@ -1351,7 +1351,8 @@ main(int ac, char **av) | |||
1351 | fprintf(stderr, "too many host keys.\n"); | 1351 | fprintf(stderr, "too many host keys.\n"); |
1352 | exit(1); | 1352 | exit(1); |
1353 | } | 1353 | } |
1354 | options.host_key_files[options.num_host_key_files++] = optarg; | 1354 | options.host_key_files[options.num_host_key_files++] = |
1355 | derelativise_path(optarg); | ||
1355 | break; | 1356 | break; |
1356 | case 't': | 1357 | case 't': |
1357 | test_flag = 1; | 1358 | test_flag = 1; |