From a5c32cff1f56afe6f0c6c70d91a88a7a8238b2d7 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 14 Feb 2013 12:26:13 +0100 Subject: honor SELinux labels, when creating and writing config files Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577 --- src/hostname/hostnamectl.c | 1 + src/hostname/hostnamed.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/hostname') diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index ff1f091776..7945c86b5f 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -36,6 +36,7 @@ #include "strv.h" #include "sd-id128.h" #include "virt.h" +#include "fileio.h" static enum transport { TRANSPORT_NORMAL, diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index c5a8b6faaf..7ea891c681 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -33,6 +33,8 @@ #include "def.h" #include "virt.h" #include "env-util.h" +#include "fileio-label.h" +#include "label.h" #define INTERFACE \ " \n" \ @@ -287,8 +289,7 @@ static int write_data_static_hostname(void) { return 0; } - - return write_one_line_file_atomic("/etc/hostname", data[PROP_STATIC_HOSTNAME]); + return write_one_line_file_atomic_label("/etc/hostname", data[PROP_STATIC_HOSTNAME]); } static int write_data_other(void) { @@ -338,7 +339,7 @@ static int write_data_other(void) { return 0; } - r = write_env_file("/etc/machine-info", l); + r = write_env_file_label("/etc/machine-info", l); strv_free(l); return r; @@ -683,6 +684,7 @@ int main(int argc, char *argv[]) { log_open(); umask(0022); + label_init("/etc"); if (argc == 2 && streq(argv[1], "--introspect")) { fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE -- cgit v1.2.3-54-g00ecf