diff options
Diffstat (limited to 'toys/lsb/su.c')
-rw-r--r-- | toys/lsb/su.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/toys/lsb/su.c b/toys/lsb/su.c index 136e81ed..71df8a6b 100644 --- a/toys/lsb/su.c +++ b/toys/lsb/su.c @@ -12,7 +12,6 @@ USE_SU(NEWTOY(su, "^lmpu:g:c:s:[!lmp]", TOYFLAG_BIN|TOYFLAG_ROOTONLY)) config SU bool "su" default y - depends on TOYBOX_SHADOW help usage: su [-lp] [-u UID] [-g GID,...] [-s SHELL] [-c CMD] [USER [COMMAND...]] @@ -46,7 +45,6 @@ void su_main() { char *name, *passhash = 0, **argu, **argv; struct passwd *up; - struct spwd *shp; if (*toys.optargs && !strcmp("-", *toys.optargs)) { toys.optflags |= FLAG_l; @@ -58,8 +56,10 @@ void su_main() loggit(LOG_NOTICE, "%s->%s", getusername(geteuid()), name); - if (!(shp = getspnam(name))) perror_exit("no '%s'", name); if (getuid()) { + struct spwd *shp; + + if (!(shp = getspnam(name))) perror_exit("no '%s'", name); if (*shp->sp_pwdp != '$') goto deny; if (read_password(toybuf, sizeof(toybuf), "Password: ")) goto deny; passhash = crypt(toybuf, shp->sp_pwdp); |