Blob Blame History Raw
From 32e6ac78e3e52500c5dab04cc468b7d4352aacc1 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 3 May 2012 16:17:58 +0200
Subject: [PATCH] systemctl: print a nice error message if an unprivileged
 user calls systemctl reboot -ff (cherry picked from commit
 c32b90dec78afe0db51ff0afa6448c01524105fa)

---
 src/systemctl/systemctl.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 4d63163..e59442f 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1788,6 +1788,11 @@ static int start_special(DBusConnection *bus, char **args) {
 
         a = verb_to_action(args[0]);
 
+        if (arg_force >= 2 && geteuid() != 0) {
+                log_error("Must be root.");
+                return -EPERM;
+        }
+
         if (arg_force >= 2 &&
             (a == ACTION_HALT ||
              a == ACTION_POWEROFF ||