perror(s);
exit(EXIT_FAILURE);
}
-static void die_msg(const char *fmt, ...) {
+static void die_fmt(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
die("setgroups");
}
if (getgroups(0, NULL) != 0) {
- die_msg("failed to drop all groups");
+ die_fmt("failed to drop all groups");
}
/* Dropping groups may require privileges, do that first. */
}
if ( uid != ruid || uid != euid || uid != suid
|| gid != rgid || gid != egid || gid != sgid) {
- die_msg("failed to drop privileges");
+ die_fmt("failed to drop privileges");
}
}
/* Just to be safe. */
if (setuid(0) != -1) {
- die_msg("failed to drop privileges (setuid)");
+ die_fmt("failed to drop privileges (setuid)");
}
}
} else if (argc > 2) {
exec_argv = argv + 2;
} else {
- die_msg("%s <user> [<cmd>...]\n", argv[0]);
+ die_fmt("%s <user> [<cmd>...]\n", argv[0]);
}
const char *user = argv[1];
struct passwd *passwd = getpwnam(user);
if (!passwd) {
- die_msg("unknown user name '%s'\n", user);
+ die_fmt("unknown user name '%s'\n", user);
}
uid_t uid = passwd->pw_uid;