diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/selinux-util.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c index c4223240f9..e2ccef2865 100644 --- a/src/shared/selinux-util.c +++ b/src/shared/selinux-util.c @@ -21,6 +21,7 @@ #include <unistd.h> #include <malloc.h> #include <sys/un.h> + #ifdef HAVE_SELINUX #include <selinux/selinux.h> #include <selinux/label.h> @@ -317,7 +318,18 @@ int mac_selinux_create_file_prepare(const char *path, mode_t mode) { if (!label_hnd) return 0; - r = selabel_lookup_raw(label_hnd, &filecon, path, mode); + if (path_is_absolute(path)) + r = selabel_lookup_raw(label_hnd, &filecon, path, mode); + else { + _cleanup_free_ char *newpath; + + newpath = path_make_absolute_cwd(path); + if (!newpath) + return -ENOMEM; + + r = selabel_lookup_raw(label_hnd, &filecon, newpath, mode); + } + if (r < 0 && errno != ENOENT) r = -errno; else if (r == 0) { |