[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Thu Jun 29 16:07:01 UTC 2023
The branch, master has been updated
via d720eb2c083 third_party: Update socket_wrapper to version 1.4.2
from afbed653526 s3:utils: smbget fix a memory leak
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit d720eb2c083f3d162e93011d69c4b742cd03f3aa
Author: Andreas Schneider <asn at samba.org>
Date: Wed Jun 21 12:40:16 2023 +0200
third_party: Update socket_wrapper to version 1.4.2
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Thu Jun 29 16:06:11 UTC 2023 on atb-devel-224
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/samba_third_party.py | 2 +-
third_party/socket_wrapper/socket_wrapper.c | 182 ++++++++++++++++++++++++++++
third_party/socket_wrapper/wscript | 7 +-
3 files changed, 189 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/samba_third_party.py b/buildtools/wafsamba/samba_third_party.py
index 356b041a2a9..52898486fd9 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -24,7 +24,7 @@ Build.BuildContext.CHECK_CMOCKA = CHECK_CMOCKA
@conf
def CHECK_SOCKET_WRAPPER(conf):
- return conf.CHECK_BUNDLED_SYSTEM_PKG('socket_wrapper', minversion='1.4.0')
+ return conf.CHECK_BUNDLED_SYSTEM_PKG('socket_wrapper', minversion='1.4.2')
Build.BuildContext.CHECK_SOCKET_WRAPPER = CHECK_SOCKET_WRAPPER
@conf
diff --git a/third_party/socket_wrapper/socket_wrapper.c b/third_party/socket_wrapper/socket_wrapper.c
index bf4a976eaee..c759d350fb1 100644
--- a/third_party/socket_wrapper/socket_wrapper.c
+++ b/third_party/socket_wrapper/socket_wrapper.c
@@ -44,6 +44,12 @@
#include "config.h"
+/*
+ * Make sure we do not redirect (f)open(at)() or fcntl() to their 64bit
+ * variants
+ */
+#undef _FILE_OFFSET_BITS
+
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -94,6 +100,10 @@
#include "socket_wrapper.h"
+#ifdef __USE_FILE_OFFSET64
+#error -D_FILE_OFFSET_BITS=64 should not be set for socket_wrapper!
+#endif
+
enum swrap_dbglvl_e {
SWRAP_LOG_ERROR = 0,
SWRAP_LOG_WARN,
@@ -507,6 +517,9 @@ typedef int (*__libc_connect)(int sockfd,
typedef int (*__libc_dup)(int fd);
typedef int (*__libc_dup2)(int oldfd, int newfd);
typedef int (*__libc_fcntl)(int fd, int cmd, ...);
+#ifdef HAVE_FCNTL64
+typedef int (*__libc_fcntl64)(int fd, int cmd, ...);
+#endif
typedef FILE *(*__libc_fopen)(const char *name, const char *mode);
#ifdef HAVE_FOPEN64
typedef FILE *(*__libc_fopen64)(const char *name, const char *mode);
@@ -531,6 +544,9 @@ typedef int (*__libc_open)(const char *pathname, int flags, ...);
#ifdef HAVE_OPEN64
typedef int (*__libc_open64)(const char *pathname, int flags, ...);
#endif /* HAVE_OPEN64 */
+#ifdef HAVE_OPENAT64
+typedef int (*__libc_openat64)(int dirfd, const char *pathname, int flags, ...);
+#endif /* HAVE_OPENAT64 */
typedef int (*__libc_openat)(int dirfd, const char *path, int flags, ...);
typedef int (*__libc_pipe)(int pipefd[2]);
typedef int (*__libc_read)(int fd, void *buf, size_t count);
@@ -612,6 +628,9 @@ struct swrap_libc_symbols {
SWRAP_SYMBOL_ENTRY(dup);
SWRAP_SYMBOL_ENTRY(dup2);
SWRAP_SYMBOL_ENTRY(fcntl);
+#ifdef HAVE_FCNTL64
+ SWRAP_SYMBOL_ENTRY(fcntl64);
+#endif
SWRAP_SYMBOL_ENTRY(fopen);
#ifdef HAVE_FOPEN64
SWRAP_SYMBOL_ENTRY(fopen64);
@@ -627,6 +646,9 @@ struct swrap_libc_symbols {
SWRAP_SYMBOL_ENTRY(open);
#ifdef HAVE_OPEN64
SWRAP_SYMBOL_ENTRY(open64);
+#endif
+#ifdef HAVE_OPENAT64
+ SWRAP_SYMBOL_ENTRY(openat64);
#endif
SWRAP_SYMBOL_ENTRY(openat);
SWRAP_SYMBOL_ENTRY(pipe);
@@ -983,6 +1005,23 @@ static int libc_vfcntl(int fd, int cmd, va_list ap)
return rc;
}
+#ifdef HAVE_FCNTL64
+DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
+static int libc_vfcntl64(int fd, int cmd, va_list ap)
+{
+ void *arg;
+ int rc;
+
+ swrap_bind_symbol_all();
+
+ arg = va_arg(ap, void *);
+
+ rc = swrap.libc.symbols._libc_fcntl64.f(fd, cmd, arg);
+
+ return rc;
+}
+#endif
+
static int libc_getpeername(int sockfd,
struct sockaddr *addr,
socklen_t *addrlen)
@@ -1115,6 +1154,29 @@ static int libc_vopen64(const char *pathname, int flags, va_list ap)
}
#endif /* HAVE_OPEN64 */
+#ifdef HAVE_OPENAT64
+static int
+libc_vopenat64(int dirfd, const char *pathname, int flags, va_list ap)
+{
+ int mode = 0;
+ int fd;
+
+ swrap_bind_symbol_all();
+
+ swrap_inject_o_largefile(&flags);
+
+ if (flags & O_CREAT) {
+ mode = va_arg(ap, int);
+ }
+ fd = swrap.libc.symbols._libc_openat64.f(dirfd,
+ pathname,
+ flags,
+ (mode_t)mode);
+
+ return fd;
+}
+#endif /* HAVE_OPENAT64 */
+
static int libc_vopenat(int dirfd, const char *path, int flags, va_list ap)
{
int mode = 0;
@@ -1401,6 +1463,9 @@ static void __swrap_bind_symbol_all_once(void)
swrap_bind_symbol_libc(dup);
swrap_bind_symbol_libc(dup2);
swrap_bind_symbol_libc(fcntl);
+#ifdef HAVE_FCNTL64
+ swrap_bind_symbol_libc(fcntl64);
+#endif
swrap_bind_symbol_libc(fopen);
#ifdef HAVE_FOPEN64
swrap_bind_symbol_libc(fopen64);
@@ -1416,6 +1481,9 @@ static void __swrap_bind_symbol_all_once(void)
swrap_bind_symbol_libc(open);
#ifdef HAVE_OPEN64
swrap_bind_symbol_libc(open64);
+#endif
+#ifdef HAVE_OPENAT64
+ swrap_bind_symbol_libc(openat64);
#endif
swrap_bind_symbol_libc(openat);
swrap_bind_symbol_libsocket(pipe);
@@ -4568,6 +4636,7 @@ static FILE *swrap_fopen(const char *name, const char *mode)
return fp;
}
+#undef fopen /* Needed for LFS handling */
FILE *fopen(const char *name, const char *mode)
{
return swrap_fopen(name, mode);
@@ -4619,6 +4688,7 @@ static int swrap_vopen(const char *pathname, int flags, va_list ap)
return ret;
}
+#undef open /* Needed for LFS handling */
int open(const char *pathname, int flags, ...)
{
va_list ap;
@@ -4666,6 +4736,42 @@ int open64(const char *pathname, int flags, ...)
}
#endif /* HAVE_OPEN64 */
+/****************************************************************************
+ * OPENAT64
+ ***************************************************************************/
+
+#ifdef HAVE_OPENAT64
+static int
+swrap_vopenat64(int dirfd, const char *pathname, int flags, va_list ap)
+{
+ int ret;
+
+ ret = libc_vopenat64(dirfd, pathname, flags, ap);
+ if (ret != -1) {
+ /*
+ * There are methods for closing descriptors (libc-internal code
+ * paths, direct syscalls) which close descriptors in ways that
+ * we can't intercept, so try to recover when we notice that
+ * that's happened
+ */
+ swrap_remove_stale(ret);
+ }
+ return ret;
+}
+
+int openat64(int dirfd, const char *pathname, int flags, ...)
+{
+ va_list ap;
+ int fd;
+
+ va_start(ap, flags);
+ fd = swrap_vopenat64(dirfd, pathname, flags, ap);
+ va_end(ap);
+
+ return fd;
+}
+#endif /* HAVE_OPENAT64 */
+
/****************************************************************************
* OPENAT
***************************************************************************/
@@ -4688,6 +4794,7 @@ static int swrap_vopenat(int dirfd, const char *path, int flags, va_list ap)
return ret;
}
+#undef openat /* Needed for LFS handling */
int openat(int dirfd, const char *path, int flags, ...)
{
va_list ap;
@@ -8412,6 +8519,7 @@ static int swrap_vfcntl(int fd, int cmd, va_list va)
return rc;
}
+#undef fcntl /* Needed for LFS handling */
int fcntl(int fd, int cmd, ...)
{
va_list va;
@@ -8426,6 +8534,80 @@ int fcntl(int fd, int cmd, ...)
return rc;
}
+/****************************
+ * FCNTL64
+ ***************************/
+
+#ifdef HAVE_FCNTL64
+static int swrap_vfcntl64(int fd, int cmd, va_list va)
+{
+ struct socket_info *si;
+ int rc, dup_fd, idx;
+
+ idx = find_socket_info_index(fd);
+ if (idx == -1) {
+ return libc_vfcntl64(fd, cmd, va);
+ }
+
+ si = swrap_get_socket_info(idx);
+
+ switch (cmd) {
+ case F_DUPFD:
+ dup_fd = libc_vfcntl64(fd, cmd, va);
+ if (dup_fd == -1) {
+ int saved_errno = errno;
+ errno = saved_errno;
+ return -1;
+ }
+
+ /* Make sure we don't have an entry for the fd */
+ swrap_remove_stale(dup_fd);
+
+ if ((size_t)dup_fd >= socket_fds_max) {
+ SWRAP_LOG(SWRAP_LOG_ERROR,
+ "The max socket index limit of %zu has been reached, "
+ "trying to add %d",
+ socket_fds_max,
+ dup_fd);
+ libc_close(dup_fd);
+ errno = EMFILE;
+ return -1;
+ }
+
+ SWRAP_LOCK_SI(si);
+
+ swrap_inc_refcount(si);
+
+ SWRAP_UNLOCK_SI(si);
+
+
+ set_socket_info_index(dup_fd, idx);
+
+ rc = dup_fd;
+ break;
+ default:
+ rc = libc_vfcntl64(fd, cmd, va);
+ break;
+ }
+
+ return rc;
+}
+
+int fcntl64(int fd, int cmd, ...)
+{
+ va_list va;
+ int rc;
+
+ va_start(va, cmd);
+
+ rc = swrap_vfcntl64(fd, cmd, va);
+
+ va_end(va);
+
+ return rc;
+}
+#endif
+
/****************************
* EVENTFD
***************************/
diff --git a/third_party/socket_wrapper/wscript b/third_party/socket_wrapper/wscript
index bc5083847dc..fdd09f24ce9 100644
--- a/third_party/socket_wrapper/wscript
+++ b/third_party/socket_wrapper/wscript
@@ -2,7 +2,8 @@
import os
-VERSION="1.4.0"
+VERSION = "1.4.2"
+
def configure(conf):
if conf.CHECK_SOCKET_WRAPPER():
@@ -55,6 +56,10 @@ def configure(conf):
conf.CHECK_FUNCS('accept4')
conf.CHECK_FUNCS('sendmmsg recvmmsg')
conf.CHECK_FUNCS('__close_nocancel')
+ conf.CHECK_FUNCS('openat64')
+ conf.CHECK_FUNCS('fopen64')
+ conf.CHECK_FUNCS('open64')
+ conf.CHECK_FUNCS('fcntl64')
conf.CHECK_FUNCS_IN('bind',
'socket',
--
Samba Shared Repository
More information about the samba-cvs
mailing list