commit 6ec8202a8ffab8d02aef9d4e18f1e6bbf6f2c4c072ca54a25c365e9947e04208 Author: Adrian Schröter Date: Fri May 3 19:39:56 2024 +0200 Sync from SUSE:SLFO:Main psmisc revision 74b38a5ff36fafb9a1443fef7ebcb74a diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text 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 new file mode 100644 index 0000000..8e491c0 --- /dev/null +++ b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch @@ -0,0 +1,1262 @@ +From e5ba304260af6a93c7af03f6bc29e1d3472ef442 Mon Sep 17 00:00:00 2001 +From: Werner Fink +Date: Wed, 23 Nov 2022 14:51:53 +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 + +Fuser does not show open kvm storage image files +such as qcow2 files. Patch from Ali Abdallah + +Correct last change by using our own namespace to +determine the appropriate mount ID for e.g. qcow2 files. + +Determine the namespace of a process only once to speed +up the parsing of fdinfo. + +Add a fallback if the system call name_to_handle_at() is +not supported by the used file system. + +Avoid foreign namespaces as well as mount IDs for +sockets. Expand paths also for named sockets. + +Signed-off-by: Werner Fink +--- + configure.ac | 18 +- + src/fuser.c | 763 +++++++++++++++++++++++++++++++++++++++++++++------ + src/fuser.h | 26 +- + 3 files changed, 721 insertions(+), 86 deletions(-) + +diff --git configure.ac configure.ac +index 723cf02..3599fea 100644 +--- configure.ac ++++ configure.ac +@@ -12,6 +12,7 @@ AC_USE_SYSTEM_EXTENSIONS(_GNU_SOURCE) + AC_PROG_CXX + AC_PROG_LN_S + AC_PROG_CC ++AC_PROG_CC_STDC + + AC_DEFUN([PSMISC_PROG_PO4A], [ + AC_REQUIRE([AM_NLS]) +@@ -62,6 +63,19 @@ if test "$enable_apparmor" = "yes"; then + fi + AC_SUBST([DL_LIB]) + ++# 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]) ++fi ++# Use /proc/self/fdinfo if available ++if test -e /proc/self/fdinfo ; then ++ AC_DEFINE([HAS_FDINFO], [1], [System has /proc/self/fdinfo for informations on file descriptors]) ++fi ++ ++# Check for Linux specific name_to_handle_at(2) system call for getting mount IDs ++AC_CHECK_FUNC([name_to_handle_at],[ ++ AC_DEFINE([HAS_NAME_TO_HANDLE_AT], [1], [System has name_to_handle_at(2) system call])]) ++ + AC_CHECK_HEADERS([sys/syscall.h]) + AC_CHECK_DECLS([SYS_statx], + [has_syscall_statx="yes"], +@@ -105,9 +119,9 @@ AC_SUBST([TERMCAP_LIB]) + + dnl Checks for header files. + AC_HEADER_DIRENT +- ++AC_HEADER_STDC + AC_HEADER_SYS_WAIT +-AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h libintl.h limits.h locale.h mntent.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h termios.h unistd.h]) ++AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h libintl.h limits.h locale.h mntent.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/mount.h sys/param.h sys/stat.h sys/socket.h sys/types.h termios.h unistd.h]) + + dnl Checks for typedefs, structures, and compiler characteristics. + AC_C_CONST +diff --git src/fuser.c src/fuser.c +index f2bd3e9..8e4c853 100644 +--- src/fuser.c ++++ src/fuser.c +@@ -32,6 +32,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -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); +-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); + static uid_t getpiduid(const pid_t pid); + static int print_matches(struct names *names_head, const opt_type opts, + const int sig_number); +@@ -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, +- struct names *this_name, dev_t device); +-void fill_unix_cache(struct unixsocket_list **unixsocket_head); +-void clear_unix_cache(struct unixsocket_list **unixsocket_head); ++ struct names *this_name, dev_t device, dev_t subvol); ++static void fill_unix_cache(struct unixsocket_list **unixsocket_head); ++static void clear_unix_cache(struct unixsocket_list **unixsocket_head); + static void atexit_clear_unix_cache(); + static dev_t find_net_dev(void); + static void scan_procs( +@@ -123,6 +125,15 @@ static void debug_match_lists( + struct device_list *dev_head); + #endif + ++static list_t mntinfo = { &mntinfo, &mntinfo }; ++static void clear_mntinfo(void) __attribute__ ((__destructor__)); ++static void init_mntinfo(void) __attribute__ ((__constructor__)); ++static int get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info, const ino_t ns); ++#if defined(HAS_NAME_TO_HANDLE_AT) ++static ino_t get_namespace(const pid_t pid); ++static int get_mountid(const char *path); ++#endif ++static int find_mountpoint(const char *path, mntinfo_t **mountinfo); + static char *expandpath(const char *path); + static struct unixsocket_list *unixsockets = NULL; + static struct names *names_head = NULL, *names_tail = NULL; +@@ -167,6 +178,7 @@ static void usage( + fprintf(stderr, _(" -4,--ipv4 search IPv4 sockets only\n" + " -6,--ipv6 search IPv6 sockets only\n")); + #endif ++ fprintf(stderr, _(" - reset options\n\n")); + fprintf(stderr, _(" udp/tcp names: [local_port][,[rmt_host][,[rmt_port]]]\n\n")); + exit(1); + } +@@ -209,6 +221,7 @@ static void scan_procs( + struct stat *cwd_stat = NULL; + struct stat *exe_stat = NULL; + struct stat *root_stat = NULL; ++ int cwd_id, exe_id, root_id; + + if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */ + continue; +@@ -218,49 +231,64 @@ static void scan_procs( + continue; + uid = getpiduid(pid); + +- cwd_stat = get_pidstat(pid, "cwd"); +- exe_stat = get_pidstat(pid, "exe"); +- root_stat = get_pidstat(pid, "root"); ++ cwd_stat = get_pidstat(pid, "cwd", &cwd_id); ++ exe_stat = get_pidstat(pid, "exe", &exe_id); ++ root_stat = get_pidstat(pid, "root", &root_id); + 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; + + /* Scan the devices */ +- for (dev_tmp = dev_head; dev_tmp != NULL; +- dev_tmp = dev_tmp->next) { +- if (exe_dev == dev_tmp->device) +- add_matched_proc(dev_tmp->name, pid, uid, +- ACCESS_EXE); +- if (root_dev == dev_tmp->device) +- add_matched_proc(dev_tmp->name, pid, uid, +- ACCESS_ROOT); +- if (cwd_dev == dev_tmp->device) +- add_matched_proc(dev_tmp->name, pid, uid, +- ACCESS_CWD); ++ for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) ++ { ++ struct subvol *vol_tmp; ++ char access = 0; ++ if (exe_dev == dev_tmp->device && dev_tmp->mnt_id == exe_id) ++ access |= ACCESS_EXE; ++ if (root_dev == dev_tmp->device && dev_tmp->mnt_id == root_id) ++ access |= ACCESS_ROOT; ++ if (cwd_dev == dev_tmp->device && dev_tmp->mnt_id == cwd_id) ++ access |= ACCESS_CWD; ++ for (vol_tmp = dev_tmp->vol; vol_tmp != NULL; vol_tmp = vol_tmp->next) ++ { ++ /* For BtrFS sub volumes there are different ++ mount ids for the same device */ ++ if (exe_dev == vol_tmp->device && vol_tmp->mnt_id == exe_id) ++ access |= ACCESS_EXE; ++ if (root_dev == vol_tmp->device && vol_tmp->mnt_id == root_id) ++ access |= ACCESS_ROOT; ++ if (cwd_dev == vol_tmp->device && vol_tmp->mnt_id == cwd_id) ++ access |= ACCESS_CWD; ++ } ++ if (access) ++ add_matched_proc(dev_tmp->name, pid, uid, access); + } +- for (ino_tmp = ino_head; ino_tmp != NULL; +- ino_tmp = ino_tmp->next) { +- if (exe_dev == ino_tmp->device) { ++ for (ino_tmp = ino_head; ino_tmp != NULL; ino_tmp = ino_tmp->next) ++ { ++ if (exe_dev == ino_tmp->device && ino_tmp->mnt_id == exe_id) ++ { + if (!exe_stat) +- exe_stat = get_pidstat(pid, "exe"); ++ exe_stat = get_pidstat(pid, "exe", NULL); + if (exe_stat + && exe_stat->st_dev == ino_tmp->device + && exe_stat->st_ino == ino_tmp->inode) + add_matched_proc(ino_tmp->name, pid, + uid, ACCESS_EXE); + } +- if (root_dev == ino_tmp->device) { ++ if (root_dev == ino_tmp->device && ino_tmp->mnt_id == root_id) ++ { + if (!root_stat) +- root_stat = get_pidstat(pid, "root"); ++ root_stat = get_pidstat(pid, "root", NULL); + if (root_stat + && root_stat->st_dev == ino_tmp->device + && root_stat->st_ino == ino_tmp->inode) + add_matched_proc(ino_tmp->name, pid, + uid, ACCESS_ROOT); + } +- if (cwd_dev == ino_tmp->device) { ++ if (cwd_dev == ino_tmp->device && ino_tmp->mnt_id == cwd_id) ++ { + if (!cwd_stat) +- cwd_stat = get_pidstat(pid, "cwd"); ++ cwd_stat = get_pidstat(pid, "cwd", NULL); + if (cwd_stat + && cwd_stat->st_dev == ino_tmp->device + && cwd_stat->st_ino == ino_tmp->inode) +@@ -302,20 +330,48 @@ static void add_inode( + ino_tmp->name = this_name; + ino_tmp->device = device; + ino_tmp->inode = inode; ++ ino_tmp->mnt_id = this_name->mnt_id; + ino_tmp->next = ino_head; + *ino_list = ino_tmp; + } ++ ++static void add_subvol( ++ struct subvol **head, ++ dev_t device, ++ int mnt_id) ++{ ++ struct subvol *vol_tmp, *vol_head; ++ ++ if ((vol_tmp = ++ (struct subvol *)malloc(sizeof(struct subvol))) == NULL) ++ return; ++ vol_head = *head; ++ vol_tmp->device = device; ++ vol_tmp->mnt_id = mnt_id; ++ vol_tmp->next = vol_head; ++ *head = vol_tmp; ++} + + static void add_device( + struct device_list **dev_list, + struct names *this_name, +- dev_t device) ++ dev_t device, ++ dev_t subvol) + { + struct device_list *dev_tmp, *dev_head; + #ifdef DEBUG + fprintf(stderr, "add_device(%s %u\n", this_name->filename, +- (unsigned int)device); +-#endif /* DEBUG */ ++ (unsigned int)device); ++#endif /* DEBUG */ ++ /* For BtrFS there are many sub volumes all on the same block device */ ++ for (dev_tmp = *dev_list; dev_tmp != NULL; dev_tmp = dev_tmp->next) ++ if (dev_tmp->device == device) ++ { ++ if (dev_tmp->device != subvol) ++ add_subvol(&dev_tmp->vol, subvol, this_name->mnt_id); ++ *dev_list = dev_tmp; ++ return; ++ } + + if ((dev_tmp = + (struct device_list *)malloc(sizeof(struct device_list))) == NULL) +@@ -323,6 +379,10 @@ static void add_device( + dev_head = *dev_list; + dev_tmp->name = this_name; + dev_tmp->device = device; ++ dev_tmp->mnt_id = this_name->mnt_id; ++ dev_tmp->vol = NULL; ++ if (dev_tmp->device != subvol) ++ add_subvol(&dev_tmp->vol, subvol, this_name->mnt_id); + dev_tmp->next = dev_head; + *dev_list = dev_tmp; + } +@@ -480,6 +540,7 @@ int parse_file( + struct inode_list **ino_list, + const opt_type opts) + { ++ mntinfo_t *mountinfo; + char *new = expandpath(this_name->filename); + if (new) + { +@@ -487,7 +548,8 @@ int parse_file( + free(this_name->filename); + this_name->filename = strdup(new); + } +- if (statn(this_name->filename, STATX_INO|STATX_TYPE, &(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, +@@ -498,10 +560,12 @@ int parse_file( + this_name->filename, strerror(errno)); + return -1; + } ++ this_name->mnt_id = mountinfo->id; + #ifdef DEBUG +- printf("adding file %s %lX %lX\n", this_name->filename, ++ printf("adding file %s %lX %lX %d nfs=%s\n", this_name->filename, + (unsigned long)this_name->st.st_dev, +- (unsigned long)this_name->st.st_ino); ++ (unsigned long)this_name->st.st_ino, ++ mountinfo->id, mountinfo->isremote ? "yes" : "no"); + #endif /* DEBUG */ + add_inode(ino_list, this_name, this_name->st.st_dev, + this_name->st.st_ino); +@@ -537,12 +601,45 @@ int parse_mounts( + const opt_type opts) + { + dev_t match_device; ++ list_t *ptr; ++ int count; + + if (S_ISBLK(this_name->st.st_mode)) + match_device = this_name->st.st_rdev; + else + match_device = this_name->st.st_dev; +- add_device(dev_list, this_name, match_device); ++ ++ count = 0; ++ list_for_each(ptr, &mntinfo) ++ { ++ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); ++ if (match_device != mnt->dev) ++ continue; ++ if (S_ISBLK(this_name->st.st_mode)) ++ { ++ /* Correct mount IDs check if a block device ++ * was specified */ ++ this_name->mnt_id = mnt->id; ++ add_device(dev_list, this_name, match_device, mnt->dev); ++ if (mnt->dev == mnt->vol) ++ count++; ++ else count = 1; ++ continue; ++ } ++ if (this_name->mnt_id != mnt->id) ++ continue; ++ count++; ++ } ++ if (count == 0) ++ { ++ errno = ENOENT; ++ fprintf(stderr, _("Specified filename %s has no mountpoint.\n"), ++ this_name->filename); ++ return -1; ++ } ++ if (S_ISBLK(this_name->st.st_mode)) ++ return 0; ++ add_device(dev_list, this_name, match_device, match_device); + return 0; + } + +@@ -1010,6 +1107,22 @@ static void free_inodes( + /* + * Free up structures allocated in add_device + */ ++ ++static void free_subvol( ++ struct subvol **volumes) ++{ ++ struct subvol *vol_tmp, *vol_next; ++ ++ vol_tmp = *volumes; ++ while (vol_tmp != NULL) ++ { ++ vol_next = vol_tmp->next; ++ free(vol_tmp); ++ vol_tmp = vol_next; ++ } ++ *volumes =NULL; ++} ++ + static void free_devices( + struct device_list **match_devices) + { +@@ -1018,6 +1131,8 @@ static void free_devices( + device_tmp = *match_devices; + while(device_tmp != NULL) + { ++ if (device_tmp->vol) ++ free_subvol(&device_tmp->vol); + device_next = device_tmp->next; + free(device_tmp); + device_tmp = device_next; +@@ -1273,8 +1388,8 @@ int main(int argc, char *argv[]) + } + + #if defined(HAVE_DECL_SYS_STATX) && HAVE_DECL_SYS_STATX == 1 +- if ((opts & OPT_ALWAYSSTAT)) +- stat_flags = 0; /* Triggers sync with e.g. remote NFS server even on autofs */ ++ if ((opts & OPT_ALWAYSSTAT)) ++ stat_flags = 0; /* Triggers sync with e.g. remote NFS server even on autofs */ + #endif + /* an option */ + /* Not an option, must be a file specification */ +@@ -1589,7 +1704,8 @@ static int print_matches( + + static struct stat *get_pidstat( + const pid_t pid, +- const char *filename) ++ const char *filename, ++ int *id) + { + char pathname[PATH_MAX]; + struct stat *st; +@@ -1602,6 +1718,16 @@ static struct stat *get_pidstat( + free(st); + return NULL; + } ++ ++ if (id) ++ { ++ mntinfo_t *info; ++ char *new = expandpath(pathname); ++ if (new && find_mountpoint(new, &info) == 0) ++ *id = info->id; ++ else *id = -1; ++ } ++ + return st; + } + +@@ -1621,10 +1747,11 @@ static void check_dir( + struct inode_list *ino_tmp; + struct device_list *dev_tmp; + struct unixsocket_list *sock_tmp; +- struct stat st, lst; ++ struct stat st; + char *dirpath; + char filepath[PATH_MAX]; + char real_filepath[PATH_MAX]; ++ ino_t ns; + + if (asprintf(&dirpath, "/proc/%d/%s", pid, dirname) < 0) + return; +@@ -1635,6 +1762,12 @@ static void check_dir( + } + free(dirpath); + ++#if defined(HAS_NAME_TO_HANDLE_AT) ++ ns = get_namespace(pid); ++#else ++ ns = -1; ++#endif ++ + while ((direntry = readdir(dirp)) != NULL) + { + if (direntry->d_name[0] < '0' || direntry->d_name[0] > '9') +@@ -1643,7 +1776,7 @@ static void check_dir( + snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s", + pid, dirname, direntry->d_name); + +- if (statn(filepath, STATX_INO, &st) != 0) ++ if (statn(filepath, STATX_INO, &st) != 0) + { + if (errno != ENOENT && errno != ENOTDIR) + { +@@ -1651,6 +1784,9 @@ static void check_dir( + filepath, strerror(errno)); + } + } else { ++ struct fdinfo fd; ++ int fdret; ++ + thedev = st.st_dev; + if (thedev == netdev) + { +@@ -1666,11 +1802,32 @@ static void check_dir( + } + } + } ++ ++ memset(&fd, 0, sizeof(struct fdinfo)); ++ fdret = get_fdinfo(pid, direntry->d_name, &fd, ns); ++ + for (dev_tmp = dev_head; dev_tmp != NULL; + dev_tmp = dev_tmp->next) + { + if (thedev != dev_tmp->device) +- continue; ++ { ++ 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 */ ++ if (thedev == vol_tmp->device) ++ { ++ subvol_found++; ++ break; ++ } ++ } ++ ++ if (!subvol_found) ++ continue; ++ } + + /* check the paths match if it is not a block device or socket */ + if (! S_ISBLK(dev_tmp->name->st.st_mode) +@@ -1686,10 +1843,14 @@ static void check_dir( + strlen(dev_tmp->name->filename)) != 0) + continue; + } ++ if (fdret != 0) ++ continue; ++ if (fd.mnt_id != dev_tmp->mnt_id) ++ continue; + } ++ + if (access == ACCESS_FILE +- && (lstat(filepath, &lst) == 0) +- && (lst.st_mode & S_IWUSR)) ++ && (fd.flags & (O_WRONLY|O_RDWR))) + { + add_matched_proc(dev_tmp->name, pid, uid, + ACCESS_FILEWR | access); +@@ -1709,9 +1870,10 @@ static void check_dir( + } + if (st.st_ino == ino_tmp->inode) + { ++ if (fdret != 0) ++ continue; + if (access == ACCESS_FILE +- && (lstat(filepath, &lst) == 0) +- && (lst.st_mode & S_IWUSR)) ++ && (fd.flags & (O_WRONLY|O_RDWR))) + { + add_matched_proc(ino_tmp->name, pid, uid, + ACCESS_FILEWR | access); +@@ -1740,7 +1902,6 @@ static void check_map( + FILE *fp; + unsigned long long tmp_inode; + unsigned int tmp_maj, tmp_min; +- dev_t tmp_device; + + if (asprintf(&pathname, "/proc/%d/%s", pid, filename) < 0) + return; +@@ -1752,18 +1913,47 @@ static void check_map( + free(pathname); + while (fgets(line, BUFSIZ, fp)) + { +- if (sscanf(line, "%*s %*s %*s %x:%x %lld", +- &tmp_maj, &tmp_min, &tmp_inode) == 3) ++ char *scanned_path = NULL; ++ if (sscanf(line, "%*s %*s %*s %x:%x %lld %ms", ++ &tmp_maj, &tmp_min, &tmp_inode, &scanned_path) == 4) + { +- tmp_device = tmp_maj * 256 + tmp_min; ++ dev_t tmp_device = makedev(tmp_maj, tmp_min); ++ int mnt_id = -1; ++ ++ if (scanned_path) ++ { ++ if (*scanned_path == '/') ++ { ++ mntinfo_t *mountinfo; ++ if (find_mountpoint(scanned_path, &mountinfo) == 0) ++ mnt_id = mountinfo->id; ++ } ++ free(scanned_path); ++ } ++ + for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) +- if (dev_tmp->device == tmp_device) ++ { ++ struct subvol *vol_tmp; ++ ++ if (dev_tmp->device == tmp_device && mnt_id == dev_tmp->mnt_id) + add_matched_proc(dev_tmp->name, pid, uid, access); ++ ++ for (vol_tmp = dev_tmp->vol; vol_tmp != NULL; vol_tmp = vol_tmp->next) ++ { ++ /* For BtrFS sub volumes there are different ++ mount ids for the same device */ ++ if (vol_tmp->device == tmp_device ++ && mnt_id == vol_tmp->mnt_id) ++ ++ add_matched_proc(dev_tmp->name, pid, uid, access); ++ } ++ } + for (ino_tmp = ino_head; ino_tmp != NULL; ino_tmp = ino_tmp->next) + if (ino_tmp->device == tmp_device + && ino_tmp->inode == tmp_inode) + add_matched_proc(ino_tmp->name, pid, uid, access); +- } ++ } else if (scanned_path) ++ free(scanned_path); + } + fclose(fp); + } +@@ -1789,7 +1979,7 @@ static uid_t getpiduid( + * fill_unix_cache : Create a list of Unix sockets + * This list is used later for matching purposes + */ +-void fill_unix_cache( ++static void fill_unix_cache( + struct unixsocket_list **unixsocket_head) + { + FILE *fp; +@@ -1808,6 +1998,8 @@ void fill_unix_cache( + { + char *path; + char *scanned_path = NULL; ++ int mnt_id = -1; ++ mntinfo_t *mountinfo; + if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %llu %ms", + &scanned_inode, &scanned_path) != 2) + { +@@ -1820,11 +2012,13 @@ void fill_unix_cache( + path = scanned_path; + if (*scanned_path == '@') + scanned_path++; +- if (statn(scanned_path, STATX_INO, &st) < 0) ++ if (statn(scanned_path, STATX_INO, &st) < 0) + { + free(path); + continue; + } ++ if (find_mountpoint(scanned_path, &mountinfo) == 0) ++ mnt_id = mountinfo->id; + if ((newsocket = (struct unixsocket_list *) + malloc(sizeof(struct unixsocket_list))) == NULL) + { +@@ -1834,6 +2028,7 @@ void fill_unix_cache( + newsocket->sun_name = strdup(scanned_path); + newsocket->inode = st.st_ino; + newsocket->dev = st.st_dev; ++ newsocket->mnt_id = mnt_id; + newsocket->net_inode = scanned_inode; + newsocket->next = *unixsocket_head; + *unixsocket_head = newsocket; +@@ -1846,7 +2041,7 @@ void fill_unix_cache( + /* + * Free up the list of Unix sockets + */ +-void clear_unix_cache( ++static void clear_unix_cache( + struct unixsocket_list **unixsocket_head) + { + while(*unixsocket_head != NULL) +@@ -2037,47 +2232,32 @@ static void scan_mounts( + { + struct device_list *dev_tmp; + struct inode_list *ino_tmp; +- FILE *fp; +- char line[BUFSIZ]; +- char *find_mountp; +- char *find_space; + struct stat st; ++ list_t *ptr; + + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + +- +- if ((fp = fopen(PROC_MOUNTS, "r")) == NULL) ++ list_for_each(ptr, &mntinfo) + { +- fprintf(stderr, "Cannot open %s\n", PROC_MOUNTS); +- return; +- } +- while (fgets(line, BUFSIZ, fp) != NULL) +- { +- if ((find_mountp = strchr(line, ' ')) == NULL) +- continue; +- find_mountp++; +- if ((find_space = strchr(find_mountp, ' ')) == NULL) +- continue; +- *find_space = '\0'; +- if (statn(find_mountp, STATX_INO, &st) != 0) ++ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); ++ const char *find_mountp = mnt->mpoint; ++ ++ if (statn(find_mountp, STATX_INO, &st) != 0) + continue; ++ + /* Scan the devices */ +- for (dev_tmp = dev_head; dev_tmp != NULL; +- dev_tmp = dev_tmp->next) ++ 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) + add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0, find_mountp); + } +- for (ino_tmp = ino_head; ino_tmp != NULL; +- ino_tmp = ino_tmp->next) ++ for (ino_tmp = ino_head; ino_tmp != NULL; ino_tmp = ino_tmp->next) + { +- if (st.st_dev == ino_tmp->device +- && st.st_ino == ino_tmp->inode) ++ if (st.st_dev == ino_tmp->device && st.st_ino == ino_tmp->inode) + add_special_proc(ino_tmp->name, PTYPE_MOUNT, 0, find_mountp); + } + } +- fclose(fp); + } + + static void scan_swaps( +@@ -2113,7 +2293,7 @@ static void scan_swaps( + if (*find_space == '\0') + continue; + } +- if (statn(line, STATX_INO, &st) != 0) ++ if (statn(line, STATX_INO, &st) != 0) + continue; + + /* Scan the devices */ +@@ -2134,6 +2314,385 @@ static void scan_swaps( + fclose(fp); + } + ++/* ++ * Use /proc/self/mountinfo of modern linux system to determine ++ * the device numbers of the mount points. Use this to avoid the ++ * stat(2) system call for remote file system. ++ */ ++ ++static mntinfo_t* add_mntinfo( ++ const char *mpoint, ++ const char *type, ++ int mid, ++ int parid, ++ dev_t dev) ++{ ++ const size_t nlen = strlen(mpoint); ++ mntinfo_t *restrict mnt; ++ if (posix_memalign((void *)&mnt, sizeof(void *), ++ alignof(mntinfo_t) + (nlen + 1)) != 0) ++ { ++ fprintf(stderr, _("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 = dev; ++ mnt->id = mid; ++ if (strncmp("nfs", type, 3) == 0 || strncmp("afs", type, 3) == 0 || strncmp("autofs", type, 6)) ++ mnt->isremote = 1; ++ else mnt->isremote = 0; ++ /* E.g. sub volumes of BtrFS do not show main device number in ++ /proc/self/mountinfo, for now just map the device to this */ ++ mnt->vol = dev; ++ return mnt; ++} ++ ++static void clear_mntinfo(void) ++{ ++ list_t *ptr, *tmp; ++ ++ list_for_each_safe(ptr, tmp, &mntinfo) ++ { ++ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); ++ delete(ptr); ++ free(mnt); ++ } ++} ++ ++static void init_mntinfo(void) ++{ ++ char type[256]; ++ char mpoint[PATH_MAX *4 + 1]; // octal escaping takes 4 chars per 1 char ++ char devname[PATH_MAX]; ++ int mid, parid; ++ mntinfo_t *mntinf; ++#if defined(HAS_MOUNTINFO) ++ uint maj, min; ++#endif ++ FILE *mnt; ++ ++ if (!list_empty(&mntinfo)) ++ return; ++#if defined(HAS_MOUNTINFO) ++ /* ++ * We could also loop over all mount namespaces, that is not only ++ * over /proc/self/ns/mnt. But this expands this list as well as ++ * we can use name_to_handle_at(2) in our get_mountid() function. ++ */ ++ if ((mnt = fopen(PROC_MOUNTINFO, "r")) == (FILE *) 0) ++ return; ++ while (fscanf (mnt, "%i %i %u:%u %*s %s %*[^-] - %s %s %*[^\n]", ++ &mid, &parid, &maj, &min, &mpoint[0], &type[0], &devname[0]) == 7) ++ { ++ struct stat st; ++ mntinf = add_mntinfo(mpoint, type, mid, parid, makedev(maj, min)); ++ if (mntinf && strncmp(devname, "/dev/", 5) == 0 && statn(devname, 0, &st) == 0) ++ { ++ if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) ++ { ++ mntinf->vol = st.st_rdev; ++ statn(mpoint, 0, &st); ++ mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ ++ } ++ } ++ } ++#else ++ if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0) ++ return; ++ mid = 1; ++ parid = -1; ++ while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) ++ { ++ struct stat st; ++ if (statn(mpoint, 0, &st) != 0) ++ { ++ if (errno != EACCES) ++ { ++ fprintf(stderr, _("Cannot stat %s: %s\n"), mpoint, strerror(errno)); ++ exit(1); ++ } ++ st.st_dev = (dev_t)-1; ++ } ++ mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev); ++ if (mntinf && strncmp(devname, "/dev/", 5) == 0 && statn(devname, 0, &st) == 0) ++ { ++ if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) ++ mntinf->vol = st.st_rdev; ++ } ++ } ++#endif ++ fclose(mnt); ++} ++ ++static int get_fdinfo( ++ const pid_t pid, ++ const char *fd, ++ struct fdinfo *info, ++ const ino_t ns) ++{ ++ int ret = 0; ++ char pathname[512]; ++ int mnt_id = 0, flags = 0; ++#if defined(HAS_FDINFO) /* Here we get the private namespace as well */ ++ const static char delimiters[] = ": \t\n"; ++ char line[BUFSIZ]; ++ FILE *fp; ++# if defined(HAS_NAME_TO_HANDLE_AT) ++ char *realname; ++# endif ++ ++ snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fdinfo/%s", pid, fd); ++ if ((fp = fopen(pathname, "r")) == NULL) ++ goto out; ++ ++ while (fgets(line, BUFSIZ, fp) && ret < 1) ++ { ++ char *xp, *vp, *ep; ++ unsigned long ul; ++ xp = strtok(&line[0], delimiters); ++ if (!xp || *xp == 0) ++ continue; ++ vp = strtok(NULL, delimiters); ++ if (!vp || *vp == 0) ++ continue; ++ if (strcmp(xp, "flags") == 0 && (ul = strtoul(vp, &ep, 0)) != ULONG_MAX && ep && *ep == 0) ++ { ++ info->flags = (mode_t)ul; ++ flags++; ++ ret++; ++ break; ++ } ++ } ++ fclose(fp); ++out: ++# if defined(HAS_NAME_TO_HANDLE_AT) ++ snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, fd); ++ realname = expandpath(pathname); ++ if (realname) ++ { ++ info->mnt_id = get_mountid(realname); ++ mnt_id++; ++ ret++; ++ } ++# endif ++#endif ++ if (!flags || !mnt_id) ++ { ++ struct stat lst; ++ ++ snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, fd); ++ if (!flags && lstatn(pathname, STATX_MODE, &lst) == 0) ++ { ++ if (lst.st_mode & S_IWUSR) ++ info->flags |= O_WRONLY; ++ ret++; ++ } ++ ++ if (!mnt_id) ++ { ++ realname = expandpath(pathname); ++ if (realname) ++ { ++ mntinfo_t *mountinfo; ++ if (find_mountpoint(realname, &mountinfo) == 0) ++ { ++ info->mnt_id = mountinfo->id; ++ ret++; ++ } ++ } ++ } ++ } ++ ++ return ret == 2 ? 0 : -1; ++} ++ ++#if defined(HAS_NAME_TO_HANDLE_AT) ++static ino_t get_namespace( ++ const pid_t pid) ++{ ++ char pathname[512]; ++ struct stat st; ++ snprintf(pathname, sizeof(pathname)-1, "/proc/%d/ns/mnt", pid); ++ if (statn(pathname, STATX_INO, &st) == 0) ++ return st.st_ino; ++ return -1; ++} ++ ++static int get_mountid( ++ const char *path) ++{ ++ union fh_u { ++ struct file_handle handle; ++ char buffer[sizeof(struct file_handle) + MAX_HANDLE_SZ]; ++ } fh = { .handle.handle_bytes = MAX_HANDLE_SZ }; ++ int mnt_id = -1; ++ ++ errno = 0; ++ if (name_to_handle_at(0, path, &fh.handle, &mnt_id, 0) == -1) ++ { ++ const static char delimiters[] = ": \t\n"; ++ char fdinfo[PATH_MAX+1]; ++ char line[BUFSIZ]; ++ FILE* fp; ++ int fd; ++ ++ if (errno != EOPNOTSUPP) ++ return -1; ++ fd = open(path, O_PATH); ++ if (fd < 0) ++ return -1; ++ ++ snprintf(fdinfo, PATH_MAX, "/proc/self/fdinfo/%d", fd); ++ if ((fp = fopen(fdinfo, "r")) == NULL) ++ { ++ close(fd); ++ return -1; ++ } ++ while (fgets(line, BUFSIZ, fp)) ++ { ++ char *xp, *vp, *ep; ++ unsigned long ul; ++ xp = strtok(&line[0], delimiters); ++ if (!xp || *xp == 0) ++ continue; ++ vp = strtok(NULL, delimiters); ++ if (!vp || *vp == 0) ++ continue; ++ if (strcmp(xp, "mnt_id") == 0 && (ul = strtoul(vp, &ep, 0)) != ULONG_MAX && ep && *ep == 0) ++ { ++ mnt_id = (int)ul; ++ break; ++ } ++ } ++ fclose(fp); ++ close(fd); ++ } ++ return mnt_id; ++} ++#endif ++ ++static int find_mountpoint( ++ const char *path, ++ mntinfo_t **mountinfo) ++{ ++ char *use, *end; ++ ssize_t nlen; ++#if defined(HAS_NAME_TO_HANDLE_AT) ++ int mnt_id = get_mountid(path); ++#endif ++ int ret = -1; ++ ++ *mountinfo = NULL; ++ ++#if defined(HAS_NAME_TO_HANDLE_AT) ++ if (mnt_id >= 0) ++ { ++ list_t *ptr; ++ ++ errno = ENOENT; ++ list_for_each(ptr, &mntinfo) ++ { ++ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); ++ ++ if (mnt_id != mnt->id) ++ continue; ++ ++ ret = 0; ++ errno = 0; ++ *mountinfo = mnt; ++ break; ++ } ++ if (*mountinfo) ++ goto out; ++ ++ if (strlen(path) == 1 && path[0] == '/') ++ { ++ struct stat st; ++ ++ /* could be a chroot or a container */ ++ ++ if (statn(path, 0, &st) != 0) ++ { ++ if (errno != EACCES) ++ { ++ fprintf(stderr, _("Cannot stat %s: %s\n"), ++ path, strerror(errno)); ++ exit(1); ++ } ++ st.st_dev = (dev_t)-1; ++ } ++ ret = 0; ++ errno = 0; ++ *mountinfo = add_mntinfo(path, "unkown", mnt_id, -1, st.st_dev); ++ goto out; ++ } ++ } ++#endif ++ use = strdup(path); ++ if (!use) ++ goto out; ++ ++ nlen = strlen(use); ++ end = use+nlen; ++ errno = ENOENT; ++ do { ++ list_t *ptr; ++ if (*end == '/') ++ { ++ if (end == use) { /* root file system */ ++ end++; ++ if (nlen == 1) ++ { ++ struct stat st; ++ ++ /* could be a chroot or a container */ ++ ++ if (statn(use, 0, &st) != 0) ++ { ++ if (errno != EACCES) ++ { ++ fprintf(stderr, _("Cannot stat %s: %s\n"), ++ use, strerror(errno)); ++ exit(1); ++ } ++ st.st_dev = (dev_t)-1; ++ } ++ ret = 0; ++ errno = 0; ++ *mountinfo = add_mntinfo(use, "unkown", 0, -1, st.st_dev); ++ break; ++ } ++ } ++ } ++ *end = '\0'; ++ nlen = end-use; ++ list_for_each(ptr, &mntinfo) ++ { ++ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); ++ ++ if (nlen != mnt->nlen) ++ continue; ++ ++ if (strcmp(use, mnt->mpoint)) ++ continue; ++ ++ ret = 0; ++ errno = 0; ++ *mountinfo = mnt; ++ break; ++ } ++ ++ } while (!*mountinfo && (end = strrchr(use, '/'))); ++ free(use); ++out: ++ return ret; ++} ++ + /* + * Somehow the realpath(3) glibc function call, nevertheless + * it avoids lstat(2) system calls. +@@ -2215,6 +2774,52 @@ char *expandpath( + } + lnkbuf[n] = '\0'; /* Don't be fooled by readlink(2) */ + ++ /* ++ * Expand to real path of named socket if any ++ */ ++ if (lnkbuf[0] != '/' && strncmp("socket:[", lnkbuf, 8) == 0) ++ { ++ FILE *fp; ++ char *inode; ++ char line[BUFSIZ]; ++ if ((inode = strchr(&lnkbuf[8], ']'))) ++ { ++ *inode = '\0'; ++ inode = &lnkbuf[8]; ++ } ++ ++ if (!inode || (fp = fopen(PROC_SOCKETS, "r")) == NULL) ++ { ++ /*fprintf(stderr, "Cannot open %s\n", PROC_SOCKETS); */ ++ return (char *)0; ++ } ++ while (fgets(line, BUFSIZ, fp) != NULL) ++ { ++ char *named = NULL; ++ unsigned long snode; ++ ++ if (*line == 'N') ++ continue; ++ ++ if (sscanf(line, "%*x: %*x %*x %*x %*x %*x %lu %ms", ++ &snode, &named) == 2) ++ { ++ char *ep; ++ unsigned long oul = strtoul(inode, &ep, 0); ++ if (oul == snode) { ++ ep = named; ++ if (*ep == '@') ++ ep++; ++ n = strlen(ep); ++ memcpy(lnkbuf, ep, n); ++ lnkbuf[n] = '\0'; ++ } ++ free (named); ++ } ++ } ++ fclose(fp); ++ } ++ + len = strlen(end); + if ((n + len) > PATH_MAX) + { +diff --git src/fuser.h src/fuser.h +index 4500ec5..f90dad9 100644 +--- src/fuser.h ++++ src/fuser.h +@@ -37,10 +37,16 @@ struct procs { + #define PTYPE_KNFSD 2 + #define PTYPE_SWAP 3 + ++struct fdinfo { ++ mode_t flags; ++ int mnt_id; ++}; ++ + struct names { + char *filename; + unsigned char name_space; + struct stat st; ++ int mnt_id; + struct procs *matched_procs; + struct names *next; + }; +@@ -65,12 +71,21 @@ struct inode_list { + struct names *name; + dev_t device; + ino_t inode; ++ int mnt_id; + struct inode_list *next; + }; + ++struct subvol { ++ dev_t device; ++ int mnt_id; ++ struct subvol *next; ++}; ++ + struct device_list { + struct names *name; ++ struct subvol *vol; + dev_t device; ++ int mnt_id; + struct device_list *next; + }; + +@@ -79,6 +94,7 @@ struct unixsocket_list { + ino_t inode; + ino_t net_inode; + dev_t dev; ++ int mnt_id; + struct unixsocket_list *next; + }; + +@@ -87,18 +103,16 @@ struct mount_list { + struct mount_list *next; + }; + +-#if defined (__GNUC__) && defined(WITH_MOUNTINFO_LIST) +-# include "lists.h" ++#include "lists.h" + typedef struct mntinfo_s { + list_t this; + int id, parid; ++ char isremote; + dev_t dev; + size_t nlen; ++ dev_t vol; + char *mpoint; + } mntinfo_t; +-#else +-# undef WITH_MOUNTINFO_LIST +-#endif + + #define NAMESPACE_FILE 0 + #define NAMESPACE_TCP 1 +@@ -109,5 +123,7 @@ typedef struct mntinfo_s { + #endif /* PATH_MAX */ + + #define KNFSD_EXPORTS "/proc/fs/nfs/exports" ++#define PROC_MOUNTINFO "/proc/self/mountinfo" ++#define PROC_SOCKETS "/proc/self/net/unix" + #define PROC_MOUNTS "/proc/mounts" + #define PROC_SWAPS "/proc/swaps" +-- +2.35.3 + diff --git a/psmisc-22.21-pstree.patch b/psmisc-22.21-pstree.patch new file mode 100644 index 0000000..c3213a0 --- /dev/null +++ b/psmisc-22.21-pstree.patch @@ -0,0 +1,79 @@ +--- + src/pstree.c | 38 +++++++++++++++++++++++++++++++------- + 1 file changed, 31 insertions(+), 7 deletions(-) + +--- src/pstree.c ++++ src/pstree.c 2022-12-13 07:46:58.243076344 +0000 +@@ -79,6 +79,7 @@ extern const char *__progname; + #define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */ + + #define VT_BEG "\033(0\017" /* use graphic chars */ ++#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" +@@ -578,6 +579,28 @@ static void out_scontext(const PROC *cur + out_string("'"); + } + ++/* ++ * Only affects vt100 line drawing mode: Do not count the strlen of ++ * VT_BEG to prevent doing end-of-line way too early: ++ */ ++static void ++out_sym (const char *str) ++{ ++ int seq = 0; ++ if (sym == &sym_vt100 && *str == '\033') { ++ seq = 1; ++ if (cur_x <= output_width || !trunc) ++ cur_x -= VT_LEN; ++ } ++ out_string(str); ++ if (seq) { ++ str = VT_END; ++ while (*str) ++ putchar (*str++); ++ } ++} ++ ++ + static void out_newline(void) + { + if (last_char && cur_x == output_width) +@@ -817,11 +840,12 @@ dump_tree(PROC * current, int level, int + for (lvl = 0; lvl < level; lvl++) { + for (i = width[lvl] + 1; i; i--) + out_char(' '); +- out_string(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) +@@ -931,7 +955,7 @@ dump_tree(PROC * current, int level, int + } + width[level] = comm_len + cur_x - offset + add; + if (cur_x >= output_width && trunc) { +- out_string(sym->first_3); ++ out_sym(sym->first_3); + out_string("+"); + out_newline(); + return; +@@ -955,7 +979,7 @@ dump_tree(PROC * current, int level, int + } + } + if (first) { +- out_string(next ? sym->first_3 : sym->single_3); ++ out_sym(next ? sym->first_3 : sym->single_3); + first = 0; + } + dump_tree(walk->child, level + 1, count + 1, diff --git a/psmisc-v23.6.dif b/psmisc-v23.6.dif new file mode 100644 index 0000000..e35d647 --- /dev/null +++ b/psmisc-v23.6.dif @@ -0,0 +1,51 @@ +--- + configure.ac | 2 +- + src/fuser.c | 5 ++++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +--- configure.ac ++++ configure.ac 2022-12-13 07:57:11.751636898 +0000 +@@ -162,7 +162,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc + struct user_regs_struct.rdi, + struct user_regs_struct.rsi, + struct user_regs_struct.rdx], [],[], +- [#include ++ [#include + #include ]) + AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3, + struct pt_regs.gpr], [],[], [#include ]) +--- src/fuser.c ++++ src/fuser.c 2022-12-13 07:59:50.896670010 +0000 +@@ -1223,6 +1223,7 @@ int main(int argc, char *argv[]) + struct option *optr; + char *nsptr; + int skip_argv; ++ int seen_file; + + struct option options[] = { + {"all", 0, NULL, 'a'}, +@@ -1266,6 +1267,7 @@ int main(int argc, char *argv[]) + #endif + atexit(atexit_free_lists); + ++ seen_file = 0; + for (argc_cnt = 1; argc_cnt < argc; argc_cnt++) + { + current_argv = argv[argc_cnt]; +@@ -1416,6 +1418,7 @@ int main(int argc, char *argv[]) + } + } + this_name->matched_procs = NULL; ++ seen_file = 1; + if (opts & (OPT_MOUNTS | OPT_ISMOUNTPOINT) + && this_name->name_space != NAMESPACE_FILE) + { +@@ -1467,7 +1470,7 @@ int main(int argc, char *argv[]) + names_tail->next = this_name; + names_tail = this_name; + } /* for across the argvs */ +- if (names_head == NULL) ++ if (names_head == NULL && !seen_file) + usage(_("No process specification given")); + + /* Check if -M flag was used and if so check mounts */ diff --git a/psmisc-v23.6.tar.bz2 b/psmisc-v23.6.tar.bz2 new file mode 100644 index 0000000..0151e3a --- /dev/null +++ b/psmisc-v23.6.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91573ca0a1a50bd491b7c3cbe400126b0dadef9a2e328030d6469bb2448e0794 +size 263463 diff --git a/psmisc.changes b/psmisc.changes new file mode 100644 index 0000000..d78360a --- /dev/null +++ b/psmisc.changes @@ -0,0 +1,840 @@ +------------------------------------------------------------------- +Thu Feb 16 16:06:59 UTC 2023 - Ludwig Nussel + +- allow to switch off Apparmor support via bcond + +------------------------------------------------------------------- +Tue Dec 27 13:15:30 UTC 2022 - Ludwig Nussel + +- Replace transitional %usrmerged macro with regular version check (boo#1206798) + +------------------------------------------------------------------- +Tue Dec 13 08:01:33 UTC 2022 - Dr. Werner Fink + +- Update to 23.6: + * buildsys: Fix DEJAGNU work-around Debian #1015089 + * killall: Use kill if pidfd_send_signal fails Debian #1015228 + * fuser: Do not mention nonexistent - reset option #42 + * fuser: Use modern statn where possible + * pstree: Better AppArmor support !30 + * killall: Check truncated names !28 + * killall: Use openat and pidfd_send_signal #37 + * killall: Don't check paths of sockets #35 + * pstree: Check for process with show_parents #38 + * pstree: Don't disable compaction with show pgids #34 + * pstree: Fix storage leak !29 +- Enable new apparmor support +- Remove patch now upstream + 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch +- Port patch psmisc-22.21-pstree.patch +- Port patch psmisc-v23.4.dif which now becomes psmisc-v23.6.dif +- Merge patch socket-fix.patch with ported patch + 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + +------------------------------------------------------------------- +Fri Nov 25 11:48:39 UTC 2022 - Dr. Werner Fink + +- Add patch socket-fix.patch + * Add test to check for named sockets as file as well as on mounts + * Fix code to find named sockets +- The former test requires nc at build aka netcat from openbsd to + create a named socket on the fly + +------------------------------------------------------------------- +Wed Feb 23 13:04:06 UTC 2022 - Dr. Werner Fink + +- Change patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Add a fallback if the system call name_to_handle_at() is + not supported by the used file system. + +------------------------------------------------------------------- +Tue Feb 1 12:39:16 UTC 2022 - Dr. Werner Fink + +- Change patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Determine the namespace of a process only once to speed + up the parsing of fdinfo (bsc#1194172). +- Adopt patch 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch + +------------------------------------------------------------------- +Thu Jan 20 13:57:13 UTC 2022 - Dr. Werner Fink + +- 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 + +- Do not change CAP within spec file (boo#1186258) + +------------------------------------------------------------------- +Fri May 7 14:53:08 UTC 2021 - Dr. Werner Fink + +- Change patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Fix bsc#1185208 to make private mount namespaces work as well + as to distinguish NFS mounts from same remote device share. + +------------------------------------------------------------------- +Fri Mar 5 14:10:11 UTC 2021 - Dr. Werner Fink + +- Change patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Fix bsc#1178407: fuser does not show open kvm storage image files + such as qcow2 files. Patch from Ali Abdallah + +------------------------------------------------------------------- +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 + +- 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 + +- 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 + +- prepare usrmerge (boo#1029961) + +------------------------------------------------------------------- +Mon Apr 27 14:57:57 UTC 2020 - Dr. Werner Fink + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Allow not unique mounts as well as not unique mountpoint (bsc#1170247) + +------------------------------------------------------------------- +Thu Sep 19 11:57:44 UTC 2019 - Ludwig Nussel + +- Do not recommend lang package. The lang package already has a + supplements. + +------------------------------------------------------------------- +Fri Nov 30 13:21:44 UTC 2018 - Dr. Werner Fink + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Always initialize head of simple linked list (bsc#1098697) + * stat(2) on binary does not see subvol dev + +------------------------------------------------------------------- +Wed Nov 14 07:44:55 UTC 2018 - Dr. Werner Fink + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + to handle sub volumes of the btrFS (bsc#1112780) + +------------------------------------------------------------------- +Mon Nov 5 07:48:25 UTC 2018 - Dr. Werner Fink + +- Modify patch 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch + to support older systems with statx kernel support + +------------------------------------------------------------------- +Fri Nov 2 13:37:49 UTC 2018 - Dr. Werner Fink + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + to respect autofs as well as afs file system +- Add patch 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch + to use statx(2) system call since kernel 4.12. Now it is possible + to avoid sync with remote file servers as well as trigger autofs + mounts due stat(x) calls. + +------------------------------------------------------------------- +Tue Oct 23 10:10:12 UTC 2018 - Dr. Werner Fink + +- Support also btrFS entries in mountinfo, that is use stat(2) to + determine the device of the mounted subvolume (bsc#1098697, bsc#1112780) + +------------------------------------------------------------------- +Mon Oct 22 10:52:10 UTC 2018 - Dr. Werner Fink + +- Update to version 23.2 + * misc: Command names increased from 16 to 64 characters + * buildsys: signals.c depends on signames.h !16 + * docs: Fix fuser.1 groff errors Debian #900225 + * killall: look at all namespaces by default + * killall: Fix -INT option parsing #11 + * killall: ignore -n 0 #15 + * killall: another crack at fixing getopt #12 #13 + * peekfd: Attach to all threads option !15 + * pslog: Define PATH_MAX if required Debian:#905797 +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch +- Remove patches now upstream solved + * psmisc-23.0-killall-signals.patch + * psmisc-23.0-killall.patch +- Modify and rename patch psmisc-23.0.dif which now becomes psmisc-v23.2.dif + +------------------------------------------------------------------- +Mon Sep 17 12:08:31 UTC 2018 - Dr. Werner Fink + +- Add COPYING to file list as otherwise a required fix does not + reach anything + +------------------------------------------------------------------- +Fri Jun 22 16:33:00 UTC 2018 - werner@suse.de + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + to make fuser option -m work even with mountinfo + (bsc#1098697) + +------------------------------------------------------------------- +Thu May 17 10:32:53 UTC 2018 - werner@suse.de + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + to let fuser -m also work for private mounts as well (boo#1093665) + +------------------------------------------------------------------- +Fri Oct 13 07:10:39 UTC 2017 - werner@suse.de + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + to run even on older kernels missing mnt_id tag in fdinfo + +------------------------------------------------------------------- +Mon Sep 18 10:17:52 UTC 2017 - werner@suse.de + +- Add patch psmisc-23.0-killall-signals.patch to fix boo#1058990 + by prior scanning for signal names in the arguments of killall + +------------------------------------------------------------------- +Thu Jul 6 13:59:36 UTC 2017 - werner@suse.de + +- Update patch + 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + +------------------------------------------------------------------- +Wed Jul 5 13:24:01 UTC 2017 - werner@suse.de + +- Remove patches + * psmisc-22.21-lessnfs.patch + * psmisc-22.21-mntpt.patch + * psmisc-23.0-net.patch +- Add patch + 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + from https://gitlab.com/bitstreamout/psmisc/tree/mountinfo + which is a heavily rework fuser used on NFS + * 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 +- Use test suite of psmisc in %check rpm section + +------------------------------------------------------------------- +Wed Jun 28 13:11:49 UTC 2017 - werner@suse.de + +- Add patch psmisc-23.0-net.patch to reenable network support + broken to my own upstream commit + +------------------------------------------------------------------- +Wed Jun 28 10:00:16 UTC 2017 - werner@suse.de + +- Add patch psmisc-23.0-killall.patch to remove left over debug + output in killall utility (boo#1046237) + +------------------------------------------------------------------- +Tue Jun 20 15:06:43 UTC 2017 - werner@suse.de + +- Update to version 23.0 + * killall: Fix process age race condition !11 Debian #822861 + * killall: only use scope of current namespace by default + * killall: better parsing of command names + * pstree: add cgroup namespaces !10 + * peekfd: Help give long options too !5 + * killall: correctly report when 32+ procs match !8 + * prtat: Remove duplicate options in man page !3 Debian #846387 + * pslog: New program to check what logs are open merge !1 + * fuser: increase path length for octal escaping SF [#37] + * Make usage of linked lists of devices found in + /proc/self/mountinfo optional + * Make timeout() in timeout.c work with shared mmap to + reduce the load due write/read the stat buffers + * Add list_sort() to lists.h to be able to sort lists + * fuser: Fixed typo for -M flag. Debian #740275 + * pstree: by default doesn't show threadnames, use -t to show + as it disables compaction. SF [#33] Debian #815902 + * pstree: Removed need for PATH_MAX Debian #750405 + * pstree: ignores disappeared processes. SF [#34] + * killall: -o and -y work with -r flags. SF [#64] + * m4/gettext.m4: Upgrade to gettext-0.19.4. + * m4/iconv.m4: Upgrade to gettext-0.19.4. + * m4/lib-ld.m4: Upgrade to gettext-0.19.4. + * m4/lib-link.m4: Upgrade to gettext-0.19.4. + * m4/lib-prefix.m4: Upgrade to gettext-0.19.4. + * m4/nls.m4: Upgrade to gettext-0.19.4. + * m4/po.m4: Upgrade to gettext-0.19.4. + * m4/progtest.m4: Upgrade to gettext-0.19.4. + * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.19.4. +- Make it build, that is create a po/POTFILES.in +- Remove obsolete patches + * psmisc-22.21-boo908063.patch + * psmisc-22.12-tigetstr.patch + * psmisc-22.21-upstream.patch + * psmisc-git-3638cc55b4d08851faba46635d737b24d016665b.patch +- Rename patch psmisc-22.21.dif which becomes psmisc-23.0.dif +- Make /bin/fuser a symblic link of /usr/bin/fuser (boo#1029973) +- Last revision was 78 + +------------------------------------------------------------------- +Tue Jun 20 14:00:36 UTC 2017 - werner@suse.de + +- Modify psmisc-22.21.dif to enforce the usage of `m' flag in + sscanf() instead of `a' for allocation. Also avoid to small + buffers and include sys/sysmacros.h for makedev macro. +- Add the patch psmisc-22.21-lessnfs.patch to support device + files of mount points as well (boo#1044638) +- Add the patch psmisc-22.21-mntpt.patch to do strinfg comparision + only for NFS shares + +------------------------------------------------------------------- +Thu May 21 13:39:34 UTC 2015 - schwab@suse.de + +- Replace negative list %nopeek with positive list %have_peekfd + +------------------------------------------------------------------- +Tue Mar 24 11:58:08 UTC 2015 - werner@suse.de + +- Add patch psmisc-22.21-boo908063.patch to avoid to close files + which are never open (boo#908063) + +------------------------------------------------------------------- +Fri Apr 25 00:59:39 CEST 2014 - ro@suse.de + +- add patch to fix fuser -M option active all the time (bnc#874983) + psmisc-git-3638cc55b4d08851faba46635d737b24d016665b.patch + +------------------------------------------------------------------- +Mon Mar 24 16:01:51 UTC 2014 - werner@suse.de + +- Update to version 22.21 + * Missing comma in fuser(1) added Debian #702391 + * pstree uses COLUMN env variable Debian #717017 + * pstree shows proper thread names SF Bug#57 + * pstree shows namespace options SF Patch#30 + * killall.1 minor fixes SF Bug#59 + * peekfd for m68k SF Patch#31 + * Fixing some derefefed pointers SF Patch#32 + * Minor typos in man pages SF Bug#61 Bug#60 + * fuser -m and -M flags work either way Debian #606178 +- Remove patch + psmisc-22.20-pstree.patch as now part of upstream + peekfd-m68k.patch as now part of upstream +- Port the patches + psmisc-22.20-upstream.patch which becomes psmisc-22.21-upstream.patch + psmisc-22.20.dif which becomes psmisc-22.21.dif + psmisc-22.12-pstree.patch which becomes psmisc-22.21-pstree.patch + +------------------------------------------------------------------- +Wed Oct 23 14:35:46 UTC 2013 - p.drouand@gmail.com + +- Remove %fillup_prereq %insserv_prereq PreReq; package provides + neither sysconfigfile or sysvinit script +- Use %lang_package instead of define a lang subpackage manually +- Use %configure instead of ./configure +- Don't define CC and CXX flags manually +- Remove redundant %clean section + +------------------------------------------------------------------- +Wed Oct 9 12:33:26 UTC 2013 - schwab@suse.de + +- peekfd-m68k.patch: Port peekfd to m68k + +------------------------------------------------------------------- +Sat Feb 9 12:46:46 UTC 2013 - schwab@suse.de + +- peekfd hasn't been ported to aarch64 yet + +------------------------------------------------------------------- +Tue Dec 18 17:16:02 UTC 2012 - werner@suse.de + +- Update to version 22.20 + upstream patch + * Make usage of linked lists of devices found in + /proc/self/mountinfo optional + * Make timeout() in timeout.c work with shared mmap to + reduce the load due write/read the stat buffers + * Add list_sort() to lists.h to be able to sort lists + * pstree sorts properly on names Debian #682014 + * fuser -m regresion fixed SF #3559232, thanks to hanpt + * pstree finds orphaned processes SF#3537508 + * fuser finds unix sockets again SF #3502649 + * pstree finds pid 0 stops looping Debian #687829 + * killall with no args exits again SF #3536526 + * Added AC_CANONICAL_TARGET for target_os Debian #673485 + * sed doesn't have [0-9]+ replace with [0-9][0-9]* + * assert in killall triggered for small lifetimes Debian #628617 + * killall MAX_NAMES off by one Debian #677428 + * Removed remaining parts of pidof + * fuser uses correct timeout_stat define Debian #661723 + * fuser is not compiled on hurd-i386 Debian #673485 + * No TEXTRELS in src/lists built as PIE on x86 + * Fake pstree root for kernels with hidepid turned on + * More fixes for Cygwin SF Patch #3511920 + * pstree can show PGIDs SF Patch #3471056 +- This should fix the bug reported by Madhu + +------------------------------------------------------------------- +Tue Mar 13 15:26:37 UTC 2012 - werner@suse.de + +- Submit ASCII null fix in pstree upsrtream +- Submit support for static background process for stat system call + upstream +- Rebuild package with upstream patches + +------------------------------------------------------------------- +Mon Feb 27 17:43:46 UTC 2012 - werner@suse.de + +- Update to version 22.16 + * Use strncpy for COMM_LEN and make it 18 characters to cover + brackets in name. + * don't change COMM_LEN, it breaks matching long commands + Debian #661145 + * Enable some harden AM_CFLAGS by default, use configure option + --disable-harden-flags to not use it. + * Use ENOENT not EBADE for FreeBSD Debian #631566 + * Fix prstat typos + * Stop zombies by using waitpid Ubuntu #876387 by Peter Holik, SF#3429674 + * Fixed minor older/younger typo in killall.1 thanks to Maikel Linke + * Correct defines for timeout in configure.ac + +------------------------------------------------------------------- +Thu Dec 1 15:57:50 UTC 2011 - coolo@suse.com + +- add automake as buildrequire to avoid implicit dependency + +------------------------------------------------------------------- +Tue Oct 11 15:36:40 UTC 2011 - werner@suse.de + +- Use __builtin___strcpy_ instead of __builtin___strcpy_chk to avoid + trouble with char path[0] tag in struct handle (bnc#723304) + +------------------------------------------------------------------- +Fri Oct 7 14:08:31 UTC 2011 - werner@suse.de + +- Make main fuser process more robust against broken pipe and check + for helper process within a SIGCHLD handler + +------------------------------------------------------------------- +Wed Oct 5 09:47:38 UTC 2011 - werner@suse.de + +- Handle internal size of structure stat by including config.h + to avoid size missmatch during copy result back (bnc#720882) + +------------------------------------------------------------------- +Mon Oct 3 10:56:19 UTC 2011 - mmarek@suse.cz + +- Fix segfault in pstree, patch by Tetsuo Handa (bnc#718915). + +------------------------------------------------------------------- +Wed Sep 28 10:43:03 UTC 2011 - coolo@suse.com + +- back out the timeout patch, it breaks fuser on i586 completely + (bnc#720882) + +------------------------------------------------------------------- +Mon Sep 12 14:28:38 UTC 2011 - werner@suse.de + +- Update to pre version 22.15 + + Really apply patch for SF#31110178 RH#651794 + + Conditionally use fork before stat calls + + Patch from Corrina Vinschen for compiling on cygwin + + Remove doubled content in src/lists.h + + Add another 2 for thread brackets in pstree.c +- Change fork before stat calls to be in best case a second process + using two pipes for bidirectional communication with main. + +------------------------------------------------------------------- +Tue Jun 21 15:56:45 CEST 2011 - werner@suse.de + +- Update to version 22.14: + + Fix file descriptor as weel as memory leaks in fuser + + Strip @ symbol from file names read from /proc/net/unix + + Above 2 changes close openSuSE bugs #536209, #529520, and #417841 + and provided by Werner Fink + + Applied patch from Werner Fink to avoid stat(2) on NFS mounts + + Zeros process group memory - Patch by jgorig SF#3152925 RH#666213 + + fuser -m -s flags work - Patch by jgorig SF#31110178 RH#651794 + + fuser silent if /proc/swaps not available SF#3072134 + + ppc 64 support for peekfd by jgorig SF#3166444 + + jiffies now ULL in killall SF#3138538 + + pstree can show parents of a process. Patch supplied by Curtis + Hawthorne SF#3135157 + + killall creates right size buffer instead of MAX_PATH Debian #623425 + + check for /proc/$$/stat not /proc/self/stat which is not available + on hurd platforms. Same Debian bug as above + + fuser understands IPv6 addresses, removed comment in fuser.1 that it + doesn't Debian #609904 + + fuser -k only returns 0 if you kill something. + + fuser doesn't complain if /proc/#/fd disappears SF#3310990 + +------------------------------------------------------------------- +Tue Feb 8 17:43:57 CET 2011 - werner@suse.de + +- Now use /proc/self/mountinfo to minimize the needs of running + stat(2) system calls. The remaining stat(2) system calls are + wrapped by an timeout function. + +------------------------------------------------------------------- +Fri Oct 15 12:36:16 CEST 2010 - werner@suse.de + +- Add fix from upstream for a crash in peekfd + +------------------------------------------------------------------- +Sun Sep 19 10:36:02 CEST 2010 - vuntz@opensuse.org + +- Update to version 22.13: + + configure patch for x86_64 properly applied sf#3029302. + + patch configure so pt_regs isn't used on SuperH. deb#588986 + + Fixed configure.ac so only mipsel not mips compiles peekfd +- Remove part of psmisc-22.12.dif that is upstream. +- Remove AutoReqProv: it's default now. + +------------------------------------------------------------------- +Tue Jul 13 18:47:35 CEST 2010 - werner@suse.de + +- Update to psmisc-22.12 + * In fuser, switched the ipv6 and ipv4 checks around Debian #581604 + * peekfd configure patch for x86_64 SF#2986027 + * peekfd works with ARM and MIPS thanks to patch by Arnaud Patard + * peekfd off-by-one patch applied SF#1948351 + * pstree -a doesn't segfault on grsec kernels Debian #588152 + * Another attempted at killall -SIGNAME Debian #573924 + * fuser -k -m ... won't kill itself Debian #562767 + * fuser -NAME fixed SF #2924691, Debian #563388, Gentoo #297423 + * Added locale.h include for killall on non NLS SF #2922163 + * Reversed normal file fuser -k check Debian #563387 + * short option l returned in fuser Debian #539087 + * long options terminated with 0s Debian #551833 + * fuser only kills normal processes, patch thanks to Erik Li SF# 2892724 + * New fuser -M if you REALLY want mount points, patch thanks to + Jeremie LE HEN SF#2899709 + * Fixed killall options for VTALRM and ILL Debian #559011 + * pstree -a does not compact threads Debian #525632 + * new program prtstat which prints contents of /proc//stat + Debian #281706 + * killall restricts by date. Thanks to George Danchev Debian #544657 + * long options terminated in pstree too to stop segfault + * Re-worked fuser getopt again so -KILL options work Gentoo #297423 + * Fix off-by-one overflow in pstree SF# 2832375 + * Applied patch from Kari Hautio for lazy umount'ed filesystems SF#2545632 + * Applied patch from Anonymous SF submitter to fix killall -l + Fixes SF#2002570 + * fuser will print mounts,nfs exports and swaps with -v Debian #356655 + and SF#533958 + * pstree and fuser have long options Debian #517412 + * Fixed pstree -a off-by-one error in buffer, Debian #536243 + * Changed configure.ac to not use CXX SF# 2789801 + +------------------------------------------------------------------- +Tue Jul 6 06:30:24 UTC 2010 - bg@novell.com + +- peekfd is not available on hppa + +------------------------------------------------------------------- +Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de + +- use %_smp_mflags + +------------------------------------------------------------------- +Thu Mar 4 02:24:15 CET 2010 - ro@suse.de + +- fix overflow crash in pstree: add 2 to COMM_LEN for {...} + brackets for threads + +------------------------------------------------------------------- +Sun Dec 6 15:07:16 CET 2009 - jengelh@medozas.de + +- enable parallel building +- do not package peekfd on SPARC (it is not built) + +------------------------------------------------------------------- +Mon Oct 12 17:15:37 CEST 2009 - werner@suse.de + +- Detect current cwd to be able to compare local files (bnc#540927) + +------------------------------------------------------------------- +Fri Oct 9 18:58:25 CEST 2009 - werner@suse.de + +- Yet an other fix for NFS based file detection in fuser + +------------------------------------------------------------------- +Fri Oct 9 08:20:29 UTC 2009 - aj@suse.de + +- fix pstree -a crash (bnc#545265) with patch backported from 22.8 + by Björn Voigt . + +------------------------------------------------------------------- +Thu Sep 10 10:21:09 CEST 2009 - werner@suse.de + +- For future use fix fd leak reported by David Binderman (bnc#536209) + +------------------------------------------------------------------- +Mon Aug 10 11:27:07 CEST 2009 - werner@suse.de + +- Close file descriptor leak (bnc#529520) + +------------------------------------------------------------------- +Fri Jul 10 19:28:53 UTC 2009 - jansimon.moeller@opensuse.org + +- Add ARM to nopeek + +------------------------------------------------------------------- +Mon May 25 13:43:53 CEST 2009 - werner@suse.de + +- Remove oldfuser from file list + +------------------------------------------------------------------- +Mon May 11 14:04:09 CEST 2009 - werner@suse.de + +- Update to psmisc-22.7 + * Updated Polish, Russian, Swedish and Indonesian PO files + * Changed fuser.1 so signal is SIGNAL to reduce confusion about wether + or not it is a parameter Debian #517413 + * fuser.1 references pkill(1) Debian #517414 + * Added Chinese (traditional) PO file + * Updated Russian PO file + * Clarified -m and -c for fuser Debian #467289 + * Patch from Arnaud Giersch to fix udp ports in fuser Debian #502208 + * pstree man page mentions -Z may not be available Debian #478327 + * pstree handles UTF-8 lengths much better Debian #413503 + * killall says no process found when process not found Debian #500097 + * pstree makes a bigger buffer for -al flags Debian #352603 + * Dynamically reallocate buffer for fuser patch from Don Armstrong + * Updated Indonesian PO file + * peekfd off by one problem in fds Debian #460530 + * Patch from Marcus Watts for better comm handling in pstree + * Updated Hungarian po file + * Updated French and German po files + * Fuser -m detects more open sockets SF patch #1728412 Thnks marienz + * Updated Italian, Chinese simplified, Dutch, Swedish and Polish po files + * Removed old fuser +- Adapt our patches + +------------------------------------------------------------------- +Fri Mar 27 16:56:24 CET 2009 - werner@suse.de + +- nfs4fuser: do not match on shadow mounts +- resolve some memory leaks in fuser + +------------------------------------------------------------------- +Thu Mar 12 10:23:12 CET 2009 - werner@suse.de + +- nfs4fuser: be able to detect the root file system (bnc#464295) + +------------------------------------------------------------------- +Wed Mar 11 14:24:06 CET 2009 - werner@suse.de + +- nfs4fuser: make sure not to stumble on short named mount points + to avoid to terminate processes on wrong mount points + +------------------------------------------------------------------- +Thu Oct 9 16:35:51 CEST 2008 - werner@suse.de + +- Make compiler happy: Don't compare pointer with zero (bnc#432986) + +------------------------------------------------------------------- +Wed Oct 1 16:39:27 CEST 2008 - werner@suse.de + +- Avoid stat(2) for all network based file systems (bnc#409011) + +------------------------------------------------------------------- +Tue Sep 23 15:30:58 CEST 2008 - werner@suse.de + +- Enhance NFS patch for fuser (bug #409011) + +------------------------------------------------------------------- +Mon Sep 1 15:10:43 CEST 2008 - werner@suse.de + +- Do not leak on /proc/net/unix (bnc#417841) +- Read /proc/net/unix and /proc/mounts only once + +------------------------------------------------------------------- +Fri Aug 22 17:12:24 CEST 2008 - prusnak@suse.cz + +- enabled SELinux support [Fate#303662] + +------------------------------------------------------------------- +Thu Aug 7 15:12:14 CEST 2008 - werner@suse.de + +- Refine NFS patch +- Add option -w for killing only procs with write access + +------------------------------------------------------------------- +Fri May 16 17:19:31 CEST 2008 - werner@suse.de + +- Add a warning about fusers option -m due NFS locks +- Strip @ symbol from file names read from /proc/net/unix + +------------------------------------------------------------------- +Wed Dec 19 18:46:56 CET 2007 - werner@suse.de + +- Enhance NFS patch for fuser (bug #346776) + +------------------------------------------------------------------- +Fri Dec 14 14:18:03 CET 2007 - werner@suse.de + +- Update to psmisc-22.6 + * killall.1 mentions you can use -SIGxxx as well as just -XXX for + signal Debian #431082 + * Added support for PPC architecture for peekfd + * Updated the Chinese simplified po file + * Added support for x86_64 architecture for peekfd + * Added Chinese simplified po file + * Updated Dutch, Vietnamese, Polish and Italian translations + * Patch for peekfd from Benno Schulenberg + * Fixed up NLS for fuser, patch from Benno Schulenberg + * killall asks for Signal (procname) if not SIGTERM + +------------------------------------------------------------------- +Thu Oct 4 23:40:19 CEST 2007 - bg@suse.de + +- Disable peekfd on hppa + +------------------------------------------------------------------- +Thu Apr 26 17:02:11 CEST 2007 - werner@suse.de + +- Args, peekfd is ix86 specific, disable on other architectures + +------------------------------------------------------------------- +Thu Apr 26 15:36:37 CEST 2007 - werner@suse.de + +- Update to psmisc-22.5 + * fuser tcp works on 64bit + * Added new tool peekfd + * killall uses /proc//exe if inode comparision fails + * fuser correctly parses remote tcp ports +- Patched fuser to avoid to be locked on stalled NFS (bug #166912) + +------------------------------------------------------------------- +Thu Mar 29 12:24:57 CEST 2007 - rguenther@suse.de + +- Add ncurses-devel BuildRequires + +------------------------------------------------------------------- +Fri Sep 15 11:37:34 CEST 2006 - werner@suse.de + +- Update to psmisc version 22.3 which includes the previous fixes + +------------------------------------------------------------------- +Wed Feb 8 11:51:52 CET 2006 - max@suse.de + +- Fix exit code of fuser in silent mode [#148563]. + +------------------------------------------------------------------- +Fri Jan 27 13:50:20 CET 2006 - mmj@suse.de + +- Fix finding AF_UNIX sockets [#142342] +- Fix minor nits with net_* + +------------------------------------------------------------------- +Wed Jan 25 21:30:51 CET 2006 - mls@suse.de + +- converted neededforbuild to BuildRequires + +------------------------------------------------------------------- +Thu Jan 12 11:30:14 CET 2006 - mmj@suse.de + +- Update to psmisc-22.1 including: + * Updated PO files + * fuser signals eg -INT work better + * removed space out of fuser man page for -signal + * fuser -s flag works + * fix grep lines in Makefile for i386 arches + +------------------------------------------------------------------- +Fri Dec 16 13:33:48 CET 2005 - mmj@suse.de + +- update to psmisc-21.9 including: + * Fixed install-exec-hook so only symlink pstree.x11 if file does + not exist already. + * buffer overflow in killall scanf removed + * Fixed segfault in pstree -a + * fuser can not use IPv6, for things like uClibc + * configure has --disable-ipv6 for above + * fuser finds unix sockets + * fixed print_matches to only print unmatched objects if -a is + specified and to output the header for -v + * fixed argument parsing to handle groups like -av again + +------------------------------------------------------------------- +Fri Dec 9 09:59:36 CET 2005 - ro@suse.de + +- disable selinux + +------------------------------------------------------------------- +Tue Nov 8 09:26:15 CET 2005 - mmj@suse.de + +- add patch to fix print_matches and commandline arguments parsing + +------------------------------------------------------------------- +Sun Nov 6 17:54:33 CET 2005 - mmj@suse.de + +- fuser returns 1 if no match found like before [#132180] + +------------------------------------------------------------------- +Tue Nov 1 10:19:32 CET 2005 - mmj@suse.de + +- Update to psmisc-21.7 + +------------------------------------------------------------------- +Mon Aug 8 11:18:07 CEST 2005 - meissner@suse.de + +- fixed buffer overflow in -k failure case with pids >= 10000 + +------------------------------------------------------------------- +Mon Aug 16 11:39:28 CEST 2004 - garloff@suse.de + +- Update to psmisc-21.5: + * bugs fixed: UTF-8 line truncation (SF#757164), ss_family + (SF#845292), docu (fuser, ...) + * POSIX compat: -m option, ignore -f, fuser output, case + insensitive options for -I. + * Cleanups: dev_t and ino_t usage, automake update + * pstree -A(SCII) flag +- Rediff patches. + +------------------------------------------------------------------- +Tue Jul 20 09:55:28 CEST 2004 - schwab@suse.de + +- Use autoreconf. + +------------------------------------------------------------------- +Sun Apr 4 20:05:18 CEST 2004 - kukuk@suse.de + +- Add split alias [Bug #38279] + +------------------------------------------------------------------- +Sun Feb 15 01:55:14 CET 2004 - stepan@suse.de + +- update to v21.4 + +------------------------------------------------------------------- +Sat Feb 14 16:47:09 CET 2004 - kukuk@suse.de + +- Split from ps package + diff --git a/psmisc.spec b/psmisc.spec new file mode 100644 index 0000000..4c788a3 --- /dev/null +++ b/psmisc.spec @@ -0,0 +1,125 @@ +# +# spec file for package psmisc +# +# Copyright (c) 2023 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%bcond_without apparmor + +Name: psmisc +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: dejagnu +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel +BuildRequires: libselinux-devel +BuildRequires: linux-glibc-devel >= 4.12 +BuildRequires: ncurses-devel +BuildRequires: netcat-openbsd +%if %{with apparmor} +BuildRequires: pkgconfig(libapparmor) +%endif +URL: https://gitlab.com/psmisc/psmisc/ +Version: 23.6 +Release: 0 +Provides: ps:/usr/bin/killall +Summary: Utilities for managing processes on your system +License: GPL-2.0-or-later +Group: System/Monitoring +Source: https://gitlab.com/%{name}/%{name}/-/archive/v%{version}/%{name}-v%{version}.tar.bz2 +Patch0: %{name}-v%{version}.dif +Patch2: %{name}-22.21-pstree.patch +# PATCH-ADD-SUSE boo#908068, boo#1046237, boo#1046237 +# https://gitlab.com/bitstreamout/psmisc/tree/mountinfo +Patch3: 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + +%define have_peekfd %ix86 x86_64 ppc ppc64 ppc64le %arm mipsel m68k aarch64 + +%description +The psmisc package contains utilities for managing processes on your +system: pstree, killall and fuser. The pstree command displays a tree +structure of all of the running processes on your system. The killall +command sends a specified signal (SIGTERM if nothing is specified) to +processes identified by name. The fuser command identifies the PIDs of +processes that are using specified files or filesystems. + +%lang_package + +%prep +%setup -q -n %{name}-v%{version} +%patch2 -p0 -b .pstree +%patch3 -p0 -b .mntinf +%patch0 -p0 -b .p0 + +%build +grep -h src/ po/*.po|\ + sed -r 's/^#: //'|\ + tr ' ' '\n'|\ + sort -t : -k1,1 -u|\ + sed -r 's/:[0-9]+$//' > po/POTFILES.in +autoreconf -fi +CFLAGS="-D_GNU_SOURCE -D_DEFAULT_SOURCE ${RPM_OPT_FLAGS} -pipe -fPIE" +CXXFLAGS="$CFLAGS" +LDFLAGS=-pie +CC=gcc +export CFLAGS CXXFLAGS LDFLAGS CC +%configure --disable-rpath \ + --with-gnu-ld \ + %{?with_apparmor:--enable-apparmor} \ + --enable-selinux +make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" + +%check +make check + +%install +make DESTDIR=%{buildroot} install +%if 0%{?suse_version} < 1550 +mkdir -p %{buildroot}/bin/ +ln -sf %{_bindir}/fuser %{buildroot}/bin/ +%endif +%ifnarch %have_peekfd +rm -f %{buildroot}%{_mandir}/man1/peekfd.1* +%endif +%find_lang psmisc + +%files +%defattr (-,root,root,755) +%license COPYING +%if 0%{?suse_version} < 1550 +/bin/fuser +%endif +%{_bindir}/fuser +%{_bindir}/killall +%ifarch %have_peekfd +%{_bindir}/peekfd +%endif +%{_bindir}/prtstat +%{_bindir}/pslog +%{_bindir}/pstree +%{_bindir}/pstree.x11 +%{_mandir}/man1/fuser.1* +%{_mandir}/man1/killall.1* +%ifarch %have_peekfd +%{_mandir}/man1/peekfd.1* +%endif +%{_mandir}/man1/prtstat.1* +%{_mandir}/man1/pslog.1* +%{_mandir}/man1/pstree.1* + +%files lang -f %{name}.lang + +%changelog