2017-06-20 16:04:40 +02:00
|
|
|
---
|
|
|
|
configure.ac | 4 ++--
|
|
|
|
src/fuser.c | 16 ++++++++++------
|
|
|
|
2 files changed, 12 insertions(+), 8 deletions(-)
|
|
|
|
|
2010-10-15 16:44:11 +02:00
|
|
|
--- configure.ac
|
2017-06-20 16:04:40 +02:00
|
|
|
+++ configure.ac 2017-06-20 13:46:32.464296485 +0000
|
2014-03-24 17:13:40 +01:00
|
|
|
@@ -40,7 +40,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
|
2012-12-18 18:20:19 +01:00
|
|
|
@@ -121,7 +121,7 @@ AC_CHECK_MEMBERS([struct user_regs_struc
|
2010-10-15 16:44:11 +02:00
|
|
|
struct user_regs_struct.rdi,
|
|
|
|
struct user_regs_struct.rsi,
|
|
|
|
struct user_regs_struct.rdx], [],[],
|
|
|
|
- [#include <bits/types.h>
|
|
|
|
+ [#include <sys/types.h>
|
|
|
|
#include <sys/user.h>])
|
|
|
|
AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3,
|
|
|
|
struct pt_regs.gpr], [],[], [#include <linux/ptrace.h>])
|
2010-07-13 18:50:33 +02:00
|
|
|
--- src/fuser.c
|
2017-06-20 16:04:40 +02:00
|
|
|
+++ src/fuser.c 2017-06-20 13:46:32.548294929 +0000
|
|
|
|
@@ -34,6 +34,7 @@
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
+#include <sys/sysmacros.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
@@ -901,6 +902,7 @@ int main(int argc, char *argv[])
|
2012-12-18 18:20:19 +01:00
|
|
|
struct option *optr;
|
2010-07-13 18:50:33 +02:00
|
|
|
char *nsptr;
|
2012-12-18 18:20:19 +01:00
|
|
|
int skip_argv;
|
2010-07-13 18:50:33 +02:00
|
|
|
+ int seen_file;
|
|
|
|
|
|
|
|
struct option options[] = {
|
2011-02-08 17:55:25 +01:00
|
|
|
{"all", 0, NULL, 'a'},
|
2017-06-20 16:04:40 +02:00
|
|
|
@@ -941,6 +943,7 @@ int main(int argc, char *argv[])
|
2010-07-13 18:50:33 +02:00
|
|
|
fill_unix_cache(&unixsockets);
|
2012-12-18 18:20:19 +01:00
|
|
|
#endif
|
2010-07-13 18:50:33 +02:00
|
|
|
|
2012-12-18 18:20:19 +01:00
|
|
|
+ seen_file = 0;
|
|
|
|
for (argc_cnt = 1; argc_cnt < argc; argc_cnt++) {
|
|
|
|
current_argv = argv[argc_cnt];
|
|
|
|
if (current_argv[0] == '-') { /* its an option */
|
2017-06-20 16:04:40 +02:00
|
|
|
@@ -1093,6 +1096,7 @@ int main(int argc, char *argv[])
|
2010-07-13 18:50:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this_name->matched_procs = NULL;
|
|
|
|
+ seen_file = 1;
|
2012-12-18 18:20:19 +01:00
|
|
|
if (opts & (OPT_MOUNTS | OPT_ISMOUNTPOINT)
|
2010-07-13 18:50:33 +02:00
|
|
|
&& this_name->name_space != NAMESPACE_FILE)
|
|
|
|
usage(_
|
2017-06-20 16:04:40 +02:00
|
|
|
@@ -1144,7 +1148,7 @@ int main(int argc, char *argv[])
|
2010-07-13 18:50:33 +02:00
|
|
|
names_tail->next = this_name;
|
|
|
|
names_tail = this_name;
|
2012-12-18 18:20:19 +01:00
|
|
|
} /* for across the argvs */
|
2010-07-13 18:50:33 +02:00
|
|
|
- if (names_head == NULL)
|
|
|
|
+ if (names_head == NULL && !seen_file)
|
|
|
|
usage(_("No process specification given"));
|
|
|
|
|
2014-03-24 17:13:40 +01:00
|
|
|
/* Check if -M flag was used and if so check mounts */
|
2017-06-20 16:04:40 +02:00
|
|
|
@@ -1394,17 +1398,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) {
|
|
|
|
@@ -1541,7 +1545,7 @@ void fill_unix_cache(struct unixsocket_l
|
|
|
|
while (fgets(line, BUFSIZ, fp) != NULL) {
|
|
|
|
char *path;
|
|
|
|
char *scanned_path = NULL;
|
|
|
|
- if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %as",
|
|
|
|
+ if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %ms",
|
|
|
|
&scanned_inode, &scanned_path) != 2) {
|
|
|
|
if (scanned_path)
|
|
|
|
free(scanned_path);
|