View | Details | Raw Unified | Return to bug 252 | Differences between
and this patch

Collapse All | Expand All

(-)openssh-3.2.2p1.orig/acconfig.h (+3 lines)
Lines 322-327 Link Here
322
/* Define in your struct dirent expects you to allocate extra space for d_name */
322
/* Define in your struct dirent expects you to allocate extra space for d_name */
323
#undef BROKEN_ONE_BYTE_DIRENT_D_NAME
323
#undef BROKEN_ONE_BYTE_DIRENT_D_NAME
324
324
325
/* Define if your system has /etc/default/login */
326
#undef HAVE_ETC_DEFAULT_LOGIN
327
325
/* Define if your getopt(3) defines and uses optreset */
328
/* Define if your getopt(3) defines and uses optreset */
326
#undef HAVE_GETOPT_OPTRESET
329
#undef HAVE_GETOPT_OPTRESET
327
330
(-)openssh-3.2.2p1.orig/configure.ac (+9 lines)
Lines 2361-2366 Link Here
2361
fi
2361
fi
2362
2362
2363
AC_EXEEXT
2363
AC_EXEEXT
2364
# check for /etc/default/login. On some systems (i.e. Solaris 2.x, ReliantUNIX)
2365
# this file defines some environment variables to be set at login time
2366
AC_CHECK_FILE("/etc/default/login",
2367
	[
2368
		AC_DEFINE_UNQUOTED(HAVE_ETC_DEFAULT_LOGIN)
2369
		have_etc_default_login=1
2370
	]
2371
)
2372
2364
AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2373
AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2365
AC_OUTPUT
2374
AC_OUTPUT
2366
2375
(-)openssh-3.2.2p1.orig/session.c (-6 / +86 lines)
Lines 771-776 Link Here
771
}
771
}
772
772
773
/*
773
/*
774
 * Returns the value of the given variable from the environment.
775
 * Returns NULL, if the variable is not found.
776
 */
777
static char *
778
child_get_env(char **envp, const char *name)
779
{
780
	u_int i, namelen;
781
782
	namelen = strlen(name);
783
	for (i = 0; envp[i]; i++) {
784
		if (strncmp(envp[i], name, namelen) == 0 &&
785
		    envp[i][namelen] == '=')
786
			break;
787
	}
788
	if(envp[i])
789
		return &envp[i][namelen + 1];
790
	
791
	return NULL;
792
}
793
794
/*
774
 * Reads environment variables from the given file and adds/overrides them
795
 * Reads environment variables from the given file and adds/overrides them
775
 * into the environment.  If the file does not exist, this does nothing.
796
 * into the environment.  If the file does not exist, this does nothing.
776
 * Otherwise, it must consist of empty lines, comments (line starts with '#')
797
 * Otherwise, it must consist of empty lines, comments (line starts with '#')
Lines 811-816 Link Here
811
	fclose(f);
832
	fclose(f);
812
}
833
}
813
834
835
#ifdef HAVE_ETC_DEFAULT_LOGIN
836
/*
837
 * Read /etc/default/login
838
 * This file is found and processed by login(1) at least on Solaris
839
 * and ReliantUNIX.
840
 *
841
 * Get PATH environment variable from:
842
 *	PATH (for mere mortals)
843
 *	SUPATH (for root)
844
 * Get umask setting from UMASK
845
 *
846
 * XXX  There are other reasonable things to process in this file:
847
 *	i.e. ALTSHELL, CONSOLE, DISABLE_RHOSTS, HZ, IDLEWEEKS, ULIMIT
848
 *
849
 */
850
static void
851
read_etc_default_login(char ***env, u_int *envsize, uid_t uid)
852
{
853
	char **edf_env, *edf;
854
	u_int i, edf_envsize;
855
	mode_t mask;
856
857
	/*
858
	 * We don't want to copy the whole file to the childs environment,
859
	 * so we use our own temporary environment here.
860
	 */
861
	edf_envsize = 10;
862
	edf_env = xmalloc(edf_envsize * sizeof(char *));
863
	edf_env[0] = NULL;
864
865
	read_environment_file(&edf_env, &edf_envsize, "/etc/default/login");
866
867
	if(uid)
868
		edf = child_get_env(edf_env, "PATH");
869
	else
870
		edf = child_get_env(edf_env, "SUPATH");
871
	if(edf != NULL)
872
		child_set_env(env, envsize, "PATH", edf);
873
	
874
	if((edf = child_get_env(edf_env, "UMASK")) != NULL)
875
		if (sscanf(edf, "%o", &mask) == 1)
876
			umask(mask);
877
	
878
	for(i = 0; edf_env[i]; i++)
879
		xfree(edf_env[i]);
880
	xfree(edf_env);
881
}
882
#endif /* HAVE_ETC_DEFAULT_LOGIN */
883
814
void copy_environment(char **source, char ***env, u_int *envsize)
884
void copy_environment(char **source, char ***env, u_int *envsize)
815
{
885
{
816
	char *var_name, *var_val;
886
	char *var_name, *var_val;
Lines 871-885 Link Here
871
		 * needed for loading shared libraries. So the path better
941
		 * needed for loading shared libraries. So the path better
872
		 * remains intact here.
942
		 * remains intact here.
873
		 */
943
		 */
874
#  ifdef SUPERUSER_PATH
944
#  ifdef HAVE_ETC_DEFAULT_LOGIN
875
		child_set_env(&env, &envsize, "PATH", 
945
		read_etc_default_login(&env, &envsize, pw->pw_uid);
876
		    s->pw->pw_uid == 0 ? SUPERUSER_PATH : _PATH_STDPATH);
946
#  endif /* HAVE_ETC_DEFAULT_LOGIN */
877
#  else 
878
		child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
879
#  endif /* SUPERUSER_PATH */
880
# endif /* HAVE_CYGWIN */
947
# endif /* HAVE_CYGWIN */
881
#endif /* HAVE_LOGIN_CAP */
948
#endif /* HAVE_LOGIN_CAP */
882
949
950
		/*
951
		 * Paranoia check: set at least a standard path
952
		 * if none is set yet.
953
		 */
954
		if(child_get_env(env, "PATH") == NULL) {
955
#ifdef SUPERUSER_PATH
956
			child_set_env(&env, &envsize, "PATH", 
957
			    s->pw->pw_uid == 0 ?
958
				SUPERUSER_PATH : _PATH_STDPATH);
959
#else 
960
			child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
961
#endif /* SUPERUSER_PATH */
962
		}
883
		snprintf(buf, sizeof buf, "%.200s/%.50s",
963
		snprintf(buf, sizeof buf, "%.200s/%.50s",
884
			 _PATH_MAILDIR, pw->pw_name);
964
			 _PATH_MAILDIR, pw->pw_name);
885
		child_set_env(&env, &envsize, "MAIL", buf);
965
		child_set_env(&env, &envsize, "MAIL", buf);

Return to bug 252