diff --git a/src/shutdown.c b/src/shutdown.c index d9ac9f4..f85bc38 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -498,7 +498,15 @@ int main(int argc, char **argv) int user_ok = 0; /* We can be installed setuid root (executable for a special group) */ - setuid(geteuid()); + /* + This way is risky, do error check on setuid call. + setuid(geteuid()); + */ + errno = 0; + if (setuid(geteuid()) == -1) { + fprintf(stderr, "%s (%d): %s\n", __FILE__, __LINE__, strerror(errno)); + abort(); + } if (getuid() != 0) { fprintf(stderr, "shutdown: you must be root to do that!\n");