Skip to content

Commit

Permalink
Exit with false status if exec(3) fails ...
Browse files Browse the repository at this point in the history
... and show errno from exec(3) to the user
  • Loading branch information
git-core committed Jan 11, 2012
1 parent b3c8708 commit da86864
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion su.c
Expand Up @@ -288,6 +288,7 @@ static void allow(char *shell, mode_t mask)
struct su_initiator *from = &su_from;
struct su_request *to = &su_to;
char *exe = NULL;
int err;

umask(mask);
send_intent(&su_from, &su_to, "", 1, 1);
Expand All @@ -306,8 +307,10 @@ static void allow(char *shell, mode_t mask)
} else {
execl(shell, exe, "-", (char*)NULL);
}
err = errno;
PLOGE("exec");
exit(EXIT_SUCCESS);
fprintf(stderr, "Cannot execute %s: %s\n", shell, strerror(err));
exit(EXIT_FAILURE);
}

int main(int argc, char *argv[])
Expand Down

0 comments on commit da86864

Please sign in to comment.