]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2010/01/13 03:48:13
authordtucker <dtucker>
Wed, 13 Jan 2010 11:44:29 +0000 (11:44 +0000)
committerdtucker <dtucker>
Wed, 13 Jan 2010 11:44:29 +0000 (11:44 +0000)
     [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@

ChangeLog
servconf.c
servconf.h
sshd.c

index d4210354e5f41ef9e6501f13d6ee5be2e5d50495..1b86fe47eab42b1c8a474699447dc6ad2ff5b087 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [sftp.c sftp-server.c sftp.1 sftp-common.c sftp-common.h]
      support '-h' (human-readable units) for sftp's ls command, just like
      ls(1); ok dtucker@
+   - 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@
 
 20100112
  - (dtucker) OpenBSD CVS Sync
index b1964e865a1938ea139e632db2d730b5953a651c..09296c9cfa3a0a4456833374ceeb33b0d58f2aaf 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.c,v 1.201 2010/01/10 03:51:17 dtucker Exp $ */
+/* $OpenBSD: servconf.c,v 1.202 2010/01/13 03:48:12 djm Exp $ */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved
@@ -459,6 +459,22 @@ parse_token(const char *cp, const char *filename,
        return sBadOption;
 }
 
+char *
+derelativise_path(const char *path)
+{
+       char *expanded, *ret, *cwd;
+
+       expanded = tilde_expand_filename(path, getuid());
+       if (*expanded == '/')
+               return expanded;
+       if ((cwd = getcwd(NULL, 0)) == NULL)
+               fatal("%s: getcwd: %s", __func__, strerror(errno));
+       xasprintf(&ret, "%s/%s", cwd, expanded);
+       xfree(cwd);
+       xfree(expanded);
+       return ret;
+}
+
 static void
 add_listen_addr(ServerOptions *options, char *addr, int port)
 {
@@ -793,7 +809,7 @@ process_server_config_line(ServerOptions *options, char *line,
                        fatal("%s line %d: missing file name.",
                            filename, linenum);
                if (*activep && *charptr == NULL) {
-                       *charptr = tilde_expand_filename(arg, getuid());
+                       *charptr = derelativise_path(arg);
                        /* increase optional counter */
                        if (intptr != NULL)
                                *intptr = *intptr + 1;
index 25a3f1b215aee04477e9214a63f426b07ab66468..c9b8619cd13dc09161603dd81731f5b355f0cbb3 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.h,v 1.89 2010/01/09 23:04:13 dtucker Exp $ */
+/* $OpenBSD: servconf.h,v 1.90 2010/01/13 03:48:13 djm Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -164,5 +164,6 @@ void         parse_server_match_config(ServerOptions *, const char *, const char *,
             const char *);
 void    copy_set_server_options(ServerOptions *, ServerOptions *, int);
 void    dump_config(ServerOptions *);
+char   *derelativise_path(const char *);
 
 #endif                         /* SERVCONF_H */
diff --git a/sshd.c b/sshd.c
index 4e34f2439c727f11903495356967dc29f65ba862..d84db897c2831cd8def0d67e8f2de49aeafc00c3 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshd.c,v 1.370 2010/01/09 23:04:13 dtucker Exp $ */
+/* $OpenBSD: sshd.c,v 1.371 2010/01/13 03:48:13 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1351,7 +1351,8 @@ main(int ac, char **av)
                                fprintf(stderr, "too many host keys.\n");
                                exit(1);
                        }
-                       options.host_key_files[options.num_host_key_files++] = optarg;
+                       options.host_key_files[options.num_host_key_files++] = 
+                          derelativise_path(optarg);
                        break;
                case 't':
                        test_flag = 1;
This page took 0.054847 seconds and 5 git commands to generate.