* [PATCH 1/5] oeqa/selftest: drop image_feature test from overlayfs
@ 2022-09-07 19:51 Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 2/5] classes: Update overlayfs classes to use new bitbake functionality Vyacheslav Yurkov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Vyacheslav Yurkov @ 2022-09-07 19:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Vyacheslav Yurkov
From: Vyacheslav Yurkov <v.yurkov@precitec.de>
The test checked the incorrect class use with INHERIT. This
functionality is now covered by bitbake
Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
---
meta/lib/oeqa/selftest/cases/overlayfs.py | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py
index bff22f21b6..f550015b4b 100644
--- a/meta/lib/oeqa/selftest/cases/overlayfs.py
+++ b/meta/lib/oeqa/selftest/cases/overlayfs.py
@@ -333,24 +333,14 @@ EXTRA_IMAGE_FEATURES += "package-management"
self.assertTrue("overlayfs-etc" in res.output, msg=res.output)
self.assertTrue("package-management" in res.output, msg=res.output)
- def test_image_feature_is_missing_class_included(self):
- configAppend = """
-INHERIT += "overlayfs-etc"
-"""
- self.run_check_image_feature(configAppend)
-
def test_image_feature_is_missing(self):
- self.run_check_image_feature()
-
- def run_check_image_feature(self, appendToConfig=""):
"""
Summary: Overlayfs-etc class is not applied when image feature is not set
- even if we inherit it directly,
Expected: Image is created successfully but /etc is not an overlay
Author: Vyacheslav Yurkov <uvv.mail@gmail.com>
"""
- config = f"""
+ config = """
DISTRO_FEATURES:append = " systemd"
# Use systemd as init manager
@@ -366,7 +356,6 @@ EXTRA_IMAGE_FEATURES += "read-only-rootfs"
# Image configuration for overlayfs-etc
OVERLAYFS_ETC_MOUNT_POINT = "/data"
OVERLAYFS_ETC_DEVICE = "/dev/sda3"
-{appendToConfig}
"""
self.write_config(config)
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/5] classes: Update overlayfs classes to use new bitbake functionality
2022-09-07 19:51 [PATCH 1/5] oeqa/selftest: drop image_feature test from overlayfs Vyacheslav Yurkov
@ 2022-09-07 19:51 ` Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 3/5] files: overlayfs-etc: refactor preinit template Vyacheslav Yurkov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Vyacheslav Yurkov @ 2022-09-07 19:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Vyacheslav Yurkov
From: Vyacheslav Yurkov <v.yurkov@precitec.de>
OverlayFS classes belong to a recipe scope
Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
---
meta/{classes => classes-recipe}/overlayfs-etc.bbclass | 0
meta/{classes => classes-recipe}/overlayfs.bbclass | 0
2 files changed, 0 insertions(+), 0 deletions(-)
rename meta/{classes => classes-recipe}/overlayfs-etc.bbclass (100%)
rename meta/{classes => classes-recipe}/overlayfs.bbclass (100%)
diff --git a/meta/classes/overlayfs-etc.bbclass b/meta/classes-recipe/overlayfs-etc.bbclass
similarity index 100%
rename from meta/classes/overlayfs-etc.bbclass
rename to meta/classes-recipe/overlayfs-etc.bbclass
diff --git a/meta/classes/overlayfs.bbclass b/meta/classes-recipe/overlayfs.bbclass
similarity index 100%
rename from meta/classes/overlayfs.bbclass
rename to meta/classes-recipe/overlayfs.bbclass
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/5] files: overlayfs-etc: refactor preinit template
2022-09-07 19:51 [PATCH 1/5] oeqa/selftest: drop image_feature test from overlayfs Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 2/5] classes: Update overlayfs classes to use new bitbake functionality Vyacheslav Yurkov
@ 2022-09-07 19:51 ` Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 4/5] classes: files: Extend overlayfs-etc class Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 5/5] oeqa/selftest: Add lower layer test for overlayfs-etc Vyacheslav Yurkov
3 siblings, 0 replies; 5+ messages in thread
From: Vyacheslav Yurkov @ 2022-09-07 19:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Vyacheslav Yurkov
From: Vyacheslav Yurkov <v.yurkov@precitec.de>
Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
---
meta/files/overlayfs-etc-preinit.sh.in | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/meta/files/overlayfs-etc-preinit.sh.in b/meta/files/overlayfs-etc-preinit.sh.in
index 43c9b04eb9..0e80849f12 100644
--- a/meta/files/overlayfs-etc-preinit.sh.in
+++ b/meta/files/overlayfs-etc-preinit.sh.in
@@ -15,19 +15,23 @@ mount -t sysfs sysfs /sys
[ -z "$CONSOLE" ] && CONSOLE="/dev/console"
+BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc
+UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper
+WORK_DIR=$BASE_OVERLAY_ETC_DIR/work
+
mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}
if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
-o {OVERLAYFS_ETC_MOUNT_OPTIONS} \
{OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT}
then
- mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper
- mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/work
+ mkdir -p $UPPER_DIR
+ mkdir -p $WORK_DIR
mount -n -t overlay \
- -o upperdir={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper \
+ -o upperdir=$UPPER_DIR \
-o lowerdir=/etc \
- -o workdir={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/work \
+ -o workdir=$WORK_DIR \
-o index=off,xino=off,redirect_dir=off,metacopy=off \
- {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper /etc || \
+ $UPPER_DIR /etc || \
echo "PREINIT: Mounting etc-overlay failed!"
else
echo "PREINIT: Mounting </data> failed!"
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] classes: files: Extend overlayfs-etc class
2022-09-07 19:51 [PATCH 1/5] oeqa/selftest: drop image_feature test from overlayfs Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 2/5] classes: Update overlayfs classes to use new bitbake functionality Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 3/5] files: overlayfs-etc: refactor preinit template Vyacheslav Yurkov
@ 2022-09-07 19:51 ` Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 5/5] oeqa/selftest: Add lower layer test for overlayfs-etc Vyacheslav Yurkov
3 siblings, 0 replies; 5+ messages in thread
From: Vyacheslav Yurkov @ 2022-09-07 19:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Vyacheslav Yurkov
From: Vyacheslav Yurkov <v.yurkov@precitec.de>
Add the ability to expose the lower layer of /etc when mounting overlay.
This is the similar to what overlayroot script from initramfs-framework does.
By default, this option is turned off to keep an old behavior intact.
Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
---
meta/classes-recipe/overlayfs-etc.bbclass | 5 ++++-
meta/files/overlayfs-etc-preinit.sh.in | 9 +++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/meta/classes-recipe/overlayfs-etc.bbclass b/meta/classes-recipe/overlayfs-etc.bbclass
index d0bc3ecfac..f8343106f3 100644
--- a/meta/classes-recipe/overlayfs-etc.bbclass
+++ b/meta/classes-recipe/overlayfs-etc.bbclass
@@ -40,6 +40,7 @@ OVERLAYFS_ETC_DEVICE ??= ""
OVERLAYFS_ETC_USE_ORIG_INIT_NAME ??= "1"
OVERLAYFS_ETC_MOUNT_OPTIONS ??= "defaults"
OVERLAYFS_ETC_INIT_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-etc-preinit.sh.in"
+OVERLAYFS_ETC_EXPOSE_LOWER ??= "0"
python create_overlayfs_etc_preinit() {
overlayEtcMountPoint = d.getVar("OVERLAYFS_ETC_MOUNT_POINT")
@@ -60,13 +61,15 @@ python create_overlayfs_etc_preinit() {
preinitPath = oe.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("base_sbindir"), "preinit")
initBaseName = oe.path.join(d.getVar("base_sbindir"), "init")
origInitNameSuffix = ".orig"
+ exposeLower = oe.types.boolean(d.getVar('OVERLAYFS_ETC_EXPOSE_LOWER'))
args = {
'OVERLAYFS_ETC_MOUNT_POINT': overlayEtcMountPoint,
'OVERLAYFS_ETC_MOUNT_OPTIONS': d.getVar('OVERLAYFS_ETC_MOUNT_OPTIONS'),
'OVERLAYFS_ETC_FSTYPE': overlayEtcFsType,
'OVERLAYFS_ETC_DEVICE': overlayEtcDevice,
- 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName
+ 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName,
+ 'OVERLAYFS_ETC_EXPOSE_LOWER': "true" if exposeLower else "false"
}
if useOrigInit:
diff --git a/meta/files/overlayfs-etc-preinit.sh.in b/meta/files/overlayfs-etc-preinit.sh.in
index 0e80849f12..8db076f4ba 100644
--- a/meta/files/overlayfs-etc-preinit.sh.in
+++ b/meta/files/overlayfs-etc-preinit.sh.in
@@ -18,6 +18,7 @@ mount -t sysfs sysfs /sys
BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc
UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper
WORK_DIR=$BASE_OVERLAY_ETC_DIR/work
+LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower
mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}
if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
@@ -26,6 +27,14 @@ if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
then
mkdir -p $UPPER_DIR
mkdir -p $WORK_DIR
+
+ if {OVERLAYFS_ETC_EXPOSE_LOWER}; then
+ mkdir -p $LOWER_DIR
+
+ # provide read-only access to original /etc content
+ mount -o bind,ro /etc $LOWER_DIR
+ fi
+
mount -n -t overlay \
-o upperdir=$UPPER_DIR \
-o lowerdir=/etc \
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] oeqa/selftest: Add lower layer test for overlayfs-etc
2022-09-07 19:51 [PATCH 1/5] oeqa/selftest: drop image_feature test from overlayfs Vyacheslav Yurkov
` (2 preceding siblings ...)
2022-09-07 19:51 ` [PATCH 4/5] classes: files: Extend overlayfs-etc class Vyacheslav Yurkov
@ 2022-09-07 19:51 ` Vyacheslav Yurkov
3 siblings, 0 replies; 5+ messages in thread
From: Vyacheslav Yurkov @ 2022-09-07 19:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Vyacheslav Yurkov
From: Vyacheslav Yurkov <v.yurkov@precitec.de>
Place a test file on the /etc by means of overlayfs-user recipe.
Perform QA checks to make sure that:
- When lower layer is exposed, that it's read-only to avoid undefined behavior
- By default lower layer is not exposed
Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
---
.../overlayfs-user/overlayfs-user.bb | 7 +-
meta/lib/oeqa/selftest/cases/overlayfs.py | 90 ++++++++++++++-----
2 files changed, 74 insertions(+), 23 deletions(-)
diff --git a/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb b/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb
index 913a4d1fdb..50cba9514b 100644
--- a/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb
+++ b/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb
@@ -12,6 +12,11 @@ OVERLAYFS_WRITABLE_PATHS[mnt-overlay] += "/usr/share/my-application"
do_install() {
install -d ${D}/usr/share/my-application
+ install -d ${D}${sysconfdir}
+ echo "Original file in /etc" >> ${D}${sysconfdir}/lower-layer-test.txt
}
-FILES:${PN} += "/usr"
+FILES:${PN} += "\
+ ${exec_prefix} \
+ ${sysconfdir \
+"
diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py
index f550015b4b..57a8c8bdb6 100644
--- a/meta/lib/oeqa/selftest/cases/overlayfs.py
+++ b/meta/lib/oeqa/selftest/cases/overlayfs.py
@@ -381,28 +381,7 @@ OVERLAYFS_ETC_DEVICE = "/dev/sda3"
Author: Vyacheslav Yurkov <uvv.mail@gmail.com>
"""
- config = """
-DISTRO_FEATURES:append = " systemd"
-
-# Use systemd as init manager
-VIRTUAL-RUNTIME_init_manager = "systemd"
-
-# enable overlayfs in the kernel
-KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc"
-
-IMAGE_FSTYPES += "wic"
-OVERLAYFS_INIT_OPTION = "{OVERLAYFS_INIT_OPTION}"
-WKS_FILE = "overlayfs_etc.wks.in"
-
-EXTRA_IMAGE_FEATURES += "read-only-rootfs"
-# Image configuration for overlayfs-etc
-EXTRA_IMAGE_FEATURES += "overlayfs-etc"
-IMAGE_FEATURES:remove = "package-management"
-OVERLAYFS_ETC_MOUNT_POINT = "/data"
-OVERLAYFS_ETC_FSTYPE = "ext4"
-OVERLAYFS_ETC_DEVICE = "/dev/sda3"
-OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "{OVERLAYFS_ETC_USE_ORIG_INIT_NAME}"
-"""
+ config = self.get_working_config()
args = {
'OVERLAYFS_INIT_OPTION': "" if origInit else "init=/sbin/preinit",
@@ -423,6 +402,11 @@ OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "{OVERLAYFS_ETC_USE_ORIG_INIT_NAME}"
line = getline_qemu(output, "upperdir=/data/overlay-etc/upper")
self.assertTrue(line and line.startswith("/data/overlay-etc/upper on /etc type overlay"), msg=output)
+ # check that lower layer is not available
+ status, output = qemu.run_serial("ls -1 /data/overlay-etc/lower")
+ line = getline_qemu(output, "No such file or directory")
+ self.assertTrue(line, msg=output)
+
status, output = qemu.run_serial("touch " + testFile)
status, output = qemu.run_serial("sync")
status, output = qemu.run_serial("ls -1 " + testFile)
@@ -434,3 +418,65 @@ OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "{OVERLAYFS_ETC_USE_ORIG_INIT_NAME}"
status, output = qemu.run_serial("ls -1 " + testFile)
line = getline_qemu(output, testFile)
self.assertTrue(line and line.startswith(testFile), msg=output)
+
+ def test_lower_layer_access(self):
+ """
+ Summary: Test that lower layer of /etc is available read-only when configured
+ Expected: Can't write to lower layer. The files on lower and upper different after
+ modification
+ Author: Vyacheslav Yurkov <uvv.mail@gmail.com>
+ """
+
+ config = self.get_working_config()
+
+ configLower = """
+OVERLAYFS_ETC_EXPOSE_LOWER = "1"
+IMAGE_INSTALL:append = " overlayfs-user"
+"""
+ testFile = "lower-layer-test.txt"
+
+ args = {
+ 'OVERLAYFS_INIT_OPTION': "",
+ 'OVERLAYFS_ETC_USE_ORIG_INIT_NAME': 1
+ }
+
+ self.write_config(config.format(**args))
+
+ self.append_config(configLower)
+ bitbake('core-image-minimal')
+
+ with runqemu('core-image-minimal', image_fstype='wic') as qemu:
+ status, output = qemu.run_serial("echo \"Modified in upper\" > /etc/" + testFile)
+ status, output = qemu.run_serial("diff /etc/" + testFile + " /data/overlay-etc/lower/" + testFile)
+ line = getline_qemu(output, "Modified in upper")
+ self.assertTrue(line, msg=output)
+ line = getline_qemu(output, "Original file")
+ self.assertTrue(line, msg=output)
+
+ status, output = qemu.run_serial("touch /data/overlay-etc/lower/ro-test.txt")
+ line = getline_qemu(output, "Read-only file system")
+ self.assertTrue(line, msg=output)
+
+ def get_working_config(self):
+ return """
+DISTRO_FEATURES:append = " systemd"
+
+# Use systemd as init manager
+VIRTUAL-RUNTIME_init_manager = "systemd"
+
+# enable overlayfs in the kernel
+KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc"
+
+IMAGE_FSTYPES += "wic"
+OVERLAYFS_INIT_OPTION = "{OVERLAYFS_INIT_OPTION}"
+WKS_FILE = "overlayfs_etc.wks.in"
+
+EXTRA_IMAGE_FEATURES += "read-only-rootfs"
+# Image configuration for overlayfs-etc
+EXTRA_IMAGE_FEATURES += "overlayfs-etc"
+IMAGE_FEATURES:remove = "package-management"
+OVERLAYFS_ETC_MOUNT_POINT = "/data"
+OVERLAYFS_ETC_FSTYPE = "ext4"
+OVERLAYFS_ETC_DEVICE = "/dev/sda3"
+OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "{OVERLAYFS_ETC_USE_ORIG_INIT_NAME}"
+"""
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-07 19:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 19:51 [PATCH 1/5] oeqa/selftest: drop image_feature test from overlayfs Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 2/5] classes: Update overlayfs classes to use new bitbake functionality Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 3/5] files: overlayfs-etc: refactor preinit template Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 4/5] classes: files: Extend overlayfs-etc class Vyacheslav Yurkov
2022-09-07 19:51 ` [PATCH 5/5] oeqa/selftest: Add lower layer test for overlayfs-etc Vyacheslav Yurkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.