Hi,

`fuser -u -c /' doesn't seem to work for me:

    fuser(28663): syscall 33 "getpw"

The patch below fixes my issue.  The pledge condition was already a bit
long, so I just switched to snprintf(3); not sure what's normally done
in such situations.

Regards,
  Michael



Index: fstat.c
===================================================================
RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.85
diff -u -p -r1.85 fstat.c
--- fstat.c     30 Dec 2015 19:02:12 -0000      1.85
+++ fstat.c     2 Jan 2016 03:18:17 -0000
@@ -142,6 +142,7 @@ main(int argc, char *argv[])
        int arg, ch, what;
        char *memf, *nlistf, *optstr;
        char buf[_POSIX2_LINE_MAX];
+       char promises[1024];
        const char *errstr;
        int cnt, flags;
 
@@ -275,18 +276,12 @@ main(int argc, char *argv[])
        if ((kf = kvm_getfiles(kd, what, arg, sizeof(*kf), &cnt)) == NULL)
                errx(1, "%s", kvm_geterr(kd));
 
-       if (fuser) {
-               if (sflg) { /* fuser might call kill(2) */
-                       if (pledge("stdio rpath proc", NULL) == -1)
-                               err(1, "pledge");
-               } else {
-                       if (pledge("stdio rpath", NULL) == -1)
-                               err(1, "pledge");
-               }
-       } else {
-               if (pledge("stdio rpath getpw", NULL) == -1)
-                       err(1, "pledge");
-       }
+       snprintf(promises, sizeof(promises), "stdio rpath%s%s",
+           (fuser && sflg) ? " proc" : "",  /* fuser might call kill(2) */
+           (!fuser || uflg) ? " getpw" : "");
+
+       if (pledge(promises, NULL) == -1)
+               err(1, "pledge");
 
        find_splices(kf, cnt);
        if (!fuser)

Reply via email to