Michael Reed([email protected]) on 2016.01.01 22:29:08 -0500:
> 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
Hi,
thanks for your bug report. I think we still want pledge calls and arguments
grepable, so i would like to commit this instead:
ok?
diff --git usr.bin/fstat/fstat.c usr.bin/fstat/fstat.c
index cc51086..98c9760 100644
--- usr.bin/fstat/fstat.c
+++ usr.bin/fstat/fstat.c
@@ -276,9 +276,19 @@ main(int argc, char *argv[])
errx(1, "%s", kvm_geterr(kd));
if (fuser) {
- if (sflg) { /* fuser might call kill(2) */
+ if (sflg && uflg) {
+ /*
+ * sflg (signal) calls kill(2) -> proc
+ * uflg needs getpw
+ */
+ if (pledge("stdio getpw rpath proc", NULL) == -1)
+ err(1, "pledge");
+ } else if (sflg && !uflg) {
if (pledge("stdio rpath proc", NULL) == -1)
err(1, "pledge");
+ } else if (!sflg && uflg) {
+ if (pledge("stdio getpw rpath", NULL) == -1)
+ err(1, "pledge");
} else {
if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");