From a07e9cfb790f3f5f492f2ff895a9de65e2b00a09 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 24 Oct 2014 01:15:53 +0200
Subject: [PATCH] selinux: fix handling of relative paths when setting up
 create label

---
 src/shared/selinux-util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
index 4332c916fa1..1eddd17d279 100644
--- a/src/shared/selinux-util.c
+++ b/src/shared/selinux-util.c
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <malloc.h>
 #include <sys/un.h>
+
 #ifdef HAVE_SELINUX
 #include <selinux/selinux.h>
 #include <selinux/label.h>
@@ -328,7 +329,7 @@ int mac_selinux_create_file_prepare(const char *path, mode_t mode) {
                 if (!newpath)
                         return -ENOMEM;
 
-                r = selabel_lookup_raw(label_hnd, &filecon, newpath, S_IFDIR);
+                r = selabel_lookup_raw(label_hnd, &filecon, newpath, mode);
         }
 
         if (r < 0 && errno != ENOENT)