aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-11-10 07:23:39 +0000
committerMike Frysinger <vapier@gentoo.org>2008-11-10 07:23:39 +0000
commit5dea7ed777362d7eff2e23925ba13e7d669d74a2 (patch)
tree6bb39b23a80a9af4ab206bfcd6ec753066bc27f6
parentscripts: strip whitespace (diff)
downloadsandbox-5dea7ed777362d7eff2e23925ba13e7d669d74a2.tar.gz
sandbox-5dea7ed777362d7eff2e23925ba13e7d669d74a2.tar.bz2
sandbox-5dea7ed777362d7eff2e23925ba13e7d669d74a2.zip
libsandbox: break function args out into WRAPPER_ARGS and func name into STRING_NAME
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--libsandbox/wrapper-funcs/__xmknod.c11
-rw-r--r--libsandbox/wrapper-funcs/access.c11
-rw-r--r--libsandbox/wrapper-funcs/chmod.c11
-rw-r--r--libsandbox/wrapper-funcs/chown.c11
-rw-r--r--libsandbox/wrapper-funcs/creat.c11
-rw-r--r--libsandbox/wrapper-funcs/creat64.c11
-rw-r--r--libsandbox/wrapper-funcs/execve.c11
-rw-r--r--libsandbox/wrapper-funcs/fopen.c11
-rw-r--r--libsandbox/wrapper-funcs/fopen64.c11
-rw-r--r--libsandbox/wrapper-funcs/getcwd.c9
-rw-r--r--libsandbox/wrapper-funcs/lchown.c11
-rw-r--r--libsandbox/wrapper-funcs/link.c11
-rw-r--r--libsandbox/wrapper-funcs/lutimes.c11
-rw-r--r--libsandbox/wrapper-funcs/mkdir.c11
-rw-r--r--libsandbox/wrapper-funcs/mkfifo.c11
-rw-r--r--libsandbox/wrapper-funcs/mknod.c11
-rw-r--r--libsandbox/wrapper-funcs/open.c11
-rw-r--r--libsandbox/wrapper-funcs/open64.c11
-rw-r--r--libsandbox/wrapper-funcs/opendir.c11
-rw-r--r--libsandbox/wrapper-funcs/rename.c13
-rw-r--r--libsandbox/wrapper-funcs/rmdir.c11
-rw-r--r--libsandbox/wrapper-funcs/symlink.c11
-rw-r--r--libsandbox/wrapper-funcs/truncate.c11
-rw-r--r--libsandbox/wrapper-funcs/truncate64.c11
-rw-r--r--libsandbox/wrapper-funcs/unlink.c11
-rw-r--r--libsandbox/wrapper-funcs/utime.c11
-rw-r--r--libsandbox/wrapper-funcs/utimes.c11
-rw-r--r--scripts/gen_symbol_header.awk3
28 files changed, 138 insertions, 162 deletions
diff --git a/libsandbox/wrapper-funcs/__xmknod.c b/libsandbox/wrapper-funcs/__xmknod.c
index 98da369..2b09dc8 100644
--- a/libsandbox/wrapper-funcs/__xmknod.c
+++ b/libsandbox/wrapper-funcs/__xmknod.c
@@ -1,6 +1,4 @@
/*
- * __xmknod.c
- *
* __xmknod() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(int, const char *, __mode_t, __dev_t *);
-static int (*WRAPPER_TRUE_NAME) (int, const char *, __mode_t, __dev_t *) = NULL;
+#define WRAPPER_ARGS int ver, const char *pathname, __mode_t mode, __dev_t *dev
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(int ver, const char *pathname, __mode_t mode, __dev_t *dev)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("mknod", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(ver, pathname, mode, dev);
diff --git a/libsandbox/wrapper-funcs/access.c b/libsandbox/wrapper-funcs/access.c
index acc1e4b..9a4c46e 100644
--- a/libsandbox/wrapper-funcs/access.c
+++ b/libsandbox/wrapper-funcs/access.c
@@ -1,6 +1,4 @@
/*
- * access.c
- *
* access() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, int);
-static int (*WRAPPER_TRUE_NAME) (const char *, int) = NULL;
+#define WRAPPER_ARGS const char *pathname, int mode
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *pathname, int mode)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE_ACCESS("access", pathname, mode) {
+ if FUNCTION_SANDBOX_SAFE_ACCESS(STRING_NAME, pathname, mode) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname, mode);
diff --git a/libsandbox/wrapper-funcs/chmod.c b/libsandbox/wrapper-funcs/chmod.c
index 49f7acc..3134c73 100644
--- a/libsandbox/wrapper-funcs/chmod.c
+++ b/libsandbox/wrapper-funcs/chmod.c
@@ -1,6 +1,4 @@
/*
- * chmod.c
- *
* chmod() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, mode_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, mode_t) = NULL;
+#define WRAPPER_ARGS const char *path, mode_t mode
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *path, mode_t mode)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("chmod", path) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, path) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(path, mode);
diff --git a/libsandbox/wrapper-funcs/chown.c b/libsandbox/wrapper-funcs/chown.c
index 1cd95cd..3a72d44 100644
--- a/libsandbox/wrapper-funcs/chown.c
+++ b/libsandbox/wrapper-funcs/chown.c
@@ -1,6 +1,4 @@
/*
- * chown.c
- *
* chown() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, uid_t, gid_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, uid_t, gid_t) = NULL;
+#define WRAPPER_ARGS const char *path, uid_t owner, gid_t group
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *path, uid_t owner, gid_t group)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("chown", path) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, path) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(path, owner, group);
diff --git a/libsandbox/wrapper-funcs/creat.c b/libsandbox/wrapper-funcs/creat.c
index 7d908e7..99f6bc7 100644
--- a/libsandbox/wrapper-funcs/creat.c
+++ b/libsandbox/wrapper-funcs/creat.c
@@ -1,6 +1,4 @@
/*
- * creat.c
- *
* creat() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,15 +8,16 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, mode_t);
+#define WRAPPER_ARGS const char *pathname, mode_t mode
+extern int EXTERN_NAME(WRAPPER_ARGS);
/* XXX: We use the open() call to simulate create() */
-/* static int (*WRAPPER_TRUE_NAME) (const char *, mode_t) = NULL; */
+/* static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; */
-int WRAPPER_NAME(const char *pathname, mode_t mode)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("creat", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(true_open_DEFAULT, symname_open_DEFAULT,
symver_open_DEFAULT);
result = true_open_DEFAULT(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
diff --git a/libsandbox/wrapper-funcs/creat64.c b/libsandbox/wrapper-funcs/creat64.c
index cfd3798..d9608de 100644
--- a/libsandbox/wrapper-funcs/creat64.c
+++ b/libsandbox/wrapper-funcs/creat64.c
@@ -1,6 +1,4 @@
/*
- * creat64.c
- *
* creat64() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,15 +8,16 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, __mode_t);
+#define WRAPPER_ARGS const char *pathname, __mode_t mode
+extern int EXTERN_NAME(WRAPPER_ARGS);
/* XXX: We use the open64() call to simulate create64() */
-/* static int (*WRAPPER_TRUE_NAME) (const char *, __mode_t) = NULL; */
+/* static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; */
-int WRAPPER_NAME(const char *pathname, __mode_t mode)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("creat64", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(true_open64_DEFAULT, symname_open64_DEFAULT,
symver_open64_DEFAULT);
result = true_open64_DEFAULT(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
diff --git a/libsandbox/wrapper-funcs/execve.c b/libsandbox/wrapper-funcs/execve.c
index 757f179..35b19b6 100644
--- a/libsandbox/wrapper-funcs/execve.c
+++ b/libsandbox/wrapper-funcs/execve.c
@@ -1,6 +1,4 @@
/*
- * execve.c
- *
* execve() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,10 +8,11 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, char *const[], char *const[]);
-static int (*WRAPPER_TRUE_NAME) (const char *, char *const[], char *const[]) = NULL;
+#define WRAPPER_ARGS const char *filename, char *const argv[], char *const envp[]
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *filename, char *const argv[], char *const envp[])
+int WRAPPER_NAME(WRAPPER_ARGS)
{
char **my_env = NULL;
char *entry;
@@ -23,7 +22,7 @@ int WRAPPER_NAME(const char *filename, char *const argv[], char *const envp[])
int result = -1;
int count;
- if (!FUNCTION_SANDBOX_SAFE("execve", filename))
+ if (!FUNCTION_SANDBOX_SAFE(STRING_NAME, filename))
return result;
str_list_for_each_item(envp, entry, count) {
diff --git a/libsandbox/wrapper-funcs/fopen.c b/libsandbox/wrapper-funcs/fopen.c
index 4962eee..ef03618 100644
--- a/libsandbox/wrapper-funcs/fopen.c
+++ b/libsandbox/wrapper-funcs/fopen.c
@@ -1,6 +1,4 @@
/*
- * fopen.c
- *
* fopen() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,10 +8,11 @@
* as some of the InstallWatch code was used.
*/
-extern FILE *WRAPPER_NAME(const char *, const char *);
-static FILE * (*WRAPPER_TRUE_NAME) (const char *, const char *) = NULL;
+#define WRAPPER_ARGS const char *pathname, const char *mode
+extern FILE *WRAPPER_NAME(WRAPPER_ARGS);
+static FILE *(*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-FILE *WRAPPER_NAME(const char *pathname, const char *mode)
+FILE *WRAPPER_NAME(WRAPPER_ARGS)
{
FILE *result = NULL;
int old_errno = errno;
@@ -28,7 +27,7 @@ FILE *WRAPPER_NAME(const char *pathname, const char *mode)
}
errno = old_errno;
- if FUNCTION_SANDBOX_SAFE_OPEN_CHAR("fopen", pathname, mode) {
+ if FUNCTION_SANDBOX_SAFE_OPEN_CHAR(STRING_NAME, pathname, mode) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname, mode);
diff --git a/libsandbox/wrapper-funcs/fopen64.c b/libsandbox/wrapper-funcs/fopen64.c
index 5134822..d5fd77e 100644
--- a/libsandbox/wrapper-funcs/fopen64.c
+++ b/libsandbox/wrapper-funcs/fopen64.c
@@ -1,6 +1,4 @@
/*
- * fopen64.c
- *
* fopen64() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,10 +8,11 @@
* as some of the InstallWatch code was used.
*/
-extern FILE *WRAPPER_NAME(const char *, const char *);
-static FILE * (*WRAPPER_TRUE_NAME) (const char *, const char *) = NULL;
+#define WRAPPER_ARGS const char *pathname, const char *mode
+extern FILE *WRAPPER_NAME(WRAPPER_ARGS);
+static FILE *(*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-FILE *WRAPPER_NAME(const char *pathname, const char *mode)
+FILE *WRAPPER_NAME(WRAPPER_ARGS)
{
FILE *result = NULL;
int old_errno = errno;
@@ -28,7 +27,7 @@ FILE *WRAPPER_NAME(const char *pathname, const char *mode)
}
errno = old_errno;
- if FUNCTION_SANDBOX_SAFE_OPEN_CHAR("fopen64", pathname, mode) {
+ if FUNCTION_SANDBOX_SAFE_OPEN_CHAR(STRING_NAME, pathname, mode) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname, mode);
diff --git a/libsandbox/wrapper-funcs/getcwd.c b/libsandbox/wrapper-funcs/getcwd.c
index 5cfc50d..23626ca 100644
--- a/libsandbox/wrapper-funcs/getcwd.c
+++ b/libsandbox/wrapper-funcs/getcwd.c
@@ -1,6 +1,4 @@
/*
- * getcwd.c
- *
* getcwd() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,10 +8,11 @@
* as some of the InstallWatch code was used.
*/
-extern char *WRAPPER_NAME(char *, size_t);
-static char * (*WRAPPER_TRUE_NAME) (char *, size_t) = NULL;
+#define WRAPPER_ARGS char *buf, size_t size
+extern char *WRAPPER_NAME(WRAPPER_ARGS);
+static char *(*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-char *WRAPPER_NAME(char *buf, size_t size)
+char *WRAPPER_NAME(WRAPPER_ARGS)
{
char *result = NULL;
diff --git a/libsandbox/wrapper-funcs/lchown.c b/libsandbox/wrapper-funcs/lchown.c
index 11de578..74cce06 100644
--- a/libsandbox/wrapper-funcs/lchown.c
+++ b/libsandbox/wrapper-funcs/lchown.c
@@ -1,6 +1,4 @@
/*
- * lchown.c
- *
* lchown() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, uid_t, gid_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, uid_t, gid_t) = NULL;
+#define WRAPPER_ARGS const char *path, uid_t owner, gid_t group
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *path, uid_t owner, gid_t group)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("lchown", path) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, path) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(path, owner, group);
diff --git a/libsandbox/wrapper-funcs/link.c b/libsandbox/wrapper-funcs/link.c
index 46cbbe0..d4b821b 100644
--- a/libsandbox/wrapper-funcs/link.c
+++ b/libsandbox/wrapper-funcs/link.c
@@ -1,20 +1,19 @@
/*
- * link.c
- *
* link() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *, const char *);
-static int (*WRAPPER_TRUE_NAME) (const char *, const char *) = NULL;
+#define WRAPPER_ARGS const char *oldpath, const char *newpath
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *oldpath, const char *newpath)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("link", newpath) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, newpath) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(oldpath, newpath);
diff --git a/libsandbox/wrapper-funcs/lutimes.c b/libsandbox/wrapper-funcs/lutimes.c
index f323a82..57ed650 100644
--- a/libsandbox/wrapper-funcs/lutimes.c
+++ b/libsandbox/wrapper-funcs/lutimes.c
@@ -1,20 +1,19 @@
/*
- * lutimes.c
- *
* lutimes() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *, const struct timeval []);
-static int (*WRAPPER_TRUE_NAME) (const char *, const struct timeval []) = NULL;
+#define WRAPPER_ARGS const char *filename, const struct timeval times[]
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *filename, const struct timeval times[])
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("lutimes", filename) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, filename) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(filename, times);
diff --git a/libsandbox/wrapper-funcs/mkdir.c b/libsandbox/wrapper-funcs/mkdir.c
index 0c54de4..b9d6505 100644
--- a/libsandbox/wrapper-funcs/mkdir.c
+++ b/libsandbox/wrapper-funcs/mkdir.c
@@ -1,16 +1,15 @@
/*
- * mkdir.c
- *
* mkdir() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *, mode_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, mode_t) = NULL;
+#define WRAPPER_ARGS const char *pathname, mode_t mode
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *pathname, mode_t mode)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
struct stat st;
int result = -1, old_errno = errno;
@@ -31,7 +30,7 @@ int WRAPPER_NAME(const char *pathname, mode_t mode)
}
errno = old_errno;
- if FUNCTION_SANDBOX_SAFE("mkdir", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname, mode);
diff --git a/libsandbox/wrapper-funcs/mkfifo.c b/libsandbox/wrapper-funcs/mkfifo.c
index 94c183c..146f9e1 100644
--- a/libsandbox/wrapper-funcs/mkfifo.c
+++ b/libsandbox/wrapper-funcs/mkfifo.c
@@ -1,6 +1,4 @@
/*
- * mkfifo.c
- *
* mkfifo() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, mode_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, mode_t) = NULL;
+#define WRAPPER_ARGS const char *pathname, mode_t mode
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *pathname, mode_t mode)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("mkfifo", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname, mode);
diff --git a/libsandbox/wrapper-funcs/mknod.c b/libsandbox/wrapper-funcs/mknod.c
index 1aef84c..965ce9e 100644
--- a/libsandbox/wrapper-funcs/mknod.c
+++ b/libsandbox/wrapper-funcs/mknod.c
@@ -1,6 +1,4 @@
/*
- * mknod.c
- *
* mknod() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, mode_t, dev_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, mode_t, dev_t) = NULL;
+#define WRAPPER_ARGS const char *pathname, mode_t mode, dev_t dev
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *pathname, mode_t mode, dev_t dev)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("mknod", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname, mode, dev);
diff --git a/libsandbox/wrapper-funcs/open.c b/libsandbox/wrapper-funcs/open.c
index 0b4f04d..923842d 100644
--- a/libsandbox/wrapper-funcs/open.c
+++ b/libsandbox/wrapper-funcs/open.c
@@ -1,6 +1,4 @@
/*
- * open.c
- *
* open() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,11 +8,12 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, int, ...);
-static int (*WRAPPER_TRUE_NAME) (const char *, int, ...) = NULL;
+#define WRAPPER_ARGS const char *pathname, int flags, ...
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
/* Eventually, there is a third parameter: it's mode_t mode */
-int WRAPPER_NAME(const char *pathname, int flags, ...)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
va_list ap;
int mode = 0;
@@ -35,7 +34,7 @@ int WRAPPER_NAME(const char *pathname, int flags, ...)
}
errno = old_errno;
- if FUNCTION_SANDBOX_SAFE_OPEN_INT("open", pathname, flags) {
+ if FUNCTION_SANDBOX_SAFE_OPEN_INT(STRING_NAME, pathname, flags) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
if (flags & O_CREAT)
diff --git a/libsandbox/wrapper-funcs/open64.c b/libsandbox/wrapper-funcs/open64.c
index ff76247..88114e0 100644
--- a/libsandbox/wrapper-funcs/open64.c
+++ b/libsandbox/wrapper-funcs/open64.c
@@ -1,6 +1,4 @@
/*
- * open64.c
- *
* open64() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,11 +8,12 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, int, ...);
-static int (*WRAPPER_TRUE_NAME) (const char *, int, ...) = NULL;
+#define WRAPPER_ARGS const char *pathname, int flags, ...
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
/* Eventually, there is a third parameter: it's mode_t mode */
-int WRAPPER_NAME(const char *pathname, int flags, ...)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
va_list ap;
int mode = 0;
@@ -35,7 +34,7 @@ int WRAPPER_NAME(const char *pathname, int flags, ...)
}
errno = old_errno;
- if FUNCTION_SANDBOX_SAFE_OPEN_INT("open64", pathname, flags) {
+ if FUNCTION_SANDBOX_SAFE_OPEN_INT(STRING_NAME, pathname, flags) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
if (flags & O_CREAT)
diff --git a/libsandbox/wrapper-funcs/opendir.c b/libsandbox/wrapper-funcs/opendir.c
index 6aa6db0..4f07d44 100644
--- a/libsandbox/wrapper-funcs/opendir.c
+++ b/libsandbox/wrapper-funcs/opendir.c
@@ -1,20 +1,19 @@
/*
- * opendir.c
- *
* opendir() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern DIR *WRAPPER_NAME(const char *);
-static DIR * (*WRAPPER_TRUE_NAME) (const char *) = NULL;
+#define WRAPPER_ARGS const char *name
+extern DIR *WRAPPER_NAME(WRAPPER_ARGS);
+static DIR *(*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-DIR *WRAPPER_NAME(const char *name)
+DIR *WRAPPER_NAME(WRAPPER_ARGS)
{
DIR *result = NULL;
- if FUNCTION_SANDBOX_SAFE("opendir", name) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, name) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(name);
diff --git a/libsandbox/wrapper-funcs/rename.c b/libsandbox/wrapper-funcs/rename.c
index d7e0fa1..f6e3a7b 100644
--- a/libsandbox/wrapper-funcs/rename.c
+++ b/libsandbox/wrapper-funcs/rename.c
@@ -1,6 +1,4 @@
/*
- * rename.c
- *
* rename() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,15 +8,16 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, const char *);
-static int (*WRAPPER_TRUE_NAME) (const char *, const char *) = NULL;
+#define WRAPPER_ARGS const char *oldpath, const char *newpath
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *oldpath, const char *newpath)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if (FUNCTION_SANDBOX_SAFE("rename", oldpath) &&
- FUNCTION_SANDBOX_SAFE("rename", newpath)) {
+ if (FUNCTION_SANDBOX_SAFE(STRING_NAME, oldpath) &&
+ FUNCTION_SANDBOX_SAFE(STRING_NAME, newpath)) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(oldpath, newpath);
diff --git a/libsandbox/wrapper-funcs/rmdir.c b/libsandbox/wrapper-funcs/rmdir.c
index cc736fd..a842fe7 100644
--- a/libsandbox/wrapper-funcs/rmdir.c
+++ b/libsandbox/wrapper-funcs/rmdir.c
@@ -1,20 +1,19 @@
/*
- * rmdir.c
- *
* rmdir() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *);
-static int (*WRAPPER_TRUE_NAME) (const char *) = NULL;
+#define WRAPPER_ARGS const char *pathname
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *pathname)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("rmdir", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname);
diff --git a/libsandbox/wrapper-funcs/symlink.c b/libsandbox/wrapper-funcs/symlink.c
index 1c7372f..996bd39 100644
--- a/libsandbox/wrapper-funcs/symlink.c
+++ b/libsandbox/wrapper-funcs/symlink.c
@@ -1,20 +1,19 @@
/*
- * symlink.c
- *
* symlink() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *, const char *);
-static int (*WRAPPER_TRUE_NAME) (const char *, const char *) = NULL;
+#define WRAPPER_ARGS const char *oldpath, const char *newpath
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *oldpath, const char *newpath)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("symlink", newpath) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, newpath) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(oldpath, newpath);
diff --git a/libsandbox/wrapper-funcs/truncate.c b/libsandbox/wrapper-funcs/truncate.c
index 5d59bc0..e7ec606 100644
--- a/libsandbox/wrapper-funcs/truncate.c
+++ b/libsandbox/wrapper-funcs/truncate.c
@@ -1,6 +1,4 @@
/*
- * truncate.c
- *
* truncate() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, TRUNCATE_T);
-static int (*WRAPPER_TRUE_NAME) (const char *, TRUNCATE_T) = NULL;
+#define WRAPPER_ARGS const char *path, TRUNCATE_T length
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *path, TRUNCATE_T length)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("truncate", path) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, path) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(path, length);
diff --git a/libsandbox/wrapper-funcs/truncate64.c b/libsandbox/wrapper-funcs/truncate64.c
index a5669f6..519ed9b 100644
--- a/libsandbox/wrapper-funcs/truncate64.c
+++ b/libsandbox/wrapper-funcs/truncate64.c
@@ -1,6 +1,4 @@
/*
- * truncate64.c
- *
* truncate64() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
@@ -10,14 +8,15 @@
* as some of the InstallWatch code was used.
*/
-extern int EXTERN_NAME(const char *, __off64_t);
-static int (*WRAPPER_TRUE_NAME) (const char *, __off64_t) = NULL;
+#define WRAPPER_ARGS const char *path, __off64_t length
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *path, __off64_t length)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("truncate64", path) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, path) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(path, length);
diff --git a/libsandbox/wrapper-funcs/unlink.c b/libsandbox/wrapper-funcs/unlink.c
index a8570ce..39de69e 100644
--- a/libsandbox/wrapper-funcs/unlink.c
+++ b/libsandbox/wrapper-funcs/unlink.c
@@ -1,16 +1,15 @@
/*
- * unlink.c
- *
* unlink() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *);
-static int (*WRAPPER_TRUE_NAME) (const char *) = NULL;
+#define WRAPPER_ARGS const char *pathname
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *pathname)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1, old_errno = errno;
char canonic[SB_PATH_MAX];
@@ -30,7 +29,7 @@ int WRAPPER_NAME(const char *pathname)
}
errno = old_errno;
- if FUNCTION_SANDBOX_SAFE("unlink", pathname) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, pathname) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(pathname);
diff --git a/libsandbox/wrapper-funcs/utime.c b/libsandbox/wrapper-funcs/utime.c
index 7ec9aeb..7fb8465 100644
--- a/libsandbox/wrapper-funcs/utime.c
+++ b/libsandbox/wrapper-funcs/utime.c
@@ -1,20 +1,19 @@
/*
- * utime.c
- *
* utime() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *, const struct utimbuf *);
-static int (*WRAPPER_TRUE_NAME) (const char *, const struct utimbuf *) = NULL;
+#define WRAPPER_ARGS const char *filename, const struct utimbuf *times
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *filename, const struct utimbuf *times)
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("utime", filename) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, filename) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(filename, times);
diff --git a/libsandbox/wrapper-funcs/utimes.c b/libsandbox/wrapper-funcs/utimes.c
index 5fdec8d..83fe7d9 100644
--- a/libsandbox/wrapper-funcs/utimes.c
+++ b/libsandbox/wrapper-funcs/utimes.c
@@ -1,20 +1,19 @@
/*
- * utimes.c
- *
* utimes() wrapper.
*
* Copyright 1999-2008 Gentoo Foundation
* Licensed under the GPL-2
*/
-extern int EXTERN_NAME(const char *, const struct timeval []);
-static int (*WRAPPER_TRUE_NAME) (const char *, const struct timeval []) = NULL;
+#define WRAPPER_ARGS const char *filename, const struct timeval times[]
+extern int EXTERN_NAME(WRAPPER_ARGS);
+static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL;
-int WRAPPER_NAME(const char *filename, const struct timeval times[])
+int WRAPPER_NAME(WRAPPER_ARGS)
{
int result = -1;
- if FUNCTION_SANDBOX_SAFE("utimes", filename) {
+ if FUNCTION_SANDBOX_SAFE(STRING_NAME, filename) {
check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME,
WRAPPER_SYMVER);
result = WRAPPER_TRUE_NAME(filename, times);
diff --git a/scripts/gen_symbol_header.awk b/scripts/gen_symbol_header.awk
index 7416243..df3b3e5 100644
--- a/scripts/gen_symbol_header.awk
+++ b/scripts/gen_symbol_header.awk
@@ -110,17 +110,20 @@ END {
printf("#define symver_%s \"%s\"\n", sym_real_name,
symbol_array[2]);
+ printf("#define STRING_NAME \"%s\"\n", sym_index);
printf("#define EXTERN_NAME %s\n", sym_index);
printf("#define WRAPPER_NAME %s\n", sym_real_name);
printf("#define WRAPPER_TRUE_NAME true_%s\n", sym_real_name);
printf("#define WRAPPER_SYMNAME symname_%s\n", sym_real_name);
printf("#define WRAPPER_SYMVER symver_%s\n", sym_real_name);
printf("#include \"wrapper-funcs/%s.c\"\n", sym_index);
+ printf("#undef STRING_NAME\n");
printf("#undef EXTERN_NAME\n");
printf("#undef WRAPPER_NAME\n");
printf("#undef WRAPPER_TRUE_NAME\n");
printf("#undef WRAPPER_SYMNAME\n");
printf("#undef WRAPPER_SYMVER\n");
+ printf("#undef WRAPPER_ARGS\n");
if (symbol_array[2]) {
# Only add symbol versions for versioned libc's