[Pkg-sysvinit-devel] Bug#668312: sysv-rc: hidden dotfile in /etc used as state file (/etc/init.d/.legacy-bootordering)

Roger Leigh rleigh at codelibre.net
Thu Apr 19 22:55:19 UTC 2012


tags 668312 + patch
thanks

On Thu, Apr 19, 2012 at 11:01:44PM +0100, Roger Leigh wrote:
> severity 668312 important
> thanks
> 
> On Tue, Apr 10, 2012 at 11:27:33PM +0200, Tollef Fog Heen wrote:
> > sysv-rc uses /etc/init.d/.legacy-bootordering as a flag file, which is
> > essentially a state file to know whether to convert to new ordering or
> > not.  It should live in /var/lib/sysv-rc or similar instead.
> > 
> > If this is meant to be a configuration file, it must not be recreated
> > after it's deleted.  It should probably also not be a hidden file, since
> > there's no good reason for it.
> 
> While I agree it's nasty, it's also in at least one, if not two,
> stable releases already, and is required to prevent breakage
> when switching between legacy and dependency based boot ordering.
> I hope it will be possible to remove post-wheezy (this is one
> advantage to mandating the use of dependency-based boot--the need
> to maintain this is no longer present).
> 
> Downgrading to important for the interim, not because it's not
> wrong, but because it's been around for a long time, and is already
> in stable and oldstable.  It also remains to be determined if it is
> safe remove it for wheezy,  It will need a check of which other
> packages are also using it, because we deliberately leave it in place
> in the postrm.
> 
> We can certainly remove /our/ use of .legacy-bootordering in the
> postinst (the check for it can be replaced with a shell function
> to do the file-rc check).  The main other use of it is for after
> we are removed (according the the comments in the maintainer
> scripts).

I don't see any other use of this file in any other packages such
as file-rc, so the comment in the postrm is probably not needed.

The following patch removes it on upgrade, and uses a shell function
instead to detect file-rc migration.  It's still used briefly in the
prerm, but is then removed in the postrm, so it's present only
transiently.  And this is needed to avoid hosing your system during
migration to e.g. file-rc, so probably needs to be retained.

Does anyone have any comments as to the safety of this?


diff --git a/debian/sysv-rc.postinst b/debian/sysv-rc.postinst
index 8d6165c..8c54a544 100644
--- a/debian/sysv-rc.postinst
+++ b/debian/sysv-rc.postinst
@@ -8,7 +8,6 @@ db_version 2.0
 now=`date +%Y%m%dT%H%M`
 logdir=/var/lib/insserv
 logfile="$logdir/run-$now.log"
-flagfile=/etc/init.d/.legacy-bootordering
 
 # Make sure insserv is in path
 PATH=/sbin:$PATH
@@ -63,6 +62,16 @@ add_suggestion() {
     fi
 }
 
+legacy_bootordering() {
+    for f in /etc/rc0.d/S* ; do
+	if [ -f $f ] ; then
+	    return 0
+	fi
+    done
+
+    return 1
+}
+
 is_unsafe_to_activate() {
     retval=1
     # Refuse to convert when there are obsolete init.d scripts left
@@ -155,19 +164,9 @@ try_to_convert() {
 
 case "$1" in
     configure)
-	# Detect migrations away from file-rc, where the legacy boot
-	# ordering is used but the flag file to indicated legacy boot
-	# ordering is missing.  Can not do this in preinst, as preinst
-	# might be executed before the postinst of file-rc creatingthe
-	# files in /etc/rc?.d/.
-	for f in /etc/rc0.d/S* ; do
-	    if [ ! -f $flagfile ] && [ -f $f ] ; then
-		touch $flagfile
-		break
-	    fi
-	done
+	rm -f /etc/init.d/.legacy-bootordering
 
-	if [ -f $flagfile ] ; then
+	if legacy_bootordering ; then
 	    # Still using legacy ordering, try to convert
 	    if try_to_convert ; then
 		:
diff --git a/debian/sysv-rc.postrm b/debian/sysv-rc.postrm
index 036e492..087d705 100755
--- a/debian/sysv-rc.postrm
+++ b/debian/sysv-rc.postrm
@@ -29,8 +29,7 @@ if [ ! -e /usr/sbin/invoke-rc.d ] ; then
     ln -sf /usr/share/sysvinit/update-rc.d /usr/sbin/invoke-rc.d
 fi
 
-# Do not remove /etc/init.d/.legacy-bootordering, to allow those
-# taking over to know where to continue.
+rm -f /etc/init.d/.legacy-bootordering
 
 #DEBHELPER#
 


-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800





More information about the Pkg-sysvinit-devel mailing list