mtab: move toward requiring /etc/mtab to be a symbolic link
This changes the mtab service in the following way: - If /etc/mtab is a symbolic link, success is returned. - If /etc is not writable, we warn that we could not update /etc/mtab and return success. - If /etc/mtab does not exist, we create a symbolic link from /etc/mtab to /proc/self/mounts. - Otherwise, we warn that updating /etc/mtab as a file is deprecated and continue to update it after outputting instructions to the user for how to move it to a symbolic link.
This commit is contained in:
parent
a8c6dbac96
commit
a6391f44ee
@ -12,20 +12,20 @@ depend()
|
|||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
if [ -L /etc/mtab ]; then
|
[ -L /etc/mtab ] && return 0
|
||||||
return 0
|
local rc=0
|
||||||
fi
|
|
||||||
|
|
||||||
ebegin "Updating /etc/mtab"
|
ebegin "Updating /etc/mtab"
|
||||||
vewarn "The support for updating /etc/mtab as a file is"
|
if ! checkpath -W /etc; then
|
||||||
vewarn "deprecated and will be removed in the future."
|
rc=1
|
||||||
vewarn "Please run the following command as root on your system."
|
elif [ ! -e /etc/mtab ]; then
|
||||||
vewarn
|
ln -snf /proc/self/mounts /etc/mtab
|
||||||
vewarn "ln -snf /proc/self/mounts /etc/mtab"
|
else
|
||||||
if ! echo 2>/dev/null >/etc/mtab; then
|
ewarn "The support for updating /etc/mtab as a file is"
|
||||||
ewend 1 "/etc/mtab is not updateable"
|
ewarn "deprecated and will be removed in the future."
|
||||||
return 0
|
ewarn "Please run the following command as root on your system."
|
||||||
fi
|
ewarn
|
||||||
|
ewarn "ln -snf /proc/self/mounts /etc/mtab"
|
||||||
|
ewarn
|
||||||
|
|
||||||
# With / as tmpfs we cannot umount -at tmpfs in localmount as that
|
# With / as tmpfs we cannot umount -at tmpfs in localmount as that
|
||||||
# makes / readonly and dismounts all tmpfs even if in use which is
|
# makes / readonly and dismounts all tmpfs even if in use which is
|
||||||
@ -35,5 +35,7 @@ start()
|
|||||||
|
|
||||||
# Remove stale backups
|
# Remove stale backups
|
||||||
rm -f /etc/mtab~ /etc/mtab~~
|
rm -f /etc/mtab~ /etc/mtab~~
|
||||||
eend 0
|
fi
|
||||||
|
eend $rc "/etc is not writable; unable to create /etc/mtab"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user