chiark / gitweb /
dbus: fix serialization of calendar timers
[elogind.git] / src / core / dbus-manager.c
index 8a6449493a709544741e3261fcad964bbf7fd065..859fa1a90699bc348881eb2c25dd567eff0307df 100644 (file)
 
 #define BUS_MANAGER_INTERFACE_PROPERTIES_GENERAL                        \
         "  <property name=\"Version\" type=\"s\" access=\"read\"/>\n"   \
-        "  <property name=\"Distribution\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"Features\" type=\"s\" access=\"read\"/>\n"  \
         "  <property name=\"Tainted\" type=\"s\" access=\"read\"/>\n"   \
         "  <property name=\"FirmwareTimestamp\" type=\"t\" access=\"read\"/>\n" \
@@ -352,17 +351,21 @@ static int bus_manager_set_log_target(DBusMessageIter *i, const char *property,
 }
 
 static int bus_manager_append_log_level(DBusMessageIter *i, const char *property, void *data) {
-        const char *t;
+        char *t;
+        int r;
 
         assert(i);
         assert(property);
 
-        t = log_level_to_string(log_get_max_level());
+        r = log_level_to_string_alloc(log_get_max_level(), &t);
+        if (r < 0)
+                return r;
 
         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
-                return -ENOMEM;
+                r = -ENOMEM;
 
-        return 0;
+        free(t);
+        return r;
 }
 
 static int bus_manager_set_log_level(DBusMessageIter *i, const char *property, void *data) {
@@ -522,13 +525,11 @@ static int bus_manager_set_runtime_watchdog_usec(DBusMessageIter *i, const char
 
 static const char systemd_property_string[] =
         PACKAGE_STRING "\0"
-        DISTRIBUTION "\0"
         SYSTEMD_FEATURES;
 
 static const BusProperty bus_systemd_properties[] = {
-        { "Version",       bus_property_append_string,    "s",  0                                             },
-        { "Distribution",  bus_property_append_string,    "s",  sizeof(PACKAGE_STRING)                        },
-        { "Features",      bus_property_append_string,    "s",  sizeof(PACKAGE_STRING) + sizeof(DISTRIBUTION) },
+        { "Version",       bus_property_append_string,    "s",  0                      },
+        { "Features",      bus_property_append_string,    "s",  sizeof(PACKAGE_STRING) },
         { NULL, }
 };
 
@@ -641,7 +642,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                         goto oom;
 
                 path = unit_dbus_path(u);
-                if (!reply)
+                if (!path)
                         goto oom;
 
                 if (!dbus_message_append_args(
@@ -736,7 +737,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 if (r < 0)
                         return bus_send_error_reply(connection, message, &error, r);
 
-                if (!(reply = dbus_message_new_method_return(message)))
+                reply = dbus_message_new_method_return(message);
+                if (!reply)
                         goto oom;
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetJob")) {
@@ -1354,7 +1356,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 if (!e)
                         goto oom;
 
-                if (!(reply = dbus_message_new_method_return(message))) {
+                reply = dbus_message_new_method_return(message);
+                if (!reply) {
                         strv_free(e);
                         goto oom;
                 }
@@ -1406,7 +1409,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 if (!f)
                         goto oom;
 
-                if (!(reply = dbus_message_new_method_return(message))) {
+                reply = dbus_message_new_method_return(message);
+                if (!reply) {
                         strv_free(f);
                         goto oom;
                 }
@@ -1432,7 +1436,6 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h);
                 if (r < 0) {
                         unit_file_list_free(h);
-                        dbus_message_unref(reply);
                         return bus_send_error_reply(connection, message, NULL, r);
                 }