]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: mangle slice name
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Nov 2019 10:21:05 +0000 (11:21 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 3 Nov 2019 12:32:56 +0000 (21:32 +0900)
It's user-facing, parsed from the command line and we typically mangle
in these cases, let's do so here too. (In particular as the identical
switch for systemd-run already does it.)

src/nspawn/nspawn.c

index c9ff00544cf763fc78ea900c3af37fd8a2199b6e..070a10fbebbbb849b47b1449ba8d0587c5f14945 100644 (file)
 #include "terminal-util.h"
 #include "tmpfile-util.h"
 #include "umask-util.h"
+#include "unit-name.h"
 #include "user-util.h"
 #include "util.h"
 
@@ -891,13 +892,17 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_settings_mask |= SETTING_MACHINE_ID;
                         break;
 
-                case 'S':
-                        r = free_and_strdup(&arg_slice, optarg);
+                case 'S': {
+                        _cleanup_free_ char *mangled = NULL;
+
+                        r = unit_name_mangle_with_suffix(optarg, NULL, UNIT_NAME_MANGLE_WARN, ".slice", &mangled);
                         if (r < 0)
                                 return log_oom();
 
+                        free_and_replace(arg_slice, mangled);
                         arg_settings_mask |= SETTING_SLICE;
                         break;
+                }
 
                 case 'M':
                         if (isempty(optarg))