Subject: pkg/9279: sshd broken in -current after recent login.conf changes
To: None <gnats-bugs@gnats.netbsd.org>
From: Urban Boquist <boquist@crt.se>
List: netbsd-bugs
Date: 01/23/2000 06:48:43
>Number: 9279
>Category: pkg
>Synopsis: sshd fails to set some environment variables
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: pkg-manager (NetBSD software packages system bug manager)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jan 23 06:48:00 2000
>Last-Modified:
>Originator: Urban Boquist
>Organization:
Carlstedt Research & Technology AB, Sweden
>Release: NetBSD-current 2000-01-23
>Environment:
System: NetBSD iller 1.4Q NetBSD 1.4Q (ILLER) #0: Sun Jan 23 01:31:52 CET 2000 root@iller:/usr/src/sys/arch/i386/compile/ILLER i386
>Description:
When logging into an sshd build under current, some environment
variables will not be set in the login shell that sshd forks off (PATH
and MAIL).
>How-To-Repeat:
Build the ssh package in -current (after /usr/include/login_cap
appeared). Start "sshd -d", ssh into the machine, and watch it output
the environment it sets in the client:
Environment:
HOME=/home/boquist
USER=boquist
LOGNAME=boquist
SHELL=/bin/csh
SSH_CLIENT=172.16.1.238 1023 2222
SSH_TTY=/dev/ttyp2
TERM=xterm
DISPLAY=iller:3.0
At least two variables are missing:
PATH=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin:/usr/pkg/bin
MAIL=/var/mail/boquist
>Fix:
The problem is in sshd.c. It is ported to FreeBSD's login.conf system,
and contains a lot of:
#if defined (__FreeBSD__) && defined(HAVE_LOGIN_CAP_H)
These lines are ok, but there are also 3 lines with only:
#ifndef HAVE_LOGIN_CAP_H
This breaks in -current, since the ssh configure script finds the new
/usr/include/login_cap.h and sets the HAVE_LOGIN_CAP_H macro.
Short-term fix: fix the #ifndef test above to also test for
FreeBSD. The patch below does that.
Long term fix: someone who understands the NetBSD login.conf system
should make sshd.c use that (I have no idea how and if it differs from
the one used by FreeBSD, does it?).
Note: the patch below should be applied after the one in patch-af.
--- sshd.c.orig Sun Jan 23 13:43:10 2000
+++ sshd.c Sun Jan 23 14:06:14 2000
@@ -4133,7 +4133,7 @@
log_msg("executing remote command as user %.200s", pw->pw_name);
}
-#ifndef HAVE_LOGIN_CAP_H
+#if !(defined(__FreeBSD) && defined(HAVE_LOGIN_CAP_H))
#ifdef HAVE_SETLOGIN
/* Set login name in the kernel. Warning: setsid() must be called before
this. */
@@ -4400,7 +4400,7 @@
child_set_env(&env, &envsize, "USER", user_name);
child_set_env(&env, &envsize, "LOGNAME", user_name);
-#ifndef HAVE_LOGIN_CAP_H
+#if !(defined(__FreeBSD) && defined(HAVE_LOGIN_CAP_H))
child_set_env(&env, &envsize, "PATH", DEFAULT_PATH ":" SSH_BINDIR);
#ifdef MAIL_SPOOL_DIRECTORY
@@ -4429,7 +4429,7 @@
child_set_env(&env, &envsize, "SSH_ORIGINAL_COMMAND",
original_command);
-#ifndef HAVE_LOGIN_CAP_H
+#if !(defined(__FreeBSD) && defined(HAVE_LOGIN_CAP_H))
/* Let it inherit timezone if we have one. */
if (getenv("TZ"))
child_set_env(&env, &envsize, "TZ", getenv("TZ"));
>Audit-Trail:
>Unformatted: