diff options
author | Mike Gilbert <floppym@gentoo.org> | 2023-07-17 11:03:13 -0400 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2023-08-03 20:20:37 -0400 |
commit | 0317bbe09fe23e4bd972ee254f14817def701731 (patch) | |
tree | 2a20bfab92c5aef7d090a7aac364a195b263f6a9 /libsandbox | |
parent | libsandbox: skip checking access() without W_OK or R_OK mode (diff) | |
download | sandbox-0317bbe09fe23e4bd972ee254f14817def701731.tar.gz sandbox-0317bbe09fe23e4bd972ee254f14817def701731.tar.bz2 sandbox-0317bbe09fe23e4bd972ee254f14817def701731.zip |
libsbutil: add sbio_faccessat and use it in sb_exists
sbio_faccessat allows libsbutil to access the unwrapped version of
faccessat when called from libsandbox.
Using faccessat in place of fstatat seems to give a small boost in
performance.
Pass AT_EACCESS faccessat to enable a faster path if uid != euid.
Bug: https://bugs.gentoo.org/910273
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'libsandbox')
-rw-r--r-- | libsandbox/libsandbox.c | 1 | ||||
-rw-r--r-- | libsandbox/wrappers.h | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c index 08b85ce..4edcf60 100644 --- a/libsandbox/libsandbox.c +++ b/libsandbox/libsandbox.c @@ -54,6 +54,7 @@ static char message_path[SB_PATH_MAX]; bool sandbox_on = true; static bool sb_init = false; static bool sb_env_init = false; +int (*sbio_faccessat)(int, const char *, int, int) = sb_unwrapped_faccessat; int (*sbio_open)(const char *, int, mode_t) = sb_unwrapped_open; FILE *(*sbio_popen)(const char *, const char *) = sb_unwrapped_popen; diff --git a/libsandbox/wrappers.h b/libsandbox/wrappers.h index bf5bf64..3237397 100644 --- a/libsandbox/wrappers.h +++ b/libsandbox/wrappers.h @@ -15,6 +15,8 @@ */ #define sb_unwrapped_access sb_unwrapped_access_DEFAULT attribute_hidden int sb_unwrapped_access (const char *, int); +#define sb_unwrapped_faccessat sb_unwrapped_faccessat_DEFAULT +attribute_hidden int sb_unwrapped_faccessat (int, const char *, int, int); #define sb_unwrapped_getcwd sb_unwrapped_getcwd_DEFAULT attribute_hidden char *sb_unwrapped_getcwd (char *, size_t); #define sb_unwrapped_open sb_unwrapped_open_DEFAULT |