summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-01-13 22:44:29 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-01-13 22:44:29 +1100
commit88b6fb2b55a5c8bb9aeadec185991c5bfae780c0 (patch)
tree85356ec63439554a143a9e2116f8af61d0e216d5
parent2901e2daebe3a0890209f31d05d5bb9338cbed5b (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--ChangeLog4
-rw-r--r--servconf.c20
-rw-r--r--servconf.h3
-rw-r--r--sshd.c5
4 files changed, 27 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index d4210354e..1b86fe47e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
2620100112 3020100112
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
462char *
463derelativise_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
462static void 478static void
463add_listen_addr(ServerOptions *options, char *addr, int port) 479add_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 *);
165void copy_set_server_options(ServerOptions *, ServerOptions *, int); 165void copy_set_server_options(ServerOptions *, ServerOptions *, int);
166void dump_config(ServerOptions *); 166void dump_config(ServerOptions *);
167char *derelativise_path(const char *);
167 168
168#endif /* SERVCONF_H */ 169#endif /* SERVCONF_H */
diff --git a/sshd.c b/sshd.c
index 4e34f2439..d84db897c 100644
--- a/sshd.c
+++ b/sshd.c
@@ -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;