#include "polkit.h"
#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" \
return 0;
}
-
- return write_one_line_file_atomic("/etc/hostname", data[PROP_STATIC_HOSTNAME]);
+ return write_string_file_atomic_label("/etc/hostname", data[PROP_STATIC_HOSTNAME]);
}
static int write_data_other(void) {
char **l = NULL;
int r, p;
- r = load_env_file("/etc/machine-info", &l);
+ r = load_env_file("/etc/machine-info", NULL, &l);
if (r < 0 && r != -ENOENT)
return r;
return 0;
}
- r = write_env_file("/etc/machine-info", l);
+ r = write_env_file_label("/etc/machine-info", l);
strv_free(l);
return r;
return bus_send_error_reply(connection, message, NULL, r);
}
- log_info("Changed host name to '%s'", strempty(data[PROP_HOSTNAME]));
+ log_info("Changed host name to '%s'", strna(data[PROP_HOSTNAME]));
changed = bus_properties_changed_new(
"/org/freedesktop/hostname1",
return bus_send_error_reply(connection, message, NULL, r);
}
- log_info("Changed static host name to '%s'", strempty(data[PROP_STATIC_HOSTNAME]));
+ log_info("Changed static host name to '%s'", strna(data[PROP_STATIC_HOSTNAME]));
changed = bus_properties_changed_new(
"/org/freedesktop/hostname1",
* safe than sorry */
if (k == PROP_ICON_NAME && !filename_is_safe(name))
return bus_send_error_reply(connection, message, NULL, -EINVAL);
- if (k == PROP_PRETTY_HOSTNAME && !string_is_safe(name))
+ if (k == PROP_PRETTY_HOSTNAME && string_has_cc(name))
return bus_send_error_reply(connection, message, NULL, -EINVAL);
if (k == PROP_CHASSIS && !valid_chassis(name))
return bus_send_error_reply(connection, message, NULL, -EINVAL);
log_info("Changed %s to '%s'",
k == PROP_PRETTY_HOSTNAME ? "pretty host name" :
- k == PROP_CHASSIS ? "chassis" : "icon name", strempty(data[k]));
+ k == PROP_CHASSIS ? "chassis" : "icon name", strna(data[k]));
changed = bus_properties_changed_new(
"/org/freedesktop/hostname1",
if (!reply)
goto oom;
- if (!dbus_connection_send(connection, reply, NULL))
+ if (!bus_maybe_send_reply(connection, message, reply))
goto oom;
dbus_message_unref(reply);
log_open();
umask(0022);
+ label_init("/etc");
if (argc == 2 && streq(argv[1], "--introspect")) {
fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE