aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-03-12 06:47:45 -0400
committerMike Frysinger <vapier@gentoo.org>2009-03-12 09:00:00 -0400
commite47edf067cbd939ac8285f87f6fab06baaccbbfb (patch)
tree4c79bde1a31f4e50e03fa17ecc284625a2c170bc /libsandbox/wrapper-funcs
parentlibsandbox: add debug output for all wrapper early-checks (diff)
downloadsandbox-e47edf067cbd939ac8285f87f6fab06baaccbbfb.tar.gz
sandbox-e47edf067cbd939ac8285f87f6fab06baaccbbfb.tar.bz2
sandbox-e47edf067cbd939ac8285f87f6fab06baaccbbfb.zip
libsandbox: unify getcwd wrapper with common wrappers
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r--libsandbox/wrapper-funcs/__wrapper_simple.c5
-rw-r--r--libsandbox/wrapper-funcs/getcwd.c36
2 files changed, 13 insertions, 28 deletions
diff --git a/libsandbox/wrapper-funcs/__wrapper_simple.c b/libsandbox/wrapper-funcs/__wrapper_simple.c
index 1cdf176..de3dafd 100644
--- a/libsandbox/wrapper-funcs/__wrapper_simple.c
+++ b/libsandbox/wrapper-funcs/__wrapper_simple.c
@@ -26,6 +26,9 @@
#ifndef WRAPPER_SAFE_POST_EXPAND
# define WRAPPER_SAFE_POST_EXPAND
#endif
+#ifndef WRAPPER_POST_EXPAND
+# define WRAPPER_POST_EXPAND
+#endif
extern WRAPPER_RET_TYPE EXTERN_NAME(WRAPPER_ARGS_PROTO);
static WRAPPER_RET_TYPE (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS_PROTO) = NULL;
@@ -49,6 +52,7 @@ WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO)
if (WRAPPER_SAFE()) {
WRAPPER_SAFE_POST_EXPAND
result = SB_HIDDEN_FUNC(WRAPPER_NAME)(WRAPPER_ARGS_FULL);
+ WRAPPER_POST_EXPAND
}
return result;
@@ -57,3 +61,4 @@ WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO)
#undef WRAPPER_ARGS_FULL
#undef WRAPPER_ARGS_PROTO_FULL
#undef WRAPPER_SAFE_POST_EXPAND
+#undef WRAPPER_POST_EXPAND
diff --git a/libsandbox/wrapper-funcs/getcwd.c b/libsandbox/wrapper-funcs/getcwd.c
index aaa7ab9..851f359 100644
--- a/libsandbox/wrapper-funcs/getcwd.c
+++ b/libsandbox/wrapper-funcs/getcwd.c
@@ -3,37 +3,17 @@
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
- *
- * Partly Copyright (C) 1998-9 Pancrazio `Ezio' de Mauro <p@demauro.net>,
- * as some of the InstallWatch code was used.
*/
#define WRAPPER_ARGS_PROTO char *buf, size_t size
#define WRAPPER_ARGS buf, size
#define WRAPPER_RET_TYPE char *
#define WRAPPER_RET_DEFAULT NULL
-
-extern WRAPPER_RET_TYPE EXTERN_NAME(WRAPPER_ARGS_PROTO);
-static WRAPPER_RET_TYPE (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS_PROTO) = NULL;
-
-attribute_hidden
-WRAPPER_RET_TYPE SB_HIDDEN_FUNC(WRAPPER_NAME)(WRAPPER_ARGS_PROTO)
-{
- check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME, WRAPPER_SYMVER);
- return WRAPPER_TRUE_NAME(WRAPPER_ARGS);
-}
-
-WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO)
-{
- WRAPPER_RET_TYPE result = WRAPPER_RET_DEFAULT;
-
- /* Need to disable sandbox, as on non-linux libc's, opendir() is
- * used by some getcwd() implementations and resolves to the sandbox
- * opendir() wrapper, causing infinit recursion and finially crashes.
- */
- sandbox_on = false;
- result = SB_HIDDEN_FUNC(WRAPPER_NAME)(WRAPPER_ARGS);
- sandbox_on = true;
-
- return result;
-}
+#define WRAPPER_SAFE() true
+/* Need to disable sandbox, as on non-linux libc's, opendir() is often
+ * used by some getcwd() implementations and resolves to the sandbox
+ * opendir() wrapper, causing infinite recursion and finally crashes.
+ */
+#define WRAPPER_SAFE_POST_EXPAND sandbox_on = false;
+#define WRAPPER_POST_EXPAND sandbox_on = true;
+#include "__wrapper_simple.c"