From f61b1cbabd86d6de618a402de5a00563c1c07726 Mon Sep 17 00:00:00 2001 From: Philip Meulengracht Date: Tue, 3 Sep 2024 10:19:06 +0200 Subject: [PATCH 1/3] slices: add util-linux --- slices/util-linux.yaml | 135 ++++++++++++++++++ tests/spread/integration/util-linux/task.yaml | 31 ++++ 2 files changed, 166 insertions(+) create mode 100644 slices/util-linux.yaml create mode 100644 tests/spread/integration/util-linux/task.yaml diff --git a/slices/util-linux.yaml b/slices/util-linux.yaml new file mode 100644 index 000000000..ead446f4e --- /dev/null +++ b/slices/util-linux.yaml @@ -0,0 +1,135 @@ +package: util-linux + +essential: + - util-linux_copyright + +slices: + bins: + essential: + - libblkid1_libs + - libc6_libs + - libcap-ng0_libs + - libcrypt1_libs + - libmount1_libs + - libpam0g_libs + - libselinux1_libs + - libsmartcols1_libs + - libsystemd0_libs + - libtinfo6_libs + - libudev1_libs + - libuuid1_libs + - util-linux_generated + - zlib1g_libs + contents: + /usr/bin/addpart: + /usr/bin/choom: + /usr/bin/chrt: + /usr/bin/delpart: + /usr/bin/dmesg: + /usr/bin/fallocate: + /usr/bin/findmnt: + /usr/bin/flock: + /usr/bin/getopt: + /usr/bin/hardlink: + /usr/bin/i386: { arch: [i386, amd64] } + /usr/bin/ionice: + /usr/bin/ipcmk: + /usr/bin/ipcrm: + /usr/bin/ipcs: + /usr/bin/last: + /usr/bin/lastb: + /usr/bin/linux32: + /usr/bin/linux64: + /usr/bin/lsblk: + /usr/bin/lscpu: + /usr/bin/lsipc: + /usr/bin/lslocks: + /usr/bin/lslogins: + /usr/bin/lsmem: + /usr/bin/lsns: + /usr/bin/mcookie: + /usr/bin/mesg: + /usr/bin/more: + /usr/bin/mountpoint: + /usr/bin/namei: + /usr/bin/nsenter: + /usr/bin/partx: + /usr/bin/ppc: { arch: [ppc64el] } + /usr/bin/ppc32: { arch: [ppc64el] } + /usr/bin/ppc64: { arch: [ppc64el] } + /usr/bin/prlimit: + /usr/bin/rename.ul: + /usr/bin/resizepart: + /usr/bin/rev: + /usr/bin/s390: { arch: [s390x] } + /usr/bin/s390x: { arch: [s390x] } + /usr/bin/setarch: + /usr/bin/setpriv: + /usr/bin/setsid: + /usr/bin/setterm: + /usr/bin/su: + /usr/bin/taskset: + /usr/bin/uclampset: + /usr/bin/unshare: + /usr/bin/utmpdump: + /usr/bin/wdctl: + /usr/bin/whereis: + /usr/bin/x86_64: { arch: [amd64] } + /usr/sbin/agetty: + /usr/sbin/blkdiscard: + /usr/sbin/blkid: + /usr/sbin/blkzone: + /usr/sbin/blockdev: + /usr/sbin/chcpu: + /usr/sbin/chmem: + /usr/sbin/ctrlaltdel: + /usr/sbin/findfs: + /usr/sbin/fsck: + /usr/sbin/fsck.cramfs: + /usr/sbin/fsck.minix: + /usr/sbin/fsfreeze: + /usr/sbin/fstrim: + /usr/sbin/getty: + /usr/sbin/isosize: + /usr/sbin/ldattach: + /usr/sbin/mkfs: + /usr/sbin/mkfs.bfs: + /usr/sbin/mkfs.cramfs: + /usr/sbin/mkfs.minix: + /usr/sbin/mkswap: + /usr/sbin/pivot_root: + /usr/sbin/readprofile: + /usr/sbin/rtcwake: + /usr/sbin/runuser: + /usr/sbin/sulogin: + /usr/sbin/swaplabel: + /usr/sbin/switch_root: + /usr/sbin/wipefs: + /usr/sbin/zramctl: + + # the following emulates the post-install script + generated: + contents: + /usr/bin/pager: {symlink: /usr/bin/more} + + mime: + contents: + /usr/lib/mime/packages/util-linux: + + pam-profile: + contents: + /etc/pam.d/runuser: + /etc/pam.d/runuser-l: + /etc/pam.d/su: + /etc/pam.d/su-l: + + services: + essential: + - util-linux_bins + contents: + /usr/lib/systemd/system/fstrim.service: + /usr/lib/systemd/system/fstrim.timer: + + copyright: + contents: + /usr/share/doc/util-linux/copyright: diff --git a/tests/spread/integration/util-linux/task.yaml b/tests/spread/integration/util-linux/task.yaml new file mode 100644 index 000000000..baeaecac0 --- /dev/null +++ b/tests/spread/integration/util-linux/task.yaml @@ -0,0 +1,31 @@ +summary: Integration tests for util-linux + +systems: + - -ubuntu-24.04-ppc64le + - -ubuntu-24.04-s390x + +execute: | + rootfs="$(install-slices util-linux_bins)" + + # we need dev/sys mounted for some of them + mkdir "${rootfs}"/dev + mkdir "${rootfs}"/sys + + mount --rbind /dev "${rootfs}"/dev + mount --rbind /sys "${rootfs}"/sys + + # smoke test a couple of the bundled applications + chroot "${rootfs}" lsblk | grep "loop0" + chroot "${rootfs}" lsipc | grep "MSGMNI" + chroot "${rootfs}" lsmem | grep "Total online memory" + chroot "${rootfs}" whereis lsblk | grep "/usr/bin/lsblk" + + # cleanup + umount -l "${rootfs}"/dev + umount -l "${rootfs}"/sys + + # ensure expected links are generated + if ! [ -e "${rootfs}"/usr/bin/pager ]; then + echo "expected /usr/bin/pager to be generated" + exit 1 + fi From db509ef7d1bf97077982deabcde5b29bd521a4bd Mon Sep 17 00:00:00 2001 From: Rafid Bin Mostofa Date: Tue, 26 Nov 2024 20:14:35 +0600 Subject: [PATCH 2/3] feat: add new slice su-support in util-linux This commit adds a new slice su-support, which segregates the su and runuser binaries to that slice for granularity. It also modifies the tests a bit. --- slices/util-linux.yaml | 34 ++++++++++++++----- tests/spread/integration/util-linux/task.yaml | 7 ++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/slices/util-linux.yaml b/slices/util-linux.yaml index ead446f4e..0d9712e1e 100644 --- a/slices/util-linux.yaml +++ b/slices/util-linux.yaml @@ -19,6 +19,7 @@ slices: - libudev1_libs - libuuid1_libs - util-linux_generated + - util-linux_su-support - zlib1g_libs contents: /usr/bin/addpart: @@ -67,7 +68,6 @@ slices: /usr/bin/setpriv: /usr/bin/setsid: /usr/bin/setterm: - /usr/bin/su: /usr/bin/taskset: /usr/bin/uclampset: /usr/bin/unshare: @@ -100,28 +100,46 @@ slices: /usr/sbin/pivot_root: /usr/sbin/readprofile: /usr/sbin/rtcwake: - /usr/sbin/runuser: /usr/sbin/sulogin: /usr/sbin/swaplabel: /usr/sbin/switch_root: /usr/sbin/wipefs: /usr/sbin/zramctl: + # Contains the binaries which supports running commands with substitute user + # and group IDs. + su-support: + essential: + - libaudit1_libs + - libc6_libs + - libcap-ng0_libs + - libpam0g_libs + - util-linux_pam-profiles + contents: + /usr/bin/su: + /usr/sbin/runuser: + + # the following emulates the post-install script generated: + essential: + # Since the more binary is located at ./usr/bin/more and /bin in noble + # points to /usr/bin via base-files, the base-files_bin slice is included + # here. + - base-files_bin contents: - /usr/bin/pager: {symlink: /usr/bin/more} + /usr/bin/pager: {symlink: /bin/more} mime: contents: /usr/lib/mime/packages/util-linux: - pam-profile: + pam-profiles: contents: - /etc/pam.d/runuser: - /etc/pam.d/runuser-l: - /etc/pam.d/su: - /etc/pam.d/su-l: + /etc/pam.d/runuser: + /etc/pam.d/runuser-l: + /etc/pam.d/su: + /etc/pam.d/su-l: services: essential: diff --git a/tests/spread/integration/util-linux/task.yaml b/tests/spread/integration/util-linux/task.yaml index baeaecac0..09941a72c 100644 --- a/tests/spread/integration/util-linux/task.yaml +++ b/tests/spread/integration/util-linux/task.yaml @@ -20,6 +20,13 @@ execute: | chroot "${rootfs}" lsmem | grep "Total online memory" chroot "${rootfs}" whereis lsblk | grep "/usr/bin/lsblk" + # Test the su and runuser binaries + cp /etc/passwd "${rootfs}"/etc/passwd + echo "foo:x:1001:1001:Test user,,,:/tmp:/bin/bash" >>"${rootfs}"/etc/passwd + cp /usr/bin/whoami "${rootfs}"/usr/bin/ + chroot "${rootfs}" su foo -c whoami | grep "foo" + chroot "${rootfs}" runuser foo -c whoami | grep "foo" + # cleanup umount -l "${rootfs}"/dev umount -l "${rootfs}"/sys From e67679d4646a28f8deb24d3fe11f8e9b842ecd00 Mon Sep 17 00:00:00 2001 From: Rafid Bin Mostofa Date: Tue, 26 Nov 2024 20:20:48 +0600 Subject: [PATCH 3/3] refactor: remove consecutive blank lines --- slices/util-linux.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/slices/util-linux.yaml b/slices/util-linux.yaml index 0d9712e1e..70d1e98c2 100644 --- a/slices/util-linux.yaml +++ b/slices/util-linux.yaml @@ -119,7 +119,6 @@ slices: /usr/bin/su: /usr/sbin/runuser: - # the following emulates the post-install script generated: essential: