From 9b7c775079be4591551ec63b50c080399211dc00 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Wed, 8 Feb 2023 14:17:53 +0000 Subject: [PATCH] import util-linux-2.32.1-40.el8 --- ...t-continuous-clock-handling-for-time.patch | 2 +- ...-clock-value-from-LIBUUID_CLOCK_FILE.patch | 2 +- ...trim-backport-entries-de-duplication.patch | 190 ++++++++++++++ ...don-t-reply-on-scsi_debug-partitions.patch | 66 +++++ ...eric-error-message-for-EACCES-on-umo.patch | 27 ++ ...logins-man-explain-password-statuses.patch | 45 ++++ ...-utmp-strings-use-with-upstream-code.patch | 245 ++++++++++++++++++ SPECS/util-linux.spec | 26 +- 8 files changed, 597 insertions(+), 6 deletions(-) create mode 100644 SOURCES/0087-fstrim-backport-entries-de-duplication.patch create mode 100644 SOURCES/0088-tests-don-t-reply-on-scsi_debug-partitions.patch create mode 100644 SOURCES/0089-libmount-use-generic-error-message-for-EACCES-on-umo.patch create mode 100644 SOURCES/0090-lslogins-man-explain-password-statuses.patch create mode 100644 SOURCES/0091-last-sync-utmp-strings-use-with-upstream-code.patch diff --git a/SOURCES/0085-libuuid-Implement-continuous-clock-handling-for-time.patch b/SOURCES/0085-libuuid-Implement-continuous-clock-handling-for-time.patch index ef9798b..9495ff0 100644 --- a/SOURCES/0085-libuuid-Implement-continuous-clock-handling-for-time.patch +++ b/SOURCES/0085-libuuid-Implement-continuous-clock-handling-for-time.patch @@ -1,4 +1,4 @@ -From ce49a152fd8a830b1c9c0a8b745ea71feff71697 Mon Sep 17 00:00:00 2001 +From ccc5db8102728d37e2e28dd50da3370e8c8de33a Mon Sep 17 00:00:00 2001 From: Michael Trapp Date: Mon, 20 Jun 2022 17:10:36 +0200 Subject: libuuid: Implement continuous clock handling for time based UUIDs diff --git a/SOURCES/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch b/SOURCES/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch index 401c52a..4352651 100644 --- a/SOURCES/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch +++ b/SOURCES/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch @@ -1,4 +1,4 @@ -From fffaa2c0856de8c42b17c52a641cbc5d00ec012b Mon Sep 17 00:00:00 2001 +From 44cebf3e692053541f362b62f88f327c2c96e70e Mon Sep 17 00:00:00 2001 From: Michael Trapp Date: Tue, 2 Aug 2022 14:16:43 +0200 Subject: libuuid: check clock value from LIBUUID_CLOCK_FILE diff --git a/SOURCES/0087-fstrim-backport-entries-de-duplication.patch b/SOURCES/0087-fstrim-backport-entries-de-duplication.patch new file mode 100644 index 0000000..921ad25 --- /dev/null +++ b/SOURCES/0087-fstrim-backport-entries-de-duplication.patch @@ -0,0 +1,190 @@ +From 9272023b42febae7db1ec828016a980146095a83 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Feb 2023 13:21:33 +0100 +Subject: fstrim: backport entries de-duplication + +Upstream: http://github.com/util-linux/util-linux/commit/9dbc073e4c58a56f68da8209df19789131446f5e +Upstream: http://github.com/util-linux/util-linux/commit/67f974d41d62c8b521fe81e1aac92562366f6a0a +Upstream: http://github.com/util-linux/util-linux/commit/20af6cee463cd6329b4f06db3282a09be942bd7a +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2121699 +Signed-off-by: Karel Zak +--- + sys-utils/fstrim.c | 88 ++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 74 insertions(+), 14 deletions(-) + +diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c +index 70870ef69..6aa523d72 100644 +--- a/sys-utils/fstrim.c ++++ b/sys-utils/fstrim.c +@@ -35,6 +35,7 @@ + + #include + #include ++#include + #include + + #include "nls.h" +@@ -43,6 +44,7 @@ + #include "closestream.h" + #include "pathnames.h" + #include "sysfs.h" ++#include "statfs_magic.h" + + #include + +@@ -84,6 +86,7 @@ static int fstrim_filesystem(const char *path, struct fstrim_range *rangetpl, + goto done; + } + errno = 0; ++ + if (ioctl(fd, FITRIM, &range)) { + rc = errno == EOPNOTSUPP || errno == ENOTTY ? 1 : -errno; + +@@ -114,7 +117,7 @@ static int has_discard(const char *devname, struct sysfs_cxt *wholedisk) + struct sysfs_cxt cxt, *parent = NULL; + uint64_t dg = 0; + dev_t disk = 0, dev; +- int rc; ++ int rc, rdonly = 0; + + dev = sysfs_devname_to_devno(devname, NULL); + if (!dev) +@@ -139,11 +142,46 @@ static int has_discard(const char *devname, struct sysfs_cxt *wholedisk) + rc = sysfs_init(&cxt, dev, parent); + if (!rc) + rc = sysfs_read_u64(&cxt, "queue/discard_granularity", &dg); ++ if (!rc) ++ sysfs_scanf(&cxt, "ro", "%d", &rdonly); + + sysfs_deinit(&cxt); +- return rc == 0 && dg > 0; ++ return rc == 0 && dg > 0 && rdonly == 0; + } + ++static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt) ++{ ++ struct statfs vfs; ++ int fd, rc; ++ ++ if (mnt_fs_is_pseudofs(fs)) ++ return 1; ++ if (mnt_fs_is_netfs(fs)) ++ return 1; ++ if (mnt_fs_is_swaparea(fs)) ++ return 1; ++ if (mnt_fs_match_fstype(fs, "autofs")) ++ return 1; ++ if (mnt_fs_match_options(fs, "ro")) ++ return 1; ++ ++ fd = open(tgt, O_PATH); ++ if (fd < 0) ++ return 1; ++ rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC; ++ close(fd); ++ if (rc) ++ return 1; ++ ++ /* FITRIM on read-only filesystem can fail, and it can fail */ ++ if (access(tgt, W_OK) != 0) { ++ if (errno == EROFS) ++ return 1; ++ if (errno == EACCES) ++ return 1; ++ } ++ return 0; ++} + + static int uniq_fs_target_cmp( + struct libmnt_table *tb __attribute__((__unused__)), +@@ -182,30 +220,38 @@ static int fstrim_all(struct fstrim_range *rangetpl, int verbose) + + mnt_init_debug(0); + +- itr = mnt_new_iter(MNT_ITER_BACKWARD); +- if (!itr) +- err(MNT_EX_FAIL, _("failed to initialize libmount iterator")); +- + tab = mnt_new_table_from_file(_PATH_PROC_MOUNTINFO); + if (!tab) + err(MNT_EX_FAIL, _("failed to parse %s"), _PATH_PROC_MOUNTINFO); + ++ if (mnt_table_is_empty(tab)) { ++ mnt_unref_table(tab); ++ return MNT_EX_SUCCESS; ++ } ++ + /* de-duplicate by mountpoints */ + mnt_table_uniq_fs(tab, 0, uniq_fs_target_cmp); + +- /* de-duplicate by source */ +- mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp); ++ itr = mnt_new_iter(MNT_ITER_BACKWARD); ++ if (!itr) ++ err(MNT_EX_FAIL, _("failed to initialize libmount iterator")); + ++ /* Remove useless entries and canonicalize the table */ + while (mnt_table_next_fs(tab, itr, &fs) == 0) { + const char *src = mnt_fs_get_srcpath(fs), + *tgt = mnt_fs_get_target(fs); + char *path; + int rc = 1; + +- if (!src || !tgt || *src != '/' || +- mnt_fs_is_pseudofs(fs) || +- mnt_fs_is_netfs(fs)) ++ if (!tgt || is_unwanted_fs(fs, tgt)) { ++ mnt_table_remove_fs(tab, fs); + continue; ++ } ++ ++ if (!src || *src != '/') { ++ mnt_table_remove_fs(tab, fs); ++ continue; ++ } + + /* Is it really accessible mountpoint? Not all mountpoints are + * accessible (maybe over mounted by another filesystem) */ +@@ -213,11 +259,25 @@ static int fstrim_all(struct fstrim_range *rangetpl, int verbose) + if (path && strcmp(path, tgt) == 0) + rc = 0; + free(path); +- if (rc) ++ if (rc) { ++ mnt_table_remove_fs(tab, fs); + continue; /* overlaying mount */ ++ } + +- if (!has_discard(src, &wholedisk)) ++ if (!has_discard(src, &wholedisk)) { ++ mnt_table_remove_fs(tab, fs); + continue; ++ } ++ } ++ ++ /* de-duplicate by source */ ++ mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp); ++ ++ mnt_reset_iter(itr, MNT_ITER_BACKWARD); ++ ++ /* Do FITRIM */ ++ while (mnt_table_next_fs(tab, itr, &fs) == 0) { ++ const char *tgt = mnt_fs_get_target(fs); + cnt++; + + /* +@@ -231,10 +291,10 @@ static int fstrim_all(struct fstrim_range *rangetpl, int verbose) + if (fstrim_filesystem(tgt, rangetpl, verbose) < 0) + cnt_err++; + } ++ mnt_free_iter(itr); + + sysfs_deinit(&wholedisk); + mnt_unref_table(tab); +- mnt_free_iter(itr); + + if (cnt && cnt == cnt_err) + return MNT_EX_FAIL; /* all failed */ +-- +2.39.1 + diff --git a/SOURCES/0088-tests-don-t-reply-on-scsi_debug-partitions.patch b/SOURCES/0088-tests-don-t-reply-on-scsi_debug-partitions.patch new file mode 100644 index 0000000..2ed72a4 --- /dev/null +++ b/SOURCES/0088-tests-don-t-reply-on-scsi_debug-partitions.patch @@ -0,0 +1,66 @@ +From a95ff5ed155c29734824f3a79350678901b22e43 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 11 Feb 2021 12:44:44 +0100 +Subject: tests: don't reply on scsi_debug partitions + +The disk layout as created by scsi_debug depends on kernel version. +Let's make the partition sizes hardcoded in our tests than rely on +kernel. + +Signed-off-by: Karel Zak +Upstream: http://github.com/util-linux/util-linux/commit/15a37d00e5e59f0f628d0a6b6cd2f9636702fd7c +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2142496 +--- + tests/expected/partx/partx-detect-parts | 6 +++--- + tests/ts/partx/partx | 14 +++++++++++--- + 2 files changed, 14 insertions(+), 6 deletions(-) + +diff --git a/tests/expected/partx/partx-detect-parts b/tests/expected/partx/partx-detect-parts +index 33d42a58c..0adc85577 100644 +--- a/tests/expected/partx/partx-detect-parts ++++ b/tests/expected/partx/partx-detect-parts +@@ -1,5 +1,5 @@ + NR START END SECTORS SIZE NAME UUID +- 1 32 33791 33760 16.5M +- 2 33792 67583 33792 16.5M +- 3 67584 102399 34816 17M ++ 1 32 33791 33760 16.5M 1ddc8a79-01 ++ 2 33792 67583 33792 16.5M 1ddc8a79-02 ++ 3 67584 102399 34816 17M 1ddc8a79-03 + OK +diff --git a/tests/ts/partx/partx b/tests/ts/partx/partx +index 84c286a94..6514ae62c 100755 +--- a/tests/ts/partx/partx ++++ b/tests/ts/partx/partx +@@ -26,6 +26,7 @@ ts_init "$*" + ts_check_test_command "$TS_CMD_PARTX" + ts_check_test_command "$TS_CMD_ADDPART" + ts_check_test_command "$TS_CMD_DELPART" ++ts_check_test_command "$TS_CMD_SFDISK" + + ts_skip_nonroot + +@@ -70,10 +71,17 @@ ts_init_subtest "delpart" + } >$TS_OUTPUT 2>&1 + ts_finalize_subtest + +-ts_scsi_debug_rmmod + +-# set global variable TS_DEVICE +-ts_scsi_debug_init dev_size_mb=50 num_parts=$PARTS ++udevadm settle ++$TS_CMD_SFDISK $TS_DEVICE &> /dev/null < +Date: Thu, 2 Feb 2023 14:47:04 +0100 +Subject: libmount: use generic error message for EACCES on umount + +Signed-off-by: Karel Zak +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2149394 +--- + libmount/src/context_umount.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c +index 240ec3be6..23aaae395 100644 +--- a/libmount/src/context_umount.c ++++ b/libmount/src/context_umount.c +@@ -1123,7 +1123,7 @@ int mnt_context_get_umount_excode( + snprintf(buf, bufsz, _("must be superuser to unmount")); + break; + case EACCES: +- snprintf(buf, bufsz, _("block devices are not permitted on filesystem")); ++ snprintf(buf, bufsz, _("filesystem not accessible")); + break; + default: + return mnt_context_get_generic_excode(syserr, buf, bufsz,_("umount(2) system call failed: %m")); +-- +2.39.1 + diff --git a/SOURCES/0090-lslogins-man-explain-password-statuses.patch b/SOURCES/0090-lslogins-man-explain-password-statuses.patch new file mode 100644 index 0000000..7dbc434 --- /dev/null +++ b/SOURCES/0090-lslogins-man-explain-password-statuses.patch @@ -0,0 +1,45 @@ +From ea1ad5e7260c770b21e547702b1e0acef9e4854c Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Feb 2023 14:52:35 +0100 +Subject: lslogins: (man) explain password statuses + +Upstream: http://github.com/util-linux/util-linux/commit/95ea3dd4128b625ab12691229020ebc50d578e71 +Upstream: http://github.com/util-linux/util-linux/commit/8001bffb03eda8d23d6a04a5dc1469cce932ae36 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2159544 +Signed-off-by: Karel Zak +--- + login-utils/lslogins.1 | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/login-utils/lslogins.1 b/login-utils/lslogins.1 +index c831739d9..5c327caf5 100644 +--- a/login-utils/lslogins.1 ++++ b/login-utils/lslogins.1 +@@ -116,6 +116,24 @@ Delimit user entries with a nul character, instead of a newline. + + .SH NOTES + The default UID thresholds are read from /etc/login.defs. ++.SS "Password status" ++.sp ++Multiple fields describe password status. ++.sp ++\fB"Login by password disabled"\fP ++.RS 4 ++\*(Aqyes\*(Aq means that there is no valid password. The password hash is missing, or the hash method is unknown or contains invalid chars. ++.RE ++.sp ++\fB"Password not required (empty)"\fP ++.RS 4 ++The password is not set (hash is missing); this is common for locked system accounts. Not requiring a password does not mean the user can log\-in without a password. It depends on the password "lock" status. ++.RE ++.sp ++\fB"Password is locked"\fP ++.RS 4 ++The password is prefixed by \*(Aq!!\*(Aq, and the user cannot login although the password is set or empty. This is common for new accounts without a set password. ++.RE + + .SH EXIT STATUS + .TP +-- +2.39.1 + diff --git a/SOURCES/0091-last-sync-utmp-strings-use-with-upstream-code.patch b/SOURCES/0091-last-sync-utmp-strings-use-with-upstream-code.patch new file mode 100644 index 0000000..6e0abc3 --- /dev/null +++ b/SOURCES/0091-last-sync-utmp-strings-use-with-upstream-code.patch @@ -0,0 +1,245 @@ +From 25f7136d326753cb0bb7612a98db6542c9fdc3bd Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Feb 2023 15:22:52 +0100 +Subject: last: sync utmp strings use with upstream code + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2160321 +Signed-off-by: Karel Zak +--- + include/strutils.h | 30 +++++++++++++++++++ + include/timeutils.h | 1 + + login-utils/last.c | 73 +++++++++++++++++++++++---------------------- + 3 files changed, 69 insertions(+), 35 deletions(-) + +diff --git a/include/strutils.h b/include/strutils.h +index 5d07fcc7c..193f1acbc 100644 +--- a/include/strutils.h ++++ b/include/strutils.h +@@ -65,6 +65,36 @@ static inline void xstrncpy(char *dest, const char *src, size_t n) + dest[n-1] = 0; + } + ++/* This is like strncpy(), but based on memcpy(), so compilers and static ++ * analyzers do not complain when sizeof(destination) is the same as 'n' and ++ * result is not terminated by zero. ++ * ++ * Use this function to copy string to logs with fixed sizes (wtmp/utmp. ...) ++ * where string terminator is optional. ++ */ ++static inline void * __attribute__((nonnull (1))) ++str2memcpy(void *dest, const char *src, size_t n) ++{ ++ size_t bytes = strlen(src) + 1; ++ ++ if (bytes > n) ++ bytes = n; ++ ++ memcpy(dest, src, bytes); ++ return dest; ++} ++ ++static inline char * __attribute__((nonnull (1))) ++mem2strcpy(char *dest, const void *src, size_t n, size_t nmax) ++{ ++ if (n + 1 > nmax) ++ n = nmax - 1; ++ ++ memset(dest, '\0', nmax); ++ memcpy(dest, src, n); ++ return dest; ++} ++ + static inline int strdup_to_offset(void *stru, size_t offset, const char *str) + { + char *n = NULL; +diff --git a/include/timeutils.h b/include/timeutils.h +index 230e6db5f..f1540a183 100644 +--- a/include/timeutils.h ++++ b/include/timeutils.h +@@ -74,6 +74,7 @@ enum { + ISO_TIMESTAMP_COMMA_GT = ISO_TIMESTAMP_COMMA_G | ISO_T + }; + ++#define CTIME_BUFSIZ 26 + #define ISO_BUFSIZ 42 + + int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz); +diff --git a/login-utils/last.c b/login-utils/last.c +index 80d77d20b..8f7c36984 100644 +--- a/login-utils/last.c ++++ b/login-utils/last.c +@@ -339,15 +339,22 @@ static int time_formatter(int fmt, char *dst, size_t dlen, time_t *when) + break; + case LAST_TIMEFTM_HHMM: + { +- struct tm *tm = localtime(when); +- if (!snprintf(dst, dlen, "%02d:%02d", tm->tm_hour, tm->tm_min)) ++ struct tm tm; ++ ++ localtime_r(when, &tm); ++ if (!snprintf(dst, dlen, "%02d:%02d", tm.tm_hour, tm.tm_min)) + ret = -1; + break; + } + case LAST_TIMEFTM_CTIME: +- snprintf(dst, dlen, "%s", ctime(when)); ++ { ++ char buf[CTIME_BUFSIZ]; ++ ++ ctime_r(when, buf); ++ snprintf(dst, dlen, "%s", buf); + ret = rtrim_whitespace((unsigned char *) dst); + break; ++ } + case LAST_TIMEFTM_ISO8601: + ret = strtime_iso(when, ISO_TIMESTAMP_T, dst, dlen); + break; +@@ -394,8 +401,7 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t + /* + * uucp and ftp have special-type entries + */ +- utline[0] = 0; +- strncat(utline, p->ut_line, sizeof(p->ut_line)); ++ mem2strcpy(utline, p->ut_line, sizeof(p->ut_line), sizeof(utline)); + if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3])) + utline[3] = 0; + if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4])) +@@ -447,48 +453,48 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t + + if (logout_time == currentdate) { + if (ctl->time_fmt > LAST_TIMEFTM_SHORT) { +- sprintf(logouttime, " still running"); ++ snprintf(logouttime, sizeof(logouttime), " still running"); + length[0] = 0; + } else { +- sprintf(logouttime, " still"); +- sprintf(length, "running"); ++ snprintf(logouttime, sizeof(logouttime), " still"); ++ snprintf(length, sizeof(length), "running"); + } + } else if (days) { +- sprintf(length, "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */ ++ snprintf(length, sizeof(length), "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */ + } else if (hours) { +- sprintf(length, " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */ ++ snprintf(length, sizeof(length), " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */ + } else if (secs >= 0) { +- sprintf(length, " (%02d:%02d)", hours, mins); ++ snprintf(length, sizeof(length), " (%02d:%02d)", hours, mins); + } else { +- sprintf(length, " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */ ++ snprintf(length, sizeof(length), " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */ + } + + switch(what) { + case R_CRASH: +- sprintf(logouttime, "- crash"); ++ snprintf(logouttime, sizeof(logouttime), "- crash"); + break; + case R_DOWN: +- sprintf(logouttime, "- down "); ++ snprintf(logouttime, sizeof(logouttime), "- down "); + break; + case R_NOW: + if (ctl->time_fmt > LAST_TIMEFTM_SHORT) { +- sprintf(logouttime, " still logged in"); ++ snprintf(logouttime, sizeof(logouttime), " still logged in"); + length[0] = 0; + } else { +- sprintf(logouttime, " still"); +- sprintf(length, "logged in"); ++ snprintf(logouttime, sizeof(logouttime), " still"); ++ snprintf(length, sizeof(length), "logged in"); + } + break; + case R_PHANTOM: + if (ctl->time_fmt > LAST_TIMEFTM_SHORT) { +- sprintf(logouttime, " gone - no logout"); ++ snprintf(logouttime, sizeof(logouttime), " gone - no logout"); + length[0] = 0; + } else if (ctl->time_fmt == LAST_TIMEFTM_SHORT) { +- sprintf(logouttime, " gone"); +- sprintf(length, "- no logout"); ++ snprintf(logouttime, sizeof(logouttime), " gone"); ++ snprintf(length, sizeof(length), "- no logout"); + } else { + logouttime[0] = 0; +- sprintf(length, "no logout"); ++ snprintf(length, sizeof(length), "no logout"); + } + break; + case R_TIMECHANGE: +@@ -508,15 +514,8 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t + r = -1; + if (ctl->usedns || ctl->useip) + r = dns_lookup(domain, sizeof(domain), ctl->useip, (int32_t*)p->ut_addr_v6); +- if (r < 0) { +- size_t sz = sizeof(p->ut_host); +- +- if (sz > sizeof(domain)) +- sz = sizeof(domain); +- +- xstrncpy(domain, p->ut_host, sz); +- } +- ++ if (r < 0) ++ mem2strcpy(domain, p->ut_host, sizeof(p->ut_host), sizeof(domain)); + + if (ctl->showhost) { + if (!ctl->altlist) { +@@ -607,10 +606,11 @@ static int is_phantom(const struct last_control *ctl, struct utmpx *ut) + + if (ut->ut_tv.tv_sec < ctl->boot_time.tv_sec) + return 1; ++ ut->ut_user[sizeof(ut->ut_user) - 1] = '\0'; + pw = getpwnam(ut->ut_user); + if (!pw) + return 1; +- sprintf(path, "/proc/%u/loginuid", ut->ut_pid); ++ snprintf(path, sizeof(path), "/proc/%u/loginuid", ut->ut_pid); + if (access(path, R_OK) == 0) { + unsigned int loginuid; + FILE *f = NULL; +@@ -624,8 +624,11 @@ static int is_phantom(const struct last_control *ctl, struct utmpx *ut) + return 1; + } else { + struct stat st; ++ char utline[sizeof(ut->ut_line) + 1]; ++ ++ mem2strcpy(utline, ut->ut_line, sizeof(ut->ut_line), sizeof(utline)); + +- sprintf(path, "/dev/%s", ut->ut_line); ++ snprintf(path, sizeof(path), "/dev/%s", utline); + if (stat(path, &st)) + return 1; + if (pw->pw_uid != st.st_uid) +@@ -736,7 +739,7 @@ static void process_wtmp_file(const struct last_control *ctl, + else { + if (ut.ut_type != DEAD_PROCESS && + ut.ut_user[0] && ut.ut_line[0] && +- strcmp(ut.ut_user, "LOGIN") != 0) ++ strncmp(ut.ut_user, "LOGIN", 5) != 0) + ut.ut_type = USER_PROCESS; + /* + * Even worse, applications that write ghost +@@ -749,7 +752,7 @@ static void process_wtmp_file(const struct last_control *ctl, + /* + * Clock changes. + */ +- if (strcmp(ut.ut_user, "date") == 0) { ++ if (strncmp(ut.ut_user, "date", 4) == 0) { + if (ut.ut_line[0] == '|') + ut.ut_type = OLD_TIME; + if (ut.ut_line[0] == '{') +@@ -784,7 +787,7 @@ static void process_wtmp_file(const struct last_control *ctl, + case RUN_LVL: + x = ut.ut_pid & 255; + if (ctl->extended) { +- sprintf(ut.ut_line, "(to lvl %c)", x); ++ snprintf(ut.ut_line, sizeof(ut.ut_line), "(to lvl %c)", x); + quit = list(ctl, &ut, lastrch, R_NORMAL); + } + if (x == '0' || x == '6') { +-- +2.39.1 + diff --git a/SPECS/util-linux.spec b/SPECS/util-linux.spec index cf4fbde..5f8f97f 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: 39%{?dist} +Release: 40%{?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 @@ -261,11 +261,22 @@ Patch82: 0082-lslogins-improve-prefixes-interpretation.patch Patch83: 0083-tests-update-atari-blkid-tests.patch Patch84: 0084-tests-update-atari-partx-tests.patch -### RHEL-8.7.Z +### RHEL-8.8 ### -# 2141969 - Add --cont-clock feature for libuuid and uuidd +# 2141969 - Add --cont-clock feature for libuuid and uuidd [rhel-8] Patch85: 0085-libuuid-Implement-continuous-clock-handling-for-time.patch Patch86: 0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch +# 2121699 - fstrim -av fails to trim root filesystem on Red Hat Coreos +Patch87: 0087-fstrim-backport-entries-de-duplication.patch +# 2142496 - update upstream tests +Patch88: 0088-tests-don-t-reply-on-scsi_debug-partitions.patch +# 2149394 - umount outputs inaccurate error message when umount() fails with EACCES +Patch89: 0089-libmount-use-generic-error-message-for-EACCES-on-umo.patch +# 2159544 - lslogins "Password is locked" status changed in util-linux-2.32.1-38 +Patch90: 0090-lslogins-man-explain-password-statuses.patch +# 2160321 - [last] ut->ut_user is not null terminated +Patch91: 0091-last-sync-utmp-strings-use-with-upstream-code.patch + %description The util-linux package contains a large variety of low-level system @@ -1114,7 +1125,14 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog -* Wed Nov 16 2022 Karel Zak 2.32.1-39 +* Mon Feb 06 2023 Karel Zak 2.32.1-40 +- fix #2121699 - fstrim -av fails to trim root filesystem on Red Hat Coreos +- fix #2142496 - update upstream tests +- fix #2149394 - umount outputs inaccurate error message when umount() fails with EACCES +- fix #2159544 - lslogins "Password is locked" status changed in util-linux-2.32.1-38 +- fix #2160321 - [last] ut->ut_user is not null terminated + +* Fri Nov 11 2022 Karel Zak 2.32.1-39 - fix #2141969 - Add --cont-clock feature for libuuid and uuidd * Mon Aug 22 2022 Karel Zak 2.32.1-38