[Initscripts-ng-commits] r838 - in /trunk/src/insserv/debian: changelog patches/00list patches/30_deterministic_order.dpatch run-testsuite
kelmo-guest at users.alioth.debian.org
kelmo-guest at users.alioth.debian.org
Mon Aug 18 17:11:53 UTC 2008
Author: kelmo-guest
Date: Mon Aug 18 17:11:53 2008
New Revision: 838
URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=838
Log:
* Add test_deterministic_order() test function to make sure that when two or
more initscripts provide the same facility, the first script actually can
be registered with insserv reliably.
* Add 30_deterministic_order.dpatch to defend against the inconsistent
directory stream sequence returned by readdir(3) under different
circumstances. (Closes: #494514)
Added:
trunk/src/insserv/debian/patches/30_deterministic_order.dpatch
Modified:
trunk/src/insserv/debian/changelog
trunk/src/insserv/debian/patches/00list
trunk/src/insserv/debian/run-testsuite
Modified: trunk/src/insserv/debian/changelog
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/changelog?rev=838&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Mon Aug 18 17:11:53 2008
@@ -3,8 +3,14 @@
* Make test_duplicate_provides() test case more realistic by placing
initscripts in init.d dir before registering with insserv. Make sure first
script is registered.
-
- -- Kel Modderman <kel at otaku42.de> Tue, 19 Aug 2008 02:06:10 +1000
+ * Add test_deterministic_order() test function to make sure that when two or
+ more initscripts provide the same facility, the first script actually can
+ be registered with insserv reliably.
+ * Add 30_deterministic_order.dpatch to defend against the inconsistent
+ directory stream sequence returned by readdir(3) under different
+ circumstances. (Closes: #494514)
+
+ -- Kel Modderman <kel at otaku42.de> Tue, 19 Aug 2008 03:09:03 +1000
insserv (1.12.0-1) unstable; urgency=low
Modified: trunk/src/insserv/debian/patches/00list
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/patches/00list?rev=838&op=diff
==============================================================================
--- trunk/src/insserv/debian/patches/00list (original)
+++ trunk/src/insserv/debian/patches/00list Mon Aug 18 17:11:53 2008
@@ -1,2 +1,3 @@
10_nosuse
11_debian_conf
+30_deterministic_order
Added: trunk/src/insserv/debian/patches/30_deterministic_order.dpatch
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/patches/30_deterministic_order.dpatch?rev=838&op=file
==============================================================================
--- trunk/src/insserv/debian/patches/30_deterministic_order.dpatch (added)
+++ trunk/src/insserv/debian/patches/30_deterministic_order.dpatch Mon Aug 18 17:11:53 2008
@@ -1,0 +1,68 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 30_deterministic_order.patch.dpatch by Kel Modderman <kel at otaku42.de>
+##
+## DP: Purpose: Defend against undeterministic directory stream sequence
+## DP: returned by readdir(3). Make sure script which is being
+## DP: registered is processed before all others.
+## DP: Fixes: #494514
+## DP: Status: Work in progress.
+
+ at DPATCH@
+--- a/insserv.c
++++ b/insserv.c
+@@ -2238,6 +2238,7 @@
+ boolean del = false;
+ boolean defaults = false;
+ boolean ignore = false;
++ boolean loadarg = argc;
+
+ myname = basename(*argv);
+
+@@ -2490,17 +2491,45 @@
+ /*
+ * Scan now all scripts found in the init.d/ directory
+ */
+- while ((d = readdir(initdir)) != (struct dirent*)0) {
+- const boolean isarg = chkfor(d->d_name, argv, argc);
++ for (;;) {
+ service_t * service = (service_t*)0;
+ char * token;
+ char * begin = (char*)0; /* hold start pointer of strings handled by strsep() */
+ boolean hard = false;
++ boolean isarg = false;
+ uchar lsb = 0;
+ #if defined(DEBUG) && (DEBUG > 0)
+ int nobug = 0;
+ #endif
+
++ if ((d = readdir(initdir)) == (struct dirent*)0) {
++ /*
++ * If first script in argument list was loaded in advance, then
++ * rewind the init.d/ directory stream and attempt to load all
++ * other scripts.
++ */
++ if (loadarg) {
++ loadarg = false;
++ rewinddir(initdir);
++ continue;
++ }
++ break;
++ }
++
++ isarg = chkfor(d->d_name, argv, argc);
++
++ /*
++ * Load first script in argument list before all other scripts. This
++ * avoids problems with loading services in underterministic sequence
++ * returned by readdir(3).
++ */
++ if (loadarg && !isarg)
++ continue;
++ else if (loadarg && isarg && (curr_argc != 0))
++ continue;
++ else if (!loadarg && isarg && (curr_argc == 0))
++ continue;
++
+ if (*d->d_name == '.')
+ continue;
+ errno = 0;
Modified: trunk/src/insserv/debian/run-testsuite
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/run-testsuite?rev=838&op=diff
==============================================================================
--- trunk/src/insserv/debian/run-testsuite (original)
+++ trunk/src/insserv/debian/run-testsuite Mon Aug 18 17:11:53 2008
@@ -1494,6 +1494,55 @@
check_script_not_present 3 symlink
check_script_not_present 4 symlink
check_script_not_present 5 symlink
+}
+##########################################################################
+test_deterministic_order() {
+echo
+echo "info: test two or more initscripts providing same facility, making sure"
+echo "info: that the first script can be registered with insserv, but others fail."
+echo
+
+initdir_purge
+
+addscript abc <<'EOF' || true
+### BEGIN INIT INFO
+# Provides: service
+# Required-Start:
+# Required-Stop:
+# Default-Start: S
+# Default-Stop:
+### END INIT INFO
+EOF
+
+addscript xyz <<'EOF' || true
+### BEGIN INIT INFO
+# Provides: service
+# Required-Start:
+# Required-Stop:
+# Default-Start: S
+# Default-Stop:
+### END INIT INFO
+EOF
+
+addscript hjk <<'EOF' || true
+### BEGIN INIT INFO
+# Provides: service
+# Required-Start:
+# Required-Stop:
+# Default-Start: S
+# Default-Stop:
+### END INIT INFO
+EOF
+
+insserv_reg xyz || true
+insserv_reg hjk || true
+insserv_reg abc || true
+
+list_rclinks
+
+check_script_present S xyz
+check_script_not_present S abc
+check_script_not_present S hjk
}
##########################################################################
@@ -1527,3 +1576,4 @@
test_no_default_start
test_no_default_stop
test_initd_symlink
+test_deterministic_order
More information about the Initscripts-ng-commits
mailing list