make tog call pledge(2) directly in main() instead of per-command All of tog's pledges are currently the same, and they must be the same because tog allows switching between available command views at run-time. ok tracey
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/tog/tog.c b/tog/tog.c
index 50fefd4..f3eeaf4 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2645,12 +2645,6 @@ cmd_log(int argc, char *argv[])
int ch, log_branches = 0;
struct tog_view *view;
-#ifndef PROFILE
- if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
- NULL) == -1)
- err(1, "pledge");
-#endif
-
while ((ch = getopt(argc, argv, "bc:r:")) != -1) {
switch (ch) {
case 'b':
@@ -3732,11 +3726,6 @@ cmd_diff(int argc, char *argv[])
const char *errstr;
struct tog_view *view;
-#ifndef PROFILE
- if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
- NULL) == -1)
- err(1, "pledge");
-#endif
while ((ch = getopt(argc, argv, "aC:r:w")) != -1) {
switch (ch) {
case 'a':
@@ -4634,12 +4623,6 @@ cmd_blame(int argc, char *argv[])
int ch;
struct tog_view *view;
-#ifndef PROFILE
- if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
- NULL) == -1)
- err(1, "pledge");
-#endif
-
while ((ch = getopt(argc, argv, "c:r:")) != -1) {
switch (ch) {
case 'c':
@@ -5435,12 +5418,6 @@ cmd_tree(int argc, char *argv[])
int ch;
struct tog_view *view;
-#ifndef PROFILE
- if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
- NULL) == -1)
- err(1, "pledge");
-#endif
-
while ((ch = getopt(argc, argv, "c:r:")) != -1) {
switch (ch) {
case 'c':
@@ -6144,12 +6121,6 @@ cmd_ref(int argc, char *argv[])
int ch;
struct tog_view *view;
-#ifndef PROFILE
- if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
- NULL) == -1)
- err(1, "pledge");
-#endif
-
while ((ch = getopt(argc, argv, "r:")) != -1) {
switch (ch) {
case 'r':
@@ -6407,6 +6378,12 @@ main(int argc, char *argv[])
return 0;
}
+#ifndef PROFILE
+ if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
+ NULL) == -1)
+ err(1, "pledge");
+#endif
+
if (argc == 0) {
if (hflag)
usage(hflag, 0);