Changeset View
Changeset View
Standalone View
Standalone View
sbin/reboot/reboot.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
const char *user, *kernel = NULL; | const char *user, *kernel = NULL; | ||||
if (strcmp(getprogname(), "halt") == 0) { | if (strcmp(getprogname(), "halt") == 0) { | ||||
dohalt = 1; | dohalt = 1; | ||||
howto = RB_HALT; | howto = RB_HALT; | ||||
} else | } else | ||||
howto = 0; | howto = 0; | ||||
lflag = nflag = qflag = 0; | lflag = nflag = qflag = 0; | ||||
while ((ch = getopt(argc, argv, "dk:lnpq")) != -1) | while ((ch = getopt(argc, argv, "dk:lnpqr")) != -1) | ||||
switch(ch) { | switch(ch) { | ||||
case 'd': | case 'd': | ||||
howto |= RB_DUMP; | howto |= RB_DUMP; | ||||
break; | break; | ||||
case 'k': | case 'k': | ||||
kernel = optarg; | kernel = optarg; | ||||
break; | break; | ||||
case 'l': | case 'l': | ||||
lflag = 1; | lflag = 1; | ||||
break; | break; | ||||
case 'n': | case 'n': | ||||
nflag = 1; | nflag = 1; | ||||
howto |= RB_NOSYNC; | howto |= RB_NOSYNC; | ||||
break; | break; | ||||
case 'p': | case 'p': | ||||
howto |= RB_POWEROFF; | howto |= RB_POWEROFF; | ||||
break; | break; | ||||
case 'q': | case 'q': | ||||
qflag = 1; | qflag = 1; | ||||
break; | break; | ||||
case 'r': | |||||
howto |= RB_REROOT; | |||||
break; | |||||
case '?': | case '?': | ||||
default: | default: | ||||
usage(); | usage(); | ||||
} | } | ||||
argc -= optind; | argc -= optind; | ||||
argv += optind; | argv += optind; | ||||
if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT)) | if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT)) | ||||
errx(1, "cannot dump (-d) when halting; must reboot instead"); | errx(1, "cannot dump (-d) when halting; must reboot instead"); | ||||
if ((howto & RB_REROOT) != 0 && (howto & RB_REROOT) != RB_REROOT) | |||||
errx(1, "-r flag is mutually exclusive with -d, -n, and -p"); | |||||
if (geteuid()) { | if (geteuid()) { | ||||
emaste: ? | |||||
Done Inline ActionsOops, right; it was commented out for debugging. trasz: Oops, right; it was commented out for debugging. | |||||
errno = EPERM; | errno = EPERM; | ||||
err(1, NULL); | err(1, NULL); | ||||
} | } | ||||
if (qflag) { | if (qflag) { | ||||
reboot(howto); | reboot(howto); | ||||
err(1, NULL); | err(1, NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |
?