]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: reject --ignore-failure in scope mode
authordongshengyuan <545258830@qq.com>
Mon, 13 Jul 2026 05:56:52 +0000 (13:56 +0800)
committerdongshengyuan <545258830@qq.com>
Tue, 14 Jul 2026 04:03:22 +0000 (12:03 +0800)
Reproducer:
  sudo systemd-run --scope --ignore-failure /bin/false
  echo $?

Before, the option was accepted but had no effect because scope mode
executes the command locally after creating the scope. The flag is only
encoded into service ExecStart properties, so accept it only where it can
be applied.

Follow-up for 1072d9473123ed174e033704fc5222216b655c9e

man/systemd-run.xml
src/run/run.c
test/units/TEST-74-AUX-UTILS.run.sh

index 386702ac401dc9e69124d85d30fdfad6f49b0ae0..9afe4ab446804432f3ddd08e4adcf94a077fc6ae 100644 (file)
         <listitem><para>By default, if the specified command fails the invoked unit will be marked failed
         (though possibly still unloaded, see <option>--collect=</option>, above), and this is reported in the
         logs. If this switch is specified this is suppressed and any non-success exit status/code of the
-        command is treated as success.</para>
+        command is treated as success. This option is not supported in <option>--scope</option> mode.</para>
 
         <xi:include href="version-info.xml" xpointer="v256"/></listitem>
       </varlistentry>
index ac6d3c01961aafdf5157f5c04fdcc8c0433df38a..69449ab2ffcc703a4e196ad80bcd0431956c5f21 100644 (file)
@@ -697,9 +697,9 @@ static int parse_argv(int argc, char *argv[]) {
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "Scope execution is not supported on remote systems.");
 
-        if (arg_scope && (arg_remain_after_exit || arg_service_type))
+        if (arg_scope && (arg_remain_after_exit || arg_service_type || arg_ignore_failure))
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                       "--remain-after-exit and --service-type= are not supported in --scope mode.");
+                                       "--remain-after-exit, --service-type= and --ignore-failure are not supported in --scope mode.");
 
         if (arg_scope && arg_no_block)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
index ec73a0bd1c40417d2b609336400e1c839ada45e4..9db1a81018afdcd7c2230a246e9024460f22d213 100755 (executable)
@@ -115,6 +115,7 @@ systemd-run --scope \
             --property=RuntimeMaxSec=10 \
             --property=RuntimeMaxSec=infinity \
             true
+(! systemd-run --scope --ignore-failure false)
 
 : "Transient scope (user daemon)"
 # FIXME: https://github.com/systemd/systemd/issues/27883