]> git.pld-linux.org Git - packages/SysVinit.git/blob - sysvinit-rebootconfirmation.patch
- updated to 3.04
[packages/SysVinit.git] / sysvinit-rebootconfirmation.patch
1 diff -urNp -x '*.orig' src/halt.c src/halt.c
2 --- src/halt.c  2021-02-25 08:12:01.388254734 +0100
3 +++ src/halt.c  2021-02-25 08:12:01.484924408 +0100
4 @@ -75,7 +75,7 @@ extern void write_wtmp(char *user, char
5   */
6  void usage(void)
7  {
8 -       fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
9 +       fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i] [-c]%s\n",
10                 progname, strcmp(progname, "halt") ? "" : " [-p]");
11         fprintf(stderr, "\t-n: don't sync before halting the system\n");
12         fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
13 @@ -83,6 +83,7 @@ void usage(void)
14         fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n");
15         fprintf(stderr, "\t-h: put harddisks in standby mode.\n");
16         fprintf(stderr, "\t-i: shut down all network interfaces.\n");
17 +       fprintf(stderr, "\t-c: ask for confirmation.\n");
18         if (!strcmp(progname, "halt"))
19                 fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
20         exit(1);
21 @@ -193,8 +194,10 @@ int main(int argc, char **argv)
22         int do_ifdown = 0;
23         int do_hddown = 0;
24         int do_poweroff = 0;
25 +       int do_confirm = 0;
26         int c;
27         char *tm = NULL;
28 +       char answer = 'n';
29  
30         /*
31          *      Find out who we are
32 @@ -212,7 +215,7 @@ int main(int argc, char **argv)
33         /*
34          *      Get flags
35          */
36 -       while((c = getopt(argc, argv, ":ihdfnpwt:")) != EOF) {
37 +       while((c = getopt(argc, argv, ":ihdfnpwct:")) != EOF) {
38                 switch(c) {
39                         case 'n':
40                                 do_sync = 0;
41 @@ -236,6 +239,9 @@ int main(int argc, char **argv)
42                         case 'p':
43                                 do_poweroff = 1;
44                                 break;
45 +                       case 'c':
46 +                               do_confirm = 1;
47 +                               break;
48                         case 't':
49                                 tm = optarg;
50                                 break;
51 @@ -256,6 +262,11 @@ int main(int argc, char **argv)
52         }
53  
54         if (!do_hard && !do_nothing) {
55 +               if (do_confirm) {
56 +                       fprintf(stderr, "Are you sure you want to reboot? N/y.\n");
57 +                       scanf("%c", &answer);
58 +                       if (tolower(answer) != 'y') exit(1);
59 +               }
60                 /*
61                  *      See if we are in runlevel 0 or 6.
62                  */
This page took 0.048872 seconds and 3 git commands to generate.