summaryrefslogtreecommitdiffstats
path: root/orc-subdir.patch
blob: 2fff4f5731788f12311fc5275fa64ac1ed1e5160 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
From 30a9f48e8dd12f7b607d1dbc9a795f939208f5d6 Mon Sep 17 00:00:00 2001
From: Fabian Deutsch <fabian.deutsch@gmx.de>
Date: Tue, 4 Oct 2011 13:28:38 +0200
Subject: [PATCH 1/3] Use a subdirectory for temporary files.

This allows the a better integration with selinux, as the rule can use the path name and doesn't need globbing.

Signed-off-by: Fabian Deutsch <fabian.deutsch@gmx.de>
---
 orc/orccodemem.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/orc/orccodemem.c b/orc/orccodemem.c
index f470be5..e125faa 100644
--- a/orc/orccodemem.c
+++ b/orc/orccodemem.c
@@ -193,11 +193,27 @@ orc_code_chunk_free (OrcCodeChunk *chunk)
 #ifdef HAVE_CODEMEM_MMAP
 int
 orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
-    const char *dir, int force_unlink)
+    const char *basedir, int force_unlink)
 {
   int fd;
   int n;
   char *filename;
+  char *dir;
+  struct stat stat_p;
+  
+  dir = malloc (strlen (basedir) + strlen ("/.orc"));
+  sprintf (dir, "%s/.orc", basedir);
+
+  stat (dir, &stat_p);
+  if (!S_ISDIR (stat_p.st_mode))
+  {
+    n = mkdir (dir, S_IRWXU);
+    if (n < 0)
+    {
+      ORC_WARNING ("failed to create subdir");
+      return FALSE;
+    }
+  }
 
   filename = malloc (strlen ("/orcexec..") +
       strlen (dir) + 6 + 1);
-- 
1.7.7.5


From 2e35ab7bca7eef855b12eed26da9d543c8b225b6 Mon Sep 17 00:00:00 2001
From: Fabian Deutsch <fabian.deutsch@gmx.de>
Date: Sun, 1 Jan 2012 21:25:28 +0100
Subject: [PATCH 2/3] orccodemem.c: Fix memory allocation and directory
 existance.

Noted in https://bugzilla.redhat.com/show_bug.cgi?id=770602

Signed-off-by: Fabian Deutsch <fabian.deutsch@gmx.de>
---
 orc/orccodemem.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/orc/orccodemem.c b/orc/orccodemem.c
index e125faa..be76472 100644
--- a/orc/orccodemem.c
+++ b/orc/orccodemem.c
@@ -201,11 +201,11 @@ orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
   char *dir;
   struct stat stat_p;
   
-  dir = malloc (strlen (basedir) + strlen ("/.orc"));
+  dir = malloc (strlen (basedir) + strlen ("/.orc") + 1);
   sprintf (dir, "%s/.orc", basedir);
 
-  stat (dir, &stat_p);
-  if (!S_ISDIR (stat_p.st_mode))
+  if (stat (dir, &stat_p) == -1 || 
+      !S_ISDIR (stat_p.st_mode))
   {
     n = mkdir (dir, S_IRWXU);
     if (n < 0)
-- 
1.7.7.5


From 5a9009d4275fd40a0079a8bf44a7de31c2962bb0 Mon Sep 17 00:00:00 2001
From: Fabian Deutsch <fabian.deutsch@gmx.de>
Date: Sun, 1 Jan 2012 21:41:04 +0100
Subject: [PATCH 3/3] Add compiler option for ENABLE_USER_CODEMEM.

This option disbales non-user-dependent path checking at compile time. If enabled, only paths corresponding to a user are checked.

Signed-off-by: Fabian Deutsch <fabian.deutsch@gmx.de>
---
 configure.ac     |    4 ++++
 orc/Makefile.am  |    3 +++
 orc/orccodemem.c |    2 ++
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6637b8e..52edb5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,6 +164,10 @@ AM_CONDITIONAL(ENABLE_BACKEND_NEON, test "x$ENABLE_BACKEND_NEON" = "xyes")
 AM_CONDITIONAL(ENABLE_BACKEND_ARM, test "x$ENABLE_BACKEND_ARM" = "xyes")
 AM_CONDITIONAL(ENABLE_BACKEND_C64X, test "x$ENABLE_BACKEND_C64X" = "xyes")
 
+AC_ARG_ENABLE(user-codemem,
+  AC_HELP_STRING([--enable-user-codemem],[Force codemem allocation to be user dependent (default is no)]),
+    [], [enable_user_codemem=no])
+AM_CONDITIONAL(ENABLE_USER_CODEMEM, test "x$enable_user_codemem" = "xyes")
 
 AC_DEFINE(ORC_EXPORTS, 1, [Defined for compiling internal code])
 
diff --git a/orc/Makefile.am b/orc/Makefile.am
index 8f379e0..43e9028 100644
--- a/orc/Makefile.am
+++ b/orc/Makefile.am
@@ -9,6 +9,9 @@ liborc_@ORC_MAJORMINOR@_la_LDFLAGS = \
 	-no-undefined -export-symbols-regex 'orc_'
 liborc_@ORC_MAJORMINOR@_la_CFLAGS = $(ORC_CFLAGS) \
 	-DORC_ENABLE_UNSTABLE_API
+if ENABLE_USER_CODEMEM
+liborc_@ORC_MAJORMINOR@_la_CFLAGS += -DORC_FORCE_USER_CODEMEM
+endif
 
 liborc_@ORC_MAJORMINOR@_la_SOURCES = \
 	orc.c \
diff --git a/orc/orccodemem.c b/orc/orccodemem.c
index be76472..32c14f1 100644
--- a/orc/orccodemem.c
+++ b/orc/orccodemem.c
@@ -279,12 +279,14 @@ orc_code_region_allocate_codemem (OrcCodeRegion *region)
 {
   const char *tmpdir;
 
+#ifndef ORC_FORCE_USER_CODEMEM
   tmpdir = getenv ("TMPDIR");
   if (tmpdir && orc_code_region_allocate_codemem_dual_map (region,
         tmpdir, FALSE)) return;
 
   if (orc_code_region_allocate_codemem_dual_map (region,
         "/tmp", FALSE)) return;
+#endif
 
   tmpdir = getenv ("XDG_RUNTIME_DIR");
   if (tmpdir && orc_code_region_allocate_codemem_dual_map (region,
-- 
1.7.7.5