Codebase list sysvinit / d21c8fc
Perform error check on setuid() call in shutdown as manual page suggests. Jesse Smith 6 years ago
1 changed file(s) with 9 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
497497 int user_ok = 0;
498498
499499 /* We can be installed setuid root (executable for a special group) */
500 setuid(geteuid());
500 /*
501 This way is risky, do error check on setuid call.
502 setuid(geteuid());
503 */
504 errno = 0;
505 if (setuid(geteuid()) == -1) {
506 fprintf(stderr, "%s (%d): %s\n", __FILE__, __LINE__, strerror(errno));
507 abort();
508 }
501509
502510 if (getuid() != 0) {
503511 fprintf(stderr, "shutdown: you must be root to do that!\n");