]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: do not unnecessarily chmod utab.lock
authorTycho Andersen <tycho@tycho.ws>
Thu, 9 Jan 2020 23:52:41 +0000 (16:52 -0700)
committerKarel Zak <kzak@redhat.com>
Fri, 15 May 2020 10:18:18 +0000 (12:18 +0200)
commitb42a2c0f6d812e43ac8df142d3eb0890ef201a3a
tree6f2bd21ccfab99a64fc34ff8e3d37de1392285b6
parent24fa7d60ea0b5838b5eaef2a0455fca4adfadeda
libmount: do not unnecessarily chmod utab.lock

Before ecfeae90a294 ("libmount: Ensure utab.lock mode 644"), you could do
something like:

irc:/tmp umount --version
umount from util-linux 2.27.1 (libmount 2.27.0: selinux, assert, debug)
irc:/tmp mkdir foo bar
irc:/tmp unshare -Urm
irc:/tmp mount --bind foo bar
irc:/tmp umount bar
irc:/tmp echo $?
0

However, afterwards, you get:

/tmp unshare -Urm
/tmp mount --bind foo bar
/tmp umount bar
umount: /tmp/bar: filesystem was unmounted, but failed to update userspace mount table.

Because of the chmod failing:

fchmod(3, 0644)                         = -1 EPERM (Operation not permitted)

Let's figure out whether the chmod is necessary before doing it, and only
do it if it is necessary. This won't fix cases where the system is already
broken, but at least on healthy systems umount will behave as before.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
libmount/src/lock.c