summaryrefslogtreecommitdiff
path: root/src/dbus-manager.c
diff options
context:
space:
mode:
authorAndrey Borzenkov <arvidjaar@gmail.com>2011-03-06 19:17:02 +0300
committerLennart Poettering <lennart@poettering.net>2011-03-07 02:17:31 +0100
commitc826cda421f0272275342173e16250adcdf6fbd4 (patch)
treed9b8ad25728a1958b6615738e083768bf764e15e /src/dbus-manager.c
parentb4353094e5097c0cb149b5adcffe2a6ba9240283 (diff)
add org.freedesktop.DBus.Properies.Set method
The patch adds framework for processing Set requests on properties and as first consumers allows setting of LogTarget and LogLevel on interface org.freedesktop.systemd1.Manager of org.freedesktop.systemd1. The code should be generic enough to allow processing of any property on other objects and interfaces as well. No systemctl visible interface is added so far. The LogTarget and LogLevel are meant for debugging in the first place; user interface can be added if other usage emerge. Set on systemwide systemd is restricted to root; I am not sure how session level access is controlled.
Diffstat (limited to 'src/dbus-manager.c')
-rw-r--r--src/dbus-manager.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 1a587197a5..7d4703b88b 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -156,8 +156,8 @@
" <property name=\"InitRDTimestamp\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"StartupTimestamp\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"FinishTimestamp\" type=\"t\" access=\"read\"/>\n" \
- " <property name=\"LogLevel\" type=\"s\" access=\"read\"/>\n" \
- " <property name=\"LogTarget\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"LogLevel\" type=\"s\" access=\"readwrite\"/>\n" \
+ " <property name=\"LogTarget\" type=\"s\" access=\"readwrite\"/>\n" \
" <property name=\"NNames\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"NJobs\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"NInstalledJobs\" type=\"u\" access=\"read\"/>\n" \
@@ -252,6 +252,18 @@ static int bus_manager_append_log_target(Manager *m, DBusMessageIter *i, const c
return 0;
}
+static int bus_manager_set_log_target(Manager *m, DBusMessageIter *i, const char *property) {
+ const char *t;
+
+ assert(m);
+ assert(i);
+ assert(property);
+
+ dbus_message_iter_get_basic(i, &t);
+
+ return log_set_target_from_string(t);
+}
+
static int bus_manager_append_log_level(Manager *m, DBusMessageIter *i, const char *property, void *data) {
const char *t;
@@ -267,6 +279,18 @@ static int bus_manager_append_log_level(Manager *m, DBusMessageIter *i, const ch
return 0;
}
+static int bus_manager_set_log_level(Manager *m, DBusMessageIter *i, const char *property) {
+ const char *t;
+
+ assert(m);
+ assert(i);
+ assert(property);
+
+ dbus_message_iter_get_basic(i, &t);
+
+ return log_set_max_level_from_string(t);
+}
+
static int bus_manager_append_n_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
uint32_t u;
@@ -341,8 +365,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "InitRDTimestamp", bus_property_append_uint64, "t", &m->initrd_timestamp.realtime },
{ "org.freedesktop.systemd1.Manager", "StartupTimestamp", bus_property_append_uint64, "t", &m->startup_timestamp.realtime },
{ "org.freedesktop.systemd1.Manager", "FinishTimestamp", bus_property_append_uint64, "t", &m->finish_timestamp.realtime },
- { "org.freedesktop.systemd1.Manager", "LogLevel", bus_manager_append_log_level, "s", NULL },
- { "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL },
+ { "org.freedesktop.systemd1.Manager", "LogLevel", bus_manager_append_log_level, "s", NULL, bus_manager_set_log_level},
+ { "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL, bus_manager_set_log_target},
{ "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NInstalledJobs",bus_property_append_uint32, "u", &m->n_installed_jobs },