systemd/0148-timedated-correctly-set-context-on-etc-localtime.patch
Zbigniew Jędrzejewski-Szmek a48f80c6e3 More patches
2015-05-20 01:34:58 -04:00

71 lines
2.3 KiB
Diff

From 22eade6dd8422ba6d044c265f0620e3ebb900320 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 5 May 2015 16:35:34 -0400
Subject: [PATCH] timedated: correctly set context on /etc/localtime
https://bugzilla.redhat.com/show_bug.cgi?id=1190377
(cherry picked from commit fad44453ec789f49529ea5244b2c2e4d5ad1d420)
---
src/shared/label.c | 18 ++++++++++++++++++
src/shared/label.h | 1 +
src/timedate/timedated.c | 4 +++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/shared/label.c b/src/shared/label.c
index 82f10b21bd..7d0a6bc7ca 100644
--- a/src/shared/label.c
+++ b/src/shared/label.c
@@ -78,3 +78,21 @@ int symlink_label(const char *old_path, const char *new_path) {
return mac_smack_fix(new_path, false, false);
}
+
+int symlink_label_atomic(const char *old_path, const char *new_path) {
+ int r;
+
+ assert(old_path);
+ assert(new_path);
+
+ r = mac_selinux_create_file_prepare(new_path, S_IFLNK);
+ if (r < 0)
+ return r;
+
+ r = symlink_atomic(old_path, new_path);
+ mac_selinux_create_file_clear();
+ if (r < 0)
+ return r;
+
+ return mac_smack_fix(new_path, false, false);
+}
diff --git a/src/shared/label.h b/src/shared/label.h
index 8070bcb021..793596409b 100644
--- a/src/shared/label.h
+++ b/src/shared/label.h
@@ -28,3 +28,4 @@ int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs);
int mkdir_label(const char *path, mode_t mode);
int symlink_label(const char *old_path, const char *new_path);
+int symlink_label_atomic(const char *old_path, const char *new_path);
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index f2d23f34b1..01ab9c98c7 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -34,6 +34,7 @@
#include "clock-util.h"
#include "conf-files.h"
#include "path-util.h"
+#include "label.h"
#include "fileio-label.h"
#include "label.h"
#include "bus-util.h"
@@ -123,7 +124,8 @@ static int context_write_data_timezone(Context *c) {
if (!p)
return log_oom();
- r = symlink_atomic(p, "/etc/localtime");
+ mac_selinux_init("/etc");
+ r = symlink_label_atomic(p, "/etc/localtime");
if (r < 0)
return r;