Blame SOURCES/0001-Use-a-subdirectory-for-temporary-files.patch

814ac5
From 048ecb97881ad2763c34458eb705fedf09dcc5ff Mon Sep 17 00:00:00 2001
814ac5
From: Fabian Deutsch <fabian.deutsch@gmx.de>
814ac5
Date: Tue, 4 Oct 2011 13:28:38 +0200
814ac5
Subject: [PATCH 1/2] Use a subdirectory for temporary files.
814ac5
814ac5
This allows the a better integration with selinux, as the rule can use the path name and doesn't need globbing.
814ac5
814ac5
Signed-off-by: Fabian Deutsch <fabian.deutsch@gmx.de>
814ac5
---
814ac5
 orc/orccodemem.c |   19 ++++++++++++++++++-
814ac5
 1 files changed, 18 insertions(+), 1 deletions(-)
814ac5
814ac5
diff --git a/orc/orccodemem.c b/orc/orccodemem.c
814ac5
index f470be5..295a880 100644
814ac5
--- a/orc/orccodemem.c
814ac5
+++ b/orc/orccodemem.c
814ac5
@@ -193,11 +193,27 @@ orc_code_chunk_free (OrcCodeChunk *chunk)
814ac5
 #ifdef HAVE_CODEMEM_MMAP
814ac5
 int
814ac5
 orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
814ac5
-    const char *dir, int force_unlink)
814ac5
+    const char *basedir, int force_unlink)
814ac5
 {
814ac5
   int fd;
814ac5
   int n;
814ac5
   char *filename;
814ac5
+  char *dir;
814ac5
+  struct stat stat_p;
814ac5
+
814ac5
+  dir = malloc (strlen (basedir) + strlen ("/.orc") + 1);
814ac5
+  sprintf (dir, "%s/.orc", basedir);
814ac5
+
814ac5
+  if (stat (dir, &stat_p) == -1 ||
814ac5
+      !S_ISDIR (stat_p.st_mode))
814ac5
+  {
814ac5
+    n = mkdir (dir, S_IRWXU);
814ac5
+    if (n < 0)
814ac5
+    {
814ac5
+      ORC_WARNING ("failed to create subdir");
814ac5
+      return FALSE;
814ac5
+    }
814ac5
+  }
814ac5
 
814ac5
   filename = malloc (strlen ("/orcexec..") +
814ac5
       strlen (dir) + 6 + 1);
814ac5
@@ -211,6 +227,7 @@ orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
814ac5
   if (force_unlink || !_orc_compiler_flag_debug) {
814ac5
     unlink (filename);
814ac5
   }
814ac5
+  free (dir);
814ac5
   free (filename);
814ac5
 
814ac5
   n = ftruncate (fd, SIZE);
814ac5
-- 
814ac5
1.7.7.6
814ac5