diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2008-06-14 18:33:44 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2008-06-14 18:33:44 +0000 |
commit | e96f082fe7aa596575191d8ca8fdf0d8a5d7ad78 (patch) | |
tree | e02a632795d62e43c5bd854f18b6c64df46408d1 | |
parent | 5e2a095c0304b38d840e91c70472fa062773b212 (diff) |
suppress the warning message from chdir(homedir) failures
when chrooted (bz#1461); ok dtucker
-rw-r--r-- | usr.bin/ssh/session.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c index 4f5c486e70d..8fb7e5124d5 100644 --- a/usr.bin/ssh/session.c +++ b/usr.bin/ssh/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.238 2008/05/09 16:16:06 markus Exp $ */ +/* $OpenBSD: session.c,v 1.239 2008/06/14 18:33:43 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved @@ -1276,6 +1276,7 @@ do_child(Session *s, const char *command) char *argv[ARGV_MAX]; const char *shell, *shell0, *hostname = NULL; struct passwd *pw = s->pw; + int r = 0; /* remove hostkey from the child's memory */ destroy_sensitive_data(); @@ -1362,9 +1363,13 @@ do_child(Session *s, const char *command) /* Change current directory to the user's home directory. */ if (chdir(pw->pw_dir) < 0) { - fprintf(stderr, "Could not chdir to home directory %s: %s\n", - pw->pw_dir, strerror(errno)); - if (login_getcapbool(lc, "requirehome", 0)) + /* Suppress missing homedir warning for chroot case */ + r = login_getcapbool(lc, "requirehome", 0); + if (r || options.chroot_directory == NULL) + fprintf(stderr, "Could not chdir to home " + "directory %s: %s\n", pw->pw_dir, + strerror(errno)); + if (r) exit(1); } |