[Pkg-sysvinit-devel] Bug#504877: initscripts.postinst fails when run as non-privileged user on systems without /dev/shm or /dev/pts

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Nov 7 19:00:46 UTC 2008


Package: initscripts
Version: 2.86.ds1-61
Severity: normal
Tags: patch

I think that initscripts.postinst should not fail if an attempt to
create /dev/shm or /dev/pts fails.  Here's why:

One of the goals of debootstrap is that it can set up a system in
"fakechroot" mode, where it is run as an entirely non-privileged user.
In this mode, the "real" /dev is linked into the chroot'ed /dev, so
that something that looks like real devices can be present during the
install.

On systems without a dynamically-generated /dev, initscripts.postinst
looks to see if /dev/pts and /dev/shm exist, and tries to create them
if they do not.  The postinst script itself fails if it is unable to
create these directories, resulting in a failed package installation,
resulting in turn in a failed debootstrap.

Instead, i think initscripts.postinst should alert with a warning, but
should not explicitly fail (especially when run within this fakechroot
debootstrap mode).  One model for this behavior is makedev.postinst,
which explicitly does "set +e", and is willing to fail (though it
prints warnings).

OK: this is a corner case of a corner case, but i've run into a
situation where this is crucial:

 * i'm running from within a vserver, which currently by default does
   not have /dev/shm (see #540780), and does not have a
   dynamically-generated /dev tree.  This triggers the relevant bit of
   code in initcripts.postinst.

 * i'm trying to do a debootstrap under fakeroot and fakechroot as a
   completely non-privileged user (for creating a debirf [0] image).

In this use case (one i'd really like to be able to support), the
debootstrap attempt bombs out when the initscripts package fails to
install.

The following simple patch should work, though i welcome any more
sophisticated approaches (e.g. testing for fakechroot to make a more
minimal exception, etc):

--- initscripts.postinst.orig	2008-11-07 13:56:12.975818014 -0500
+++ initscripts.postinst	2008-11-07 13:57:41.915810091 -0500
@@ -280,8 +280,8 @@
 	#
 	if ! mountpoint -q /dev
 	then
-		[ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts ; }
-		[ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm ; }
+		[ -d /dev/pts ] || { mkdir --mode=755 /dev/pts && chown root:root /dev/pts || true; }
+		[ -d /dev/shm ] || { mkdir --mode=755 /dev/shm && chown root:root /dev/shm || true; }
 	fi
 fi
 

Thanks for maintaining initscripts in debian!

Regards,

        --dkg

[0] http://cmrg.fifthhorseman.net/wiki/debirf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 826 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20081107/4c36c380/attachment.pgp 


More information about the Pkg-sysvinit-devel mailing list