Perform error check on setuid() call in shutdown as manual page suggests.
Jesse Smith
6 years ago
497 | 497 | int user_ok = 0; |
498 | 498 | |
499 | 499 | /* 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 | } | |
501 | 509 | |
502 | 510 | if (getuid() != 0) { |
503 | 511 | fprintf(stderr, "shutdown: you must be root to do that!\n"); |