diff options
-rw-r--r-- | usr.bin/ssh/session.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c index 26e6a1aa093..48b0bd91198 100644 --- a/usr.bin/ssh/session.c +++ b/usr.bin/ssh/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.278 2015/04/24 01:36:00 deraadt Exp $ */ +/* $OpenBSD: session.c,v 1.279 2015/10/24 22:52:22 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved @@ -142,6 +142,7 @@ static Session *sessions = NULL; login_cap_t *lc; static int is_child = 0; +static int in_chroot = 0; /* Name and directory of socket for authentication agent forwarding. */ static char *auth_sock_name = NULL; @@ -1212,7 +1213,7 @@ do_setusercontext(struct passwd *pw) exit(1); } - if (options.chroot_directory != NULL && + if (!in_chroot && options.chroot_directory != NULL && strcasecmp(options.chroot_directory, "none") != 0) { tmp = tilde_expand_filename(options.chroot_directory, pw->pw_uid); @@ -1224,6 +1225,7 @@ do_setusercontext(struct passwd *pw) /* Make sure we don't attempt to chroot again */ free(options.chroot_directory); options.chroot_directory = NULL; + in_chroot = 1; } /* Set UID */ @@ -1412,11 +1414,11 @@ do_child(Session *s, const char *command) if (chdir(pw->pw_dir) < 0) { /* Suppress missing homedir warning for chroot case */ r = login_getcapbool(lc, "requirehome", 0); - if (r || options.chroot_directory == NULL || - strcasecmp(options.chroot_directory, "none") == 0) + if (r || !in_chroot) { fprintf(stderr, "Could not chdir to home " "directory %s: %s\n", pw->pw_dir, strerror(errno)); + } if (r) exit(1); } |