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

18
su.c
View File

@ -61,17 +61,17 @@ 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);
for (i = 0; pass[i]; i++)
pass[i] = '\0';
if (!cryptpass)
eprintf("crypt:");
if (strcmp(cryptpass, spw->sp_pwdp) != 0)
enprintf(EXIT_FAILURE, "Denied\n");
} }
cryptpass = crypt(pass, spw->sp_pwdp);
for (i = 0; pass[i]; i++)
pass[i] = '\0';
if (!cryptpass)
eprintf("crypt:");
if (strcmp(cryptpass, spw->sp_pwdp) != 0)
enprintf(EXIT_FAILURE, "Denied\n");
errno = 0; errno = 0;
pw = getpwnam(usr); pw = getpwnam(usr);
if (errno) if (errno)