aboutsummaryrefslogtreecommitdiff
path: root/loginutils/su.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-09 23:12:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-09 23:12:10 +0200
commitd069e5398d7538bdcf0e97c357c28aade3d01a28 (patch)
treef4ed8b62dbed942bbac2bddb19463f48da3af9de /loginutils/su.c
parente66ccfaa2c0a575f56202dd343de923929cf1f38 (diff)
downloadbusybox-w32-d069e5398d7538bdcf0e97c357c28aade3d01a28.tar.gz
busybox-w32-d069e5398d7538bdcf0e97c357c28aade3d01a28.tar.bz2
busybox-w32-d069e5398d7538bdcf0e97c357c28aade3d01a28.zip
a few more GCC-isms removed
text data bss dec hex filename 824641 458 6956 832055 cb237 busybox_old 824631 458 6956 832045 cb22d busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils/su.c')
-rw-r--r--loginutils/su.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/loginutils/su.c b/loginutils/su.c
index a8b852b09..a3f7ed8a0 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -40,11 +40,24 @@ int su_main(int argc UNUSED_PARAM, char **argv)
40 40
41 if (ENABLE_FEATURE_SU_SYSLOG) { 41 if (ENABLE_FEATURE_SU_SYSLOG) {
42 /* The utmp entry (via getlogin) is probably the best way to identify 42 /* The utmp entry (via getlogin) is probably the best way to identify
43 the user, especially if someone su's from a su-shell. 43 * the user, especially if someone su's from a su-shell.
44 But getlogin can fail -- usually due to lack of utmp entry. 44 * But getlogin can fail -- usually due to lack of utmp entry.
45 in this case resort to getpwuid. */ 45 * in this case resort to getpwuid. */
46 old_user = xstrdup(IF_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : ""); 46 const char *user;
47 tty = xmalloc_ttyname(2) ? : "none"; 47#if ENABLE_FEATURE_UTMP
48 char user_buf[64];
49 user = user_buf;
50 if (getlogin_r(user_buf, sizeof(user_buf)) != 0)
51#endif
52 {
53 pw = getpwuid(cur_uid);
54 user = pw ? pw->pw_name : "";
55 }
56 old_user = xstrdup(user);
57 tty = xmalloc_ttyname(2);
58 if (!tty) {
59 tty = "none";
60 }
48 openlog(applet_name, 0, LOG_AUTH); 61 openlog(applet_name, 0, LOG_AUTH);
49 } 62 }
50 63