aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-03-05 16:19:08 -0500
committerMike Frysinger <vapier@gentoo.org>2012-03-05 16:21:47 -0500
commit5498907383c7f1654188b6a0d02d8b03112a28c3 (patch)
tree4d207926c2d4b5c63d36f6108149f170be510bce /libsbutil
parenttests: note that testsuite.list.at is generated (diff)
downloadsandbox-5498907383c7f1654188b6a0d02d8b03112a28c3.tar.gz
sandbox-5498907383c7f1654188b6a0d02d8b03112a28c3.tar.bz2
sandbox-5498907383c7f1654188b6a0d02d8b03112a28c3.zip
libsandbox: push down constructor init
Since every consumer of sb_open gets a copy of the sbio_open data, push the init of this into the .data section of the respective consumers to avoid the runtime overhead. This just leaves sandbox_lib setup in the constructor function, but that is only needed by the execve wrapper, so push down init of that to the existing sb_init logic which happens before our execve wrapper gets used. URL: http://bugs.gentoo.org/404013 Reported-by: Mike Gilbert <floppym@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r--libsbutil/sb_open.c11
-rw-r--r--libsbutil/sbutil.h2
2 files changed, 1 insertions, 12 deletions
diff --git a/libsbutil/sb_open.c b/libsbutil/sb_open.c
index 2e405c6..27dda9c 100644
--- a/libsbutil/sb_open.c
+++ b/libsbutil/sb_open.c
@@ -10,17 +10,6 @@
#include "headers.h"
#include "sbutil.h"
-static int (*sbio_open)(const char *, int, mode_t) = (void *)open;
-
-
-void sb_set_open(void *new_open)
-{
- if (!check_ptr(new_open))
- return;
-
- sbio_open = new_open;
-}
-
/* General purpose function to _reliably_ open a file
*
* Returns the file descriptor or -1 on error (and errno set)
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index e232b31..bdff33f 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -91,7 +91,7 @@ bool is_env_on (const char *);
bool is_env_off (const char *);
/* libsandbox need to use a wrapper for open */
-void sb_set_open(void *new_open);
+attribute_hidden extern int (*sbio_open)(const char *, int, mode_t);
/* Convenience functions to reliably open, read and write to a file */
int sb_open(const char *path, int flags, mode_t mode);
size_t sb_read(int fd, void *buf, size_t count);