=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/session.c,v retrieving revision 1.278 retrieving revision 1.279 diff -u -r1.278 -r1.279 --- src/usr.bin/ssh/session.c 2015/04/24 01:36:00 1.278 +++ src/usr.bin/ssh/session.c 2015/10/24 22:52:22 1.279 @@ -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 , Espoo, Finland * All rights reserved @@ -142,6 +142,7 @@ 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 @@ 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 @@ /* 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 @@ 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); }