From 6051c94a0a7766111ed16f2936b73098fa354661 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Mon, 16 Jun 2008 07:53:16 +1000 Subject: [PATCH] - djm@cvs.openbsd.org 2008/06/14 18:33:43 [session.c] suppress the warning message from chdir(homedir) failures when chrooted (bz#1461); ok dtucker --- ChangeLog | 6 +++++- session.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30e8d2c44..a4ed90296 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ - dtucker@cvs.openbsd.org 2008/06/14 17:07:11 [sshd.c] ensure default umask disallows at least group and world write; ok djm@ + - djm@cvs.openbsd.org 2008/06/14 18:33:43 + [session.c] + suppress the warning message from chdir(homedir) failures + when chrooted (bz#1461); ok dtucker 20080614 - (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction @@ -4379,4 +4383,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.5014 2008/06/15 21:50:58 djm Exp $ +$Id: ChangeLog,v 1.5015 2008/06/15 21:53:16 djm Exp $ diff --git a/session.c b/session.c index b4afed6fd..3ea783f63 100644 --- a/session.c +++ b/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 , Espoo, Finland * All rights reserved @@ -1647,6 +1647,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(); @@ -1762,12 +1763,16 @@ 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)); + /* Suppress missing homedir warning for chroot case */ #ifdef HAVE_LOGIN_CAP - if (login_getcapbool(lc, "requirehome", 0)) - exit(1); + r = login_getcapbool(lc, "requirehome", 0); #endif + 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); } closefrom(STDERR_FILENO + 1);