]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: define main through macro and call ask_password_agent_close() from the...
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Nov 2018 09:22:26 +0000 (10:22 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 21 Nov 2018 08:14:00 +0000 (09:14 +0100)
This doesn't save us anything, but I like consistency.

src/shared/main-func.h
src/systemctl/systemctl.c

index d8fd89df3c06e855f59d491d3b79941f60d7b7f4..a2b9bc09e00bccef6a60cbd12936938c1e9edcf8 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 
 #include "pager.h"
+#include "spawn-ask-password-agent.h"
 #include "spawn-polkit-agent.h"
 #include "static-destruct.h"
 
@@ -12,6 +13,7 @@
                 int r;                                                  \
                 r = impl(argc, argv);                                   \
                 static_destruct();                                      \
+                ask_password_agent_close();                             \
                 polkit_agent_close();                                   \
                 pager_close();                                          \
                 return ret;                                             \
index a54d5abebd624fe0710feac33330025921e131af..5292c648dfc0683abb4e2f73823cf59012eb0d40 100644 (file)
@@ -51,6 +51,7 @@
 #include "log.h"
 #include "logs-show.h"
 #include "macro.h"
+#include "main-func.h"
 #include "mkdir.h"
 #include "pager.h"
 #include "parse-util.h"
@@ -8648,7 +8649,7 @@ static int logind_cancel_shutdown(void) {
 #endif
 }
 
-int main(int argc, char*argv[]) {
+static int run(int argc, char*argv[]) {
         int r;
 
         argv_cmdline = argv[0];
@@ -8672,7 +8673,6 @@ int main(int argc, char*argv[]) {
                 goto finish;
 
         if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) {
-
                 if (!arg_quiet)
                         log_info("Running in chroot, ignoring request.");
                 r = 0;
@@ -8738,10 +8738,6 @@ int main(int argc, char*argv[]) {
 finish:
         release_busses();
 
-        pager_close();
-        ask_password_agent_close();
-        polkit_agent_close();
-
         strv_free(arg_types);
         strv_free(arg_states);
         strv_free(arg_properties);
@@ -8750,6 +8746,8 @@ finish:
         free(arg_root);
         free(arg_esp_path);
 
-        /* Note that we return r here, not EXIT_SUCCESS, so that we can implement the LSB-like return codes */
-        return r < 0 ? EXIT_FAILURE : r;
+        /* Note that we return r here, not 0, so that we can implement the LSB-like return codes */
+        return r;
 }
+
+DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);