Skip to content
Snippets Groups Projects
Commit 41e612d3 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Produce a more verbose output in cases when getpwnam() fails.

parent 9d0ae547
No related branches found
No related tags found
No related merge requests found
...@@ -775,8 +775,15 @@ main(int argc, char **argv) ...@@ -775,8 +775,15 @@ main(int argc, char **argv)
if (cfg.username != NULL) { if (cfg.username != NULL) {
if (getuid() == 0 || geteuid() == 0) { if (getuid() == 0 || geteuid() == 0) {
struct passwd *pw; struct passwd *pw;
errno = 0;
if ((pw = getpwnam(cfg.username)) == 0) { if ((pw = getpwnam(cfg.username)) == 0) {
say_syserror("getpwnam: %s", cfg.username); if (errno) {
say_syserror("getpwnam: %s",
cfg.username);
} else {
say_error("User not found: %s",
cfg.username);
}
exit(EX_NOUSER); exit(EX_NOUSER);
} }
if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0 || seteuid(pw->pw_uid)) { if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0 || seteuid(pw->pw_uid)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment