Skip to contentSkip to conversation

util-linux: add setpriv utility

PATCH Superseded Randy MacLeod 4 participants 16 messages Jun 14, 2019 – Jun 17, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 util-linux: add setpriv utility

Enable the setpriv utility for targets only. It will be used in the run-ptest script for bash and perhaps other packages where the ptest code is expected to run as a user.

setpriv uses libcap-ng which doesn't build natively so disable it for native* builds. Also, busybox has a setpriv implementation so ensure that setpriv adheres to the alternatives scheme.

---
 meta/recipes-core/util-linux/util-linux.inc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
meta/recipes-core/util-linux/util-linux.inc +11 -4
index df1d1224dd..2d8991095c 100644
@@ -20,7 +20,7 @@ LIC_FILES_CHKSUM = "file://README.licensing;md5=972a134f1e14b2b060e365df2fab0099
 
 #gtk-doc is not enabled as it requires xmlto which requires util-linux
 inherit autotools gettext manpages pkgconfig systemd update-alternatives python3-dir bash-completion ptest
-DEPENDS = "zlib ncurses virtual/crypt"
+DEPENDS = "libcap-ng ncurses virtual/crypt zlib"
 
 MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/v${MAJOR_VERSION}/${BP}.tar.xz \
@@ -102,6 +102,10 @@ EXTRA_OECONF = "\
     --libdir='${UTIL_LINUX_LIBDIR}' \
 "
 
+EXTRA_OECONF_append_class-target = " --enable-setpriv"
+EXTRA_OECONF_append_class-native = " --without-cap-ng --disable-setpriv"
+EXTRA_OECONF_append_class-nativesdk = " --without-cap-ng --disable-setpriv"
+
 PACKAGECONFIG_class-target ?= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}"
 # inherit manpages requires this to be present, however util-linux does not have 
 # configuration options, and installs manpages always
@@ -109,8 +113,6 @@ PACKAGECONFIG[manpages] = ""
 PACKAGECONFIG[pam] = "--enable-su --enable-runuser,--disable-su --disable-runuser, libpam,"
 # Respect the systemd feature for uuidd
 PACKAGECONFIG[systemd] = "--with-systemd --with-systemdsystemunitdir=${systemd_system_unitdir}, --without-systemd --without-systemdsystemunitdir,systemd"
-# Build setpriv requires libcap-ng
-PACKAGECONFIG[libcap-ng] = "--enable-setpriv,--disable-setpriv,libcap-ng,"
 # Build python bindings for libmount
 PACKAGECONFIG[pylibmount] = "--with-python=3 --enable-pylibmount,--without-python --disable-pylibmount,python3"
 # Readline support
@@ -248,6 +250,7 @@ ALTERNATIVE_LINK_NAME[readprofile] = "${sbindir}/readprofile"
 ALTERNATIVE_LINK_NAME[renice] = "${bindir}/renice"
 ALTERNATIVE_LINK_NAME[rev] = "${bindir}/rev"
 ALTERNATIVE_LINK_NAME[rfkill] = "${sbindir}/rfkill"
+ALTERNATIVE_LINK_NAME[setpriv] = "${bindir}/setpriv"
 ALTERNATIVE_LINK_NAME[setsid] = "${bindir}/setsid"
 ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
 ALTERNATIVE_LINK_NAME[sulogin] = "${base_sbindir}/sulogin"
@@ -260,7 +263,10 @@ ALTERNATIVE_LINK_NAME[unshare] = "${bindir}/unshare"
 ALTERNATIVE_LINK_NAME[utmpdump] = "${bindir}/utmpdump"
 ALTERNATIVE_LINK_NAME[wall] = "${bindir}/wall"
 
-ALTERNATIVE_${PN}-doc = "blkid.8 eject.1 findfs.8 fsck.8 kill.1 last.1 lastb.1 libblkid.3 logger.1 mesg.1 mountpoint.1 nologin.8 rfkill.8 sulogin.8 utmpdump.1 uuid.3 wall.1"
+ALTERNATIVE_${PN}-doc = "\
+blkid.8 eject.1 findfs.8 fsck.8 kill.1 last.1 lastb.1 libblkid.3 logger.1 mesg.1 \
+mountpoint.1 nologin.8 rfkill.8 setpriv.1 sulogin.8 utmpdump.1 uuid.3 wall.1\
+"
 ALTERNATIVE_${PN}-doc += "${@bb.utils.contains('PACKAGECONFIG', 'pam', 'su.1', '', d)}"
 
 ALTERNATIVE_LINK_NAME[blkid.8] = "${mandir}/man8/blkid.8"
@@ -276,6 +282,7 @@ ALTERNATIVE_LINK_NAME[mesg.1] = "${mandir}/man1/mesg.1"
 ALTERNATIVE_LINK_NAME[mountpoint.1] = "${mandir}/man1/mountpoint.1"
 ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
 ALTERNATIVE_LINK_NAME[rfkill.8] = "${mandir}/man8/rfkill.8"
+ALTERNATIVE_LINK_NAME[setpriv.1] = "${mandir}/man1/setpriv.1"
 ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
 ALTERNATIVE_LINK_NAME[sulogin.8] = "${mandir}/man8/sulogin.8"
 ALTERNATIVE_LINK_NAME[utmpdump.1] = "${mandir}/man1/utmpdump.1"
Signature · 1 line
2.17.0
#1 lore raw

PATCH 2/4 libcap-ng: split into libcap-ng/libcap-ng-python

util-linux's setpriv needs the libcap-ng library but not the python package so split the package up to enable this without a dependency loop.

---
 meta/recipes-support/libcap-ng/libcap-ng      |  1 +
 .../python.patch                              |  0
 .../libcap-ng/libcap-ng-python_0.7.9.bb       | 27 ++++++++++++++++++
 meta/recipes-support/libcap-ng/libcap-ng.inc  | 17 +++++++++++
 .../libcap-ng/libcap-ng_0.7.9.bb              | 28 +++----------------
 5 files changed, 49 insertions(+), 24 deletions(-)
 create mode 120000 meta/recipes-support/libcap-ng/libcap-ng
 rename meta/recipes-support/libcap-ng/{libcap-ng => libcap-ng-python}/python.patch (100%)
 create mode 100644 meta/recipes-support/libcap-ng/libcap-ng-python_0.7.9.bb
 create mode 100644 meta/recipes-support/libcap-ng/libcap-ng.inc
meta/recipes-support/libcap-ng/libcap-ng new file +1 -0
new file mode 120000
index 0000000000..fb7744d293
@@ -0,0 +1 @@
+libcap-ng-python
\ No newline at end of file
meta/recipes-support/libcap-ng/libcap-ng-python/python.patch renamed from meta/recipes-support/libcap-ng/libcap-ng/python.patch +0 -0
similarity index 100%
rename from meta/recipes-support/libcap-ng/libcap-ng/python.patch
rename to meta/recipes-support/libcap-ng/libcap-ng-python/python.patch
meta/recipes-support/libcap-ng/libcap-ng-python_0.7.9.bb new file +27 -0
new file mode 100644
index 0000000000..e49b445f57
@@ -0,0 +1,27 @@
+require libcap-ng.inc
+
+SUMMARY .= " - python"
+
+inherit lib_package autotools python3native
+
+DEPENDS += "libcap-ng python3 swig-native"
+
+S = "${WORKDIR}/libcap-ng-${PV}"
+
+EXTRA_OECONF += "--with-python --with-python3"
+EXTRA_OEMAKE += "PYLIBVER='python${PYTHON_BASEVERSION}${PYTHON_ABI}' PYINC='${STAGING_INCDIR}/${PYLIBVER}'"
+
+do_install_append() {
+    rm -rf ${D}${bindir}
+    rm -rf ${D}${libdir}/.debug
+    rm -f ${D}${libdir}/lib*
+    rm -rf ${D}${libdir}/pkgconfig
+    rm -rf ${D}${datadir}
+    rm -rf ${D}${includedir}
+}
+
+# PACKAGES = "${PN}"
+
+FILES_${PN} = "${libdir}/python${PYTHON_BASEVERSION}"
+FILES_${PN}-dbg =+ "${PYTHON_SITEPACKAGES_DIR}/.debug/_capng.so"
+
meta/recipes-support/libcap-ng/libcap-ng.inc new file +17 -0
new file mode 100644
index 0000000000..739b91fd2e
@@ -0,0 +1,17 @@
+SUMMARY = "An alternate posix capabilities library"
+DESCRIPTION = "The libcap-ng library is intended to make programming \
+with POSIX capabilities much easier than the traditional libcap library."
+HOMEPAGE = "http://freecode.com/projects/libcap-ng"
+SECTION = "base"
+LICENSE = "GPLv2+ & LGPLv2.1+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
+		    file://COPYING.LIB;md5=e3eda01d9815f8d24aae2dbd89b68b06"
+
+SRC_URI = "http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${PV}.tar.gz \
+           file://python.patch \
+"
+
+SRC_URI[md5sum] = "2398d695508fab9ce33668c53a89b0e9"
+SRC_URI[sha256sum] = "4a1532bcf3731aade40936f6d6a586ed5a66ca4c7455e1338d1f6c3e09221328"
+
+BBCLASSEXTEND = "native nativesdk"
\ No newline at end of file
meta/recipes-support/libcap-ng/libcap-ng_0.7.9.bb +4 -24
index aff6259db2..6e6de45494 100644
@@ -1,30 +1,10 @@
-SUMMARY = "An alternate posix capabilities library"
-DESCRIPTION = "The libcap-ng library is intended to make programming \
-with POSIX capabilities much easier than the traditional libcap library."
-HOMEPAGE = "http://freecode.com/projects/libcap-ng"
-SECTION = "base"
-LICENSE = "GPLv2+ & LGPLv2.1+"
-LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
-		    file://COPYING.LIB;md5=e3eda01d9815f8d24aae2dbd89b68b06"
+require libcap-ng.inc
 
-SRC_URI = "http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${PV}.tar.gz \
-           file://python.patch"
+inherit lib_package autotools
 
-inherit lib_package autotools python3native
+EXTRA_OECONF += "--without-python --without-python3"
 
-SRC_URI[md5sum] = "2398d695508fab9ce33668c53a89b0e9"
-SRC_URI[sha256sum] = "4a1532bcf3731aade40936f6d6a586ed5a66ca4c7455e1338d1f6c3e09221328"
-
-DEPENDS += "swig-native python3"
-
-EXTRA_OECONF += "--with-python --with-python3"
-EXTRA_OEMAKE += "PYLIBVER='python${PYTHON_BASEVERSION}${PYTHON_ABI}' PYINC='${STAGING_INCDIR}/${PYLIBVER}'"
-
-PACKAGES += "${PN}-python"
-
-FILES_${PN}-python = "${libdir}/python${PYTHON_BASEVERSION}"
-
-BBCLASSEXTEND = "native"
+BBCLASSEXTEND = "native nativesdk"
 
 do_install_append() {
 	# Moving libcap-ng to base_libdir
Signature · 1 line
2.17.0
#2 lore raw

Re: [PATCH 2/4] libcap-ng: split into libcap-ng/libcap-ng-python

Quoted 5 lines · Randy MacLeod

util-linux's setpriv needs the libcap-ng library but not the python package so split the package up to enable this without a dependency loop.

Quoted 15 lines
---
 meta/recipes-support/libcap-ng/libcap-ng      |  1 +
 .../python.patch                              |  0
 .../libcap-ng/libcap-ng-python_0.7.9.bb       | 27
++++++++++++++++++
 meta/recipes-support/libcap-ng/libcap-ng.inc  | 17 +++++++++++
 .../libcap-ng/libcap-ng_0.7.9.bb              | 28 +++------------
----
 5 files changed, 49 insertions(+), 24 deletions(-)
 create mode 120000 meta/recipes-support/libcap-ng/libcap-ng
 rename meta/recipes-support/libcap-ng/{libcap-ng => libcap-ng-
python}/python.patch (100%)
 create mode 100644 meta/recipes-support/libcap-ng/libcap-ng-
python_0.7.9.bb
 create mode 100644 meta/recipes-support/libcap-ng/libcap-ng.inc

This is going to fail on the autobuilder due to a missing maintainers.inc entry...

Cheers,

Richard

#3 lore raw

PATCH 1/4 util-linux: add setpriv utility

Enable the setpriv utility for targets only. It will be used in the run-ptest script for bash and perhaps other packages where the ptest code is expected to run as a user.

setpriv uses libcap-ng which doesn't build natively so disable it for native* builds. Also, busybox has a setpriv implementation so ensure that setpriv adheres to the alternatives scheme.

---
 meta/recipes-core/util-linux/util-linux.inc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
meta/recipes-core/util-linux/util-linux.inc +11 -4
index df1d1224dd..2d8991095c 100644
@@ -20,7 +20,7 @@ LIC_FILES_CHKSUM = "file://README.licensing;md5=972a134f1e14b2b060e365df2fab0099
 
 #gtk-doc is not enabled as it requires xmlto which requires util-linux
 inherit autotools gettext manpages pkgconfig systemd update-alternatives python3-dir bash-completion ptest
-DEPENDS = "zlib ncurses virtual/crypt"
+DEPENDS = "libcap-ng ncurses virtual/crypt zlib"
 
 MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/v${MAJOR_VERSION}/${BP}.tar.xz \
@@ -102,6 +102,10 @@ EXTRA_OECONF = "\
     --libdir='${UTIL_LINUX_LIBDIR}' \
 "
 
+EXTRA_OECONF_append_class-target = " --enable-setpriv"
+EXTRA_OECONF_append_class-native = " --without-cap-ng --disable-setpriv"
+EXTRA_OECONF_append_class-nativesdk = " --without-cap-ng --disable-setpriv"
+
 PACKAGECONFIG_class-target ?= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}"
 # inherit manpages requires this to be present, however util-linux does not have 
 # configuration options, and installs manpages always
@@ -109,8 +113,6 @@ PACKAGECONFIG[manpages] = ""
 PACKAGECONFIG[pam] = "--enable-su --enable-runuser,--disable-su --disable-runuser, libpam,"
 # Respect the systemd feature for uuidd
 PACKAGECONFIG[systemd] = "--with-systemd --with-systemdsystemunitdir=${systemd_system_unitdir}, --without-systemd --without-systemdsystemunitdir,systemd"
-# Build setpriv requires libcap-ng
-PACKAGECONFIG[libcap-ng] = "--enable-setpriv,--disable-setpriv,libcap-ng,"
 # Build python bindings for libmount
 PACKAGECONFIG[pylibmount] = "--with-python=3 --enable-pylibmount,--without-python --disable-pylibmount,python3"
 # Readline support
@@ -248,6 +250,7 @@ ALTERNATIVE_LINK_NAME[readprofile] = "${sbindir}/readprofile"
 ALTERNATIVE_LINK_NAME[renice] = "${bindir}/renice"
 ALTERNATIVE_LINK_NAME[rev] = "${bindir}/rev"
 ALTERNATIVE_LINK_NAME[rfkill] = "${sbindir}/rfkill"
+ALTERNATIVE_LINK_NAME[setpriv] = "${bindir}/setpriv"
 ALTERNATIVE_LINK_NAME[setsid] = "${bindir}/setsid"
 ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
 ALTERNATIVE_LINK_NAME[sulogin] = "${base_sbindir}/sulogin"
@@ -260,7 +263,10 @@ ALTERNATIVE_LINK_NAME[unshare] = "${bindir}/unshare"
 ALTERNATIVE_LINK_NAME[utmpdump] = "${bindir}/utmpdump"
 ALTERNATIVE_LINK_NAME[wall] = "${bindir}/wall"
 
-ALTERNATIVE_${PN}-doc = "blkid.8 eject.1 findfs.8 fsck.8 kill.1 last.1 lastb.1 libblkid.3 logger.1 mesg.1 mountpoint.1 nologin.8 rfkill.8 sulogin.8 utmpdump.1 uuid.3 wall.1"
+ALTERNATIVE_${PN}-doc = "\
+blkid.8 eject.1 findfs.8 fsck.8 kill.1 last.1 lastb.1 libblkid.3 logger.1 mesg.1 \
+mountpoint.1 nologin.8 rfkill.8 setpriv.1 sulogin.8 utmpdump.1 uuid.3 wall.1\
+"
 ALTERNATIVE_${PN}-doc += "${@bb.utils.contains('PACKAGECONFIG', 'pam', 'su.1', '', d)}"
 
 ALTERNATIVE_LINK_NAME[blkid.8] = "${mandir}/man8/blkid.8"
@@ -276,6 +282,7 @@ ALTERNATIVE_LINK_NAME[mesg.1] = "${mandir}/man1/mesg.1"
 ALTERNATIVE_LINK_NAME[mountpoint.1] = "${mandir}/man1/mountpoint.1"
 ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
 ALTERNATIVE_LINK_NAME[rfkill.8] = "${mandir}/man8/rfkill.8"
+ALTERNATIVE_LINK_NAME[setpriv.1] = "${mandir}/man1/setpriv.1"
 ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
 ALTERNATIVE_LINK_NAME[sulogin.8] = "${mandir}/man8/sulogin.8"
 ALTERNATIVE_LINK_NAME[utmpdump.1] = "${mandir}/man1/utmpdump.1"
Signature · 1 line
2.17.0
#4 lore raw

PATCH 2/4 libcap-ng: split into libcap-ng/libcap-ng-python

util-linux's setpriv needs the libcap-ng library but not the python package so split the package up to enable this without a dependency loop.

Add libcap-ng-python to mainatiners.inc.

---
 meta/conf/distro/include/maintainers.inc      |  1 +
 meta/recipes-support/libcap-ng/libcap-ng      |  1 +
 .../python.patch                              |  0
 .../libcap-ng/libcap-ng-python_0.7.9.bb       | 27 ++++++++++++++++++
 meta/recipes-support/libcap-ng/libcap-ng.inc  | 17 +++++++++++
 .../libcap-ng/libcap-ng_0.7.9.bb              | 28 +++----------------
 6 files changed, 50 insertions(+), 24 deletions(-)
 create mode 120000 meta/recipes-support/libcap-ng/libcap-ng
 rename meta/recipes-support/libcap-ng/{libcap-ng => libcap-ng-python}/python.patch (100%)
 create mode 100644 meta/recipes-support/libcap-ng/libcap-ng-python_0.7.9.bb
 create mode 100644 meta/recipes-support/libcap-ng/libcap-ng.inc
meta/conf/distro/include/maintainers.inc +1 -0
index 40c93107c8..3a109b5aea 100644
@@ -312,6 +312,7 @@ RECIPE_MAINTAINER_pn-libatomic-ops = "Anuj Mittal <[email protected]>"
 RECIPE_MAINTAINER_pn-libbsd = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER_pn-libcap = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER_pn-libcap-ng = "Yi Zhao <[email protected]>"
+RECIPE_MAINTAINER_pn-libcap-ng-python = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER_pn-libcgroup = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER_pn-libcheck = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER_pn-libcomps = "Alexander Kanavin <[email protected]>"
meta/recipes-support/libcap-ng/libcap-ng new file +1 -0
new file mode 120000
index 0000000000..fb7744d293
@@ -0,0 +1 @@
+libcap-ng-python
\ No newline at end of file
meta/recipes-support/libcap-ng/libcap-ng-python/python.patch renamed from meta/recipes-support/libcap-ng/libcap-ng/python.patch +0 -0
similarity index 100%
rename from meta/recipes-support/libcap-ng/libcap-ng/python.patch
rename to meta/recipes-support/libcap-ng/libcap-ng-python/python.patch
meta/recipes-support/libcap-ng/libcap-ng-python_0.7.9.bb new file +27 -0
new file mode 100644
index 0000000000..e49b445f57
@@ -0,0 +1,27 @@
+require libcap-ng.inc
+
+SUMMARY .= " - python"
+
+inherit lib_package autotools python3native
+
+DEPENDS += "libcap-ng python3 swig-native"
+
+S = "${WORKDIR}/libcap-ng-${PV}"
+
+EXTRA_OECONF += "--with-python --with-python3"
+EXTRA_OEMAKE += "PYLIBVER='python${PYTHON_BASEVERSION}${PYTHON_ABI}' PYINC='${STAGING_INCDIR}/${PYLIBVER}'"
+
+do_install_append() {
+    rm -rf ${D}${bindir}
+    rm -rf ${D}${libdir}/.debug
+    rm -f ${D}${libdir}/lib*
+    rm -rf ${D}${libdir}/pkgconfig
+    rm -rf ${D}${datadir}
+    rm -rf ${D}${includedir}
+}
+
+# PACKAGES = "${PN}"
+
+FILES_${PN} = "${libdir}/python${PYTHON_BASEVERSION}"
+FILES_${PN}-dbg =+ "${PYTHON_SITEPACKAGES_DIR}/.debug/_capng.so"
+
meta/recipes-support/libcap-ng/libcap-ng.inc new file +17 -0
new file mode 100644
index 0000000000..739b91fd2e
@@ -0,0 +1,17 @@
+SUMMARY = "An alternate posix capabilities library"
+DESCRIPTION = "The libcap-ng library is intended to make programming \
+with POSIX capabilities much easier than the traditional libcap library."
+HOMEPAGE = "http://freecode.com/projects/libcap-ng"
+SECTION = "base"
+LICENSE = "GPLv2+ & LGPLv2.1+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
+		    file://COPYING.LIB;md5=e3eda01d9815f8d24aae2dbd89b68b06"
+
+SRC_URI = "http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${PV}.tar.gz \
+           file://python.patch \
+"
+
+SRC_URI[md5sum] = "2398d695508fab9ce33668c53a89b0e9"
+SRC_URI[sha256sum] = "4a1532bcf3731aade40936f6d6a586ed5a66ca4c7455e1338d1f6c3e09221328"
+
+BBCLASSEXTEND = "native nativesdk"
\ No newline at end of file
meta/recipes-support/libcap-ng/libcap-ng_0.7.9.bb +4 -24
index aff6259db2..6e6de45494 100644
@@ -1,30 +1,10 @@
-SUMMARY = "An alternate posix capabilities library"
-DESCRIPTION = "The libcap-ng library is intended to make programming \
-with POSIX capabilities much easier than the traditional libcap library."
-HOMEPAGE = "http://freecode.com/projects/libcap-ng"
-SECTION = "base"
-LICENSE = "GPLv2+ & LGPLv2.1+"
-LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
-		    file://COPYING.LIB;md5=e3eda01d9815f8d24aae2dbd89b68b06"
+require libcap-ng.inc
 
-SRC_URI = "http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${PV}.tar.gz \
-           file://python.patch"
+inherit lib_package autotools
 
-inherit lib_package autotools python3native
+EXTRA_OECONF += "--without-python --without-python3"
 
-SRC_URI[md5sum] = "2398d695508fab9ce33668c53a89b0e9"
-SRC_URI[sha256sum] = "4a1532bcf3731aade40936f6d6a586ed5a66ca4c7455e1338d1f6c3e09221328"
-
-DEPENDS += "swig-native python3"
-
-EXTRA_OECONF += "--with-python --with-python3"
-EXTRA_OEMAKE += "PYLIBVER='python${PYTHON_BASEVERSION}${PYTHON_ABI}' PYINC='${STAGING_INCDIR}/${PYLIBVER}'"
-
-PACKAGES += "${PN}-python"
-
-FILES_${PN}-python = "${libdir}/python${PYTHON_BASEVERSION}"
-
-BBCLASSEXTEND = "native"
+BBCLASSEXTEND = "native nativesdk"
 
 do_install_append() {
 	# Moving libcap-ng to base_libdir
Signature · 1 line
2.17.0
#5 lore raw

PATCH 3/4 ptest-runner: enable child procs as session leader

In reply to Randy MacLeod

When running the run-execscript bash ptest as a user rather than root, a warning:
bash: cannot set terminal process group (16036): Inappropriate ioctl for device
bash: no job control in this shell
contaminates the bash log files causing the test to fail. This happens only when run under ptest-runner and not when interactively testing!

The changes made to fix this include:
1. Get the process group id (pgid) before forking,
2. Set the pgid in both the parent and child to avoid a race,
3. Find, open and set permission on the child tty, and
4. Allow the child to attach to controlling tty.

---
 ...s-ensure-child-can-be-session-leader.patch | 212 ++++++++++++++++++
 .../ptest-runner/ptest-runner_2.3.1.bb        |   4 +-
 2 files changed, 215 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch
meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch new file +212 -0
new file mode 100644
index 0000000000..13b4cbc7fb
@@ -0,0 +1,212 @@
+From 79698d3205dedba887e0d2492de945d3079de029 Mon Sep 17 00:00:00 2001
+From: Randy MacLeod <[email protected]>
+Date: Thu, 6 Jun 2019 17:03:50 -0400
+Subject: [PATCH] utils: ensure child can be session leader
+
+When running the run-execscript bash ptest as a user rather than root, a warning:
+  bash: cannot set terminal process group (16036): Inappropriate ioctl for device
+  bash: no job control in this shell
+contaminates the bash log files causing the test to fail. This happens only
+when run under ptest-runner and not when interactively testing!
+
+The changes made to fix this include:
+1. Get the process group id (pgid) before forking,
+2. Set the pgid in both the parent and child to avoid a race,
+3. Find, open and set permission on the child tty, and
+4. Allow the child to attach to controlling tty.
+
+Also add '-lutil' to Makefile. This lib is from libc and provides openpty.
+
+Upstream-Status: Submitted [[email protected]]
+
+Signed-off-by: Sakib Sajal <[email protected]>
+Signed-off-by: Randy MacLeod <[email protected]>
+---
+ Makefile |   2 +-
+ utils.c  | 102 +++++++++++++++++++++++++++++++++++++++++++++++++------
+ 2 files changed, 92 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1bde7be..439eb79 100644
+--- a/Makefile
++++ b/Makefile
+@@ -29,7 +29,7 @@ TEST_DATA=$(shell echo `pwd`/tests/data)
+ all: $(SOURCES) $(EXECUTABLE)
+ 
+ $(EXECUTABLE): $(OBJECTS)
+-	$(CC) $(LDFLAGS) $(OBJECTS) -o $@
++	$(CC) $(LDFLAGS) $(OBJECTS) -lutil -o $@
+ 
+ tests: $(TEST_SOURCES) $(TEST_EXECUTABLE)
+ 
+diff --git a/utils.c b/utils.c
+index ad737c2..f11ce39 100644
+--- a/utils.c
++++ b/utils.c
+@@ -1,5 +1,6 @@
+ /**
+  * Copyright (c) 2016 Intel Corporation
++ * Copyright (C) 2019 Wind River Systems, Inc.
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+@@ -22,23 +23,27 @@
+  */
+ 
+ #define _GNU_SOURCE 
++
+ #include <stdio.h>
+ 
++#include <dirent.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <grp.h>
+ #include <libgen.h>
+-#include <signal.h>
+ #include <poll.h>
+-#include <fcntl.h>
++#include <pty.h>
++#include <signal.h>
++#include <stdlib.h>
++#include <string.h>
+ #include <time.h>
+-#include <dirent.h>
++#include <unistd.h>
++
++#include <sys/ioctl.h>
+ #include <sys/resource.h>
++#include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+-#include <sys/stat.h>
+-#include <unistd.h>
+-#include <string.h>
+-#include <stdlib.h>
+-
+-#include <errno.h>
+ 
+ #include "ptest_list.h"
+ #include "utils.h"
+@@ -346,6 +351,53 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
+ 	return status;
+ }
+ 
++/* Returns an integer file descriptor.
++ * If it returns < 0, an error has occurred.
++ * Otherwise, it has returned the slave pty file descriptor.
++ * fp should be writable, likely stdout/err.
++ */
++static int
++setup_slave_pty(FILE *fp) { 
++	int pty_master = -1;
++	int pty_slave = -1;
++	char pty_name[256];
++	struct group *gptr;
++	gid_t gid;
++	int slave = -1;
++
++	if (openpty(&pty_master, &pty_slave, pty_name, NULL, NULL) < 0) {
++		fprintf(fp, "ERROR: openpty() failed with: %s.\n", strerror(errno));
++		return -1;
++	}
++
++	if ((gptr = getgrnam(pty_name)) != 0) {
++		gid = gptr->gr_gid;
++	} else {
++		/* If the tty group does not exist, don't change the
++		 * group on the slave pty, only the owner
++		 */
++		gid = -1;
++	}
++
++	/* chown/chmod the corresponding pty, if possible.
++	 * This will only work if the process has root permissions.
++	 */
++	if (chown(pty_name, getuid(), gid) != 0) {
++		fprintf(fp, "ERROR; chown() failed with: %s.\n", strerror(errno));
++	}
++
++	/* Makes the slave read/writeable for the user. */
++	if (chmod(pty_name, S_IRUSR|S_IWUSR) != 0) {
++		fprintf(fp, "ERROR: chmod() failed with: %s.\n", strerror(errno));
++	}
++
++	if ((slave = open(pty_name, O_RDWR)) == -1) {
++		fprintf(fp, "ERROR: open() failed with: %s.\n", strerror(errno));
++	}
++	return (slave);
++}
++
++
+ int
+ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 		const char *progname, FILE *fp, FILE *fp_stderr)
+@@ -362,6 +414,8 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 	int timeouted;
+ 	time_t sttime, entime;
+ 	int duration;
++	int slave;
++	int pgid = -1;
+ 
+ 	if (opts.xml_filename) {
+ 		xh = xml_create(ptest_list_length(head), opts.xml_filename);
+@@ -379,7 +433,6 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 			close(pipefd_stdout[1]);
+ 			break;
+ 		}
+-
+ 		fprintf(fp, "START: %s\n", progname);
+ 		PTEST_LIST_ITERATE_START(head, p);
+ 			char *ptest_dir = strdup(p->run_ptest);
+@@ -388,6 +441,13 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 				break;
+ 			}
+ 			dirname(ptest_dir);
++			if (ioctl(0, TIOCNOTTY) == -1) {
++				fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
++			}
++
++			if ((pgid = getpgid(0)) == -1) {
++				fprintf(fp, "ERROR: getpgid() failed, %s\n", strerror(errno));
++			}
+ 
+ 			child = fork();
+ 			if (child == -1) {
+@@ -395,13 +455,33 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 				rc = -1;
+ 				break;
+ 			} else if (child == 0) {
+-				setsid();
++				close(0);
++				if ((slave = setup_slave_pty(fp)) < 0) {
++					fprintf(fp, "ERROR: could not setup pty (%d).", slave);
++				}
++				if (setpgid(0,pgid) == -1) {
++					fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
++				}
++
++				if (setsid() ==  -1) {
++					fprintf(fp, "ERROR: setsid() failed, %s\n", strerror(errno));
++				}
++
++				if (ioctl(0, TIOCSCTTY, NULL) == -1) {
++					fprintf(fp, "ERROR: Unable to attach to controlling tty, %s\n", strerror(errno));
++				}
++
+ 				run_child(p->run_ptest, pipefd_stdout[1], pipefd_stderr[1]);
++
+ 			} else {
+ 				int status;
+ 				int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
+ 				FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
+ 
++				if (setpgid(child, pgid) == -1) {
++					fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
++				}
++
+ 				sttime = time(NULL);
+ 				fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
+ 				fprintf(fp, "BEGIN: %s\n", ptest_dir);
+-- 
+2.17.0
+
meta/recipes-support/ptest-runner/ptest-runner_2.3.1.bb +3 -1
index 0450e18e4e..dec60fcc9b 100644
@@ -13,7 +13,9 @@ PV = "2.3.1+git${SRCPV}"
 SRC_URI = "git://git.yoctoproject.org/ptest-runner2 \
  file://0001-utils-Ensure-stdout-stderr-are-flushed.patch \
  file://0002-use-process-groups-when-spawning.patch \
- file://0003-utils-Ensure-pipes-are-read-after-exit.patch"
+ file://0003-utils-Ensure-pipes-are-read-after-exit.patch \
+ file://0004-utils-ensure-child-can-be-session-leader.patch \
+"
 
 S = "${WORKDIR}/git"
 
Signature · 1 line
2.17.0
#6 lore raw

PATCH 4/4 bash: use setpriv, sed.sed to run ptests

In reply to Randy MacLeod

The execscript test in bash fails when run with ptest-runner calling 'su', with the error:
bash: cannot set terminal process group (16036): Inappropriate ioctl for device
Even with ptest-runner fixed to make a child process use the right process group, 'su' still results in the warning above. Use 'setpriv' instead. 'runuser' was considered and works but depends on pam so it's ruled out.

Now that all bash tests are run as a user, the patch:
fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch
can be removed. Also to create the account 'bashtest' in the 'run-ptest' script the bash-ptest must depend on 'shadow'. Also, in 'run-ptest', ensure that the bash ptests are owned by the 'bashtest' user.

Add 'sed' as a dependency for ptests since tests/exp8.sub runs:
var=$'x\001y\177z'
declare -p var | sed -n l
and that results in:

    sed.busybox: ""
    sed.sed: declare -- var="x\001y\177z"$

This appears to be a feature that busybox sed has not implemented.

With this series of changes, bash-ptest for qemux86-64 passes 79 of 81 tests. The remaining failures are:

1. run-read:

  # cat tests/read6.sub
  # test read with a timeout of 0 -- input polling
  # sleep with fractional seconds argument is not universal
  echo abcde | { sleep 0.25 2>/dev/null ; read -t 0; }
  echo $?

read -t 0 < $0
echo $?

read -t 0
echo $? <-- returns 1, when 0 is expected.

I can reproduce this on my workstation but only when using ptest-runner and initially logging into the console as root. That's a little odd and seems like I need to continue to improve ptest-runner.

2. run-trap:

  # cat tests/trap3.sub
  PS4='+[$LINENO] '
  trap 'echo trap: $LINENO' ERR

set -x

echo 1
echo 2
echo 3 | cat | false <--- error
echo 4

This is a scheduler behaviour difference between the common case on a workstation and the common case in qemu. The test case does warn about the completion order not being deterministic so I plan to ignore it.

From tests/run-trap:
UNIX versions number signals and schedule processes differently. If output differing only in line numbers is produced, please do not consider this a test failure.

Still, it's notable and slightly odd that the common case output is different.

---
 meta/recipes-extended/bash/bash.inc           |  5 +--
 ...un-heredoc-run-execscript-run-test-f.patch | 45 -------------------
 .../bash/bash/run-bash-ptests                 |  4 ++
 meta/recipes-extended/bash/bash/run-ptest     | 10 ++---
 meta/recipes-extended/bash/bash_5.0.bb        |  2 +-
 5 files changed, 12 insertions(+), 54 deletions(-)
 delete mode 100644 meta/recipes-extended/bash/bash/fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch
 create mode 100644 meta/recipes-extended/bash/bash/run-bash-ptests
meta/recipes-extended/bash/bash.inc +2 -3
index 4cf1054967..c91cc8ada8 100644
@@ -23,7 +23,7 @@ ALTERNATIVE_PRIORITY = "100"
 
 RDEPENDS_${PN} += "base-files"
 RDEPENDS_${PN}_class-nativesdk = ""
-RDEPENDS_${PN}-ptest += "make coreutils perl"
+RDEPENDS_${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
 
 DEPENDS_append_libc-glibc = " virtual/libc-locale"
 RDEPENDS_${PN}-ptest_append_libc-glibc = " \
@@ -36,8 +36,6 @@ RDEPENDS_${PN}-ptest_append_libc-glibc = " \
 	locale-base-fr-fr.iso-8859-1 \
 	locale-base-zh-hk.big5-hkscs \
 	"
-USERADD_PACKAGES = "${PN}-ptest"
-USERADD_PARAM_${PN}-ptest = "--create-home --user-group test"
 
 CACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
 
@@ -74,6 +72,7 @@ do_install_append_class-target () {
 do_install_ptest () {
 	make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
 	cp ${B}/Makefile ${D}${PTEST_PATH}
+	install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
         sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
 	    -e 's|${DEBUG_PREFIX_MAP}||g' \
 	    -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
meta/recipes-extended/bash/bash/fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch deleted +0 -45

45 lines not on this page · raw message

meta/recipes-extended/bash/bash/run-bash-ptests new file +4 -0
new file mode 100644
index 0000000000..d73a27224d
@@ -0,0 +1,4 @@
+#!/bin/sh
+cd "$(dirname "$0")"
+make -k THIS_SH=/bin/bash BUILD_DIR=`pwd` srcdir=`pwd` runtest
+
meta/recipes-extended/bash/bash/run-ptest +5 -5
index c0cf27b6c2..738ad3c42c 100644
@@ -19,8 +19,8 @@ then
         echo "Warning: The de_DE* locales is needed to run the intl.tests, please add it."
 fi
 
-useradd bash_user
-chown -R bash_user:bash_user ./tests
-su bash_user -c "make -k THIS_SH=/bin/bash BUILD_DIR=`pwd` srcdir=`pwd` runtest"
-chown -R root:root ./tests
-userdel bash_user
+useradd bashtest
+chown -R bashtest:bashtest tests
+setpriv --reuid bashtest --rgid bashtest --clear-groups --reset-env $(dirname "$0")/run-bash-ptests
+chown -R root:root tests
+userdel -r bashtest
meta/recipes-extended/bash/bash_5.0.bb +1 -1
index e60e5304a5..eadc82279d 100644
@@ -16,8 +16,8 @@ SRC_URI = "${GNU_MIRROR}/bash/${BP}.tar.gz;name=tarball \
            file://mkbuiltins_have_stringize.patch \
            file://build-tests.patch \
            file://test-output.patch \
-           file://fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch \
            file://run-ptest \
+           file://run-bash-ptests \
            file://fix-run-builtins.patch \
            "
 
Signature · 1 line
2.17.0
#7 lore raw
In reply to Randy MacLeod
Quoted 4 lines · Randy MacLeod

Enable the setpriv utility for targets only. It will be used in the run-ptest script for bash and perhaps other packages where the ptest code is expected to run as a user.

Quoted 8 lines

setpriv uses libcap-ng which doesn't build natively so disable it for native* builds. Also, busybox has a setpriv implementation so ensure that setpriv adheres to the alternatives scheme.

---
 meta/recipes-core/util-linux/util-linux.inc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

No errors but the build is now seeing warnings e.g.:

https://autobuilder.yoctoproject.org/typhoon/#/builders/42/builds/703

Cheers,

Richard

#8 lore raw
Quoted 9 lines · Richard Purdie
Quoted 8 lines · Randy MacLeod

Enable the setpriv utility for targets only. It will be used in the run-ptest script for bash and perhaps other packages where the ptest code is expected to run as a user.

setpriv uses libcap-ng which doesn't build natively so disable it for native* builds. Also, busybox has a setpriv implementation so ensure that setpriv adheres to the alternatives scheme.

Quoted 9 lines
Quoted 4 lines
---
  meta/recipes-core/util-linux/util-linux.inc | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)

No errors but the build is now seeing warnings e.g.:

https://autobuilder.yoctoproject.org/typhoon/#/builders/42/builds/703

Fixed for my populate_sdk_ext build at least and hopefully for the autobuild tests. v3 sent.

../Randy

Quoted 4 lines

Cheers,

Richard

Signature · 2 lines
# Randy MacLeod
# Wind River Linux
#9 lore raw

PATCH 3/4 ptest-runner: enable child procs as session leader

In reply to Randy MacLeod

When running the run-execscript bash ptest as a user rather than root, a warning:
bash: cannot set terminal process group (16036): Inappropriate ioctl for device
bash: no job control in this shell
contaminates the bash log files causing the test to fail. This happens only when run under ptest-runner and not when interactively testing!

The changes made to fix this include:
1. Get the process group id (pgid) before forking,
2. Set the pgid in both the parent and child to avoid a race,
3. Find, open and set permission on the child tty, and
4. Allow the child to attach to controlling tty.

---
 ...s-ensure-child-can-be-session-leader.patch | 212 ++++++++++++++++++
 .../ptest-runner/ptest-runner_2.3.1.bb        |   4 +-
 2 files changed, 215 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch
meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch new file +212 -0
new file mode 100644
index 0000000000..13b4cbc7fb
@@ -0,0 +1,212 @@
+From 79698d3205dedba887e0d2492de945d3079de029 Mon Sep 17 00:00:00 2001
+From: Randy MacLeod <[email protected]>
+Date: Thu, 6 Jun 2019 17:03:50 -0400
+Subject: [PATCH] utils: ensure child can be session leader
+
+When running the run-execscript bash ptest as a user rather than root, a warning:
+  bash: cannot set terminal process group (16036): Inappropriate ioctl for device
+  bash: no job control in this shell
+contaminates the bash log files causing the test to fail. This happens only
+when run under ptest-runner and not when interactively testing!
+
+The changes made to fix this include:
+1. Get the process group id (pgid) before forking,
+2. Set the pgid in both the parent and child to avoid a race,
+3. Find, open and set permission on the child tty, and
+4. Allow the child to attach to controlling tty.
+
+Also add '-lutil' to Makefile. This lib is from libc and provides openpty.
+
+Upstream-Status: Submitted [[email protected]]
+
+Signed-off-by: Sakib Sajal <[email protected]>
+Signed-off-by: Randy MacLeod <[email protected]>
+---
+ Makefile |   2 +-
+ utils.c  | 102 +++++++++++++++++++++++++++++++++++++++++++++++++------
+ 2 files changed, 92 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1bde7be..439eb79 100644
+--- a/Makefile
++++ b/Makefile
+@@ -29,7 +29,7 @@ TEST_DATA=$(shell echo `pwd`/tests/data)
+ all: $(SOURCES) $(EXECUTABLE)
+ 
+ $(EXECUTABLE): $(OBJECTS)
+-	$(CC) $(LDFLAGS) $(OBJECTS) -o $@
++	$(CC) $(LDFLAGS) $(OBJECTS) -lutil -o $@
+ 
+ tests: $(TEST_SOURCES) $(TEST_EXECUTABLE)
+ 
+diff --git a/utils.c b/utils.c
+index ad737c2..f11ce39 100644
+--- a/utils.c
++++ b/utils.c
+@@ -1,5 +1,6 @@
+ /**
+  * Copyright (c) 2016 Intel Corporation
++ * Copyright (C) 2019 Wind River Systems, Inc.
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+@@ -22,23 +23,27 @@
+  */
+ 
+ #define _GNU_SOURCE 
++
+ #include <stdio.h>
+ 
++#include <dirent.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <grp.h>
+ #include <libgen.h>
+-#include <signal.h>
+ #include <poll.h>
+-#include <fcntl.h>
++#include <pty.h>
++#include <signal.h>
++#include <stdlib.h>
++#include <string.h>
+ #include <time.h>
+-#include <dirent.h>
++#include <unistd.h>
++
++#include <sys/ioctl.h>
+ #include <sys/resource.h>
++#include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+-#include <sys/stat.h>
+-#include <unistd.h>
+-#include <string.h>
+-#include <stdlib.h>
+-
+-#include <errno.h>
+ 
+ #include "ptest_list.h"
+ #include "utils.h"
+@@ -346,6 +351,53 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
+ 	return status;
+ }
+ 
++/* Returns an integer file descriptor.
++ * If it returns < 0, an error has occurred.
++ * Otherwise, it has returned the slave pty file descriptor.
++ * fp should be writable, likely stdout/err.
++ */
++static int
++setup_slave_pty(FILE *fp) { 
++	int pty_master = -1;
++	int pty_slave = -1;
++	char pty_name[256];
++	struct group *gptr;
++	gid_t gid;
++	int slave = -1;
++
++	if (openpty(&pty_master, &pty_slave, pty_name, NULL, NULL) < 0) {
++		fprintf(fp, "ERROR: openpty() failed with: %s.\n", strerror(errno));
++		return -1;
++	}
++
++	if ((gptr = getgrnam(pty_name)) != 0) {
++		gid = gptr->gr_gid;
++	} else {
++		/* If the tty group does not exist, don't change the
++		 * group on the slave pty, only the owner
++		 */
++		gid = -1;
++	}
++
++	/* chown/chmod the corresponding pty, if possible.
++	 * This will only work if the process has root permissions.
++	 */
++	if (chown(pty_name, getuid(), gid) != 0) {
++		fprintf(fp, "ERROR; chown() failed with: %s.\n", strerror(errno));
++	}
++
++	/* Makes the slave read/writeable for the user. */
++	if (chmod(pty_name, S_IRUSR|S_IWUSR) != 0) {
++		fprintf(fp, "ERROR: chmod() failed with: %s.\n", strerror(errno));
++	}
++
++	if ((slave = open(pty_name, O_RDWR)) == -1) {
++		fprintf(fp, "ERROR: open() failed with: %s.\n", strerror(errno));
++	}
++	return (slave);
++}
++
++
+ int
+ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 		const char *progname, FILE *fp, FILE *fp_stderr)
+@@ -362,6 +414,8 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 	int timeouted;
+ 	time_t sttime, entime;
+ 	int duration;
++	int slave;
++	int pgid = -1;
+ 
+ 	if (opts.xml_filename) {
+ 		xh = xml_create(ptest_list_length(head), opts.xml_filename);
+@@ -379,7 +433,6 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 			close(pipefd_stdout[1]);
+ 			break;
+ 		}
+-
+ 		fprintf(fp, "START: %s\n", progname);
+ 		PTEST_LIST_ITERATE_START(head, p);
+ 			char *ptest_dir = strdup(p->run_ptest);
+@@ -388,6 +441,13 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 				break;
+ 			}
+ 			dirname(ptest_dir);
++			if (ioctl(0, TIOCNOTTY) == -1) {
++				fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
++			}
++
++			if ((pgid = getpgid(0)) == -1) {
++				fprintf(fp, "ERROR: getpgid() failed, %s\n", strerror(errno));
++			}
+ 
+ 			child = fork();
+ 			if (child == -1) {
+@@ -395,13 +455,33 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
+ 				rc = -1;
+ 				break;
+ 			} else if (child == 0) {
+-				setsid();
++				close(0);
++				if ((slave = setup_slave_pty(fp)) < 0) {
++					fprintf(fp, "ERROR: could not setup pty (%d).", slave);
++				}
++				if (setpgid(0,pgid) == -1) {
++					fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
++				}
++
++				if (setsid() ==  -1) {
++					fprintf(fp, "ERROR: setsid() failed, %s\n", strerror(errno));
++				}
++
++				if (ioctl(0, TIOCSCTTY, NULL) == -1) {
++					fprintf(fp, "ERROR: Unable to attach to controlling tty, %s\n", strerror(errno));
++				}
++
+ 				run_child(p->run_ptest, pipefd_stdout[1], pipefd_stderr[1]);
++
+ 			} else {
+ 				int status;
+ 				int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
+ 				FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
+ 
++				if (setpgid(child, pgid) == -1) {
++					fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
++				}
++
+ 				sttime = time(NULL);
+ 				fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
+ 				fprintf(fp, "BEGIN: %s\n", ptest_dir);
+-- 
+2.17.0
+
meta/recipes-support/ptest-runner/ptest-runner_2.3.1.bb +3 -1
index 0450e18e4e..dec60fcc9b 100644
@@ -13,7 +13,9 @@ PV = "2.3.1+git${SRCPV}"
 SRC_URI = "git://git.yoctoproject.org/ptest-runner2 \
  file://0001-utils-Ensure-stdout-stderr-are-flushed.patch \
  file://0002-use-process-groups-when-spawning.patch \
- file://0003-utils-Ensure-pipes-are-read-after-exit.patch"
+ file://0003-utils-Ensure-pipes-are-read-after-exit.patch \
+ file://0004-utils-ensure-child-can-be-session-leader.patch \
+"
 
 S = "${WORKDIR}/git"
 
Signature · 1 line
2.17.0
#10 lore raw

PATCH 4/4 bash: use setpriv, sed.sed to run ptests

In reply to Randy MacLeod

The execscript test in bash fails when run with ptest-runner calling 'su', with the error:
bash: cannot set terminal process group (16036): Inappropriate ioctl for device
Even with ptest-runner fixed to make a child process use the right process group, 'su' still results in the warning above. Use 'setpriv' instead. 'runuser' was considered and works but depends on pam so it's ruled out.

Now that all bash tests are run as a user, the patch:
fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch
can be removed. Also to create the account 'bashtest' in the 'run-ptest' script the bash-ptest must depend on 'shadow'. Also, in 'run-ptest', ensure that the bash ptests are owned by the 'bashtest' user.

Add 'sed' as a dependency for ptests since tests/exp8.sub runs:
var=$'x\001y\177z'
declare -p var | sed -n l
and that results in:

    sed.busybox: ""
    sed.sed: declare -- var="x\001y\177z"$

This appears to be a feature that busybox sed has not implemented.

With this series of changes, bash-ptest for qemux86-64 passes 79 of 81 tests. The remaining failures are:

1. run-read:

  # cat tests/read6.sub
  # test read with a timeout of 0 -- input polling
  # sleep with fractional seconds argument is not universal
  echo abcde | { sleep 0.25 2>/dev/null ; read -t 0; }
  echo $?

read -t 0 < $0
echo $?

read -t 0
echo $? <-- returns 1, when 0 is expected.

I can reproduce this on my workstation but only when using ptest-runner and initially logging into the console as root. That's a little odd and seems like I need to continue to improve ptest-runner.

2. run-trap:

  # cat tests/trap3.sub
  PS4='+[$LINENO] '
  trap 'echo trap: $LINENO' ERR

set -x

echo 1
echo 2
echo 3 | cat | false <--- error
echo 4

This is a scheduler behaviour difference between the common case on a workstation and the common case in qemu. The test case does warn about the completion order not being deterministic so I plan to ignore it.

From tests/run-trap:
UNIX versions number signals and schedule processes differently. If output differing only in line numbers is produced, please do not consider this a test failure.

Still, it's notable and slightly odd that the common case output is different.

---
 meta/recipes-extended/bash/bash.inc           |  5 +--
 ...un-heredoc-run-execscript-run-test-f.patch | 45 -------------------
 .../bash/bash/run-bash-ptests                 |  4 ++
 meta/recipes-extended/bash/bash/run-ptest     | 10 ++---
 meta/recipes-extended/bash/bash_5.0.bb        |  2 +-
 5 files changed, 12 insertions(+), 54 deletions(-)
 delete mode 100644 meta/recipes-extended/bash/bash/fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch
 create mode 100644 meta/recipes-extended/bash/bash/run-bash-ptests
meta/recipes-extended/bash/bash.inc +2 -3
index 4cf1054967..c91cc8ada8 100644
@@ -23,7 +23,7 @@ ALTERNATIVE_PRIORITY = "100"
 
 RDEPENDS_${PN} += "base-files"
 RDEPENDS_${PN}_class-nativesdk = ""
-RDEPENDS_${PN}-ptest += "make coreutils perl"
+RDEPENDS_${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
 
 DEPENDS_append_libc-glibc = " virtual/libc-locale"
 RDEPENDS_${PN}-ptest_append_libc-glibc = " \
@@ -36,8 +36,6 @@ RDEPENDS_${PN}-ptest_append_libc-glibc = " \
 	locale-base-fr-fr.iso-8859-1 \
 	locale-base-zh-hk.big5-hkscs \
 	"
-USERADD_PACKAGES = "${PN}-ptest"
-USERADD_PARAM_${PN}-ptest = "--create-home --user-group test"
 
 CACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
 
@@ -74,6 +72,7 @@ do_install_append_class-target () {
 do_install_ptest () {
 	make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
 	cp ${B}/Makefile ${D}${PTEST_PATH}
+	install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
         sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
 	    -e 's|${DEBUG_PREFIX_MAP}||g' \
 	    -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
meta/recipes-extended/bash/bash/fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch deleted +0 -45

45 lines not on this page · raw message

meta/recipes-extended/bash/bash/run-bash-ptests new file +4 -0
new file mode 100644
index 0000000000..d73a27224d
@@ -0,0 +1,4 @@
+#!/bin/sh
+cd "$(dirname "$0")"
+make -k THIS_SH=/bin/bash BUILD_DIR=`pwd` srcdir=`pwd` runtest
+
meta/recipes-extended/bash/bash/run-ptest +5 -5
index c0cf27b6c2..738ad3c42c 100644
@@ -19,8 +19,8 @@ then
         echo "Warning: The de_DE* locales is needed to run the intl.tests, please add it."
 fi
 
-useradd bash_user
-chown -R bash_user:bash_user ./tests
-su bash_user -c "make -k THIS_SH=/bin/bash BUILD_DIR=`pwd` srcdir=`pwd` runtest"
-chown -R root:root ./tests
-userdel bash_user
+useradd bashtest
+chown -R bashtest:bashtest tests
+setpriv --reuid bashtest --rgid bashtest --clear-groups --reset-env $(dirname "$0")/run-bash-ptests
+chown -R root:root tests
+userdel -r bashtest
meta/recipes-extended/bash/bash_5.0.bb +1 -1
index e60e5304a5..eadc82279d 100644
@@ -16,8 +16,8 @@ SRC_URI = "${GNU_MIRROR}/bash/${BP}.tar.gz;name=tarball \
            file://mkbuiltins_have_stringize.patch \
            file://build-tests.patch \
            file://test-output.patch \
-           file://fix-run-coproc-run-heredoc-run-execscript-run-test-f.patch \
            file://run-ptest \
+           file://run-bash-ptests \
            file://fix-run-builtins.patch \
            "
 
Signature · 1 line
2.17.0
#11 lore raw

✗ patchtest: failure for "util-linux: add setpriv utilit..." and 3 more (rev2)

In reply to Randy MacLeod

== Series Details ==

Series: "util-linux: add setpriv utilit..." and 3 more (rev2)
Revision: 2
URL : https://patchwork.openembedded.org/series/18163/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at ca737408bb)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
#12 lore raw

✗ patchtest: failure for "util-linux: add setpriv utilit..." and 3 more (rev4)

In reply to Randy MacLeod

== Series Details ==

Series: "util-linux: add setpriv utilit..." and 3 more (rev4)
Revision: 4
URL : https://patchwork.openembedded.org/series/18163/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at ca737408bb)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
#13 lore raw

✗ patchtest: failure for "util-linux: add setpriv utilit..." and 3 more (rev5)

In reply to Randy MacLeod

== Series Details ==

Series: "util-linux: add setpriv utilit..." and 3 more (rev5)
Revision: 5
URL : https://patchwork.openembedded.org/series/18163/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at ca737408bb)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
#14 lore raw

Re: ✗ patchtest: failure for "util-linux: add setpriv utilit..." and 3 more (rev5)

Quoted 3 lines · Patchwork
* Issue             Series does not apply on top of target branch [test_series_merge_on_head]
   Suggested fix    Rebase your series on top of targeted branch
   Targeted branch  master (currently at ca737408bb)

This appears to be wrong.

From my local repo:

$ git log --oneline  -6
3461af0c76 (HEAD -> bash-ptest) bash: use setpriv, sed.sed to run ptests
7ab387fcac ptest-runner: enable child procs as session leader
ef6ef10236 libcap-ng: split into libcap-ng/libcap-ng-python
11d5c1bbfd util-linux: add setpriv utility
ca737408bb (origin/master, origin/HEAD, master) <------ same id as above
            bluez: fix test case failures with GCC 9
c6b49cb752 kernel-fitimage: uboot-sign: Check UBOOT_DTB_BINARY before adding deps

I was setting the 'In-reply-to' field to the original thread so perhaps patchtest is confused by that or I did something wrong since I've rarely used that feature of git send-email.

Signature · 2 lines
# Randy MacLeod
# Wind River Linux
#15 lore raw

Re: ✗ patchtest: failure for "util-linux: add setpriv utilit..." and 3 more (rev5)

It should related to the way you send the patch.

Currently,  on the patchwork,  for this series, Revision 5 is like this:

[1/4] util-linux: add setpriv utility <https://patchwork.openembedded.org/series/18163/#> 162216 <https://patchwork.openembedded.org/patch/162216/> Randy MacLeod <https://patchwork.openembedded.org/project/oe-core/patches/?submitter=3343>
Master Next
[4/4] bash: use setpriv, sed.sed to run ptests <https://patchwork.openembedded.org/series/18163/#> 162223 <https://patchwork.openembedded.org/patch/162223/> Randy MacLeod <https://patchwork.openembedded.org/project/oe-core/patches/?submitter=3343>
New
[3/4] ptest-runner: enable child procs as session leader <https://patchwork.openembedded.org/series/18163/#> 162219 <https://patchwork.openembedded.org/patch/162219/> Randy MacLeod <https://patchwork.openembedded.org/project/oe-core/patches/?submitter=3343>
Master Next
[4/4] bash: use setpriv, sed.sed to run ptests <https://patchwork.openembedded.org/series/18163/#> 162218 <https://patchwork.openembedded.org/patch/162218/> Randy MacLeod <https://patchwork.openembedded.org/project/oe-core/patches/?submitter=3343>
Master Next

So patch cannot be merge.

There is patch of patchwork doc related to this:

Patchwork supports:

* Re-sending a single patch as a reply to the reviewer email. This is usually only used when a few patches have to be resent.
* Re-sending a full series as a new thread.

+ [PATCH 0/3] Cover Letter Subject

   +-->  [PATCH  1/3]  Patch  1
   +-->  [PATCH  2/3]  Patch  2
   |   +-->  Re:  [PATCH  2/3]  Patch  2                (reviewer  comments)
   |      +-->  [PATCH  v2  2/3]  Patch  2              (v2  of  patch  2/3)
   +-->  [PATCH  3/3]  Patch  3

+ [PATCH v2 0/3] Cover Letter Subject

+-->  [PATCH  v2  1/3]  Patch  1                    (v2  of  patch  1/3)
+-->  [PATCH  v2  2/3]  Patch  2                    (v2  of  patch  2/3)
+-->  [PATCH  v2  3/3]  Patch  3                    (v2  of  patch  3/3)
Quoted 22 lines · Randy MacLeod
Quoted 3 lines · Patchwork

* Issue             Series does not apply on top of target branch [test_series_merge_on_head] Suggested fix    Rebase your series on top of targeted branch
   Targeted branch  master (currently at ca737408bb)

This appears to be wrong.

From my local repo:

$ git log --oneline  -6
3461af0c76 (HEAD -> bash-ptest) bash: use setpriv, sed.sed to run ptests
7ab387fcac ptest-runner: enable child procs as session leader
ef6ef10236 libcap-ng: split into libcap-ng/libcap-ng-python
11d5c1bbfd util-linux: add setpriv utility
ca737408bb (origin/master, origin/HEAD, master) <------ same id as above
            bluez: fix test case failures with GCC 9
c6b49cb752 kernel-fitimage: uboot-sign: Check UBOOT_DTB_BINARY before adding deps

I was setting the 'In-reply-to' field to the original thread so perhaps patchtest is confused by that or I did something wrong since I've rarely used that feature of git send-email.

Signature · 3 lines
BRs

Sandy(Li Changqing)