Hi,
This adds pledge to midiplay, it only needs stdio rpath if reading
files, otherwise (playing the sample or from stdin) only stdio is
needed.
OK?
Index: midiplay.c
===
RCS file: /cvs/src/usr.bin/midiplay/midiplay.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 midiplay.c
--- midiplay.c 24 Apr 2017 06:45:56 - 1.19
+++ midiplay.c 20 Jul 2018 08:08:27 -
@@ -446,7 +446,7 @@ main(int argc, char **argv)
}
argc -= optind;
argv += optind;
-
+
hdl = mio_open(file, MIO_OUT, 0);
if (hdl == NULL)
errx(1, "failed to open MIDI output");
@@ -463,11 +463,22 @@ main(int argc, char **argv)
if (setitimer(ITIMER_REAL, &it, NULL) < 0)
err(1, "setitimer");
- if (example)
+ if (example) {
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+
playdata(sample, sizeof sample, "");
- else if (argc == 0)
+ }
+ else if (argc == 0) {
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+
playfile(stdin, "");
- else
+ }
+ else {
+ if (pledge("stdio rpath", NULL) == -1)
+ err(1, "pledge");
+
while (argc--) {
f = fopen(*argv, "r");
if (f == NULL)
@@ -478,6 +489,7 @@ main(int argc, char **argv)
}
argv++;
}
+ }
exit(0);
}