]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run0: Make --same-root-dir available for run0
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Nov 2025 08:10:18 +0000 (09:10 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Nov 2025 09:36:53 +0000 (10:36 +0100)
This enables running something like
"mkosi box -- run0 --empower --same-root-dir -E PATH" to get an
empowered session as the current user within the "mkosi box" environment.

man/run0.xml
src/run/run.c

index d44743620e2c72331fec36df1c5b47ce6f2bef7e..01e6b4b9f726b3e7391486ce1df8df32ab3a6e90 100644 (file)
         <xi:include href="version-info.xml" xpointer="v259"/></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--same-root-dir</option></term>
+
+        <listitem><para>Execute the <command>run0</command> session in the same root directory that the
+        <command>run0</command> command is executed in.</para>
+
+        <xi:include href="version-info.xml" xpointer="v259"/></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--machine=</option></term>
 
index 1286ae176ef7253876d60f8529d71eb05fa7b579..d1202632ac78c5e2938f19e347e50c4ebe49cb23 100644 (file)
@@ -899,6 +899,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) {
                 ARG_AREA,
                 ARG_VIA_SHELL,
                 ARG_EMPOWER,
+                ARG_SAME_ROOT_DIR,
         };
 
         /* If invoked as "run0" binary, let's expose a more sudo-like interface. We add various extensions
@@ -929,6 +930,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) {
                 { "lightweight",         required_argument, NULL, ARG_LIGHTWEIGHT         },
                 { "area",                required_argument, NULL, ARG_AREA                },
                 { "empower",             no_argument,       NULL, ARG_EMPOWER             },
+                { "same-root-dir",       no_argument,       NULL, ARG_SAME_ROOT_DIR       },
                 {},
         };
 
@@ -1072,6 +1074,13 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) {
                         arg_empower = true;
                         break;
 
+                case ARG_SAME_ROOT_DIR:
+                        r = free_and_strdup_warn(&arg_root_directory, "/");
+                        if (r < 0)
+                                return r;
+
+                        break;
+
                 case '?':
                         return -EINVAL;