Git init
[external/insserv.git] / debian / patches / 61_interactive_keyword.patch
1 Purpose: Add support for a X-Interactive keyword to avoid specifying it in insserv.conf
2 Fixes:   #458224
3 Status:  Work in progress.
4 ---
5
6 Index: insserv/insserv.8.in
7 ===================================================================
8 --- insserv.orig/insserv.8.in   2009-09-26 22:35:25.000000000 +0200
9 +++ insserv/insserv.8.in        2009-09-26 22:35:43.000000000 +0200
10 @@ -76,6 +76,7 @@
11   # X-Stop-After:      boot_facility_1 [ boot_facility_2 ...]
12   # Default-Start:     run_level_1 [ run_level_2 ...]
13   # Default-Stop:      run_level_1 [ run_level_2 ...]
14 + # X-Interactive:     true
15   # Short-Description: single_line_description
16   # Description:       multiline_description
17   ### END INIT INFO
18 @@ -117,6 +118,11 @@
19  these tags is stopped.
20  @@END_SUSE@@
21  .PP
22 +The optional X\-Interactive keyword implies that the script using this
23 +keyword should be started alone in a concurrent boot configuration
24 +because it interact with the user at the console.  Only the value
25 +`true' is recogniced.  All other are ignored.
26 +.PP
27  The optional
28  .B X\-Start\-Before
29  keyword implies that the script using this keyword
30 Index: insserv/insserv.c
31 ===================================================================
32 --- insserv.orig/insserv.c      2009-09-26 22:35:39.000000000 +0200
33 +++ insserv/insserv.c   2009-09-26 22:35:43.000000000 +0200
34 @@ -97,6 +97,7 @@
35  #define DEFAULT_START  DEFAULT  START VALUE
36  #define DEFAULT_STOP   DEFAULT  STOP  VALUE
37  #define DESCRIPTION    COMM "description" VALUE
38 +#define INTERACTIVE    COMM "x-interactive" VALUE
39  
40  /* System facility search within /etc/insserv.conf */
41  #define EQSIGN         "([[:blank:]]*[=:][[:blank:]]*|[[:blank:]]+)"
42 @@ -133,6 +134,7 @@
43      char *default_start;
44      char *default_stop;
45      char *description;
46 +    char *interactive;
47  } attribute((aligned(sizeof(char*)))) lsb_t;
48  
49  /* Search results points here */
50 @@ -147,6 +149,7 @@
51      regex_t def_start;
52      regex_t def_stop;
53      regex_t desc;
54 +    regex_t interact;
55  } attribute((aligned(sizeof(regex_t)))) reg_t;
56  
57  typedef struct creg_struct {
58 @@ -1132,6 +1135,7 @@
59      regcompiler(&reg.def_start, DEFAULT_START,  REG_EXTENDED|REG_ICASE|REG_NEWLINE);
60      regcompiler(&reg.def_stop,  DEFAULT_STOP,   REG_EXTENDED|REG_ICASE|REG_NEWLINE);
61      regcompiler(&reg.desc,      DESCRIPTION,    REG_EXTENDED|REG_ICASE|REG_NEWLINE);
62 +    regcompiler(&reg.interact,  INTERACTIVE,    REG_EXTENDED|REG_ICASE|REG_NEWLINE);
63  }
64  
65  static inline void scan_script_reset(void) attribute((always_inline));
66 @@ -1147,6 +1151,7 @@
67      xreset(script_inf.default_start);
68      xreset(script_inf.default_stop);
69      xreset(script_inf.description);
70 +    xreset(script_inf.interactive);
71  }
72  
73  #define FOUND_LSB_HEADER   0x01
74 @@ -1177,6 +1182,7 @@
75  #define default_start  script_inf.default_start
76  #define default_stop   script_inf.default_stop
77  #define description    script_inf.description
78 +#define interactive    script_inf.interactive
79  
80      info("Loading %s\n", path);
81  
82 @@ -1273,6 +1279,14 @@
83                 description = empty;
84         }
85  
86 +       if (!interactive    && regexecutor(&reg.interact,      COMMON_ARGS) == true) {
87 +           if (val->rm_so < val->rm_eo) {
88 +               *(pbuf+val->rm_eo) = '\0';
89 +               interactive = xstrdup(pbuf+val->rm_so);
90 +           } else
91 +               interactive = empty;
92 +       }
93 +
94         /* Skip scanning below from LSB magic end */
95         if ((end = strstr(buf, "### END INIT INFO")))
96             break;
97 @@ -1341,6 +1355,7 @@
98  #undef default_start
99  #undef default_stop
100  #undef description
101 +#undef interactive
102      return ret;
103  }
104  
105 @@ -1503,6 +1518,7 @@
106      regfree(&reg.def_start);
107      regfree(&reg.def_stop);
108      regfree(&reg.desc);
109 +    regfree(&reg.interact);
110  }
111  
112  static struct {
113 @@ -1781,6 +1797,9 @@
114                 if (script_inf.stop_after && script_inf.stop_after != empty) {
115                     reversereq(service, REQ_SHLD|REQ_KILL, script_inf.stop_after);
116                 }
117 +               if (script_inf.interactive && 0 == strcmp(script_inf.interactive, "true")) {
118 +                   service->attr.flags |= SERV_INTRACT;
119 +               }
120             }
121  
122             if (name) 
123 @@ -2881,6 +2900,9 @@
124                         if (script_inf.should_stop && script_inf.should_stop != empty) {
125                             rememberreq(service, REQ_SHLD|REQ_KILL, script_inf.should_stop);
126                         }
127 +                       if (script_inf.interactive && 0 == strcmp(script_inf.interactive, "true")) {
128 +                           service->attr.flags |= SERV_INTRACT;
129 +                       }
130                     }
131  
132                     if (script_inf.start_before && script_inf.start_before != empty) {