]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: when parsing verb command lines, optionally shortcut them in chroot() environments
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Jan 2016 18:30:56 +0000 (19:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 Jan 2016 14:16:56 +0000 (15:16 +0100)
This adds some basic infrastructure in order to fix #2015.

src/basic/verbs.c
src/basic/verbs.h

index 7feb47c48e114ce0eca3a7f38e066913b3da0d98..6dded9fb77e9ca75f767ba8bd6aa11d8f6f71e82 100644 (file)
@@ -28,6 +28,7 @@
 #include "macro.h"
 #include "string-util.h"
 #include "verbs.h"
+#include "virt.h"
 
 int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata) {
         const Verb *verb;
@@ -84,6 +85,11 @@ int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata) {
                 return -EINVAL;
         }
 
+        if ((verb->flags & VERB_NOCHROOT) && running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         if (name)
                 return verb->dispatch(left, argv + optind, userdata);
         else {
index d59e4d59b8f0b79e611ec82fcadccd8bc124f5e7..4132cad7730f814f9c43960504e902dac2fda902 100644 (file)
@@ -22,7 +22,8 @@
 ***/
 
 #define VERB_ANY ((unsigned) -1)
-#define VERB_DEFAULT 1
+#define VERB_DEFAULT 1U
+#define VERB_NOCHROOT 2U
 
 typedef struct {
         const char *verb;