]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-invoke: use bind_mount_add() where appropriate
authorMike Yuan <me@yhndnzj.com>
Wed, 4 Sep 2024 13:28:45 +0000 (15:28 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 4 Sep 2024 19:44:24 +0000 (21:44 +0200)
src/core/exec-invoke.c

index af5552379efc13ca90f600345586ba6c12dc462c..f15b73d0500efd8ef0a0816cbf8cdde2314be4d9 100644 (file)
@@ -2641,23 +2641,9 @@ static int compile_bind_mounts(
                 return -ENOMEM;
 
         FOREACH_ARRAY(item, context->bind_mounts, context->n_bind_mounts) {
-                _cleanup_free_ char *s = NULL, *d = NULL;
-
-                s = strdup(item->source);
-                if (!s)
-                        return -ENOMEM;
-
-                d = strdup(item->destination);
-                if (!d)
-                        return -ENOMEM;
-
-                bind_mounts[h++] = (BindMount) {
-                        .source = TAKE_PTR(s),
-                        .destination = TAKE_PTR(d),
-                        .read_only = item->read_only,
-                        .recursive = item->recursive,
-                        .ignore_enoent = item->ignore_enoent,
-                };
+                r = bind_mount_add(&bind_mounts, &h, item);
+                if (r < 0)
+                        return r;
         }
 
         for (ExecDirectoryType t = 0; t < _EXEC_DIRECTORY_TYPE_MAX; t++) {