]> git.pld-linux.org Git - packages/SysVinit.git/blame - sysvinit-rebootconfirmation.patch
- does not require logrotate; rel 19
[packages/SysVinit.git] / sysvinit-rebootconfirmation.patch
CommitLineData
b2cd1c4a 1--- src/halt.c-dupa 2008-08-20 14:45:39.019976250 +0200
2+++ src/halt.c 2008-08-20 14:49:35.418750250 +0200
3@@ -64,7 +64,7 @@
4 */
5 void usage(void)
6 {
7- fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
8+ fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i] [-c]%s\n",
9 progname, strcmp(progname, "halt") ? "" : " [-p]");
10 fprintf(stderr, "\t-n: don't sync before halting the system\n");
11 fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
12@@ -72,6 +72,7 @@
13 fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n");
14 fprintf(stderr, "\t-h: put harddisks in standby mode.\n");
15 fprintf(stderr, "\t-i: shut down all network interfaces.\n");
2d435542 16+ fprintf(stderr, "\t-c: ask for confirmation.\n");
b2cd1c4a 17 if (!strcmp(progname, "halt"))
18 fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
19 exit(1);
20@@ -172,8 +173,10 @@
21 int do_ifdown = 0;
22 int do_hddown = 0;
23 int do_poweroff = 0;
24+ int do_confirm = 0;
25 int c;
26 char *tm = NULL;
27+ char answer = 'n';
28
29 /*
30 * Find out who we are
31@@ -190,7 +193,7 @@
32 /*
33 * Get flags
34 */
35- while((c = getopt(argc, argv, ":ihdfnpwt:")) != EOF) {
36+ while((c = getopt(argc, argv, ":ihdfnpwct:")) != EOF) {
37 switch(c) {
38 case 'n':
39 do_sync = 0;
40@@ -214,6 +217,9 @@
41 case 'p':
42 do_poweroff = 1;
43 break;
44+ case 'c':
45+ do_confirm = 1;
46+ break;
47 case 't':
48 tm = optarg;
49 break;
50@@ -231,6 +237,11 @@
51 (void)chdir("/");
52
53 if (!do_hard && !do_nothing) {
54+ if (do_confirm) {
55+ fprintf(stderr, "Are you sure you want to reboot? N/y.\n");
56+ scanf("%c", &answer);
57+ if (tolower(answer) != 'y') exit(1);
58+ }
59 /*
60 * See if we are in runlevel 0 or 6.
61 */
This page took 0.126437 seconds and 4 git commands to generate.