]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/selinux-util.c
label: rework label_fix() implementations (#8583)
authorLennart Poettering <lennart@poettering.net>
Tue, 27 Mar 2018 05:38:26 +0000 (07:38 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 27 Mar 2018 05:38:26 +0000 (07:38 +0200)
commit08c849815c8db19ab0ab1ca226354d4a104041f0
tree8e7004dc8d46fd9f5ddbca3d9f855b7c83433653
parentffb3c2bd705409ca5bbbb9ccef4c59349ea787cf
label: rework label_fix() implementations (#8583)

This reworks the SELinux and SMACK label fixing calls in a number of
ways:

1. The two separate boolean arguments of these functions are converted
   into a flags type LabelFixFlags.

2. The operations are now implemented based on O_PATH. This should
   resolve TTOCTTOU races between determining the label for the file
   system object and applying it, as it it allows to pin the object
   while we are operating on it.

3. When changing a label fails we'll query the label previously set, and
   if matches what we want to set anyway we'll suppress the error.

Also, all calls to label_fix() are now (void)ified, when we ignore the
return values.

Fixes: #8566
14 files changed:
src/basic/label.c
src/basic/label.h
src/basic/mkdir-label.c
src/basic/selinux-util.c
src/basic/selinux-util.h
src/basic/smack-util.c
src/basic/smack-util.h
src/core/automount.c
src/core/mount-setup.c
src/hwdb/hwdb.c
src/login/logind-user.c
src/tmpfiles/tmpfiles.c
src/udev/udev-node.c
src/udev/udevadm-hwdb.c