From 22a5451de44392c2882458940c7614e11d5ee0cc Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 05 2019 21:27:20 +0000 Subject: import util-linux-2.32.1-17.el8 --- diff --git a/SOURCES/0015-tests-add-missing-ts_check_test_command-calls.patch b/SOURCES/0015-tests-add-missing-ts_check_test_command-calls.patch new file mode 100644 index 0000000..f9dcc0e --- /dev/null +++ b/SOURCES/0015-tests-add-missing-ts_check_test_command-calls.patch @@ -0,0 +1,132 @@ +From 9bccbbf06a91f4e7bf5c0cddadf18265dc2e9e4b Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 4 Mar 2019 16:42:30 +0100 +Subject: [PATCH 15/19] tests: add missing ts_check_test_command calls + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Upstream: http://github.com/karelzak/util-linux/commit/19e00ec9e9e9c36305cf2dd163d0333e2d72c671 +Signed-off-by: Karel Zak +--- + tests/ts/fsck/ismounted | 2 ++ + tests/ts/hexdump/format-strings | 1 + + tests/ts/hexdump/highlighting | 1 + + tests/ts/ipcs/limits | 1 + + tests/ts/ipcs/limits2 | 1 + + tests/ts/ipcs/mk-rm-msg | 1 + + tests/ts/ipcs/mk-rm-sem | 1 + + tests/ts/ipcs/mk-rm-shm | 1 + + tests/ts/misc/swaplabel | 1 + + 9 files changed, 10 insertions(+) + +diff --git a/tests/ts/fsck/ismounted b/tests/ts/fsck/ismounted +index 2a55907a7..7d1fe6273 100755 +--- a/tests/ts/fsck/ismounted ++++ b/tests/ts/fsck/ismounted +@@ -22,6 +22,8 @@ ts_init "$*" + + ts_check_test_command "$TS_CMD_FDISK" + ts_check_test_command "$TS_CMD_MOUNT" ++ts_check_test_command "$TS_CMD_UMOUNT" ++ts_check_test_command "$TS_HELPER_ISMOUNTED" + + ts_skip_nonroot + ts_check_losetup +diff --git a/tests/ts/hexdump/format-strings b/tests/ts/hexdump/format-strings +index e6f9229a5..f2dc6a89b 100755 +--- a/tests/ts/hexdump/format-strings ++++ b/tests/ts/hexdump/format-strings +@@ -23,6 +23,7 @@ FILES="$TS_TOPDIR/ts/hexdump/files" + ts_init "$*" + + ts_check_test_command "$TS_CMD_HEXDUMP" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + # on big endian systems some of the subtests have different expected output + BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +diff --git a/tests/ts/hexdump/highlighting b/tests/ts/hexdump/highlighting +index cf78f7b96..e57757978 100755 +--- a/tests/ts/hexdump/highlighting ++++ b/tests/ts/hexdump/highlighting +@@ -25,6 +25,7 @@ ADDRFMT='-e "%07.7_Ax\n"' + ts_init "$*" + + ts_check_test_command "$TS_CMD_HEXDUMP" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + # on big endian systems some of the subtests have different expected output + BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits +index 7b64b3c17..671f23c77 100755 +--- a/tests/ts/ipcs/limits ++++ b/tests/ts/ipcs/limits +@@ -23,6 +23,7 @@ TS_DESC="limits overflow" + ts_init "$*" + + ts_check_test_command "$TS_CMD_IPCS" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + ts_skip_nonroot + ts_check_prog "bc" +diff --git a/tests/ts/ipcs/limits2 b/tests/ts/ipcs/limits2 +index d23c41a35..77ad70f9b 100755 +--- a/tests/ts/ipcs/limits2 ++++ b/tests/ts/ipcs/limits2 +@@ -23,6 +23,7 @@ TS_DESC="basic limits" + ts_init "$*" + + ts_check_test_command "$TS_CMD_IPCS" ++ts_check_test_command "$TS_HELPER_SYSINFO" + ts_check_prog "bc" + + . $TS_SELF/functions.sh +diff --git a/tests/ts/ipcs/mk-rm-msg b/tests/ts/ipcs/mk-rm-msg +index 25460e25d..de3682e87 100755 +--- a/tests/ts/ipcs/mk-rm-msg ++++ b/tests/ts/ipcs/mk-rm-msg +@@ -21,6 +21,7 @@ ts_init "$*" + ts_check_test_command "$TS_CMD_IPCS" + ts_check_test_command "$TS_CMD_IPCMK" + ts_check_test_command "$TS_CMD_IPCRM" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + . $TS_SELF/functions.sh + +diff --git a/tests/ts/ipcs/mk-rm-sem b/tests/ts/ipcs/mk-rm-sem +index 61e0cfdef..d7b505f7c 100755 +--- a/tests/ts/ipcs/mk-rm-sem ++++ b/tests/ts/ipcs/mk-rm-sem +@@ -21,6 +21,7 @@ ts_init "$*" + ts_check_test_command "$TS_CMD_IPCS" + ts_check_test_command "$TS_CMD_IPCMK" + ts_check_test_command "$TS_CMD_IPCRM" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + . $TS_SELF/functions.sh + +diff --git a/tests/ts/ipcs/mk-rm-shm b/tests/ts/ipcs/mk-rm-shm +index 838fb3f21..c21547b82 100755 +--- a/tests/ts/ipcs/mk-rm-shm ++++ b/tests/ts/ipcs/mk-rm-shm +@@ -21,6 +21,7 @@ ts_init "$*" + ts_check_test_command "$TS_CMD_IPCS" + ts_check_test_command "$TS_CMD_IPCMK" + ts_check_test_command "$TS_CMD_IPCRM" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + . $TS_SELF/functions.sh + +diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel +index 646304508..22858b0ac 100755 +--- a/tests/ts/misc/swaplabel ++++ b/tests/ts/misc/swaplabel +@@ -20,6 +20,7 @@ ts_init "$*" + + ts_check_test_command "$TS_CMD_MKSWAP" + ts_check_test_command "$TS_CMD_SWAPLABEL" ++ts_check_test_command "$TS_HELPER_SYSINFO" + + # fallocate does not work on most file systems + function fallocate_or_skip() +-- +2.20.1 + diff --git a/SOURCES/0016-tests-add-use-system-commands.patch b/SOURCES/0016-tests-add-use-system-commands.patch new file mode 100644 index 0000000..1e5003a --- /dev/null +++ b/SOURCES/0016-tests-add-use-system-commands.patch @@ -0,0 +1,357 @@ +From 748fbfa9b1bb3b64b3fbc6b1e51d260d8376c791 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 4 Mar 2019 17:10:04 +0100 +Subject: [PATCH 16/19] tests: add --use-system-commands + +This change allows to use commands from $PATH rather than from +$top_builddir. There two basic use cases: + +* check differences between installed and git version + run.sh --use-system-command --show-diff + +* check system binaries by upstream tests (for example tests from + src.rpm package) + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Upstream: http://github.com/karelzak/util-linux/commit/43b4a4d3c720a4e65fe9de884cd73e0b1b94fbe +Signed-off-by: Karel Zak +--- + tests/commands.sh | 194 ++++++++++++++++++++++----------------------- + tests/functions.sh | 34 ++++++-- + tests/run.sh | 33 +++++--- + 3 files changed, 146 insertions(+), 115 deletions(-) + +diff --git a/tests/commands.sh b/tests/commands.sh +index 1be2d25b4..93100caf6 100644 +--- a/tests/commands.sh ++++ b/tests/commands.sh +@@ -2,105 +2,105 @@ + TS_TESTUSER=${TS_TESTUSER:-"nobody"} + + # helpers +-TS_HELPER_BYTESWAP="$top_builddir/test_byteswap" +-TS_HELPER_CPUSET="$top_builddir/test_cpuset" +-TS_HELPER_DMESG="$top_builddir/test_dmesg" +-TS_HELPER_ISLOCAL="$top_builddir/test_islocal" +-TS_HELPER_ISMOUNTED="$top_builddir/test_ismounted" +-TS_HELPER_LIBFDISK_GPT="$top_builddir/test_fdisk_gpt" +-TS_HELPER_LIBFDISK_MKPART="$top_builddir/sample-fdisk-mkpart" +-TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/test_mount_context" +-TS_HELPER_LIBFDISK_MKPART_FULLSPEC="$top_builddir/sample-fdisk-mkpart-fullspec" +-TS_HELPER_LIBMOUNT_LOCK="$top_builddir/test_mount_lock" +-TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/test_mount_optstr" +-TS_HELPER_LIBMOUNT_TABDIFF="$top_builddir/test_mount_tab_diff" +-TS_HELPER_LIBMOUNT_TAB="$top_builddir/test_mount_tab" +-TS_HELPER_LIBMOUNT_UPDATE="$top_builddir/test_mount_tab_update" +-TS_HELPER_LIBMOUNT_UTILS="$top_builddir/test_mount_utils" +-TS_HELPER_LIBMOUNT_DEBUG="$top_builddir/test_mount_debug" +-TS_HELPER_LIBSMARTCOLS_FROMFILE="$top_builddir/sample-scols-fromfile" +-TS_HELPER_LIBSMARTCOLS_TITLE="$top_builddir/sample-scols-title" ++TS_HELPER_BYTESWAP="${ts_helpersdir}test_byteswap" ++TS_HELPER_CPUSET="${ts_helpersdir}test_cpuset" ++TS_HELPER_DMESG="${ts_helpersdir}test_dmesg" ++TS_HELPER_ISLOCAL="${ts_helpersdir}test_islocal" ++TS_HELPER_ISMOUNTED="${ts_helpersdir}test_ismounted" ++TS_HELPER_LIBFDISK_GPT="${ts_helpersdir}test_fdisk_gpt" ++TS_HELPER_LIBFDISK_MKPART="${ts_helpersdir}sample-fdisk-mkpart" ++TS_HELPER_LIBMOUNT_CONTEXT="${ts_helpersdir}test_mount_context" ++TS_HELPER_LIBFDISK_MKPART_FULLSPEC="${ts_helpersdir}sample-fdisk-mkpart-fullspec" ++TS_HELPER_LIBMOUNT_LOCK="${ts_helpersdir}test_mount_lock" ++TS_HELPER_LIBMOUNT_OPTSTR="${ts_helpersdir}test_mount_optstr" ++TS_HELPER_LIBMOUNT_TABDIFF="${ts_helpersdir}test_mount_tab_diff" ++TS_HELPER_LIBMOUNT_TAB="${ts_helpersdir}test_mount_tab" ++TS_HELPER_LIBMOUNT_UPDATE="${ts_helpersdir}test_mount_tab_update" ++TS_HELPER_LIBMOUNT_UTILS="${ts_helpersdir}test_mount_utils" ++TS_HELPER_LIBMOUNT_DEBUG="${ts_helpersdir}test_mount_debug" ++TS_HELPER_LIBSMARTCOLS_FROMFILE="${ts_helpersdir}sample-scols-fromfile" ++TS_HELPER_LIBSMARTCOLS_TITLE="${ts_helpersdir}sample-scols-title" + TS_HELPER_PYLIBMOUNT_CONTEXT="$top_srcdir/libmount/python/test_mount_context.py" + TS_HELPER_PYLIBMOUNT_TAB="$top_srcdir/libmount/python/test_mount_tab.py" + TS_HELPER_PYLIBMOUNT_UPDATE="$top_srcdir/libmount/python/test_mount_tab_update.py" +-TS_HELPER_LOGGER="$top_builddir/test_logger" +-TS_HELPER_LOGINDEFS="$top_builddir/test_logindefs" +-TS_HELPER_MD5="$top_builddir/test_md5" +-TS_HELPER_SHA1="$top_builddir/test_sha1" +-TS_HELPER_MKFS_MINIX="$top_builddir/test_mkfs_minix" +-TS_HELPER_MORE=${TS_HELPER_MORE-"$top_builddir/test_more"} +-TS_HELPER_PARTITIONS="$top_builddir/sample-partitions" +-TS_HELPER_PATHS="$top_builddir/test_pathnames" +-TS_HELPER_SCRIPT="$top_builddir/test_script" +-TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive" +-TS_HELPER_STRUTILS="$top_builddir/test_strutils" +-TS_HELPER_SYSINFO="$top_builddir/test_sysinfo" +-TS_HELPER_TIOCSTI="$top_builddir/test_tiocsti" +-TS_HELPER_UUID_PARSER="$top_builddir/test_uuid_parser" +-TS_HELPER_UUID_NAMESPACE="$top_builddir/test_uuid_namespace" +-TS_HELPER_MBSENCODE="$top_builddir/test_mbsencode" +-TS_HELPER_CAL="$top_builddir/test_cal" ++TS_HELPER_LOGGER="${ts_helpersdir}test_logger" ++TS_HELPER_LOGINDEFS="${ts_helpersdir}test_logindefs" ++TS_HELPER_MD5="${ts_helpersdir}test_md5" ++TS_HELPER_SHA1="${ts_helpersdir}test_sha1" ++TS_HELPER_MKFS_MINIX="${ts_helpersdir}test_mkfs_minix" ++TS_HELPER_MORE=${TS_HELPER_MORE-"${ts_helpersdir}test_more"} ++TS_HELPER_PARTITIONS="${ts_helpersdir}sample-partitions" ++TS_HELPER_PATHS="${ts_helpersdir}test_pathnames" ++TS_HELPER_SCRIPT="${ts_helpersdir}test_script" ++TS_HELPER_SIGRECEIVE="${ts_helpersdir}test_sigreceive" ++TS_HELPER_STRUTILS="${ts_helpersdir}test_strutils" ++TS_HELPER_SYSINFO="${ts_helpersdir}test_sysinfo" ++TS_HELPER_TIOCSTI="${ts_helpersdir}test_tiocsti" ++TS_HELPER_UUID_PARSER="${ts_helpersdir}test_uuid_parser" ++TS_HELPER_UUID_NAMESPACE="${ts_helpersdir}test_uuid_namespace" ++TS_HELPER_MBSENCODE="${ts_helpersdir}test_mbsencode" ++TS_HELPER_CAL="${ts_helpersdir}test_cal" + + # paths to commands +-TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"} +-TS_CMD_DELPART=${TS_CMD_DELPART:-"$top_builddir/delpart"} +-TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"$top_builddir/blkdiscard"} +-TS_CMD_BLKID=${TS_CMD_BLKID-"$top_builddir/blkid"} +-TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/cal"} +-TS_CMD_COLCRT=${TS_CMD_COLCRT:-"$top_builddir/colcrt"} +-TS_CMD_COLRM=${TS_CMD_COLRM:-"$top_builddir/colrm"} +-TS_CMD_COL=${TS_CMD_COL:-"$top_builddir/col"} +-TS_CMD_COLUMN=${TS_CMD_COLUMN:-"$top_builddir/column"} +-TS_CMD_EJECT=${TS_CMD_EJECT-"$top_builddir/eject"} +-TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"$top_builddir/fallocate"} +-TS_CMD_FDISK=${TS_CMD_FDISK-"$top_builddir/fdisk"} +-TS_CMD_FLOCK=${TS_CMD_FLOCK-"$top_builddir/flock"} +-TS_CMD_SFDISK=${TS_CMD_SFDISK-"$top_builddir/sfdisk"} +-TS_CMD_FINCORE=${TS_CMD_FINCORE-"$top_builddir/fincore"} +-TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"$top_builddir/findmnt"} +-TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"$top_builddir/fsck.cramfs"} +-TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"$top_builddir/fsck.minix"} +-TS_CMD_GETOPT=${TS_CMD_GETOPT-"$top_builddir/getopt"} +-TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"$top_builddir/hexdump"} +-TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"$top_builddir/hwclock"} +-TS_CMD_IONICE=${TS_CMD_IONICE-"$top_builddir/ionice"} +-TS_CMD_IPCMK=${TS_CMD_IPCMK-"$top_builddir/ipcmk"} +-TS_CMD_IPCRM=${TS_CMD_IPCRM-"$top_builddir/ipcrm"} +-TS_CMD_IPCS=${TS_CMD_IPCS:-"$top_builddir/ipcs"} +-TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"$top_builddir/isosize"} +-TS_CMD_KILL=${TS_CMD_KILL-"$top_builddir/kill"} +-TS_CMD_LAST=${TS_CMD_LAST-"$top_builddir/last"} +-TS_CMD_LINE=${TS_CMD_LINE-"$top_builddir/line"} +-TS_CMD_LOOK=${TS_CMD_LOOK-"$top_builddir/look"} +-TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"$top_builddir/losetup"} +-TS_CMD_LSBLK=${TS_CMD_LSBLK-"$top_builddir/lsblk"} +-TS_CMD_LSCPU=${TS_CMD_LSCPU-"$top_builddir/lscpu"} +-TS_CMD_LSMEM=${TS_CMD_LSMEM-"$top_builddir/lsmem"} +-TS_CMD_LSNS=${TS_CMD_LSNS-"$top_builddir/lsns"} +-TS_CMD_MCOOKIE=${TS_CMD_MCOOKIE-"$top_builddir/mcookie"} +-TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"$top_builddir/mkfs.cramfs"} +-TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"$top_builddir/mkfs.minix"} +-TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"$top_builddir/mkswap"} +-TS_CMD_MOUNT=${TS_CMD_MOUNT:-"$top_builddir/mount"} +-TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"$top_builddir/mountpoint"} +-TS_CMD_NAMEI=${TS_CMD_NAMEI-"$top_builddir/namei"} +-TS_CMD_PARTX=${TS_CMD_PARTX-"$top_builddir/partx"} +-TS_CMD_RENAME=${TS_CMD_RENAME-"$top_builddir/rename"} +-TS_CMD_RUNUSER=${TS_CMD_RUNUSER-"$top_builddir/runuser"} +-TS_CMD_REV=${TS_CMD_REV:-"$top_builddir/rev"} +-TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"$top_builddir/script"} +-TS_CMD_SCRIPTREPLAY=${TS_CMD_SCRIPTREPLAY-"$top_builddir/scriptreplay"} +-TS_CMD_SETARCH=${TS_CMD_SETARCH-"$top_builddir/setarch"} +-TS_CMD_SETSID=${TS_CMD_SETSID-"$top_builddir/setsid"} +-TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"$top_builddir/swaplabel"} +-TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"$top_builddir/swapoff"} +-TS_CMD_SWAPON=${TS_CMD_SWAPON:-"$top_builddir/swapon"} +-TS_CMD_UL=${TS_CMD_UL-"$top_builddir/ul"} +-TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"$top_builddir/umount"} +-TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"$top_builddir/utmpdump"} +-TS_CMD_UUIDD=${TS_CMD_UUIDD-"$top_builddir/uuidd"} +-TS_CMD_UUIDGEN=${TS_CMD_UUIDGEN-"$top_builddir/uuidgen"} +-TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"$top_builddir/uuidparse"} +-TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"$top_builddir/whereis"} +-TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"$top_builddir/wipefs"} +-TS_CMD_CHRT=${TS_CMD_CHRT-"$top_builddir/chrt"} ++TS_CMD_ADDPART=${TS_CMD_ADDPART:-"${ts_commandsdir}addpart"} ++TS_CMD_DELPART=${TS_CMD_DELPART:-"${ts_commandsdir}delpart"} ++TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"${ts_commandsdir}blkdiscard"} ++TS_CMD_BLKID=${TS_CMD_BLKID-"${ts_commandsdir}blkid"} ++TS_CMD_CAL=${TS_CMD_CAL-"${ts_commandsdir}cal"} ++TS_CMD_COLCRT=${TS_CMD_COLCRT:-"${ts_commandsdir}colcrt"} ++TS_CMD_COLRM=${TS_CMD_COLRM:-"${ts_commandsdir}colrm"} ++TS_CMD_COL=${TS_CMD_COL:-"${ts_commandsdir}col"} ++TS_CMD_COLUMN=${TS_CMD_COLUMN:-"${ts_commandsdir}column"} ++TS_CMD_EJECT=${TS_CMD_EJECT-"${ts_commandsdir}eject"} ++TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"${ts_commandsdir}fallocate"} ++TS_CMD_FDISK=${TS_CMD_FDISK-"${ts_commandsdir}fdisk"} ++TS_CMD_FLOCK=${TS_CMD_FLOCK-"${ts_commandsdir}flock"} ++TS_CMD_SFDISK=${TS_CMD_SFDISK-"${ts_commandsdir}sfdisk"} ++TS_CMD_FINCORE=${TS_CMD_FINCORE-"${ts_commandsdir}fincore"} ++TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"${ts_commandsdir}findmnt"} ++TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"${ts_commandsdir}fsck.cramfs"} ++TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"${ts_commandsdir}fsck.minix"} ++TS_CMD_GETOPT=${TS_CMD_GETOPT-"${ts_commandsdir}getopt"} ++TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"${ts_commandsdir}hexdump"} ++TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"${ts_commandsdir}hwclock"} ++TS_CMD_IONICE=${TS_CMD_IONICE-"${ts_commandsdir}ionice"} ++TS_CMD_IPCMK=${TS_CMD_IPCMK-"${ts_commandsdir}ipcmk"} ++TS_CMD_IPCRM=${TS_CMD_IPCRM-"${ts_commandsdir}ipcrm"} ++TS_CMD_IPCS=${TS_CMD_IPCS:-"${ts_commandsdir}ipcs"} ++TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"${ts_commandsdir}isosize"} ++TS_CMD_KILL=${TS_CMD_KILL-"${ts_commandsdir}kill"} ++TS_CMD_LAST=${TS_CMD_LAST-"${ts_commandsdir}last"} ++TS_CMD_LINE=${TS_CMD_LINE-"${ts_commandsdir}line"} ++TS_CMD_LOOK=${TS_CMD_LOOK-"${ts_commandsdir}look"} ++TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"${ts_commandsdir}losetup"} ++TS_CMD_LSBLK=${TS_CMD_LSBLK-"${ts_commandsdir}lsblk"} ++TS_CMD_LSCPU=${TS_CMD_LSCPU-"${ts_commandsdir}lscpu"} ++TS_CMD_LSMEM=${TS_CMD_LSMEM-"${ts_commandsdir}lsmem"} ++TS_CMD_LSNS=${TS_CMD_LSNS-"${ts_commandsdir}lsns"} ++TS_CMD_MCOOKIE=${TS_CMD_MCOOKIE-"${ts_commandsdir}mcookie"} ++TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"${ts_commandsdir}mkfs.cramfs"} ++TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"${ts_commandsdir}mkfs.minix"} ++TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"${ts_commandsdir}mkswap"} ++TS_CMD_MOUNT=${TS_CMD_MOUNT:-"${ts_commandsdir}mount"} ++TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"${ts_commandsdir}mountpoint"} ++TS_CMD_NAMEI=${TS_CMD_NAMEI-"${ts_commandsdir}namei"} ++TS_CMD_PARTX=${TS_CMD_PARTX-"${ts_commandsdir}partx"} ++TS_CMD_RENAME=${TS_CMD_RENAME-"${ts_commandsdir}rename"} ++TS_CMD_RUNUSER=${TS_CMD_RUNUSER-"${ts_commandsdir}runuser"} ++TS_CMD_REV=${TS_CMD_REV:-"${ts_commandsdir}rev"} ++TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"${ts_commandsdir}script"} ++TS_CMD_SCRIPTREPLAY=${TS_CMD_SCRIPTREPLAY-"${ts_commandsdir}scriptreplay"} ++TS_CMD_SETARCH=${TS_CMD_SETARCH-"${ts_commandsdir}setarch"} ++TS_CMD_SETSID=${TS_CMD_SETSID-"${ts_commandsdir}setsid"} ++TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"${ts_commandsdir}swaplabel"} ++TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"${ts_commandsdir}swapoff"} ++TS_CMD_SWAPON=${TS_CMD_SWAPON:-"${ts_commandsdir}swapon"} ++TS_CMD_UL=${TS_CMD_UL-"${ts_commandsdir}ul"} ++TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"${ts_commandsdir}umount"} ++TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"${ts_commandsdir}utmpdump"} ++TS_CMD_UUIDD=${TS_CMD_UUIDD-"${ts_commandsdir}uuidd"} ++TS_CMD_UUIDGEN=${TS_CMD_UUIDGEN-"${ts_commandsdir}uuidgen"} ++TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"${ts_commandsdir}uuidparse"} ++TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"${ts_commandsdir}whereis"} ++TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"${ts_commandsdir}wipefs"} ++TS_CMD_CHRT=${TS_CMD_CHRT-"${ts_commandsdir}chrt"} +diff --git a/tests/functions.sh b/tests/functions.sh +index 2fb0ddb5f..ab607c4ce 100644 +--- a/tests/functions.sh ++++ b/tests/functions.sh +@@ -75,9 +75,19 @@ function ts_report { + } + + function ts_check_test_command { +- if [ ! -x "$1" ]; then +- ts_skip "${1##*/} not found" +- fi ++ case "$1" in ++ */*) ++ # paths ++ if [ ! -x "$1" ]; then ++ ts_skip "${1##*/} not found" ++ fi ++ ;; ++ *) ++ # just command names (e.g. --use-system-commands) ++ local cmd=$1 ++ type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd" ++ ;; ++ esac + } + + function ts_check_prog { +@@ -254,8 +264,20 @@ function ts_init_env { + top_srcdir=$(ts_abspath $top_srcdir) + top_builddir=$(ts_abspath $top_builddir) + +- # some ul commands search other ul commands in $PATH +- export PATH="$top_builddir:$PATH" ++ # We use helpser always from build tree ++ ts_helpersdir="${top_builddir}/" ++ ++ TS_USE_SYSTEM_COMMANDS=$(ts_has_option "use-system-commands" "$*") ++ if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then ++ # Don't define anything, just follow current PATH ++ ts_commandsdir="" ++ else ++ # The default is to use commands from build tree ++ ts_commandsdir="${top_builddir}/" ++ ++ # some ul commands search other ul commands in $PATH ++ export PATH="$ts_commandsdir:$PATH" ++ fi + + TS_SCRIPT="$mydir/$(basename $0)" + TS_SUBDIR=$(dirname $TS_SCRIPT) +@@ -319,6 +341,8 @@ function ts_init_env { + if [ "$TS_VERBOSE" == "yes" ]; then + echo + echo " script: $TS_SCRIPT" ++ echo " commands: $ts_commandsdir" ++ echo " helpers: $ts_helpersdir" + echo " sub dir: $TS_SUBDIR" + echo " top dir: $TS_TOPDIR" + echo " self: $TS_SELF" +diff --git a/tests/run.sh b/tests/run.sh +index f40c9f801..28f8ee25a 100755 +--- a/tests/run.sh ++++ b/tests/run.sh +@@ -20,6 +20,7 @@ TS_TOPDIR=$(cd ${0%/*} && pwd) + SUBTESTS= + EXCLUDETESTS= + OPTS= ++SYSCOMMANDS= + + top_srcdir= + top_builddir= +@@ -68,6 +69,11 @@ while [ -n "$1" ]; do + # these options are simply forwarded to the test scripts + OPTS="$OPTS $1" + ;; ++ --use-system-commands) ++ OPTS="$OPTS $1" ++ SYSCOMMANDS="yes" ++ ;; ++ + --nonroot) + if [ $(id -ru) -eq 0 ]; then + echo "Ignore util-linux test suite [non-root UID expected]." +@@ -98,18 +104,19 @@ while [ -n "$1" ]; do + echo "Usage: " + echo " $(basename $0) [options] [ ...]" + echo "Options:" +- echo " --force execute demanding tests" +- echo " --fake do not run, setup tests only" +- echo " --memcheck-valgrind run with valgrind" +- echo " --memcheck-asan enable ASAN (requires ./configure --enable-asan)" +- echo " --nolocks don't use flock to lock resources" +- echo " --verbose verbose mode" +- echo " --show-diff show diff from failed tests" +- echo " --nonroot ignore test suite if user is root" +- echo " --srcdir= autotools top source directory" +- echo " --builddir= autotools top build directory" +- echo " --parallel= number of parallel test jobs, default: num cpus" +- echo " --exclude= exclude tests by list '/ ..'" ++ echo " --force execute demanding tests" ++ echo " --fake do not run, setup tests only" ++ echo " --memcheck-valgrind run with valgrind" ++ echo " --memcheck-asan enable ASAN (requires ./configure --enable-asan)" ++ echo " --nolocks don't use flock to lock resources" ++ echo " --verbose verbose mode" ++ echo " --show-diff show diff from failed tests" ++ echo " --nonroot ignore test suite if user is root" ++ echo " --use-system-commands use PATH rather than builddir" ++ echo " --srcdir= autotools top source directory" ++ echo " --builddir= autotools top build directory" ++ echo " --parallel= number of parallel test jobs, default: num cpus" ++ echo " --exclude= exclude tests by list '/ ..'" + echo + exit 1 + ;; +@@ -148,7 +155,7 @@ if [ -n "$SUBTESTS" ]; then + fi + done + else +- if [ ! -f "$top_builddir/test_ttyutils" ]; then ++ if [ -z "$SYSCOMMANDS" -a ! -f "$top_builddir/test_ttyutils" ]; then + echo "Tests not compiled! Run 'make check' to fix the problem." + exit 1 + fi +-- +2.20.1 + diff --git a/SOURCES/0017-tests-kill-do-not-use-shell-build-in.patch b/SOURCES/0017-tests-kill-do-not-use-shell-build-in.patch new file mode 100644 index 0000000..5ae2785 --- /dev/null +++ b/SOURCES/0017-tests-kill-do-not-use-shell-build-in.patch @@ -0,0 +1,99 @@ +From 47b0f3480a88be94ef73973e73ad9f7fb8258cad Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 4 Mar 2019 17:28:15 +0100 +Subject: [PATCH 17/19] tests: (kill) do not use shell build-in + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Upstream: http://github.com/karelzak/util-linux/commit/2fadcded53add5b5b0ca7071f310a0f37c711c51 +Signed-off-by: Karel Zak +--- + tests/ts/kill/all_processes | 5 +++++ + tests/ts/kill/name_to_number | 5 +++++ + tests/ts/kill/options | 5 +++++ + tests/ts/kill/print_pid | 5 +++++ + tests/ts/kill/queue | 5 +++++ + 5 files changed, 25 insertions(+) + +diff --git a/tests/ts/kill/all_processes b/tests/ts/kill/all_processes +index 2596ef02b..7a0c95931 100755 +--- a/tests/ts/kill/all_processes ++++ b/tests/ts/kill/all_processes +@@ -20,6 +20,11 @@ ts_init "$*" + + ts_skip_nonroot + ++# make sure we do not use shell built-in command ++if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then ++ TS_CMD_KILL="/bin/kill" ++fi ++ + ts_check_test_command "$TS_CMD_KILL" + ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +diff --git a/tests/ts/kill/name_to_number b/tests/ts/kill/name_to_number +index cde55c9ed..fd2aaafe0 100755 +--- a/tests/ts/kill/name_to_number ++++ b/tests/ts/kill/name_to_number +@@ -18,6 +18,11 @@ TS_DESC="name_to_number" + . "$TS_TOPDIR/functions.sh" + ts_init "$*" + ++# make sure we do not use shell built-in command ++if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then ++ TS_CMD_KILL="/bin/kill" ++fi ++ + ts_check_test_command "$TS_CMD_KILL" + ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +diff --git a/tests/ts/kill/options b/tests/ts/kill/options +index 2c82bbccc..ee9e52f47 100755 +--- a/tests/ts/kill/options ++++ b/tests/ts/kill/options +@@ -18,6 +18,11 @@ TS_DESC="options" + . "$TS_TOPDIR/functions.sh" + ts_init "$*" + ++# make sure we do not use shell built-in command ++if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then ++ TS_CMD_KILL="/bin/kill" ++fi ++ + ts_check_test_command "$TS_CMD_KILL" + ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +diff --git a/tests/ts/kill/print_pid b/tests/ts/kill/print_pid +index c6187f192..2a2a838ee 100755 +--- a/tests/ts/kill/print_pid ++++ b/tests/ts/kill/print_pid +@@ -18,6 +18,11 @@ TS_DESC="print_pid" + . "$TS_TOPDIR/functions.sh" + ts_init "$*" + ++# make sure we do not use shell built-in command ++if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then ++ TS_CMD_KILL="/bin/kill" ++fi ++ + ts_check_test_command "$TS_CMD_KILL" + ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +diff --git a/tests/ts/kill/queue b/tests/ts/kill/queue +index 992acf7a6..4727cbfc4 100755 +--- a/tests/ts/kill/queue ++++ b/tests/ts/kill/queue +@@ -18,6 +18,11 @@ TS_DESC="queue" + . "$TS_TOPDIR/functions.sh" + ts_init "$*" + ++# make sure we do not use shell built-in command ++if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then ++ TS_CMD_KILL="/bin/kill" ++fi ++ + ts_check_test_command "$TS_CMD_KILL" + ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +-- +2.20.1 + diff --git a/SOURCES/0018-tests-add-missing-TS_CMD_UMOUNT-check.patch b/SOURCES/0018-tests-add-missing-TS_CMD_UMOUNT-check.patch new file mode 100644 index 0000000..66e45cc --- /dev/null +++ b/SOURCES/0018-tests-add-missing-TS_CMD_UMOUNT-check.patch @@ -0,0 +1,27 @@ +From aa983f0eea49638f04de0fbafcd156c1472726ee Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 4 Mar 2019 17:32:03 +0100 +Subject: [PATCH 18/19] tests: add missing TS_CMD_UMOUNT check + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Upstream: http://github.com/karelzak/util-linux/commit/bb872a239ce9faae7ac672a9137945dd8e4ee964 +Signed-off-by: Karel Zak +--- + tests/ts/libmount/loop | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop +index b52b7476a..090b79fa4 100755 +--- a/tests/ts/libmount/loop ++++ b/tests/ts/libmount/loop +@@ -23,6 +23,7 @@ TS_DESC="losetup-loop" + ts_init "$*" + + ts_check_test_command "$TS_CMD_MOUNT" ++ts_check_test_command "$TS_CMD_UMOUNT" + ts_check_test_command "$TS_CMD_FINDMNT" + ts_check_test_command "$TS_CMD_LOSETUP" + +-- +2.20.1 + diff --git a/SOURCES/0019-tests-add-noskip-commands.patch b/SOURCES/0019-tests-add-noskip-commands.patch new file mode 100644 index 0000000..28358fc --- /dev/null +++ b/SOURCES/0019-tests-add-noskip-commands.patch @@ -0,0 +1,66 @@ +From 9e92f2ff939a885b70d3a5d20e8c94f6e41e821b Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 5 Mar 2019 11:06:41 +0100 +Subject: [PATCH 19/19] tests: add --noskip-commands + +The default is SKIP missing commands on --use-system-commands, but +with --noskip-commands the test will FAIL. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Upstream: http://github.com/karelzak/util-linux/commit/7c90efa384cbb2ace873e2b90e8cc396a1719535 +Signed-off-by: Karel Zak +--- + tests/functions.sh | 9 ++++++++- + tests/run.sh | 2 ++ + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/tests/functions.sh b/tests/functions.sh +index ab607c4ce..0605a1320 100644 +--- a/tests/functions.sh ++++ b/tests/functions.sh +@@ -85,7 +85,13 @@ function ts_check_test_command { + *) + # just command names (e.g. --use-system-commands) + local cmd=$1 +- type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd" ++ type "$cmd" >/dev/null 2>&1 ++ if [ $? -ne 0 ]; then ++ if [ "$TS_NOSKIP_COMMANDS" = "yes" ]; then ++ ts_failed "missing in PATH: $cmd" ++ fi ++ ts_skip "missing in PATH: $cmd" ++ fi + ;; + esac + } +@@ -301,6 +307,7 @@ function ts_init_env { + + ts_init_core_env + ++ TS_NOSKIP_COMMANDS=$(ts_has_option "noskip-commands" "$*") + TS_VERBOSE=$(ts_has_option "verbose" "$*") + TS_SHOWDIFF=$(ts_has_option "show-diff" "$*") + TS_PARALLEL=$(ts_has_option "parallel" "$*") +diff --git a/tests/run.sh b/tests/run.sh +index 28f8ee25a..e8328cc5d 100755 +--- a/tests/run.sh ++++ b/tests/run.sh +@@ -65,6 +65,7 @@ while [ -n "$1" ]; do + --show-diff |\ + --verbose |\ + --skip-loopdevs |\ ++ --noskip-commands |\ + --parsable) + # these options are simply forwarded to the test scripts + OPTS="$OPTS $1" +@@ -113,6 +114,7 @@ while [ -n "$1" ]; do + echo " --show-diff show diff from failed tests" + echo " --nonroot ignore test suite if user is root" + echo " --use-system-commands use PATH rather than builddir" ++ echo " --noskip-commands fail on missing commands" + echo " --srcdir= autotools top source directory" + echo " --builddir= autotools top build directory" + echo " --parallel= number of parallel test jobs, default: num cpus" +-- +2.20.1 + diff --git a/SOURCES/0020-tests-add-missing-program-checks.patch b/SOURCES/0020-tests-add-missing-program-checks.patch new file mode 100644 index 0000000..06d9d8d --- /dev/null +++ b/SOURCES/0020-tests-add-missing-program-checks.patch @@ -0,0 +1,83 @@ +From 68ab6d9691e667f89f72bc7eb39a5300b2f6cbaf Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 5 Mar 2019 13:56:45 +0100 +Subject: [PATCH] tests: add missing program checks + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Signed-off-by: Karel Zak +--- + tests/ts/cal/bigyear | 2 +- + tests/ts/cal/month | 2 +- + tests/ts/cal/sep1752 | 2 +- + tests/ts/misc/mbsencode | 2 ++ + tests/ts/misc/strtosize | 2 ++ + 5 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear +index d205c3afd..34139fd27 100755 +--- a/tests/ts/cal/bigyear ++++ b/tests/ts/cal/bigyear +@@ -18,7 +18,7 @@ TS_DESC="Year 2147483646" + . $TS_TOPDIR/functions.sh + ts_init "$*" + +-ts_check_test_command "$TS_CMD_CAL" ++ts_check_test_command "$TS_HELPER_CAL" + + export TERM=linux + +diff --git a/tests/ts/cal/month b/tests/ts/cal/month +index 9794e90c0..37996acae 100755 +--- a/tests/ts/cal/month ++++ b/tests/ts/cal/month +@@ -22,7 +22,7 @@ TS_DESC="month" + . $TS_TOPDIR/functions.sh + ts_init "$*" + +-ts_check_test_command "$TS_CMD_CAL" ++ts_check_test_command "$TS_HELPER_CAL" + + export TERM=linux + +diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752 +index 3128261cd..41c30d40e 100755 +--- a/tests/ts/cal/sep1752 ++++ b/tests/ts/cal/sep1752 +@@ -18,7 +18,7 @@ TS_DESC="September 1752" + . $TS_TOPDIR/functions.sh + ts_init "$*" + +-ts_check_test_command "$TS_CMD_CAL" ++ts_check_test_command "$TS_HELPER_CAL" + + export TERM=linux + +diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode +index 405d34c56..139148259 100755 +--- a/tests/ts/misc/mbsencode ++++ b/tests/ts/misc/mbsencode +@@ -22,6 +22,8 @@ TS_DESC="mbsencode" + . $TS_TOPDIR/functions.sh + ts_init "$*" + ++ts_check_test_command "$TS_HELPER_MBSENCODE" ++ + # These test may fail on some machines (locales, other libc...) + TS_KNOWN_FAIL="yes" + +diff --git a/tests/ts/misc/strtosize b/tests/ts/misc/strtosize +index 68b3b8bab..a5914a939 100755 +--- a/tests/ts/misc/strtosize ++++ b/tests/ts/misc/strtosize +@@ -21,6 +21,8 @@ TS_DESC="strtosize" + . $TS_TOPDIR/functions.sh + ts_init "$*" + ++ts_check_test_command "$TS_HELPER_STRUTILS" ++ + $TS_HELPER_STRUTILS --size -1 >> $TS_OUTPUT 2>&1 + $TS_HELPER_STRUTILS --size 0 >> $TS_OUTPUT 2>&1 + $TS_HELPER_STRUTILS --size 1 >> $TS_OUTPUT 2>&1 +-- +2.20.1 + diff --git a/SOURCES/0021-tests-check-for-tar-and-b-g-zip.patch b/SOURCES/0021-tests-check-for-tar-and-b-g-zip.patch new file mode 100644 index 0000000..17199f8 --- /dev/null +++ b/SOURCES/0021-tests-check-for-tar-and-b-g-zip.patch @@ -0,0 +1,42 @@ +From 0c57e5fedce0e627debda3258e2203842b427572 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 11 Dec 2018 11:44:48 +0100 +Subject: [PATCH] tests: check for tar and {b,g}zip + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Upstream: http://github.com/karelzak/util-linux/commit/9e07672bb9989c88f6a7d8b8ab23158701fb4eec +Signed-off-by: Karel Zak +--- + tests/ts/lscpu/lscpu | 2 ++ + tests/ts/lsmem/lsmem | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/tests/ts/lscpu/lscpu b/tests/ts/lscpu/lscpu +index 70fbce9f3..ccf271149 100755 +--- a/tests/ts/lscpu/lscpu ++++ b/tests/ts/lscpu/lscpu +@@ -22,6 +22,8 @@ TS_TOPDIR="${0%/*}/../.." + + ts_init "$*" + ++ts_check_prog "tar" ++ts_check_prog "gzip" + ts_check_test_command "$TS_CMD_LSCPU" + + for dump in $(ls $TS_SELF/dumps/*.tar.gz | sort); do +diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem +index f1a643f85..bedf4143f 100755 +--- a/tests/ts/lsmem/lsmem ++++ b/tests/ts/lsmem/lsmem +@@ -21,6 +21,8 @@ TS_TOPDIR="${0%/*}/../.." + ts_init "$*" + + ts_check_test_command "$TS_CMD_LSMEM" ++ts_check_prog "tar" ++ts_check_prog "bzip2" + + LSCOLUMNS="RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE" + +-- +2.20.1 + diff --git a/SOURCES/0022-tests-make-mount-oloop-use-more-robust.patch b/SOURCES/0022-tests-make-mount-oloop-use-more-robust.patch new file mode 100644 index 0000000..6b05766 --- /dev/null +++ b/SOURCES/0022-tests-make-mount-oloop-use-more-robust.patch @@ -0,0 +1,93 @@ +From 8822103e30121d95fa58b5e8b7ce8ce91d4e778e Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 3 Jun 2019 22:29:51 +0200 +Subject: [PATCH] tests: make mount -oloop use more robust + +The command creates loop device, so udevd is in the game and it seems +better to wait for him. + +Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1681062 +Signed-off-by: Karel Zak +--- + tests/ts/libmount/loop | 4 ++++ + tests/ts/libmount/loop-overlay | 11 +++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop +index 090b79fa4..50764781c 100755 +--- a/tests/ts/libmount/loop ++++ b/tests/ts/libmount/loop +@@ -65,6 +65,7 @@ ts_finalize_subtest + ts_init_subtest "file-o-loop" + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + $TS_CMD_MOUNT -oloop "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 ++udevadm settle + $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 + udevadm settle + ts_log "Success" +@@ -89,6 +90,7 @@ else + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) + $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 ++ udevadm settle + verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 + $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 + udevadm settle +@@ -122,6 +124,7 @@ ts_init_subtest "o-loop-val-initialized" + LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT) + $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' > $TS_OUTPUT ++udevadm settle + $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1 + udevadm settle + ts_log "Success" +@@ -133,6 +136,7 @@ cp "$BACKFILE" "$BACKFILE"-2 + LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT) + $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' > $TS_OUTPUT ++udevadm settle + $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1 + rm "$BACKFILE"-2 + udevadm settle +diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay +index fffb823c0..1ba6eb06e 100755 +--- a/tests/ts/libmount/loop-overlay ++++ b/tests/ts/libmount/loop-overlay +@@ -43,23 +43,34 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null + + echo "second should fail" >>$TS_OUTPUT + $TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1 ++udevadm settle + $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT ++udevadm settle + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1 ++udevadm settle + + echo "should succeed" >>$TS_OUTPUT + $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1 ++udevadm settle + $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1 ++udevadm settle + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1 ++udevadm settle + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1 ++udevadm settle + + echo "both should fail" >>$TS_OUTPUT + LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG") ++udevadm settle + $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT ++udevadm settle + $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT ++udevadm settle + $TS_CMD_LOSETUP --detach $LOOPDEV ++udevadm settle + + ts_log "Success" + ts_finalize +-- +2.21.0 + diff --git a/SOURCES/0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch b/SOURCES/0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch new file mode 100644 index 0000000..1c2f1c8 --- /dev/null +++ b/SOURCES/0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch @@ -0,0 +1,87 @@ +From e431bfeca0f3e7be2eba30be83260f20976f871d Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 31 Jul 2019 16:18:27 +0200 +Subject: [PATCH 23/24] libblkid: fix file descriptor leak in blkid_verify() + +The function blkid_verify() uses private device file descriptor and +uses blkid_probe_set_device() to assign the descriptor to low-level +probing code. Unfortunately, close() in this case is not enough as the +prober can internally open whole-disk device too. + +The library API has been extended so blkid_probe_set_device() +deallocates and close previously used prober for whole-disk. This new +functionality is used in blkid_verify() now. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1734553 +Upstream: http://github.com/karelzak/util-linux/commit/c4d6d1c54dcd0eff701236d396d88b1fc6251768 +Signed-off-by: Karel Zak +--- + libblkid/src/probe.c | 19 ++++++++++++++++--- + libblkid/src/verify.c | 4 +++- + 2 files changed, 19 insertions(+), 4 deletions(-) + +diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c +index 647ae416a..a6dc8416a 100644 +--- a/libblkid/src/probe.c ++++ b/libblkid/src/probe.c +@@ -848,10 +848,15 @@ failed: + * @off: begin of probing area + * @size: size of probing area (zero means whole device/file) + * +- * Assigns the device to probe control struct, resets internal buffers and +- * resets the current probing. ++ * Assigns the device to probe control struct, resets internal buffers, resets ++ * the current probing, and close previously associated device (if open by ++ * libblkid). + * +- * Returns: -1 in case of failure, or 0 on success. ++ * If @fd is < 0 than only resets the prober and returns 1. Note that ++ * blkid_reset_probe() keeps the device associated with the prober, but ++ * blkid_probe_set_device() does complete reset. ++ * ++ * Returns: -1 in case of failure, 0 on success and 1 on reset. + */ + int blkid_probe_set_device(blkid_probe pr, int fd, + blkid_loff_t off, blkid_loff_t size) +@@ -866,6 +871,11 @@ int blkid_probe_set_device(blkid_probe pr, int fd, + if ((pr->flags & BLKID_FL_PRIVATE_FD) && pr->fd >= 0) + close(pr->fd); + ++ if (pr->disk_probe) { ++ blkid_free_probe(pr->disk_probe); ++ pr->disk_probe = NULL; ++ } ++ + pr->flags &= ~BLKID_FL_PRIVATE_FD; + pr->flags &= ~BLKID_FL_TINY_DEV; + pr->flags &= ~BLKID_FL_CDROM_DEV; +@@ -881,6 +891,9 @@ int blkid_probe_set_device(blkid_probe pr, int fd, + pr->wipe_size = 0; + pr->wipe_chain = NULL; + ++ if (fd < 0) ++ return 1; ++ + #if defined(POSIX_FADV_RANDOM) && defined(HAVE_POSIX_FADVISE) + /* Disable read-ahead */ + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM); +diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c +index 7f44f5497..750378f8c 100644 +--- a/libblkid/src/verify.c ++++ b/libblkid/src/verify.c +@@ -184,9 +184,11 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) + dev->bid_name, (long long)st.st_rdev, dev->bid_type)); + } + +- blkid_reset_probe(cache->probe); ++ /* reset prober */ + blkid_probe_reset_superblocks_filter(cache->probe); ++ blkid_probe_set_device(cache->probe, -1, 0, 0); + close(fd); ++ + return dev; + } + +-- +2.21.0 + diff --git a/SOURCES/0024-findmnt-verify-ignore-passno-for-XFS.patch b/SOURCES/0024-findmnt-verify-ignore-passno-for-XFS.patch new file mode 100644 index 0000000..f0ed8c8 --- /dev/null +++ b/SOURCES/0024-findmnt-verify-ignore-passno-for-XFS.patch @@ -0,0 +1,73 @@ +From 3f6de92999cf63e234265f51d6ee02134bc75ac3 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 12 Jun 2019 11:02:51 +0200 +Subject: [PATCH 24/24] findmnt: (verify) ignore passno for XFS + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1719069 +Upstream: http://github.com/karelzak/util-linux/commit/f5b7bf155b9881de5b99cc0a23b4dccf9a2d4af3 +Signed-off-by: Karel Zak +--- + misc-utils/findmnt-verify.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/misc-utils/findmnt-verify.c b/misc-utils/findmnt-verify.c +index 1cc62def9..73e44a418 100644 +--- a/misc-utils/findmnt-verify.c ++++ b/misc-utils/findmnt-verify.c +@@ -28,7 +28,8 @@ struct verify_context { + int nwarnings; + int nerrors; + +- unsigned int target_printed : 1; ++ unsigned int target_printed : 1, ++ no_fsck : 1; + }; + + static void verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap) +@@ -408,6 +409,8 @@ static int verify_fstype(struct verify_context *vfy) + isauto = 1; + else if (strcmp(type, "swap") == 0) + isswap = 1; ++ else if (strcmp(type, "xfs") == 0) ++ vfy->no_fsck = 1; + + if (!isswap && !isauto && !none && !is_supported_filesystem(vfy, type)) + verify_warn(vfy, _("%s seems unsupported by the current kernel"), type); +@@ -422,6 +425,7 @@ static int verify_fstype(struct verify_context *vfy) + + if (realtype) { + isswap = strcmp(realtype, "swap") == 0; ++ vfy->no_fsck = strcmp(realtype, "xfs") == 0; + + if (type && !isauto && strcmp(type, realtype) != 0) + return verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype); +@@ -440,7 +444,7 @@ static int verify_passno(struct verify_context *vfy) + int passno = mnt_fs_get_passno(vfy->fs); + const char *tgt = mnt_fs_get_target(vfy->fs); + +- if (tgt && strcmp("/", tgt) == 0 && passno != 1) ++ if (tgt && strcmp("/", tgt) == 0 && passno != 1 && !vfy->no_fsck) + return verify_warn(vfy, _("recommended root FS passno is 1 (current is %d)"), passno); + + return 0; +@@ -463,7 +467,7 @@ static int verify_filesystem(struct verify_context *vfy) + if (!rc) + rc = verify_fstype(vfy); + if (!rc) +- rc = verify_passno(vfy); ++ rc = verify_passno(vfy); /* depends on verify_fstype() */ + + return rc; + } +@@ -492,6 +496,8 @@ int verify_table(struct libmnt_table *tb) + + while (rc == 0 && (vfy.fs = get_next_fs(tb, itr))) { + vfy.target_printed = 0; ++ vfy.no_fsck = 0; ++ + if (check_order) + rc = verify_order(&vfy); + if (!rc) +-- +2.21.0 + diff --git a/SOURCES/0025-partx-don-t-report-ENXIO-as-error-on-d.patch b/SOURCES/0025-partx-don-t-report-ENXIO-as-error-on-d.patch new file mode 100644 index 0000000..0afeed4 --- /dev/null +++ b/SOURCES/0025-partx-don-t-report-ENXIO-as-error-on-d.patch @@ -0,0 +1,41 @@ +From be5e6b14db3cdd09dab711572116d7ee39344875 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 21 Aug 2019 10:51:18 +0200 +Subject: [PATCH 25/26] partx: don't report ENXIO as error on -d + +The errno ENXIO should be ignored, unfortunately the current code uses +variable 'rc' for ioctl return code as well as for final del_parts() +return value. So, failed ioctl (which should be ignored) affects all +del_parts() status. + + # modprobe scsi_debug dev_size_mb=100 + # partx -d --nr 1-1024 /dev/sdc; echo $? + 1 + +The device dos not contains any partitions, so 0 return code is +expected in this case. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179 +Upstream: http://github.com/karelzak/util-linux/commit/53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555 +Signed-off-by: Karel Zak +--- + disk-utils/partx.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/disk-utils/partx.c b/disk-utils/partx.c +index e3443ea80..f3dcc9007 100644 +--- a/disk-utils/partx.c ++++ b/disk-utils/partx.c +@@ -327,8 +327,7 @@ static int del_parts(int fd, const char *device, dev_t devno, + } + + for (i = lower; i <= upper; i++) { +- rc = partx_del_partition(fd, i); +- if (rc == 0) { ++ if (partx_del_partition(fd, i) == 0) { + if (verbose) + printf(_("%s: partition #%d removed\n"), device, i); + continue; +-- +2.21.0 + diff --git a/SOURCES/0026-partx-document-d-vs.-nr-and-fix-test.patch b/SOURCES/0026-partx-document-d-vs.-nr-and-fix-test.patch new file mode 100644 index 0000000..33b50ff --- /dev/null +++ b/SOURCES/0026-partx-document-d-vs.-nr-and-fix-test.patch @@ -0,0 +1,59 @@ +From 5a9269c019f9cb0b2d54444501beb74663670693 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 21 Aug 2019 13:42:22 +0200 +Subject: [PATCH 26/26] partx: document -d vs. --nr and fix test + +The commit ab025087f91b66ee8e23a16bc49eb0d9bd421d65 has disabled error +message, but unfortunately it keeps wrong return code. This has been fixed +by commit 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555. + +This commit add hit about it to docs and fix regression test too. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179 +Upstream: http://github.com/karelzak/util-linux/commit/5200aa99d27e084b514e8b035db32f39b49562a3 +Signed-off-by: Karel Zak +--- + disk-utils/partx.8 | 5 ++++- + tests/ts/partx/partx | 9 +++++++-- + 2 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/disk-utils/partx.8 b/disk-utils/partx.8 +index af7313cb9..c6bbbae42 100644 +--- a/disk-utils/partx.8 ++++ b/disk-utils/partx.8 +@@ -53,7 +53,10 @@ Add the specified partitions, or read the disk and add all partitions. + Print the SIZE column in bytes rather than in human-readable format. + .TP + .BR \-d , " \-\-delete" +-Delete the specified partitions or all partitions. ++Delete the specified partitions or all partitions. It is not error to ++remove non-existing partitions, so this option is possible to use together with ++large \fB\-\-nr\fR ranges without care about the current partitions set on ++the device. + .TP + .BR \-g , " \-\-noheadings" + Do not print a header line with \fB\-\-show\fR or \fB\-\-raw\fR. +diff --git a/tests/ts/partx/partx b/tests/ts/partx/partx +index b21dc44ef..84c286a94 100755 +--- a/tests/ts/partx/partx ++++ b/tests/ts/partx/partx +@@ -137,9 +137,14 @@ udevadm settle + ts_init_subtest "delete-non-existent" + #attempt to remove it again + { ++ # remove non-existing partitions (ENXIO) is not error ++ # ++ # see ab025087f91b66ee8e23a16bc49eb0d9bd421d65 and ++ # 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555 ++ # + $TS_CMD_PARTX -d --nr $PARTS $TS_DEVICE && +- echo "partx failed: removed non-existing partition" || +- echo "partx: OK" ++ echo "partx: OK" || ++ echo "partx failed: removed non-existing partition" + } >$TS_OUTPUT 2>&1 + ts_finalize_subtest + +-- +2.21.0 + diff --git a/SOURCES/0027-libmount-improve-mountinfo-reliability.patch b/SOURCES/0027-libmount-improve-mountinfo-reliability.patch new file mode 100644 index 0000000..c78f9ad --- /dev/null +++ b/SOURCES/0027-libmount-improve-mountinfo-reliability.patch @@ -0,0 +1,396 @@ +From 32fe4f1dd8fbc104bd848e24de613122947f095a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 28 Aug 2019 15:47:16 +0200 +Subject: [PATCH] libmount: improve mountinfo reliability +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The standard way how we read mount table is not reliable because +during the read() syscalls the table may be modified by some another +process. The changes in the table is possible to detect by poll() +event, and in this case it seems better to lseek to the begin of the file +and read it again. It's expensive, but better than races... + +This patch does not modify mountinfo parser, but it reads all file to +memory (by read()+poll()) and than it creates memory stream +from the buffer and use it rather than a regular file stream. + +It means the parser is still possible to use for normal files +(e.g. fstab) as well as for mountinfo and it's also portable to +systems where for some reason is no fmemopen(). + +Addresses: https://github.com/systemd/systemd/issues/10872 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1751447 +Upstream: http://github.com/karelzak/util-linux/commit/e4925f591c1bfb83719418b56b952830d15b77eb +Upstream: http://github.com/karelzak/util-linux/commit/ee551c909f95437fd9fcd162f398c069d0ce9720 +Reported-by: Zbigniew Jędrzejewski-Szmek +Signed-off-by: Karel Zak +--- + configure.ac | 1 + + libmount/src/mountP.h | 2 + + libmount/src/tab_parse.c | 87 +++++++++++++++++---- + libmount/src/utils.c | 158 +++++++++++++++++++++++++++++++++++++++ + 4 files changed, 233 insertions(+), 15 deletions(-) + +diff --git a/configure.ac b/configure.ac +index a05a294ad..245004890 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -456,6 +456,7 @@ AC_CHECK_FUNCS([ \ + err \ + errx \ + explicit_bzero \ ++ fmemopen \ + fsync \ + utimensat \ + getdomainname \ +diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h +index d47d26442..52a238ef3 100644 +--- a/libmount/src/mountP.h ++++ b/libmount/src/mountP.h +@@ -93,6 +93,7 @@ extern int mnt_valid_tagname(const char *tagname); + extern int append_string(char **a, const char *b); + + extern const char *mnt_statfs_get_fstype(struct statfs *vfs); ++extern int is_procfs_fd(int fd); + extern int is_file_empty(const char *name); + + extern int mnt_is_readonly(const char *path) +@@ -118,6 +119,7 @@ extern void mnt_free_filesystems(char **filesystems); + extern char *mnt_get_kernel_cmdline_option(const char *name); + extern int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path); + extern int mnt_stat_mountpoint(const char *target, struct stat *st); ++extern FILE *mnt_get_procfs_memstream(int fd, char **membuf); + + /* tab.c */ + extern int is_mountinfo(struct libmnt_table *tb); +diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c +index 3ed84ebc2..10fc68279 100644 +--- a/libmount/src/tab_parse.c ++++ b/libmount/src/tab_parse.c +@@ -603,15 +603,7 @@ static int kernel_fs_postparse(struct libmnt_table *tb, + return rc; + } + +-/** +- * mnt_table_parse_stream: +- * @tb: tab pointer +- * @f: file stream +- * @filename: filename used for debug and error messages +- * +- * Returns: 0 on success, negative number in case of error. +- */ +-int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename) ++static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename) + { + int rc = -1; + int flags = 0; +@@ -685,6 +677,40 @@ err: + return rc; + } + ++/** ++ * mnt_table_parse_stream: ++ * @tb: tab pointer ++ * @f: file stream ++ * @filename: filename used for debug and error messages ++ * ++ * Returns: 0 on success, negative number in case of error. ++ */ ++int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename) ++{ ++ int fd, rc; ++ FILE *memf = NULL; ++ char *membuf = NULL; ++ ++ /* ++ * For /proc/#/{mountinfo,mount} we read all file to memory and use it ++ * as memory stream. For more details see mnt_read_procfs_file(). ++ */ ++ if ((fd = fileno(f)) >= 0 ++ && (tb->fmt == MNT_FMT_GUESS || ++ tb->fmt == MNT_FMT_MOUNTINFO || ++ tb->fmt == MNT_FMT_MTAB) ++ && is_procfs_fd(fd) ++ && (memf = mnt_get_procfs_memstream(fd, &membuf))) { ++ ++ rc = __table_parse_stream(tb, memf, filename); ++ fclose(memf); ++ free(membuf); ++ } else ++ rc = __table_parse_stream(tb, f, filename); ++ ++ return rc; ++} ++ + /** + * mnt_table_parse_file: + * @tb: tab pointer +@@ -700,18 +726,49 @@ err: + int mnt_table_parse_file(struct libmnt_table *tb, const char *filename) + { + FILE *f; +- int rc; ++ int rc, fd = -1; + + if (!filename || !tb) + return -EINVAL; + +- f = fopen(filename, "r" UL_CLOEXECSTR); ++ /* ++ * Try to use read()+poll() to realiably read all ++ * /proc/#/{mount,mountinfo} file to memory ++ */ ++ if (tb->fmt != MNT_FMT_SWAPS ++ && strncmp(filename, "/proc/", 6) == 0) { ++ ++ FILE *memf; ++ char *membuf = NULL; ++ ++ fd = open(filename, O_RDONLY|O_CLOEXEC); ++ if (fd < 0) { ++ rc = -errno; ++ goto done; ++ } ++ memf = mnt_get_procfs_memstream(fd, &membuf); ++ if (memf) { ++ rc = __table_parse_stream(tb, memf, filename); ++ ++ fclose(memf); ++ free(membuf); ++ close(fd); ++ goto done; ++ } ++ /* else fallback to fopen/fdopen() */ ++ } ++ ++ if (fd >= 0) ++ f = fdopen(fd, "r" UL_CLOEXECSTR); ++ else ++ f = fopen(filename, "r" UL_CLOEXECSTR); ++ + if (f) { +- rc = mnt_table_parse_stream(tb, f, filename); ++ rc = __table_parse_stream(tb, f, filename); + fclose(f); + } else + rc = -errno; +- ++done: + DBG(TAB, ul_debugobj(tb, "parsing done [filename=%s, rc=%d]", filename, rc)); + return rc; + } +@@ -768,7 +825,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) + + f = fopen_at(dd, d->d_name, O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR); + if (f) { +- mnt_table_parse_stream(tb, f, d->d_name); ++ __table_parse_stream(tb, f, d->d_name); + fclose(f); + } + } +@@ -809,7 +866,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) + f = fopen_at(dirfd(dir), d->d_name, + O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR); + if (f) { +- mnt_table_parse_stream(tb, f, d->d_name); ++ __table_parse_stream(tb, f, d->d_name); + fclose(f); + } + } +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index c36187c07..f7d85d124 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + + #include "strutils.h" +@@ -408,6 +409,12 @@ const char *mnt_statfs_get_fstype(struct statfs *vfs) + return NULL; + } + ++int is_procfs_fd(int fd) ++{ ++ struct statfs sfs; ++ ++ return fstatfs(fd, &sfs) == 0 && sfs.f_type == STATFS_PROC_MAGIC; ++} + + /** + * mnt_match_fstype: +@@ -1117,8 +1124,158 @@ done: + return 1; + } + ++#if defined(HAVE_FMEMOPEN) || defined(TEST_PROGRAM) ++ ++/* ++ * This function tries to minimize possible races when we read ++ * /proc/#/{mountinfo,mount} files. ++ * ++ * The idea is to minimize number of read()s and check by poll() that during ++ * the read the mount table has not been modified. If yes, than re-read it ++ * (with some limitations to avoid never ending loop). ++ * ++ * Returns: <0 error, 0 success, 1 too many attempts ++ */ ++static int read_procfs_file(int fd, char **buf, size_t *bufsiz) ++{ ++ size_t bufmax = 0; ++ int rc = 0, tries = 0, ninters = 0; ++ char *bufptr = NULL;; ++ ++ assert(buf); ++ assert(bufsiz); ++ ++ *bufsiz = 0; ++ *buf = NULL; ++ ++ do { ++ ssize_t ret; ++ ++ if (!bufptr || bufmax == *bufsiz) { ++ char *tmp; ++ ++ bufmax = bufmax ? bufmax * 2 : (16 * 1024); ++ tmp = realloc(*buf, bufmax); ++ if (!tmp) ++ break; ++ *buf = tmp; ++ bufptr = tmp + *bufsiz; ++ } ++ ++ errno = 0; ++ ret = read(fd, bufptr, bufmax - *bufsiz); ++ ++ if (ret < 0) { ++ /* error */ ++ if ((errno == EAGAIN || errno == EINTR) && (ninters++ < 5)) { ++ xusleep(200000); ++ continue; ++ } ++ break; ++ ++ } else if (ret > 0) { ++ /* success -- verify no event during read */ ++ struct pollfd fds[] = { ++ { .fd = fd, .events = POLLPRI } ++ }; ++ ++ rc = poll(fds, 1, 0); ++ if (rc < 0) ++ break; /* poll() error */ ++ if (rc > 0) { ++ /* event -- read all again */ ++ if (lseek(fd, 0, SEEK_SET) != 0) ++ break; ++ *bufsiz = 0; ++ bufptr = *buf; ++ tries++; ++ ++ if (tries > 10) ++ /* busy system? -- wait */ ++ xusleep(10000); ++ continue; ++ } ++ ++ /* successful read() without active poll() */ ++ (*bufsiz) += (size_t) ret; ++ bufptr += ret; ++ tries = ninters = 0; ++ } else { ++ /* end-of-file */ ++ goto success; ++ } ++ } while (tries <= 100); ++ ++ rc = errno ? -errno : 1; ++ free(*buf); ++ return rc; ++ ++success: ++ return 0; ++} ++ ++/* ++ * Create FILE stream for data from read_procfs_file() ++ */ ++FILE *mnt_get_procfs_memstream(int fd, char **membuf) ++{ ++ FILE *memf; ++ size_t sz = 0; ++ off_t cur; ++ ++ /* in case of error, rewind to the original position */ ++ cur = lseek(fd, 0, SEEK_CUR); ++ ++ if (read_procfs_file(fd, membuf, &sz) == 0 ++ && sz > 0 ++ && (memf = fmemopen(*membuf, sz, "r"))) ++ return memf; ++ ++ /* error */ ++ lseek(fd, cur, SEEK_SET); ++ return NULL; ++} ++#else ++FILE *mnt_get_procfs_memstream(int fd __attribute((__unused__)), ++ char **membuf __attribute((__unused__))) ++{ ++ return NULL; ++} ++#endif /* HAVE_FMEMOPEN */ ++ + + #ifdef TEST_PROGRAM ++static int test_proc_read(struct libmnt_test *ts, int argc, char *argv[]) ++{ ++ char *buf = NULL; ++ char *filename = argv[1]; ++ size_t bufsiz = 0; ++ int rc = 0, fd = open(filename, O_RDONLY); ++ ++ if (fd <= 0) { ++ warn("%s: cannot open", filename); ++ return -errno; ++ } ++ ++ rc = read_procfs_file(fd, &buf, &bufsiz); ++ close(fd); ++ ++ switch (rc) { ++ case 0: ++ fwrite(buf, 1, bufsiz, stdout); ++ free(buf); ++ break; ++ case 1: ++ warnx("too many attempts"); ++ break; ++ default: ++ warn("%s: cannot read", filename); ++ break; ++ } ++ ++ return rc; ++} ++ + static int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[]) + { + char *type = argv[1]; +@@ -1300,6 +1457,7 @@ int main(int argc, char *argv[]) + { "--guess-root", test_guess_root, "[]" }, + { "--mkdir", test_mkdir, "" }, + { "--statfs-type", test_statfs_type, "" }, ++ { "--read-procfs", test_proc_read, "" }, + + { NULL } + }; +-- +2.21.0 + diff --git a/SOURCES/0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch b/SOURCES/0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch new file mode 100644 index 0000000..e356bf4 --- /dev/null +++ b/SOURCES/0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch @@ -0,0 +1,53 @@ +From d9fe56d8da9015694fcba5f3dd850becff677ab5 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 20 Sep 2019 13:00:19 +0200 +Subject: [PATCH] libmount: use fmemopen() in more robust way [coverity scan] + +Upstream: http://github.com/karelzak/util-linux/commit/026f7d302066a4e6f5a69dc9818ec3180939f4a3 +Upstream: http://github.com/karelzak/util-linux/commit/bc747dfccf511419312ec872cefa90e25d83136a +Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1751447 +Signed-off-by: Karel Zak +--- + libmount/src/utils.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index f7d85d124..04e79f53f 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -1219,20 +1219,26 @@ success: + */ + FILE *mnt_get_procfs_memstream(int fd, char **membuf) + { +- FILE *memf; + size_t sz = 0; + off_t cur; + ++ *membuf = NULL; ++ + /* in case of error, rewind to the original position */ + cur = lseek(fd, 0, SEEK_CUR); + +- if (read_procfs_file(fd, membuf, &sz) == 0 +- && sz > 0 +- && (memf = fmemopen(*membuf, sz, "r"))) +- return memf; ++ if (read_procfs_file(fd, membuf, &sz) == 0 && sz > 0) { ++ FILE *memf = fmemopen(*membuf, sz, "r"); ++ if (memf) ++ return memf; /* success */ ++ ++ free(*membuf); ++ *membuf = NULL; ++ } + + /* error */ +- lseek(fd, cur, SEEK_SET); ++ if (cur != (off_t) -1) ++ lseek(fd, cur, SEEK_SET); + return NULL; + } + #else +-- +2.21.0 + diff --git a/SOURCES/util-linux-su.pamd b/SOURCES/util-linux-su.pamd index 030657f..5733201 100644 --- a/SOURCES/util-linux-su.pamd +++ b/SOURCES/util-linux-su.pamd @@ -1,4 +1,5 @@ #%PAM-1.0 +auth required pam_env.so auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. #auth sufficient pam_wheel.so trust use_uid diff --git a/SPECS/util-linux.spec b/SPECS/util-linux.spec index 883de2d..cf2d224 100644 --- a/SPECS/util-linux.spec +++ b/SPECS/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 8%{?dist} +Release: 17%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -37,6 +37,13 @@ Buildrequires: libuser-devel BuildRequires: libcap-ng-devel BuildRequires: %{pypkg}-devel BuildRequires: gcc +%ifarch ppc64le +BuildRequires: librtas-devel +%endif +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +BuildRequires: bison ### Sources Source0: ftp://ftp.kernel.org/pub/linux/utils/util-linux/v%{upstream_major}/util-linux-%{upstream_version}.tar.xz @@ -119,6 +126,28 @@ Patch13: 0013-libfdisk-Fix-multipath-partition-seperators-for-user.patch # 1653413 - blkid: add --no-part-details to not return metadata from empty partitions Patch14: 0014-blkid-make-PART_ENTRY_-tags-optional-add-no-part-det.patch +### RHEL-8.1 +### +# 1681062 - Add gainting tests +Patch15: 0015-tests-add-missing-ts_check_test_command-calls.patch +Patch16: 0016-tests-add-use-system-commands.patch +Patch17: 0017-tests-kill-do-not-use-shell-build-in.patch +Patch18: 0018-tests-add-missing-TS_CMD_UMOUNT-check.patch +Patch19: 0019-tests-add-noskip-commands.patch +Patch20: 0020-tests-add-missing-program-checks.patch +Patch21: 0021-tests-check-for-tar-and-b-g-zip.patch +Patch22: 0022-tests-make-mount-oloop-use-more-robust.patch +# 1734553 - RHEL-8: blkid_get_dev() leak file descriptor to underlying block device +Patch23: 0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch +# 1719069 - Findmnt warning "recommended root FS passno is 1" for XFS +Patch24: 0024-findmnt-verify-ignore-passno-for-XFS.patch +# 1739179 - partx failed on nvme devices with exit code 1 +Patch25: 0025-partx-don-t-report-ENXIO-as-error-on-d.patch +Patch26: 0026-partx-document-d-vs.-nr-and-fix-test.patch +# 1751447 - improve /proc/self/mountinfo reliability +Patch27: 0027-libmount-improve-mountinfo-reliability.patch +Patch28: 0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch + %description The util-linux package contains a large variety of low-level system @@ -305,6 +334,12 @@ chfn and chsh utilities with dependence on libuser %build unset LINGUAS || : +# unfortunately, we did changes to build-system +./autogen.sh + +# if we modify .po files by RHEL patches +rm -f po/stamp* + export CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS" export SUID_CFLAGS="-fpie" export SUID_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" @@ -350,7 +385,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_sbindir} mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/{pam.d,security/console.apps} mkdir -p ${RPM_BUILD_ROOT}/var/log touch ${RPM_BUILD_ROOT}/var/log/lastlog -chmod 0644 ${RPM_BUILD_ROOT}/var/log/lastlog +chmod 0664 ${RPM_BUILD_ROOT}/var/log/lastlog # install util-linux make install DESTDIR=${RPM_BUILD_ROOT} @@ -459,8 +494,8 @@ find $RPM_BUILD_ROOT%{_mandir}/man8 -regextype posix-egrep \ # only for minimal buildroots without /var/log [ -d /var/log ] || mkdir -p /var/log touch /var/log/lastlog -chown root:root /var/log/lastlog -chmod 0644 /var/log/lastlog +chown root:utmp /var/log/lastlog +chmod 0664 /var/log/lastlog # Fix the file context, do not use restorecon if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then SECXT=$( /usr/sbin/matchpathcon -n /var/log/lastlog 2> /dev/null ) @@ -549,7 +584,7 @@ fi %attr(755,root,root) %{_bindir}/login %attr(2755,root,tty) %{_bindir}/write -%ghost %attr(0644,root,root) %verify(not md5 size mtime) /var/log/lastlog +%ghost %attr(0664,root,utmp) %verify(not md5 size mtime) /var/log/lastlog %ghost %verify(not md5 size mtime) %config(noreplace,missingok) /etc/mtab %{_unitdir}/fstrim.* @@ -978,6 +1013,35 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Sat Sep 21 2019 Karel Zak 2.32.1-17 +- fix error path in mountinfo patch (#1751447) + +* Fri Sep 20 2019 Karel Zak 2.32.1-16 +- cleanup mountinfo libmount patch (#1751447) + +* Mon Sep 16 2019 Karel Zak 2.32.1-15 +- fix #1751447 - improve /proc/self/mountinfo reliability + +* Tue Sep 03 2019 Karel Zak 2.32.1-14 +- fix #1739179 - partx failed on nvme devices with exit code 1 + +* Mon Aug 05 2019 Karel Zak 2.32.1-13 +- fix #1734553 - blkid_get_dev() leak file descriptor to underlying block device +- fix #1719069 - findmnt warning "recommended root FS passno is 1" for XFS + +* Tue Jul 30 2019 Karel Zak 2.32.1-12 +- fix #1732769 - lscpu not showing Physical socket, chips information + +* Tue Jun 04 2019 Karel Zak 2.32.1-11 +- fix #1681062 - improve loopdev use in gating tests + +* Mon Jun 03 2019 Karel Zak 2.32.1-10 +- fix #1699310 - rpm -V setup fail on /var/log/lastlog +- fix #1702712 - pam_env bypassed for root user when using su + +* Tue Mar 05 2019 Karel Zak 2.32.1-9 +- fix #1681062 - implement gating tests + * Tue Dec 11 2018 Karel Zak 2.32.1-8 - fix #1658206 - improve dependence between subpackages