[gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/

2021-10-28 Thread Mike Frysinger
commit: b9a9f6239d46f54ff1fc747b73ddf58082aa6559
Author: Mike Frysinger  gentoo  org>
AuthorDate: Fri Oct 29 04:02:22 2021 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Fri Oct 29 04:02:22 2021 +
URL:https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=b9a9f623

libsandbox: drop args to trace_main

The filename was only used for a single debug print, and the args
ignored completely.  Don't bother passing them down at all.

Signed-off-by: Mike Frysinger  gentoo.org>

 libsandbox/libsandbox.h   | 2 +-
 libsandbox/trace.c| 6 ++
 libsandbox/wrapper-funcs/__wrapper_exec.c | 6 --
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libsandbox/libsandbox.h b/libsandbox/libsandbox.h
index fbea6ba..206c506 100644
--- a/libsandbox/libsandbox.h
+++ b/libsandbox/libsandbox.h
@@ -82,7 +82,7 @@ extern void sb_lock(void);
 extern void sb_unlock(void);
 
 bool trace_possible(const char *filename, char *const argv[], const void 
*data);
-void trace_main(const char *filename, char *const argv[]);
+void trace_main(void);
 
 /* glibc modified realpath() function */
 char *erealpath(const char *, char *);

diff --git a/libsandbox/trace.c b/libsandbox/trace.c
index d53051d..4e01f6e 100644
--- a/libsandbox/trace.c
+++ b/libsandbox/trace.c
@@ -510,12 +510,10 @@ static void trace_loop(void)
} while (1);
 }
 
-void trace_main(const char *filename, char *const argv[])
+void trace_main(void)
 {
struct sigaction old_sa, sa = { .sa_handler = SIG_DFL, };
 
-   sb_debug_dyn("trace_main: tracing: %s\n", filename);
-
if (trace_pid)
sb_ebort("ISE: trace code assumes multiple threads are not 
forking\n");
 
@@ -550,7 +548,7 @@ void trace_main(const char *filename, char *const argv[])
 #undef _trace_possible
 #define _trace_possible(data) false
 
-void trace_main(const char *filename, char *const argv[])
+void trace_main(void)
 {
/* trace_possible() triggers a warning for us */
 }

diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c 
b/libsandbox/wrapper-funcs/__wrapper_exec.c
index 8ea5255..d66e3a0 100644
--- a/libsandbox/wrapper-funcs/__wrapper_exec.c
+++ b/libsandbox/wrapper-funcs/__wrapper_exec.c
@@ -242,8 +242,10 @@ static bool sb_check_exec(const char *filename, char 
*const argv[])
  out_fd:
close(fd);
 
-   if (do_trace)
-   trace_main(filename, argv);
+   if (do_trace) {
+   sb_debug_dyn("tracing: %s\n", filename);
+   trace_main();
+   }
 
return run_in_process;
 }



[gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/, tests/

2021-10-23 Thread Mike Frysinger
commit: afa38c053de48152beef9d8bf6726a4710bcba58
Author: Mike Frysinger  gentoo  org>
AuthorDate: Sat Oct 23 07:25:25 2021 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Sat Oct 23 22:18:03 2021 +
URL:https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=afa38c05

libsandbox: add 64-bit time_t wrappers

This intercepts the C library 64-bit time_t interfaces.  The syscall
trace side will need more work first.

Bug: https://bugs.gentoo.org/751241
Signed-off-by: Mike Frysinger  gentoo.org>

 libsandbox/symbols.h.in  |  5 +
 libsandbox/wrapper-funcs/__futimesat64.c | 13 +
 libsandbox/wrapper-funcs/__lutimes64.c   | 13 +
 libsandbox/wrapper-funcs/__utime64.c | 13 +
 libsandbox/wrapper-funcs/__utimensat64.c | 13 +
 libsandbox/wrapper-funcs/__utimes64.c| 13 +
 libsandbox/wrapper-funcs/futimesat.c |  4 +++-
 libsandbox/wrapper-funcs/lutimes.c   |  4 +++-
 libsandbox/wrapper-funcs/utime.c |  4 +++-
 libsandbox/wrapper-funcs/utimensat.c |  4 +++-
 libsandbox/wrapper-funcs/utimes.c|  4 +++-
 tests/local.mk   |  2 ++
 tests/test-skel-0.c  |  4 ++--
 tests/utimensat64-0.c|  3 +++
 tests/utimensat64-1.sh   |  9 +
 tests/utimensat64.at |  1 +
 tests/utimensat64_static-0.c |  1 +
 tests/utimensat64_static-1.sh| 10 ++
 tests/utimensat64_static.at  |  1 +
 19 files changed, 114 insertions(+), 7 deletions(-)

diff --git a/libsandbox/symbols.h.in b/libsandbox/symbols.h.in
index 0fe6eca..40c04e3 100644
--- a/libsandbox/symbols.h.in
+++ b/libsandbox/symbols.h.in
@@ -74,9 +74,14 @@ lremovexattr
 setxattr
 lsetxattr
 utime
+__utime64
 utimes
+__utimes64
 utimensat
+__utimensat64
 futimesat
+__futimesat64
 lutimes
+__lutimes64
 fork
 vfork

diff --git a/libsandbox/wrapper-funcs/__futimesat64.c 
b/libsandbox/wrapper-funcs/__futimesat64.c
new file mode 100644
index 000..9ad791e
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__futimesat64.c
@@ -0,0 +1,13 @@
+/*
+ * __futimesat64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit 
time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it 
doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE_AT(SB_NR_FUTIMESAT, STRING_NAME, dirfd, 
filename, 0)
+#include "futimesat.c"

diff --git a/libsandbox/wrapper-funcs/__lutimes64.c 
b/libsandbox/wrapper-funcs/__lutimes64.c
new file mode 100644
index 000..edab47c
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__lutimes64.c
@@ -0,0 +1,13 @@
+/*
+ * __lutimes64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit 
time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it 
doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE(SB_NR_LUTIMES, STRING_NAME, filename)
+#include "lutimes.c"

diff --git a/libsandbox/wrapper-funcs/__utime64.c 
b/libsandbox/wrapper-funcs/__utime64.c
new file mode 100644
index 000..4e1b573
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__utime64.c
@@ -0,0 +1,13 @@
+/*
+ * __utime64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit 
time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it 
doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE(SB_NR_UTIME, STRING_NAME, filename)
+#include "utime.c"

diff --git a/libsandbox/wrapper-funcs/__utimensat64.c 
b/libsandbox/wrapper-funcs/__utimensat64.c
new file mode 100644
index 000..4ef1c69
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__utimensat64.c
@@ -0,0 +1,13 @@
+/*
+ * __utimensat64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit 
time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it 
doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE_AT(SB_NR_UTIMENSAT, STRING_NAME, dirfd, 
filename, flags)
+#include "utimensat.c"

diff --git a/libsandbox/wrapper-funcs/__utimes64.c 
b/libsandbox/wrapper-funcs/__utimes64.c
new file mode 100644
index 000..3fa6688
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__utimes64.c
@@ -0,0 +1,13 @@
+/*
+ * __utimes64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit 
time interface uses a
+ * different structure, but we never deco

[gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/

2015-12-22 Thread Mike Frysinger
commit: 0c51ddd4f3f9c96149750445cc68c00ed8829404
Author: Mike Frysinger  gentoo  org>
AuthorDate: Wed Dec 23 01:57:07 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Wed Dec 23 01:57:07 2015 +
URL:https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=0c51ddd4

libsandbox: add wrappers for execveat & execvpe

Signed-off-by: Mike Frysinger  gentoo.org>

 libsandbox/symbols.h.in |  2 ++
 libsandbox/wrapper-funcs/execveat.c | 13 +
 libsandbox/wrapper-funcs/execvpe.c  | 12 
 3 files changed, 27 insertions(+)

diff --git a/libsandbox/symbols.h.in b/libsandbox/symbols.h.in
index e34b977..bdbce08 100644
--- a/libsandbox/symbols.h.in
+++ b/libsandbox/symbols.h.in
@@ -62,7 +62,9 @@ mkstemps64
 #execlp
 execv
 execve
+execveat
 execvp
+execvpe
 fexecve
 system
 popen

diff --git a/libsandbox/wrapper-funcs/execveat.c 
b/libsandbox/wrapper-funcs/execveat.c
new file mode 100644
index 000..70ac0bd
--- /dev/null
+++ b/libsandbox/wrapper-funcs/execveat.c
@@ -0,0 +1,13 @@
+/*
+ * execve() wrapper.
+ *
+ * Copyright 1999-2015 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+#define WRAPPER_ARGS_PROTO int dirfd, const char *path, char *const argv[], 
char *const envp[], int flags
+#define WRAPPER_ARGS dirfd, path, argv, envp, flags
+#define EXEC_ARGS dirfd, path, argv, my_env, flags
+#define EXEC_MY_ENV
+#define EXEC_NO_PATH
+#include "__wrapper_exec.c"

diff --git a/libsandbox/wrapper-funcs/execvpe.c 
b/libsandbox/wrapper-funcs/execvpe.c
new file mode 100644
index 000..3402043
--- /dev/null
+++ b/libsandbox/wrapper-funcs/execvpe.c
@@ -0,0 +1,12 @@
+/*
+ * execvpe() wrapper.
+ *
+ * Copyright 1999-2015 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+#define WRAPPER_ARGS_PROTO const char *path, char *const argv[], char *const 
envp[]
+#define WRAPPER_ARGS path, argv, envp
+#define EXEC_ARGS path, argv, my_env
+#define EXEC_MY_ENV
+#include "__wrapper_exec.c"