Accepting request 947699 from Base:System

- Update to 23.4:
  * killall: Dynamically link to selinux and use security attributes
  * pstree: Do not crash on missing processes !21
  * pstree: fix layout when using -C !24
  * pstree: add time namespace !25
  * pstree: Dynamically link to selinux and use attr
  * fuser: Get less confused about duplicate dev_id !10
  * fuser: Only check pathname on non-block devices !31
- 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
- Port psmisc-22.21-pstree.patch
- Delete psmisc-v23.3-selinux.patch as not needed anymore
- Rename psmisc-v23.3.dif which is now psmisc-v23.4.dif with correct offsets

OBS-URL: https://build.opensuse.org/request/show/947699
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/psmisc?expand=0&rev=81
This commit is contained in:
Dominique Leuenberger 2022-01-22 07:17:59 +00:00 committed by Git OBS Bridge
commit 26abc8baab
9 changed files with 638 additions and 170 deletions

View File

@ -24,15 +24,17 @@ determine the appropriate mount ID for e.g. qcow2 files.
Signed-off-by: Werner Fink <werner@suse.de>
---
configure.ac | 15 +
src/fuser.c | 681 +++++++++++++++++++++++++++++++++++++++++++++-------------
src/fuser.h | 27 +-
src/timeout.c | 5
configure.ac | 15 +-
src/fuser.c | 683 +++++++++++++++++++++++++++++++++++++++-----------
src/fuser.h | 25 +-
src/timeout.c | 5 +-
4 files changed, 567 insertions(+), 161 deletions(-)
diff --git configure.ac configure.ac
index 182a0df..d4dee51 100644
--- configure.ac
+++ configure.ac 2021-05-07 15:01:31.910757814 +0000
@@ -44,6 +44,19 @@ if test "$enable_timeout_stat" = "static
+++ configure.ac
@@ -60,6 +60,19 @@ if test "$enable_timeout_stat" = "static"; then
fi
AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"])
@ -52,7 +54,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
# Use string search for network based file systems but only if the system
# has /proc/self/mountinfo
AC_SUBST([WITH_MOUNTINFO_LIST])
@@ -85,7 +98,7 @@ dnl Checks for header files.
@@ -101,7 +114,7 @@ dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
@ -61,8 +63,10 @@ Signed-off-by: Werner Fink <werner@suse.de>
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
diff --git src/fuser.c src/fuser.c
index 03e6237..dd928d2 100644
--- src/fuser.c
+++ src/fuser.c 2021-05-07 15:03:42.232365037 +0000
+++ src/fuser.c
@@ -32,6 +32,8 @@
#include <stdlib.h>
#include <string.h>
@ -72,7 +76,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -79,7 +81,7 @@ static void check_map(const pid_t pid, c
@@ -87,7 +89,7 @@ static void check_map(const pid_t pid, const char *filename,
struct device_list *dev_head,
struct inode_list *ino_head, const uid_t uid,
const char access);
@ -81,7 +85,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
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 +90,9 @@ static int kill_matched_proc(struct proc
@@ -96,9 +98,9 @@ static int kill_matched_proc(struct procs *pptr, const opt_type opts,
/*int parse_mount(struct names *this_name, struct device_list **dev_list);*/
static void add_device(struct device_list **dev_list,
@ -94,7 +98,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
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 +111,15 @@ static void debug_match_lists(struct nam
@@ -117,9 +119,15 @@ static void debug_match_lists(struct names *names_head,
struct device_list *dev_head);
#endif
@ -111,7 +115,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
static int mntstat(const char *path, struct stat *buf);
#endif
static stat_t thestat = stat;
@@ -202,6 +210,7 @@ scan_procs(struct names *names_head, str
@@ -210,6 +218,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
struct stat *cwd_stat = NULL;
struct stat *exe_stat = NULL;
struct stat *root_stat = NULL;
@ -119,7 +123,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */
continue;
@@ -211,9 +220,9 @@ scan_procs(struct names *names_head, str
@@ -219,9 +228,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
continue;
uid = getpiduid(pid);
@ -132,7 +136,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
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;
@@ -221,39 +230,51 @@ scan_procs(struct names *names_head, str
@@ -229,39 +238,51 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
/* Scan the devices */
for (dev_tmp = dev_head; dev_tmp != NULL;
dev_tmp = dev_tmp->next) {
@ -199,7 +203,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (cwd_stat
&& cwd_stat->st_dev == ino_tmp->device
&& cwd_stat->st_ino == ino_tmp->inode)
@@ -294,18 +315,42 @@ add_inode(struct inode_list **ino_list,
@@ -302,18 +323,42 @@ add_inode(struct inode_list **ino_list, struct names *this_name,
ino_tmp->name = this_name;
ino_tmp->device = device;
ino_tmp->inode = inode;
@ -243,7 +247,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if ((dev_tmp =
(struct device_list *)malloc(sizeof(struct device_list))) == NULL)
@@ -313,6 +358,10 @@ add_device(struct device_list **dev_list
@@ -321,6 +366,10 @@ add_device(struct device_list **dev_list, struct names *this_name, dev_t device)
dev_head = *dev_list;
dev_tmp->name = this_name;
dev_tmp->device = device;
@ -254,7 +258,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
dev_tmp->next = dev_head;
*dev_list = dev_tmp;
}
@@ -454,13 +503,15 @@ add_special_proc(struct names *name_list
@@ -462,13 +511,15 @@ add_special_proc(struct names *name_list, const char ptype, const uid_t uid,
int parse_file(struct names *this_name, struct inode_list **ino_list,
const opt_type opts)
{
@ -271,7 +275,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (errno == ENOENT)
fprintf(stderr,
_("Specified filename %s does not exist.\n"),
@@ -470,10 +521,12 @@ int parse_file(struct names *this_name,
@@ -478,10 +529,12 @@ int parse_file(struct names *this_name, struct inode_list **ino_list,
this_name->filename, strerror(errno));
return -1;
}
@ -286,7 +290,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
#endif /* DEBUG */
add_inode(ino_list, this_name, this_name->st.st_dev,
this_name->st.st_ino);
@@ -505,12 +558,43 @@ parse_mounts(struct names *this_name, st
@@ -513,12 +566,43 @@ parse_mounts(struct names *this_name, struct device_list **dev_list,
const opt_type opts)
{
dev_t match_device;
@ -331,7 +335,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
return 0;
}
@@ -687,10 +771,12 @@ int parse_inet(struct names *this_name,
@@ -695,10 +779,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
break;
#endif
}
@ -347,7 +351,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
}
return 1;
}
@@ -957,6 +1043,21 @@ free_inodes(struct inode_list **match_in
@@ -965,6 +1051,21 @@ free_inodes(struct inode_list **match_inodes)
/*
* Free up structures allocated in add_device
*/
@ -369,7 +373,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
static void
free_devices(struct device_list **match_devices)
{
@@ -964,6 +1065,8 @@ free_devices(struct device_list **match_
@@ -972,6 +1073,8 @@ free_devices(struct device_list **match_devices)
device_tmp = *match_devices;
while(device_tmp != NULL) {
@ -378,7 +382,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
device_next = device_tmp->next;
free(device_tmp);
device_tmp = device_next;
@@ -1166,16 +1269,11 @@ int main(int argc, char *argv[])
@@ -1174,16 +1277,11 @@ int main(int argc, char *argv[])
skip_argv = 1;
//while(option != '\0') option++;
if (strcmp(argv[argc_cnt], "tcp") == 0)
@ -400,7 +404,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
else
usage(_
("Invalid namespace name"));
@@ -1215,7 +1313,7 @@ int main(int argc, char *argv[])
@@ -1223,7 +1321,7 @@ int main(int argc, char *argv[])
}
#if defined(WITH_MOUNTINFO_LIST)
@ -409,16 +413,16 @@ Signed-off-by: Werner Fink <werner@suse.de>
thestat = mntstat;
#endif
/* an option */
@@ -1529,7 +1627,7 @@ print_matches(struct names *names_head,
@@ -1537,7 +1635,7 @@ print_matches(struct names *names_head, const opt_type opts,
}
-static struct stat *get_pidstat(const pid_t pid, const char *filename)
+static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id)
{
char pathname[256];
char pathname[PATH_MAX];
struct stat *st;
@@ -1541,6 +1639,15 @@ static struct stat *get_pidstat(const pi
@@ -1549,6 +1647,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename)
free(st);
return NULL;
}
@ -434,7 +438,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
return st;
}
@@ -1555,7 +1662,7 @@ check_dir(const pid_t pid, const char *d
@@ -1563,7 +1670,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
struct inode_list *ino_tmp;
struct device_list *dev_tmp;
struct unixsocket_list *sock_tmp;
@ -442,8 +446,8 @@ Signed-off-by: Werner Fink <werner@suse.de>
+ struct stat st;
char *dirpath;
char filepath[PATH_MAX];
@@ -1580,6 +1687,9 @@ check_dir(const pid_t pid, const char *d
char real_filepath[PATH_MAX];
@@ -1589,6 +1696,9 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
filepath, strerror(errno));
}
} else {
@ -453,7 +457,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
thedev = st.st_dev;
if (thedev == netdev) {
for (sock_tmp = sockets; sock_tmp != NULL;
@@ -1592,13 +1702,37 @@ check_dir(const pid_t pid, const char *d
@@ -1601,10 +1711,29 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
}
}
}
@ -464,11 +468,12 @@ Signed-off-by: Werner Fink <werner@suse.de>
for (dev_tmp = dev_head; dev_tmp != NULL;
dev_tmp = dev_tmp->next) {
- if (thedev != dev_tmp->device)
- continue;
+
+ if (thedev != dev_tmp->device) {
+ struct subvol *vol_tmp;
+ int subvol_found = 0;
+
+
+ for (vol_tmp = dev_tmp->vol; vol_tmp != NULL;
+ vol_tmp = vol_tmp->next) {
+ /* Check for BtrFS sub volumes as well */
@ -477,15 +482,22 @@ Signed-off-by: Werner Fink <werner@suse.de>
+ break;
+ }
+ }
+
+
+ if (!subvol_found)
+ continue;
+ }
/* check the paths match if it is not a block device */
if (! S_ISBLK(dev_tmp->name->st.st_mode)) {
@@ -1616,9 +1745,14 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
continue;
}
}
+
+ if (fdret != 0)
+ continue;
+ if (fd.mnt_id != dev_tmp->mnt_id)
continue;
+ continue;
+
if (access == ACCESS_FILE
- && (lstat(filepath, &lst) == 0)
@ -494,7 +506,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
add_matched_proc(dev_tmp->name,
pid, uid,
ACCESS_FILEWR |
@@ -1620,9 +1754,10 @@ check_dir(const pid_t pid, const char *d
@@ -1640,9 +1774,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
continue;
}
if (st.st_ino == ino_tmp->inode) {
@ -507,7 +519,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
add_matched_proc(ino_tmp->name,
pid, uid,
ACCESS_FILEWR |
@@ -1651,31 +1786,54 @@ check_map(const pid_t pid, const char *f
@@ -1671,31 +1806,54 @@ check_map(const pid_t pid, const char *filename,
FILE *fp;
unsigned long long tmp_inode;
unsigned int tmp_maj, tmp_min;
@ -572,7 +584,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
}
fclose(fp);
}
@@ -1699,6 +1857,7 @@ static uid_t getpiduid(const pid_t pid)
@@ -1719,6 +1877,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
*/
@ -580,7 +592,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
void fill_unix_cache(struct unixsocket_list **unixsocket_head)
{
FILE *fp;
@@ -1715,6 +1874,8 @@ void fill_unix_cache(struct unixsocket_l
@@ -1735,6 +1894,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
while (fgets(line, BUFSIZ, fp) != NULL) {
char *path;
char *scanned_path = NULL;
@ -589,7 +601,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %llu %ms",
&scanned_inode, &scanned_path) != 2) {
if (scanned_path)
@@ -1730,6 +1891,8 @@ void fill_unix_cache(struct unixsocket_l
@@ -1750,6 +1911,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
free(path);
continue;
}
@ -598,7 +610,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if ((newsocket = (struct unixsocket_list *)
malloc(sizeof(struct unixsocket_list))) == NULL) {
free(path);
@@ -1738,6 +1901,7 @@ void fill_unix_cache(struct unixsocket_l
@@ -1758,6 +1921,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
newsocket->sun_name = strdup(scanned_path);
newsocket->inode = st.st_ino;
newsocket->dev = st.st_dev;
@ -606,7 +618,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
newsocket->net_inode = scanned_inode;
newsocket->next = *unixsocket_head;
*unixsocket_head = newsocket;
@@ -1750,6 +1914,7 @@ void fill_unix_cache(struct unixsocket_l
@@ -1770,6 +1934,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
/*
* Free up the list of Unix sockets
*/
@ -614,7 +626,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
void clear_unix_cache(struct unixsocket_list **unixsocket_head)
{
while(*unixsocket_head != NULL) {
@@ -1921,34 +2086,21 @@ scan_mounts(struct names *names_head, st
@@ -1941,34 +2106,21 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
{
struct device_list *dev_tmp;
struct inode_list *ino_tmp;
@ -657,7 +669,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0,
find_mountp);
}
@@ -1960,7 +2112,6 @@ scan_mounts(struct names *names_head, st
@@ -1980,7 +2132,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
find_mountp);
}
}
@ -665,7 +677,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
}
static void
@@ -2013,16 +2164,44 @@ scan_swaps(struct names *names_head, str
@@ -2033,16 +2184,44 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
fclose(fp);
}
@ -714,7 +726,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
{
list_t *ptr, *tmp;
@@ -2033,72 +2212,276 @@ static void clear_mntinfo(void)
@@ -2053,72 +2232,276 @@ static void clear_mntinfo(void)
}
}
@ -768,17 +780,8 @@ Signed-off-by: Werner Fink <werner@suse.de>
+ stat(mpoint, &st);
+ mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */
+ }
}
- 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;
}
+ }
+ }
+#else
+ if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0)
+ return;
@ -798,8 +801,17 @@ Signed-off-by: Werner Fink <werner@suse.de>
+ 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);
+}
@ -1004,12 +1016,12 @@ Signed-off-by: Werner Fink <werner@suse.de>
- if (mid != mnt->parid)
+
+ if (nlen != mnt->nlen)
+ continue;
+
+ if (strcmp(use, mnt->mpoint))
continue;
- move_head(ptr, &sort);
+
+ if (strcmp(use, mnt->mpoint))
+ continue;
+
+ ret = 0;
+ errno = 0;
+ *mountinfo = mnt;
@ -1035,7 +1047,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
/*
* Determine device of links below /proc/
*/
@@ -2106,8 +2489,7 @@ static int mntstat(const char *path, str
@@ -2126,8 +2509,7 @@ static int mntstat(const char *path, struct stat *buf)
{
char name[PATH_MAX + 1];
const char *use;
@ -1045,7 +1057,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if ((use = realpath(path, name)) == NULL || *use != '/')
{
@@ -2119,27 +2501,26 @@ static int mntstat(const char *path, str
@@ -2139,27 +2521,26 @@ static int mntstat(const char *path, struct stat *buf)
errno = 0;
return stat(path, buf);
}
@ -1091,8 +1103,10 @@ Signed-off-by: Werner Fink <werner@suse.de>
}
#endif /* WITH_MOUNTINFO_LIST */
diff --git src/fuser.h src/fuser.h
index 4500ec5..16abc55 100644
--- src/fuser.h
+++ src/fuser.h 2021-05-07 15:01:31.954757006 +0000
+++ src/fuser.h
@@ -37,10 +37,16 @@ struct procs {
#define PTYPE_KNFSD 2
#define PTYPE_SWAP 3
@ -1105,8 +1119,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
struct names {
char *filename;
unsigned char name_space;
- struct stat st;
+ struct stat st;
struct stat st;
+ int mnt_id;
struct procs *matched_procs;
struct names *next;
@ -1170,8 +1183,10 @@ Signed-off-by: Werner Fink <werner@suse.de>
+#define PROC_MOUNTINFO "/proc/self/mountinfo"
#define PROC_MOUNTS "/proc/mounts"
#define PROC_SWAPS "/proc/swaps"
diff --git src/timeout.c src/timeout.c
index ca4a7cd..a3c7055 100644
--- src/timeout.c
+++ src/timeout.c 2021-05-07 15:01:31.954757006 +0000
+++ src/timeout.c
@@ -67,9 +67,6 @@
# ifndef constructor
# define constructor __constructor__
@ -1191,3 +1206,6 @@ Signed-off-by: Werner Fink <werner@suse.de>
/*
* Using a forked process for doing e.g. stat(2) system call as this
--
2.26.2

View File

@ -5,16 +5,24 @@ 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 | 24 +++++----
src/fuser.c | 102 ++++++++++------------------------------
src/statx.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/statx.h | 68 ++++++++++++++++++++++++++
5 files changed, 260 insertions(+), 87 deletions(-)
Makefile.am | 4 +-
configure.ac | 38 ++----
src/fuser.c | 102 ++++----------
src/statx.c | 149 ++++++++++++++++++++
src/statx.h | 68 ++++++++++
src/timeout.c | 369 --------------------------------------------------
src/timeout.h | 45 ------
7 files changed, 260 insertions(+), 515 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
diff --git Makefile.am Makefile.am
index 8067689..ea44203 100644
--- Makefile.am
+++ Makefile.am 2021-05-07 15:04:28.611513529 +0000
@@ -64,8 +64,8 @@ src_fuser_SOURCES = \
+++ Makefile.am
@@ -65,8 +65,8 @@ src_fuser_SOURCES = \
src/fuser.h \
src/lists.h
@ -25,9 +33,32 @@ Signed-off-by: Werner Fink <werner@suse.de>
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 d4dee51..eda0e62 100644
--- configure.ac
+++ configure.ac 2021-05-07 15:04:28.623513310 +0000
@@ -57,16 +57,20 @@ fi
+++ configure.ac
@@ -46,20 +46,6 @@ if test "$enable_selinux" = "yes"; then
fi
AC_SUBST([DL_LIB])
-# Call fork before all stat calls to stop hanging on NFS mounts
-AC_SUBST([WITH_TIMEOUT_STAT])
-AC_ARG_ENABLE([timeout_stat],
- [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls (optional with argument "static" for a static background process)])],
- [enable_timeout_stat=$enableval],
- [enable_timeout_stat="no"])
-if test "$enable_timeout_stat" = "yes"; then
- AC_DEFINE([WITH_TIMEOUT_STAT], [1], [Use timeout on stat calls])
-fi
-if test "$enable_timeout_stat" = "static"; then
- AC_DEFINE([WITH_TIMEOUT_STAT], [2], [Use timeout on stat calls])
-fi
-AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"])
-
# 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])
@@ -73,16 +59,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])])
@ -58,9 +89,11 @@ Signed-off-by: Werner Fink <werner@suse.de>
# Enable hardened compile and link flags
AC_ARG_ENABLE([harden_flags],
diff --git src/fuser.c src/fuser.c
index dd928d2..d08f7a9 100644
--- src/fuser.c
+++ src/fuser.c 2021-05-07 15:04:28.627513237 +0000
@@ -61,7 +61,7 @@
+++ src/fuser.c
@@ -65,7 +65,7 @@
#include "fuser.h"
#include "signals.h"
#include "i18n.h"
@ -69,7 +102,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
#include "comm.h"
//#define DEBUG 1
@@ -119,10 +119,6 @@ static int get_fdinfo(const pid_t pid, c
@@ -127,10 +127,6 @@ static int get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info);
static int get_mountid(const char *path);
#endif
static int find_mountpoint(const char *path, mntinfo_t **mountinfo);
@ -80,7 +113,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
static char *expandpath(const char *path);
static struct unixsocket_list *unixsockets = NULL;
static struct names *names_head = NULL, *names_tail = NULL;
@@ -510,7 +506,7 @@ int parse_file(struct names *this_name,
@@ -518,7 +514,7 @@ int parse_file(struct names *this_name, struct inode_list **ino_list,
free(this_name->filename);
this_name->filename = strdup(new);
}
@ -89,7 +122,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
find_mountpoint(this_name->filename, &mountinfo) != 0) {
if (errno == ENOENT)
fprintf(stderr,
@@ -1244,9 +1240,7 @@ int main(int argc, char *argv[])
@@ -1252,9 +1248,7 @@ int main(int argc, char *argv[])
opts |= OPT_INTERACTIVE;
break;
case 'I':
@ -99,7 +132,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
break;
case 'k':
opts |= OPT_KILL;
@@ -1312,10 +1306,11 @@ int main(int argc, char *argv[])
@@ -1320,10 +1314,11 @@ int main(int argc, char *argv[])
continue;
}
@ -114,16 +147,16 @@ Signed-off-by: Werner Fink <werner@suse.de>
/* an option */
/* Not an option, must be a file specification */
if ((this_name = malloc(sizeof(struct names))) == NULL)
@@ -1635,7 +1630,7 @@ static struct stat *get_pidstat(const pi
@@ -1643,7 +1638,7 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id)
if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL)
return NULL;
snprintf(pathname, 256, "/proc/%d/%s", pid, filename);
snprintf(pathname, PATH_MAX-1, "/proc/%d/%s", pid, filename);
- if (timeout(thestat, pathname, st, 5) != 0) {
+ if (statn(pathname, STATX_UID|STATX_INO|STATX_TYPE, st) != 0) {
free(st);
return NULL;
}
@@ -1681,7 +1676,7 @@ check_dir(const pid_t pid, const char *d
@@ -1690,7 +1685,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s",
pid, dirname, direntry->d_name);
@ -132,7 +165,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (errno != ENOENT && errno != ENOTDIR) {
fprintf(stderr, _("Cannot stat file %s: %s\n"),
filepath, strerror(errno));
@@ -1747,7 +1742,7 @@ check_dir(const pid_t pid, const char *d
@@ -1767,7 +1762,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
if (thedev != ino_tmp->device)
continue;
if (!st.st_ino
@ -141,7 +174,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
fprintf(stderr,
_("Cannot stat file %s: %s\n"),
filepath, strerror(errno));
@@ -1845,11 +1840,11 @@ static uid_t getpiduid(const pid_t pid)
@@ -1865,11 +1860,11 @@ static uid_t getpiduid(const pid_t pid)
if (asprintf(&pathname, "/proc/%d", pid) < 0)
return 0;
@ -157,7 +190,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
return st.st_uid;
}
@@ -1887,7 +1882,7 @@ void fill_unix_cache(struct unixsocket_l
@@ -1907,7 +1902,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
path = scanned_path;
if (*scanned_path == '@')
scanned_path++;
@ -166,7 +199,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
free(path);
continue;
}
@@ -2022,7 +2017,7 @@ static dev_t find_net_dev(void)
@@ -2042,7 +2037,7 @@ static dev_t find_net_dev(void)
fprintf(stderr, _("Cannot open a network socket.\n"));
return -1;
}
@ -175,7 +208,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
fprintf(stderr, _("Cannot find socket's device number.\n"));
close(skt);
return -1;
@@ -2059,7 +2054,7 @@ scan_knfsd(struct names *names_head, str
@@ -2079,7 +2074,7 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head,
if ((find_space = strpbrk(line, " \t")) == NULL)
continue;
*find_space = '\0';
@ -184,7 +217,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
continue;
}
/* Scan the devices */
@@ -2093,7 +2088,7 @@ scan_mounts(struct names *names_head, st
@@ -2113,7 +2108,7 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
const char *find_mountp = mnt->mpoint;
@ -193,7 +226,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
continue;
/* Scan the devices */
@@ -2143,7 +2138,7 @@ scan_swaps(struct names *names_head, str
@@ -2163,7 +2158,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
if (*find_space == '\0')
continue;
}
@ -202,7 +235,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
continue;
}
/* Scan the devices */
@@ -2240,10 +2235,10 @@ init_mntinfo(void)
@@ -2260,10 +2255,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));
@ -215,7 +248,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */
}
}
@@ -2255,7 +2250,7 @@ init_mntinfo(void)
@@ -2275,7 +2270,7 @@ init_mntinfo(void)
parid = -1;
while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) {
struct stat st;
@ -224,7 +257,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"),
mpoint, strerror(errno));
@@ -2264,7 +2259,7 @@ init_mntinfo(void)
@@ -2284,7 +2279,7 @@ init_mntinfo(void)
st.st_dev = (dev_t)-1;
}
mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev);
@ -233,7 +266,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (st.st_rdev != 0 && mntinf->dev != st.st_rdev)
mntinf->vol = st.st_rdev;
}
@@ -2288,7 +2283,7 @@ get_fdinfo(const pid_t pid, const char *
@@ -2308,7 +2303,7 @@ get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info)
struct stat st;
if (!mynamespace) {
@ -242,7 +275,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
fprintf(stderr, _("Cannot stat %s: %s\n"),
"/proc/self/ns/mnt", strerror(errno));
exit(1);
@@ -2323,7 +2318,7 @@ get_fdinfo(const pid_t pid, const char *
@@ -2343,7 +2338,7 @@ get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info)
out:
# if defined(HAS_NAME_TO_HANDLE_AT)
snprintf(pathname, 256, "/proc/%d/ns/mnt", pid);
@ -251,7 +284,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
char *realname;
snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
realname = expandpath(pathname);
@@ -2338,7 +2333,7 @@ out:
@@ -2358,7 +2353,7 @@ out:
struct stat lst;
snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
@ -260,7 +293,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (lst.st_mode & S_IWUSR)
info->flags |= O_WRONLY;
ret++;
@@ -2411,7 +2406,7 @@ find_mountpoint(const char *path, mntinf
@@ -2431,7 +2426,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
/* could be a chroot or a container */
@ -269,7 +302,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"),
path, strerror(errno));
@@ -2443,7 +2438,7 @@ find_mountpoint(const char *path, mntinf
@@ -2463,7 +2458,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
/* could be a chroot or a container */
@ -278,7 +311,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"),
use, strerror(errno));
@@ -2481,49 +2476,6 @@ out:
@@ -2501,49 +2496,6 @@ out:
return ret;
}
@ -328,8 +361,11 @@ Signed-off-by: Werner Fink <werner@suse.de>
/*
* Somehow the realpath(3) glibc function call, nevertheless
* it avoids lstat(2) system calls.
--- src/statx.c
+++ src/statx.c 2021-05-07 15:04:28.627513237 +0000
diff --git src/statx.c src/statx.c
new file mode 100644
index 0000000..a598c89
--- /dev/null
+++ src/statx.c
@@ -0,0 +1,149 @@
+/*
+ * statx.c - Map modern statx(2) system call to older stat(2), lstat(2),
@ -480,8 +516,11 @@ Signed-off-by: Werner Fink <werner@suse.de>
+ }
+ return ret;
+}
--- src/statx.h
+++ src/statx.h 2021-05-07 15:04:28.627513237 +0000
diff --git src/statx.h src/statx.h
new file mode 100644
index 0000000..fdd0137
--- /dev/null
+++ src/statx.h
@@ -0,0 +1,68 @@
+/*
+ * statx.h - Map modern statx(2) system call to older stat(2), lstat(2),
@ -551,3 +590,432 @@ Signed-off-by: Werner Fink <werner@suse.de>
+#define STATX_ALL 0
+#endif
+#endif
diff --git src/timeout.c src/timeout.c
deleted file mode 100644
index a3c7055..0000000
--- src/timeout.c
+++ /dev/null
@@ -1,369 +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 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];
-} 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.26.2

View File

@ -1,6 +1,10 @@
--- 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 @@
---
src/pstree.c | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 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;
#define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */
#define VT_BEG "\033(0\017" /* use graphic chars */
@ -8,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"
@@ -470,6 +471,27 @@
out_string("'");
@@ -522,6 +523,27 @@ static void out_scontext(const PROC *cur
}
}
+/*
@ -36,7 +40,7 @@
static void out_newline(void)
{
if (last_char && cur_x == output_width)
@@ -705,11 +727,12 @@
@@ -761,11 +783,12 @@ dump_tree(PROC * current, int level, int
for (lvl = 0; lvl < level; lvl++) {
for (i = width[lvl] + 1; i; i--)
out_char(' ');
@ -45,16 +49,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)
@@ -819,7 +842,7 @@
@@ -875,7 +898,7 @@ dump_tree(PROC * current, int level, int
}
width[level] = comm_len + cur_x - offset + add;
if (cur_x >= output_width && trunc) {
@ -63,7 +67,7 @@
out_string("+");
out_newline();
return;
@@ -843,7 +866,7 @@
@@ -899,7 +922,7 @@ dump_tree(PROC * current, int level, int
}
}
if (first) {

View File

@ -1,38 +0,0 @@
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

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

View File

@ -16,7 +16,7 @@
struct pt_regs.gpr], [],[], [#include <linux/ptrace.h>])
--- src/fuser.c
+++ src/fuser.c 2021-01-14 11:31:31.640709812 +0000
@@ -1145,6 +1145,7 @@ int main(int argc, char *argv[])
@@ -1153,6 +1153,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'},
@@ -1188,6 +1189,7 @@ int main(int argc, char *argv[])
@@ -1196,6 +1197,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 */
@@ -1332,6 +1334,7 @@ int main(int argc, char *argv[])
@@ -1340,6 +1342,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);
@@ -1385,7 +1388,7 @@ int main(int argc, char *argv[])
@@ -1393,7 +1396,7 @@ int main(int argc, char *argv[])
names_tail->next = this_name;
names_tail = this_name;
} /* for across the argvs */

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

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

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Thu Jan 20 13:57:13 UTC 2022 - Dr. Werner Fink <werner@suse.de>
- Update to 23.4:
* killall: Dynamically link to selinux and use security attributes
* pstree: Do not crash on missing processes !21
* pstree: fix layout when using -C !24
* pstree: add time namespace !25
* pstree: Dynamically link to selinux and use attr
* fuser: Get less confused about duplicate dev_id !10
* fuser: Only check pathname on non-block devices !31
- 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
- Port psmisc-22.21-pstree.patch
- Delete psmisc-v23.3-selinux.patch as not needed anymore
- Rename psmisc-v23.3.dif which is now psmisc-v23.4.dif with correct offsets
-------------------------------------------------------------------
Thu May 20 07:21:45 UTC 2021 - Dr. Werner Fink <werner@suse.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package psmisc
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 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.3
Version: 23.4
Release: 0
Provides: ps:/usr/bin/killall
Summary: Utilities for managing processes on your system
@ -40,7 +40,6 @@ 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 aarch64
@ -59,7 +58,6 @@ 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
@ -72,7 +70,8 @@ autoreconf -fi
CFLAGS="-D_GNU_SOURCE -D_DEFAULT_SOURCE ${RPM_OPT_FLAGS} -pipe -fPIE"
CXXFLAGS="$CFLAGS"
LDFLAGS=-pie
export CFLAGS CXXFLAGS LDFLAGS
CC=gcc
export CFLAGS CXXFLAGS LDFLAGS CC
%configure --disable-rpath \
--with-gnu-ld \
--enable-selinux \