Bug#397525: initscripts: Remove extra fd usage from mtab init script

2006-11-26 Thread Petter Reinholdtsen
[David Härdeman]
 the attached patch changes the initscripts mtab script to not use an
 extra fd when processing /proc/mounts. This makes SELinux happier as
 the extra fds aren't leaked to the utils that are executed later.

Sounds like a good idea, but I would like to know if it affect the
runtime behaviour or not.

 I must admit though that I didn't really understand why the fd9
 trick was used in the first place?

It is an optimization, to reduce the number of forks needed during
boot.  Will your version increase the number of forks needed?

Friendly,
-- 
Petter Reinholdtsen



Bug#397525: initscripts: Remove extra fd usage from mtab init script

2006-11-07 Thread David Härdeman

Package: initscripts
Version: 2.86.ds1-34
Severity: minor
Tags: patch

Hi,

the attached patch changes the initscripts mtab script to not use an 
extra fd when processing /proc/mounts. This makes SELinux happier as the 
extra fds aren't leaked to the utils that are executed later.


I must admit though that I didn't really understand why the fd9 trick 
was used in the first place?


--
David Härdeman
diff -ur ./sysvinit-2.86.ds1.orig/debian/initscripts/etc/init.d/mtab.sh 
./sysvinit-2.86.ds1/debian/initscripts/etc/init.d/mtab.sh
--- ./sysvinit-2.86.ds1.orig/debian/initscripts/etc/init.d/mtab.sh  
2006-11-07 23:49:09.0 +0100
+++ ./sysvinit-2.86.ds1/debian/initscripts/etc/init.d/mtab.sh   2006-11-07 
23:50:05.0 +0100
@@ -44,7 +44,7 @@
fi
 
# Not mounted?
-   if ! mountpoint -q $2
+   if ! mountpoint -q $2  /dev/null
then
return
fi
@@ -57,9 +57,9 @@
fi
 
# Already recorded?
-   if ! grep -E -sq ^([^ ]+) +$2 + /etc/mtab
+   if ! grep -E -sq ^([^ ]+) +$2 + /etc/mtab  /dev/null
then
-   mount -f -t $1 $OPTS $4 $NAME $2
+   mount -f -t $1 $OPTS $4 $NAME $2  /dev/null
fi
 }
 
@@ -141,7 +141,6 @@
 
# Add everything else in /proc/mounts into /etc/mtab, with
# special exceptions.
-   exec 90 0/proc/mounts
while read FDEV FDIR FTYPE FOPTS REST
do
case $FDIR in
@@ -156,8 +155,7 @@
;;
esac
domtab $FTYPE $FDIR $FDEV -o$FOPTS
-   done
-   exec 09 9-
+   done  /proc/mounts
 }
 
 case $1 in