teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0339-hwdb-selinuxify-a-bit-3460.patch

803fb7
From ca82178b166ae5fb8efe4b09aadae802534cf6e3 Mon Sep 17 00:00:00 2001
803fb7
From: Evgeny Vereshchagin <evvers@ya.ru>
803fb7
Date: Tue, 7 Jun 2016 20:47:41 +0300
803fb7
Subject: [PATCH] hwdb: selinuxify a bit (#3460)
803fb7
803fb7
-bash-4.3# rm /etc/udev/hwdb.bin
803fb7
-bash-4.3# systemd-hwdb update
803fb7
-bash-4.3# ls -Z /etc/udev/hwdb.bin
803fb7
system_u:object_r:systemd_hwdb_etc_t:s0 /etc/udev/hwdb.bin
803fb7
803fb7
Fixes: #3458
803fb7
803fb7
(cherry picked from commit ea683512f9b82f2257770f0ed56d819eea230fc2)
803fb7
Resolves: #1343648
803fb7
---
803fb7
 Makefile.am     | 1 +
803fb7
 src/hwdb/hwdb.c | 8 ++++++--
803fb7
 2 files changed, 7 insertions(+), 2 deletions(-)
803fb7
803fb7
diff --git a/Makefile.am b/Makefile.am
803fb7
index b0a34b212..3848338a2 100644
803fb7
--- a/Makefile.am
803fb7
+++ b/Makefile.am
803fb7
@@ -3752,6 +3752,7 @@ systemd_hwdb_SOURCES = \
803fb7
 	src/hwdb/hwdb.c
803fb7
 
803fb7
 systemd_hwdb_LDADD = \
803fb7
+	libsystemd-label.la \
803fb7
 	libsystemd-shared.la \
803fb7
 	libsystemd-internal.la \
803fb7
 	libudev-internal.la
803fb7
diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c
803fb7
index 4539673ea..8e5d6cc86 100644
803fb7
--- a/src/hwdb/hwdb.c
803fb7
+++ b/src/hwdb/hwdb.c
803fb7
@@ -34,6 +34,8 @@
803fb7
 
803fb7
 #include "hwdb-internal.h"
803fb7
 #include "hwdb-util.h"
803fb7
+#include "label.h"
803fb7
+#include "selinux-util.h"
803fb7
 
803fb7
 /*
803fb7
  * Generic udev properties, key/value database based on modalias strings.
803fb7
@@ -642,12 +644,12 @@ static int hwdb_update(int argc, char *argv[], void *userdata) {
803fb7
         if (!hwdb_bin)
803fb7
                 return -ENOMEM;
803fb7
 
803fb7
-        mkdir_parents(hwdb_bin, 0755);
803fb7
+        mkdir_parents_label(hwdb_bin, 0755);
803fb7
         r = trie_store(trie, hwdb_bin);
803fb7
         if (r < 0)
803fb7
                 return log_error_errno(r, "Failure writing database %s: %m", hwdb_bin);
803fb7
 
803fb7
-        return 0;
803fb7
+        return label_fix(hwdb_bin, false, false);
803fb7
 }
803fb7
 
803fb7
 static void help(void) {
803fb7
@@ -733,6 +735,8 @@ int main (int argc, char *argv[]) {
803fb7
         if (r <= 0)
803fb7
                 goto finish;
803fb7
 
803fb7
+        mac_selinux_init(NULL);
803fb7
+
803fb7
         r = hwdb_main(argc, argv);
803fb7
 
803fb7
 finish: