summaryrefslogtreecommitdiff
path: root/servconf.c
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 /servconf.c
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@
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c20
1 files changed, 18 insertions, 2 deletions
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;