]> git.ipfire.org Git - thirdparty/util-linux.git/commit - sys-utils/mount.c
mount, umount: restore environ[] after suid drop
authorKarel Zak <kzak@redhat.com>
Tue, 25 Aug 2020 08:48:29 +0000 (10:48 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 25 Aug 2020 08:48:29 +0000 (10:48 +0200)
commitf1f48270c92e6b14a5b4b0ea68d53c2f5fc8597c
tree12f43c704050f1c4ce3228b6d5a4acc572942bfe
parente113093ce94ac1145f9986e072746e8b6e8d0da9
mount, umount: restore environ[] after suid drop

The commands mount and umount sanitize environment variables as it
works with suid permissions by default. Since v2.36 it's possible
that the commands drop the permissions and continue as regular user.
It seems we also need to restore the original environ to keep things
consistent for users (e.g. HOME=).

The implementation is pretty simple -- it keeps in memory removed
variables and use it after switch to non-suid mode.

Addresses: https://github.com/karelzak/util-linux/issues/880
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/mount.c
sys-utils/umount.c