diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2014-10-26 11:39:40 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-10-26 11:39:40 -0400 |
commit | 1279a751a046db2b8c001a11e3a4ad3359d33533 (patch) | |
tree | e5024eb1bf0e0332f784af9756e6dbbd4aef7a8d | |
parent | abf869c4168fedffd0f992d2f215a924258c294b (diff) |
src/shared/selinux-util.c: add path_is_absolute() check
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-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) { |