summaryrefslogtreecommitdiff
path: root/sys-apps/mawk/files/mawk-1.3.4-sandbox-default.patch
blob: c3b0fc1c892d2468a918f020bb41f65116970247 (plain)
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
82
83
84
85
86
87
88
89
90
91
https://github.com/ThomasDickey/original-mawk/issues/49

Note: We hand modify the configure file here because the version of autotools
used by upstream is very old/finicky, and it's a simple enough change.

From 1ac333b97615c451d7a4743b4724edd46d37a8b2 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@chromium.org>
Date: Tue, 7 Nov 2017 01:07:47 -0500
Subject: [PATCH 2/2] add a configure flag to lock sandbox by default

This lets us deploy systems with the sandbox always enabled.
---
 configure    | 23 +++++++++++++++++++++++
 configure.in | 11 +++++++++++
 init.c       |  4 ++++
 3 files changed, 38 insertions(+)

diff --git a/configure.in b/configure.in
index 8b795fbd264b..770092005386 100644
--- a/configure.in
+++ b/configure.in
@@ -112,6 +112,17 @@ fi
 AC_MSG_RESULT($with_init_srand)
 
 ###############################################################################
+AC_MSG_CHECKING(if you want mawk to always run in sandbox mode)
+CF_ARG_ENABLE([forced-sandbox],
+[  --enable-forced-sandbox always run in sandbox mode],
+	[with_forced_sandbox=yes],
+	[with_forced_sandbox=no])
+if test "x${with_forced_sandbox}" != xno; then
+	CPPFLAGS="$CPPFLAGS -DFORCED_SANDBOX"
+fi
+AC_MSG_RESULT($with_forced_sandbox)
+
+###############################################################################
 
 AC_PROG_YACC
 CF_PROG_LINT
diff --git a/init.c b/init.c
index f7babb337e04..e035d6ea2fc0 100644
--- a/init.c
+++ b/init.c
@@ -492,6 +492,10 @@ process_cmdline(int argc, char **argv)
 
   no_more_opts:
 
+#ifdef FORCED_SANDBOX
+    sandbox_flag = 1;
+#endif
+
     tail->link = (PFILE *) 0;
     pfile_list = dummy.link;
 
diff --git a/configure b/configure
index a3bf42fe9245..442875b8e58a 100755
--- a/configure
+++ b/configure
@@ -4132,6 +4132,29 @@ echo "$as_me:4131: result: $with_init_srand" >&5
 echo "${ECHO_T}$with_init_srand" >&6
 
 ###############################################################################
+echo "$as_me:4109: checking if you want mawk to always run in sandbox mode" >&5
+echo $ECHO_N "checking if you want mawk to always run in sandbox mode... $ECHO_C" >&6
+
+if test "${enable_forced_sandbox+set}" = set; then
+  enableval="$enable_forced_sandbox"
+  test "$enableval" != yes && enableval=no
+	if test "$enableval" != "no" ; then
+    with_forced_sandbox=yes
+	else
+		with_forced_sandbox=no
+	fi
+else
+  enableval=no
+	with_forced_sandbox=no
+
+fi;
+if test "x${with_forced_sandbox}" != xno; then
+	CPPFLAGS="$CPPFLAGS -DFORCED_SANDBOX"
+fi
+echo "$as_me:4131: result: $with_forced_sandbox" >&5
+echo "${ECHO_T}$with_forced_sandbox" >&6
+
+###############################################################################
 
 for ac_prog in 'bison -y' byacc
 do
-- 
2.13.5