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

Collapse All | Expand All

(-)openssh-3.5p1.orig/acconfig.h (+3 lines)
Lines 328-333 Link Here
328
/* Define in your struct dirent expects you to allocate extra space for d_name */
328
/* Define in your struct dirent expects you to allocate extra space for d_name */
329
#undef BROKEN_ONE_BYTE_DIRENT_D_NAME
329
#undef BROKEN_ONE_BYTE_DIRENT_D_NAME
330
330
331
/* Define if your system has /etc/default/login */
332
#undef HAVE_ETC_DEFAULT_LOGIN
333
331
/* Define if your getopt(3) defines and uses optreset */
334
/* Define if your getopt(3) defines and uses optreset */
332
#undef HAVE_GETOPT_OPTRESET
335
#undef HAVE_GETOPT_OPTRESET
333
336
(-)openssh-3.5p1.orig/configure.ac (+9 lines)
Lines 2427-2432 Link Here
2427
fi
2427
fi
2428
2428
2429
AC_EXEEXT
2429
AC_EXEEXT
2430
# check for /etc/default/login. On some systems (i.e. Solaris 2.x, ReliantUNIX)
2431
# this file defines some environment variables to be set at login time
2432
AC_CHECK_FILE("/etc/default/login",
2433
	[
2434
		AC_DEFINE_UNQUOTED(HAVE_ETC_DEFAULT_LOGIN)
2435
		have_etc_default_login=1
2436
	]
2437
)
2438
2430
AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2439
AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2431
AC_OUTPUT
2440
AC_OUTPUT
2432
2441
(-)openssh-3.5p1.orig/session.c (-6 / +86 lines)
Lines 877-882 Link Here
877
}
877
}
878
878
879
/*
879
/*
880
 * Returns the value of the given variable from the environment.
881
 * Returns NULL, if the variable is not found.
882
 */
883
static char *
884
child_get_env(char **envp, const char *name)
885
{
886
	u_int i, namelen;
887
888
	namelen = strlen(name);
889
	for (i = 0; envp[i]; i++) {
890
		if (strncmp(envp[i], name, namelen) == 0 &&
891
		    envp[i][namelen] == '=')
892
			break;
893
	}
894
	if(envp[i])
895
		return &envp[i][namelen + 1];
896
	
897
	return NULL;
898
}
899
900
/*
880
 * Reads environment variables from the given file and adds/overrides them
901
 * Reads environment variables from the given file and adds/overrides them
881
 * into the environment.  If the file does not exist, this does nothing.
902
 * into the environment.  If the file does not exist, this does nothing.
882
 * Otherwise, it must consist of empty lines, comments (line starts with '#')
903
 * Otherwise, it must consist of empty lines, comments (line starts with '#')
Lines 921-926 Link Here
921
	fclose(f);
942
	fclose(f);
922
}
943
}
923
944
945
#ifdef HAVE_ETC_DEFAULT_LOGIN
946
/*
947
 * Read /etc/default/login
948
 * This file is found and processed by login(1) at least on Solaris
949
 * and ReliantUNIX.
950
 *
951
 * Get PATH environment variable from:
952
 *	PATH (for mere mortals)
953
 *	SUPATH (for root)
954
 * Get umask setting from UMASK
955
 *
956
 * XXX  There are other reasonable things to process in this file:
957
 *	i.e. ALTSHELL, CONSOLE, DISABLE_RHOSTS, HZ, IDLEWEEKS, ULIMIT
958
 *
959
 */
960
static void
961
read_etc_default_login(char ***env, u_int *envsize, uid_t uid)
962
{
963
	char **edf_env, *edf;
964
	u_int i, edf_envsize;
965
	mode_t mask;
966
967
	/*
968
	 * We don't want to copy the whole file to the childs environment,
969
	 * so we use our own temporary environment here.
970
	 */
971
	edf_envsize = 10;
972
	edf_env = xmalloc(edf_envsize * sizeof(char *));
973
	edf_env[0] = NULL;
974
975
	read_environment_file(&edf_env, &edf_envsize, "/etc/default/login");
976
977
	if(uid)
978
		edf = child_get_env(edf_env, "PATH");
979
	else
980
		edf = child_get_env(edf_env, "SUPATH");
981
	if(edf != NULL)
982
		child_set_env(env, envsize, "PATH", edf);
983
	
984
	if((edf = child_get_env(edf_env, "UMASK")) != NULL)
985
		if (sscanf(edf, "%o", &mask) == 1)
986
			umask(mask);
987
	
988
	for(i = 0; edf_env[i]; i++)
989
		xfree(edf_env[i]);
990
	xfree(edf_env);
991
}
992
#endif /* HAVE_ETC_DEFAULT_LOGIN */
993
924
void copy_environment(char **source, char ***env, u_int *envsize)
994
void copy_environment(char **source, char ***env, u_int *envsize)
925
{
995
{
926
	char *var_name, *var_val;
996
	char *var_name, *var_val;
Lines 983-997 Link Here
983
		 * needed for loading shared libraries. So the path better
1053
		 * needed for loading shared libraries. So the path better
984
		 * remains intact here.
1054
		 * remains intact here.
985
		 */
1055
		 */
986
#  ifdef SUPERUSER_PATH
1056
#  ifdef HAVE_ETC_DEFAULT_LOGIN
987
		child_set_env(&env, &envsize, "PATH", 
1057
		read_etc_default_login(&env, &envsize, pw->pw_uid);
988
		    s->pw->pw_uid == 0 ? SUPERUSER_PATH : _PATH_STDPATH);
1058
#  endif /* HAVE_ETC_DEFAULT_LOGIN */
989
#  else 
990
		child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
991
#  endif /* SUPERUSER_PATH */
992
# endif /* HAVE_CYGWIN */
1059
# endif /* HAVE_CYGWIN */
993
#endif /* HAVE_LOGIN_CAP */
1060
#endif /* HAVE_LOGIN_CAP */
994
1061
1062
		/*
1063
		 * Paranoia check: set at least a standard path
1064
		 * if none is set yet.
1065
		 */
1066
		if(child_get_env(env, "PATH") == NULL) {
1067
#ifdef SUPERUSER_PATH
1068
			child_set_env(&env, &envsize, "PATH", 
1069
			    s->pw->pw_uid == 0 ?
1070
				SUPERUSER_PATH : _PATH_STDPATH);
1071
#else 
1072
			child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
1073
#endif /* SUPERUSER_PATH */
1074
		}
995
		snprintf(buf, sizeof buf, "%.200s/%.50s",
1075
		snprintf(buf, sizeof buf, "%.200s/%.50s",
996
			 _PATH_MAILDIR, pw->pw_name);
1076
			 _PATH_MAILDIR, pw->pw_name);
997
		child_set_env(&env, &envsize, "MAIL", buf);
1077
		child_set_env(&env, &envsize, "MAIL", buf);

Return to bug 252