]> err.no Git - systemd/commitdiff
shutdown: respect the dry run option '-k'
authorMichal Schmidt <mschmidt@redhat.com>
Sat, 2 Jul 2011 21:09:59 +0000 (23:09 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Sat, 2 Jul 2011 22:12:16 +0000 (00:12 +0200)
Don't do the actual power-off/reboot when '-k' is passed to shutdown.

Related to: https://bugzilla.redhat.com/show_bug.cgi?id=624149

src/shutdownd.c
src/shutdownd.h
src/systemctl.c

index 13819417c3f5da1047aad14c5b9c129a909b894c..7fd9573b2fa30ba425241857ae2f2f16bb2ada10 100644 (file)
@@ -348,7 +348,7 @@ finish:
         if (unlink_nologin)
                 unlink("/run/nologin");
 
-        if (exec_shutdown) {
+        if (exec_shutdown && !c.dry_run) {
                 char sw[3];
 
                 sw[0] = '-';
index ed8a704b1cd48db21eb1929200bf7368f5025e25..4581649733dd50395f1cc7dee0866879cd68441b 100644 (file)
@@ -33,6 +33,7 @@ _packed_ struct shutdownd_command {
         char mode; /* H, P, r, i.e. the switches usually passed to
                     * shutdown to select whether to halt, power-off or
                     * reboot the machine */
+        bool dry_run;
         bool warn_wall;
 
         /* Yepp, sometimes we are lazy and use fixed-size strings like
index b584e7032b9558672b5424d854096ffdaf974a6e..8f904c16c2026bae68cb63c886ce8de173e2aea9 100644 (file)
@@ -5422,7 +5422,7 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
         return verbs[i].dispatch(bus, argv + optind, left);
 }
 
-static int send_shutdownd(usec_t t, char mode, bool warn, const char *message) {
+static int send_shutdownd(usec_t t, char mode, bool dry_run, bool warn, const char *message) {
         int fd = -1;
         struct msghdr msghdr;
         struct iovec iovec;
@@ -5432,6 +5432,7 @@ static int send_shutdownd(usec_t t, char mode, bool warn, const char *message) {
         zero(c);
         c.elapse = t;
         c.mode = mode;
+        c.dry_run = dry_run;
         c.warn_wall = warn;
 
         if (message)
@@ -5527,6 +5528,7 @@ static int halt_main(DBusConnection *bus) {
                                    arg_action == ACTION_HALT     ? 'H' :
                                    arg_action == ACTION_POWEROFF ? 'P' :
                                                                    'r',
+                                   arg_dry,
                                    !arg_no_wall,
                                    m);
                 free(m);
@@ -5774,7 +5776,7 @@ int main(int argc, char*argv[]) {
                 break;
 
         case ACTION_CANCEL_SHUTDOWN:
-                r = send_shutdownd(0, 0, false, NULL);
+                r = send_shutdownd(0, 0, false, false, NULL);
                 break;
 
         case ACTION_INVALID: