From 1279a751a046db2b8c001a11e3a4ad3359d33533 Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Sun, 26 Oct 2014 11:39:40 -0400 Subject: src/shared/selinux-util.c: add path_is_absolute() check Signed-off-by: Anthony G. Basile --- src/shared/selinux-util.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/shared') 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 #include #include + #ifdef HAVE_SELINUX #include #include @@ -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) { -- cgit v1.2.3-54-g00ecf