~ubuntu-branches/ubuntu/natty/insserv/natty-updates

« back to all changes in this revision

Viewing changes to debian/patches/30_deterministic_order.patch

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen, Kel Modderman, Petter Reinholdtsen
  • Date: 2010-05-07 09:45:19 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100507094519-laz6segpkp1t9mce
Tags: 1.14.0-2
[ Kel Modderman ]
* Add 21_tweak_warnings.patch to make insserv warn about differing on
  disk state/LSB runlevel info for the script(s) in its argument list.
  (Closes: #578308)
* Add 100_show.patch which allows insserv --showall to dump start/stop
  bit, sequence number, runlevels and script name in the format:
  SK:NUM:RUNLEVELS:SCRIPT. It is commented out in quilt series file
  until confirmation from #573004 that it is actually useful.
* Add 30_interactive_regexp_match_fix.patch which fixes failure to
  properly match the correct group in the regular expression used on
  the X-Interactive keyword. (Closes: #580564)
* Modify 92_m68k_alignment.patch so that the define is grouped in an
  area of code which other similar defines live.

[ Petter Reinholdtsen ]
* Improve the output from make-testsuite. 
* Adjust the test_x_interactive behaviour to make sure it fails with
  a fatal error if X-Interactive: true do not work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Purpose: Defend against undeterministic directory stream sequence
2
 
         returned by readdir(3). Make sure script which is being
3
 
         registered is processed before all others.
4
 
Fixes:   #494514
5
 
Status:  Applied upstream.
6
 
---
7
 
Index: insserv/insserv.c
8
 
===================================================================
9
 
--- insserv.orig/insserv.c      2009-09-26 22:35:25.000000000 +0200
10
 
+++ insserv/insserv.c   2009-09-26 22:35:44.000000000 +0200
11
 
@@ -2238,6 +2238,7 @@
12
 
     boolean del = false;
13
 
     boolean defaults = false;
14
 
     boolean ignore = false;
15
 
+    boolean loadarg = false;
16
 
 
17
 
     myname = basename(*argv);
18
 
 
19
 
@@ -2305,7 +2306,9 @@
20
 
     argv += optind;
21
 
     argc -= optind;
22
 
 
23
 
-    if (!argc && del)
24
 
+    if (argc)
25
 
+       loadarg = true;
26
 
+    else if (del)
27
 
        error("usage: %s [[-r] init_script|init_directory]\n", myname);
28
 
 
29
 
     if (*argv) {
30
 
@@ -2490,17 +2493,45 @@
31
 
     /*
32
 
      * Scan now all scripts found in the init.d/ directory
33
 
      */
34
 
-    while ((d = readdir(initdir)) != (struct dirent*)0) {
35
 
-       const boolean isarg = chkfor(d->d_name, argv, argc);
36
 
+    for (;;) {
37
 
        service_t * service = (service_t*)0;
38
 
        char * token;
39
 
        char * begin = (char*)0;        /* hold start pointer of strings handled by strsep() */
40
 
        boolean hard = false;
41
 
+       boolean isarg = false;
42
 
        uchar lsb = 0;
43
 
 #if defined(DEBUG) && (DEBUG > 0)
44
 
        int nobug = 0;
45
 
 #endif
46
 
 
47
 
+       if ((d = readdir(initdir)) == (struct dirent*)0) {
48
 
+           /*
49
 
+            * If first script in argument list was loaded in advance, then
50
 
+            * rewind the init.d/ directory stream and attempt to load all
51
 
+            * other scripts.
52
 
+            */
53
 
+           if (loadarg) {
54
 
+               loadarg = false;
55
 
+               rewinddir(initdir);
56
 
+               continue;
57
 
+           }
58
 
+           break;
59
 
+       }
60
 
+
61
 
+       isarg = chkfor(d->d_name, argv, argc);
62
 
+
63
 
+       /*
64
 
+        * Load first script in argument list before all other scripts. This
65
 
+        * avoids problems with loading scripts in underterministic sequence
66
 
+        * returned by readdir(3).
67
 
+        */
68
 
+       if (loadarg && !isarg)
69
 
+           continue;
70
 
+       if (loadarg  && isarg && (curr_argc != 0))
71
 
+           continue;
72
 
+       if (!loadarg && isarg && (curr_argc == 0))
73
 
+           continue;
74
 
+
75
 
        if (*d->d_name == '.')
76
 
            continue;
77
 
        errno = 0;