Default $PATH of rsh (Was Re: What risk is X11Forward to a server?)

Brian Harvell harvell at aol.net
Fri Oct 26 15:38:26 EST 2001


On Thu, 25 Oct 2001, Bob Proulx wrote:

> On AIX, PATH and other variables are set in /etc/environment.  HPUX
> has /etc/PATH.  Solaris has /etc/default/login.  Hmm... Wish there was
> a consistent interface to this.  And on none of those systems do I
> know of an easy way to localize it for ssh since usually those are all
> read at interative shell startup by /etc/profile and not on
> non-interactive shell startup when ssh runs.
>

Reads /etc/default/login if detected during compile (ie Solaris)
Reads $sysconfdir/environment all the time if it's there.
Adding checks for other OS's is left as an exercise for the reader.

fyi if you want to use you will also need autoconf to rebuild configure. It's
also had limited testing since I just wrote it.

Brian

Brian Harvell                harvell at aol.net             http://ToolBoy.com/
echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc



--------------------------------cut-----------------------------------------
diff -uNr openssh-2.9.9p2.orig/acconfig.h openssh-2.9.9p2/acconfig.h
--- openssh-2.9.9p2.orig/acconfig.h	Thu Sep 20 15:43:41 2001
+++ openssh-2.9.9p2/acconfig.h	Fri Oct 26 01:19:03 2001
@@ -236,6 +236,9 @@
 /* to pam_strerror */
 #undef HAVE_OLD_PAM

+/* Define if you have /etc/default/login to set default environment */
+#undef HAVE_ETC_DEFAULT_LOGIN
+
 /* Define if you are using Solaris-derived PAM which passes pam_messages  */
 /* to the conversation function with an extra level of indirection */
 #undef PAM_SUN_CODEBASE
diff -uNr openssh-2.9.9p2.orig/config.h.in openssh-2.9.9p2/config.h.in
--- openssh-2.9.9p2.orig/config.h.in	Tue Sep 25 18:50:32 2001
+++ openssh-2.9.9p2/config.h.in	Fri Oct 26 01:19:03 2001
@@ -236,6 +236,9 @@
 /* to pam_strerror */
 #undef HAVE_OLD_PAM

+/* Define if you have /etc/default/login to set default environment */
+#undef HAVE_ETC_DEFAULT_LOGIN
+
 /* Define if you are using Solaris-derived PAM which passes pam_messages  */
 /* to the conversation function with an extra level of indirection */
 #undef PAM_SUN_CODEBASE
diff -uNr openssh-2.9.9p2.orig/configure.in openssh-2.9.9p2/configure.in
--- openssh-2.9.9p2.orig/configure.in	Tue Sep 25 18:39:38 2001
+++ openssh-2.9.9p2/configure.in	Fri Oct 26 01:19:03 2001
@@ -159,6 +159,13 @@
 	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
 	LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
 	need_dash_r=1
+	AC_MSG_CHECKING(for /etc/default/login)
+	if test -f /etc/default/login; then
+		AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
+		AC_MSG_RESULT(yes)
+	else
+		AC_MSG_RESULT(no)
+	fi
 	AC_DEFINE(PAM_SUN_CODEBASE)
 	AC_DEFINE(LOGIN_NEEDS_UTMPX)
 	AC_DEFINE(LOGIN_NEEDS_TERM)
diff -uNr openssh-2.9.9p2.orig/session.c openssh-2.9.9p2/session.c
--- openssh-2.9.9p2.orig/session.c	Sun Sep 16 18:17:15 2001
+++ openssh-2.9.9p2/session.c	Fri Oct 26 01:28:15 2001
@@ -1283,10 +1283,17 @@
 		child_set_env(&env, &envsize, "KRB5CCNAME",
 		    s->authctxt->krb5_ticket_file);
 #endif
+#ifdef HAVE_ETC_DEFAULT_LOGIN
+	/* Add system defaults to environment. */
+	read_environment_file(&env, &envsize, "/etc/default/login");
+#endif
 #ifdef USE_PAM
 	/* Pull in any environment variables that may have been set by PAM. */
 	do_pam_environment(&env, &envsize);
 #endif /* USE_PAM */
+	/* Add ssh specific environment */
+	snprintf(buf, sizeof buf, "%.200s/environment", ETCDIR);
+	read_environment_file(&env, &envsize, buf);

 	if (auth_get_socket_name() != NULL)
 		child_set_env(&env, &envsize, SSH_AUTHSOCKET_ENV_NAME,

--------------------------------cut-----------------------------------------




More information about the openssh-unix-dev mailing list