First sweep of OpenBSD's pledge()

pull/79/head
Alex Holst 7 years ago
parent 7eed9240a7
commit a9a1a7ba7e

@ -1,5 +1,6 @@
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -73,6 +74,9 @@ main(int argc, char *argv[])
exit(1);
}
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
if (argc == optind && isatty(0))
blaze822_loop1(":", addr);
else

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <regex.h>
#include <stdio.h>
@ -188,6 +189,9 @@ main(int argc, char *argv[])
if (!rx)
goto usage;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
*rx++ = 0;
int r = regcomp(&pattern, rx, REG_EXTENDED | iflag);
if (r != 0) {

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@ -206,6 +207,9 @@ main(int argc, char *argv[])
return 1;
}
if (pledge("stdio wpath", NULL) == -1)
err(1, "pledge");
targetdir = argv[optind];
gethost();

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@ -81,6 +82,9 @@ main(int argc, char *argv[])
if (argc == optind)
goto usage;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
for (i = 0; i < argc; i++)
mdirs(argv[i]);

@ -141,6 +141,9 @@ main(int argc, char *argv[])
status = 0;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
if (argc == optind && isatty(0))
blaze822_loop1(":", export);
else

@ -135,6 +135,10 @@ main(int argc, char *argv[])
exit(1);
}
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
curfile = blaze822_seq_cur();
if (vflag) {

@ -35,6 +35,9 @@ int main()
char *f = blaze822_home_file("profile");
struct message *config = blaze822(f);
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
if (config) // try FQDN: first
host = blaze822_hdr(config, "fqdn");

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -204,6 +205,9 @@ main(int argc, char *argv[])
status = 1;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
if (argc == optind && isatty(0))
blaze822_loop1(".", header);
else

@ -1,6 +1,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@ -74,6 +75,9 @@ main(int argc, char *argv[])
if (optind == argc)
goto usage;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
status = 0;
for (i = optind; i < argc; i++)
inc(argv[i]);

@ -3,6 +3,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include <err.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
@ -254,6 +255,9 @@ main(int argc, char *argv[])
}
int i;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
for (i = 0, flagsum = 0, flagset = 0; (size_t)i < sizeof flags; i++) {
if (flags[i] != 0)

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@ -475,6 +476,9 @@ main(int argc, char *argv[])
if (argc != optind)
goto usage;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
if (cflag)
return check();

@ -6,6 +6,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -501,6 +502,9 @@ main(int argc, char *argv[])
exit(1);
}
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
if (nflag) {
if (argc == optind && isatty(0))
blaze822_loop1(":", numline);

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <regex.h>
@ -306,6 +307,9 @@ main(int argc, char *argv[])
exit(1);
}
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
expr = argv[optind];
optind++;

@ -1,4 +1,5 @@
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <search.h>
@ -288,6 +289,9 @@ main(int argc, char *argv[])
exit(1);
}
if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
err(1, "pledge");
if (cflag)
blaze822_loop1(cflag, overridecur);

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
@ -750,6 +751,9 @@ main(int argc, char *argv[])
if (!rflag && !Oflag && !Rflag)
safe_output = 1;
if (pledge("stdio rpath tty cpath proc", NULL) == -1)
err(1, "pledge");
if (safe_output && isatty(1)) {
char *pg;
pg = getenv("MBLAZE_PAGER");
@ -766,6 +770,9 @@ main(int argc, char *argv[])
}
}
if (pledge("stdio rpath cpath tty", NULL) == -1)
err(1, "pledge");
if (xflag) { // extract
extract(xflag, argc-optind, argv+optind, 0);
} else if (Oflag) { // extract to stdout

@ -2,6 +2,7 @@
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -316,6 +317,8 @@ main(int argc, char *argv[])
exit(1);
}
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
mails = calloc(sizeof (struct mail), mailalloc);
if (!mails)

@ -8,6 +8,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <search.h>
@ -400,6 +401,9 @@ main(int argc, char *argv[])
optional = 1;
if (pledge("stdio rpath tty", NULL) == -1)
err(1, "pledge");
while ((c = getopt(argc, argv, "S:v")) != -1)
switch(c) {
case 'S': blaze822_loop1(optarg, thread); break;

Loading…
Cancel
Save