summaryrefslogtreecommitdiff
path: root/src/basic/smack-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-03-27 07:38:26 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-03-27 07:38:26 +0200
commit08c849815c8db19ab0ab1ca226354d4a104041f0 (patch)
tree8e7004dc8d46fd9f5ddbca3d9f855b7c83433653 /src/basic/smack-util.h
parentffb3c2bd705409ca5bbbb9ccef4c59349ea787cf (diff)
downloadsystemd-08c849815c8db19ab0ab1ca226354d4a104041f0.tar.gz
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
Diffstat (limited to 'src/basic/smack-util.h')
-rw-r--r--src/basic/smack-util.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/basic/smack-util.h b/src/basic/smack-util.h
index e4d46d7736..58e6a548b6 100644
--- a/src/basic/smack-util.h
+++ b/src/basic/smack-util.h
@@ -25,25 +25,26 @@
#include <stdbool.h>
#include <sys/types.h>
+#include "label.h"
#include "macro.h"
#define SMACK_FLOOR_LABEL "_"
#define SMACK_STAR_LABEL "*"
typedef enum SmackAttr {
- SMACK_ATTR_ACCESS = 0,
- SMACK_ATTR_EXEC = 1,
- SMACK_ATTR_MMAP = 2,
- SMACK_ATTR_TRANSMUTE = 3,
- SMACK_ATTR_IPIN = 4,
- SMACK_ATTR_IPOUT = 5,
+ SMACK_ATTR_ACCESS,
+ SMACK_ATTR_EXEC,
+ SMACK_ATTR_MMAP,
+ SMACK_ATTR_TRANSMUTE,
+ SMACK_ATTR_IPIN,
+ SMACK_ATTR_IPOUT,
_SMACK_ATTR_MAX,
_SMACK_ATTR_INVALID = -1,
} SmackAttr;
bool mac_smack_use(void);
-int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs);
+int mac_smack_fix(const char *path, LabelFixFlags flags);
const char* smack_attr_to_string(SmackAttr i) _const_;
SmackAttr smack_attr_from_string(const char *s) _pure_;