* [gentoo-commits] proj/sandbox:stable-2.x commit in: tests/, libsbutil/include/rcscripts/util/, libsandbox/, src/, libsbutil/src/, ...
@ 2025-01-08 2:12 Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master commit in: /, tests/, src/, libsandbox/wrapper-funcs/, libsbutil/, Mike Gilbert
0 siblings, 1 reply; 2+ messages in thread
From: Mike Gilbert @ 2025-01-08 2:12 UTC (permalink / raw
To: gentoo-commits
commit: d02e2c066681c44180926c33e1cf8efaf1bf83d9
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 4 02:30:39 2025 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Jan 6 04:16:33 2025 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=d02e2c06
Rework LFS handing
Define _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for code that does not
directly affect the wrapper functions.
Replace _LARGEFILE64_SOURCE functions with the standard variants.
Undefine _FILE_OFFSET_BITS and _TIME_BITS in wrappers.c to expose the
legacy declarations.
Also build the tests without _FILE_OFFSET_BITS set so we can actually
test the legacy functions.
The rc_get_size function now returns int64_t instead of off64_t. There
should be no effective change in behavior.
A new helper sb_fstat is added to avoid calling fstat64 from the wrapper
code.
Bug: https://bugs.gentoo.org/908801
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
Makefile.am | 2 ++
configure.ac | 7 ----
libsandbox/canonicalize.c | 6 ++--
libsandbox/libsandbox.c | 8 ++---
libsandbox/local.mk | 5 +--
libsandbox/pre_check_mkdirat.c | 6 ++--
libsandbox/wrapper-funcs/__wrapper_exec.c | 15 ++++----
libsandbox/wrappers.c | 4 +++
libsbutil/include/rcscripts/util/file.h | 2 +-
libsbutil/local.mk | 3 +-
libsbutil/sb_close.c | 4 +--
libsbutil/{sb_exists.c => sb_stat.c} | 14 ++++++--
libsbutil/sbutil.h | 1 +
libsbutil/src/file.c | 57 +++++++++++++------------------
src/local.mk | 1 +
src/namespaces.c | 4 +--
tests/creat64-0.c | 1 +
tests/fopen64-0.c | 1 +
tests/get-group.c | 4 +--
tests/get-user.c | 4 +--
tests/local.mk | 4 +++
tests/mkostemp64-0.c | 1 +
tests/mkostemps64-0.c | 1 +
tests/mkstemp64-0.c | 1 +
tests/mkstemps64-0.c | 1 +
tests/open64-0.c | 1 +
tests/openat64-0.c | 1 +
tests/test-skel-0.c | 2 +-
tests/trace-memory_static_tst.c | 4 +--
tests/truncate64-0.c | 1 +
30 files changed, 92 insertions(+), 74 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 07b1c6d..37d9933 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
+SIXTY_FOUR_FLAGS = -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
MAKEFLAGS = --no-print-directory
AM_CPPFLAGS = \
+ -U_FILE_OFFSET_BITS -U_TIME_BITS \
$(SANDBOX_DEFINES) \
-I$(top_srcdir)
diff --git a/configure.ac b/configure.ac
index ac43a2e..f58da0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,13 +24,6 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_ISC_POSIX
AC_USE_SYSTEM_EXTENSIONS
-dnl http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html
-dnl _LARGEFILE_SOURCE: enable support for new LFS funcs (ftello/etc...)
-dnl _LARGEFILE64_SOURCE: enable support for 64-bit variants (off64_t/fseeko64/etc...)
-dnl NB: We do not want -D_FILE_OFFSET_BITS=64 because we need to interpose both 32-bit
-dnl and 64-bit FS interfaces, and having the C library rewrite them makes that difficult.
-dnl Along those lines, we do not use AC_SYS_LARGEFILE.
-AS_VAR_APPEND([CPPFLAGS], [" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"])
dnl Checks for programs.
AM_PROG_AR
diff --git a/libsandbox/canonicalize.c b/libsandbox/canonicalize.c
index f8d32f0..ed4a997 100644
--- a/libsandbox/canonicalize.c
+++ b/libsandbox/canonicalize.c
@@ -92,14 +92,14 @@ erealpath(const char *name, char *resolved)
* If not, try a little harder to consume this path in
* case it has symlinks out into a better world ...
*/
- struct stat64 st;
- if (lstat64(rpath, &st) == -1 && errno == EACCES) {
+ struct stat st;
+ if (lstat(rpath, &st) == -1 && errno == EACCES) {
char *p = rpath;
strcpy(rpath, name);
do {
p = strchr(p, '/');
if (p) *p = '\0';
- if (lstat64(rpath, &st))
+ if (lstat(rpath, &st))
break;
if (S_ISLNK(st.st_mode)) {
char buffer[SB_PATH_MAX];
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index c9b4e72..c4637bb 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -343,7 +343,7 @@ static char *resolve_path(const char *path, int follow_link)
char *egetcwd(char *buf, size_t size)
{
- struct stat64 st;
+ struct stat st;
char *tmpbuf;
/* We can't let the C lib allocate memory for us since we have our
@@ -386,7 +386,7 @@ char *egetcwd(char *buf, size_t size)
*/
if ((tmpbuf) && (errno == 0)) {
save_errno();
- if (!lstat64(buf, &st))
+ if (!lstat(buf, &st))
/* errno is set only on failure */
errno = 0;
@@ -445,12 +445,12 @@ void __sb_dump_backtrace(void)
static bool write_logfile(const char *logfile, const char *func, const char *path,
const char *apath, const char *rpath, bool access)
{
- struct stat64 log_stat;
+ struct stat log_stat;
int stat_ret;
int logfd;
bool ret = false;
- stat_ret = lstat64(logfile, &log_stat);
+ stat_ret = lstat(logfile, &log_stat);
/* Do not care about failure */
errno = 0;
if (stat_ret == 0 && S_ISREG(log_stat.st_mode) == 0)
diff --git a/libsandbox/local.mk b/libsandbox/local.mk
index dd78a76..d2fb1d1 100644
--- a/libsandbox/local.mk
+++ b/libsandbox/local.mk
@@ -2,6 +2,7 @@ lib_LTLIBRARIES += %D%/libsandbox.la
%C%_libsandbox_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ $(SIXTY_FOUR_FLAGS) \
-I%D% \
-I$(top_srcdir)/%D% \
-I$(top_srcdir)/libsbutil \
@@ -14,8 +15,8 @@ lib_LTLIBRARIES += %D%/libsandbox.la
libsbutil/.libs/libsbutil.a: libsbutil/libsbutil.la
%C%_libsandbox_la_LIBSBLIB = libsbutil/.libs/libsbutil.a
%C%_libsandbox_la_LIBADD = \
- -lc $(LIBDL) \
- $(%C%_libsandbox_la_LIBSBLIB)
+ $(%C%_libsandbox_la_LIBSBLIB) \
+ $(LIBDL)
# Do not add -nostdlib or -nostartfiles, as then our constructor
# and destructor will not be executed ...
%C%_libsandbox_la_LDFLAGS = \
diff --git a/libsandbox/pre_check_mkdirat.c b/libsandbox/pre_check_mkdirat.c
index c717576..78a1cbe 100644
--- a/libsandbox/pre_check_mkdirat.c
+++ b/libsandbox/pre_check_mkdirat.c
@@ -36,8 +36,8 @@ bool sb_mkdirat_pre_check(const char *func, const char *pathname, int dirfd)
* not want to pass this attempt up to the higher levels as those
* will trigger a sandbox violation.
*/
- struct stat64 st;
- if (0 == lstat64(canonic, &st)) {
+ struct stat st;
+ if (0 == lstat(canonic, &st)) {
int new_errno;
sb_debug_dyn("EARLY FAIL: %s(%s[%s]) @ lstat: %s\n",
func, pathname, canonic, strerror(errno));
@@ -47,7 +47,7 @@ bool sb_mkdirat_pre_check(const char *func, const char *pathname, int dirfd)
/* Hmm, is this a broken symlink we're trying to extend ?
* Or is this a path like "foo/.." ?
*/
- if (stat64(pathname, &st) != 0) {
+ if (stat(pathname, &st) != 0) {
/* XXX: This awful hack should probably be turned into a
* common func that does a better job. For now, we have
* enough crap to catch gnulib tests #297026.
diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c b/libsandbox/wrapper-funcs/__wrapper_exec.c
index f603257..ff63544 100644
--- a/libsandbox/wrapper-funcs/__wrapper_exec.c
+++ b/libsandbox/wrapper-funcs/__wrapper_exec.c
@@ -27,7 +27,8 @@ static bool sb_check_exec(const char *filename, char *const argv[])
{
int fd;
unsigned char *elf;
- struct stat64 st;
+ mode_t mode;
+ int64_t size;
bool do_trace = false;
bool run_in_process = true;
sandbox_method_t method = get_sandbox_method();
@@ -38,11 +39,11 @@ static bool sb_check_exec(const char *filename, char *const argv[])
fd = sb_unwrapped_open_DEFAULT(filename, O_RDONLY|O_CLOEXEC, 0);
if (fd == -1)
return true;
- if (fstat64(fd, &st))
+ if (sb_fstat(fd, &mode, &size))
goto out_fd;
- if (st.st_size < sizeof(Elf64_Ehdr))
+ if (size < sizeof(Elf64_Ehdr))
goto out_fd;
- elf = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ elf = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0);
if (elf == MAP_FAILED)
goto out_fd;
@@ -64,7 +65,7 @@ static bool sb_check_exec(const char *filename, char *const argv[])
* gains root just to preload libsandbox.so. That unfortunately
* could easily open up people to root vulns.
*/
- if (st.st_mode & (S_ISUID | S_ISGID))
+ if (mode & (S_ISUID | S_ISGID))
if (getuid() != 0)
run_in_process = false;
@@ -95,7 +96,7 @@ static bool sb_check_exec(const char *filename, char *const argv[])
bool dynamic = false; \
size_t i; \
\
- if (st.st_size < ehdr->e_phoff + ehdr->e_phentsize * ehdr->e_phnum) \
+ if (size < ehdr->e_phoff + ehdr->e_phentsize * ehdr->e_phnum) \
goto out_mmap; \
\
/* First gather the tags we care about. */ \
@@ -238,7 +239,7 @@ static bool sb_check_exec(const char *filename, char *const argv[])
done:
out_mmap:
- munmap(elf, st.st_size);
+ munmap(elf, size);
out_fd:
close(fd);
diff --git a/libsandbox/wrappers.c b/libsandbox/wrappers.c
index 42b2df1..3ba17b9 100644
--- a/libsandbox/wrappers.c
+++ b/libsandbox/wrappers.c
@@ -10,6 +10,10 @@
* as some of the InstallWatch code was used.
*/
+#undef _FILE_OFFSET_BITS
+#undef _TIME_BITS
+#define _LARGEFILE64_SOURCE
+
#include "headers.h"
#include "sbutil.h"
#include "libsandbox.h"
diff --git a/libsbutil/include/rcscripts/util/file.h b/libsbutil/include/rcscripts/util/file.h
index 8bbde00..cbbd017 100644
--- a/libsbutil/include/rcscripts/util/file.h
+++ b/libsbutil/include/rcscripts/util/file.h
@@ -23,7 +23,7 @@ bool rc_is_dir (const char *pathname, bool follow_link);
/* The following functions do not care about errors - it only returns
* the size/mtime of 'pathname' if it exists, and is the type requested,
* or else 0. */
-off64_t rc_get_size (const char *pathname, bool follow_link);
+int64_t rc_get_size (const char *pathname, bool follow_link);
/* The following return a pointer on success, or NULL with errno set on error.
* If it returned NULL, but errno is not set, then there was no error, but
diff --git a/libsbutil/local.mk b/libsbutil/local.mk
index 1cb5de7..44c3e20 100644
--- a/libsbutil/local.mk
+++ b/libsbutil/local.mk
@@ -2,6 +2,7 @@ noinst_LTLIBRARIES += %D%/libsbutil.la
%C%_libsbutil_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ $(SIXTY_FOUR_FLAGS) \
-I$(top_srcdir)/%D% \
-I$(top_srcdir)/%D%/include
%C%_libsbutil_la_LDFLAGS = -no-undefined
@@ -16,11 +17,11 @@ noinst_LTLIBRARIES += %D%/libsbutil.la
%D%/environment.c \
%D%/sb_backtrace.c \
%D%/sb_efuncs.c \
- %D%/sb_exists.c \
%D%/sb_gdb.c \
%D%/sb_method.c \
%D%/sb_open.c \
%D%/sb_read.c \
+ %D%/sb_stat.c \
%D%/sb_write.c \
%D%/sb_write_fd.c \
%D%/sb_close.c \
diff --git a/libsbutil/sb_close.c b/libsbutil/sb_close.c
index 113deab..5379197 100644
--- a/libsbutil/sb_close.c
+++ b/libsbutil/sb_close.c
@@ -34,7 +34,7 @@ int sb_close(int fd)
void sb_close_all_fds(void)
{
DIR *dirp;
- struct dirent64 *de;
+ struct dirent *de;
int dfd, fd;
const char *fd_dir = sb_get_fd_dir();
@@ -43,7 +43,7 @@ void sb_close_all_fds(void)
sb_ebort("could not process %s\n", fd_dir);
dfd = dirfd(dirp);
- while ((de = readdir64(dirp)) != NULL) {
+ while ((de = readdir(dirp)) != NULL) {
if (de->d_name[0] == '.')
continue;
fd = atoi(de->d_name);
diff --git a/libsbutil/sb_exists.c b/libsbutil/sb_stat.c
similarity index 71%
rename from libsbutil/sb_exists.c
rename to libsbutil/sb_stat.c
index c2171fe..07e31b5 100644
--- a/libsbutil/sb_exists.c
+++ b/libsbutil/sb_stat.c
@@ -9,7 +9,7 @@
/* Wrapper for faccessat to work around buggy behavior on musl */
int sb_exists(int dirfd, const char *pathname, int flags)
{
- struct stat64 buf;
+ struct stat buf;
if (sbio_faccessat(dirfd, pathname, F_OK, flags|AT_EACCESS) == 0)
return 0;
@@ -20,5 +20,15 @@ int sb_exists(int dirfd, const char *pathname, int flags)
if (errno != EINVAL)
return -1;
- return fstatat64(dirfd, pathname, &buf, flags);
+ return fstatat(dirfd, pathname, &buf, flags);
+}
+
+int sb_fstat(int fd, mode_t *mode, int64_t *size)
+{
+ struct stat buf;
+ if(fstat(fd, &buf))
+ return -1;
+ *mode = buf.st_mode;
+ *size = buf.st_size;
+ return 0;
}
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index ed335e2..de89786 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -111,6 +111,7 @@ int sb_close(int fd);
void sb_close_all_fds(void);
int sb_copy_file_to_fd(const char *file, int ofd);
int sb_exists(int dirfd, const char *pathname, int flags);
+int sb_fstat(int fd, mode_t *mode, int64_t *size);
/* Reliable output */
__printf(1, 2) void sb_printf(const char *format, ...);
diff --git a/libsbutil/src/file.c b/libsbutil/src/file.c
index 64a6f0e..ba8da48 100644
--- a/libsbutil/src/file.c
+++ b/libsbutil/src/file.c
@@ -21,62 +21,53 @@ rc_file_exists (const char *pathname)
bool
rc_is_file (const char *pathname, bool follow_link)
{
- struct stat64 buf;
- int retval;
+ struct stat buf;
+ int r;
if (!check_str (pathname))
return false;
- retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
- if ((-1 != retval) && (S_ISREG (buf.st_mode)))
- retval = true;
- else
- retval = false;
-
- return retval;
+ r = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ if (r == -1)
+ return false;
+ return (S_ISREG (buf.st_mode));
}
bool
rc_is_dir (const char *pathname, bool follow_link)
{
- struct stat64 buf;
- int retval;
+ struct stat buf;
+ int r;
if (!check_str (pathname))
return false;
- retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
- if ((-1 != retval) && (S_ISDIR (buf.st_mode)))
- retval = true;
- else
- retval = false;
-
- return retval;
+ r = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ if (r == -1)
+ return false;
+ return (S_ISDIR (buf.st_mode));
}
-off64_t
+int64_t
rc_get_size (const char *pathname, bool follow_link)
{
- struct stat64 buf;
- int retval;
+ struct stat buf;
+ int r;
if (!check_str (pathname))
return 0;
- retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
- if (-1 != retval)
- retval = buf.st_size;
- else
- retval = 0;
-
- return retval;
+ r = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ if (r == -1)
+ return 0;
+ return buf.st_size;
}
char **
rc_ls_dir (const char *pathname, bool hidden, bool sort)
{
DIR *dp;
- struct dirent64 *dir_entry;
+ struct dirent *dir_entry;
char **dirlist = NULL;
if (!check_arg_str (pathname))
@@ -102,7 +93,7 @@ rc_ls_dir (const char *pathname, bool hidden, bool sort)
{
/* Clear errno to distinguish between EOF and error */
errno = 0;
- dir_entry = readdir64 (dp);
+ dir_entry = readdir (dp);
/* Only an error if 'errno' != 0, else EOF */
if ((NULL == dir_entry) && (0 != errno))
{
@@ -184,10 +175,10 @@ error:
int
rc_file_map (const char *filename, char **buf, size_t * bufsize)
{
- struct stat64 stats;
+ struct stat stats;
int fd;
- fd = open64 (filename, O_RDONLY);
+ fd = open (filename, O_RDONLY);
if (fd < 0)
{
rc_errno_set (errno);
@@ -195,7 +186,7 @@ rc_file_map (const char *filename, char **buf, size_t * bufsize)
return -1;
}
- if (fstat64 (fd, &stats) < 0)
+ if (fstat (fd, &stats) < 0)
{
rc_errno_set (errno);
DBG_MSG ("Failed to stat file!\n");
diff --git a/src/local.mk b/src/local.mk
index 61877ae..363ed17 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -2,6 +2,7 @@ bin_PROGRAMS += %D%/sandbox
%C%_sandbox_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ $(SIXTY_FOUR_FLAGS) \
-I$(top_srcdir)/libsbutil \
-I$(top_srcdir)/libsbutil/include
diff --git a/src/namespaces.c b/src/namespaces.c
index 290111a..ee9f82a 100644
--- a/src/namespaces.c
+++ b/src/namespaces.c
@@ -28,7 +28,7 @@
#define xfopen(path, ...) \
({ \
- FILE *_ret = fopen64(path, __VA_ARGS__); \
+ FILE *_ret = fopen(path, __VA_ARGS__); \
if (_ret == 0) \
sb_perr("fopen(%s) failed", #path); \
_ret; \
@@ -107,7 +107,7 @@ static void ns_mount_setup(void)
/* Now map in all the files/dirs we do want to expose. */
int fd;
#define bind_file(node) \
- fd = open64("/dev/shm/" node, O_CREAT, 0); \
+ fd = open("/dev/shm/" node, O_CREAT, 0); \
sb_assert(fd != -1); \
close(fd); \
xmount("/dev/" node, "/dev/shm/" node, NULL, MS_BIND, NULL)
diff --git a/tests/creat64-0.c b/tests/creat64-0.c
index 2fba9c8..f900c58 100644
--- a/tests/creat64-0.c
+++ b/tests/creat64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
mode_t mode = sscanf_mode_t(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/fopen64-0.c b/tests/fopen64-0.c
index 78c0fa7..2c229b9 100644
--- a/tests/fopen64-0.c
+++ b/tests/fopen64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
char *mode = s;
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/get-group.c b/tests/get-group.c
index 30cdfc9..8138967 100644
--- a/tests/get-group.c
+++ b/tests/get-group.c
@@ -31,8 +31,8 @@ int main(int argc, char *argv[])
printf("%i\n", grp->gr_gid);
} else {
const char *file = argv[1];
- struct stat64 st;
- if (lstat64(file, &st))
+ struct stat st;
+ if (lstat(file, &st))
errp("lstat(%s) failed", file);
printf("%i\n", st.st_gid);
}
diff --git a/tests/get-user.c b/tests/get-user.c
index be448d7..f85e299 100644
--- a/tests/get-user.c
+++ b/tests/get-user.c
@@ -31,8 +31,8 @@ int main(int argc, char *argv[])
printf("%i\n", pwd->pw_uid);
} else {
const char *file = argv[1];
- struct stat64 st;
- if (lstat64(file, &st))
+ struct stat st;
+ if (lstat(file, &st))
errp("lstat(%s) failed", file);
printf("%i\n", st.st_uid);
}
diff --git a/tests/local.mk b/tests/local.mk
index f14c1c9..8bf5da5 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -110,6 +110,10 @@ dist_check_SCRIPTS += \
# This will be used by all programs, not just tests/ ...
AM_LDFLAGS = `expr $@ : .*_static >/dev/null && echo -all-static`
+%C%_get_group_CPPFLAGS = $(SIXTY_FOUR_FLAGS)
+%C%_get_user_CPPFLAGS = $(SIXTY_FOUR_FLAGS)
+%C%_trace_memory_static_tst_CPPFLAGS = $(SIXTY_FOUR_FLAGS)
+
%C%_sb_printf_tst_CFLAGS = -I$(top_srcdir)/libsbutil -I$(top_srcdir)/libsbutil/include
%C%_sb_printf_tst_LDADD = libsbutil/libsbutil.la
diff --git a/tests/mkostemp64-0.c b/tests/mkostemp64-0.c
index 54e5a5b..d3c7f7c 100644
--- a/tests/mkostemp64-0.c
+++ b/tests/mkostemp64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
int flags = f_get_flags(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/mkostemps64-0.c b/tests/mkostemps64-0.c
index 9f2e5d8..9328a0c 100644
--- a/tests/mkostemps64-0.c
+++ b/tests/mkostemps64-0.c
@@ -17,4 +17,5 @@
s = argv[i++]; \
int flags = f_get_flags(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/mkstemp64-0.c b/tests/mkstemp64-0.c
index 4e6dc24..cc42d59 100644
--- a/tests/mkstemp64-0.c
+++ b/tests/mkstemp64-0.c
@@ -10,4 +10,5 @@
s = argv[i++]; \
char *template = s;
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/mkstemps64-0.c b/tests/mkstemps64-0.c
index 8506332..af9f25c 100644
--- a/tests/mkstemps64-0.c
+++ b/tests/mkstemps64-0.c
@@ -14,4 +14,5 @@
int suffixlen = 0; \
sscanf(s, "%i", &suffixlen);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/open64-0.c b/tests/open64-0.c
index 5000ddb..e6befb5 100644
--- a/tests/open64-0.c
+++ b/tests/open64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
int flags = f_get_flags(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/openat64-0.c b/tests/openat64-0.c
index 9686bc9..0b8ab19 100644
--- a/tests/openat64-0.c
+++ b/tests/openat64-0.c
@@ -19,4 +19,5 @@
s = argv[i++]; \
mode_t mode = sscanf_mode_t(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c
index efc03f1..6d9a1bb 100644
--- a/tests/test-skel-0.c
+++ b/tests/test-skel-0.c
@@ -129,7 +129,7 @@ int at_get_fd(const char *str_dirfd)
}
str_mode = strtok(NULL, ":");
- return open64(str_path, f_get_flags(str_flags), sscanf_mode_t(str_mode));
+ return open(str_path, f_get_flags(str_flags), sscanf_mode_t(str_mode));
}
#define V_TIMESPEC "NULL | NOW | #[,#]"
diff --git a/tests/trace-memory_static_tst.c b/tests/trace-memory_static_tst.c
index 86a47fe..14c6477 100644
--- a/tests/trace-memory_static_tst.c
+++ b/tests/trace-memory_static_tst.c
@@ -26,7 +26,7 @@ volatile uintptr_t offset = 0;
#define check_ptr(addr) \
({ \
printf(" open(%p)\n", addr); \
- ret = open64(non_const_ptr(addr), O_RDONLY); \
+ ret = open(non_const_ptr(addr), O_RDONLY); \
assert(ret == -1 && errno == EFAULT); \
})
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
printf(" open(%p -> %p [+%#zx])\n", p, p + len, len);
memset(p, 'a', len);
path[end] = '\0';
- ret = open64(p, O_RDONLY);
+ ret = open(p, O_RDONLY);
assert(ret == -1 && (errno == ENOENT || errno == ENAMETOOLONG));
}
}
diff --git a/tests/truncate64-0.c b/tests/truncate64-0.c
index 6e1a15f..710c8bd 100644
--- a/tests/truncate64-0.c
+++ b/tests/truncate64-0.c
@@ -16,4 +16,5 @@
sscanf(s, "%llu", &sl); \
length = sl;
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/sandbox:master commit in: /, tests/, src/, libsandbox/wrapper-funcs/, libsbutil/, ...
2025-01-08 2:12 [gentoo-commits] proj/sandbox:stable-2.x commit in: tests/, libsbutil/include/rcscripts/util/, libsandbox/, src/, libsbutil/src/, Mike Gilbert
@ 2025-01-14 4:38 ` Mike Gilbert
0 siblings, 0 replies; 2+ messages in thread
From: Mike Gilbert @ 2025-01-14 4:38 UTC (permalink / raw
To: gentoo-commits
commit: d02e2c066681c44180926c33e1cf8efaf1bf83d9
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 4 02:30:39 2025 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Jan 6 04:16:33 2025 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=d02e2c06
Rework LFS handing
Define _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for code that does not
directly affect the wrapper functions.
Replace _LARGEFILE64_SOURCE functions with the standard variants.
Undefine _FILE_OFFSET_BITS and _TIME_BITS in wrappers.c to expose the
legacy declarations.
Also build the tests without _FILE_OFFSET_BITS set so we can actually
test the legacy functions.
The rc_get_size function now returns int64_t instead of off64_t. There
should be no effective change in behavior.
A new helper sb_fstat is added to avoid calling fstat64 from the wrapper
code.
Bug: https://bugs.gentoo.org/908801
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
Makefile.am | 2 ++
configure.ac | 7 ----
libsandbox/canonicalize.c | 6 ++--
libsandbox/libsandbox.c | 8 ++---
libsandbox/local.mk | 5 +--
libsandbox/pre_check_mkdirat.c | 6 ++--
libsandbox/wrapper-funcs/__wrapper_exec.c | 15 ++++----
libsandbox/wrappers.c | 4 +++
libsbutil/include/rcscripts/util/file.h | 2 +-
libsbutil/local.mk | 3 +-
libsbutil/sb_close.c | 4 +--
libsbutil/{sb_exists.c => sb_stat.c} | 14 ++++++--
libsbutil/sbutil.h | 1 +
libsbutil/src/file.c | 57 +++++++++++++------------------
src/local.mk | 1 +
src/namespaces.c | 4 +--
tests/creat64-0.c | 1 +
tests/fopen64-0.c | 1 +
tests/get-group.c | 4 +--
tests/get-user.c | 4 +--
tests/local.mk | 4 +++
tests/mkostemp64-0.c | 1 +
tests/mkostemps64-0.c | 1 +
tests/mkstemp64-0.c | 1 +
tests/mkstemps64-0.c | 1 +
tests/open64-0.c | 1 +
tests/openat64-0.c | 1 +
tests/test-skel-0.c | 2 +-
tests/trace-memory_static_tst.c | 4 +--
tests/truncate64-0.c | 1 +
30 files changed, 92 insertions(+), 74 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 07b1c6d..37d9933 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
+SIXTY_FOUR_FLAGS = -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
MAKEFLAGS = --no-print-directory
AM_CPPFLAGS = \
+ -U_FILE_OFFSET_BITS -U_TIME_BITS \
$(SANDBOX_DEFINES) \
-I$(top_srcdir)
diff --git a/configure.ac b/configure.ac
index ac43a2e..f58da0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,13 +24,6 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_ISC_POSIX
AC_USE_SYSTEM_EXTENSIONS
-dnl http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html
-dnl _LARGEFILE_SOURCE: enable support for new LFS funcs (ftello/etc...)
-dnl _LARGEFILE64_SOURCE: enable support for 64-bit variants (off64_t/fseeko64/etc...)
-dnl NB: We do not want -D_FILE_OFFSET_BITS=64 because we need to interpose both 32-bit
-dnl and 64-bit FS interfaces, and having the C library rewrite them makes that difficult.
-dnl Along those lines, we do not use AC_SYS_LARGEFILE.
-AS_VAR_APPEND([CPPFLAGS], [" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"])
dnl Checks for programs.
AM_PROG_AR
diff --git a/libsandbox/canonicalize.c b/libsandbox/canonicalize.c
index f8d32f0..ed4a997 100644
--- a/libsandbox/canonicalize.c
+++ b/libsandbox/canonicalize.c
@@ -92,14 +92,14 @@ erealpath(const char *name, char *resolved)
* If not, try a little harder to consume this path in
* case it has symlinks out into a better world ...
*/
- struct stat64 st;
- if (lstat64(rpath, &st) == -1 && errno == EACCES) {
+ struct stat st;
+ if (lstat(rpath, &st) == -1 && errno == EACCES) {
char *p = rpath;
strcpy(rpath, name);
do {
p = strchr(p, '/');
if (p) *p = '\0';
- if (lstat64(rpath, &st))
+ if (lstat(rpath, &st))
break;
if (S_ISLNK(st.st_mode)) {
char buffer[SB_PATH_MAX];
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index c9b4e72..c4637bb 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -343,7 +343,7 @@ static char *resolve_path(const char *path, int follow_link)
char *egetcwd(char *buf, size_t size)
{
- struct stat64 st;
+ struct stat st;
char *tmpbuf;
/* We can't let the C lib allocate memory for us since we have our
@@ -386,7 +386,7 @@ char *egetcwd(char *buf, size_t size)
*/
if ((tmpbuf) && (errno == 0)) {
save_errno();
- if (!lstat64(buf, &st))
+ if (!lstat(buf, &st))
/* errno is set only on failure */
errno = 0;
@@ -445,12 +445,12 @@ void __sb_dump_backtrace(void)
static bool write_logfile(const char *logfile, const char *func, const char *path,
const char *apath, const char *rpath, bool access)
{
- struct stat64 log_stat;
+ struct stat log_stat;
int stat_ret;
int logfd;
bool ret = false;
- stat_ret = lstat64(logfile, &log_stat);
+ stat_ret = lstat(logfile, &log_stat);
/* Do not care about failure */
errno = 0;
if (stat_ret == 0 && S_ISREG(log_stat.st_mode) == 0)
diff --git a/libsandbox/local.mk b/libsandbox/local.mk
index dd78a76..d2fb1d1 100644
--- a/libsandbox/local.mk
+++ b/libsandbox/local.mk
@@ -2,6 +2,7 @@ lib_LTLIBRARIES += %D%/libsandbox.la
%C%_libsandbox_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ $(SIXTY_FOUR_FLAGS) \
-I%D% \
-I$(top_srcdir)/%D% \
-I$(top_srcdir)/libsbutil \
@@ -14,8 +15,8 @@ lib_LTLIBRARIES += %D%/libsandbox.la
libsbutil/.libs/libsbutil.a: libsbutil/libsbutil.la
%C%_libsandbox_la_LIBSBLIB = libsbutil/.libs/libsbutil.a
%C%_libsandbox_la_LIBADD = \
- -lc $(LIBDL) \
- $(%C%_libsandbox_la_LIBSBLIB)
+ $(%C%_libsandbox_la_LIBSBLIB) \
+ $(LIBDL)
# Do not add -nostdlib or -nostartfiles, as then our constructor
# and destructor will not be executed ...
%C%_libsandbox_la_LDFLAGS = \
diff --git a/libsandbox/pre_check_mkdirat.c b/libsandbox/pre_check_mkdirat.c
index c717576..78a1cbe 100644
--- a/libsandbox/pre_check_mkdirat.c
+++ b/libsandbox/pre_check_mkdirat.c
@@ -36,8 +36,8 @@ bool sb_mkdirat_pre_check(const char *func, const char *pathname, int dirfd)
* not want to pass this attempt up to the higher levels as those
* will trigger a sandbox violation.
*/
- struct stat64 st;
- if (0 == lstat64(canonic, &st)) {
+ struct stat st;
+ if (0 == lstat(canonic, &st)) {
int new_errno;
sb_debug_dyn("EARLY FAIL: %s(%s[%s]) @ lstat: %s\n",
func, pathname, canonic, strerror(errno));
@@ -47,7 +47,7 @@ bool sb_mkdirat_pre_check(const char *func, const char *pathname, int dirfd)
/* Hmm, is this a broken symlink we're trying to extend ?
* Or is this a path like "foo/.." ?
*/
- if (stat64(pathname, &st) != 0) {
+ if (stat(pathname, &st) != 0) {
/* XXX: This awful hack should probably be turned into a
* common func that does a better job. For now, we have
* enough crap to catch gnulib tests #297026.
diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c b/libsandbox/wrapper-funcs/__wrapper_exec.c
index f603257..ff63544 100644
--- a/libsandbox/wrapper-funcs/__wrapper_exec.c
+++ b/libsandbox/wrapper-funcs/__wrapper_exec.c
@@ -27,7 +27,8 @@ static bool sb_check_exec(const char *filename, char *const argv[])
{
int fd;
unsigned char *elf;
- struct stat64 st;
+ mode_t mode;
+ int64_t size;
bool do_trace = false;
bool run_in_process = true;
sandbox_method_t method = get_sandbox_method();
@@ -38,11 +39,11 @@ static bool sb_check_exec(const char *filename, char *const argv[])
fd = sb_unwrapped_open_DEFAULT(filename, O_RDONLY|O_CLOEXEC, 0);
if (fd == -1)
return true;
- if (fstat64(fd, &st))
+ if (sb_fstat(fd, &mode, &size))
goto out_fd;
- if (st.st_size < sizeof(Elf64_Ehdr))
+ if (size < sizeof(Elf64_Ehdr))
goto out_fd;
- elf = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ elf = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0);
if (elf == MAP_FAILED)
goto out_fd;
@@ -64,7 +65,7 @@ static bool sb_check_exec(const char *filename, char *const argv[])
* gains root just to preload libsandbox.so. That unfortunately
* could easily open up people to root vulns.
*/
- if (st.st_mode & (S_ISUID | S_ISGID))
+ if (mode & (S_ISUID | S_ISGID))
if (getuid() != 0)
run_in_process = false;
@@ -95,7 +96,7 @@ static bool sb_check_exec(const char *filename, char *const argv[])
bool dynamic = false; \
size_t i; \
\
- if (st.st_size < ehdr->e_phoff + ehdr->e_phentsize * ehdr->e_phnum) \
+ if (size < ehdr->e_phoff + ehdr->e_phentsize * ehdr->e_phnum) \
goto out_mmap; \
\
/* First gather the tags we care about. */ \
@@ -238,7 +239,7 @@ static bool sb_check_exec(const char *filename, char *const argv[])
done:
out_mmap:
- munmap(elf, st.st_size);
+ munmap(elf, size);
out_fd:
close(fd);
diff --git a/libsandbox/wrappers.c b/libsandbox/wrappers.c
index 42b2df1..3ba17b9 100644
--- a/libsandbox/wrappers.c
+++ b/libsandbox/wrappers.c
@@ -10,6 +10,10 @@
* as some of the InstallWatch code was used.
*/
+#undef _FILE_OFFSET_BITS
+#undef _TIME_BITS
+#define _LARGEFILE64_SOURCE
+
#include "headers.h"
#include "sbutil.h"
#include "libsandbox.h"
diff --git a/libsbutil/include/rcscripts/util/file.h b/libsbutil/include/rcscripts/util/file.h
index 8bbde00..cbbd017 100644
--- a/libsbutil/include/rcscripts/util/file.h
+++ b/libsbutil/include/rcscripts/util/file.h
@@ -23,7 +23,7 @@ bool rc_is_dir (const char *pathname, bool follow_link);
/* The following functions do not care about errors - it only returns
* the size/mtime of 'pathname' if it exists, and is the type requested,
* or else 0. */
-off64_t rc_get_size (const char *pathname, bool follow_link);
+int64_t rc_get_size (const char *pathname, bool follow_link);
/* The following return a pointer on success, or NULL with errno set on error.
* If it returned NULL, but errno is not set, then there was no error, but
diff --git a/libsbutil/local.mk b/libsbutil/local.mk
index 1cb5de7..44c3e20 100644
--- a/libsbutil/local.mk
+++ b/libsbutil/local.mk
@@ -2,6 +2,7 @@ noinst_LTLIBRARIES += %D%/libsbutil.la
%C%_libsbutil_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ $(SIXTY_FOUR_FLAGS) \
-I$(top_srcdir)/%D% \
-I$(top_srcdir)/%D%/include
%C%_libsbutil_la_LDFLAGS = -no-undefined
@@ -16,11 +17,11 @@ noinst_LTLIBRARIES += %D%/libsbutil.la
%D%/environment.c \
%D%/sb_backtrace.c \
%D%/sb_efuncs.c \
- %D%/sb_exists.c \
%D%/sb_gdb.c \
%D%/sb_method.c \
%D%/sb_open.c \
%D%/sb_read.c \
+ %D%/sb_stat.c \
%D%/sb_write.c \
%D%/sb_write_fd.c \
%D%/sb_close.c \
diff --git a/libsbutil/sb_close.c b/libsbutil/sb_close.c
index 113deab..5379197 100644
--- a/libsbutil/sb_close.c
+++ b/libsbutil/sb_close.c
@@ -34,7 +34,7 @@ int sb_close(int fd)
void sb_close_all_fds(void)
{
DIR *dirp;
- struct dirent64 *de;
+ struct dirent *de;
int dfd, fd;
const char *fd_dir = sb_get_fd_dir();
@@ -43,7 +43,7 @@ void sb_close_all_fds(void)
sb_ebort("could not process %s\n", fd_dir);
dfd = dirfd(dirp);
- while ((de = readdir64(dirp)) != NULL) {
+ while ((de = readdir(dirp)) != NULL) {
if (de->d_name[0] == '.')
continue;
fd = atoi(de->d_name);
diff --git a/libsbutil/sb_exists.c b/libsbutil/sb_stat.c
similarity index 71%
rename from libsbutil/sb_exists.c
rename to libsbutil/sb_stat.c
index c2171fe..07e31b5 100644
--- a/libsbutil/sb_exists.c
+++ b/libsbutil/sb_stat.c
@@ -9,7 +9,7 @@
/* Wrapper for faccessat to work around buggy behavior on musl */
int sb_exists(int dirfd, const char *pathname, int flags)
{
- struct stat64 buf;
+ struct stat buf;
if (sbio_faccessat(dirfd, pathname, F_OK, flags|AT_EACCESS) == 0)
return 0;
@@ -20,5 +20,15 @@ int sb_exists(int dirfd, const char *pathname, int flags)
if (errno != EINVAL)
return -1;
- return fstatat64(dirfd, pathname, &buf, flags);
+ return fstatat(dirfd, pathname, &buf, flags);
+}
+
+int sb_fstat(int fd, mode_t *mode, int64_t *size)
+{
+ struct stat buf;
+ if(fstat(fd, &buf))
+ return -1;
+ *mode = buf.st_mode;
+ *size = buf.st_size;
+ return 0;
}
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index ed335e2..de89786 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -111,6 +111,7 @@ int sb_close(int fd);
void sb_close_all_fds(void);
int sb_copy_file_to_fd(const char *file, int ofd);
int sb_exists(int dirfd, const char *pathname, int flags);
+int sb_fstat(int fd, mode_t *mode, int64_t *size);
/* Reliable output */
__printf(1, 2) void sb_printf(const char *format, ...);
diff --git a/libsbutil/src/file.c b/libsbutil/src/file.c
index 64a6f0e..ba8da48 100644
--- a/libsbutil/src/file.c
+++ b/libsbutil/src/file.c
@@ -21,62 +21,53 @@ rc_file_exists (const char *pathname)
bool
rc_is_file (const char *pathname, bool follow_link)
{
- struct stat64 buf;
- int retval;
+ struct stat buf;
+ int r;
if (!check_str (pathname))
return false;
- retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
- if ((-1 != retval) && (S_ISREG (buf.st_mode)))
- retval = true;
- else
- retval = false;
-
- return retval;
+ r = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ if (r == -1)
+ return false;
+ return (S_ISREG (buf.st_mode));
}
bool
rc_is_dir (const char *pathname, bool follow_link)
{
- struct stat64 buf;
- int retval;
+ struct stat buf;
+ int r;
if (!check_str (pathname))
return false;
- retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
- if ((-1 != retval) && (S_ISDIR (buf.st_mode)))
- retval = true;
- else
- retval = false;
-
- return retval;
+ r = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ if (r == -1)
+ return false;
+ return (S_ISDIR (buf.st_mode));
}
-off64_t
+int64_t
rc_get_size (const char *pathname, bool follow_link)
{
- struct stat64 buf;
- int retval;
+ struct stat buf;
+ int r;
if (!check_str (pathname))
return 0;
- retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
- if (-1 != retval)
- retval = buf.st_size;
- else
- retval = 0;
-
- return retval;
+ r = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ if (r == -1)
+ return 0;
+ return buf.st_size;
}
char **
rc_ls_dir (const char *pathname, bool hidden, bool sort)
{
DIR *dp;
- struct dirent64 *dir_entry;
+ struct dirent *dir_entry;
char **dirlist = NULL;
if (!check_arg_str (pathname))
@@ -102,7 +93,7 @@ rc_ls_dir (const char *pathname, bool hidden, bool sort)
{
/* Clear errno to distinguish between EOF and error */
errno = 0;
- dir_entry = readdir64 (dp);
+ dir_entry = readdir (dp);
/* Only an error if 'errno' != 0, else EOF */
if ((NULL == dir_entry) && (0 != errno))
{
@@ -184,10 +175,10 @@ error:
int
rc_file_map (const char *filename, char **buf, size_t * bufsize)
{
- struct stat64 stats;
+ struct stat stats;
int fd;
- fd = open64 (filename, O_RDONLY);
+ fd = open (filename, O_RDONLY);
if (fd < 0)
{
rc_errno_set (errno);
@@ -195,7 +186,7 @@ rc_file_map (const char *filename, char **buf, size_t * bufsize)
return -1;
}
- if (fstat64 (fd, &stats) < 0)
+ if (fstat (fd, &stats) < 0)
{
rc_errno_set (errno);
DBG_MSG ("Failed to stat file!\n");
diff --git a/src/local.mk b/src/local.mk
index 61877ae..363ed17 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -2,6 +2,7 @@ bin_PROGRAMS += %D%/sandbox
%C%_sandbox_CPPFLAGS = \
$(AM_CPPFLAGS) \
+ $(SIXTY_FOUR_FLAGS) \
-I$(top_srcdir)/libsbutil \
-I$(top_srcdir)/libsbutil/include
diff --git a/src/namespaces.c b/src/namespaces.c
index 290111a..ee9f82a 100644
--- a/src/namespaces.c
+++ b/src/namespaces.c
@@ -28,7 +28,7 @@
#define xfopen(path, ...) \
({ \
- FILE *_ret = fopen64(path, __VA_ARGS__); \
+ FILE *_ret = fopen(path, __VA_ARGS__); \
if (_ret == 0) \
sb_perr("fopen(%s) failed", #path); \
_ret; \
@@ -107,7 +107,7 @@ static void ns_mount_setup(void)
/* Now map in all the files/dirs we do want to expose. */
int fd;
#define bind_file(node) \
- fd = open64("/dev/shm/" node, O_CREAT, 0); \
+ fd = open("/dev/shm/" node, O_CREAT, 0); \
sb_assert(fd != -1); \
close(fd); \
xmount("/dev/" node, "/dev/shm/" node, NULL, MS_BIND, NULL)
diff --git a/tests/creat64-0.c b/tests/creat64-0.c
index 2fba9c8..f900c58 100644
--- a/tests/creat64-0.c
+++ b/tests/creat64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
mode_t mode = sscanf_mode_t(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/fopen64-0.c b/tests/fopen64-0.c
index 78c0fa7..2c229b9 100644
--- a/tests/fopen64-0.c
+++ b/tests/fopen64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
char *mode = s;
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/get-group.c b/tests/get-group.c
index 30cdfc9..8138967 100644
--- a/tests/get-group.c
+++ b/tests/get-group.c
@@ -31,8 +31,8 @@ int main(int argc, char *argv[])
printf("%i\n", grp->gr_gid);
} else {
const char *file = argv[1];
- struct stat64 st;
- if (lstat64(file, &st))
+ struct stat st;
+ if (lstat(file, &st))
errp("lstat(%s) failed", file);
printf("%i\n", st.st_gid);
}
diff --git a/tests/get-user.c b/tests/get-user.c
index be448d7..f85e299 100644
--- a/tests/get-user.c
+++ b/tests/get-user.c
@@ -31,8 +31,8 @@ int main(int argc, char *argv[])
printf("%i\n", pwd->pw_uid);
} else {
const char *file = argv[1];
- struct stat64 st;
- if (lstat64(file, &st))
+ struct stat st;
+ if (lstat(file, &st))
errp("lstat(%s) failed", file);
printf("%i\n", st.st_uid);
}
diff --git a/tests/local.mk b/tests/local.mk
index f14c1c9..8bf5da5 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -110,6 +110,10 @@ dist_check_SCRIPTS += \
# This will be used by all programs, not just tests/ ...
AM_LDFLAGS = `expr $@ : .*_static >/dev/null && echo -all-static`
+%C%_get_group_CPPFLAGS = $(SIXTY_FOUR_FLAGS)
+%C%_get_user_CPPFLAGS = $(SIXTY_FOUR_FLAGS)
+%C%_trace_memory_static_tst_CPPFLAGS = $(SIXTY_FOUR_FLAGS)
+
%C%_sb_printf_tst_CFLAGS = -I$(top_srcdir)/libsbutil -I$(top_srcdir)/libsbutil/include
%C%_sb_printf_tst_LDADD = libsbutil/libsbutil.la
diff --git a/tests/mkostemp64-0.c b/tests/mkostemp64-0.c
index 54e5a5b..d3c7f7c 100644
--- a/tests/mkostemp64-0.c
+++ b/tests/mkostemp64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
int flags = f_get_flags(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/mkostemps64-0.c b/tests/mkostemps64-0.c
index 9f2e5d8..9328a0c 100644
--- a/tests/mkostemps64-0.c
+++ b/tests/mkostemps64-0.c
@@ -17,4 +17,5 @@
s = argv[i++]; \
int flags = f_get_flags(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/mkstemp64-0.c b/tests/mkstemp64-0.c
index 4e6dc24..cc42d59 100644
--- a/tests/mkstemp64-0.c
+++ b/tests/mkstemp64-0.c
@@ -10,4 +10,5 @@
s = argv[i++]; \
char *template = s;
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/mkstemps64-0.c b/tests/mkstemps64-0.c
index 8506332..af9f25c 100644
--- a/tests/mkstemps64-0.c
+++ b/tests/mkstemps64-0.c
@@ -14,4 +14,5 @@
int suffixlen = 0; \
sscanf(s, "%i", &suffixlen);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/open64-0.c b/tests/open64-0.c
index 5000ddb..e6befb5 100644
--- a/tests/open64-0.c
+++ b/tests/open64-0.c
@@ -13,4 +13,5 @@
s = argv[i++]; \
int flags = f_get_flags(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/openat64-0.c b/tests/openat64-0.c
index 9686bc9..0b8ab19 100644
--- a/tests/openat64-0.c
+++ b/tests/openat64-0.c
@@ -19,4 +19,5 @@
s = argv[i++]; \
mode_t mode = sscanf_mode_t(s);
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c
index efc03f1..6d9a1bb 100644
--- a/tests/test-skel-0.c
+++ b/tests/test-skel-0.c
@@ -129,7 +129,7 @@ int at_get_fd(const char *str_dirfd)
}
str_mode = strtok(NULL, ":");
- return open64(str_path, f_get_flags(str_flags), sscanf_mode_t(str_mode));
+ return open(str_path, f_get_flags(str_flags), sscanf_mode_t(str_mode));
}
#define V_TIMESPEC "NULL | NOW | #[,#]"
diff --git a/tests/trace-memory_static_tst.c b/tests/trace-memory_static_tst.c
index 86a47fe..14c6477 100644
--- a/tests/trace-memory_static_tst.c
+++ b/tests/trace-memory_static_tst.c
@@ -26,7 +26,7 @@ volatile uintptr_t offset = 0;
#define check_ptr(addr) \
({ \
printf(" open(%p)\n", addr); \
- ret = open64(non_const_ptr(addr), O_RDONLY); \
+ ret = open(non_const_ptr(addr), O_RDONLY); \
assert(ret == -1 && errno == EFAULT); \
})
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
printf(" open(%p -> %p [+%#zx])\n", p, p + len, len);
memset(p, 'a', len);
path[end] = '\0';
- ret = open64(p, O_RDONLY);
+ ret = open(p, O_RDONLY);
assert(ret == -1 && (errno == ENOENT || errno == ENAMETOOLONG));
}
}
diff --git a/tests/truncate64-0.c b/tests/truncate64-0.c
index 6e1a15f..710c8bd 100644
--- a/tests/truncate64-0.c
+++ b/tests/truncate64-0.c
@@ -16,4 +16,5 @@
sscanf(s, "%llu", &sl); \
length = sl;
+#define _LARGEFILE64_SOURCE
#include "test-skel-0.c"
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-14 4:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 2:12 [gentoo-commits] proj/sandbox:stable-2.x commit in: tests/, libsbutil/include/rcscripts/util/, libsandbox/, src/, libsbutil/src/, Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master commit in: /, tests/, src/, libsandbox/wrapper-funcs/, libsbutil/, Mike Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox