ryantimwilson / rpms / systemd

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