diff options
author | Mike Frysinger <vapier@gentoo.org> | 2008-11-10 15:48:58 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-11-10 15:48:58 +0000 |
commit | f27622d796b1ee07a604b0fdb3a2c15c9e0c3343 (patch) | |
tree | 5bf92d6bb93018d3283f887ff4acab6337d5c141 /libsandbox/wrapper-funcs | |
parent | libsandbox: break function args out into WRAPPER_ARGS and func name into STRI... (diff) | |
download | sandbox-f27622d796b1ee07a604b0fdb3a2c15c9e0c3343.tar.gz sandbox-f27622d796b1ee07a604b0fdb3a2c15c9e0c3343.tar.bz2 sandbox-f27622d796b1ee07a604b0fdb3a2c15c9e0c3343.zip |
libsandbox: unify 64bit versions with the non-64bit versions
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r-- | libsandbox/wrapper-funcs/__64_post.h | 2 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/__64_pre.h | 2 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/creat.c | 2 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/creat64.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/fopen.c | 3 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/fopen64.c | 33 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/open.c | 3 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/open64.c | 43 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/truncate.c | 2 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/truncate64.c | 22 |
10 files changed, 19 insertions, 97 deletions
diff --git a/libsandbox/wrapper-funcs/__64_post.h b/libsandbox/wrapper-funcs/__64_post.h new file mode 100644 index 0000000..33ea3b2 --- /dev/null +++ b/libsandbox/wrapper-funcs/__64_post.h @@ -0,0 +1,2 @@ +#undef stat +#undef off_t diff --git a/libsandbox/wrapper-funcs/__64_pre.h b/libsandbox/wrapper-funcs/__64_pre.h new file mode 100644 index 0000000..f76e1b4 --- /dev/null +++ b/libsandbox/wrapper-funcs/__64_pre.h @@ -0,0 +1,2 @@ +#define stat stat64 +#define off_t __off64_t diff --git a/libsandbox/wrapper-funcs/creat.c b/libsandbox/wrapper-funcs/creat.c index 99f6bc7..aa3aaa5 100644 --- a/libsandbox/wrapper-funcs/creat.c +++ b/libsandbox/wrapper-funcs/creat.c @@ -10,7 +10,7 @@ #define WRAPPER_ARGS const char *pathname, mode_t mode extern int EXTERN_NAME(WRAPPER_ARGS); -/* XXX: We use the open() call to simulate create() */ +/* XXX: We use the open() call to simulate creat() */ /* static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; */ int WRAPPER_NAME(WRAPPER_ARGS) diff --git a/libsandbox/wrapper-funcs/creat64.c b/libsandbox/wrapper-funcs/creat64.c index d9608de..5e83d0e 100644 --- a/libsandbox/wrapper-funcs/creat64.c +++ b/libsandbox/wrapper-funcs/creat64.c @@ -8,9 +8,9 @@ * as some of the InstallWatch code was used. */ -#define WRAPPER_ARGS const char *pathname, __mode_t mode +#define WRAPPER_ARGS const char *pathname, mode_t mode extern int EXTERN_NAME(WRAPPER_ARGS); -/* XXX: We use the open64() call to simulate create64() */ +/* XXX: We use the open64() call to simulate creat64() */ /* static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; */ int WRAPPER_NAME(WRAPPER_ARGS) diff --git a/libsandbox/wrapper-funcs/fopen.c b/libsandbox/wrapper-funcs/fopen.c index ef03618..2e285f2 100644 --- a/libsandbox/wrapper-funcs/fopen.c +++ b/libsandbox/wrapper-funcs/fopen.c @@ -21,9 +21,8 @@ FILE *WRAPPER_NAME(WRAPPER_ARGS) if ((NULL != mode) && (mode[0] == 'r')) { /* XXX: If we're trying to read, fail normally if file does * not stat */ - if (-1 == stat(pathname, &st)) { + if (-1 == stat(pathname, &st)) return NULL; - } } errno = old_errno; diff --git a/libsandbox/wrapper-funcs/fopen64.c b/libsandbox/wrapper-funcs/fopen64.c index d5fd77e..4645745 100644 --- a/libsandbox/wrapper-funcs/fopen64.c +++ b/libsandbox/wrapper-funcs/fopen64.c @@ -3,35 +3,8 @@ * * 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 const char *pathname, const char *mode -extern FILE *WRAPPER_NAME(WRAPPER_ARGS); -static FILE *(*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; - -FILE *WRAPPER_NAME(WRAPPER_ARGS) -{ - FILE *result = NULL; - int old_errno = errno; - struct stat64 st; - - if ((NULL != mode) && (mode[0] == 'r')) { - /* XXX: If we're trying to read, fail normally if file does - * not stat */ - if (-1 == stat64(pathname, &st)) { - return NULL; - } - } - errno = old_errno; - - 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); - } - - return result; -} +#include "__64_pre.h" +#include "fopen.c" +#include "__64_post.h" diff --git a/libsandbox/wrapper-funcs/open.c b/libsandbox/wrapper-funcs/open.c index 923842d..18605df 100644 --- a/libsandbox/wrapper-funcs/open.c +++ b/libsandbox/wrapper-funcs/open.c @@ -28,9 +28,8 @@ int WRAPPER_NAME(WRAPPER_ARGS) } else { /* XXX: If we're not trying to create, fail normally if * file does not stat */ - if (-1 == stat(pathname, &st)) { + if (-1 == stat(pathname, &st)) return -1; - } } errno = old_errno; diff --git a/libsandbox/wrapper-funcs/open64.c b/libsandbox/wrapper-funcs/open64.c index 88114e0..622b8ea 100644 --- a/libsandbox/wrapper-funcs/open64.c +++ b/libsandbox/wrapper-funcs/open64.c @@ -3,45 +3,8 @@ * * 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 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(WRAPPER_ARGS) -{ - va_list ap; - int mode = 0; - int result = -1; - int old_errno = errno; - struct stat64 st; - - if (flags & O_CREAT) { - va_start(ap, flags); - mode = va_arg(ap, int); - va_end(ap); - } else { - /* XXX: If we're not trying to create, fail normally if - * file does not stat */ - if (-1 == stat64(pathname, &st)) { - return -1; - } - } - errno = old_errno; - - if FUNCTION_SANDBOX_SAFE_OPEN_INT(STRING_NAME, pathname, flags) { - check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME, - WRAPPER_SYMVER); - if (flags & O_CREAT) - result = WRAPPER_TRUE_NAME(pathname, flags, mode); - else - result = WRAPPER_TRUE_NAME(pathname, flags); - } - - return result; -} +#include "__64_pre.h" +#include "open.c" +#include "__64_post.h" diff --git a/libsandbox/wrapper-funcs/truncate.c b/libsandbox/wrapper-funcs/truncate.c index e7ec606..10a8496 100644 --- a/libsandbox/wrapper-funcs/truncate.c +++ b/libsandbox/wrapper-funcs/truncate.c @@ -8,7 +8,7 @@ * as some of the InstallWatch code was used. */ -#define WRAPPER_ARGS const char *path, TRUNCATE_T length +#define WRAPPER_ARGS const char *path, off_t length extern int EXTERN_NAME(WRAPPER_ARGS); static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; diff --git a/libsandbox/wrapper-funcs/truncate64.c b/libsandbox/wrapper-funcs/truncate64.c index 519ed9b..a06b895 100644 --- a/libsandbox/wrapper-funcs/truncate64.c +++ b/libsandbox/wrapper-funcs/truncate64.c @@ -3,24 +3,8 @@ * * 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 const char *path, __off64_t length -extern int EXTERN_NAME(WRAPPER_ARGS); -static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS) = NULL; - -int WRAPPER_NAME(WRAPPER_ARGS) -{ - int result = -1; - - if FUNCTION_SANDBOX_SAFE(STRING_NAME, path) { - check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME, - WRAPPER_SYMVER); - result = WRAPPER_TRUE_NAME(path, length); - } - - return result; -} +#include "__64_pre.h" +#include "truncate.c" +#include "__64_post.h" |