Add error handling in case exec fails

We should print error message if exec fails, for some reason.
This commit is contained in:
Josef Möllers 2017-02-20 14:32:37 +01:00 committed by Adam Majer
parent 3f9af9deb9
commit 5ac4918bdd

View File

@ -1817,7 +1817,9 @@ static void tallylog_reset (char *user_name)
pname++; /* Skip the '/' */ pname++; /* Skip the '/' */
execl(pam_tally2, pname, "--user", user_name, "--reset", "--quiet", NULL); execl(pam_tally2, pname, "--user", user_name, "--reset", "--quiet", NULL);
/* If we come here, something has gone terribly wrong */ /* If we come here, something has gone terribly wrong */
failed = 1; perror(pam_tally2);
exit(42); /* don't continue, we now have 2 processes running! */
/* NOTREACHED */
break; break;
default: /* parent */ default: /* parent */
if (waitpid(childpid, &status, 0) == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) if (waitpid(childpid, &status, 0) == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)