Dr. Werner Fink 2009-10-12 15:18:14 +00:00 committed by Git OBS Bridge
parent a0083cf69d
commit 20c741fed8
2 changed files with 27 additions and 12 deletions

View File

@ -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-10-09 18:43:54.839930561 +0200
+++ src/fuser.c 2009-10-12 17:14:23.228525394 +0200
@@ -32,9 +32,11 @@
#include <stdlib.h>
#include <string.h>
@ -444,7 +444,7 @@
/* File specifications */
if ( (this_name = malloc(sizeof(struct names))) == NULL)
continue;
@@ -828,10 +1051,14 @@ int main(int argc, char *argv[])
@@ -828,10 +1051,24 @@ int main(int argc, char *argv[])
break;
default: /* FILE */
this_name->filename = strdup(argv[optc]);
@ -454,6 +454,16 @@
+ len = strlen(this_name->filename);
+ if (len > 1 && this_name->filename[len-1] == '/')
+ this_name->filename[len-1] = '\0';
+ if (len > 1 && this_name->filename[0] != '/') {
+ char pwd[MAX_PATHNAME];
+ if (getcwd(pwd, MAX_PATHNAME-1)) {
+ char *new, *old = this_name->filename;
+ if (asprintf(&new, "%s/%s", (strlen(pwd) > 1 ? pwd : ""), old) > 0) {
+ this_name->filename = new;
+ free(old);
+ }
+ }
+ }
+ parse_file(this_name, &match_inodes, opts);
+ parse_unixsockets(this_name, &match_inodes, unixsockets, netdev, opts);
+ if (opts & (OPT_MOUNTPOINT | OPT_MOUNTS)) {
@ -462,7 +472,7 @@
break;
}
@@ -872,10 +1099,11 @@ int main(int argc, char *argv[])
@@ -872,10 +1109,11 @@ int main(int argc, char *argv[])
#ifdef DEBUG
debug_match_lists(names_head, match_inodes, match_devices);
#endif
@ -475,7 +485,7 @@
return print_matches(names_head,opts, sig_number);
}
@@ -978,7 +1206,7 @@ static int print_matches(struct names *n
@@ -978,7 +1216,7 @@ static int print_matches(struct names *n
}
@ -484,7 +494,7 @@
{
char pathname[256];
struct stat *st;
@@ -986,6 +1214,10 @@ static struct stat *get_pidstat(const pi
@@ -986,6 +1224,10 @@ static struct stat *get_pidstat(const pi
if ( (st = malloc(sizeof(struct stat))) == NULL)
return NULL;
snprintf(pathname, 256, "/proc/%d/%s", pid, filename);
@ -495,7 +505,7 @@
if (stat(pathname, st) != 0)
return NULL;
else
@@ -1030,6 +1262,16 @@ static void check_dir(const pid_t pid, c
@@ -1030,6 +1272,16 @@ static void check_dir(const pid_t pid, c
}
}
for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
@ -512,7 +522,7 @@
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 +1281,16 @@ static void check_dir(const pid_t pid, c
@@ -1039,6 +1291,16 @@ static void check_dir(const pid_t pid, c
}
}
for (ino_tmp = ino_head ; ino_tmp != NULL ; ino_tmp = ino_tmp->next) {
@ -529,7 +539,7 @@
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 +1302,8 @@ static void check_dir(const pid_t pid, c
@@ -1050,6 +1312,8 @@ static void check_dir(const pid_t pid, c
}
} /* while fd_dent */
closedir(dirp);
@ -538,7 +548,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)
@@ -1069,13 +1323,36 @@ static void check_map(const pid_t pid, c
@@ -1069,13 +1333,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) {
@ -577,7 +587,7 @@
}
}
fclose(fp);
@@ -1146,6 +1423,16 @@ void fill_unix_cache(struct unixsocket_l
@@ -1146,6 +1433,16 @@ void fill_unix_cache(struct unixsocket_l
}
@ -594,7 +604,7 @@
/*
* scan_mount_devices : Create a list of mount points and devices
* This list is used later for matching purposes
@@ -1155,17 +1442,94 @@ void scan_mount_devices(const opt_type o
@@ -1155,17 +1452,94 @@ void scan_mount_devices(const opt_type o
FILE *mntfp;
struct mntent *mnt_ptr;
struct stat st;
@ -691,7 +701,7 @@
}
#ifdef DEBUG
@@ -1291,3 +1655,56 @@ static void scan_knfsd(struct names *nam
@@ -1291,3 +1665,56 @@ static void scan_knfsd(struct names *nam
}
}
#endif /* NFSCHECKS */

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
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