From d16b550658330553d565b7dadb985d3b22bfe5e8 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Wed, 5 Jul 2017 13:33:06 +0000 Subject: [PATCH] Rework of patch sets OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=89 --- ...to-be-able-to-use-the-mount-identity.patch | 1031 +++++++++++++++++ psmisc-22.21-lessnfs.patch | 81 -- psmisc-22.21-mntpt.patch | 23 - psmisc-23.0-net.patch | 15 - psmisc-23.0.dif | 48 +- psmisc.changes | 20 + psmisc.spec | 24 +- 7 files changed, 1076 insertions(+), 166 deletions(-) create mode 100644 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch delete mode 100644 psmisc-22.21-lessnfs.patch delete mode 100644 psmisc-22.21-mntpt.patch delete mode 100644 psmisc-23.0-net.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 new file mode 100644 index 0000000..0b25bd1 --- /dev/null +++ b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch @@ -0,0 +1,1031 @@ +From 5bcb9ee808fa6f35b7fb2fb986cd9d8486720410 Mon Sep 17 00:00:00 2001 +From: Werner Fink +Date: Thu, 29 Jun 2017 15:18:28 +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 + +Signed-off-by: Werner Fink +--- + configure.ac | 18 +- + src/fuser.c | 525 +++++++++++++++++++++++++++---------- + src/fuser.h | 19 +- + testsuite/Makefile.am | 3 +- + testsuite/killall.test/killall.exp | 4 + + 5 files changed, 421 insertions(+), 148 deletions(-) + +diff --git configure.ac configure.ac +index 176a2fc..d8d3366 100644 +--- configure.ac ++++ configure.ac +@@ -27,6 +27,9 @@ if test "$enable_selinux" = "yes"; then + AC_DEFINE([WITH_SELINUX], [1], [Use Security-Enhanced Linux features]) + AC_CHECK_LIB([selinux], [getfilecon], [SELINUX_LIB=-lselinux], [ + AC_MSG_ERROR([Cannot find selinux static library]) ]) ++ echo 'set has_selinux 1' > testsuite/selinux.exp ++else ++ echo 'set has_selinux 0' > testsuite/selinux.exp + fi + AC_SUBST([SELINUX_LIB]) + +@@ -44,6 +47,19 @@ if test "$enable_timeout_stat" = "static"; then + fi + AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"]) + ++# Use /proc/self/mountinfo if available ++if test -e /proc/self/mountinfo ; then ++ AC_DEFINE([HAS_MOUNTINFO], [1], [System has /proc/self/mountinfo which can used instead /proc(/self)/mounts]) ++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])]) ++ + # 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. + 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 31ef30c..74c2353 100644 +--- src/fuser.c ++++ src/fuser.c +@@ -32,6 +32,10 @@ + #include + #include + #include ++#include ++#if defined(HAS_GETFH) ++#include ++#endif + #include + #include + #include +@@ -78,7 +82,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); +@@ -88,8 +92,8 @@ 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); ++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(struct names *names_head, struct inode_list *ino_head, +@@ -108,9 +112,12 @@ static void debug_match_lists(struct names *names_head, + struct device_list *dev_head); + #endif + +-#if defined(WITH_MOUNTINFO_LIST) ++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); ++static int find_mountpoint(const char *path, mntinfo_t **mountinfo); ++#if defined(WITH_MOUNTINFO_LIST) + static int mntstat(const char *path, struct stat *buf); + #endif + static stat_t thestat = stat; +@@ -198,6 +205,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, + struct stat *cwd_stat = NULL; + struct stat *exe_stat = NULL; + struct stat *root_stat = NULL; ++ int cwd_id, exe_id, root_id; + + if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */ + continue; +@@ -207,9 +215,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, + 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; +@@ -217,21 +225,21 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, + /* Scan the devices */ + for (dev_tmp = dev_head; dev_tmp != NULL; + dev_tmp = dev_tmp->next) { +- 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); ++ 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; ++ 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) { + 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) +@@ -240,7 +248,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, + } + if (root_dev == ino_tmp->device) { + 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) +@@ -249,7 +257,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, + } + if (cwd_dev == ino_tmp->device) { + 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) +@@ -290,6 +298,7 @@ add_inode(struct inode_list **ino_list, struct names *this_name, + 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; + } +@@ -309,6 +318,7 @@ add_device(struct device_list **dev_list, struct names *this_name, dev_t device) + dev_head = *dev_list; + dev_tmp->name = this_name; + dev_tmp->device = device; ++ dev_tmp->mnt_id = this_name->mnt_id; + dev_tmp->next = dev_head; + *dev_list = dev_tmp; + } +@@ -450,13 +460,15 @@ add_special_proc(struct names *name_list, const char ptype, const uid_t uid, + int parse_file(struct names *this_name, struct inode_list **ino_list, + const opt_type opts) + { ++ mntinfo_t *mountinfo; + char *new = expandpath(this_name->filename); + if (new) { + if (this_name->filename) + free(this_name->filename); + this_name->filename = strdup(new); + } +- if (timeout(thestat, this_name->filename, &(this_name->st), 5) != 0) { ++ if (timeout(thestat, this_name->filename, &(this_name->st), 5) != 0 || ++ find_mountpoint(this_name->filename, &mountinfo) != 0) { + if (errno == ENOENT) + fprintf(stderr, + _("Specified filename %s does not exist.\n"), +@@ -466,10 +478,12 @@ int parse_file(struct names *this_name, struct inode_list **ino_list, + 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.isnfs ? "yes" : "no"); + #endif /* DEBUG */ + add_inode(ino_list, this_name, this_name->st.st_dev, + this_name->st.st_ino); +@@ -501,11 +515,39 @@ parse_mounts(struct names *this_name, struct device_list **dev_list, + const opt_type opts) + { + dev_t match_device; ++ mntinfo_t *mountinfo = NULL; ++ 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; ++ ++ count = 0; ++ list_for_each(ptr, &mntinfo) { ++ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); ++ if (match_device != mnt->dev) ++ continue; ++ if (!mountinfo) ++ mountinfo = mnt; ++ count++; ++ } ++ if (count == 0) { ++ errno = ENOENT; ++ fprintf(stderr, ++ _("Specified filename %s has no mountpoint.\n"), ++ this_name->filename); ++ return -1; ++ } ++ if (count > 1) { ++ errno = ENOTUNIQ; ++ fprintf(stderr, ++ _("The device %u:%u is not unique. Please change!\n"), ++ major(mountinfo->dev), minor(mountinfo->dev)); ++ /* return -1 */ ++ } ++ this_name->mnt_id = mountinfo->id; + add_device(dev_list, this_name, match_device); + return 0; + } +@@ -620,7 +662,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) + fprintf(stderr, _("Unknown local port AF %d\n"), + res->ai_family); + freeaddrinfo(res); +- free(lcl_port_str); ++ free(lcl_port_str); + return -1; + } + freeaddrinfo(res); +@@ -683,10 +725,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) + break; + #endif + } +- } /*while */ +- freeaddrinfo(res); ++ } /* for (;;) */ ++ ++ freeaddrinfo(res); + return 0; +- } ++ ++ } /* if getaddrinfo */ + } + return 1; + } +@@ -1161,16 +1205,11 @@ int main(int argc, char *argv[]) + skip_argv = 1; + //while(option != '\0') option++; + if (strcmp(argv[argc_cnt], "tcp") == 0) +- default_namespace = +- NAMESPACE_TCP; +- else if (strcmp(argv[argc_cnt], "udp") +- == 0) +- default_namespace = +- NAMESPACE_UDP; +- else if (strcmp(argv[argc_cnt], "file") +- == 0) +- default_namespace = +- NAMESPACE_FILE; ++ default_namespace = NAMESPACE_TCP; ++ else if (strcmp(argv[argc_cnt], "udp") == 0) ++ default_namespace = NAMESPACE_UDP; ++ else if (strcmp(argv[argc_cnt], "file") == 0) ++ default_namespace = NAMESPACE_FILE; + else + usage(_ + ("Invalid namespace name")); +@@ -1210,7 +1249,7 @@ int main(int argc, char *argv[]) + } + + #if defined(WITH_MOUNTINFO_LIST) +- if ((opts & OPT_ALWAYSSTAT) == 0) ++ if ((opts & (OPT_MOUNTS|OPT_ALWAYSSTAT)) == OPT_MOUNTS) + thestat = mntstat; + #endif + /* an option */ +@@ -1524,7 +1563,7 @@ print_matches(struct names *names_head, const opt_type opts, + + } + +-static struct stat *get_pidstat(const pid_t pid, const char *filename) ++static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id) + { + char pathname[256]; + struct stat *st; +@@ -1536,6 +1575,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename) + 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; + } + +@@ -1550,18 +1598,19 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, + struct inode_list *ino_tmp; + struct device_list *dev_tmp; + struct unixsocket_list *sock_tmp; +- struct stat st, lst; +- char dirpath[MAX_PATHNAME]; +- char filepath[MAX_PATHNAME]; ++ struct fdinfo fd; ++ struct stat st; ++ char dirpath[PATH_MAX+1]; ++ char filepath[PATH_MAX+1]; + +- snprintf(dirpath, MAX_PATHNAME, "/proc/%d/%s", pid, dirname); ++ snprintf(dirpath, PATH_MAX, "/proc/%d/%s", pid, dirname); + if ((dirp = opendir(dirpath)) == NULL) + return; + while ((direntry = readdir(dirp)) != NULL) { + if (direntry->d_name[0] < '0' || direntry->d_name[0] > '9') + continue; + +- snprintf(filepath, MAX_PATHNAME, "/proc/%d/%s/%s", ++ snprintf(filepath, PATH_MAX, "/proc/%d/%s/%s", + pid, dirname, direntry->d_name); + + if (timeout(thestat, filepath, &st, 5) != 0) { +@@ -1586,9 +1635,12 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, + dev_tmp = dev_tmp->next) { + if (thedev != dev_tmp->device) + continue; ++ if (get_fdinfo(pid, direntry->d_name, &fd) != 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 | +@@ -1610,9 +1662,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, + continue; + } + if (st.st_ino == ino_tmp->inode) { ++ if (get_fdinfo(pid, direntry->d_name, &fd) != 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 | +@@ -1641,18 +1694,30 @@ check_map(const pid_t pid, const char *filename, + FILE *fp; + unsigned long long tmp_inode; + unsigned int tmp_maj, tmp_min; +- dev_t tmp_device; + + snprintf(pathname, MAX_PATHNAME, "/proc/%d/%s", pid, filename); + if ((fp = fopen(pathname, "r")) == NULL) + return; + while (fgets(line, BUFSIZ, fp)) { +- if (sscanf(line, "%*s %*s %*s %x:%x %lld", +- &tmp_maj, &tmp_min, &tmp_inode) == 3) { +- tmp_device = tmp_maj * 256 + tmp_min; ++ char *scanned_path = NULL; ++ if (sscanf(line, "%*s %*s %*s %x:%x %lld %ms", ++ &tmp_maj, &tmp_min, &tmp_inode, &scanned_path) == 4) { ++ 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) ++ if (dev_tmp->device == tmp_device && ++ mnt_id == dev_tmp->mnt_id) + add_matched_proc(dev_tmp->name, pid, + uid, access); + for (ino_tmp = ino_head; ino_tmp != NULL; +@@ -1661,7 +1726,8 @@ check_map(const pid_t pid, const char *filename, + && ino_tmp->inode == tmp_inode) + add_matched_proc(ino_tmp->name, pid, + uid, access); +- } ++ } else if (scanned_path) ++ free(scanned_path); + } + fclose(fp); + } +@@ -1682,6 +1748,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 + */ ++static + void fill_unix_cache(struct unixsocket_list **unixsocket_head) + { + FILE *fp; +@@ -1698,6 +1765,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) + 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", + &scanned_inode, &scanned_path) != 2) { + if (scanned_path) +@@ -1713,6 +1782,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) + 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) { + free(path); +@@ -1721,6 +1792,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) + newsocket->sun_name = strdup(scanned_path); + newsocket->inode = st.st_ino; + newsocket->dev = st.st_dev; ++ newsocket->mnt_id = mnt_id; + newsocket->net_inode = scanned_inode; + newsocket->next = *unixsocket_head; + *unixsocket_head = newsocket; +@@ -1733,6 +1805,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) + /* + * Free up the list of Unix sockets + */ ++static + void clear_unix_cache(struct unixsocket_list **unixsocket_head) + { + while(*unixsocket_head != NULL) { +@@ -1900,30 +1973,22 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, + { + struct device_list *dev_tmp; + struct inode_list *ino_tmp; +- FILE *fp; +- char line[BUFSIZ]; +- char *find_mountp; +- char *find_space; + struct stat st; + +- 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; +- 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; +- } ++ + /* 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) + add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0, + find_mountp); + } +@@ -1935,7 +2000,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, + find_mountp); + } + } +- fclose(fp); + } + + static void +@@ -1985,16 +2049,42 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, + fclose(fp); + } + +-#if defined(WITH_MOUNTINFO_LIST) + /* + * 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 wherever possible. + */ + +-static list_t mntinfo = { &mntinfo, &mntinfo }; ++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) ++ mnt->isnfs = 1; ++ else mnt->isnfs = 0; ++ ++ return mnt; ++} + +-static void clear_mntinfo(void) ++static void ++clear_mntinfo(void) + { + list_t *ptr, *tmp; + +@@ -2005,72 +2095,229 @@ static void clear_mntinfo(void) + } + } + +-static void init_mntinfo(void) ++static void ++init_mntinfo(void) + { ++ char type[256]; + char mpoint[PATH_MAX*4 + 1]; // octal escaping takes 4 chars per 1 char +- int mid, parid, max = 0; ++ int mid, parid; ++#if defined(HAS_MOUNTINFO) + uint maj, min; +- list_t sort; ++#endif + FILE *mnt; + + if (!list_empty(&mntinfo)) + return; +- if ((mnt = fopen("/proc/self/mountinfo", "r")) == (FILE *) 0) ++#if defined(HAS_MOUNTINFO) ++ if ((mnt = fopen(PROC_MOUNTINFO, "r")) == (FILE *) 0) + return; + while (fscanf +- (mnt, "%i %i %u:%u %*s %s %*[^\n]", &mid, &parid, &maj, &min, +- &mpoint[0]) == 5) { +- 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); ++ (mnt, "%i %i %u:%u %*s %s %*s %*s - %s %*[^\n]", ++ &mid, &parid, &maj, &min, &mpoint[0], &type[0]) == 6) ++ (void)add_mntinfo(mpoint, type, mid, parid, makedev(maj, min)); ++#else ++ if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0) ++ return; ++ mid = 1; ++ parid = -1; ++ while (fscanf (mnt, "%*s %s %s %*[^\n]", &mpoint[0], &type[0]) == 2) { ++ struct stat st; ++ if (stat(mpoint, &st) != 0) { ++ if (errno != EACCES) { ++ fprintf(stderr, _("Cannot stat %s: %s\n"), ++ mnt->mpoint, strerror(errno)); ++ exit(1); ++ } ++ st.st_dev = (dev_t)-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; ++ (void)add_mntinfo(mpoint, type, mid++, parid, st.st_dev); + } ++#endif + fclose(mnt); ++} ++ ++static int ++get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info) ++{ ++#if defined(HAS_FDINFO) ++ const static char delimiters[] = ": \t\n"; ++ char pathname[256]; ++ char line[BUFSIZ]; ++ FILE *fp; ++ int ret = 0; ++ ++ snprintf(pathname, 256, "/proc/%d/fdinfo/%s", pid, fd); ++ if ((fp = fopen(pathname, "r")) == NULL) ++ goto out; ++ while (fgets(line, BUFSIZ, fp) && ret < 2) { ++ char *fp, *vp, *ep; ++ unsigned long ul; ++ fp = strtok(&line[0], delimiters); ++ if (!fp || *fp == 0) ++ continue; ++ vp = strtok(NULL, delimiters); ++ if (!vp || *vp == 0) ++ continue; ++ if (strcmp(fp, "flags") == 0 && (ul = strtoul(vp, &ep, 0)) != ULONG_MAX && ep && *ep == 0) { ++ info->flags = (mode_t)ul; ++ ret++; ++ } ++ if (strcmp(fp, "mnt_id") == 0 && (ul = strtoul(vp, &ep, 0)) != ULONG_MAX && ep && *ep == 0) { ++ info->mnt_id = (int)ul; ++ ret++; ++ } ++ ++ } ++ fclose(fp); ++out: ++#else ++ char pathname[256], *realname; ++ struct stat lst; ++ int ret = 0; ++ ++ snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd); ++ if (lstat(pathname, &lst) == 0) { ++ if (lst.st_mode & S_IWUSR) ++ info->flags |= O_WRONLY; ++ ret++; ++ } ++ ++ realname = expandpath(pathname); ++ if (realname) { ++ mntinfo_t *mountinfo; ++ if (find_mountpoint(realname, &mountinfo) == 0) { ++ info->mnt_id = mountinfo->id; ++ ret++; ++ } ++ } ++#endif ++ return ret == 2 ? 0 : -1; ++} ++ ++#if defined(HAS_NAME_TO_HANDLE_AT) ++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) ++ mnt_id = -1; ++ 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; + +- /* 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) { ++ *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 (mid != mnt->id) ++ ++ if (mnt_id != mnt->id) + continue; +- move_head(ptr, &sort); ++ ++ ret = 0; ++ errno = 0; ++ *mountinfo = mnt; + break; + } +- list_for_each_safe(ptr, tmp, &mntinfo) { ++ if (*mountinfo) ++ goto out; ++ ++ if (strlen(path) == 1 && path[0] == '/') { ++ struct stat st; ++ ++ /* could be a chroot or a container */ ++ ++ if (stat(path, &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 (stat(use, &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 (mid != mnt->parid) ++ ++ if (nlen != mnt->nlen) ++ continue; ++ ++ if (strcmp(use, mnt->mpoint)) + continue; +- move_head(ptr, &sort); ++ ++ ret = 0; ++ errno = 0; ++ *mountinfo = mnt; ++ break; + } +- } +- if (!list_empty(&mntinfo)) { +-#ifdef EBADE +- errno = EBADE; +-#else +- errno = ENOENT; +-#endif /* EBADE */ +- } +- join(&sort, &mntinfo); ++ ++ } while (!*mountinfo && (end = strrchr(use, '/'))); ++ free(use); ++out: ++ return ret; + } + ++#if defined(WITH_MOUNTINFO_LIST) + /* + * Determine device of links below /proc/ + */ +@@ -2078,8 +2325,7 @@ static int mntstat(const char *path, struct stat *buf) + { + char name[PATH_MAX + 1]; + const char *use; +- ssize_t nlen; +- list_t *ptr; ++ mntinfo_t *mnt; + + if ((use = realpath(path, name)) == NULL || *use != '/') + { +@@ -2091,27 +2337,26 @@ static int mntstat(const char *path, struct stat *buf) + errno = 0; + return stat(path, buf); + } ++ if (strncmp("/dev/", use, 5) == 0) { ++ /* ++ * Could be a special file (socket, pipe, inotify) ++ */ ++ errno = 0; ++ return stat(path, buf); ++ } + +- nlen = strlen(use); +- list_for_each(ptr, &mntinfo) { +- mntinfo_t *mnt = list_entry(ptr, mntinfo_t); +- if (nlen < mnt->nlen) +- continue; +- if (mnt->nlen == 1) { /* root fs is the last entry */ +- buf->st_dev = mnt->dev; +- buf->st_ino = 0; +- return 0; +- } +- if (use[mnt->nlen] != '\0' && use[mnt->nlen] != '/') +- continue; +- if (strncmp(use, mnt->mpoint, mnt->nlen) == 0) { +- buf->st_dev = mnt->dev; +- buf->st_ino = 0; +- return 0; +- } ++ if (find_mountpoint(use, &mnt) < 0) { ++ errno = ENOENT; ++ return -1; + } +- errno = ENOENT; +- return -1; ++ ++ if (mnt->isnfs) { ++ buf->st_dev = mnt->dev; ++ buf->st_ino = mnt->id; /* inode substitute */ ++ return 0; /* found on NFS */ ++ } ++ ++ return stat(path, buf); + } + #endif /* WITH_MOUNTINFO_LIST */ + +diff --git src/fuser.h src/fuser.h +index a4df711..4b9b1d6 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; ++ struct stat st; ++ int mnt_id; + struct procs *matched_procs; + struct names *next; + }; +@@ -65,12 +71,14 @@ struct inode_list { + struct names *name; + dev_t device; + ino_t inode; ++ int mnt_id; + struct inode_list *next; + }; + + struct device_list { + struct names *name; + dev_t device; ++ int mnt_id; + struct device_list *next; + }; + +@@ -79,6 +87,7 @@ struct unixsocket_list { + ino_t inode; + ino_t net_inode; + dev_t dev; ++ int mnt_id; + struct unixsocket_list *next; + }; + +@@ -87,18 +96,15 @@ 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 isnfs; + dev_t dev; + size_t nlen; + char *mpoint; + } mntinfo_t; +-#else +-# undef WITH_MOUNTINFO_LIST +-#endif + + #define NAMESPACE_FILE 0 + #define NAMESPACE_TCP 1 +@@ -108,5 +114,6 @@ typedef struct mntinfo_s { + #define MAX_CMDNAME 16 + + #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 b244893..1a10a1a 100644 +--- testsuite/killall.test/killall.exp ++++ testsuite/killall.test/killall.exp +@@ -7,7 +7,11 @@ set fake_proc_name "afakeprocname" + + set test "killall with no arguments" + spawn $killall ++if { $has_selinux == 0 } { + expect_pass "$test" "^Usage: killall \\\[OPTION\\\]\\.\\.\\. \\\[--\\\] NAME\\.\\.\\." ++} else { ++expect_pass "$test" "^Usage: killall \\\[ -Z CONTEXT \\\] \\\[ -u USER \\\] \\\[ -y TIME \\\] \\\[ -o TIME \\\] \\\[ -eIgiqrvw \\\]" ++} + + set test "killall list signals" + spawn $killall -l +-- +2.12.3 + diff --git a/psmisc-22.21-lessnfs.patch b/psmisc-22.21-lessnfs.patch deleted file mode 100644 index 153eaca..0000000 --- a/psmisc-22.21-lessnfs.patch +++ /dev/null @@ -1,81 +0,0 @@ -Use string comparision only if case of searching for NFS shares - ---- - src/fuser.c | 29 +++++++++++++++++++++-------- - src/fuser.h | 2 +- - 2 files changed, 22 insertions(+), 9 deletions(-) - ---- src/fuser.c -+++ src/fuser.c 2017-06-20 14:30:08.176217649 +0000 -@@ -2007,6 +2007,7 @@ static void clear_mntinfo(void) - - static void init_mntinfo(void) - { -+ char type[256]; - char mpoint[PATH_MAX*4 + 1]; // octal escaping takes 4 chars per 1 char - int mid, parid, max = 0; - uint maj, min; -@@ -2018,8 +2019,8 @@ static void init_mntinfo(void) - if ((mnt = fopen("/proc/self/mountinfo", "r")) == (FILE *) 0) - return; - while (fscanf -- (mnt, "%i %i %u:%u %*s %s %*[^\n]", &mid, &parid, &maj, &min, -- &mpoint[0]) == 5) { -+ (mnt, "%i %i %u:%u %*s %s %*s %*s - %s %*[^\n]", -+ &mid, &parid, &maj, &min, &mpoint[0], &type[0]) == 6) { - const size_t nlen = strlen(mpoint); - mntinfo_t *restrict mnt; - if (posix_memalign -@@ -2038,6 +2039,9 @@ static void init_mntinfo(void) - mnt->parid = parid; - mnt->dev = makedev(maj, min); - mnt->id = mid; -+ if (strncmp("nfs", type, 3) == 0) -+ mnt->nfs = 1; -+ else mnt->nfs = 0; - if (mid > max) - max = mid; - } -@@ -2105,16 +2109,25 @@ static int mntstat(const char *path, str - if (nlen < mnt->nlen) - continue; - if (mnt->nlen == 1) { /* root fs is the last entry */ -- buf->st_dev = mnt->dev; -- buf->st_ino = 0; -- return 0; -+ if (mnt->nfs) { -+ fprintf(stderr, "NFS %s\n", use); -+ buf->st_dev = mnt->dev; -+ buf->st_ino = 0; -+ return 0; -+ } -+ errno = 0; -+ return stat(path, buf); - } - if (use[mnt->nlen] != '\0' && use[mnt->nlen] != '/') - continue; - if (strncmp(use, mnt->mpoint, mnt->nlen) == 0) { -- buf->st_dev = mnt->dev; -- buf->st_ino = 0; -- return 0; -+ if (mnt->nfs) { -+ buf->st_dev = mnt->dev; -+ buf->st_ino = 0; -+ return 0; -+ } -+ errno = 0; -+ return stat(path, buf); - } - } - errno = ENOENT; ---- src/fuser.h -+++ src/fuser.h 2017-06-20 14:28:48.013689702 +0000 -@@ -91,7 +91,7 @@ struct mount_list { - # include "lists.h" - typedef struct mntinfo_s { - list_t this; -- int id, parid; -+ int id, parid, nfs:1; - dev_t dev; - size_t nlen; - char *mpoint; diff --git a/psmisc-22.21-mntpt.patch b/psmisc-22.21-mntpt.patch deleted file mode 100644 index 6c57037..0000000 --- a/psmisc-22.21-mntpt.patch +++ /dev/null @@ -1,23 +0,0 @@ -For bug boo#908068: fuser -m not handling block devices properly -Avoid string comparision for device files - ---- - src/fuser.c | 7 +++++++ - 1 file changed, 7 insertions(+) - ---- src/fuser.c -+++ src/fuser.c 2017-06-20 13:56:29.717283482 +0000 -@@ -1915,6 +1915,13 @@ static int mntstat(const char *path, str - errno = 0; - return stat(path, buf); - } -+ if (strncmp("/dev/", use, 5) == 0) { -+ /* -+ * Could be a special file (socket, pipe, inotify) -+ */ -+ errno = 0; -+ return stat(path, buf); -+ } - - nlen = strlen(use); - list_for_each(ptr, &mntinfo) { diff --git a/psmisc-23.0-net.patch b/psmisc-23.0-net.patch deleted file mode 100644 index 940767b..0000000 --- a/psmisc-23.0-net.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- - src/fuser.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- src/fuser.c -+++ src/fuser.c 2017-06-28 16:52:23.402294591 +0000 -@@ -1210,7 +1210,7 @@ int main(int argc, char *argv[]) - } - - #if defined(WITH_MOUNTINFO_LIST) -- if ((opts & OPT_ALWAYSSTAT) == 0) -+ if ((opts & (OPT_MOUNTS|OPT_ALWAYSSTAT)) == OPT_MOUNTS) - thestat = mntstat; - #endif - /* an option */ diff --git a/psmisc-23.0.dif b/psmisc-23.0.dif index 9f6f515..e1c371e 100644 --- a/psmisc-23.0.dif +++ b/psmisc-23.0.dif @@ -1,21 +1,21 @@ --- configure.ac | 4 ++-- doc/Makefile.am | 2 +- - src/fuser.c | 13 ++++++++----- - 3 files changed, 11 insertions(+), 8 deletions(-) + src/fuser.c | 5 ++++- + 3 files changed, 7 insertions(+), 4 deletions(-) --- configure.ac -+++ configure.ac 2017-06-28 13:10:43.594188007 +0000 -@@ -42,7 +42,7 @@ fi ++++ configure.ac 2017-07-05 13:18:18.806270222 +0000 +@@ -45,7 +45,7 @@ fi if test "$enable_timeout_stat" = "static"; then AC_DEFINE([WITH_TIMEOUT_STAT], [2], [Use timeout on stat calls]) fi -AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"]) +AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" != "no"]) - # Use string search for network based file systems but only if the system - # has /proc/self/mountinfo -@@ -126,7 +126,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc + # Use /proc/self/mountinfo if available + if test -e /proc/self/mountinfo ; then +@@ -142,7 +142,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc struct user_regs_struct.rdi, struct user_regs_struct.rsi, struct user_regs_struct.rdx], [],[], @@ -25,7 +25,7 @@ AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3, struct pt_regs.gpr], [],[], [#include ]) --- doc/Makefile.am -+++ doc/Makefile.am 2017-06-28 13:10:43.594188007 +0000 ++++ doc/Makefile.am 2017-07-05 13:18:18.806270222 +0000 @@ -1,5 +1,5 @@ -man_MANS = killall.1 peekfd.1 prtstat.1 pstree.1 @@ -34,8 +34,8 @@ if WANT_FUSER --- src/fuser.c -+++ src/fuser.c 2017-06-28 13:10:43.594188007 +0000 -@@ -1041,6 +1041,7 @@ int main(int argc, char *argv[]) ++++ src/fuser.c 2017-07-05 13:18:18.806270222 +0000 +@@ -1085,6 +1085,7 @@ int main(int argc, char *argv[]) struct option *optr; char *nsptr; int skip_argv; @@ -43,7 +43,7 @@ struct option options[] = { {"all", 0, NULL, 'a'}, -@@ -1084,6 +1085,7 @@ int main(int argc, char *argv[]) +@@ -1128,6 +1129,7 @@ int main(int argc, char *argv[]) #endif atexit(atexit_free_lists); @@ -51,7 +51,7 @@ for (argc_cnt = 1; argc_cnt < argc; argc_cnt++) { current_argv = argv[argc_cnt]; if (current_argv[0] == '-') { /* its an option */ -@@ -1235,6 +1237,7 @@ int main(int argc, char *argv[]) +@@ -1273,6 +1275,7 @@ int main(int argc, char *argv[]) } } this_name->matched_procs = NULL; @@ -59,7 +59,7 @@ if (opts & (OPT_MOUNTS | OPT_ISMOUNTPOINT) && this_name->name_space != NAMESPACE_FILE) { free(this_name); -@@ -1288,7 +1291,7 @@ int main(int argc, char *argv[]) +@@ -1326,7 +1329,7 @@ int main(int argc, char *argv[]) names_tail->next = this_name; names_tail = this_name; } /* for across the argvs */ @@ -68,25 +68,3 @@ usage(_("No process specification given")); /* Check if -M flag was used and if so check mounts */ -@@ -1552,17 +1555,17 @@ check_dir(const pid_t pid, const char *d - struct device_list *dev_tmp; - struct unixsocket_list *sock_tmp; - struct stat st, lst; -- char dirpath[MAX_PATHNAME]; -- char filepath[MAX_PATHNAME]; -+ char dirpath[PATH_MAX+1]; -+ char filepath[PATH_MAX+1]; - -- snprintf(dirpath, MAX_PATHNAME, "/proc/%d/%s", pid, dirname); -+ snprintf(dirpath, PATH_MAX , "/proc/%d/%s", pid, dirname); - if ((dirp = opendir(dirpath)) == NULL) - return; - while ((direntry = readdir(dirp)) != NULL) { - if (direntry->d_name[0] < '0' || direntry->d_name[0] > '9') - continue; - -- snprintf(filepath, MAX_PATHNAME, "/proc/%d/%s/%s", -+ snprintf(filepath, PATH_MAX, "/proc/%d/%s/%s", - pid, dirname, direntry->d_name); - - if (timeout(thestat, filepath, &st, 5) != 0) { diff --git a/psmisc.changes b/psmisc.changes index f6f9e87..a43e6eb 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,23 @@ +------------------------------------------------------------------- +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 diff --git a/psmisc.spec b/psmisc.spec index 0441544..9eaf256 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -17,7 +17,9 @@ Name: psmisc +BuildRequires: autoconf BuildRequires: automake +BuildRequires: dejagnu BuildRequires: gcc-c++ BuildRequires: gettext-devel BuildRequires: glibc-devel @@ -35,14 +37,11 @@ Group: System/Monitoring Source: https://gitlab.com/%{name}/%{name}/repository/archive.tar.bz2?ref=v%{version}#/%{name}-%{version}.tar.bz2 Patch0: %{name}-%{version}.dif Patch2: %{name}-22.21-pstree.patch -# PATCH-FIX-SUSE boo#908068 -- fuser -m not handling block devices properly -Patch4: %{name}-22.21-mntpt.patch -# PATCH-ADD-SUSE use string comparision only for nfs shares -Patch5: %{name}-22.21-lessnfs.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 # PATCH-FIX_UPSTREAM boo#1046237 -- Debug output in killall from psmisc package -Patch6: %{name}-%{version}-killall.patch -# PATCH-FIX-SUSE broken net support as the mntstat does not work with fd of sockets -Patch7: %{name}-%{version}-net.patch +Patch4: %{name}-%{version}-killall.patch %define have_peekfd %ix86 x86_64 ppc ppc64 ppc64le %arm mipsel m68k @@ -60,11 +59,9 @@ processes that are using specified files or filesystems. ln -sf %{name}-v%{version}-%{hash} %{name}-%version %setup -q -D -n %{name}-%version %patch2 -p0 -b .pstree -%patch4 -p0 -b .mntpt -%patch5 -p0 -b .lessnfs -%patch6 -p0 -b .ka -%patch7 -p0 -b .net -%patch0 -p0 -b .0 +%patch3 -p0 -b .mntinf +%patch4 -p0 -b .ka +%patch0 -p0 -b .p0 %build grep -h src/ po/*.po|\ @@ -83,6 +80,9 @@ export CFLAGS CXXFLAGS --enable-timeout-stat=static make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" +%check +make check + %install make DESTDIR=%{buildroot} install mkdir -p %{buildroot}/bin/