|
|
e6b4d8 |
From a7a751b69f2315635d6ae38a0b1344287b67079a Mon Sep 17 00:00:00 2001
|
|
|
e6b4d8 |
From: Jonathan Lebon <jonathan@jlebon.com>
|
|
|
e6b4d8 |
Date: Fri, 28 Aug 2020 12:35:29 -0400
|
|
|
e6b4d8 |
Subject: [PATCH] ostree-remount: Remount /etc rw if needed
|
|
|
e6b4d8 |
|
|
|
e6b4d8 |
When we remount `/sysroot` as read-only, we also make `/etc` read-only.
|
|
|
e6b4d8 |
This is usually OK because we then remount `/var` read-write, which also
|
|
|
e6b4d8 |
flips `/etc` back to read-write... unless `/var` is a separate
|
|
|
e6b4d8 |
filesystem and not a bind-mount to the stateroot `/var`.
|
|
|
e6b4d8 |
|
|
|
e6b4d8 |
Fix this by just remounting `/etc` read-write in the read-only sysroot
|
|
|
e6b4d8 |
case.
|
|
|
e6b4d8 |
|
|
|
e6b4d8 |
Eventually, I think we should rework this to set everything up the way
|
|
|
e6b4d8 |
we want from the initramfs (#2115). This would also eliminate the window
|
|
|
e6b4d8 |
during which `/etc` is read-only while `ostree-remount` runs.
|
|
|
e6b4d8 |
---
|
|
|
e6b4d8 |
src/switchroot/ostree-remount.c | 5 +++++
|
|
|
e6b4d8 |
1 file changed, 5 insertions(+)
|
|
|
e6b4d8 |
|
|
|
e6b4d8 |
diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c
|
|
|
e6b4d8 |
index cfd270bb..3981682a 100644
|
|
|
e6b4d8 |
--- a/src/switchroot/ostree-remount.c
|
|
|
e6b4d8 |
+++ b/src/switchroot/ostree-remount.c
|
|
|
e6b4d8 |
@@ -112,6 +112,11 @@ main(int argc, char *argv[])
|
|
|
e6b4d8 |
bool sysroot_configured_readonly = unlink (_OSTREE_SYSROOT_READONLY_STAMP) == 0;
|
|
|
e6b4d8 |
do_remount ("/sysroot", !sysroot_configured_readonly);
|
|
|
e6b4d8 |
|
|
|
e6b4d8 |
+ /* And also make sure to make /etc rw again. We make this conditional on
|
|
|
e6b4d8 |
+ * sysroot_configured_readonly because only in that case is it a bind-mount. */
|
|
|
e6b4d8 |
+ if (sysroot_configured_readonly)
|
|
|
e6b4d8 |
+ do_remount ("/etc", true);
|
|
|
e6b4d8 |
+
|
|
|
e6b4d8 |
/* If /var was created as as an OSTree default bind mount (instead of being a separate filesystem)
|
|
|
e6b4d8 |
* then remounting the root mount read-only also remounted it.
|
|
|
e6b4d8 |
* So just like /etc, we need to make it read-write by default.
|
|
|
e6b4d8 |
--
|
|
|
e6b4d8 |
2.26.2
|
|
|
e6b4d8 |
|