ostree-prepare-root: Fix /etc bind mount
authorJonathan Lebon <jonathan@jlebon.com>
Fri, 28 Aug 2020 16:35:28 +0000 (12:35 -0400)
committerJonathan Lebon <jonathan@jlebon.com>
Fri, 28 Aug 2020 18:16:29 +0000 (14:16 -0400)
We were bind-mounting the initramfs' `/etc` (to itself) instead of the
target deployment `/etc` (to itself). Since we're already `chdir`'ed
into it, we can just drop the leading slash.

src/switchroot/ostree-prepare-root.c

index f7e4fe47c3670999b09d0d1cd36ae30572b5c52c..6351babbc452c05fccb39e1492a1fc3bc8a9a3eb 100644 (file)
@@ -251,7 +251,7 @@ main(int argc, char *argv[])
        * sysroot, we still need a writable /etc.  And to avoid race conditions
        * we ensure it's writable in the initramfs, before we switchroot at all.
        */
-      if (mount ("/etc", "/etc", NULL, MS_BIND, NULL) < 0)
+      if (mount ("etc", "etc", NULL, MS_BIND, NULL) < 0)
         err (EXIT_FAILURE, "failed to make /etc a bind mount");
       /* Pass on the fact that we discovered a readonly sysroot to ostree-remount.service */
       int fd = open (_OSTREE_SYSROOT_READONLY_STAMP, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);