diff --git a/su-exec b/su-exec new file mode 100755 index 0000000..424abc2 Binary files /dev/null and b/su-exec differ diff --git a/su-exec.c b/su-exec.c index 176bbf2..4117de0 100644 --- a/su-exec.c +++ b/su-exec.c @@ -45,9 +45,15 @@ int main(int argc, char *argv[]) if (*end == '\0') uid = nuid; } - if (pw == NULL) { + if (pw == NULL && pw != 0) { pw = getpwuid(uid); } + + if (pw == 0) { + fprintf(stderr, "user %s does not exist\n", user); + exit(1); + } + if (pw != NULL) { uid = pw->pw_uid; gid = pw->pw_gid;