From fe076b12821bb162d73bce8ce3e80cd65fedf01e Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 11 Jan 2021 08:22:06 +0000 Subject: [PATCH 1/3] Accepting request 859586 from home:polslinux:branches:Base:System - 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/859586 OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=125 --- ...to-be-able-to-use-the-mount-identity.patch | 261 +++++++-------- ...-2-system-call-to-avoid-hangs-on-NFS.patch | 308 ++++++++++++------ psmisc-22.21-pstree.patch | 34 +- psmisc-v23.2.tar.bz2 | 3 - psmisc-v23.2.dif => psmisc-v23.3.dif | 0 psmisc-v23.3.tar.bz2 | 3 + psmisc.changes | 13 + psmisc.spec | 6 +- 8 files changed, 365 insertions(+), 263 deletions(-) delete mode 100644 psmisc-v23.2.tar.bz2 rename psmisc-v23.2.dif => psmisc-v23.3.dif (100%) create mode 100644 psmisc-v23.3.tar.bz2 diff --git a/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch index 06c3eb7..99e4338 100644 --- a/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch +++ b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch @@ -1,35 +1,7 @@ -From 63d402a35e29106828f59b0b5b42a277136460c0 Mon Sep 17 00:00:00 2001 -From: Werner Fink -Date: Mon, 27 Apr 2020 14:41:03 +0200 -Subject: [PATCH] Use mountinfo to be able to use the mount identity - -which allows to distinguish different mounts with the -same device number as it happens with NFS shares. -Smaller cleanup as support of chroot environments -and older systems. - -Add support for name_to_handle_at() system call to -get the real mount ID for each file - -Support also BtrFS with its various subvolumes -On BtrFS stat(2) on binary does not see subvol dev - -Allow not unique mounts as well as not unique mountpoint - -Signed-off-by: Werner Fink ---- - 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(-) - -diff --git configure.ac configure.ac -index 176a2fc..d8d3366 100644 ---- configure.ac -+++ configure.ac -@@ -27,6 +27,9 @@ if test "$enable_selinux" = "yes"; then +diff -ru old/configure.ac new/configure.ac +--- old/configure.ac 2019-11-12 11:23:38.000000000 +0100 ++++ new/configure.ac 2020-12-31 10:49:48.159279790 +0100 +@@ -27,6 +27,9 @@ 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]) ]) @@ -39,7 +11,7 @@ index 176a2fc..d8d3366 100644 fi AC_SUBST([SELINUX_LIB]) -@@ -44,6 +47,19 @@ if test "$enable_timeout_stat" = "static"; then +@@ -44,6 +47,19 @@ fi AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"]) @@ -59,7 +31,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 +101,7 @@ AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT @@ -68,10 +40,10 @@ 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 +Only in new: .idea +diff -ru old/src/fuser.c new/src/fuser.c +--- old/src/fuser.c 2019-11-12 11:23:38.000000000 +0100 ++++ new/src/fuser.c 2020-12-31 11:02:04.273256080 +0100 @@ -32,6 +32,10 @@ #include #include @@ -83,7 +55,7 @@ index c44cee8..1b58374 100644 #include #include #include -@@ -79,7 +83,7 @@ static void check_map(const pid_t pid, const char *filename, +@@ -79,7 +83,7 @@ struct device_list *dev_head, struct inode_list *ino_head, const uid_t uid, const char access); @@ -92,7 +64,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 @@ /*int parse_mount(struct names *this_name, struct device_list **dev_list);*/ static void add_device(struct device_list **dev_list, @@ -105,7 +77,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 @@ struct device_list *dev_head); #endif @@ -119,7 +91,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 @@ struct stat *cwd_stat = NULL; struct stat *exe_stat = NULL; struct stat *root_stat = NULL; @@ -127,7 +99,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 @@ continue; uid = getpiduid(pid); @@ -140,7 +112,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 the devices */ for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) { @@ -184,7 +156,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 @@ } if (root_dev == ino_tmp->device) { if (!root_stat) @@ -193,7 +165,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 @@ } if (cwd_dev == ino_tmp->device) { if (!cwd_stat) @@ -202,7 +174,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 @@ ino_tmp->name = this_name; ino_tmp->device = device; ino_tmp->inode = inode; @@ -246,7 +218,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 @@ dev_head = *dev_list; dev_tmp->name = this_name; dev_tmp->device = device; @@ -257,7 +229,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 @@ int parse_file(struct names *this_name, struct inode_list **ino_list, const opt_type opts) { @@ -274,7 +246,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 @@ this_name->filename, strerror(errno)); return -1; } @@ -289,7 +261,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 @@ const opt_type opts) { dev_t match_device; @@ -336,7 +308,7 @@ index c44cee8..1b58374 100644 return 0; } -@@ -621,7 +706,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) +@@ -624,7 +709,7 @@ fprintf(stderr, _("Unknown local port AF %d\n"), res->ai_family); freeaddrinfo(res); @@ -345,7 +317,7 @@ index c44cee8..1b58374 100644 return -1; } freeaddrinfo(res); -@@ -684,10 +769,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) +@@ -687,10 +772,12 @@ break; #endif } @@ -361,7 +333,7 @@ index c44cee8..1b58374 100644 } return 1; } -@@ -953,6 +1040,21 @@ free_inodes(struct inode_list **match_inodes) +@@ -957,6 +1044,21 @@ /* * Free up structures allocated in add_device */ @@ -383,7 +355,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 @@ device_tmp = *match_devices; while(device_tmp != NULL) { @@ -392,7 +364,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 @@ skip_argv = 1; //while(option != '\0') option++; if (strcmp(argv[argc_cnt], "tcp") == 0) @@ -414,7 +386,7 @@ index c44cee8..1b58374 100644 else usage(_ ("Invalid namespace name")); -@@ -1211,7 +1310,7 @@ int main(int argc, char *argv[]) +@@ -1215,7 +1314,7 @@ } #if defined(WITH_MOUNTINFO_LIST) @@ -423,7 +395,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 @@ } @@ -432,7 +404,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 @@ free(st); return NULL; } @@ -448,7 +420,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 @@ struct inode_list *ino_tmp; struct device_list *dev_tmp; struct unixsocket_list *sock_tmp; @@ -458,7 +430,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,27 @@ } for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) { @@ -489,7 +461,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 +1745,10 @@ continue; } if (st.st_ino == ino_tmp->inode) { @@ -502,7 +474,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 +1777,54 @@ FILE *fp; unsigned long long tmp_inode; unsigned int tmp_maj, tmp_min; @@ -567,7 +539,7 @@ index c44cee8..1b58374 100644 } fclose(fp); } -@@ -1695,6 +1844,7 @@ static uid_t getpiduid(const pid_t pid) +@@ -1699,6 +1848,7 @@ * fill_unix_cache : Create a list of Unix sockets * This list is used later for matching purposes */ @@ -575,16 +547,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 +1865,8 @@ 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", ++ int mnt_id = -1; ++ mntinfo_t *mountinfo; + 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 +1882,8 @@ free(path); continue; } @@ -593,7 +565,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 +1892,7 @@ newsocket->sun_name = strdup(scanned_path); newsocket->inode = st.st_ino; newsocket->dev = st.st_dev; @@ -601,7 +573,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 +1905,7 @@ /* * Free up the list of Unix sockets */ @@ -609,7 +581,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 +2077,24 @@ { struct device_list *dev_tmp; struct inode_list *ino_tmp; @@ -619,38 +591,40 @@ index c44cee8..1b58374 100644 - char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + ++ list_t *ptr; ++ 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); - return; - } - while (fgets(line, BUFSIZ, fp) != NULL) { - if ((find_mountp = strchr(line, ' ')) == NULL) -- continue; ++ if (timeout(thestat, find_mountp, &st, 5) != 0) + continue; - find_mountp++; - if ((find_space = strchr(find_mountp, ' ')) == NULL) - 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; +- continue; - } + /* Scan the devices */ for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) { - if (st.st_dev == dev_tmp->device) -+ if (st.st_dev == dev_tmp->device && -+ mnt->id == dev_tmp->mnt_id) ++ if (st.st_dev == dev_tmp->device && ++ mnt->id == dev_tmp->mnt_id) 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 +2106,6 @@ find_mountp); } } @@ -658,7 +632,7 @@ index c44cee8..1b58374 100644 } static void -@@ -1998,16 +2145,44 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, +@@ -2013,16 +2158,44 @@ fclose(fp); } @@ -707,7 +681,7 @@ index c44cee8..1b58374 100644 { list_t *ptr, *tmp; -@@ -2018,72 +2193,247 @@ static void clear_mntinfo(void) +@@ -2033,72 +2206,247 @@ } } @@ -746,6 +720,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; @@ -757,7 +741,7 @@ index c44cee8..1b58374 100644 + mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ + } + } -+ } + } +#else + if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0) + return; @@ -777,26 +761,12 @@ 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) +{ @@ -886,7 +856,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; @@ -968,12 +943,12 @@ index c44cee8..1b58374 100644 - 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; @@ -999,7 +974,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 +2454,7 @@ { char name[PATH_MAX + 1]; const char *use; @@ -1009,7 +984,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 +2466,26 @@ errno = 0; return stat(path, buf); } @@ -1055,11 +1030,10 @@ 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 -@@ -37,10 +37,16 @@ struct procs { +diff -ru old/src/fuser.h new/src/fuser.h +--- old/src/fuser.h 2019-11-12 11:23:38.000000000 +0100 ++++ new/src/fuser.h 2020-12-31 10:49:48.159279790 +0100 +@@ -37,10 +37,16 @@ #define PTYPE_KNFSD 2 #define PTYPE_SWAP 3 @@ -1077,7 +1051,7 @@ index 93020d5..ca20081 100644 struct procs *matched_procs; struct names *next; }; -@@ -65,12 +71,21 @@ struct inode_list { +@@ -65,12 +71,21 @@ struct names *name; dev_t device; ino_t inode; @@ -1099,7 +1073,7 @@ index 93020d5..ca20081 100644 struct device_list *next; }; -@@ -79,6 +94,7 @@ struct unixsocket_list { +@@ -79,6 +94,7 @@ ino_t inode; ino_t net_inode; dev_t dev; @@ -1107,7 +1081,7 @@ index 93020d5..ca20081 100644 struct unixsocket_list *next; }; -@@ -87,18 +103,16 @@ struct mount_list { +@@ -87,18 +103,16 @@ struct mount_list *next; }; @@ -1129,37 +1103,17 @@ index 93020d5..ca20081 100644 #define NAMESPACE_FILE 0 #define NAMESPACE_TCP 1 -@@ -109,5 +123,6 @@ typedef struct mntinfo_s { +@@ -109,5 +123,6 @@ #endif /* PATH_MAX */ #define KNFSD_EXPORTS "/proc/fs/nfs/exports" +#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 - -+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" +diff -ru old/testsuite/killall.test/killall.exp new/testsuite/killall.test/killall.exp +--- old/testsuite/killall.test/killall.exp 2019-11-12 11:23:38.000000000 +0100 ++++ new/testsuite/killall.test/killall.exp 2020-12-31 10:49:48.159279790 +0100 +@@ -7,7 +7,11 @@ set test "killall with no arguments" spawn $killall @@ -1171,6 +1125,21 @@ index 8bb3889..a345582 100644 set test "killall list signals" spawn $killall -l --- -2.25.0 - +diff -ru old/testsuite/Makefile.am new/testsuite/Makefile.am +--- old/testsuite/Makefile.am 2019-11-12 11:23:38.000000000 +0100 ++++ new/testsuite/Makefile.am 2020-12-31 10:49:48.159279790 +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 +@@ -9,5 +11,4 @@ + DEJATOOL += fuser + endif + +- + EXTRA_DIST = diff --git a/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch b/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch index bfc74d5..e615934 100644 --- a/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch +++ b/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch @@ -1,43 +1,7 @@ -From 59144ef25a4bf0ecceb27e1c2dd2276de54555fe Mon Sep 17 00:00:00 2001 -From: Werner Fink -Date: Mon, 27 Apr 2020 16:44:17 +0200 -Subject: [PATCH] Use new statx(2) system call to avoid hangs on NFS - -Signed-off-by: Werner Fink ---- - 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 - -diff --git Makefile.am Makefile.am -index d8c4619..a76799c 100644 ---- Makefile.am -+++ Makefile.am -@@ -58,8 +58,8 @@ src_fuser_SOURCES = \ - src/fuser.h \ - src/lists.h - --if WANT_TIMEOUT_STAT --src_fuser_SOURCES += src/timeout.c src/timeout.h -+if HAVE_SYSCALL_STATX -+src_fuser_SOURCES += src/statx.c src/statx.h - 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 +diff -ruN old/configure.ac new/configure.ac +--- old/configure.ac 2020-12-31 11:08:34.654310080 +0100 ++++ new/configure.ac 2020-12-31 11:07:25.506123358 +0100 +@@ -33,20 +33,6 @@ fi AC_SUBST([SELINUX_LIB]) @@ -58,7 +22,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 +@@ -60,16 +46,20 @@ 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 +53,181 @@ 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 +diff -ruN old/.idea/workspace.xml new/.idea/workspace.xml +--- old/.idea/workspace.xml 1970-01-01 01:00:00.000000000 +0100 ++++ new/.idea/workspace.xml 2020-12-31 11:08:03.610226251 +0100 +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ 1609409125494 ++ ++ ++ ++ +\ No newline at end of file +diff -ruN old/Makefile.am new/Makefile.am +--- old/Makefile.am 2019-11-12 11:23:38.000000000 +0100 ++++ new/Makefile.am 2020-12-31 11:07:25.506123358 +0100 +@@ -64,8 +64,8 @@ + src/fuser.h \ + src/lists.h + +-if WANT_TIMEOUT_STAT +-src_fuser_SOURCES += src/timeout.c src/timeout.h ++if HAVE_SYSCALL_STATX ++src_fuser_SOURCES += src/statx.c src/statx.h + endif + src_fuser_LDADD = @LIBINTL@ + src_killall_SOURCES = src/killall.c src/comm.h src/signals.c src/signals.h src/i18n.h +diff -ruN old/Makefile.am.orig new/Makefile.am.orig +--- old/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100 ++++ new/Makefile.am.orig 2019-11-12 11:23:38.000000000 +0100 +@@ -0,0 +1,106 @@ ++ ++AM_CPPFLAGS = \ ++ -Wall \ ++ -DLOCALEDIR=\"$(localedir)\" \ ++ -I$(top_builddir)/src \ ++ @HARDEN_CFLAGS@ ++ ++AM_LDFLAGS = @HARDEN_LDFLAGS@ ++ ++ACLOCAL_AMFLAGS = -I m4 ++ ++SUBDIRS = \ ++ doc \ ++ po \ ++ icons \ ++ testsuite ++ ++bin_PROGRAMS = \ ++ src/killall \ ++ src/pslog \ ++ src/prtstat \ ++ src/pstree ++ ++if WANT_FUSER ++ bin_PROGRAMS += src/fuser ++endif ++if WANT_PEEKFD_I386 ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DI386 ++endif ++if WANT_PEEKFD_X86_64 ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DX86_64 ++endif ++if WANT_PEEKFD_PPC ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DPPC ++endif ++if WANT_PEEKFD_ARM ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DARM ++endif ++ ++if WANT_PEEKFD_ARM64 ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DARM64 ++endif ++ ++if WANT_PEEKFD_MIPS ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DMIPS ++endif ++if WANT_PEEKFD_M68K ++ bin_PROGRAMS += src/peekfd ++ AM_CPPFLAGS += -DM68K ++endif ++ ++src_fuser_SOURCES = \ ++ src/fuser.c \ ++ src/comm.h \ ++ src/signals.c \ ++ src/signals.h \ ++ src/i18n.h \ ++ src/fuser.h \ ++ src/lists.h ++ ++if WANT_TIMEOUT_STAT ++src_fuser_SOURCES += src/timeout.c src/timeout.h ++endif ++src_fuser_LDADD = @LIBINTL@ ++src_killall_SOURCES = src/killall.c src/comm.h src/signals.c src/signals.h src/i18n.h ++src_killall_LDADD = @LIBINTL@ @SELINUX_LIB@ ++src_peekfd_SOURCES = src/peekfd.c ++src_peekfd_LDADD = @LIBINTL@ ++src_pslog_SOURCES = src/pslog.c ++src_pstree_SOURCES = src/pstree.c src/comm.h src/i18n.h ++src_pstree_LDADD = @LIBINTL@ @TERMCAP_LIB@ @SELINUX_LIB@ ++src_prtstat_SOURCES = src/prtstat.c src/prtstat.h ++src_prtstat_LDADD = @LIBINTL@ ++nodist_src_killall_SOURCES = signames.h ++ ++BUILT_SOURCES = src/signames.h ++ ++EXTRA_DIST = src/signames.c README.md misc/git-version-gen ++ ++CLEANFILES = src/signames.h ++ ++src/signames.h: src/signames.c Makefile src/$(am__dirstamp) ++ export LC_ALL=C ; \ ++ @CPP@ -dM $< |\ ++ tr -s '\t ' ' ' | sort -n -k 3 | sed \ ++ 's:#define SIG\([A-Z][A-Z]*[0-9]*\) \([0-9][0-9]*\).*$\:{\ \2,"\1" },:p;d' | \ ++ grep -v '[0-9][0-9][0-9]' >$@ || \ ++ { rm -f $@; exit 1; } ++ grep '^{ 1,"HUP" },$$' $@ >/dev/null || \ ++ { rm -f $@; exit 1; } ++ ++src/signals.c: src/signames.h ++ ++install-exec-hook: ++ cd $(DESTDIR)$(bindir) && \ ++ ( [ -h pstree.x11 ] || $(LN_S) pstree pstree.x11) ++ ++ ++get-trans: ++ rsync -Lrtvz translationproject.org::tp/latest/psmisc/ po +diff -ruN old/src/fuser.c new/src/fuser.c +--- old/src/fuser.c 2020-12-31 11:08:34.658310092 +0100 ++++ new/src/fuser.c 2020-12-31 11:07:57.282209163 +0100 @@ -63,7 +63,7 @@ #include "fuser.h" #include "signals.h" @@ -102,7 +237,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 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,7 +248,7 @@ 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 @@ free(this_name->filename); this_name->filename = strdup(new); } @@ -122,7 +257,7 @@ index 1b58374..fc98790 100644 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 @@ opts |= OPT_INTERACTIVE; break; case 'I': @@ -132,7 +267,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 @@ continue; } @@ -147,7 +282,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 @@ if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL) return NULL; snprintf(pathname, 256, "/proc/%d/%s", pid, filename); @@ -156,7 +291,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 @@ snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s", pid, dirname, direntry->d_name); @@ -165,7 +300,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, +@@ -1738,7 +1733,7 @@ if (thedev != ino_tmp->device) continue; if (!st.st_ino @@ -174,7 +309,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) +@@ -1836,11 +1831,11 @@ if (asprintf(&pathname, "/proc/%d", pid) < 0) return 0; @@ -190,7 +325,7 @@ index 1b58374..fc98790 100644 return st.st_uid; } -@@ -1874,7 +1869,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) +@@ -1878,7 +1873,7 @@ path = scanned_path; if (*scanned_path == '@') scanned_path++; @@ -199,7 +334,7 @@ index 1b58374..fc98790 100644 free(path); continue; } -@@ -2009,7 +2004,7 @@ static dev_t find_net_dev(void) +@@ -2013,7 +2008,7 @@ fprintf(stderr, _("Cannot open a network socket.\n")); return -1; } @@ -208,7 +343,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, +@@ -2050,7 +2045,7 @@ if ((find_space = strpbrk(line, " \t")) == NULL) continue; *find_space = '\0'; @@ -217,16 +352,16 @@ index 1b58374..fc98790 100644 continue; } /* Scan the devices */ -@@ -2077,7 +2072,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; +@@ -2087,7 +2082,7 @@ + mntinfo_t *mnt = list_entry(ptr, mntinfo_t); + const char *find_mountp = mnt->mpoint; -- if (timeout(thestat, find_mountp, &st, 5) != 0) -+ if (statn(find_mountp, STATX_INO, &st) != 0) +- if (timeout(thestat, find_mountp, &st, 5) != 0) ++ if (statn(find_mountp, STATX_INO, &st) != 0) continue; /* Scan the devices */ -@@ -2124,7 +2119,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, +@@ -2137,7 +2132,7 @@ if (*find_space == '\0') continue; } @@ -235,7 +370,7 @@ index 1b58374..fc98790 100644 continue; } /* Scan the devices */ -@@ -2216,10 +2211,10 @@ init_mntinfo(void) +@@ -2229,10 +2224,10 @@ &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 +383,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) +@@ -2244,7 +2239,7 @@ parid = -1; while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) { struct stat st; @@ -257,7 +392,7 @@ index 1b58374..fc98790 100644 if (errno != EACCES) { fprintf(stderr, _("Cannot stat %s: %s\n"), mnt->mpoint, strerror(errno)); -@@ -2240,7 +2235,7 @@ init_mntinfo(void) +@@ -2253,7 +2248,7 @@ st.st_dev = (dev_t)-1; } mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev); @@ -266,7 +401,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: +@@ -2303,7 +2298,7 @@ struct stat lst; snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd); @@ -275,7 +410,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) +@@ -2376,7 +2371,7 @@ /* could be a chroot or a container */ @@ -284,7 +419,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) +@@ -2408,7 +2403,7 @@ /* could be a chroot or a container */ @@ -293,7 +428,7 @@ index 1b58374..fc98790 100644 if (errno != EACCES) { fprintf(stderr, _("Cannot stat %s: %s\n"), use, strerror(errno)); -@@ -2433,49 +2428,6 @@ out: +@@ -2446,49 +2441,6 @@ return ret; } @@ -343,11 +478,9 @@ 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 +diff -ruN old/src/statx.c new/src/statx.c +--- old/src/statx.c 1970-01-01 01:00:00.000000000 +0100 ++++ new/src/statx.c 2020-12-31 11:07:25.506123358 +0100 @@ -0,0 +1,149 @@ +/* + * statx.c - Map modern statx(2) system call to older stat(2), lstat(2), @@ -498,11 +631,9 @@ 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 +diff -ruN old/src/statx.h new/src/statx.h +--- old/src/statx.h 1970-01-01 01:00:00.000000000 +0100 ++++ new/src/statx.h 2020-12-31 11:07:25.506123358 +0100 @@ -0,0 +1,68 @@ +/* + * statx.h - Map modern statx(2) system call to older stat(2), lstat(2), @@ -572,11 +703,9 @@ 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 +diff -ruN old/src/timeout.c new/src/timeout.c +--- old/src/timeout.c 2019-11-12 11:23:38.000000000 +0100 ++++ new/src/timeout.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,372 +0,0 @@ -/* - * timout.c Advanced timeout handling for file system calls @@ -950,11 +1079,9 @@ index ca4a7cd..0000000 -/* - * End of timeout.c - */ -diff --git src/timeout.h src/timeout.h -deleted file mode 100644 -index f372297..0000000 ---- src/timeout.h -+++ /dev/null +diff -ruN old/src/timeout.h new/src/timeout.h +--- old/src/timeout.h 2019-11-12 11:23:38.000000000 +0100 ++++ new/src/timeout.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ -/* - * timout.h Advanced timeout handling for file system calls @@ -1001,6 +1128,3 @@ index f372297..0000000 -#endif - -#endif --- -2.25.0 - diff --git a/psmisc-22.21-pstree.patch b/psmisc-22.21-pstree.patch index ac1f133..68d9285 100644 --- a/psmisc-22.21-pstree.patch +++ b/psmisc-22.21-pstree.patch @@ -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) { diff --git a/psmisc-v23.2.tar.bz2 b/psmisc-v23.2.tar.bz2 deleted file mode 100644 index fd8fca5..0000000 --- a/psmisc-v23.2.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2f7807eb8bf8bac6835a81ef3740924755f1f3b8402d4e7b5ee1ab8a699c9679 -size 160432 diff --git a/psmisc-v23.2.dif b/psmisc-v23.3.dif similarity index 100% rename from psmisc-v23.2.dif rename to psmisc-v23.3.dif diff --git a/psmisc-v23.3.tar.bz2 b/psmisc-v23.3.tar.bz2 new file mode 100644 index 0000000..74adcc5 --- /dev/null +++ b/psmisc-v23.3.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe530b0a29902f8660481248fc19f6994927282b4fe0cd992121016144b95fa6 +size 168796 diff --git a/psmisc.changes b/psmisc.changes index 44ef4ed..5efae84 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Thu Dec 31 09:40:07 UTC 2020 - Paolo Stivanin + +- 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 diff --git a/psmisc.spec b/psmisc.spec index 2864b68..09e04ec 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -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 @@ -56,8 +56,8 @@ processes that are using specified files or filesystems. %prep %setup -q -n %{name}-v%{version} %patch2 -p0 -b .pstree -%patch3 -p0 -b .mntinf -%patch4 -p0 -b .statx +%patch3 -p1 -b .mntinf +%patch4 -p1 -b .statx %patch0 -p0 -b .p0 %build From c9f9c2947c42a0936c837dafd3c17d336bfca94e Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 14 Jan 2021 12:02:55 +0000 Subject: [PATCH 2/3] rework former submit OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=126 --- ...to-be-able-to-use-the-mount-identity.patch | 247 +++--- ...-2-system-call-to-avoid-hangs-on-NFS.patch | 700 ++---------------- psmisc-v23.3-selinux.patch | 38 + psmisc-v23.3.dif | 14 +- psmisc.changes | 9 + psmisc.spec | 8 +- 6 files changed, 242 insertions(+), 774 deletions(-) create mode 100644 psmisc-v23.3-selinux.patch diff --git a/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch index 99e4338..39bb7b2 100644 --- a/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch +++ b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch @@ -1,17 +1,32 @@ -diff -ru old/configure.ac new/configure.ac ---- old/configure.ac 2019-11-12 11:23:38.000000000 +0100 -+++ new/configure.ac 2020-12-31 10:49:48.159279790 +0100 -@@ -27,6 +27,9 @@ - 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 @@ +From e5d42c39541c94c00d97ed490add24bc898ebe0a Mon Sep 17 00:00:00 2001 +From: Werner Fink +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 +same device number as it happens with NFS shares. +Smaller cleanup as support of chroot environments +and older systems. + +Add support for name_to_handle_at() system call to +get the real mount ID for each file + +Support also BtrFS with its various subvolumes +On BtrFS stat(2) on binary does not see subvol dev + +Allow not unique mounts as well as not unique mountpoint + +Signed-off-by: Werner Fink +--- + configure.ac | 15 + + src/fuser.c | 643 ++++++++++++++++++++++++++++++++++++++++++++-------------- + src/fuser.h | 27 +- + src/timeout.c | 5 + 4 files changed, 530 insertions(+), 160 deletions(-) + +--- configure.ac ++++ 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"]) @@ -31,7 +46,7 @@ diff -ru old/configure.ac new/configure.ac # 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 @@ +@@ -85,7 +98,7 @@ dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT @@ -40,10 +55,8 @@ diff -ru old/configure.ac new/configure.ac dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -Only in new: .idea -diff -ru old/src/fuser.c new/src/fuser.c ---- old/src/fuser.c 2019-11-12 11:23:38.000000000 +0100 -+++ new/src/fuser.c 2020-12-31 11:02:04.273256080 +0100 +--- src/fuser.c ++++ src/fuser.c 2021-01-14 11:22:51.546798981 +0000 @@ -32,6 +32,10 @@ #include #include @@ -55,7 +68,7 @@ diff -ru old/src/fuser.c new/src/fuser.c #include #include #include -@@ -79,7 +83,7 @@ +@@ -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); @@ -64,7 +77,7 @@ diff -ru old/src/fuser.c new/src/fuser.c 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 @@ +@@ -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, @@ -77,7 +90,7 @@ diff -ru old/src/fuser.c new/src/fuser.c 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 @@ +@@ -109,9 +113,12 @@ static void debug_match_lists(struct nam struct device_list *dev_head); #endif @@ -91,7 +104,7 @@ diff -ru old/src/fuser.c new/src/fuser.c static int mntstat(const char *path, struct stat *buf); #endif static stat_t thestat = stat; -@@ -202,6 +209,7 @@ +@@ -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; @@ -99,7 +112,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */ continue; -@@ -211,9 +219,9 @@ +@@ -211,9 +219,9 @@ scan_procs(struct names *names_head, str continue; uid = getpiduid(pid); @@ -112,7 +125,7 @@ diff -ru old/src/fuser.c new/src/fuser.c 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,21 +229,33 @@ +@@ -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) { @@ -156,7 +169,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if (exe_stat && exe_stat->st_dev == ino_tmp->device && exe_stat->st_ino == ino_tmp->inode) -@@ -244,7 +264,7 @@ +@@ -244,7 +264,7 @@ scan_procs(struct names *names_head, str } if (root_dev == ino_tmp->device) { if (!root_stat) @@ -165,7 +178,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if (root_stat && root_stat->st_dev == ino_tmp->device && root_stat->st_ino == ino_tmp->inode) -@@ -253,7 +273,7 @@ +@@ -253,7 +273,7 @@ scan_procs(struct names *names_head, str } if (cwd_dev == ino_tmp->device) { if (!cwd_stat) @@ -174,7 +187,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if (cwd_stat && cwd_stat->st_dev == ino_tmp->device && cwd_stat->st_ino == ino_tmp->inode) -@@ -294,18 +314,42 @@ +@@ -294,18 +314,42 @@ add_inode(struct inode_list **ino_list, ino_tmp->name = this_name; ino_tmp->device = device; ino_tmp->inode = inode; @@ -218,7 +231,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if ((dev_tmp = (struct device_list *)malloc(sizeof(struct device_list))) == NULL) -@@ -313,6 +357,10 @@ +@@ -313,6 +357,10 @@ add_device(struct device_list **dev_list dev_head = *dev_list; dev_tmp->name = this_name; dev_tmp->device = device; @@ -229,7 +242,7 @@ diff -ru old/src/fuser.c new/src/fuser.c dev_tmp->next = dev_head; *dev_list = dev_tmp; } -@@ -454,13 +502,15 @@ +@@ -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) { @@ -246,7 +259,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if (errno == ENOENT) fprintf(stderr, _("Specified filename %s does not exist.\n"), -@@ -470,10 +520,12 @@ +@@ -470,10 +520,12 @@ int parse_file(struct names *this_name, this_name->filename, strerror(errno)); return -1; } @@ -261,7 +274,7 @@ diff -ru old/src/fuser.c new/src/fuser.c #endif /* DEBUG */ add_inode(ino_list, this_name, this_name->st.st_dev, this_name->st.st_ino); -@@ -505,12 +557,45 @@ +@@ -505,12 +557,45 @@ parse_mounts(struct names *this_name, st const opt_type opts) { dev_t match_device; @@ -308,16 +321,7 @@ diff -ru old/src/fuser.c new/src/fuser.c return 0; } -@@ -624,7 +709,7 @@ - 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); -@@ -687,10 +772,12 @@ +@@ -687,10 +772,12 @@ int parse_inet(struct names *this_name, break; #endif } @@ -333,7 +337,7 @@ diff -ru old/src/fuser.c new/src/fuser.c } return 1; } -@@ -957,6 +1044,21 @@ +@@ -957,6 +1044,21 @@ free_inodes(struct inode_list **match_in /* * Free up structures allocated in add_device */ @@ -355,7 +359,7 @@ diff -ru old/src/fuser.c new/src/fuser.c static void free_devices(struct device_list **match_devices) { -@@ -964,6 +1066,8 @@ +@@ -964,6 +1066,8 @@ free_devices(struct device_list **match_ device_tmp = *match_devices; while(device_tmp != NULL) { @@ -364,7 +368,7 @@ diff -ru old/src/fuser.c new/src/fuser.c device_next = device_tmp->next; free(device_tmp); device_tmp = device_next; -@@ -1166,16 +1270,11 @@ +@@ -1166,16 +1270,11 @@ int main(int argc, char *argv[]) skip_argv = 1; //while(option != '\0') option++; if (strcmp(argv[argc_cnt], "tcp") == 0) @@ -386,7 +390,7 @@ diff -ru old/src/fuser.c new/src/fuser.c else usage(_ ("Invalid namespace name")); -@@ -1215,7 +1314,7 @@ +@@ -1215,7 +1314,7 @@ int main(int argc, char *argv[]) } #if defined(WITH_MOUNTINFO_LIST) @@ -395,7 +399,7 @@ diff -ru old/src/fuser.c new/src/fuser.c thestat = mntstat; #endif /* an option */ -@@ -1529,7 +1628,7 @@ +@@ -1529,7 +1628,7 @@ print_matches(struct names *names_head, } @@ -404,7 +408,7 @@ diff -ru old/src/fuser.c new/src/fuser.c { char pathname[256]; struct stat *st; -@@ -1541,6 +1640,15 @@ +@@ -1541,6 +1640,15 @@ static struct stat *get_pidstat(const pi free(st); return NULL; } @@ -420,7 +424,7 @@ diff -ru old/src/fuser.c new/src/fuser.c return st; } -@@ -1555,7 +1663,8 @@ +@@ -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; @@ -430,7 +434,7 @@ diff -ru old/src/fuser.c new/src/fuser.c char *dirpath; char filepath[PATH_MAX]; -@@ -1594,11 +1703,27 @@ +@@ -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) { @@ -438,6 +442,7 @@ diff -ru old/src/fuser.c new/src/fuser.c + 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 */ @@ -446,10 +451,11 @@ diff -ru old/src/fuser.c new/src/fuser.c + break; + } + } -+ ++ + if (!found) + continue; + } ++ + if (get_fdinfo(pid, direntry->d_name, &fd) != 0) + continue; + if (fd.mnt_id != dev_tmp->mnt_id) @@ -461,7 +467,7 @@ diff -ru old/src/fuser.c new/src/fuser.c add_matched_proc(dev_tmp->name, pid, uid, ACCESS_FILEWR | -@@ -1620,9 +1745,10 @@ +@@ -1620,9 +1747,10 @@ check_dir(const pid_t pid, const char *d continue; } if (st.st_ino == ino_tmp->inode) { @@ -474,7 +480,7 @@ diff -ru old/src/fuser.c new/src/fuser.c add_matched_proc(ino_tmp->name, pid, uid, ACCESS_FILEWR | -@@ -1651,31 +1777,54 @@ +@@ -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; @@ -539,7 +545,7 @@ diff -ru old/src/fuser.c new/src/fuser.c } fclose(fp); } -@@ -1699,6 +1848,7 @@ +@@ -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 */ @@ -547,16 +553,16 @@ diff -ru old/src/fuser.c new/src/fuser.c void fill_unix_cache(struct unixsocket_list **unixsocket_head) { FILE *fp; -@@ -1715,6 +1865,8 @@ +@@ -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; ++ int mnt_id = -1; ++ mntinfo_t *mountinfo; if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %llu %ms", &scanned_inode, &scanned_path) != 2) { if (scanned_path) -@@ -1730,6 +1882,8 @@ +@@ -1730,6 +1884,8 @@ void fill_unix_cache(struct unixsocket_l free(path); continue; } @@ -565,7 +571,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if ((newsocket = (struct unixsocket_list *) malloc(sizeof(struct unixsocket_list))) == NULL) { free(path); -@@ -1738,6 +1892,7 @@ +@@ -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; @@ -573,7 +579,7 @@ diff -ru old/src/fuser.c new/src/fuser.c newsocket->net_inode = scanned_inode; newsocket->next = *unixsocket_head; *unixsocket_head = newsocket; -@@ -1750,6 +1905,7 @@ +@@ -1750,6 +1907,7 @@ void fill_unix_cache(struct unixsocket_l /* * Free up the list of Unix sockets */ @@ -581,7 +587,7 @@ diff -ru old/src/fuser.c new/src/fuser.c void clear_unix_cache(struct unixsocket_list **unixsocket_head) { while(*unixsocket_head != NULL) { -@@ -1921,34 +2077,24 @@ +@@ -1921,34 +2079,21 @@ scan_mounts(struct names *names_head, st { struct device_list *dev_tmp; struct inode_list *ino_tmp; @@ -590,14 +596,14 @@ diff -ru old/src/fuser.c new/src/fuser.c - char *find_mountp; - char *find_space; struct stat st; - - if ( (ino_head == NULL) && (dev_head == NULL) ) - return; - + list_t *ptr; -+ list_for_each(ptr, &mntinfo) { -+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); -+ const char *find_mountp = mnt->mpoint; + +- 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); @@ -605,26 +611,26 @@ diff -ru old/src/fuser.c new/src/fuser.c - } - while (fgets(line, BUFSIZ, fp) != NULL) { - if ((find_mountp = strchr(line, ' ')) == NULL) -+ if (timeout(thestat, find_mountp, &st, 5) != 0) - continue; +- continue; - find_mountp++; - if ((find_space = strchr(find_mountp, ' ')) == NULL) - continue; - *find_space = '\0'; - if (timeout(thestat, find_mountp, &st, 5) != 0) { -- continue; ++ if (timeout(thestat, find_mountp, &st, 5) != 0) + continue; - } + /* Scan the devices */ for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) { - if (st.st_dev == dev_tmp->device) -+ if (st.st_dev == dev_tmp->device && -+ mnt->id == dev_tmp->mnt_id) ++ if (st.st_dev == dev_tmp->device && ++ mnt->id == dev_tmp->mnt_id) add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0, find_mountp); } -@@ -1960,7 +2106,6 @@ +@@ -1960,7 +2105,6 @@ scan_mounts(struct names *names_head, st find_mountp); } } @@ -632,7 +638,7 @@ diff -ru old/src/fuser.c new/src/fuser.c } static void -@@ -2013,16 +2158,44 @@ +@@ -2013,16 +2157,44 @@ scan_swaps(struct names *names_head, str fclose(fp); } @@ -681,7 +687,7 @@ diff -ru old/src/fuser.c new/src/fuser.c { list_t *ptr, *tmp; -@@ -2033,72 +2206,247 @@ +@@ -2033,72 +2205,247 @@ static void clear_mntinfo(void) } } @@ -741,7 +747,7 @@ diff -ru old/src/fuser.c new/src/fuser.c + mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ + } + } - } ++ } +#else + if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0) + return; @@ -752,7 +758,7 @@ diff -ru old/src/fuser.c new/src/fuser.c + 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; @@ -762,7 +768,7 @@ diff -ru old/src/fuser.c new/src/fuser.c + if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) + mntinf->vol = st.st_rdev; + } -+ } + } +#endif fclose(mnt); +} @@ -772,11 +778,11 @@ diff -ru old/src/fuser.c new/src/fuser.c +{ + 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) @@ -943,11 +949,11 @@ diff -ru old/src/fuser.c new/src/fuser.c - if (mid != mnt->parid) + + if (nlen != mnt->nlen) - continue; -- move_head(ptr, &sort); ++ continue; + + if (strcmp(use, mnt->mpoint)) -+ continue; + continue; +- move_head(ptr, &sort); + + ret = 0; + errno = 0; @@ -974,7 +980,7 @@ diff -ru old/src/fuser.c new/src/fuser.c /* * Determine device of links below /proc/ */ -@@ -2106,8 +2454,7 @@ +@@ -2106,8 +2453,7 @@ static int mntstat(const char *path, str { char name[PATH_MAX + 1]; const char *use; @@ -984,7 +990,7 @@ diff -ru old/src/fuser.c new/src/fuser.c if ((use = realpath(path, name)) == NULL || *use != '/') { -@@ -2119,27 +2466,26 @@ +@@ -2119,27 +2465,26 @@ static int mntstat(const char *path, str errno = 0; return stat(path, buf); } @@ -1030,16 +1036,15 @@ diff -ru old/src/fuser.c new/src/fuser.c } #endif /* WITH_MOUNTINFO_LIST */ -diff -ru old/src/fuser.h new/src/fuser.h ---- old/src/fuser.h 2019-11-12 11:23:38.000000000 +0100 -+++ new/src/fuser.h 2020-12-31 10:49:48.159279790 +0100 -@@ -37,10 +37,16 @@ +--- 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 { @@ -1051,7 +1056,7 @@ diff -ru old/src/fuser.h new/src/fuser.h struct procs *matched_procs; struct names *next; }; -@@ -65,12 +71,21 @@ +@@ -65,12 +71,21 @@ struct inode_list { struct names *name; dev_t device; ino_t inode; @@ -1073,7 +1078,7 @@ diff -ru old/src/fuser.h new/src/fuser.h struct device_list *next; }; -@@ -79,6 +94,7 @@ +@@ -79,6 +94,7 @@ struct unixsocket_list { ino_t inode; ino_t net_inode; dev_t dev; @@ -1081,7 +1086,7 @@ diff -ru old/src/fuser.h new/src/fuser.h struct unixsocket_list *next; }; -@@ -87,18 +103,16 @@ +@@ -87,18 +103,16 @@ struct mount_list { struct mount_list *next; }; @@ -1103,43 +1108,31 @@ diff -ru old/src/fuser.h new/src/fuser.h #define NAMESPACE_FILE 0 #define NAMESPACE_TCP 1 -@@ -109,5 +123,6 @@ +@@ -109,5 +123,6 @@ typedef struct mntinfo_s { #endif /* PATH_MAX */ #define KNFSD_EXPORTS "/proc/fs/nfs/exports" +#define PROC_MOUNTINFO "/proc/self/mountinfo" #define PROC_MOUNTS "/proc/mounts" #define PROC_SWAPS "/proc/swaps" -diff -ru old/testsuite/killall.test/killall.exp new/testsuite/killall.test/killall.exp ---- old/testsuite/killall.test/killall.exp 2019-11-12 11:23:38.000000000 +0100 -+++ new/testsuite/killall.test/killall.exp 2020-12-31 10:49:48.159279790 +0100 -@@ -7,7 +7,11 @@ +--- 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; - 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 -diff -ru old/testsuite/Makefile.am new/testsuite/Makefile.am ---- old/testsuite/Makefile.am 2019-11-12 11:23:38.000000000 +0100 -+++ new/testsuite/Makefile.am 2020-12-31 10:49:48.159279790 +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 -@@ -9,5 +11,4 @@ - DEJATOOL += fuser - endif - -- - EXTRA_DIST = + /* + * Using a forked process for doing e.g. stat(2) system call as this diff --git a/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch b/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch index e615934..d3c9eb1 100644 --- a/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch +++ b/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch @@ -1,7 +1,33 @@ -diff -ruN old/configure.ac new/configure.ac ---- old/configure.ac 2020-12-31 11:08:34.654310080 +0100 -+++ new/configure.ac 2020-12-31 11:07:25.506123358 +0100 -@@ -33,20 +33,6 @@ +From 9f3910df62bcc1f726b8e84f9ffc40c4d7916eac Mon Sep 17 00:00:00 2001 +From: Werner Fink +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 +--- + 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(-) + +--- Makefile.am ++++ Makefile.am 2021-01-14 11:29:22.011223930 +0000 +@@ -64,8 +64,8 @@ src_fuser_SOURCES = \ + src/fuser.h \ + src/lists.h + +-if WANT_TIMEOUT_STAT +-src_fuser_SOURCES += src/timeout.c src/timeout.h ++if HAVE_SYSCALL_STATX ++src_fuser_SOURCES += src/statx.c src/statx.h + endif + src_fuser_LDADD = @LIBINTL@ + src_killall_SOURCES = src/killall.c src/comm.h src/signals.c src/signals.h src/i18n.h +--- configure.ac ++++ 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]) @@ -22,7 +48,7 @@ diff -ruN old/configure.ac new/configure.ac # 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 @@ +@@ -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])]) @@ -53,181 +79,8 @@ diff -ruN old/configure.ac new/configure.ac # Enable hardened compile and link flags AC_ARG_ENABLE([harden_flags], -diff -ruN old/.idea/workspace.xml new/.idea/workspace.xml ---- old/.idea/workspace.xml 1970-01-01 01:00:00.000000000 +0100 -+++ new/.idea/workspace.xml 2020-12-31 11:08:03.610226251 +0100 -@@ -0,0 +1,43 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ 1609409125494 -+ -+ -+ -+ -\ No newline at end of file -diff -ruN old/Makefile.am new/Makefile.am ---- old/Makefile.am 2019-11-12 11:23:38.000000000 +0100 -+++ new/Makefile.am 2020-12-31 11:07:25.506123358 +0100 -@@ -64,8 +64,8 @@ - src/fuser.h \ - src/lists.h - --if WANT_TIMEOUT_STAT --src_fuser_SOURCES += src/timeout.c src/timeout.h -+if HAVE_SYSCALL_STATX -+src_fuser_SOURCES += src/statx.c src/statx.h - endif - src_fuser_LDADD = @LIBINTL@ - src_killall_SOURCES = src/killall.c src/comm.h src/signals.c src/signals.h src/i18n.h -diff -ruN old/Makefile.am.orig new/Makefile.am.orig ---- old/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100 -+++ new/Makefile.am.orig 2019-11-12 11:23:38.000000000 +0100 -@@ -0,0 +1,106 @@ -+ -+AM_CPPFLAGS = \ -+ -Wall \ -+ -DLOCALEDIR=\"$(localedir)\" \ -+ -I$(top_builddir)/src \ -+ @HARDEN_CFLAGS@ -+ -+AM_LDFLAGS = @HARDEN_LDFLAGS@ -+ -+ACLOCAL_AMFLAGS = -I m4 -+ -+SUBDIRS = \ -+ doc \ -+ po \ -+ icons \ -+ testsuite -+ -+bin_PROGRAMS = \ -+ src/killall \ -+ src/pslog \ -+ src/prtstat \ -+ src/pstree -+ -+if WANT_FUSER -+ bin_PROGRAMS += src/fuser -+endif -+if WANT_PEEKFD_I386 -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DI386 -+endif -+if WANT_PEEKFD_X86_64 -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DX86_64 -+endif -+if WANT_PEEKFD_PPC -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DPPC -+endif -+if WANT_PEEKFD_ARM -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DARM -+endif -+ -+if WANT_PEEKFD_ARM64 -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DARM64 -+endif -+ -+if WANT_PEEKFD_MIPS -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DMIPS -+endif -+if WANT_PEEKFD_M68K -+ bin_PROGRAMS += src/peekfd -+ AM_CPPFLAGS += -DM68K -+endif -+ -+src_fuser_SOURCES = \ -+ src/fuser.c \ -+ src/comm.h \ -+ src/signals.c \ -+ src/signals.h \ -+ src/i18n.h \ -+ src/fuser.h \ -+ src/lists.h -+ -+if WANT_TIMEOUT_STAT -+src_fuser_SOURCES += src/timeout.c src/timeout.h -+endif -+src_fuser_LDADD = @LIBINTL@ -+src_killall_SOURCES = src/killall.c src/comm.h src/signals.c src/signals.h src/i18n.h -+src_killall_LDADD = @LIBINTL@ @SELINUX_LIB@ -+src_peekfd_SOURCES = src/peekfd.c -+src_peekfd_LDADD = @LIBINTL@ -+src_pslog_SOURCES = src/pslog.c -+src_pstree_SOURCES = src/pstree.c src/comm.h src/i18n.h -+src_pstree_LDADD = @LIBINTL@ @TERMCAP_LIB@ @SELINUX_LIB@ -+src_prtstat_SOURCES = src/prtstat.c src/prtstat.h -+src_prtstat_LDADD = @LIBINTL@ -+nodist_src_killall_SOURCES = signames.h -+ -+BUILT_SOURCES = src/signames.h -+ -+EXTRA_DIST = src/signames.c README.md misc/git-version-gen -+ -+CLEANFILES = src/signames.h -+ -+src/signames.h: src/signames.c Makefile src/$(am__dirstamp) -+ export LC_ALL=C ; \ -+ @CPP@ -dM $< |\ -+ tr -s '\t ' ' ' | sort -n -k 3 | sed \ -+ 's:#define SIG\([A-Z][A-Z]*[0-9]*\) \([0-9][0-9]*\).*$\:{\ \2,"\1" },:p;d' | \ -+ grep -v '[0-9][0-9][0-9]' >$@ || \ -+ { rm -f $@; exit 1; } -+ grep '^{ 1,"HUP" },$$' $@ >/dev/null || \ -+ { rm -f $@; exit 1; } -+ -+src/signals.c: src/signames.h -+ -+install-exec-hook: -+ cd $(DESTDIR)$(bindir) && \ -+ ( [ -h pstree.x11 ] || $(LN_S) pstree pstree.x11) -+ -+ -+get-trans: -+ rsync -Lrtvz translationproject.org::tp/latest/psmisc/ po -diff -ruN old/src/fuser.c new/src/fuser.c ---- old/src/fuser.c 2020-12-31 11:08:34.658310092 +0100 -+++ new/src/fuser.c 2020-12-31 11:07:57.282209163 +0100 +--- src/fuser.c ++++ src/fuser.c 2021-01-14 11:30:10.750278604 +0000 @@ -63,7 +63,7 @@ #include "fuser.h" #include "signals.h" @@ -237,7 +90,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c #include "comm.h" //#define DEBUG 1 -@@ -118,10 +118,6 @@ +@@ -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); @@ -248,16 +101,16 @@ diff -ruN old/src/fuser.c new/src/fuser.c static char *expandpath(const char *path); static struct unixsocket_list *unixsockets = NULL; static struct names *names_head = NULL, *names_tail = NULL; -@@ -509,7 +505,7 @@ +@@ -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, -@@ -1245,9 +1241,7 @@ +@@ -1245,9 +1241,7 @@ int main(int argc, char *argv[]) opts |= OPT_INTERACTIVE; break; case 'I': @@ -267,7 +120,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c break; case 'k': opts |= OPT_KILL; -@@ -1313,10 +1307,11 @@ +@@ -1313,10 +1307,11 @@ int main(int argc, char *argv[]) continue; } @@ -282,7 +135,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c /* an option */ /* Not an option, must be a file specification */ if ((this_name = malloc(sizeof(struct names))) == NULL) -@@ -1636,7 +1631,7 @@ +@@ -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); @@ -291,7 +144,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c free(st); return NULL; } -@@ -1683,7 +1678,7 @@ +@@ -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); @@ -300,7 +153,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c if (errno != ENOENT && errno != ENOTDIR) { fprintf(stderr, _("Cannot stat file %s: %s\n"), filepath, strerror(errno)); -@@ -1738,7 +1733,7 @@ +@@ -1740,7 +1735,7 @@ check_dir(const pid_t pid, const char *d if (thedev != ino_tmp->device) continue; if (!st.st_ino @@ -309,7 +162,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c fprintf(stderr, _("Cannot stat file %s: %s\n"), filepath, strerror(errno)); -@@ -1836,11 +1831,11 @@ +@@ -1838,11 +1833,11 @@ static uid_t getpiduid(const pid_t pid) if (asprintf(&pathname, "/proc/%d", pid) < 0) return 0; @@ -325,7 +178,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c return st.st_uid; } -@@ -1878,7 +1873,7 @@ +@@ -1880,7 +1875,7 @@ void fill_unix_cache(struct unixsocket_l path = scanned_path; if (*scanned_path == '@') scanned_path++; @@ -334,7 +187,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c free(path); continue; } -@@ -2013,7 +2008,7 @@ +@@ -2015,7 +2010,7 @@ static dev_t find_net_dev(void) fprintf(stderr, _("Cannot open a network socket.\n")); return -1; } @@ -343,7 +196,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c fprintf(stderr, _("Cannot find socket's device number.\n")); close(skt); return -1; -@@ -2050,7 +2045,7 @@ +@@ -2052,7 +2047,7 @@ scan_knfsd(struct names *names_head, str if ((find_space = strpbrk(line, " \t")) == NULL) continue; *find_space = '\0'; @@ -352,16 +205,16 @@ diff -ruN old/src/fuser.c new/src/fuser.c continue; } /* Scan the devices */ -@@ -2087,7 +2082,7 @@ - mntinfo_t *mnt = list_entry(ptr, mntinfo_t); - const char *find_mountp = mnt->mpoint; +@@ -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; -- if (timeout(thestat, find_mountp, &st, 5) != 0) -+ if (statn(find_mountp, STATX_INO, &st) != 0) +- if (timeout(thestat, find_mountp, &st, 5) != 0) ++ if (statn(find_mountp, STATX_INO, &st) != 0) continue; /* Scan the devices */ -@@ -2137,7 +2132,7 @@ +@@ -2136,7 +2131,7 @@ scan_swaps(struct names *names_head, str if (*find_space == '\0') continue; } @@ -370,7 +223,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c continue; } /* Scan the devices */ -@@ -2229,10 +2224,10 @@ +@@ -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)); @@ -383,7 +236,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ } } -@@ -2244,7 +2239,7 @@ +@@ -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; @@ -391,8 +244,8 @@ diff -ruN old/src/fuser.c new/src/fuser.c + if (statn(mpoint, 0, &st) != 0) { if (errno != EACCES) { fprintf(stderr, _("Cannot stat %s: %s\n"), - mnt->mpoint, strerror(errno)); -@@ -2253,7 +2248,7 @@ + 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); @@ -401,7 +254,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) mntinf->vol = st.st_rdev; } -@@ -2303,7 +2298,7 @@ +@@ -2302,7 +2297,7 @@ out: struct stat lst; snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd); @@ -410,7 +263,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c if (lst.st_mode & S_IWUSR) info->flags |= O_WRONLY; ret++; -@@ -2376,7 +2371,7 @@ +@@ -2375,7 +2370,7 @@ find_mountpoint(const char *path, mntinf /* could be a chroot or a container */ @@ -419,7 +272,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c if (errno != EACCES) { fprintf(stderr, _("Cannot stat %s: %s\n"), path, strerror(errno)); -@@ -2408,7 +2403,7 @@ +@@ -2407,7 +2402,7 @@ find_mountpoint(const char *path, mntinf /* could be a chroot or a container */ @@ -428,7 +281,7 @@ diff -ruN old/src/fuser.c new/src/fuser.c if (errno != EACCES) { fprintf(stderr, _("Cannot stat %s: %s\n"), use, strerror(errno)); -@@ -2446,49 +2441,6 @@ +@@ -2445,49 +2440,6 @@ out: return ret; } @@ -478,9 +331,8 @@ diff -ruN old/src/fuser.c new/src/fuser.c /* * Somehow the realpath(3) glibc function call, nevertheless * it avoids lstat(2) system calls. -diff -ruN old/src/statx.c new/src/statx.c ---- old/src/statx.c 1970-01-01 01:00:00.000000000 +0100 -+++ new/src/statx.c 2020-12-31 11:07:25.506123358 +0100 +--- 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), @@ -631,9 +483,8 @@ diff -ruN old/src/statx.c new/src/statx.c + } + return ret; +} -diff -ruN old/src/statx.h new/src/statx.h ---- old/src/statx.h 1970-01-01 01:00:00.000000000 +0100 -+++ new/src/statx.h 2020-12-31 11:07:25.506123358 +0100 +--- 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), @@ -703,428 +554,3 @@ diff -ruN old/src/statx.h new/src/statx.h +#define STATX_ALL 0 +#endif +#endif -diff -ruN old/src/timeout.c new/src/timeout.c ---- old/src/timeout.c 2019-11-12 11:23:38.000000000 +0100 -+++ new/src/timeout.c 1970-01-01 01:00:00.000000000 +0100 -@@ -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 , 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 --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#if USE_SOCKETPAIR --# include --# include --# include --# 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 -- --#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 -ruN old/src/timeout.h new/src/timeout.h ---- old/src/timeout.h 2019-11-12 11:23:38.000000000 +0100 -+++ new/src/timeout.h 1970-01-01 01:00:00.000000000 +0100 -@@ -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 , 2011 -- */ -- --#ifndef _TIMEOUT_H --#define _TIMEOUT_H -- --#include "config.h" -- --#ifndef WITH_TIMEOUT_STAT --# define WITH_TIMEOUT_STAT 0 --#endif -- --#include --#include --#include --#include -- --#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 diff --git a/psmisc-v23.3-selinux.patch b/psmisc-v23.3-selinux.patch new file mode 100644 index 0000000..84a3e4f --- /dev/null +++ b/psmisc-v23.3-selinux.patch @@ -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 diff --git a/psmisc-v23.3.dif b/psmisc-v23.3.dif index bcaf6e3..aa80e2a 100644 --- a/psmisc-v23.3.dif +++ b/psmisc-v23.3.dif @@ -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 ]) --- 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 */ diff --git a/psmisc.changes b/psmisc.changes index 5efae84..46a0569 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Jan 14 11:58:43 UTC 2021 - Dr. Werner Fink + +- 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 diff --git a/psmisc.spec b/psmisc.spec index 09e04ec..a78e46d 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -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 @@ -40,6 +40,7 @@ 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 @@ -56,8 +57,9 @@ processes that are using specified files or filesystems. %prep %setup -q -n %{name}-v%{version} %patch2 -p0 -b .pstree -%patch3 -p1 -b .mntinf -%patch4 -p1 -b .statx +%patch3 -p0 -b .mntinf +%patch4 -p0 -b .statx +%patch5 -p0 -b .selx %patch0 -p0 -b .p0 %build From ddaf11107c39c27d555944de5357218963495fe0 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 14 Jan 2021 15:49:40 +0000 Subject: [PATCH 3/3] . OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=127 --- psmisc.changes | 5 +++++ psmisc.spec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/psmisc.changes b/psmisc.changes index 46a0569..b324e98 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jan 14 15:48:53 UTC 2021 - Dr. Werner Fink + +- Now with 23.3 peekfd is build even for aarch64 + ------------------------------------------------------------------- Thu Jan 14 11:58:43 UTC 2021 - Dr. Werner Fink diff --git a/psmisc.spec b/psmisc.spec index a78e46d..fa6e13e 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -42,7 +42,7 @@ 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