Update to psmisc-v23.6

OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=141
This commit is contained in:
Dr. Werner Fink 2022-12-13 08:15:06 +00:00 committed by Git OBS Bridge
parent 14915a367d
commit e3f42a6aa5
9 changed files with 1068 additions and 2264 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
---
src/pstree.c | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
src/pstree.c | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
--- src/pstree.c
+++ src/pstree.c 2022-01-20 13:27:44.175949055 +0000
@@ -72,6 +72,7 @@ extern const char *__progname;
+++ src/pstree.c 2022-12-13 07:46:58.243076344 +0000
@@ -79,6 +79,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,8 +12,8 @@
#define VT_END "\033(B" /* back to normal char set */
#define VT_V "x" /* see UTF definitions above */
#define VT_VR "t"
@@ -522,6 +523,27 @@ static void out_scontext(const PROC *cur
}
@@ -578,6 +579,28 @@ static void out_scontext(const PROC *cur
out_string("'");
}
+/*
@ -36,11 +36,12 @@
+ putchar (*str++);
+ }
+}
+
+
static void out_newline(void)
{
if (last_char && cur_x == output_width)
@@ -761,11 +783,12 @@ dump_tree(PROC * current, int level, int
@@ -817,11 +840,12 @@ dump_tree(PROC * current, int level, int
for (lvl = 0; lvl < level; lvl++) {
for (i = width[lvl] + 1; i; i--)
out_char(' ');
@ -58,7 +59,7 @@
}
if (rep < 2)
@@ -875,7 +898,7 @@ dump_tree(PROC * current, int level, int
@@ -931,7 +955,7 @@ dump_tree(PROC * current, int level, int
}
width[level] = comm_len + cur_x - offset + add;
if (cur_x >= output_width && trunc) {
@ -67,7 +68,7 @@
out_string("+");
out_newline();
return;
@@ -899,7 +922,7 @@ dump_tree(PROC * current, int level, int
@@ -955,7 +979,7 @@ dump_tree(PROC * current, int level, int
}
}
if (first) {

View File

@ -1,51 +0,0 @@
---
configure.ac | 2 +-
src/fuser.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
--- configure.ac
+++ configure.ac 2021-01-14 11:31:31.640709812 +0000
@@ -145,7 +145,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
struct user_regs_struct.rdi,
struct user_regs_struct.rsi,
struct user_regs_struct.rdx], [],[],
- [#include <bits/types.h>
+ [#include <sys/types.h>
#include <sys/user.h>])
AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3,
struct pt_regs.gpr], [],[], [#include <linux/ptrace.h>])
--- src/fuser.c
+++ src/fuser.c 2021-01-14 11:31:31.640709812 +0000
@@ -1153,6 +1153,7 @@ int main(int argc, char *argv[])
struct option *optr;
char *nsptr;
int skip_argv;
+ int seen_file;
struct option options[] = {
{"all", 0, NULL, 'a'},
@@ -1196,6 +1197,7 @@ int main(int argc, char *argv[])
#endif
atexit(atexit_free_lists);
+ seen_file = 0;
for (argc_cnt = 1; argc_cnt < argc; argc_cnt++) {
current_argv = argv[argc_cnt];
if (current_argv[0] == '-') { /* its an option */
@@ -1340,6 +1342,7 @@ int main(int argc, char *argv[])
}
}
this_name->matched_procs = NULL;
+ seen_file = 1;
if (opts & (OPT_MOUNTS | OPT_ISMOUNTPOINT)
&& this_name->name_space != NAMESPACE_FILE) {
free(this_name);
@@ -1393,7 +1396,7 @@ int main(int argc, char *argv[])
names_tail->next = this_name;
names_tail = this_name;
} /* for across the argvs */
- if (names_head == NULL)
+ if (names_head == NULL && !seen_file)
usage(_("No process specification given"));
/* Check if -M flag was used and if so check mounts */

51
psmisc-v23.6.dif Normal file
View File

@ -0,0 +1,51 @@
---
configure.ac | 2 +-
src/fuser.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
--- configure.ac
+++ configure.ac 2022-12-13 07:57:11.751636898 +0000
@@ -162,7 +162,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
struct user_regs_struct.rdi,
struct user_regs_struct.rsi,
struct user_regs_struct.rdx], [],[],
- [#include <bits/types.h>
+ [#include <sys/types.h>
#include <sys/user.h>])
AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3,
struct pt_regs.gpr], [],[], [#include <linux/ptrace.h>])
--- src/fuser.c
+++ src/fuser.c 2022-12-13 07:59:50.896670010 +0000
@@ -1223,6 +1223,7 @@ int main(int argc, char *argv[])
struct option *optr;
char *nsptr;
int skip_argv;
+ int seen_file;
struct option options[] = {
{"all", 0, NULL, 'a'},
@@ -1266,6 +1267,7 @@ int main(int argc, char *argv[])
#endif
atexit(atexit_free_lists);
+ seen_file = 0;
for (argc_cnt = 1; argc_cnt < argc; argc_cnt++)
{
current_argv = argv[argc_cnt];
@@ -1416,6 +1418,7 @@ int main(int argc, char *argv[])
}
}
this_name->matched_procs = NULL;
+ seen_file = 1;
if (opts & (OPT_MOUNTS | OPT_ISMOUNTPOINT)
&& this_name->name_space != NAMESPACE_FILE)
{
@@ -1467,7 +1470,7 @@ int main(int argc, char *argv[])
names_tail->next = this_name;
names_tail = this_name;
} /* for across the argvs */
- if (names_head == NULL)
+ if (names_head == NULL && !seen_file)
usage(_("No process specification given"));
/* Check if -M flag was used and if so check mounts */

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

Binary file not shown.

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Tue Dec 13 08:01:33 UTC 2022 - Dr. Werner Fink <werner@suse.de>
- Update to 23.6:
* buildsys: Fix DEJAGNU work-around Debian #1015089
* killall: Use kill if pidfd_send_signal fails Debian #1015228
* fuser: Do not mention nonexistent - reset option #42
* fuser: Use modern statn where possible
* pstree: Better AppArmor support !30
* killall: Check truncated names !28
* killall: Use openat and pidfd_send_signal #37
* killall: Don't check paths of sockets #35
* pstree: Check for process with show_parents #38
* pstree: Don't disable compaction with show pgids #34
* pstree: Fix storage leak !29
- Enable new apparmor support
- Remove patch now upstream
0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
- Port patch psmisc-22.21-pstree.patch
- Port patch psmisc-v23.4.dif which now becomes psmisc-v23.6.dif
- Merge patch socket-fix.patch with ported patch
0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
-------------------------------------------------------------------
Fri Nov 25 11:48:39 UTC 2022 - Dr. Werner Fink <werner@suse.de>

View File

@ -27,8 +27,9 @@ BuildRequires: libselinux-devel
BuildRequires: linux-glibc-devel >= 4.12
BuildRequires: ncurses-devel
BuildRequires: netcat-openbsd
BuildRequires: pkgconfig(libapparmor)
URL: https://gitlab.com/psmisc/psmisc/
Version: 23.4
Version: 23.6
Release: 0
Provides: ps:/usr/bin/killall
Summary: Utilities for managing processes on your system
@ -40,8 +41,6 @@ Patch2: %{name}-22.21-pstree.patch
# PATCH-ADD-SUSE boo#908068, boo#1046237, boo#1046237
# https://gitlab.com/bitstreamout/psmisc/tree/mountinfo
Patch3: 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
Patch4: 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
Patch5: socket-fix.patch
%define have_peekfd %ix86 x86_64 ppc ppc64 ppc64le %arm mipsel m68k aarch64
@ -59,8 +58,6 @@ processes that are using specified files or filesystems.
%setup -q -n %{name}-v%{version}
%patch2 -p0 -b .pstree
%patch3 -p0 -b .mntinf
%patch4 -p0 -b .statx
%patch5 -p0 -b .sk
%patch0 -p0 -b .p0
%build

View File

@ -1,183 +0,0 @@
---
src/fuser.c | 93 +++++++++++++++++++++++++++++++---------------
src/fuser.h | 1
testsuite/config/unix.exp | 19 +++++++++
3 files changed, 83 insertions(+), 30 deletions(-)
--- src/fuser.c
+++ src/fuser.c 2022-11-25 11:42:29.019144216 +0000
@@ -1741,8 +1741,9 @@ check_dir(const pid_t pid, const char *d
continue;
}
- /* check the paths match if it is not a block device */
- if (! S_ISBLK(dev_tmp->name->st.st_mode)) {
+ /* check the paths match if it is not a block device or socket */
+ if (! S_ISBLK(dev_tmp->name->st.st_mode)
+ & !S_ISSOCK(st.st_mode)) {
if (readlink(filepath, real_filepath, PATH_MAX-1) < 0) {
if (strncmp(dev_tmp->name->filename, filepath, strlen(dev_tmp->name->filename)) != 0)
continue;
@@ -1750,13 +1751,14 @@ check_dir(const pid_t pid, const char *d
if (strncmp(dev_tmp->name->filename, real_filepath, strlen(dev_tmp->name->filename)) != 0)
continue;
}
- }
- if (fdret != 0)
+ if (fdret != 0)
continue;
- if (fd.mnt_id != dev_tmp->mnt_id)
+ if (fd.mnt_id != dev_tmp->mnt_id)
continue;
+ }
+
if (access == ACCESS_FILE
&& (fd.flags & (O_WRONLY|O_RDWR))) {
add_matched_proc(dev_tmp->name,
@@ -2310,22 +2312,12 @@ get_fdinfo(const pid_t pid, const char *
char line[BUFSIZ];
FILE *fp;
# if defined(HAS_NAME_TO_HANDLE_AT)
- static ino_t mynamespace;
- struct stat st;
-
- if (!mynamespace) {
- if (statn("/proc/self/ns/mnt", STATX_INO, &st) != 0) {
- fprintf(stderr, _("Cannot stat %s: %s\n"),
- "/proc/self/ns/mnt", strerror(errno));
- exit(1);
- }
- mynamespace = st.st_ino;
- }
+ char *realname;
# endif
snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fdinfo/%s", pid, fd);
if ((fp = fopen(pathname, "r")) == NULL)
goto out; /* forbidden namesspace, try our own namespace */
- while (fgets(line, BUFSIZ, fp) && ret < 2) {
+ while (fgets(line, BUFSIZ, fp) && ret < 1) {
char *xp, *vp, *ep;
unsigned long ul;
xp = strtok(&line[0], delimiters);
@@ -2338,24 +2330,18 @@ get_fdinfo(const pid_t pid, const char *
info->flags = (mode_t)ul;
flags++;
ret++;
- }
- if (strcmp(xp, "mnt_id") == 0 && (ul = strtoul(vp, &ep, 0)) != ULONG_MAX && ep && *ep == 0) {
- info->mnt_id = (int)ul;
- mnt_id++;
- ret++;
+ break;
}
}
fclose(fp);
out:
# if defined(HAS_NAME_TO_HANDLE_AT)
- if (mynamespace != ns) {
- char *realname;
- snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, fd);
- realname = expandpath(pathname);
- if (realname) { /* Use our namespace for mount ID <sigh> */
- info->mnt_id = get_mountid(realname);
- mnt_id++;
- }
+ snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, fd);
+ realname = expandpath(pathname);
+ if (realname) { /* Use our namespace for mount ID <sigh> */
+ info->mnt_id = get_mountid(realname);
+ mnt_id++;
+ ret++;
}
# endif
#endif
@@ -2625,6 +2611,53 @@ char *expandpath(const char *path)
}
lnkbuf[n] = '\0'; /* Don't be fooled by readlink(2) */
+ /*
+ * Expand to real path of named socket if any
+ */
+ if (lnkbuf[0] != '/' && strncmp("socket:[", lnkbuf, 8) == 0)
+ {
+ FILE *fp;
+ char *inode;
+ char line[BUFSIZ];
+ if ((inode = strchr(&lnkbuf[8], ']')))
+ {
+ *inode = '\0';
+ inode = &lnkbuf[8];
+ }
+
+ if (!inode || (fp = fopen(PROC_SOCKETS, "r")) == NULL)
+ {
+ /*fprintf(stderr, "Cannot open %s\n", PROC_SOCKETS); */
+ return (char *)0;
+ }
+ while (fgets(line, BUFSIZ, fp) != NULL)
+ {
+ char *named = NULL;
+ unsigned long snode;
+
+ if (*line == 'N')
+ continue;
+
+ if (sscanf(line, "%*x: %*x %*x %*x %*x %*x %lu %ms",
+ &snode, &named) == 2)
+ {
+ char *ep;
+ unsigned long oul = strtoul(inode, &ep, 0);
+ if (oul == snode) {
+ ep = named;
+ if (*ep == '@')
+ ep++;
+ n = strlen(ep);
+ memcpy(lnkbuf, ep, n);
+ lnkbuf[n] = '\0';
+ }
+ free (named);
+ }
+ }
+ fclose(fp);
+ }
+
+
len = strlen(end);
if ((n + len) > PATH_MAX) {
errno = ENAMETOOLONG;
--- src/fuser.h
+++ src/fuser.h 2022-11-25 11:26:23.523783208 +0000
@@ -124,5 +124,6 @@ typedef struct mntinfo_s {
#define KNFSD_EXPORTS "/proc/fs/nfs/exports"
#define PROC_MOUNTINFO "/proc/self/mountinfo"
+#define PROC_SOCKETS "/proc/self/net/unix"
#define PROC_MOUNTS "/proc/mounts"
#define PROC_SWAPS "/proc/swaps"
--- testsuite/config/unix.exp
+++ testsuite/config/unix.exp 2022-11-25 10:07:30.595008557 +0000
@@ -29,3 +29,22 @@ proc expect_nothing { test } {
eof { pass "$test" }
}
}
+
+proc kill_process pid {
+ set cmdline "kill $pid"
+ if { [catch { exec /bin/sh -c $cmdline } msg]} {
+ warning "Could not kill process: $msg\n"
+ }
+}
+
+proc make_socketproc { sktpath } {
+ global topdir socketproc_pid socketproc_spawnid testsocket_path
+
+ set testproc_realpath "nc"
+ set socketproc_pid [ spawn $testproc_realpath -lU $sktpath ]
+}
+
+proc kill_socketproc { } {
+ global socketproc_pid
+ kill_process $socketproc_pid
+}