Codebase list insserv / debian/1.09.0-14
Import Debian changes 1.09.0-14 insserv (1.09.0-14) unstable; urgency=low * Changed patch 21_overrides to only warn once about scripts without LSB header, to reduce the noise. * Changed patch 21_overrides to speed up processing by only reading override default files only when the script is lacking an LSB header. * Moved default dependency values from patch 21_overrides to 41_debiandefault where it belong. * New test to check that scripts introducing a loop (or a fake loop, see bug #458582) will refuse to install. * New patch 45_loopsarefatal to make sure insserv considering all kind of loops fatal, to not mess up the script sequences. * Introduce very simple manual page for update-rc.d-insserv. * Make failing 'make clean' fatal, as it should always work. * Change debconf template text to make it easier to understand. Petter Reinholdtsen authored 16 years ago Dmitry Bogatov committed 5 years ago
9 changed file(s) with 273 addition(s) and 76 deletion(s). Raw diff Collapse all Expand all
0 insserv (1.09.0-14) unstable; urgency=low
1
2 * Changed patch 21_overrides to only warn once about scripts without
3 LSB header, to reduce the noise.
4 * Changed patch 21_overrides to speed up processing by only reading
5 override default files only when the script is lacking an LSB header.
6 * Moved default dependency values from patch 21_overrides to
7 41_debiandefault where it belong.
8 * New test to check that scripts introducing a loop (or a fake loop,
9 see bug #458582) will refuse to install.
10 * New patch 45_loopsarefatal to make sure insserv considering all
11 kind of loops fatal, to not mess up the script sequences.
12 * Introduce very simple manual page for update-rc.d-insserv.
13 * Make failing 'make clean' fatal, as it should always work.
14 * Change debconf template text to make it easier to understand.
15
16 -- Petter Reinholdtsen <pere@debian.org> Sun, 6 Jan 2008 09:37:43 +0100
17
018 insserv (1.09.0-13) unstable; urgency=low
119
220 * Update patch 21_overrides to fix bug in override handling. Now a
00 Template: insserv/enable
11 Type: boolean
2 Description: Use dependency based boot sequence?
3 This will reorder all the scripts in /etc/rc*.d/ using the dependency
4 information provided in each script and default or insserv-provided
5 dependency info in case the scripts are missing dependency info. It
6 will also change all S* symlinks in rc0.d/ and rc6.d/ to K* symlinks,
7 to make sure the way they are used (with 'stop' argument) matches
8 their names.
2 Description: Enable (or keep enabled) dependency based boot sequence?
3 Enabling this will reorder all the scripts in /etc/rc*.d/ using the
4 dependency information provided in each script. If such information
5 is missing, default dependency info will be used. It will also
6 change all S* symlinks in rc0.d/ and rc6.d/ to K* symlinks, to make
7 sure the way they are used (with 'stop' argument) matches their
8 names. The change will only be done after it is verified that it is
9 safe to convert. Disabling it when enabled will try to revert the
10 change.
911 .
10 WARNING: It is very hard to revert this change. Reinstallation is
11 probably required to stop using the dependecy based boot system.
12 WARNING: It is very hard to revert from dependency based boot
13 sequencing to the non-dependency based boot sequencing.
14 Reinstallation might be required.
1215 .
13 This is an experimental feature, and is only intended for testing of
14 insserv and the LSB style dependecy information in init.d scripts.
16 This is an experimental feature, and is at the moment only intended
17 for testing of insserv and the LSB style dependecy information in
18 init.d scripts.
1519
1111 42_redundantlvl
1212 43_shutdown
1313 44_reportloopmemb
14 45_loopsarefatal
66
77 @DPATCH@
88 diff -urNad insserv~/insserv.c insserv/insserv.c
9 --- insserv~/insserv.c 2008-01-04 11:21:58.000000000 +0100
10 +++ insserv/insserv.c 2008-01-04 11:21:58.000000000 +0100
9 --- insserv~/insserv.c 2008-01-05 00:29:39.000000000 +0100
10 +++ insserv/insserv.c 2008-01-05 00:30:56.000000000 +0100
1111 @@ -23,6 +23,7 @@
1212 #include <fcntl.h>
1313 #include <sys/stat.h>
2626 #ifndef INSCONF
2727 # define INSCONF "/etc/insserv.conf"
2828 #endif
29 @@ -998,7 +1002,21 @@
29 @@ -998,7 +1004,21 @@
3030 regcompiler(&reg.desc, DESCRIPTION, REG_EXTENDED|REG_ICASE|REG_NEWLINE);
3131 }
3232
4949 {
5050 regmatch_t subloc[SUBNUM_SHD+1], *val = &subloc[SUBNUM-1], *shl = &subloc[SUBNUM_SHD-1];
5151 FILE *script;
52 @@ -1022,25 +1040,18 @@
52 @@ -1022,25 +1042,18 @@
5353 if (!script)
5454 error("fopen(%s): %s\n", path, strerror(errno));
5555
8181
8282 if (!provides && regexecutor(&reg.prov, COMMON_ARGS) == true) {
8383 if (val->rm_so < val->rm_eo) {
84 @@ -1169,10 +1180,104 @@
84 @@ -1169,7 +1180,96 @@
8585 #undef default_start
8686 #undef default_stop
8787 #undef description
132132 +
133133 + free(script);
134134 + script = xstrdup(basename(linkbuf));
135
135 +
136136 + return script;
137137 +}
138138 +
140140 + const char *const name)
141141 +{
142142 + boolean ret = 0;
143 +
143
144144 + char fullpath[PATH_MAX+1];
145145 + snprintf(fullpath, sizeof(fullpath), "%s/%s", dir, name);
146146 + struct stat statbuf;
147147 + if (0 == stat(fullpath, &statbuf) && S_ISREG(statbuf.st_mode)) {
148148 + ret = scan_lsb_headers(fullpath);
149149 + }
150 + return ret;
151 +}
152 +
153 +#define FOUND_LSB_HEADER 0x01
154 +#define FOUND_LSB_DEFAULT 0x02
155 +#define FOUND_LSB_OVERRIDE 0x02
156 +
157 +static boolean scan_script_defaults(const char *const path, const char *const override_path)
158 +{
159 + int ret = 0;
160 + char *name = scriptname(path);
161 +
162 + /* Reset old results */
163 + scan_script_reset();
164 +
165 + /* Replace with headers from the script itself */
166 + ret |= scan_lsb_headers(path);
167 +
168 + if (!ret)
169 + /* Load values if the override file exist */
170 + ret |= load_overrides("/usr/share/insserv/overrides", name);
171 +
172 +
173 + /* Allow host-specific overrides to replace the content in the
174 + init.d scripts */
175 + ret |= load_overrides(override_path, name);
176 +
177 + free(name);
150178 return ret;
151179 }
152180
153 +static boolean scan_script_defaults(const char *const path, const char *const override_path)
154 +{
155 + boolean ret = 0;
156 + boolean override = 0;
157 + char *name = scriptname(path);
158 +
159 + /* Reset old results */
160 + scan_script_reset();
161 +
162 + /* Load values if the override file exist */
163 + override = load_overrides("/usr/share/insserv/overrides", name);
164 +
165 + /* Replace with headers from the script itself */
166 + ret = scan_lsb_headers(path);
167 +
168 + /* Allow host-specific overrides to replace the content in the
169 + init.d scripts */
170 + override |= load_overrides(override_path, name);
171 +
172 + if (!ret) {
173 + warn("warning: script '%s' missing LSB tags\n", path);
174 + if (!override) {
175 + warn("warning: script '%s' missing override too\n", name);
176 + script_inf.required_start = xstrdup("$remote_fs $syslog");
177 + script_inf.required_stop = xstrdup("$remote_fs $syslog");
178 + script_inf.default_start = xstrdup(DEFAULT_START_LVL);
179 + script_inf.default_stop = xstrdup(DEFAULT_STOP_LVL);
180 + }
181 + }
182 + free(name);
183 + return ret | override;
184 +}
185 +
186 static inline void scan_script_regfree()
187 {
188 regfree(&reg.prov);
189 @@ -1237,7 +1342,7 @@
181 @@ -1237,7 +1337,7 @@
190182 /*
191183 * Scan current service structure
192184 */
195187 {
196188 int runlevel;
197189
198 @@ -1274,7 +1379,7 @@
190 @@ -1274,10 +1374,12 @@
199191 continue;
200192 }
201193
202194 - lsb = scan_script_defaults(d->d_name);
203195 + lsb = scan_script_defaults(d->d_name, override_path);
196 +
204197 if (!script_inf.provides || script_inf.provides == empty)
205198 script_inf.provides = xstrdup(ptr);
206199
207 @@ -1325,16 +1430,7 @@
200 +
201 begin = script_inf.provides;
202 while ((token = strsep(&script_inf.provides, delimeter)) && *token) {
203 serv_t * service = NULL;
204 @@ -1293,6 +1401,15 @@
205
206 if (!lsb)
207 service->opts |= SERV_NOTLSB;
208 +
209 + if (! (lsb & FOUND_LSB_HEADER) ) {
210 + if (! (lsb & (FOUND_LSB_DEFAULT | FOUND_LSB_OVERRIDE) ))
211 + warn("warning: script '%s' missing LSB tags and overrides\n",
212 + d->d_name);
213 + else
214 + warn("warning: script '%s' missing LSB tags\n",
215 + d->d_name);
216 + }
217 if (script_inf.required_start && script_inf.required_start != empty) {
218 rememberreq(service, REQ_MUST, script_inf.required_start);
219 requiresv(token, script_inf.required_start);
220 @@ -1325,16 +1442,7 @@
208221 }
209222 script_inf.provides = begin;
210223
222235 }
223236 popd();
224237 closedir(rcdir);
225 @@ -1561,6 +1657,7 @@
238 @@ -1561,6 +1669,7 @@
226239 {"remove", 0, NULL, 'r'},
227240 {"force", 0, NULL, 'f'},
228241 {"path", 1, NULL, 'p'},
230243 {"help", 0, NULL, 'h'},
231244 { 0, 0, NULL, 0 },
232245 };
233 @@ -1574,6 +1671,7 @@
246 @@ -1574,6 +1683,7 @@
234247 printf(" -f, --force Ignore if a required service is missed.\n");
235248 printf(" -v, --verbose Provide information on what is being done.\n");
236249 printf(" -p <path>, --path <path> Path to replace " INITDIR ".\n");
238251 printf(" -c <config>, --config <config> Path to config file.\n");
239252 printf(" -n, --dryrun Do not change the system, only talk about it.\n");
240253 printf(" -d, --default Use default runlevels a defined in the scripts\n");
241 @@ -1590,6 +1688,7 @@
254 @@ -1590,6 +1700,7 @@
242255 struct stat st_script;
243256 char * argr[argc];
244257 char * path = INITDIR;
246259 char * insconf = INSCONF;
247260 int runlevel, c;
248261 boolean del = false;
249 @@ -1601,7 +1700,7 @@
262 @@ -1601,7 +1712,7 @@
250263 for (c = 0; c < argc; c++)
251264 argr[c] = NULL;
252265
255268 switch (c) {
256269 case 'c':
257270 insconf = optarg;
258 @@ -1625,6 +1724,9 @@
271 @@ -1625,6 +1736,9 @@
259272 case 'p':
260273 path = optarg;
261274 break;
265278 case '?':
266279 error("For help use: %s -h\n", myname);
267280 case 'h':
268 @@ -1736,7 +1838,7 @@
281 @@ -1736,7 +1850,7 @@
269282 #if 0
270283 if (!defaults)
271284 #endif
274287
275288 if ((initdir = opendir(path)) == NULL)
276289 error("can not opendir(%s): %s\n", path, strerror(errno));
277 @@ -1823,7 +1925,7 @@
290 @@ -1823,7 +1937,16 @@
278291 }
279292
280293 /* main scanner for LSB comment in current script */
281294 - lsb = scan_script_defaults(d->d_name);
282295 + lsb = scan_script_defaults(d->d_name, override_path);
296 +
297 + if (! (lsb & FOUND_LSB_HEADER) ) {
298 + if (! (lsb & (FOUND_LSB_DEFAULT | FOUND_LSB_OVERRIDE) ))
299 + warn("warning: script '%s' missing LSB tags and overrides\n",
300 + d->d_name);
301 + else
302 + warn("warning: script '%s' missing LSB tags\n",
303 + d->d_name);
304 + }
283305
284306 /* Common script ... */
285307 if (!strcmp(d->d_name, "halt")) {
286 @@ -2175,16 +2277,7 @@
308 @@ -2175,16 +2305,7 @@
287309 service->opts |= SERV_NOTLSB;
288310 }
289311 /* Reset remaining pointers */
55
66 @DPATCH@
77 diff -urNad insserv~/insserv.c insserv/insserv.c
8 --- insserv~/insserv.c 2008-01-04 11:22:07.000000000 +0100
9 +++ insserv/insserv.c 2008-01-04 11:22:07.000000000 +0100
10 @@ -37,6 +37,14 @@
8 --- insserv~/insserv.c 2008-01-04 16:54:52.000000000 +0100
9 +++ insserv/insserv.c 2008-01-04 16:56:22.000000000 +0100
10 @@ -37,6 +37,15 @@
1111 static const int map_runlevel_to_seek(const int runlevel);
1212 #endif /* not SUSE */
1313
1717 +/* for Debian*/
1818 +#define DEFAULT_START_LVL "2 3 4 5"
1919 +#define DEFAULT_STOP_LVL "0 1 6"
20 +#define DEFAULT_DEPENDENCY "$remote_fs $syslog"
2021 +#endif
2122 +
2223 #ifndef INITDIR
2324 # define INITDIR "/etc/init.d"
2425 #endif
25 @@ -2162,7 +2170,7 @@
26 @@ -1377,6 +1386,12 @@
27 if (!script_inf.provides || script_inf.provides == empty)
28 script_inf.provides = xstrdup(ptr);
29
30 + if (!lsb) {
31 + script_inf.required_start = xstrdup(DEFAULT_DEPENDENCY);
32 + script_inf.required_stop = xstrdup(DEFAULT_DEPENDENCY);
33 + script_inf.default_start = xstrdup(DEFAULT_START_LVL);
34 + script_inf.default_stop = xstrdup(DEFAULT_STOP_LVL);
35 + }
36
37 begin = script_inf.provides;
38 while ((token = strsep(&script_inf.provides, delimeter)) && *token) {
39 @@ -1968,6 +1983,13 @@
40 }
41 #endif /* SUSE */
42
43 + if (!lsb) {
44 + script_inf.required_start = xstrdup(DEFAULT_DEPENDENCY);
45 + script_inf.required_stop = xstrdup(DEFAULT_DEPENDENCY);
46 + script_inf.default_start = xstrdup(DEFAULT_START_LVL);
47 + script_inf.default_stop = xstrdup(DEFAULT_STOP_LVL);
48 + }
49 +
50 /*
51 * Oops, no comment found, guess one
52 */
53 @@ -2175,7 +2197,7 @@
2654 /*
2755 * Ahh ... set default multiuser with network
2856 */
3159 }
3260 #ifndef SUSE
3361 /*
34 @@ -2208,15 +2216,12 @@
62 @@ -2221,15 +2243,12 @@
3563 free(begin);
3664 }
3765
0 #! /bin/sh /usr/share/dpatch/dpatch-run
1 ## 45_loopsarefatal.dpatch by Petter Reinholdtsen
2
3 To avoid introducing broken boot and shutdown sequences, it is
4 important that no loops are detected when inserting a script. This
5 patch is a naive fix to make sure any loop detected is a fatal error.
6 The alternative is a broken boot or shutdown sequence.
7
8 It will also report "fake loops" as described in #458582 as fatal, but
9 that is intentional as these fake loops also confuse insserv to a
10 point where its generated boot and shutdown sequence is broken.
11
12 @DPATCH@
13 diff -urNad insserv~/insserv.c insserv/insserv.c
14 --- insserv~/insserv.c 2008-01-05 10:17:45.000000000 +0100
15 +++ insserv/insserv.c 2008-01-05 10:18:31.000000000 +0100
16 @@ -2385,6 +2385,9 @@
17 */
18 follow_all();
19
20 + if (is_loop_detected())
21 + error("exiting now!\n");
22 +
23 /*
24 * Re-order some well known scripts to get
25 * a more stable order collection.
26 diff -urNad insserv~/listing.c insserv/listing.c
27 --- insserv~/listing.c 2008-01-05 10:17:45.000000000 +0100
28 +++ insserv/listing.c 2008-01-05 10:17:45.000000000 +0100
29 @@ -415,6 +415,17 @@
30 }
31 }
32
33 +boolean is_loop_detected(void)
34 +{
35 + list_t *tmp;
36 + list_for_each(tmp, d_start) {
37 + dir_t * dir = getdir(tmp);
38 + if (dir->flags & DIR_LOOPREPORT)
39 + return true;
40 + }
41 + return false;
42 +}
43 +
44 /*
45 * For debuging: show all services
46 */
47 diff -urNad insserv~/listing.h insserv/listing.h
48 --- insserv~/listing.h 2008-01-05 10:17:43.000000000 +0100
49 +++ insserv/listing.h 2008-01-05 10:17:45.000000000 +0100
50 @@ -88,6 +88,7 @@
51 extern const char * getprovides(const char * script);
52 extern boolean listscripts(const char ** script, const int lvl);
53 extern int maxorder;
54 +extern boolean is_loop_detected(void);
55
56 /*
57 * Common short cuts
4242 rm -f build-stamp
4343
4444 # Add here commands to clean up after the build process.
45 -$(MAKE) clean
45 $(MAKE) clean
4646
4747 dh_clean
4848
7474 dh_installexamples
7575 dh_installdebconf
7676 # dh_install
77 dh_installman debian/update-bootsystem-insserv.8
77 dh_installman debian/update-bootsystem-insserv.8 debian/update-rc.d-insserv.8
7878 dh_link
7979 dh_strip
8080 dh_compress
3838 return 1;
3939 }
4040
41 error() {
42 echo error: $@
43 retval=1
44 }
45
46 warning() {
47 echo warning: $@
48 }
49
4150 # Fatal check
4251 check_order() {
4352 if order_ok $@ ; then
44 echo "error: incorrect $runlevel sequence $script1 not before $script2"
45 retval=1
53 error "incorrect $runlevel sequence $script1 not before $script2"
4654 fi
4755 }
4856
4957 # Non-fatal check
5058 test_order() {
5159 if order_ok $@ ; then
52 echo "warning: incorrect $runlevel sequence $script1 not before $script2"
60 warning "incorrect $runlevel sequence $script1 not before $script2"
5361 fi
5462 }
5563
414422 mkdir -p $initddir
415423
416424 # Two scripts with a loop between them
417 insertscript loop1 <<'EOF' || true
425 if insertscript loop1 <<'EOF' ; then
418426 ### BEGIN INIT INFO
419427 # Provides: loop1
420428 # Required-Start: loop2
423431 # Default-Stop:
424432 ### END INIT INFO
425433 EOF
434 error "inserting script with missing dependencies did not fail"
435 fi
426436
427437 insertscript loop2 <<'EOF' || true
428438 ### BEGIN INIT INFO
450460 insserv_reg loop2 || true
451461
452462 check_order S loop1 loop2
463
464 echo
465 echo "info: testing to insert scripts with a longer loop, making sure it fail"
466 echo
467 rm -rf $initddir
468 mkdir -p $initddir
469
470 # Three scripts with a loop between them, make sure introducing the
471 # loop fail, as it will make insserv generate a unstable and broken
472 # boot and shutdown sequence.
473 insertscript loop1 <<'EOF'
474 ### BEGIN INIT INFO
475 # Provides: loop1
476 # Required-Start:
477 # Required-Stop:
478 # Default-Start: S
479 # Default-Stop:
480 ### END INIT INFO
481 EOF
482
483 insertscript loop2 <<'EOF' || true
484 ### BEGIN INIT INFO
485 # Provides: loop2
486 # Required-Start: loop1
487 # Required-Stop:
488 # Default-Start: S
489 # Default-Stop:
490 ### END INIT INFO
491 EOF
492
493 if insertscript loop3 <<'EOF' ; then
494 ### BEGIN INIT INFO
495 # Provides: loop3
496 # Required-Start: loop2
497 # Required-Stop:
498 # X-Start-Before: loop1
499 # Default-Start: S
500 # Default-Stop:
501 ### END INIT INFO
502 EOF
503 error "inserting script causing a loop did not fail"
504 fi
453505
454506 # Test real loop in the combined start and stop sequence. There is no
455507 # loop in the start sequence, and no loop in the stop sequence, but in
0 .\" Copyright 2008 Petter Reinholdtsen
1 .\" May be distributed under the GNU General Public License
2 .TH "update-bootsystem-insserv" "8" "5 January 2008" "Petter Reinholdtsen" ""
3 .SH "NAME"
4 update\-rc.d\-insserv \- insert init.d scripts into boot system using dependency information in the init.d scripts
5 .SH "DESCRIPTION"
6 .B update\-rc.d\-insserv
7 is an implementation of the update-rc.d interface for the dependency
8 based boot sequencing system insserv. It is enabled using
9 update-bootsystem-insserv.
10 .SH "SEE ALSO"
11 update\-rc.d(8), insserv(8), update-bootsystem-insserv(8)
12 .SH "AUTHOR"
13 Petter Reinholdtsen, <pere@hungry.com>