[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#4542: /etc/mtab should not be rm'd



Package: sysvinit
Version: 2.64-1

/etc/init.d/boot currently clears /etc/mtab like so:

	rm -f /etc/mtab /etc/mtab~ /etc/nologin /fastboot

This is a problem if /etc/mtab is in fact some sort of special file. In my
case, I'm using a kernel patch called the transname patch. In brief, it
lets multiple computers all mount the same root partition, and provides
context-dependent files. I have a /etc/mtab file that is used by my nfs
server. There's another file named /etc/mtab#host=box# that serves as the
mtab for a diskless client named box. Processes running on box see the
contents of /etc/mtab#host=box# whenever they open /etc/mtab.

The problem comes when the boot script rm's /etc/mtab. If the script is
running on box, it actually removes /etc/mtab#host=box#. So there is no
longer a context-dependent mtab file, and so any programs running on
box now see the "real" /etc/mtab that kite uses, and all kinds of nasty
things get done to it since both computers are now using the same mtab
file.

My solution has been to modify init.d/boot and replace the line that rm's
mtab with the following:

# Mod for transname: don't delete /etc/mtab.
>/etc/mtab
rm -f /etc/mtab~ /etc/nologin /fastboot

This works quite well on my system, the mtab#host=box# file gets cleared,
but never unlinked. I don't see any problems with using this on all debian
systems, even those that don't use the transname patch. I suspect this
modification would also be useful on a system where /etc/mtab was
symlinked to /proc/mounts or something of the sort.

-- 
#!/usr/bin/perl -lisubstr($_,39+38*sin++$y/9,2)=$s # jeh22@cornell.edu
for($s='  '||McQ;$_='JOEY HESS 'x8;print){eval$^I} #         Joey Hess
      "How appropriate, you fight like a cow." - - Guybrush Threepwood



Reply to: