]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: always take exclusive locks of ephemeral OS tree copies
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Jul 2019 09:17:23 +0000 (11:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 29 Jul 2019 07:52:02 +0000 (09:52 +0200)
src/nspawn/nspawn.c

index de748b9de3387481aa75572cea1aa08685ffbae3..2289a0a97fb3e78dc28b21e99ff6a3ea85a4892d 100644 (file)
@@ -4774,7 +4774,9 @@ static int run(int argc, char *argv[]) {
                                 goto finish;
                         }
 
-                        r = image_path_lock(np, (arg_read_only ? LOCK_SH : LOCK_EX) | LOCK_NB, &tree_global_lock, &tree_local_lock);
+                        /* We take an exclusive lock on this image, since it's our private, ephemeral copy
+                         * only owned by us and noone else. */
+                        r = image_path_lock(np, LOCK_EX|LOCK_NB, &tree_global_lock, &tree_local_lock);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to lock %s: %m", np);
                                 goto finish;
@@ -4894,7 +4896,8 @@ static int run(int argc, char *argv[]) {
                                 goto finish;
                         }
 
-                        r = image_path_lock(np, (arg_read_only ? LOCK_SH : LOCK_EX) | LOCK_NB, &tree_global_lock, &tree_local_lock);
+                        /* Always take an exclusive lock on our own ephemeral copy. */
+                        r = image_path_lock(np, LOCK_EX|LOCK_NB, &tree_global_lock, &tree_local_lock);
                         if (r < 0) {
                                 r = log_error_errno(r, "Failed to create image lock: %m");
                                 goto finish;