From: Ludwig Nussel <ludwig.nussel@suse.de>
To: util-linux@vger.kernel.org
Cc: Ludwig Nussel <ludwig.nussel@suse.de>
Subject: [PATCH 3/7] use ENV_PATH resp ENV_SUPATH to be consistent with login
Date: Fri, 1 Jun 2012 14:51:17 +0200 [thread overview]
Message-ID: <1338555081-2061-3-git-send-email-ludwig.nussel@suse.de> (raw)
In-Reply-To: <1338555081-2061-1-git-send-email-ludwig.nussel@suse.de>
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
---
login-utils/su.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/login-utils/su.c b/login-utils/su.c
index b1fca5f..22b9ccc 100644
--- a/login-utils/su.c
+++ b/login-utils/su.c
@@ -476,6 +476,20 @@ clearsbin (const char *const path)
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
the value for the SHELL environment variable. */
@@ -497,9 +511,7 @@ modify_environment (const struct passwd *pw, const char *shell)
xsetenv ("SHELL", shell);
xsetenv ("USER", pw->pw_name);
xsetenv ("LOGNAME", pw->pw_name);
- xsetenv ("PATH", (pw->pw_uid
- ? getlogindefs_str ("PATH", _PATH_DEFPATH)
- : getlogindefs_str ("SUPATH", _PATH_DEFPATH_ROOT)));
+ set_path(pw);
}
else
{
@@ -510,11 +522,7 @@ modify_environment (const struct passwd *pw, const char *shell)
xsetenv ("HOME", pw->pw_dir);
xsetenv ("SHELL", shell);
if (getlogindefs_bool ("ALWAYS_SET_PATH", 0))
- xsetenv ("PATH", (pw->pw_uid
- ? getlogindefs_str ("PATH",
- _PATH_DEFPATH)
- : getlogindefs_str ("SUPATH",
- _PATH_DEFPATH_ROOT)));
+ set_path(pw);
else
{
char const *path = getenv ("PATH");
--
1.7.7
next prev parent reply other threads:[~2012-06-01 12:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 12:51 [PATCH 1/7] don't use custom MAX macro Ludwig Nussel
2012-06-01 12:51 ` [PATCH 2/7] use EXIT_FAILURE consistently Ludwig Nussel
2012-06-01 12:51 ` Ludwig Nussel [this message]
2012-06-01 12:51 ` [PATCH 4/7] introduce xsetenv globally Ludwig Nussel
2012-06-05 13:27 ` Karel Zak
2012-06-01 12:51 ` [PATCH 5/7] replace PAM_BAIL_P macro with better solution Ludwig Nussel
2012-06-01 12:51 ` [PATCH 6/7] remove unused code Ludwig Nussel
2012-06-01 12:51 ` [PATCH 7/7] use BSD err function instead of gnu's error() Ludwig Nussel
2012-06-05 13:27 ` [PATCH 1/7] don't use custom MAX macro Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338555081-2061-3-git-send-email-ludwig.nussel@suse.de \
--to=ludwig.nussel@suse.de \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).