Blob Blame History Raw
From 048ecb97881ad2763c34458eb705fedf09dcc5ff 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/2] 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 |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/orc/orccodemem.c b/orc/orccodemem.c
index f470be5..295a880 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") + 1);
+  sprintf (dir, "%s/.orc", basedir);
+
+  if (stat (dir, &stat_p) == -1 ||
+      !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);
@@ -211,6 +227,7 @@ orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
   if (force_unlink || !_orc_compiler_flag_debug) {
     unlink (filename);
   }
+  free (dir);
   free (filename);
 
   n = ftruncate (fd, SIZE);
-- 
1.7.7.6