|
|
bbf564a |
From 52c002150a34c07a59369ee952bcd3a1f8f316ca Mon Sep 17 00:00:00 2001
|
|
|
bbf564a |
From: Michal Schmidt <mschmidt@redhat.com>
|
|
|
bbf564a |
Date: Sat, 2 Jul 2011 23:09:59 +0200
|
|
|
bbf564a |
Subject: [PATCH] shutdown: respect the dry run option '-k'
|
|
|
bbf564a |
|
|
|
bbf564a |
Don't do the actual power-off/reboot when '-k' is passed to shutdown.
|
|
|
bbf564a |
|
|
|
bbf564a |
Related to: https://bugzilla.redhat.com/show_bug.cgi?id=624149
|
|
|
bbf564a |
---
|
|
|
bbf564a |
src/shutdownd.c | 2 +-
|
|
|
bbf564a |
src/shutdownd.h | 1 +
|
|
|
bbf564a |
src/systemctl.c | 6 ++++--
|
|
|
bbf564a |
3 files changed, 6 insertions(+), 3 deletions(-)
|
|
|
bbf564a |
|
|
|
bbf564a |
diff --git a/src/shutdownd.c b/src/shutdownd.c
|
|
|
bbf564a |
index 1381941..7fd9573 100644
|
|
|
bbf564a |
--- a/src/shutdownd.c
|
|
|
bbf564a |
+++ b/src/shutdownd.c
|
|
|
bbf564a |
@@ -348,7 +348,7 @@ finish:
|
|
|
bbf564a |
if (unlink_nologin)
|
|
|
bbf564a |
unlink("/run/nologin");
|
|
|
bbf564a |
|
|
|
bbf564a |
- if (exec_shutdown) {
|
|
|
bbf564a |
+ if (exec_shutdown && !c.dry_run) {
|
|
|
bbf564a |
char sw[3];
|
|
|
bbf564a |
|
|
|
bbf564a |
sw[0] = '-';
|
|
|
bbf564a |
diff --git a/src/shutdownd.h b/src/shutdownd.h
|
|
|
bbf564a |
index ed8a704..4581649 100644
|
|
|
bbf564a |
--- a/src/shutdownd.h
|
|
|
bbf564a |
+++ b/src/shutdownd.h
|
|
|
bbf564a |
@@ -33,6 +33,7 @@ _packed_ struct shutdownd_command {
|
|
|
bbf564a |
char mode; /* H, P, r, i.e. the switches usually passed to
|
|
|
bbf564a |
* shutdown to select whether to halt, power-off or
|
|
|
bbf564a |
* reboot the machine */
|
|
|
bbf564a |
+ bool dry_run;
|
|
|
bbf564a |
bool warn_wall;
|
|
|
bbf564a |
|
|
|
bbf564a |
/* Yepp, sometimes we are lazy and use fixed-size strings like
|
|
|
bbf564a |
diff --git a/src/systemctl.c b/src/systemctl.c
|
|
|
bbf564a |
index b584e70..8f904c1 100644
|
|
|
bbf564a |
--- a/src/systemctl.c
|
|
|
bbf564a |
+++ b/src/systemctl.c
|
|
|
bbf564a |
@@ -5422,7 +5422,7 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
|
|
|
bbf564a |
return verbs[i].dispatch(bus, argv + optind, left);
|
|
|
bbf564a |
}
|
|
|
bbf564a |
|
|
|
bbf564a |
-static int send_shutdownd(usec_t t, char mode, bool warn, const char *message) {
|
|
|
bbf564a |
+static int send_shutdownd(usec_t t, char mode, bool dry_run, bool warn, const char *message) {
|
|
|
bbf564a |
int fd = -1;
|
|
|
bbf564a |
struct msghdr msghdr;
|
|
|
bbf564a |
struct iovec iovec;
|
|
|
bbf564a |
@@ -5432,6 +5432,7 @@ static int send_shutdownd(usec_t t, char mode, bool warn, const char *message) {
|
|
|
bbf564a |
zero(c);
|
|
|
bbf564a |
c.elapse = t;
|
|
|
bbf564a |
c.mode = mode;
|
|
|
bbf564a |
+ c.dry_run = dry_run;
|
|
|
bbf564a |
c.warn_wall = warn;
|
|
|
bbf564a |
|
|
|
bbf564a |
if (message)
|
|
|
bbf564a |
@@ -5527,6 +5528,7 @@ static int halt_main(DBusConnection *bus) {
|
|
|
bbf564a |
arg_action == ACTION_HALT ? 'H' :
|
|
|
bbf564a |
arg_action == ACTION_POWEROFF ? 'P' :
|
|
|
bbf564a |
'r',
|
|
|
bbf564a |
+ arg_dry,
|
|
|
bbf564a |
!arg_no_wall,
|
|
|
bbf564a |
m);
|
|
|
bbf564a |
free(m);
|
|
|
bbf564a |
@@ -5774,7 +5776,7 @@ int main(int argc, char*argv[]) {
|
|
|
bbf564a |
break;
|
|
|
bbf564a |
|
|
|
bbf564a |
case ACTION_CANCEL_SHUTDOWN:
|
|
|
bbf564a |
- r = send_shutdownd(0, 0, false, NULL);
|
|
|
bbf564a |
+ r = send_shutdownd(0, 0, false, false, NULL);
|
|
|
bbf564a |
break;
|
|
|
bbf564a |
|
|
|
bbf564a |
case ACTION_INVALID:
|
|
|
bbf564a |
--
|
|
|
bbf564a |
1.7.4.4
|
|
|
bbf564a |
|