summaryrefslogtreecommitdiff
path: root/src/hostname/hostnamed.c
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-02-14 12:26:13 +0100
committerHarald Hoyer <harald@redhat.com>2013-02-14 16:19:38 +0100
commita5c32cff1f56afe6f0c6c70d91a88a7a8238b2d7 (patch)
treeb3cc19cede403ac324f56c54ca89db0feef2a72d /src/hostname/hostnamed.c
parentedc211f314f257921eb3599b5dca8d51984b9328 (diff)
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
Diffstat (limited to 'src/hostname/hostnamed.c')
-rw-r--r--src/hostname/hostnamed.c8
1 files changed, 5 insertions, 3 deletions
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 \
" <interface name=\"org.freedesktop.hostname1\">\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