su: use ENV_PATH resp ENV_SUPATH to be consistent with login
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
This commit is contained in:
parent
07ffbaf2b0
commit
a711e67a44
|
@ -476,6 +476,20 @@ clearsbin (const char *const path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_path(const struct passwd* pw)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
if (pw->pw_uid)
|
||||||
|
r = logindefs_setenv("PATH", "ENV_PATH", _PATH_DEFPATH);
|
||||||
|
|
||||||
|
else if ((r = logindefs_setenv("PATH", "ENV_ROOTPATH", NULL)) != 0)
|
||||||
|
r = logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT);
|
||||||
|
|
||||||
|
if (r != 0)
|
||||||
|
err (EXIT_FAILURE, _("failed to set PATH"));
|
||||||
|
}
|
||||||
|
|
||||||
/* Update `environ' for the new shell based on PW, with SHELL being
|
/* Update `environ' for the new shell based on PW, with SHELL being
|
||||||
the value for the SHELL environment variable. */
|
the value for the SHELL environment variable. */
|
||||||
|
|
||||||
|
@ -497,9 +511,7 @@ modify_environment (const struct passwd *pw, const char *shell)
|
||||||
xsetenv ("SHELL", shell);
|
xsetenv ("SHELL", shell);
|
||||||
xsetenv ("USER", pw->pw_name);
|
xsetenv ("USER", pw->pw_name);
|
||||||
xsetenv ("LOGNAME", pw->pw_name);
|
xsetenv ("LOGNAME", pw->pw_name);
|
||||||
xsetenv ("PATH", (pw->pw_uid
|
set_path(pw);
|
||||||
? getlogindefs_str ("PATH", _PATH_DEFPATH)
|
|
||||||
: getlogindefs_str ("SUPATH", _PATH_DEFPATH_ROOT)));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -510,11 +522,7 @@ modify_environment (const struct passwd *pw, const char *shell)
|
||||||
xsetenv ("HOME", pw->pw_dir);
|
xsetenv ("HOME", pw->pw_dir);
|
||||||
xsetenv ("SHELL", shell);
|
xsetenv ("SHELL", shell);
|
||||||
if (getlogindefs_bool ("ALWAYS_SET_PATH", 0))
|
if (getlogindefs_bool ("ALWAYS_SET_PATH", 0))
|
||||||
xsetenv ("PATH", (pw->pw_uid
|
set_path(pw);
|
||||||
? getlogindefs_str ("PATH",
|
|
||||||
_PATH_DEFPATH)
|
|
||||||
: getlogindefs_str ("SUPATH",
|
|
||||||
_PATH_DEFPATH_ROOT)));
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char const *path = getenv ("PATH");
|
char const *path = getenv ("PATH");
|
||||||
|
|
Loading…
Reference in New Issue