prepare-root: Fail if sysroot-ns already exists

This commit is contained in:
Misaki Kasumi 2024-12-19 14:42:50 +08:00
parent 6626f51e13
commit 3dc167e2ee

View File

@ -735,7 +735,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);