mtab: fix test for a link to a location in /proc

/etc/mtab can be a link to a file in /proc. If it is, we should not
attempt to update /etc/mtab.

The original test used "! -w" as part of the test.  This does not
work since everything is writeable by root.

Thanks to Robin Johnson for the suggestion of using readlink -f and the
regular expression.

Reported-By: junkmailnotread@yahoo.com
X-Gentoo-Bug: 370037
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=370037
This commit is contained in:
William Hubbs 2011-07-23 18:25:55 -05:00
parent 05c2d68192
commit 863ef36011

View File

@ -12,9 +12,10 @@ depend()
start()
{
# /etc/mtab could be a symlink to /proc/mounts
if [ ! -w /etc/mtab -a -L /etc/mtab ]; then
einfo "Skipping mtab update (non writeable symlink)"
# /etc/mtab could be a symlink to a location in /proc
if readlink -f /etc/mtab | grep -sq '^/proc/\(self\|[0-9]\+\)/mounts$'
then
einfo "Skipping mtab update (link points to location in /proc)"
return 0
fi