[systemd-commits] 2 commits - TODO src/locale src/login src/run

Lennart Poettering lennart at kemper.freedesktop.org
Fri Nov 8 19:50:00 CET 2013


 TODO                   |    4 +++-
 src/locale/localectl.c |    6 +++---
 src/login/pam-module.c |   13 +++----------
 src/run/run.c          |   27 +++++++++++++++++----------
 4 files changed, 26 insertions(+), 24 deletions(-)

New commits:
commit 8159d91a9c92aaee66d450ab0daff88f6e1a42b3
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 8 19:49:49 2013 +0100

    bus: port remaining code over to use bus_error_message()

diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index f469244..1975d80 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -40,6 +40,7 @@
 #include "def.h"
 #include "socket-util.h"
 #include "fileio.h"
+#include "bus-error.h"
 
 static int parse_argv(pam_handle_t *handle,
                       int argc, const char **argv,
@@ -355,11 +356,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                                remote_host,
                                0);
         if (r < 0) {
-                pam_syslog(handle, LOG_ERR, "Failed to communicate with systemd-logind: %s", strerror(-r));
-                if (error.name || error.message)
-                        pam_syslog(handle, LOG_ERR, "systemd-logind returned %s: %s",
-                                   error.name ?: "unknown error",
-                                   error.message ?: "no message");
+                pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));
                 return PAM_SYSTEM_ERR;
         }
 
@@ -482,11 +479,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                                        id);
                 if (r < 0) {
                         pam_syslog(handle, LOG_ERR,
-                                   "Failed to release session: %s", strerror(-r));
-                        if (error.name || error.message)
-                                pam_syslog(handle, LOG_ERR, "systemd-logind returned %s: %s",
-                                           error.name ?: "unknown error",
-                                           error.message ?: "no message");
+                                   "Failed to release session: %s", bus_error_message(&error, r));
 
                         r = PAM_SESSION_ERR;
                         goto finish;
diff --git a/src/run/run.c b/src/run/run.c
index f4c7005..1eeb5c6 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -178,6 +178,10 @@ static int message_start_transient_unit_new(sd_bus *bus, const char *name, sd_bu
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         int r;
 
+        assert(bus);
+        assert(name);
+        assert(ret);
+
         log_info("Running as unit %s.", name);
 
         r = sd_bus_message_new_method_call(
@@ -226,6 +230,9 @@ static int message_start_transient_unit_new(sd_bus *bus, const char *name, sd_bu
 static int message_start_transient_unit_send(sd_bus *bus, sd_bus_message *m, sd_bus_error *error, sd_bus_message **reply) {
         int r;
 
+        assert(bus);
+        assert(m);
+
         r = sd_bus_message_close_container(m);
         if (r < 0)
                 return r;
@@ -238,7 +245,7 @@ static int start_transient_service(
                 char **argv,
                 sd_bus_error *error) {
 
-        _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
+        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         _cleanup_free_ char *name = NULL;
         char **i;
         int r;
@@ -316,7 +323,7 @@ static int start_transient_service(
         if (r < 0)
                 return r;
 
-        return  message_start_transient_unit_send(bus, m, error, &reply);
+        return message_start_transient_unit_send(bus, m, error, NULL);
 }
 
 static int start_transient_scope(
@@ -324,10 +331,12 @@ static int start_transient_scope(
                 char **argv,
                 sd_bus_error *error) {
 
-        _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
+        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         _cleanup_free_ char *name = NULL;
         int r;
 
+        assert(bus);
+
         if (arg_unit)
                 name = unit_name_mangle_with_suffix(arg_unit, ".scope");
         else
@@ -343,7 +352,7 @@ static int start_transient_scope(
         if (r < 0)
                 return r;
 
-        r = message_start_transient_unit_send(bus, m, error, &reply);
+        r = message_start_transient_unit_send(bus, m, error, NULL);
         if (r < 0)
                 return r;
 
@@ -353,7 +362,7 @@ static int start_transient_scope(
 }
 
 int main(int argc, char* argv[]) {
-        sd_bus_error error = SD_BUS_ERROR_NULL;
+        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         _cleanup_bus_unref_ sd_bus *bus = NULL;
         _cleanup_free_ char *description = NULL, *command = NULL;
         int r;
@@ -392,11 +401,8 @@ int main(int argc, char* argv[]) {
                 r = start_transient_scope(bus, argv + optind, &error);
         else
                 r = start_transient_service(bus, argv + optind, &error);
-        if (r < 0) {
-                log_error("Failed start transient unit: %s", error.message ? error.message : strerror(-r));
-                sd_bus_error_free(&error);
-                goto finish;
-        }
+        if (r < 0)
+                log_error("Failed start transient unit: %s", bus_error_message(&error, r));
 
 finish:
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;

commit 94676f3e9352cbf1f72e0a512ee0d2ed83ff676d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 8 19:48:42 2013 +0100

    localectl: port over to bus_log_create_error()

diff --git a/TODO b/TODO
index 9f83a24..38246f6 100644
--- a/TODO
+++ b/TODO
@@ -50,7 +50,9 @@ Features:
 
 * add field to transient units that indicate whether systemd or somebody else saves/restores its settings, for integration with libvirt
 
-* wait filter, unify dispatch table in systemctl_main() and friends, convert all to bus_log_create_error()
+* systemctl: rework wait filter to not require match callback
+
+* unify dispatch table in systemctl_main() and friends
 
 * bus: access policy as vtable flag
 
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 31deb67..ed66668 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -154,15 +154,15 @@ static int set_locale(sd_bus *bus, char **args, unsigned n) {
                         "org.freedesktop.locale1",
                         "SetLocale", &m);
         if (r < 0)
-                return r;
+                return bus_log_create_error(r);
 
         r = sd_bus_message_append_strv(m, args + 1);
         if (r < 0)
-                return r;
+                return bus_log_create_error(r);
 
         r = sd_bus_message_append(m, "b", arg_ask_password);
         if (r < 0)
-                return r;
+                return bus_log_create_error(r);
 
         r = sd_bus_send_with_reply_and_block(bus, m, 0, &error, NULL);
         if (r < 0) {
diff --git a/src/run/run.c b/src/run/run.c
index 3fb72e6..f4c7005 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -28,6 +28,7 @@
 #include "build.h"
 #include "unit-name.h"
 #include "path-util.h"
+#include "bus-error.h"
 
 static bool arg_scope = false;
 static bool arg_remain_after_exit = false;



More information about the systemd-commits mailing list