Update to psmisc-v23.7

OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=147
This commit is contained in:
Dr. Werner Fink 2024-05-27 12:03:39 +00:00 committed by Git OBS Bridge
parent d9e1d026ae
commit 92f45d0f13
8 changed files with 195 additions and 15 deletions

View File

@ -67,10 +67,10 @@ index 723cf02..3599fea 100644
+AC_CHECK_FUNC([name_to_handle_at],[
+ AC_DEFINE([HAS_NAME_TO_HANDLE_AT], [1], [System has name_to_handle_at(2) system call])])
+
AC_CHECK_HEADERS([sys/syscall.h])
AC_CHECK_DECLS([SYS_statx],
[has_syscall_statx="yes"],
@@ -105,9 +119,9 @@ AC_SUBST([TERMCAP_LIB])
[has_syscall_statx="no"],
@@ -112,9 +126,9 @@ AC_SUBST([TERMCAP_LIB])
dnl Checks for header files.
AC_HEADER_DIRENT
@ -482,7 +482,7 @@ index f2bd3e9..8e4c853 100644
- if (statn(filepath, STATX_INO, &st) != 0)
+ if (statn(filepath, STATX_INO, &st) != 0)
{
if (errno != ENOENT && errno != ENOTDIR)
if (errno != ENOENT && errno != ENOTDIR && errno != EACCES)
{
@@ -1651,6 +1784,9 @@ static void check_dir(
filepath, strerror(errno));
@ -1123,7 +1123,7 @@ index f2bd3e9..8e4c853 100644
/*
* Somehow the realpath(3) glibc function call, nevertheless
* it avoids lstat(2) system calls.
@@ -2215,6 +2774,52 @@ char *expandpath(
@@ -2211,6 +2770,52 @@ char *expandpath(
}
lnkbuf[n] = '\0'; /* Don't be fooled by readlink(2) */

View File

@ -0,0 +1,160 @@
From a146bfc359a4d4d96c438f3a0fa988c6a171d40d Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Wed, 13 Mar 2024 22:01:07 +1100
Subject: [PATCH] killall,pstree use clock_gettime not uptime
/proc/uptime can become a container uptime in LXC containers
but the process start time is still relative to the boot time.
This means things like "newer than" or "older than" will be incorrect
in some containers, using clock_gettime() fixes this as its always the
hosts boot time.
References:
https://bugs.debian.org/1066090
https://gitlab.com/procps-ng/procps/-/commit/b5e19c1730bcc68d553f44b5585704e3c92267bf#83c45d853acc8384452b404946e4a0c484b16a4e
Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
ChangeLog | 4 ++++
src/killall.c | 39 +++++++++++++++++++--------------------
src/pstree.c | 39 +++++++++++++++++++--------------------
3 files changed, 42 insertions(+), 40 deletions(-)
diff --git ChangeLog ChangeLog
index 15c5725..f4dcfd2 100644
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,7 @@
+Changes in NEXT
+===============
+ * killall,pstree: Use gettime instead of uptime Debian 1066090
+
Changes in 23.7
===============
* build-sys: Make disable-statx work
diff --git src/killall.c src/killall.c
index 81dcc4b..229e61c 100644
--- src/killall.c
+++ src/killall.c
@@ -45,6 +45,7 @@
#include <regex.h>
#include <ctype.h>
#include <assert.h>
+#include <time.h>
#ifdef WITH_SELINUX
#include <dlfcn.h>
@@ -132,30 +133,28 @@ ask (char *name, pid_t pid, const int signal)
/* Never should get here */
}
-static double
-uptime()
-{
- char * savelocale;
- char buf[2048];
- FILE* file;
- if (!(file=fopen( PROC_BASE "/uptime", "r"))) {
- fprintf(stderr, "killall: error opening uptime file\n");
- exit(1);
- }
- savelocale = setlocale(LC_NUMERIC,"C");
- if (fscanf(file, "%2047s", buf) == EOF) perror("uptime");
- fclose(file);
- setlocale(LC_NUMERIC,savelocale);
- return atof(buf);
-}
-/* process age from jiffies to seconds via uptime */
+/* process age from jiffies to seconds via uptime
+ * Cannot use /proc/uptime as this can change in containers
+ * but process start time does not
+ */
static double process_age(const unsigned long long jf)
{
+ struct timespec ts;
+ double sc_clk_tck;
double age;
- double sc_clk_tck = sysconf(_SC_CLK_TCK);
- assert(sc_clk_tck > 0);
- age = uptime() - jf / sc_clk_tck;
+
+ if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) {
+ perror("clock_gettime():");
+ exit(EXIT_FAILURE);
+ }
+
+ if ( (sc_clk_tck = sysconf(_SC_CLK_TCK)) < 0) {
+ perror("sysconf(CLK_TCK):");
+ exit(EXIT_FAILURE);
+ }
+
+ age = (ts.tv_sec + ts.tv_nsec * 1.0e-9) - jf / sc_clk_tck;
if (age < 0L)
return 0L;
return age;
diff --git src/pstree.c src/pstree.c
index 39265d1..2545e24 100644
--- src/pstree.c
+++ src/pstree.c
@@ -44,6 +44,7 @@
#include <sys/ioctl.h>
#include <limits.h>
#include <locale.h>
+#include <time.h>
#include "i18n.h"
#include "comm.h"
@@ -1028,30 +1029,28 @@ static void trim_tree_by_parent(PROC * current)
trim_tree_by_parent(parent);
}
-static double
-uptime()
-{
- char * savelocale;
- char buf[2048];
- FILE* file;
- if (!(file=fopen( PROC_BASE "/uptime", "r"))) {
- fprintf(stderr, "pstree: error opening uptime file\n");
- exit(1);
- }
- savelocale = setlocale(LC_NUMERIC,"C");
- if (fscanf(file, "%2047s", buf) == EOF) perror("uptime");
- fclose(file);
- setlocale(LC_NUMERIC,savelocale);
- return atof(buf);
-}
-/* process age from jiffies to seconds via uptime */
+/* process age from jiffies to seconds via uptime
+ * Cannot use /proc/uptime as this can change in containers
+ * but process start time does not
+ */
static double process_age(const unsigned long long jf)
{
+ struct timespec ts;
+ double sc_clk_tck;
double age;
- double sc_clk_tck = sysconf(_SC_CLK_TCK);
- assert(sc_clk_tck > 0);
- age = uptime() - jf / sc_clk_tck;
+
+ if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) {
+ perror("clock_gettime():");
+ exit(EXIT_FAILURE);
+ }
+
+ if ( (sc_clk_tck = sysconf(_SC_CLK_TCK)) < 0) {
+ perror("sysconf(CLK_TCK):");
+ exit(EXIT_FAILURE);
+ }
+
+ age = (ts.tv_sec + ts.tv_nsec * 1.0e-9) - jf / sc_clk_tck;
if (age < 0L)
return 0L;
return age;
--
2.35.3

View File

@ -4,7 +4,7 @@
--- src/pstree.c
+++ src/pstree.c 2022-12-13 07:46:58.243076344 +0000
@@ -79,6 +79,7 @@ extern const char *__progname;
@@ -81,6 +81,7 @@ extern const char *__progname;
#define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */
#define VT_BEG "\033(0\017" /* use graphic chars */
@ -12,7 +12,7 @@
#define VT_END "\033(B" /* back to normal char set */
#define VT_V "x" /* see UTF definitions above */
#define VT_VR "t"
@@ -578,6 +579,28 @@ static void out_scontext(const PROC *cur
@@ -594,6 +595,28 @@ static void out_scontext(const PROC *cur
out_string("'");
}
@ -41,7 +41,7 @@
static void out_newline(void)
{
if (last_char && cur_x == output_width)
@@ -817,11 +840,12 @@ dump_tree(PROC * current, int level, int
@@ -833,11 +856,12 @@ dump_tree(PROC * current, int level, int
for (lvl = 0; lvl < level; lvl++) {
for (i = width[lvl] + 1; i; i--)
out_char(' ');
@ -59,7 +59,7 @@
}
if (rep < 2)
@@ -931,7 +955,7 @@ dump_tree(PROC * current, int level, int
@@ -947,7 +971,7 @@ dump_tree(PROC * current, int level, int
}
width[level] = comm_len + cur_x - offset + add;
if (cur_x >= output_width && trunc) {
@ -68,7 +68,7 @@
out_string("+");
out_newline();
return;
@@ -955,7 +979,7 @@ dump_tree(PROC * current, int level, int
@@ -971,7 +995,7 @@ dump_tree(PROC * current, int level, int
}
}
if (first) {

BIN
psmisc-v23.6.tar.bz2 (Stored with Git LFS)

Binary file not shown.

View File

@ -5,7 +5,7 @@
--- configure.ac
+++ configure.ac 2022-12-13 07:57:11.751636898 +0000
@@ -162,7 +162,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
@@ -169,7 +169,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
struct user_regs_struct.rdi,
struct user_regs_struct.rsi,
struct user_regs_struct.rdx], [],[],

3
psmisc-v23.7.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c4b1df2e671e8194f6c3063e43cb9afa26cbe9859f1026ff6ad258ac562804f4
size 268418

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Mon May 27 11:55:43 UTC 2024 - Dr. Werner Fink <werner@suse.de>
- Update to 23.7
* build-sys: Make disable-statx work
* fuser: Fallback to stat() if no statx() Debian 1030747 #48
* fuser: silently ignore EACCES when scanning proc directories
* killall: small formatting fixes Debian #1037231
* pstree: Do not assume root PID #49
* pslog: include config.h #51 !36
* misc: Update gettext to 0.21
- Add patch from upstream 0001-killall,pstree-use-clock_gettime-not-uptime.patch
- Port the patches
* 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
* psmisc-22.21-pstree.patch
- Port patch psmisc-v23.6.dif and rename it to psmisc-v23.7.dif
-------------------------------------------------------------------
Thu Feb 29 15:01:09 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -1,7 +1,7 @@
#
# spec file for package psmisc
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -25,6 +25,7 @@ BuildRequires: dejagnu
BuildRequires: gcc-c++
BuildRequires: gettext-devel
BuildRequires: glibc-devel
BuildRequires: glibc-gconv-modules-extra
BuildRequires: libselinux-devel
BuildRequires: linux-glibc-devel >= 4.12
BuildRequires: ncurses-devel
@ -33,7 +34,7 @@ BuildRequires: netcat-openbsd
BuildRequires: pkgconfig(libapparmor)
%endif
URL: https://gitlab.com/psmisc/psmisc/
Version: 23.6
Version: 23.7
Release: 0
Provides: ps:/usr/bin/killall
Summary: Utilities for managing processes on your system
@ -41,6 +42,7 @@ License: GPL-2.0-or-later
Group: System/Monitoring
Source: https://gitlab.com/%{name}/%{name}/-/archive/v%{version}/%{name}-v%{version}.tar.bz2
Patch0: %{name}-v%{version}.dif
Patch1: 0001-killall,pstree-use-clock_gettime-not-uptime.patch
Patch2: %{name}-22.21-pstree.patch
# PATCH-ADD-SUSE boo#908068, boo#1046237, boo#1046237
# https://gitlab.com/bitstreamout/psmisc/tree/mountinfo
@ -60,6 +62,7 @@ processes that are using specified files or filesystems.
%prep
%setup -q -n %{name}-v%{version}
%patch -P 1 -p0 -b .uptime
%patch -P 2 -p0 -b .pstree
%patch -P 3 -p0 -b .mntinf
%patch -P 0 -p0 -b .p0