summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/selinux-util.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
index e2ccef2865..a374c277a8 100644
--- a/src/shared/selinux-util.c
+++ b/src/shared/selinux-util.c
@@ -330,9 +330,13 @@ int mac_selinux_create_file_prepare(const char *path, mode_t mode) {
r = selabel_lookup_raw(label_hnd, &filecon, newpath, mode);
}
- if (r < 0 && errno != ENOENT)
+ /* No context specified by the policy? Proceed without setting it. */
+ if (r < 0 && errno == ENOENT)
+ return 0;
+
+ if (r < 0)
r = -errno;
- else if (r == 0) {
+ else {
r = setfscreatecon(filecon);
if (r < 0) {
log_enforcing("Failed to set SELinux security context %s for %s: %m", filecon, path);