Accepting request 863141 from Base:System

- Now with 23.3 peekfd is build even for aarch64 

- Rework 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
  and split off the patch psmisc-v23.3-selinux.patch 
- Rework 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
- New patch psmisc-v23.3-selinux.patch
- Rename patch psmisc-v23.2.dif which is now psmisc-v23.3.dif

- Update to 23.3:
  * killall: check also truncated 16 char comm names Debian
  * fuser: Return early if have nulls
  * peekfd: Add support for ARM64
  * pstree: Add color by age
  * fuser: Use larger inode sizes
- Rebase 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
- Rebase 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
- Rebase psmisc-22.21-pstree.patch

OBS-URL: https://build.opensuse.org/request/show/863141
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/psmisc?expand=0&rev=76
This commit is contained in:
Dominique Leuenberger 2021-01-18 10:27:42 +00:00 committed by Git OBS Bridge
commit 4d191d2219
9 changed files with 236 additions and 661 deletions

View File

@ -1,6 +1,6 @@
From 63d402a35e29106828f59b0b5b42a277136460c0 Mon Sep 17 00:00:00 2001
From e5d42c39541c94c00d97ed490add24bc898ebe0a Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de>
Date: Mon, 27 Apr 2020 14:41:03 +0200
Date: Wed, 13 Jan 2021 11:59:24 +0100
Subject: [PATCH] Use mountinfo to be able to use the mount identity
which allows to distinguish different mounts with the
@ -18,28 +18,15 @@ Allow not unique mounts as well as not unique mountpoint
Signed-off-by: Werner Fink <werner@suse.de>
---
configure.ac | 18 +-
src/fuser.c | 638 ++++++++++++++++++++++-------
src/fuser.h | 27 +-
testsuite/Makefile.am | 3 +-
testsuite/killall.test/killall.exp | 4 +
5 files changed, 537 insertions(+), 153 deletions(-)
configure.ac | 15 +
src/fuser.c | 643 ++++++++++++++++++++++++++++++++++++++++++++--------------
src/fuser.h | 27 +-
src/timeout.c | 5
4 files changed, 530 insertions(+), 160 deletions(-)
diff --git configure.ac configure.ac
index 176a2fc..d8d3366 100644
--- configure.ac
+++ configure.ac
@@ -27,6 +27,9 @@ if test "$enable_selinux" = "yes"; then
AC_DEFINE([WITH_SELINUX], [1], [Use Security-Enhanced Linux features])
AC_CHECK_LIB([selinux], [getfilecon], [SELINUX_LIB=-lselinux], [
AC_MSG_ERROR([Cannot find selinux static library]) ])
+ echo 'set has_selinux 1' > testsuite/selinux.exp
+else
+ echo 'set has_selinux 0' > testsuite/selinux.exp
fi
AC_SUBST([SELINUX_LIB])
@@ -44,6 +47,19 @@ if test "$enable_timeout_stat" = "static"; then
+++ configure.ac 2021-01-14 11:14:51.192122696 +0000
@@ -44,6 +44,19 @@ if test "$enable_timeout_stat" = "static
fi
AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"])
@ -59,7 +46,7 @@ index 176a2fc..d8d3366 100644
# Use string search for network based file systems but only if the system
# has /proc/self/mountinfo
AC_SUBST([WITH_MOUNTINFO_LIST])
@@ -85,7 +101,7 @@ dnl Checks for header files.
@@ -85,7 +98,7 @@ dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
@ -68,10 +55,8 @@ index 176a2fc..d8d3366 100644
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
diff --git src/fuser.c src/fuser.c
index c44cee8..1b58374 100644
--- src/fuser.c
+++ src/fuser.c
+++ src/fuser.c 2021-01-14 11:22:51.546798981 +0000
@@ -32,6 +32,10 @@
#include <stdlib.h>
#include <string.h>
@ -83,7 +68,7 @@ index c44cee8..1b58374 100644
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -79,7 +83,7 @@ static void check_map(const pid_t pid, const char *filename,
@@ -79,7 +83,7 @@ static void check_map(const pid_t pid, c
struct device_list *dev_head,
struct inode_list *ino_head, const uid_t uid,
const char access);
@ -92,7 +77,7 @@ index c44cee8..1b58374 100644
static uid_t getpiduid(const pid_t pid);
static int print_matches(struct names *names_head, const opt_type opts,
const int sig_number);
@@ -88,9 +92,9 @@ static int kill_matched_proc(struct procs *pptr, const opt_type opts,
@@ -88,9 +92,9 @@ static int kill_matched_proc(struct proc
/*int parse_mount(struct names *this_name, struct device_list **dev_list);*/
static void add_device(struct device_list **dev_list,
@ -105,7 +90,7 @@ index c44cee8..1b58374 100644
static void atexit_clear_unix_cache();
static dev_t find_net_dev(void);
static void scan_procs(struct names *names_head, struct inode_list *ino_head,
@@ -109,9 +113,12 @@ static void debug_match_lists(struct names *names_head,
@@ -109,9 +113,12 @@ static void debug_match_lists(struct nam
struct device_list *dev_head);
#endif
@ -119,7 +104,7 @@ index c44cee8..1b58374 100644
static int mntstat(const char *path, struct stat *buf);
#endif
static stat_t thestat = stat;
@@ -199,6 +206,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
@@ -202,6 +209,7 @@ scan_procs(struct names *names_head, str
struct stat *cwd_stat = NULL;
struct stat *exe_stat = NULL;
struct stat *root_stat = NULL;
@ -127,7 +112,7 @@ index c44cee8..1b58374 100644
if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */
continue;
@@ -208,9 +216,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
@@ -211,9 +219,9 @@ scan_procs(struct names *names_head, str
continue;
uid = getpiduid(pid);
@ -140,7 +125,7 @@ index c44cee8..1b58374 100644
cwd_dev = cwd_stat ? cwd_stat->st_dev : 0;
exe_dev = exe_stat ? exe_stat->st_dev : 0;
root_dev = root_stat ? root_stat->st_dev : 0;
@@ -218,21 +226,33 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
@@ -221,21 +229,33 @@ scan_procs(struct names *names_head, str
/* Scan the devices */
for (dev_tmp = dev_head; dev_tmp != NULL;
dev_tmp = dev_tmp->next) {
@ -184,7 +169,7 @@ index c44cee8..1b58374 100644
if (exe_stat
&& exe_stat->st_dev == ino_tmp->device
&& exe_stat->st_ino == ino_tmp->inode)
@@ -241,7 +261,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
@@ -244,7 +264,7 @@ scan_procs(struct names *names_head, str
}
if (root_dev == ino_tmp->device) {
if (!root_stat)
@ -193,7 +178,7 @@ index c44cee8..1b58374 100644
if (root_stat
&& root_stat->st_dev == ino_tmp->device
&& root_stat->st_ino == ino_tmp->inode)
@@ -250,7 +270,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
@@ -253,7 +273,7 @@ scan_procs(struct names *names_head, str
}
if (cwd_dev == ino_tmp->device) {
if (!cwd_stat)
@ -202,7 +187,7 @@ index c44cee8..1b58374 100644
if (cwd_stat
&& cwd_stat->st_dev == ino_tmp->device
&& cwd_stat->st_ino == ino_tmp->inode)
@@ -291,18 +311,42 @@ add_inode(struct inode_list **ino_list, struct names *this_name,
@@ -294,18 +314,42 @@ add_inode(struct inode_list **ino_list,
ino_tmp->name = this_name;
ino_tmp->device = device;
ino_tmp->inode = inode;
@ -246,7 +231,7 @@ index c44cee8..1b58374 100644
if ((dev_tmp =
(struct device_list *)malloc(sizeof(struct device_list))) == NULL)
@@ -310,6 +354,10 @@ add_device(struct device_list **dev_list, struct names *this_name, dev_t device)
@@ -313,6 +357,10 @@ add_device(struct device_list **dev_list
dev_head = *dev_list;
dev_tmp->name = this_name;
dev_tmp->device = device;
@ -257,7 +242,7 @@ index c44cee8..1b58374 100644
dev_tmp->next = dev_head;
*dev_list = dev_tmp;
}
@@ -451,13 +499,15 @@ add_special_proc(struct names *name_list, const char ptype, const uid_t uid,
@@ -454,13 +502,15 @@ add_special_proc(struct names *name_list
int parse_file(struct names *this_name, struct inode_list **ino_list,
const opt_type opts)
{
@ -274,7 +259,7 @@ index c44cee8..1b58374 100644
if (errno == ENOENT)
fprintf(stderr,
_("Specified filename %s does not exist.\n"),
@@ -467,10 +517,12 @@ int parse_file(struct names *this_name, struct inode_list **ino_list,
@@ -470,10 +520,12 @@ int parse_file(struct names *this_name,
this_name->filename, strerror(errno));
return -1;
}
@ -289,7 +274,7 @@ index c44cee8..1b58374 100644
#endif /* DEBUG */
add_inode(ino_list, this_name, this_name->st.st_dev,
this_name->st.st_ino);
@@ -502,12 +554,45 @@ parse_mounts(struct names *this_name, struct device_list **dev_list,
@@ -505,12 +557,45 @@ parse_mounts(struct names *this_name, st
const opt_type opts)
{
dev_t match_device;
@ -336,16 +321,7 @@ index c44cee8..1b58374 100644
return 0;
}
@@ -621,7 +706,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
fprintf(stderr, _("Unknown local port AF %d\n"),
res->ai_family);
freeaddrinfo(res);
- free(lcl_port_str);
+ free(lcl_port_str);
return -1;
}
freeaddrinfo(res);
@@ -684,10 +769,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
@@ -687,10 +772,12 @@ int parse_inet(struct names *this_name,
break;
#endif
}
@ -361,7 +337,7 @@ index c44cee8..1b58374 100644
}
return 1;
}
@@ -953,6 +1040,21 @@ free_inodes(struct inode_list **match_inodes)
@@ -957,6 +1044,21 @@ free_inodes(struct inode_list **match_in
/*
* Free up structures allocated in add_device
*/
@ -383,7 +359,7 @@ index c44cee8..1b58374 100644
static void
free_devices(struct device_list **match_devices)
{
@@ -960,6 +1062,8 @@ free_devices(struct device_list **match_devices)
@@ -964,6 +1066,8 @@ free_devices(struct device_list **match_
device_tmp = *match_devices;
while(device_tmp != NULL) {
@ -392,7 +368,7 @@ index c44cee8..1b58374 100644
device_next = device_tmp->next;
free(device_tmp);
device_tmp = device_next;
@@ -1162,16 +1266,11 @@ int main(int argc, char *argv[])
@@ -1166,16 +1270,11 @@ int main(int argc, char *argv[])
skip_argv = 1;
//while(option != '\0') option++;
if (strcmp(argv[argc_cnt], "tcp") == 0)
@ -414,7 +390,7 @@ index c44cee8..1b58374 100644
else
usage(_
("Invalid namespace name"));
@@ -1211,7 +1310,7 @@ int main(int argc, char *argv[])
@@ -1215,7 +1314,7 @@ int main(int argc, char *argv[])
}
#if defined(WITH_MOUNTINFO_LIST)
@ -423,7 +399,7 @@ index c44cee8..1b58374 100644
thestat = mntstat;
#endif
/* an option */
@@ -1525,7 +1624,7 @@ print_matches(struct names *names_head, const opt_type opts,
@@ -1529,7 +1628,7 @@ print_matches(struct names *names_head,
}
@ -432,7 +408,7 @@ index c44cee8..1b58374 100644
{
char pathname[256];
struct stat *st;
@@ -1537,6 +1636,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename)
@@ -1541,6 +1640,15 @@ static struct stat *get_pidstat(const pi
free(st);
return NULL;
}
@ -448,7 +424,7 @@ index c44cee8..1b58374 100644
return st;
}
@@ -1551,7 +1659,8 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1555,7 +1663,8 @@ check_dir(const pid_t pid, const char *d
struct inode_list *ino_tmp;
struct device_list *dev_tmp;
struct unixsocket_list *sock_tmp;
@ -458,7 +434,7 @@ index c44cee8..1b58374 100644
char *dirpath;
char filepath[PATH_MAX];
@@ -1590,11 +1699,27 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1594,11 +1703,29 @@ check_dir(const pid_t pid, const char *d
}
for (dev_tmp = dev_head; dev_tmp != NULL;
dev_tmp = dev_tmp->next) {
@ -466,6 +442,7 @@ index c44cee8..1b58374 100644
+ if (thedev != dev_tmp->device) {
+ struct subvol *vol_tmp;
+ int found = 0;
+
+ for (vol_tmp = dev_tmp->vol; vol_tmp != NULL;
+ vol_tmp = vol_tmp->next) {
+ /* Check for BtrFS sub volumes as well */
@ -474,10 +451,11 @@ index c44cee8..1b58374 100644
+ break;
+ }
+ }
+
+
+ if (!found)
+ continue;
+ }
+
+ if (get_fdinfo(pid, direntry->d_name, &fd) != 0)
+ continue;
+ if (fd.mnt_id != dev_tmp->mnt_id)
@ -489,7 +467,7 @@ index c44cee8..1b58374 100644
add_matched_proc(dev_tmp->name,
pid, uid,
ACCESS_FILEWR |
@@ -1616,9 +1741,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1620,9 +1747,10 @@ check_dir(const pid_t pid, const char *d
continue;
}
if (st.st_ino == ino_tmp->inode) {
@ -502,7 +480,7 @@ index c44cee8..1b58374 100644
add_matched_proc(ino_tmp->name,
pid, uid,
ACCESS_FILEWR |
@@ -1647,31 +1773,54 @@ check_map(const pid_t pid, const char *filename,
@@ -1651,31 +1779,54 @@ check_map(const pid_t pid, const char *f
FILE *fp;
unsigned long long tmp_inode;
unsigned int tmp_maj, tmp_min;
@ -567,7 +545,7 @@ index c44cee8..1b58374 100644
}
fclose(fp);
}
@@ -1695,6 +1844,7 @@ static uid_t getpiduid(const pid_t pid)
@@ -1699,6 +1850,7 @@ static uid_t getpiduid(const pid_t pid)
* fill_unix_cache : Create a list of Unix sockets
* This list is used later for matching purposes
*/
@ -575,16 +553,16 @@ index c44cee8..1b58374 100644
void fill_unix_cache(struct unixsocket_list **unixsocket_head)
{
FILE *fp;
@@ -1711,6 +1861,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
@@ -1715,6 +1867,8 @@ void fill_unix_cache(struct unixsocket_l
while (fgets(line, BUFSIZ, fp) != NULL) {
char *path;
char *scanned_path = NULL;
+ int mnt_id = -1;
+ mntinfo_t *mountinfo;
if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %ms",
if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %llu %ms",
&scanned_inode, &scanned_path) != 2) {
if (scanned_path)
@@ -1726,6 +1878,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
@@ -1730,6 +1884,8 @@ void fill_unix_cache(struct unixsocket_l
free(path);
continue;
}
@ -593,7 +571,7 @@ index c44cee8..1b58374 100644
if ((newsocket = (struct unixsocket_list *)
malloc(sizeof(struct unixsocket_list))) == NULL) {
free(path);
@@ -1734,6 +1888,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
@@ -1738,6 +1894,7 @@ void fill_unix_cache(struct unixsocket_l
newsocket->sun_name = strdup(scanned_path);
newsocket->inode = st.st_ino;
newsocket->dev = st.st_dev;
@ -601,7 +579,7 @@ index c44cee8..1b58374 100644
newsocket->net_inode = scanned_inode;
newsocket->next = *unixsocket_head;
*unixsocket_head = newsocket;
@@ -1746,6 +1901,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
@@ -1750,6 +1907,7 @@ void fill_unix_cache(struct unixsocket_l
/*
* Free up the list of Unix sockets
*/
@ -609,7 +587,7 @@ index c44cee8..1b58374 100644
void clear_unix_cache(struct unixsocket_list **unixsocket_head)
{
while(*unixsocket_head != NULL) {
@@ -1913,30 +2069,22 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
@@ -1921,34 +2079,21 @@ scan_mounts(struct names *names_head, st
{
struct device_list *dev_tmp;
struct inode_list *ino_tmp;
@ -618,6 +596,14 @@ index c44cee8..1b58374 100644
- char *find_mountp;
- char *find_space;
struct stat st;
+ list_t *ptr;
- if ( (ino_head == NULL) && (dev_head == NULL) )
- return;
-
+ list_for_each(ptr, &mntinfo) {
+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
+ const char *find_mountp = mnt->mpoint;
- if ((fp = fopen(PROC_MOUNTS, "r")) == NULL) {
- fprintf(stderr, "Cannot open %s\n", PROC_MOUNTS);
@ -631,12 +617,6 @@ index c44cee8..1b58374 100644
- continue;
- *find_space = '\0';
- if (timeout(thestat, find_mountp, &st, 5) != 0) {
+ list_t *ptr;
+
+ list_for_each(ptr, &mntinfo) {
+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
+ const char *find_mountp = mnt->mpoint;
+
+ if (timeout(thestat, find_mountp, &st, 5) != 0)
continue;
- }
@ -650,7 +630,7 @@ index c44cee8..1b58374 100644
add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0,
find_mountp);
}
@@ -1948,7 +2096,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
@@ -1960,7 +2105,6 @@ scan_mounts(struct names *names_head, st
find_mountp);
}
}
@ -658,7 +638,7 @@ index c44cee8..1b58374 100644
}
static void
@@ -1998,16 +2145,44 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
@@ -2013,16 +2157,44 @@ scan_swaps(struct names *names_head, str
fclose(fp);
}
@ -707,7 +687,7 @@ index c44cee8..1b58374 100644
{
list_t *ptr, *tmp;
@@ -2018,72 +2193,247 @@ static void clear_mntinfo(void)
@@ -2033,72 +2205,247 @@ static void clear_mntinfo(void)
}
}
@ -746,6 +726,16 @@ index c44cee8..1b58374 100644
- ("Cannot allocate memory for matched proc: %s\n"),
- strerror(errno));
- exit(1);
- }
- append(mnt, mntinfo);
- mnt->mpoint = ((char *)mnt) + alignof(mntinfo_t);
- strcpy(mnt->mpoint, mpoint);
- mnt->nlen = nlen;
- mnt->parid = parid;
- mnt->dev = makedev(maj, min);
- mnt->id = mid;
- if (mid > max)
- max = mid;
+ (mnt, "%i %i %u:%u %*s %s %*[^-] - %s %s %*[^\n]",
+ &mid, &parid, &maj, &min, &mpoint[0], &type[0], &devname[0]) == 7) {
+ struct stat st;
@ -768,7 +758,7 @@ index c44cee8..1b58374 100644
+ if (stat(mpoint, &st) != 0) {
+ if (errno != EACCES) {
+ fprintf(stderr, _("Cannot stat %s: %s\n"),
+ mnt->mpoint, strerror(errno));
+ mpoint, strerror(errno));
+ exit(1);
+ }
+ st.st_dev = (dev_t)-1;
@ -777,36 +767,22 @@ index c44cee8..1b58374 100644
+ if (mntinf && strncmp(devname, "/dev/", 5) == 0 && stat(devname, &st) == 0) {
+ if (st.st_rdev != 0 && mntinf->dev != st.st_rdev)
+ mntinf->vol = st.st_rdev;
}
- append(mnt, mntinfo);
- mnt->mpoint = ((char *)mnt) + alignof(mntinfo_t);
- strcpy(mnt->mpoint, mpoint);
- mnt->nlen = nlen;
- mnt->parid = parid;
- mnt->dev = makedev(maj, min);
- mnt->id = mid;
- if (mid > max)
- max = mid;
+ }
}
+#endif
fclose(mnt);
+}
- /* Sort mount points accordingly to the reverse mount order */
- initial(&sort);
- for (mid = 1; mid <= max; mid++) {
- list_t *ptr, *tmp;
- list_for_each_safe(ptr, tmp, &mntinfo) {
+
+static int
+get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info)
+{
+ int ret = 0;
+ char pathname[256];
+ int mnt_id = 0, flags = 0;
+#if defined(HAS_FDINFO)
+ const static char delimiters[] = ": \t\n";
+ char line[BUFSIZ];
+ FILE *fp;
+ int mnt_id = 0, flags = 0;
+
+ snprintf(pathname, 256, "/proc/%d/fdinfo/%s", pid, fd);
+ if ((fp = fopen(pathname, "r")) == NULL)
@ -886,7 +862,12 @@ index c44cee8..1b58374 100644
+ int ret = -1;
+
+ *mountinfo = NULL;
+
- /* Sort mount points accordingly to the reverse mount order */
- initial(&sort);
- for (mid = 1; mid <= max; mid++) {
- list_t *ptr, *tmp;
- list_for_each_safe(ptr, tmp, &mntinfo) {
+#if defined(HAS_NAME_TO_HANDLE_AT)
+ if (mnt_id >= 0) {
+ list_t *ptr;
@ -999,7 +980,7 @@ index c44cee8..1b58374 100644
/*
* Determine device of links below /proc/
*/
@@ -2091,8 +2441,7 @@ static int mntstat(const char *path, struct stat *buf)
@@ -2106,8 +2453,7 @@ static int mntstat(const char *path, str
{
char name[PATH_MAX + 1];
const char *use;
@ -1009,7 +990,7 @@ index c44cee8..1b58374 100644
if ((use = realpath(path, name)) == NULL || *use != '/')
{
@@ -2104,27 +2453,26 @@ static int mntstat(const char *path, struct stat *buf)
@@ -2119,27 +2465,26 @@ static int mntstat(const char *path, str
errno = 0;
return stat(path, buf);
}
@ -1055,17 +1036,15 @@ index c44cee8..1b58374 100644
}
#endif /* WITH_MOUNTINFO_LIST */
diff --git src/fuser.h src/fuser.h
index 93020d5..ca20081 100644
--- src/fuser.h
+++ src/fuser.h
+++ src/fuser.h 2021-01-14 11:16:13.262529434 +0000
@@ -37,10 +37,16 @@ struct procs {
#define PTYPE_KNFSD 2
#define PTYPE_SWAP 3
+struct fdinfo {
+ mode_t flags;
+ int mnt_id;
+ mode_t flags;
+ int mnt_id;
+};
+
struct names {
@ -1136,41 +1115,24 @@ index 93020d5..ca20081 100644
+#define PROC_MOUNTINFO "/proc/self/mountinfo"
#define PROC_MOUNTS "/proc/mounts"
#define PROC_SWAPS "/proc/swaps"
diff --git testsuite/Makefile.am testsuite/Makefile.am
index 696a44a..739237e 100644
--- testsuite/Makefile.am
+++ testsuite/Makefile.am
@@ -1,6 +1,8 @@
AUTOMAKE_OPTIONS = dejagnu
export DEJAGNU
--- src/timeout.c
+++ src/timeout.c 2021-01-14 11:14:51.196122619 +0000
@@ -67,9 +67,6 @@
# ifndef constructor
# define constructor __constructor__
# endif
-# ifndef packed
-# define packed __packed__
-# endif
# ifndef inline
# define inline __inline__
# endif
@@ -107,7 +104,7 @@ typedef struct _handle {
stat_t function;
size_t len;
char path[0];
-} attribute((packed)) handle_t;
+} handle_t;
+EXTRA_DEJAGNU_SITE_CONFIG=$(srcdir)/selinux.exp
+
# Programs that are expected across the board.
DEJATOOL = killall
DEJATOOL += pslog
@@ -9,5 +11,4 @@ if WANT_FUSER
DEJATOOL += fuser
endif
-
EXTRA_DIST =
diff --git testsuite/killall.test/killall.exp testsuite/killall.test/killall.exp
index 8bb3889..a345582 100644
--- testsuite/killall.test/killall.exp
+++ testsuite/killall.test/killall.exp
@@ -7,7 +7,11 @@ set fake_proc_name "afakeprocname"
set test "killall with no arguments"
spawn $killall
+if { $has_selinux == 0 } {
expect_pass "$test" "^Usage: killall \\\[OPTION\\\]\\.\\.\\. \\\[--\\\] NAME\\.\\.\\."
+} else {
+expect_pass "$test" "^Usage: killall \\\[ -Z CONTEXT \\\] \\\[ -u USER \\\] \\\[ -y TIME \\\] \\\[ -o TIME \\\] \\\[ -eIgiqrvw \\\]"
+}
set test "killall list signals"
spawn $killall -l
--
2.25.0
/*
* Using a forked process for doing e.g. stat(2) system call as this

View File

@ -1,28 +1,20 @@
From 59144ef25a4bf0ecceb27e1c2dd2276de54555fe Mon Sep 17 00:00:00 2001
From 9f3910df62bcc1f726b8e84f9ffc40c4d7916eac Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de>
Date: Mon, 27 Apr 2020 16:44:17 +0200
Date: Thu, 14 Jan 2021 11:37:46 +0100
Subject: [PATCH] Use new statx(2) system call to avoid hangs on NFS
Signed-off-by: Werner Fink <werner@suse.de>
---
Makefile.am | 4 +-
configure.ac | 38 ++----
src/fuser.c | 98 ++++---------
src/statx.c | 149 ++++++++++++++++++++
src/statx.h | 68 +++++++++
src/timeout.c | 372 --------------------------------------------------
src/timeout.h | 45 ------
7 files changed, 258 insertions(+), 516 deletions(-)
create mode 100644 src/statx.c
create mode 100644 src/statx.h
delete mode 100644 src/timeout.c
delete mode 100644 src/timeout.h
Makefile.am | 4 -
configure.ac | 38 +++++----------
src/fuser.c | 98 +++++++++-----------------------------
src/statx.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/statx.h | 68 ++++++++++++++++++++++++++
5 files changed, 258 insertions(+), 99 deletions(-)
diff --git Makefile.am Makefile.am
index d8c4619..a76799c 100644
--- Makefile.am
+++ Makefile.am
@@ -58,8 +58,8 @@ src_fuser_SOURCES = \
+++ Makefile.am 2021-01-14 11:29:22.011223930 +0000
@@ -64,8 +64,8 @@ src_fuser_SOURCES = \
src/fuser.h \
src/lists.h
@ -33,11 +25,9 @@ index d8c4619..a76799c 100644
endif
src_fuser_LDADD = @LIBINTL@
src_killall_SOURCES = src/killall.c src/comm.h src/signals.c src/signals.h src/i18n.h
diff --git configure.ac configure.ac
index d8d3366..81d3674 100644
--- configure.ac
+++ configure.ac
@@ -33,20 +33,6 @@ else
+++ configure.ac 2021-01-14 11:29:22.011223930 +0000
@@ -30,20 +30,6 @@ if test "$enable_selinux" = "yes"; then
fi
AC_SUBST([SELINUX_LIB])
@ -58,7 +48,7 @@ index d8d3366..81d3674 100644
# Use /proc/self/mountinfo if available
if test -e /proc/self/mountinfo ; then
AC_DEFINE([HAS_MOUNTINFO], [1], [System has /proc/self/mountinfo which can used instead /proc(/self)/mounts])
@@ -60,16 +46,20 @@ fi
@@ -57,16 +43,20 @@ fi
AC_CHECK_FUNC([name_to_handle_at],[
AC_DEFINE([HAS_NAME_TO_HANDLE_AT], [1], [System has name_to_handle_at(2) system call])])
@ -89,10 +79,8 @@ index d8d3366..81d3674 100644
# Enable hardened compile and link flags
AC_ARG_ENABLE([harden_flags],
diff --git src/fuser.c src/fuser.c
index 1b58374..fc98790 100644
--- src/fuser.c
+++ src/fuser.c
+++ src/fuser.c 2021-01-14 11:30:10.750278604 +0000
@@ -63,7 +63,7 @@
#include "fuser.h"
#include "signals.h"
@ -102,7 +90,7 @@ index 1b58374..fc98790 100644
#include "comm.h"
//#define DEBUG 1
@@ -118,10 +118,6 @@ static void clear_mntinfo(void) __attribute__ ((__destructor__));
@@ -118,10 +118,6 @@ static void clear_mntinfo(void) __attrib
static void init_mntinfo(void) __attribute__ ((__constructor__));
static int get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info);
static int find_mountpoint(const char *path, mntinfo_t **mountinfo);
@ -113,16 +101,16 @@ index 1b58374..fc98790 100644
static char *expandpath(const char *path);
static struct unixsocket_list *unixsockets = NULL;
static struct names *names_head = NULL, *names_tail = NULL;
@@ -506,7 +502,7 @@ int parse_file(struct names *this_name, struct inode_list **ino_list,
@@ -509,7 +505,7 @@ int parse_file(struct names *this_name,
free(this_name->filename);
this_name->filename = strdup(new);
}
- if (timeout(thestat, this_name->filename, &(this_name->st), 5) != 0 ||
+ if (statn(this_name->filename, STATX_INO, &(this_name->st)) != 0 ||
+ if (statn(this_name->filename, STATX_INO|STATX_TYPE, &(this_name->st)) != 0 ||
find_mountpoint(this_name->filename, &mountinfo) != 0) {
if (errno == ENOENT)
fprintf(stderr,
@@ -1241,9 +1237,7 @@ int main(int argc, char *argv[])
@@ -1245,9 +1241,7 @@ int main(int argc, char *argv[])
opts |= OPT_INTERACTIVE;
break;
case 'I':
@ -132,7 +120,7 @@ index 1b58374..fc98790 100644
break;
case 'k':
opts |= OPT_KILL;
@@ -1309,10 +1303,11 @@ int main(int argc, char *argv[])
@@ -1313,10 +1307,11 @@ int main(int argc, char *argv[])
continue;
}
@ -147,7 +135,7 @@ index 1b58374..fc98790 100644
/* an option */
/* Not an option, must be a file specification */
if ((this_name = malloc(sizeof(struct names))) == NULL)
@@ -1632,7 +1627,7 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id)
@@ -1636,7 +1631,7 @@ static struct stat *get_pidstat(const pi
if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL)
return NULL;
snprintf(pathname, 256, "/proc/%d/%s", pid, filename);
@ -156,7 +144,7 @@ index 1b58374..fc98790 100644
free(st);
return NULL;
}
@@ -1679,7 +1674,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1683,7 +1678,7 @@ check_dir(const pid_t pid, const char *d
snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s",
pid, dirname, direntry->d_name);
@ -165,7 +153,7 @@ index 1b58374..fc98790 100644
if (errno != ENOENT && errno != ENOTDIR) {
fprintf(stderr, _("Cannot stat file %s: %s\n"),
filepath, strerror(errno));
@@ -1734,7 +1729,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1740,7 +1735,7 @@ check_dir(const pid_t pid, const char *d
if (thedev != ino_tmp->device)
continue;
if (!st.st_ino
@ -174,7 +162,7 @@ index 1b58374..fc98790 100644
fprintf(stderr,
_("Cannot stat file %s: %s\n"),
filepath, strerror(errno));
@@ -1832,11 +1827,11 @@ static uid_t getpiduid(const pid_t pid)
@@ -1838,11 +1833,11 @@ static uid_t getpiduid(const pid_t pid)
if (asprintf(&pathname, "/proc/%d", pid) < 0)
return 0;
@ -190,7 +178,7 @@ index 1b58374..fc98790 100644
return st.st_uid;
}
@@ -1874,7 +1869,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
@@ -1880,7 +1875,7 @@ void fill_unix_cache(struct unixsocket_l
path = scanned_path;
if (*scanned_path == '@')
scanned_path++;
@ -199,7 +187,7 @@ index 1b58374..fc98790 100644
free(path);
continue;
}
@@ -2009,7 +2004,7 @@ static dev_t find_net_dev(void)
@@ -2015,7 +2010,7 @@ static dev_t find_net_dev(void)
fprintf(stderr, _("Cannot open a network socket.\n"));
return -1;
}
@ -208,7 +196,7 @@ index 1b58374..fc98790 100644
fprintf(stderr, _("Cannot find socket's device number.\n"));
close(skt);
return -1;
@@ -2042,7 +2037,7 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head,
@@ -2052,7 +2047,7 @@ scan_knfsd(struct names *names_head, str
if ((find_space = strpbrk(line, " \t")) == NULL)
continue;
*find_space = '\0';
@ -217,7 +205,7 @@ index 1b58374..fc98790 100644
continue;
}
/* Scan the devices */
@@ -2077,7 +2072,7 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
@@ -2086,7 +2081,7 @@ scan_mounts(struct names *names_head, st
mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
const char *find_mountp = mnt->mpoint;
@ -226,7 +214,7 @@ index 1b58374..fc98790 100644
continue;
/* Scan the devices */
@@ -2124,7 +2119,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
@@ -2136,7 +2131,7 @@ scan_swaps(struct names *names_head, str
if (*find_space == '\0')
continue;
}
@ -235,7 +223,7 @@ index 1b58374..fc98790 100644
continue;
}
/* Scan the devices */
@@ -2216,10 +2211,10 @@ init_mntinfo(void)
@@ -2228,10 +2223,10 @@ init_mntinfo(void)
&mid, &parid, &maj, &min, &mpoint[0], &type[0], &devname[0]) == 7) {
struct stat st;
mntinf = add_mntinfo(mpoint, type, mid, parid, makedev(maj, min));
@ -248,7 +236,7 @@ index 1b58374..fc98790 100644
mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */
}
}
@@ -2231,7 +2226,7 @@ init_mntinfo(void)
@@ -2243,7 +2238,7 @@ init_mntinfo(void)
parid = -1;
while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) {
struct stat st;
@ -256,8 +244,8 @@ index 1b58374..fc98790 100644
+ if (statn(mpoint, 0, &st) != 0) {
if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"),
mnt->mpoint, strerror(errno));
@@ -2240,7 +2235,7 @@ init_mntinfo(void)
mpoint, strerror(errno));
@@ -2252,7 +2247,7 @@ init_mntinfo(void)
st.st_dev = (dev_t)-1;
}
mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev);
@ -266,7 +254,7 @@ index 1b58374..fc98790 100644
if (st.st_rdev != 0 && mntinf->dev != st.st_rdev)
mntinf->vol = st.st_rdev;
}
@@ -2290,7 +2285,7 @@ out:
@@ -2302,7 +2297,7 @@ out:
struct stat lst;
snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
@ -275,7 +263,7 @@ index 1b58374..fc98790 100644
if (lst.st_mode & S_IWUSR)
info->flags |= O_WRONLY;
ret++;
@@ -2363,7 +2358,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
@@ -2375,7 +2370,7 @@ find_mountpoint(const char *path, mntinf
/* could be a chroot or a container */
@ -284,7 +272,7 @@ index 1b58374..fc98790 100644
if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"),
path, strerror(errno));
@@ -2395,7 +2390,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
@@ -2407,7 +2402,7 @@ find_mountpoint(const char *path, mntinf
/* could be a chroot or a container */
@ -293,7 +281,7 @@ index 1b58374..fc98790 100644
if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"),
use, strerror(errno));
@@ -2433,49 +2428,6 @@ out:
@@ -2445,49 +2440,6 @@ out:
return ret;
}
@ -343,11 +331,8 @@ index 1b58374..fc98790 100644
/*
* Somehow the realpath(3) glibc function call, nevertheless
* it avoids lstat(2) system calls.
diff --git src/statx.c src/statx.c
new file mode 100644
index 0000000..a598c89
--- /dev/null
+++ src/statx.c
--- src/statx.c
+++ src/statx.c 2021-01-14 11:29:22.015223853 +0000
@@ -0,0 +1,149 @@
+/*
+ * statx.c - Map modern statx(2) system call to older stat(2), lstat(2),
@ -498,11 +483,8 @@ index 0000000..a598c89
+ }
+ return ret;
+}
diff --git src/statx.h src/statx.h
new file mode 100644
index 0000000..fdd0137
--- /dev/null
+++ src/statx.h
--- src/statx.h
+++ src/statx.h 2021-01-14 11:29:22.019223776 +0000
@@ -0,0 +1,68 @@
+/*
+ * statx.h - Map modern statx(2) system call to older stat(2), lstat(2),
@ -572,435 +554,3 @@ index 0000000..fdd0137
+#define STATX_ALL 0
+#endif
+#endif
diff --git src/timeout.c src/timeout.c
deleted file mode 100644
index ca4a7cd..0000000
--- src/timeout.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * timout.c Advanced timeout handling for file system calls
- * to avoid deadlocks on remote file shares.
- *
- * Version: 0.2 11-Dec-2012 Fink
- *
- * Copyright 2011,2012 Werner Fink, 2011,2012 SUSE LINUX Products GmbH, Germany.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Author: Werner Fink <werner@suse.de>, 2011
- */
-
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
-#ifdef _FEATURES_H
-# error Include local config.h before any system header file
-#endif
-#include "config.h"
-
-#ifndef WITH_TIMEOUT_STAT
-# define WITH_TIMEOUT_STAT 0
-#endif
-
-#ifndef USE_SOCKETPAIR
-# define USE_SOCKETPAIR 1
-#endif
-
-#include <errno.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/select.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#if USE_SOCKETPAIR
-# include <sys/socket.h>
-# include <netdb.h>
-# include <netinet/in.h>
-# ifndef SHUT_RD
-# define SHUT_RD 0
-# endif
-# ifndef SHUT_WR
-# define SHUT_WR 1
-# endif
-# undef pipe
-# define pipe(v) (((socketpair(AF_UNIX,SOCK_STREAM,0,v) < 0) || \
- (shutdown((v)[1],SHUT_RD) < 0) || (shutdown((v)[0],SHUT_WR) < 0)) ? -1 : 0)
-#endif
-#include <wait.h>
-
-#include "timeout.h"
-
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
-# ifndef destructor
-# define destructor __destructor__
-# endif
-# ifndef constructor
-# define constructor __constructor__
-# endif
-# ifndef packed
-# define packed __packed__
-# endif
-# ifndef inline
-# define inline __inline__
-# endif
-# ifndef unused
-# define unused __unused__
-# endif
-# ifndef volatile
-# define volatile __volatile__
-# endif
-#endif
-#ifndef attribute
-# define attribute(attr) __attribute__(attr)
-#endif
-
-#if defined __GNUC__
-# undef strcpy
-# define strcpy(d,s) __builtin_strcpy((d),(s)) /* Without boundary check please */
-#endif
-
-#if WITH_TIMEOUT_STAT
-static sigjmp_buf jenv;
-static void sigjump(int sig attribute((unused)))
-{
- siglongjmp(jenv, 1);
-}
-#endif
-
-#if WITH_TIMEOUT_STAT == 2
-/*
- * The structure used for communication between the processes
- */
-typedef struct _handle {
- int errcode;
- struct stat argument;
- stat_t function;
- size_t len;
- char path[0];
-} attribute((packed)) handle_t;
-
-/*
- * Using a forked process for doing e.g. stat(2) system call as this
- * allows us to send e.g. SIGKILL to this process if it hangs in `D'
- * state on a file share due a stalled NFS server. This does not work
- * with (p)threads as SIGKILL would kill all threads including main.
- */
-
-static volatile pid_t active;
-static int pipes[4] = {-1, -1, -1, -1};
-static handle_t *restrict handle;
-static const size_t buflen = PATH_MAX+sizeof(handle_t)+1;
-
-static void sigchild(int sig attribute((unused)))
-{
- pid_t pid = waitpid(active, NULL, WNOHANG|WUNTRACED);
- if (pid <= 0)
- return;
- if (errno == ECHILD)
- return;
- active = 0;
-}
-
-static void attribute((constructor)) start(void)
-{
- sigset_t sigset, oldset;
- struct sigaction act;
- char sync[1];
- ssize_t in;
-
- if (pipes[1] >= 0) close(pipes[1]);
- if (pipes[2] >= 0) close(pipes[2]);
-
- if (pipe(&pipes[0]))
- goto error;
- if (pipe(&pipes[2]))
- goto error;
-
- memset(&act, 0, sizeof(act));
- sigemptyset(&act.sa_mask);
- act.sa_flags = SA_RESTART;
- act.sa_handler = sigchild;
- sigaction(SIGCHLD, &act, 0);
-
- if (!handle)
- handle = mmap(NULL, buflen, PROT_READ|PROT_WRITE,
- MAP_ANONYMOUS|MAP_SHARED, -1, 0);
- if (handle == MAP_FAILED)
- goto error;
-
- if ((active = fork()) < 0)
- goto error;
-
- if (active) {
- close(pipes[0]);
- close(pipes[3]);
- pipes[0] = pipes[3] = -1;
- return;
- }
-
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGALRM);
- sigprocmask(SIG_BLOCK, &sigset, &oldset);
-
- act.sa_handler = SIG_DFL;
- sigaction(SIGCHLD, &act, 0);
-
- close(pipes[1]);
- close(pipes[2]);
- dup2(pipes[0], STDIN_FILENO);
- dup2(pipes[3], STDOUT_FILENO);
- close(pipes[0]);
- close(pipes[3]);
- pipes[1] = pipes[2] = -1;
- pipes[0] = pipes[3] = -1;
-
- while ((in = read(STDIN_FILENO, &sync, sizeof(sync))) != 0) {
- ssize_t out;
- if (in < 0) {
- if (errno == EINTR)
- continue;
- break;
- }
- if (!handle)
- break;
- if (handle->function(handle->path, &handle->argument) < 0)
- handle->errcode = errno;
- do
- out = write(STDOUT_FILENO, &sync, sizeof(sync));
- while (out < 0 && errno == EINTR);
- }
-
- sigprocmask(SIG_SETMASK, &oldset, NULL);
- exit(0);
-error:
- if (pipes[0] >= 0) close(pipes[0]);
- if (pipes[1] >= 0) close(pipes[1]);
- if (pipes[2] >= 0) close(pipes[2]);
- if (pipes[3] >= 0) close(pipes[3]);
- if (handle && handle != MAP_FAILED)
- munmap(handle, buflen);
- handle = NULL;
-}
-
-static void /* attribute((destructor)) */ stop(void)
-{
- if (active && waitpid(active, NULL, WNOHANG|WUNTRACED) == 0)
- kill(active, SIGKILL);
-}
-
-/*
- * External routine
- *
- * Execute stat(2) system call with timeout to avoid deadlock
- * on network based file systems.
- *
- */
-int
-timeout(stat_t function, const char *path, struct stat *restrict argument, time_t seconds)
-{
- struct sigaction alrm_act, pipe_act, new_act;
- sigset_t sigset, oldset;
- char sync[1] = "x";
-
- if (active <= 0) /* Oops, last one failed therefore clear status and restart */
- start();
- if (!handle) /* No shared memory area */
- return function(path, argument);
- memset(handle, 0, sizeof(handle_t));
- handle->len = strlen(path) + 1;
- if (handle->len >= PATH_MAX) {
- errno = ENAMETOOLONG;
- goto error;
- }
- handle->errcode = 0;
- handle->argument = *argument;
- handle->function = function;
- strcpy(handle->path, path);
-
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGALRM);
- sigaddset(&sigset, SIGPIPE);
- sigprocmask(SIG_UNBLOCK, &sigset, &oldset);
-
- memset(&new_act, 0, sizeof(new_act));
- sigemptyset(&new_act.sa_mask);
- new_act.sa_flags = SA_RESETHAND;
-
- if (sigsetjmp(jenv, 1))
- goto timed;
-
- new_act.sa_handler = sigjump;
- sigaction(SIGALRM, &new_act, &alrm_act);
- sigaction(SIGPIPE, &new_act, &pipe_act);
- alarm(seconds);
-
- write(pipes[1], &sync, sizeof(sync));
- read(pipes[2], &sync, sizeof(sync));
-
- alarm(0);
- sigaction(SIGPIPE, &pipe_act, NULL);
- sigaction(SIGALRM, &alrm_act, NULL);
-
- if (handle->errcode) {
- errno = handle->errcode;
- goto error;
- }
-
- *argument = handle->argument;
- sigprocmask(SIG_SETMASK, &oldset, NULL);
-
- return 0;
-timed:
- (void) alarm(0);
- sigaction(SIGPIPE, &pipe_act, NULL);
- sigaction(SIGALRM, &alrm_act, NULL);
- sigprocmask(SIG_SETMASK, &oldset, NULL);
- stop();
- errno = ETIMEDOUT;
-error:
- return -1;
-}
-#elif WITH_TIMEOUT_STAT == 1
-/*
- * External routine
- *
- * Execute stat(2) system call with timeout to avoid deadlock
- * on network based file systems.
- *
- */
-int
-timeout(stat_t function, const char *path, struct stat *restrict argument, time_t seconds)
-{
- struct sigaction alrm_act, pipe_act, new_act;
- sigset_t sigset, oldset;
- int ret = 0, pipes[4];
- pid_t pid = 0;
- ssize_t len;
-
- if (pipe(&pipes[0]) < 0)
- goto error;
- switch ((pid = fork())) {
- case -1:
- close(pipes[0]);
- close(pipes[1]);
- goto error;
- case 0:
- new_act.sa_handler = SIG_DFL;
- sigaction(SIGALRM, &new_act, NULL);
- close(pipes[0]);
- if ((ret = function(path, argument)) == 0)
- do
- len = write(pipes[1], argument, sizeof(struct stat));
- while (len < 0 && errno == EINTR);
- close(pipes[1]);
- exit(ret);
- default:
- close(pipes[1]);
-
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGALRM);
- sigaddset(&sigset, SIGPIPE);
- sigprocmask(SIG_UNBLOCK, &sigset, &oldset);
-
- memset(&new_act, 0, sizeof(new_act));
- sigemptyset(&new_act.sa_mask);
-
- if (sigsetjmp(jenv, 1))
- goto timed;
-
- new_act.sa_handler = sigjump;
- sigaction(SIGALRM, &new_act, &alrm_act);
- sigaction(SIGPIPE, &new_act, &pipe_act);
- alarm(seconds);
- if (read(pipes[0], argument, sizeof(struct stat)) == 0) {
- errno = EFAULT;
- ret = -1;
- }
- (void)alarm(0);
- sigaction(SIGPIPE, &pipe_act, NULL);
- sigaction(SIGALRM, &alrm_act, NULL);
-
- close(pipes[0]);
- waitpid(pid, NULL, 0);
- break;
- }
- return ret;
-timed:
- (void)alarm(0);
- sigaction(SIGPIPE, &pipe_act, NULL);
- sigaction(SIGALRM, &alrm_act, NULL);
- if (waitpid(0, NULL, WNOHANG) == 0)
- kill(pid, SIGKILL);
- errno = ETIMEDOUT;
-error:
- return -1;
-}
-#endif
-
-/*
- * End of timeout.c
- */
diff --git src/timeout.h src/timeout.h
deleted file mode 100644
index f372297..0000000
--- src/timeout.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * timout.h Advanced timeout handling for file system calls
- * to avoid deadlocks on remote file shares.
- *
- * Version: 0.1 07-Sep-2011 Fink
- *
- * Copyright 2011 Werner Fink, 2011 SUSE LINUX Products GmbH, Germany.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Author: Werner Fink <werner@suse.de>, 2011
- */
-
-#ifndef _TIMEOUT_H
-#define _TIMEOUT_H
-
-#include "config.h"
-
-#ifndef WITH_TIMEOUT_STAT
-# define WITH_TIMEOUT_STAT 0
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <limits.h>
-
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
-# ifndef restrict
-# define restrict __restrict__
-# endif
-#endif
-
-typedef int (*stat_t)(const char *, struct stat *);
-
-#if WITH_TIMEOUT_STAT > 0
-extern int timeout(stat_t, const char *, struct stat *restrict, time_t);
-#else
-# define timeout(func,path,buf,dummy) (func)((path),(buf))
-#endif
-
-#endif
--
2.25.0

View File

@ -1,18 +1,14 @@
---
src/pstree.c | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
--- src/pstree.c
+++ src/pstree.c 2017-06-20 14:24:15.670691071 +0000
@@ -70,6 +70,7 @@ extern const char *__progname;
--- src/pstree.c.orig 2019-11-12 11:23:38.000000000 +0100
+++ src/pstree.c 2020-12-31 10:43:59.650348130 +0100
@@ -71,6 +71,7 @@
#define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */
#define VT_BEG "\033(0\017" /* use graphic chars */
+#define VT_LEN 4
+#define VT_LEN 4
#define VT_END "\033(B" /* back to normal char set */
#define VT_V "x" /* see UTF definitions above */
#define VT_VR "t"
@@ -450,6 +451,27 @@ static void out_scontext(security_contex
@@ -470,6 +471,27 @@
out_string("'");
}
@ -40,7 +36,7 @@
static void out_newline(void)
{
if (last_char && cur_x == output_width)
@@ -662,11 +684,12 @@ dump_tree(PROC * current, int level, int
@@ -705,11 +727,12 @@
for (lvl = 0; lvl < level; lvl++) {
for (i = width[lvl] + 1; i; i--)
out_char(' ');
@ -49,16 +45,16 @@
- 1 ? last ? sym->last_2 : sym->branch_2 : more[lvl +
- 1] ?
- sym->vert_2 : sym->empty_2);
+ /*
+ * Replace all three symbol-drawing calls with calls to out_sym()
+ * to handle VT100 line drawing sequences if VT100 mode is active:
+ */
+ out_sym(lvl == level - 1 ? last ? sym->last_2 : sym->branch_2 :
+ more[lvl + 1] ? sym->vert_2 : sym->empty_2);
+ /*
+ * Replace all three symbol-drawing calls with calls to out_sym()
+ * to handle VT100 line drawing sequences if VT100 mode is active:
+ */
+ out_sym(lvl == level - 1 ? last ? sym->last_2 : sym->branch_2 :
+ more[lvl + 1] ? sym->vert_2 : sym->empty_2);
}
if (rep < 2)
add = 0;
@@ -773,7 +796,7 @@ dump_tree(PROC * current, int level, int
@@ -819,7 +842,7 @@
}
width[level] = comm_len + cur_x - offset + add;
if (cur_x >= output_width && trunc) {
@ -67,7 +63,7 @@
out_string("+");
out_newline();
return;
@@ -797,7 +820,7 @@ dump_tree(PROC * current, int level, int
@@ -843,7 +866,7 @@
}
}
if (first) {

View File

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

View File

@ -0,0 +1,38 @@
Avoid to fail on killall without any argiments in case of libselinux
--- configure.ac
+++ configure.ac 2021-01-14 12:52:33.493812041 +0100
@@ -27,6 +27,8 @@ if test "$enable_selinux" = "yes"; then
AC_DEFINE([WITH_SELINUX], [1], [Use Security-Enhanced Linux features])
AC_CHECK_LIB([selinux], [getfilecon], [SELINUX_LIB=-lselinux], [
AC_MSG_ERROR([Cannot find selinux static library]) ])
+ AC_CHECK_LIB([selinux], [getfilecon], [echo 'set has_selinux 1' > testsuite/selinux.exp],
+ [echo 'set has_selinux 0' > testsuite/selinux.exp])
fi
AC_SUBST([SELINUX_LIB])
--- testsuite/Makefile.am
+++ testsuite/Makefile.am 2021-01-14 12:53:25.962505766 +0100
@@ -1,6 +1,8 @@
AUTOMAKE_OPTIONS = dejagnu
export DEJAGNU
+EXTRA_DEJAGNU_SITE_CONFIG=$(srcdir)/selinux.exp
+
# Programs that are expected across the board.
DEJATOOL = killall
DEJATOOL += pslog
--- testsuite/killall.test/killall.exp
+++ testsuite/killall.test/killall.exp 2021-01-14 12:54:27.087313939 +0100
@@ -7,7 +7,11 @@ set fake_proc_name "afakeprocname"
set test "killall with no arguments"
spawn $killall
+if { $has_selinux == 0 } {
expect_pass "$test" "^Usage: killall \\\[OPTION\\\]\\.\\.\\. \\\[--\\\] NAME\\.\\.\\."
+} else {
+expect_pass "$test" "^Usage: killall \\\[ -Z CONTEXT \\\] \\\[ -u USER \\\] \\\[ -y TIME \\\] \\\[ -o TIME \\\] \\\[ -eIgiqrvw \\\]"
+}
set test "killall list signals"
spawn $killall -l

View File

@ -4,8 +4,8 @@
2 files changed, 5 insertions(+), 2 deletions(-)
--- configure.ac
+++ configure.ac 2018-11-02 13:34:07.811373984 +0000
@@ -132,7 +132,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
+++ configure.ac 2021-01-14 11:31:31.640709812 +0000
@@ -129,7 +129,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
struct user_regs_struct.rdi,
struct user_regs_struct.rsi,
struct user_regs_struct.rdx], [],[],
@ -15,8 +15,8 @@
AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3,
struct pt_regs.gpr], [],[], [#include <linux/ptrace.h>])
--- src/fuser.c
+++ src/fuser.c 2018-11-02 13:34:07.811373984 +0000
@@ -1094,6 +1094,7 @@ int main(int argc, char *argv[])
+++ src/fuser.c 2021-01-14 11:31:31.640709812 +0000
@@ -1146,6 +1146,7 @@ int main(int argc, char *argv[])
struct option *optr;
char *nsptr;
int skip_argv;
@ -24,7 +24,7 @@
struct option options[] = {
{"all", 0, NULL, 'a'},
@@ -1137,6 +1138,7 @@ int main(int argc, char *argv[])
@@ -1189,6 +1190,7 @@ int main(int argc, char *argv[])
#endif
atexit(atexit_free_lists);
@ -32,7 +32,7 @@
for (argc_cnt = 1; argc_cnt < argc; argc_cnt++) {
current_argv = argv[argc_cnt];
if (current_argv[0] == '-') { /* its an option */
@@ -1279,6 +1281,7 @@ int main(int argc, char *argv[])
@@ -1333,6 +1335,7 @@ int main(int argc, char *argv[])
}
}
this_name->matched_procs = NULL;
@ -40,7 +40,7 @@
if (opts & (OPT_MOUNTS | OPT_ISMOUNTPOINT)
&& this_name->name_space != NAMESPACE_FILE) {
free(this_name);
@@ -1332,7 +1335,7 @@ int main(int argc, char *argv[])
@@ -1386,7 +1389,7 @@ int main(int argc, char *argv[])
names_tail->next = this_name;
names_tail = this_name;
} /* for across the argvs */

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

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

View File

@ -1,3 +1,30 @@
-------------------------------------------------------------------
Thu Jan 14 15:48:53 UTC 2021 - Dr. Werner Fink <werner@suse.de>
- Now with 23.3 peekfd is build even for aarch64
-------------------------------------------------------------------
Thu Jan 14 11:58:43 UTC 2021 - Dr. Werner Fink <werner@suse.de>
- Rework 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
and split off the patch psmisc-v23.3-selinux.patch
- Rework 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
- New patch psmisc-v23.3-selinux.patch
- Rename patch psmisc-v23.2.dif which is now psmisc-v23.3.dif
-------------------------------------------------------------------
Thu Dec 31 09:40:07 UTC 2020 - Paolo Stivanin <info@paolostivanin.com>
- Update to 23.3:
* killall: check also truncated 16 char comm names Debian
* fuser: Return early if have nulls
* peekfd: Add support for ARM64
* pstree: Add color by age
* fuser: Use larger inode sizes
- Rebase 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
- Rebase 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
- Rebase psmisc-22.21-pstree.patch
-------------------------------------------------------------------
Fri Oct 16 10:18:52 UTC 2020 - Ludwig Nussel <lnussel@suse.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package psmisc
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -27,7 +27,7 @@ BuildRequires: libselinux-devel
BuildRequires: linux-glibc-devel >= 4.12
BuildRequires: ncurses-devel
URL: https://gitlab.com/psmisc/psmisc/
Version: 23.2
Version: 23.3
Release: 0
Provides: ps:/usr/bin/killall
Summary: Utilities for managing processes on your system
@ -40,8 +40,9 @@ Patch2: %{name}-22.21-pstree.patch
# 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: psmisc-v23.3-selinux.patch
%define have_peekfd %ix86 x86_64 ppc ppc64 ppc64le %arm mipsel m68k
%define have_peekfd %ix86 x86_64 ppc ppc64 ppc64le %arm mipsel m68k aarch64
%description
The psmisc package contains utilities for managing processes on your
@ -58,6 +59,7 @@ processes that are using specified files or filesystems.
%patch2 -p0 -b .pstree
%patch3 -p0 -b .mntinf
%patch4 -p0 -b .statx
%patch5 -p0 -b .selx
%patch0 -p0 -b .p0
%build