Skip to contentSkip to conversation

shadow: generate alternative links for chfn and chsh

PATCH New Ross Burton 1 participant 5 messages Jul 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 shadow: generate alternative links for chfn and chsh

These can be provided by util-linux, so add alternative links for them.

---
 meta/recipes-extended/shadow/shadow.inc | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-extended/shadow/shadow.inc +2 -0
index 2278541f6b1..2cbdfbc1cf1 100644
@@ -173,6 +173,8 @@ inherit update-alternatives
 ALTERNATIVE_PRIORITY = "200"
 
 ALTERNATIVE_${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
+ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn"
+ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh"
 ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
 ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
 ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/5 util-linux: build chfn and chsh

As we now split util-linux per-binary there's no disadvantage to not building chfn and chsh.

This also means that the tests pass instead of failing when the test uses the binaries from shadow.

---
 meta/recipes-core/util-linux/util-linux_2.37.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-core/util-linux/util-linux_2.37.bb +3 -1
index 9a50c75e77d..933995ea94d 100644
@@ -71,7 +71,7 @@ EXTRA_OECONF = "\
     --enable-mount --enable-partx --enable-raw --enable-rfkill \
     --enable-unshare --enable-write \
     \
-    --disable-bfs --disable-chfn-chsh --disable-login \
+    --disable-bfs --disable-login \
     --disable-makeinstall-chown --disable-minix --disable-newgrp \
     --disable-use-tty-group --disable-vipw \
     \
@@ -209,6 +209,8 @@ ALTERNATIVE_PRIORITY = "80"
 ALTERNATIVE_LINK_NAME[blkid] = "${base_sbindir}/blkid"
 ALTERNATIVE_LINK_NAME[blockdev] = "${base_sbindir}/blockdev"
 ALTERNATIVE_LINK_NAME[cal] = "${bindir}/cal"
+ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn"
+ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh"
 ALTERNATIVE_LINK_NAME[chrt] = "${bindir}/chrt"
 ALTERNATIVE_LINK_NAME[dmesg] = "${base_bindir}/dmesg"
 ALTERNATIVE_LINK_NAME[eject] = "${bindir}/eject"
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 3/5 util-linux: add missing ptest dependencies

In reply to Ross Burton

The kernel modules loop and sd-mod are needed for the block device tests.

GNU find is used in some tests.

---
 meta/recipes-core/util-linux/util-linux_2.37.bb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-core/util-linux/util-linux_2.37.bb +2 -2
index 933995ea94d..48b6208612e 100644
@@ -132,8 +132,8 @@ RDEPENDS_${PN}-dev += " util-linux-libuuid-dev"
 RPROVIDES_${PN}-dev = "${PN}-libblkid-dev ${PN}-libmount-dev"
 
 RDEPENDS_${PN}-bash-completion += "${PN}-lsblk"
-RDEPENDS_${PN}-ptest += "bash bc btrfs-tools coreutils e2fsprogs grep iproute2 kmod mdadm procps sed socat which xz"
-RRECOMMENDS_${PN}-ptest += "kernel-module-scsi-debug"
+RDEPENDS_${PN}-ptest += "bash bc btrfs-tools coreutils e2fsprogs findutils grep iproute2 kmod mdadm procps sed socat which xz"
+RRECOMMENDS_${PN}-ptest += "kernel-module-scsi-debug kernel-module-sd-mod kernel-module-loop"
 RDEPENDS_${PN}-swaponoff = "${PN}-swapon ${PN}-swapoff"
 ALLOW_EMPTY_${PN}-swaponoff = "1"
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 4/5 util-linux: backport test suite fixes

In reply to Ross Burton

Backport a number of fixes so the test suite passes.

---
 meta/recipes-core/util-linux/util-linux.inc   |  6 ++
 .../util-linux/tests-blkdiscard.patch         | 31 +++++++
 .../util-linux/util-linux/tests-eject.patch   | 56 ++++++++++++
 .../util-linux/util-linux/tests-kill.patch    | 88 +++++++++++++++++++
 .../util-linux/util-linux/tests-lscpu.patch   | 42 +++++++++
 .../util-linux/util-linux/tests-ul.patch      | 35 ++++++++
 6 files changed, 258 insertions(+)
 create mode 100644 meta/recipes-core/util-linux/util-linux/tests-blkdiscard.patch
 create mode 100644 meta/recipes-core/util-linux/util-linux/tests-eject.patch
 create mode 100644 meta/recipes-core/util-linux/util-linux/tests-kill.patch
 create mode 100644 meta/recipes-core/util-linux/util-linux/tests-lscpu.patch
 create mode 100644 meta/recipes-core/util-linux/util-linux/tests-ul.patch
meta/recipes-core/util-linux/util-linux.inc +6 -0
index 9d7d8a23aaa..f10d911fb1d 100644
@@ -36,5 +36,11 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://display_testname_for_subtest.patch \
            file://avoid_parallel_tests.patch \
            file://8a3a74160b96498d672e3652827aa7e6d7f3a120.patch \
+           file://tests-kill.patch \
+           file://tests-blkdiscard.patch \
+           file://tests-ul.patch \
+           file://tests-eject.patch \
+           file://tests-lscpu.patch \
            "
+
 SRC_URI[sha256sum] = "bd07b7e98839e0359842110525a3032fdb8eaf3a90bedde3dd1652d32d15cce5"
meta/recipes-core/util-linux/util-linux/tests-blkdiscard.patch new file +31 -0
new file mode 100644
index 00000000000..34b07a4b2de
@@ -0,0 +1,31 @@
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <[email protected]>
+
+From 45fe65d934df2c938701f1c3cd3e0a6f3bdf25e6 Mon Sep 17 00:00:00 2001
+From: Ross Burton <[email protected]>
+Date: Tue, 29 Jun 2021 18:10:40 +0100
+Subject: [PATCH] tests/blkdiscard: check correct log file for errors
+
+When checking if the discard ioctl is supported, look in stderr not stdout.
+
+Signed-off-by: Ross Burton <[email protected]>
+---
+ tests/ts/blkdiscard/offsets | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/ts/blkdiscard/offsets b/tests/ts/blkdiscard/offsets
+index 9dddc35e2..5e724d51b 100755
+--- a/tests/ts/blkdiscard/offsets
++++ b/tests/ts/blkdiscard/offsets
+@@ -48,7 +48,7 @@ ts_log "testing offsets with full block size"
+ run_tscmd $TS_CMD_BLKDISCARD -v $DEVICE
+ if [ "$?" != "0" ]; then
+ 	# Skip the rest? For example loop backing files on NFS seem unsupported.
+-	grep -q "BLKDISCARD ioctl failed: Operation not supported" "$TS_OUTPUT" \
++	grep -q "BLKDISCARD ioctl failed: Operation not supported" "$TS_ERRLOG" \
+ 		&& ts_skip "BLKDISCARD not supported"
+ fi
+ run_tscmd $TS_CMD_BLKDISCARD -v -o 1 $DEVICE
+-- 
+2.25.1
+
meta/recipes-core/util-linux/util-linux/tests-eject.patch new file +56 -0

56 lines not on this page · raw message

meta/recipes-core/util-linux/util-linux/tests-kill.patch new file +88 -0

88 lines not on this page · raw message

meta/recipes-core/util-linux/util-linux/tests-lscpu.patch new file +42 -0

42 lines not on this page · raw message

meta/recipes-core/util-linux/util-linux/tests-ul.patch new file +35 -0
new file mode 100644
index 00000000000..6896393105e
@@ -0,0 +1,35 @@
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <[email protected]>
+
+From b1c71f19ea404e74d36ca5b8fbb0484043cdaef3 Mon Sep 17 00:00:00 2001
+From: Ross Burton <[email protected]>
+Date: Wed, 30 Jun 2021 11:25:01 +0100
+Subject: [PATCH] tests: mark ul/ul as a known failure
+
+As with ul/basic, this test produces different output when ran under
+different terminals, which isn't very useful.
+
+Set TS_KNOWN_FAIL so that these problems don't cause the test to fail.
+
+Signed-off-by: Ross Burton <[email protected]>
+---
+ tests/ts/ul/ul | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/tests/ts/ul/ul b/tests/ts/ul/ul
+index b856e33db..c707658ac 100755
+--- a/tests/ts/ul/ul
++++ b/tests/ts/ul/ul
+@@ -20,6 +20,9 @@ ts_init "$*"
+ 
+ ts_check_test_command "$TS_CMD_UL"
+ 
++# This test provides different result on some terminals and virtual machines
++TS_KNOWN_FAIL="yes"
++
+ printf "a\x08ab\x5F\x08c\\n\\ttab\\f\\b\\r" |
+ 	$TS_CMD_UL -t xterm >> $TS_OUTPUT 2>> $TS_ERRLOG
+ 
+-- 
+2.25.1
+
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 5/5 util-linux: rewrite the ptest integration

In reply to Ross Burton

Instead of duplicating logic, we can use the run.sh that the test suite installs.

Unless told otherwise, the util-linux test suite assumes that it is running in a build tree and looks for binaries to run, but we're on target so pass --use-system-commands (drops ~180 skips to tens).

Add --show-diff so that debugging can be done from the logs alone.

Remove redundant path manipulation that is now done upstream.

If PAM is disabled, delete the chfn test: it will run the chfn from shadow which has different output, and the test will fail.

[ YOCTO #14244 ]

---
 .../util-linux/util-linux/run-ptest           | 23 ++---------------
 .../util-linux/util-linux_2.37.bb             | 25 ++++---------------
 2 files changed, 7 insertions(+), 41 deletions(-)
meta/recipes-core/util-linux/util-linux/run-ptest +2 -21
index e135ee583bd..3a910be1218 100644
@@ -13,31 +13,12 @@ current_path=$(readlink -f $0)
 export bindir=$(dirname $current_path)
 export PATH=$bindir/bin:$PATH
 
-cd tests || exit 1                                                          
-
-comps=$(find ts/ -type f -perm -111 -regex ".*/[^\.~]*" |  sort)
-
-
-echo
-echo "-------------------- util-linux regression tests --------------------"
-echo
-echo "                    For development purpose only.                    "
-echo "                 Don't execute on production system!                 "
-echo
-
-res=0
-count=0
-for ts in $comps; 
-do 
-   $ts | sed -u '{        
+./tests/run.sh --use-system-commands --parsable --show-diff | sed -u '{
       s/^\(.*\):\(.*\) \.\.\. OK$/PASS: \1:\2/                              
       s/^\(.*\):\(.*\) \.\.\. FAILED \(.*\)$/FAIL: \1:\2 \3/                
       s/^\(.*\):\(.*\) \.\.\. SKIPPED \(.*\)$/SKIP: \1:\2 \3/               
-   }' 
-done
-
+   }'
 
 if [ "x$UDEV_PID" != "x" ]; then
     /etc/init.d/udev start
 fi
-
meta/recipes-core/util-linux/util-linux_2.37.bb +5 -20
index 48b6208612e..399f66d6a01 100644
@@ -280,25 +280,10 @@ do_install_ptest() {
     cp -pR ${S}/tests/ts ${D}${PTEST_PATH}/tests/
     cp ${WORKDIR}/build/config.h ${D}${PTEST_PATH}
 
-    # The original paths of executables to be tested point to a local folder containing
-    # the executables. We want to test the installed executables, not the local copies.
-    # So strip the paths, the executables will be located via "which"
-    sed  -i \
-         -e '/^TS_CMD/ s|$top_builddir/||g' \
-         -e '/^TS_HELPER/ s|$top_builddir|${PTEST_PATH}|g' \
-         ${D}${PTEST_PATH}/tests/commands.sh
-
-    # Change 'if [ ! -x "$1" ]' to 'if [ ! -x "`which $1 2>/dev/null`"]'
-    sed -i -e \
-        '/^\tif[[:space:]]\[[[:space:]]![[:space:]]-x[[:space:]]"$1"/s|$1|`which $1 2>/dev/null`|g' \
-         ${D}${PTEST_PATH}/tests/functions.sh
-
-    # Running "kill" without the the complete path would use the shell's built-in kill
-    sed -i -e \
-         '/^TS_CMD_KILL/ s|kill|${PTEST_PATH}/bin/kill|g' \
-         ${D}${PTEST_PATH}/tests/commands.sh
-
-
-    sed -i 's|@base_sbindir@|${base_sbindir}|g'       ${D}${PTEST_PATH}/run-ptest
+    sed -i 's|@base_sbindir@|${base_sbindir}|g' ${D}${PTEST_PATH}/run-ptest
 
+    # chfn needs PAM
+    if ! ${@bb.utils.contains('PACKAGECONFIG', 'pam', 'true', 'false', d)}; then
+        rm -rf ${D}${PTEST_PATH}/tests/ts/chfn
+    fi
 }
Signature · 1 line
2.25.1