.
OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=9
This commit is contained in:
parent
568a4d99b2
commit
223d0f383d
@ -33,7 +33,7 @@
|
||||
cannot report on any processes that it doesn't have permission to look at
|
||||
the file descriptor table for. The most common time this problem occurs
|
||||
--- src/fuser.c
|
||||
+++ src/fuser.c 2009-05-11 13:45:16.565902120 +0200
|
||||
+++ src/fuser.c 2009-10-09 18:43:54.839930561 +0200
|
||||
@@ -32,9 +32,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -85,6 +85,15 @@
|
||||
|
||||
static void usage (const char *errormsg)
|
||||
{
|
||||
@@ -92,7 +102,7 @@ static void usage (const char *errormsg)
|
||||
" fuser -V\n"
|
||||
"Show which processes use the named files, sockets, or filesystems.\n\n"
|
||||
" -a display unused files too\n"
|
||||
- " -c Same as \-m (for POSIX compatibility)\n"
|
||||
+ " -c Same as -m (for POSIX compatibility)\n"
|
||||
" -f silently ignored (for POSIX compatibility)\n"
|
||||
" -i ask before killing (ignored without -k)\n"
|
||||
" -k kill processes accessing the named file\n"
|
||||
@@ -127,7 +137,14 @@ void print_version()
|
||||
"For more information about these matters, see the files named COPYING.\n"));
|
||||
}
|
||||
@ -486,25 +495,41 @@
|
||||
if (stat(pathname, st) != 0)
|
||||
return NULL;
|
||||
else
|
||||
@@ -1030,6 +1262,8 @@ static void check_dir(const pid_t pid, c
|
||||
@@ -1030,6 +1262,16 @@ static void check_dir(const pid_t pid, c
|
||||
}
|
||||
}
|
||||
for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
|
||||
+ if (dev_tmp->name->name_space & NAMESPACE_NFS)
|
||||
+ if (dev_tmp->name->name_space & NAMESPACE_NFS) {
|
||||
+ char buf[PATH_MAX+1];
|
||||
+ ssize_t len;
|
||||
+ if ((len = readlink(filepath, buf, PATH_MAX)) < 0)
|
||||
+ continue;
|
||||
+ buf[len] = '\0'; /* Don't be fooled by readlink(2) */
|
||||
+ if (islocatedon(buf, dev_tmp->name->filename))
|
||||
+ add_matched_proc(dev_tmp->name, pid,uid, access);
|
||||
+ continue;
|
||||
+ }
|
||||
if (st.st_dev == dev_tmp->device) {
|
||||
if (access == ACCESS_FILE && (lstat(filepath, &lst)==0) && (lst.st_mode & S_IWUSR)) {
|
||||
add_matched_proc(dev_tmp->name, pid,uid, ACCESS_FILEWR|access);
|
||||
@@ -1039,6 +1273,8 @@ static void check_dir(const pid_t pid, c
|
||||
@@ -1039,6 +1281,16 @@ static void check_dir(const pid_t pid, c
|
||||
}
|
||||
}
|
||||
for (ino_tmp = ino_head ; ino_tmp != NULL ; ino_tmp = ino_tmp->next) {
|
||||
+ if (ino_tmp->name->name_space & NAMESPACE_NFS)
|
||||
+ if (ino_tmp->name->name_space & NAMESPACE_NFS) {
|
||||
+ char buf[PATH_MAX+1];
|
||||
+ ssize_t len;
|
||||
+ if ((len = readlink(filepath, buf, PATH_MAX)) < 0)
|
||||
+ continue;
|
||||
+ buf[len] = '\0'; /* Don't be fooled by readlink(2) */
|
||||
+ if (islocatedon(buf, ino_tmp->name->filename))
|
||||
+ add_matched_proc(ino_tmp->name, pid,uid, access);
|
||||
+ continue;
|
||||
+ }
|
||||
if (st.st_dev == ino_tmp->device && st.st_ino == ino_tmp->inode) {
|
||||
if (access == ACCESS_FILE && (lstat(filepath, &lst)==0) && (lst.st_mode & S_IWUSR)) {
|
||||
add_matched_proc(ino_tmp->name, pid,uid, ACCESS_FILEWR|access);
|
||||
@@ -1050,6 +1286,8 @@ static void check_dir(const pid_t pid, c
|
||||
@@ -1050,6 +1302,8 @@ static void check_dir(const pid_t pid, c
|
||||
}
|
||||
} /* while fd_dent */
|
||||
closedir(dirp);
|
||||
@ -513,28 +538,46 @@
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -1070,12 +1308,18 @@ static void check_map(const pid_t pid, c
|
||||
@@ -1069,13 +1323,36 @@ static void check_map(const pid_t pid, c
|
||||
while (fgets(line,BUFSIZ, fp)) {
|
||||
if (sscanf(line, "%*s %*s %*s %x:%x %lld",
|
||||
&tmp_maj, &tmp_min, &tmp_inode) == 3) {
|
||||
+ const char * filepath = strchr(line, '/');
|
||||
tmp_device = tmp_maj * 256 + tmp_min;
|
||||
- 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 (dev_tmp->name->name_space & NAMESPACE_NFS)
|
||||
+ if (dev_tmp->name->name_space & NAMESPACE_NFS) {
|
||||
+ char *nl;
|
||||
+ if (!filepath)
|
||||
+ continue;
|
||||
+ if ((nl = strchr(filepath, '\n')))
|
||||
+ nl = '\0';
|
||||
+ if (islocatedon(filepath, dev_tmp->name->filename))
|
||||
+ add_matched_proc(dev_tmp->name, pid,uid, access);
|
||||
+ continue;
|
||||
+ }
|
||||
if (dev_tmp->device == tmp_device)
|
||||
add_matched_proc(dev_tmp->name, pid, uid, access);
|
||||
- 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 (ino_tmp->name->name_space & NAMESPACE_NFS)
|
||||
+ if (ino_tmp->name->name_space & NAMESPACE_NFS) {
|
||||
+ char *nl;
|
||||
+ if (!filepath)
|
||||
+ continue;
|
||||
+ if ((nl = strchr(filepath, '\n')))
|
||||
+ nl = '\0';
|
||||
+ if (islocatedon(filepath, ino_tmp->name->filename))
|
||||
+ add_matched_proc(ino_tmp->name, pid,uid, access);
|
||||
+ continue;
|
||||
+ }
|
||||
if (ino_tmp->device == tmp_device && ino_tmp->inode == tmp_inode)
|
||||
add_matched_proc(ino_tmp->name, pid, uid, access);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
@@ -1146,6 +1390,16 @@ void fill_unix_cache(struct unixsocket_l
|
||||
@@ -1146,6 +1423,16 @@ void fill_unix_cache(struct unixsocket_l
|
||||
|
||||
}
|
||||
|
||||
@ -551,7 +594,7 @@
|
||||
/*
|
||||
* scan_mount_devices : Create a list of mount points and devices
|
||||
* This list is used later for matching purposes
|
||||
@@ -1155,17 +1409,94 @@ void scan_mount_devices(const opt_type o
|
||||
@@ -1155,17 +1442,94 @@ void scan_mount_devices(const opt_type o
|
||||
FILE *mntfp;
|
||||
struct mntent *mnt_ptr;
|
||||
struct stat st;
|
||||
@ -605,8 +648,8 @@
|
||||
add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, st.st_dev);
|
||||
+ } else {
|
||||
+ fprintf(stderr, _("Cannot stat file %s: %s\n"), mnt_ptr->mnt_dir, strerror(errno));
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+ endmntent(mntfp);
|
||||
+
|
||||
+ if (!mnts)
|
||||
@ -641,14 +684,14 @@
|
||||
+ s->next = p->shadow;
|
||||
+ s->prev = (struct shadow_list*)0;
|
||||
+ p->shadow = s;
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
+out:
|
||||
+ endmntent(mntfp);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -1291,3 +1622,56 @@ static void scan_knfsd(struct names *nam
|
||||
@@ -1291,3 +1655,56 @@ static void scan_knfsd(struct names *nam
|
||||
}
|
||||
}
|
||||
#endif /* NFSCHECKS */
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user