From 622444b26fa471d923a31c78f468aa419cb8c902 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Thu, 19 Dec 2024 14:42:50 +0800 Subject: [PATCH] prepare-root: Fail if sysroot-ns already exists --- src/switchroot/ostree-prepare-root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 3d4e1ef290..bba5920166 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -742,7 +742,7 @@ main (int argc, char *argv[]) * and unmount sysroot in the root mount namespace to make it invisible. */ const char *sysroot_ns = OTCORE_RUN_OSTREE_PRIVATE "/sysroot-ns"; - glnx_autofd int ns_fd = open (sysroot_ns, O_WRONLY | O_CREAT, 0); + glnx_autofd int ns_fd = open (sysroot_ns, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0); if (ns_fd < 0) err (EXIT_FAILURE, "failed to create %s", sysroot_ns);