Only try to ask for a password and check if uid is != 0

This commit is contained in:
sin 2013-10-18 10:25:39 +01:00
parent 56ce9e8bff
commit 86566f4ceb
1 changed files with 9 additions and 9 deletions

2
su.c
View File

@ -61,7 +61,6 @@ main(int argc, char **argv)
pass = getpass("Password: "); pass = getpass("Password: ");
if (!pass) if (!pass)
eprintf("getpass:"); eprintf("getpass:");
}
cryptpass = crypt(pass, spw->sp_pwdp); cryptpass = crypt(pass, spw->sp_pwdp);
for (i = 0; pass[i]; i++) for (i = 0; pass[i]; i++)
@ -71,6 +70,7 @@ main(int argc, char **argv)
if (strcmp(cryptpass, spw->sp_pwdp) != 0) if (strcmp(cryptpass, spw->sp_pwdp) != 0)
enprintf(EXIT_FAILURE, "Denied\n"); enprintf(EXIT_FAILURE, "Denied\n");
}
errno = 0; errno = 0;
pw = getpwnam(usr); pw = getpwnam(usr);