[Initscripts-ng-commits] r858 - in /trunk/src/insserv/debian: changelog patches/00list patches/50_symlink_in_initddir.dpatch run-testsuite
kelmo-guest at users.alioth.debian.org
kelmo-guest at users.alioth.debian.org
Thu Sep 18 07:33:45 UTC 2008
Author: kelmo-guest
Date: Thu Sep 18 07:33:45 2008
New Revision: 858
URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=858
Log:
* Add 50_symlink_in_initddir.dpatch to defend aginst symlinks
installed to /etc/init.d/ that point to other scripts in
/etc/init.d/, causing insserv to fail due to duplicate provides.
(Closes: #485045)
* Extend test_initd_symlink() test suite case to handle cases which
50_symlink_in_initddir.dpatch must handle.
Added:
trunk/src/insserv/debian/patches/50_symlink_in_initddir.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=858&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Thu Sep 18 07:33:45 2008
@@ -15,8 +15,14 @@
* Add 40_badboy_segfault.dpatch to fix segfault when scriptname()
function of insserv does not return script name due to script in
runlevel directory not being a symlink (or corrupt). (Closes: #493202)
-
- -- Kel Modderman <kel at otaku42.de> Fri, 12 Sep 2008 18:13:32 +1000
+ * Add 50_symlink_in_initddir.dpatch to defend aginst symlinks
+ installed to /etc/init.d/ that point to other scripts in
+ /etc/init.d/, causing insserv to fail due to duplicate provides.
+ (Closes: #485045)
+ * Extend test_initd_symlink() test suite case to handle cases which
+ 50_symlink_in_initddir.dpatch must handle.
+
+ -- Kel Modderman <kel at otaku42.de> Thu, 18 Sep 2008 17:32:47 +1000
insserv (1.12.0-2) 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=858&op=diff
==============================================================================
--- trunk/src/insserv/debian/patches/00list (original)
+++ trunk/src/insserv/debian/patches/00list Thu Sep 18 07:33:45 2008
@@ -2,3 +2,4 @@
11_debian_conf
30_deterministic_order
40_badboy_segfault
+50_symlink_in_initddir
Added: trunk/src/insserv/debian/patches/50_symlink_in_initddir.dpatch
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/patches/50_symlink_in_initddir.dpatch?rev=858&op=file
==============================================================================
--- trunk/src/insserv/debian/patches/50_symlink_in_initddir.dpatch (added)
+++ trunk/src/insserv/debian/patches/50_symlink_in_initddir.dpatch Thu Sep 18 07:33:45 2008
@@ -1,0 +1,74 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50_symlink_in_initddir.patch by Kel Modderman <kel at otaku42.de>
+##
+## DP: Purpose: Defend against symlinks in init.d/ to other scripts in init.d/
+## DP: Fixes: #485045
+## DP: Status: Work in progress.
+
+ at DPATCH@
+--- a/insserv.c
++++ b/insserv.c
+@@ -2542,11 +2542,12 @@
+ errno = 0;
+
+ /* d_type seems not to work, therefore use (l)stat(2) */
+- if (xstat(dfd, d->d_name, &st_script) < 0) {
++ if (xlstat(dfd, d->d_name, &st_script) < 0) {
+ warn("can not stat(%s)\n", d->d_name);
+ continue;
+ }
+- if (!S_ISREG(st_script.st_mode) || !(S_IXUSR & st_script.st_mode))
++ if ((!S_ISLNK(st_script.st_mode) && !S_ISREG(st_script.st_mode)) ||
++ !(S_IXUSR & st_script.st_mode))
+ {
+ if (S_ISDIR(st_script.st_mode))
+ continue;
+@@ -2555,6 +2556,48 @@
+ continue;
+ }
+
++ /*
++ * Do extra sanity checking of symlinks in init.d/ dir, except if it
++ * is named reboot, as that is a special case on SUSE
++ */
++ if (S_ISLNK(st_script.st_mode) && ((strcmp(d->d_name, "reboot") != 0)))
++ {
++ char * basename;
++ char linkbuf[PATH_MAX+1];
++ int linklen;
++
++ linklen = xreadlink(dfd, d->d_name, linkbuf, sizeof(linkbuf)-1);
++ if (linklen < 0)
++ continue;
++ linkbuf[linklen] = '\0';
++
++ if ((basename = strrchr(linkbuf, '/')))
++ basename++;
++ else
++ basename = xstrdup(linkbuf);
++
++ /* skip symbolic links to other scripts in this path */
++ if (xstat(dfd, basename, &st_script) == 0) {
++ if (isarg)
++ warn("script %s is a symlink to another script %s, skipped!\n",
++ d->d_name, basename);
++ continue;
++ }
++
++ /* stat the symlink target and make sure it is a valid script */
++ if (xstat(dfd, d->d_name, &st_script) < 0)
++ continue;
++
++ if (!S_ISREG(st_script.st_mode) || !(S_IXUSR & st_script.st_mode)) {
++ if (S_ISDIR(st_script.st_mode))
++ continue;
++ if (isarg)
++ warn("script %s is not an executable regular file, skipped!\n",
++ d->d_name);
++ continue;
++ }
++ }
++
+ if (!strncmp(d->d_name, "README", strlen("README"))) {
+ if (isarg)
+ warn("script name %s is not valid, skipped!\n", d->d_name);
Modified: trunk/src/insserv/debian/run-testsuite
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/run-testsuite?rev=858&op=diff
==============================================================================
--- trunk/src/insserv/debian/run-testsuite (original)
+++ trunk/src/insserv/debian/run-testsuite Thu Sep 18 07:33:45 2008
@@ -1478,13 +1478,31 @@
### END INIT INFO
EOF
+addscript outsider <<'EOF'
+### BEGIN INIT INFO
+# Provides: outsider
+# Required-Start:
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 1
+### END INIT INFO
+EOF
+
+#addscript halt <<'EOF'
+### BEGIN INIT INFO
+# Provides: halt
+# Required-Start:
+# Required-Stop:
+# Default-Start:
+# Default-Stop: 0 6
+### END INIT INFO
+#EOF
+
# Now make an illegal symlink to see if it causes problems, #485045
ln -s symlinked ${initddir}/symlink
insserv_reg symlinked || true
insserv_reg symlink || true
-
-list_rclinks
check_script_present 1 symlinked
check_script_present 2 symlinked
@@ -1496,6 +1514,30 @@
check_script_not_present 3 symlink
check_script_not_present 4 symlink
check_script_not_present 5 symlink
+
+# Add a /etc/init.d/reboot -> halt symlink, to make sure the SUSE case
+# is not broken with stricter symlink sanity checking
+#ln -s halt ${initddir}/reboot
+
+#insserv_reg reboot || true
+
+#check_script_present 0 reboot
+#check_script_present 6 reboot
+
+# Move outsider to a location other than /etc/init.d/ and create a symlink
+# to it. insserv should register it without problems.
+mv ${initddir}/outsider ${initddir}/../
+ln -s ../outsider ${initddir}/outsidelink
+
+insserv_reg outsidelink || true
+
+list_rclinks
+
+check_script_present 1 outsidelink
+check_script_present 2 outsidelink
+check_script_present 3 outsidelink
+check_script_present 4 outsidelink
+check_script_present 5 outsidelink
}
##########################################################################
test_deterministic_order() {
More information about the Initscripts-ng-commits
mailing list