summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2011-07-02 23:09:59 +0200
committerMichal Schmidt <mschmidt@redhat.com>2011-07-03 00:12:16 +0200
commit52c002150a34c07a59369ee952bcd3a1f8f316ca (patch)
tree8bf5fb00378c1d38e5a5a31abfa46626941cdb67
parent1a63987788624a8819b94b199aa6748665f5e957 (diff)
shutdown: respect the dry run option '-k'
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
-rw-r--r--src/shutdownd.c2
-rw-r--r--src/shutdownd.h1
-rw-r--r--src/systemctl.c6
3 files changed, 6 insertions, 3 deletions
diff --git a/src/shutdownd.c b/src/shutdownd.c
index 13819417c3..7fd9573b2f 100644
--- a/src/shutdownd.c
+++ b/src/shutdownd.c
@@ -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] = '-';
diff --git a/src/shutdownd.h b/src/shutdownd.h
index ed8a704b1c..4581649733 100644
--- a/src/shutdownd.h
+++ b/src/shutdownd.h
@@ -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
diff --git a/src/systemctl.c b/src/systemctl.c
index b584e7032b..8f904c16c2 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -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: