void-packages/srcpkgs/elogind/patches/001-fix-label-selinux.patch

65 lines
1.4 KiB
Diff

--- src/shared/label.c 2015-04-19 13:32:24.659347470 +0200
+++ src/shared/label.c 2017-03-04 13:41:05.953585324 +0100
@@ -25,9 +25,11 @@
#include "label.h"
int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
- int r, q;
+ int r = 0, q = 0;
+#ifdef HAVE_SELINUX
r = mac_selinux_fix(path, ignore_enoent, ignore_erofs);
+#endif
q = mac_smack_fix(path, ignore_enoent, ignore_erofs);
if (r < 0)
@@ -39,18 +41,22 @@
}
int mkdir_label(const char *path, mode_t mode) {
- int r;
+ int r = 0;
assert(path);
+#ifdef HAVE_SELINUX
r = mac_selinux_create_file_prepare(path, S_IFDIR);
if (r < 0)
return r;
+#endif
if (mkdir(path, mode) < 0)
r = -errno;
+#ifdef HAVE_SELINUX
mac_selinux_create_file_clear();
+#endif
if (r < 0)
return r;
@@ -59,19 +65,23 @@
}
int symlink_label(const char *old_path, const char *new_path) {
- int r;
+ int r = 0;
assert(old_path);
assert(new_path);
+#ifdef HAVE_SELINUX
r = mac_selinux_create_file_prepare(new_path, S_IFLNK);
if (r < 0)
return r;
+#endif
if (symlink(old_path, new_path) < 0)
r = -errno;
+#ifdef HAVE_SELINUX
mac_selinux_create_file_clear();
+#endif
if (r < 0)
return r;