src/uid_wrapper.c: export uid_wrapper_syscall_{valid,va}()
authorStefan Metzmacher <metze@samba.org>
Mon, 16 Jan 2023 10:42:05 +0000 (11:42 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 17 Jan 2023 13:31:10 +0000 (14:31 +0100)
We need to hook into syscall() from uid_wrapper as well as
from socket_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 uid_wrapper_syscall_valid() in order to allow
external consumers (e.g. socket_wrapper.so) to check if
uid_wrapper wants to handle a specified syscall number.

And we provide uid_wrapper_syscall_va() in order to allow
calling into uwrap_syscall().

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

index f81c5539fa45d187381cc4c27a776a3ea064ae48..dd52c423237427841f38ac46d3e3b06f846833e5 100644 (file)
@@ -2667,6 +2667,39 @@ long int syscall (long int sysno, ...)
 
        return rc;
 }
+
+/* used by socket_wrapper */
+bool uid_wrapper_syscall_valid(long int sysno);
+bool uid_wrapper_syscall_valid(long int sysno)
+{
+       if (!uwrap_is_uwrap_related_syscall(sysno)) {
+               return false;
+       }
+
+       if (!uid_wrapper_enabled()) {
+               return false;
+       }
+
+       return true;
+}
+
+/* used by socket_wrapper */
+long int uid_wrapper_syscall_va(long int sysno, va_list va);
+long int uid_wrapper_syscall_va(long int sysno, va_list va)
+{
+       if (!uwrap_is_uwrap_related_syscall(sysno)) {
+               errno = ENOSYS;
+               return -1;
+       }
+
+       if (!uid_wrapper_enabled()) {
+               return libc_vsyscall(sysno, va);
+       }
+
+       uwrap_init();
+
+       return uwrap_syscall(sysno, va);
+}
 #endif /* HAVE_SYSCALL */
 #endif /* HAVE_SYS_SYSCALL_H || HAVE_SYSCALL_H */