src/socket_wrapper.c: export socket_wrapper_syscall_{valid,va}()
authorStefan Metzmacher <metze@samba.org>
Mon, 16 Jan 2023 18:48:57 +0000 (19:48 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 17 Jan 2023 16:49:01 +0000 (17:49 +0100)
We need to hook into syscall() from socket_wrapper as well as
from uid_wrapper() (and maybe others in future).
But the assumption is that only one wrapper will take care
of a single syscall number.

So we provide socket_wrapper_syscall_valid() in order to allow
external consumers (e.g. uid_wrapper.so) to check if
socket_wrapper wants to handle a specified syscall number.

And we provide socket_wrapper_syscall_va() in order to allow
calling into swrap_syscall().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/socket_wrapper.c

index bddadbbaf81b0a7e9e30ef9983280078f7f664c9..199d65243cba738d5de064453680e6b2a042cf56 100644 (file)
@@ -8520,6 +8520,37 @@ long int syscall(long int sysno, ...)
 
        return rc;
 }
+
+/* used by uid_wrapper */
+bool socket_wrapper_syscall_valid(long int sysno);
+bool socket_wrapper_syscall_valid(long int sysno)
+{
+       if (!swrap_is_swrap_related_syscall(sysno)) {
+               return false;
+       }
+
+       if (!socket_wrapper_enabled()) {
+               return false;
+       }
+
+       return true;
+}
+
+/* used by uid_wrapper */
+long int socket_wrapper_syscall_va(long int sysno, va_list va);
+long int socket_wrapper_syscall_va(long int sysno, va_list va)
+{
+       if (!swrap_is_swrap_related_syscall(sysno)) {
+               errno = ENOSYS;
+               return -1;
+       }
+
+       if (!socket_wrapper_enabled()) {
+               return libc_vsyscall(sysno, va);
+       }
+
+       return swrap_syscall(sysno, va);
+}
 #endif /* HAVE_SYSCALL */
 
 static void swrap_thread_prepare(void)