diff options
author | Alexander Holler <holler@ahsoftware.de> | 2022-11-04 08:06:29 +0100 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2022-11-04 10:48:52 -0500 |
commit | 0bb61e3aefc32940d8578eb174bf6e39dca17c35 (patch) | |
tree | 68942e996998dc66c98e96f759951db411fd7c45 | |
parent | 149bc75a9b72f6495933819e09de7cf98a407a19 (diff) | |
download | toybox-0bb61e3aefc32940d8578eb174bf6e39dca17c35.tar.gz |
su: do not require /etc/shadow or a password there if called as root
-rw-r--r-- | toys/lsb/su.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/toys/lsb/su.c b/toys/lsb/su.c index 74a87dbd..71df8a6b 100644 --- a/toys/lsb/su.c +++ b/toys/lsb/su.c @@ -45,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; @@ -57,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); |