anitazha / rpms / systemd

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