]> granicus.if.org Git - psmisc/commitdiff
F for write access
authorCraig Small <csmall@users.sourceforge.net>
Wed, 13 Jul 2005 04:16:27 +0000 (04:16 +0000)
committerCraig Small <csmall@users.sourceforge.net>
Wed, 13 Jul 2005 04:16:27 +0000 (04:16 +0000)
ChangeLog
doc/fuser.1
src/fuser.c
src/fuser.h

index 827349c1b1aa5f19c852834f921196af63c86858..71e8b80674f973596b734a2da128d224ce97240c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,10 +4,10 @@ Changes in 21.7
        * define rpmatch for libraries that dont have it
        * Fixed small typos in help, thanks to Benno Schulenberg
          fixes SF# 1150042
-       * fusernew - this will be the new fuser once it gets tested on
-         those strange setups folks out there have
        * Completed change from Flask to SELinux, thanks to Benno Schulenberg
        * pstree works better with uClibc, thanks Mike Frysinger
+       * fuser rewritten: possibly fixes Debian #312560
+       * fuser prints F instead of f is access is write, thanks to Tet.
 
 Changes in 21.6
 ===============
index 8484a1d3fc98445ef17dd16922f78fa976f3705f..0d89cc3cffc90cfd6846fdc2a29f022b8c51dfa6 100644 (file)
@@ -32,6 +32,8 @@ current directory.
 executable being run.
 .IP \fBf\fP
 open file. \fBf\fP is omitted in default display mode.
+.IP \fBF\fP
+open file for writing. \fBF\fP is omitted in default display mode.
 .IP \fBr\fP
 root directory.
 .IP \fBm\fP
index 8586957655093e79683dd630f40127f204931f62..4530082055c5347b2cfd9271a96c46af0da21d5b 100644 (file)
@@ -811,7 +811,7 @@ static void print_matches(struct names *names_head, const opt_type opts, const i
                        fflush(stdout);
                        if (opts & OPT_VERBOSE) {
                                fprintf(stderr, " %c%c%c%c%c ",
-                                               pptr->access & ACCESS_FILE ? 'f' : '.',
+                                               pptr->access & ACCESS_FILE ? (pptr->access & ACCESS_FILEWR ? 'F' : 'f' ) : '.',
                                                pptr->access & ACCESS_ROOT ? 'r' : '.',
                                                pptr->access & ACCESS_CWD ? 'c' : '.',
                                                pptr->access & ACCESS_EXE ? 'e' : '.',
@@ -871,7 +871,7 @@ static void check_dir(const pid_t pid, const char *dirname, struct device_list *
        struct dirent *direntry;
        struct inode_list *ino_tmp;
        struct device_list *dev_tmp;
-       struct stat st;
+       struct stat st, lst;
 
        if ( (dirpath = malloc(MAX_PATHNAME)) == NULL)
                return;
@@ -891,12 +891,22 @@ static void check_dir(const pid_t pid, const char *dirname, struct device_list *
                        fprintf(stderr, _("Cannot stat file %s: %s\n"),filepath, strerror(errno));
                } else {
                        for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
-                               if (st.st_dev == dev_tmp->device)
-                                       add_matched_proc(dev_tmp->name, pid,uid, access);
+                               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);
+                                       } else  {
+                                               add_matched_proc(dev_tmp->name, pid,uid, access);
+                                       }
+                               }
                        }
                        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)
-                                       add_matched_proc(ino_tmp->name, pid,uid, access);
+                               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);
+                                       } else {
+                                               add_matched_proc(ino_tmp->name, pid,uid, access);
+                                       }
+                               }
                        }
                }
        } /* while fd_dent */
index dbdf8f32a810f3a1639a5eb3ad00f0b8353c04e6..2cc563e5836d2491d8cfea13c9ce1f7281184b90 100644 (file)
@@ -26,6 +26,7 @@ struct procs {
 #define ACCESS_FILE 4
 #define ACCESS_ROOT 8
 #define ACCESS_MMAP 16
+#define ACCESS_FILEWR 32
 
 struct names {
        char *filename;