Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package socket_wrapper for openSUSE:Factory checked in at 2023-07-07 15:46:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/socket_wrapper (Old) and /work/SRC/openSUSE:Factory/.socket_wrapper.new.23466 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "socket_wrapper" Fri Jul 7 15:46:00 2023 rev:23 rq:1097147 version:1.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/socket_wrapper/socket_wrapper.changes 2023-06-29 17:27:44.714054368 +0200 +++ /work/SRC/openSUSE:Factory/.socket_wrapper.new.23466/socket_wrapper.changes 2023-07-07 15:46:01.891735288 +0200 @@ -1,0 +2,6 @@ +Thu Jun 29 12:47:01 UTC 2023 - Andreas Schneider <[email protected]> + +- Update to version 1.4.2 + * Fix LFS issues on 32bit platforms + +------------------------------------------------------------------- Old: ---- socket_wrapper-1.4.1.tar.gz socket_wrapper-1.4.1.tar.gz.asc New: ---- socket_wrapper-1.4.2.tar.gz socket_wrapper-1.4.2.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ socket_wrapper.spec ++++++ --- /var/tmp/diff_new_pack.fGycla/_old 2023-07-07 15:46:02.767740506 +0200 +++ /var/tmp/diff_new_pack.fGycla/_new 2023-07-07 15:46:02.771740530 +0200 @@ -24,7 +24,7 @@ ############################# NOTE ################################## Name: socket_wrapper -Version: 1.4.1 +Version: 1.4.2 Release: 0 Summary: A library passing all socket communications through Unix sockets License: BSD-3-Clause ++++++ socket_wrapper-1.4.1.tar.gz -> socket_wrapper-1.4.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/.gitlab-ci.yml new/socket_wrapper-1.4.2/.gitlab-ci.yml --- old/socket_wrapper-1.4.1/.gitlab-ci.yml 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/.gitlab-ci.yml 2023-06-29 14:45:12.000000000 +0200 @@ -6,6 +6,7 @@ TUMBLEWEED_BUILD: buildenv-tumbleweed MINGW_BUILD: buildenv-mingw UBUNTU_BUILD: buildenv-ubuntu + UBUNTU32_BUILD: buildenv-ubuntu32 stages: - build @@ -295,6 +296,25 @@ script: - mkdir -p obj && cd obj && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DPICKY_DEVELOPER=ON + -DUNIT_TESTING=ON .. && + make -j$(nproc) && ctest --output-on-failure + tags: + - shared + except: + - tags + artifacts: + expire_in: 1 week + when: on_failure + paths: + - obj/ + +ubuntu/x86: + stage: test + image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$UBUNTU32_BUILD + script: + - mkdir -p obj && cd obj && cmake + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON .. && make -j$(nproc) && ctest --output-on-failure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/CHANGELOG new/socket_wrapper-1.4.2/CHANGELOG --- old/socket_wrapper-1.4.1/CHANGELOG 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/CHANGELOG 2023-06-29 14:45:12.000000000 +0200 @@ -1,6 +1,9 @@ CHANGELOG ========= +version 1.4.2 (released 2023-06-29) + * Fixed LFS issues on 32bit platforms + version 1.4.1 (released 2023-06-21) * Fixed issue with fnctl() on 32bit * Added openat64() to detect stale fds diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/CMakeLists.txt new/socket_wrapper-1.4.2/CMakeLists.txt --- old/socket_wrapper-1.4.1/CMakeLists.txt 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/CMakeLists.txt 2023-06-29 14:45:12.000000000 +0200 @@ -11,7 +11,7 @@ include(DefineCMakeDefaults) include(DefineCompilerFlags) -project(socket_wrapper VERSION 1.4.1 LANGUAGES C) +project(socket_wrapper VERSION 1.4.2 LANGUAGES C) # global needed variables set(APPLICATION_NAME ${PROJECT_NAME}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/config.h.cmake new/socket_wrapper-1.4.2/config.h.cmake --- old/socket_wrapper-1.4.1/config.h.cmake 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/config.h.cmake 2023-06-29 14:45:12.000000000 +0200 @@ -45,6 +45,7 @@ #cmakedefine HAVE_OPEN64 1 #cmakedefine HAVE_OPENAT64 1 #cmakedefine HAVE_FOPEN64 1 +#cmakedefine HAVE_FCNTL64 1 #cmakedefine HAVE_GETPROGNAME 1 #cmakedefine HAVE_GETEXECNAME 1 #cmakedefine HAVE_PLEDGE 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/src/socket_wrapper.c new/socket_wrapper-1.4.2/src/socket_wrapper.c --- old/socket_wrapper-1.4.1/src/socket_wrapper.c 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/src/socket_wrapper.c 2023-06-29 14:45:12.000000000 +0200 @@ -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_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); @@ -614,10 +627,9 @@ SWRAP_SYMBOL_ENTRY(connect); SWRAP_SYMBOL_ENTRY(dup); SWRAP_SYMBOL_ENTRY(dup2); + SWRAP_SYMBOL_ENTRY(fcntl); #ifdef HAVE_FCNTL64 SWRAP_SYMBOL_ENTRY(fcntl64); -#else - SWRAP_SYMBOL_ENTRY(fcntl); #endif SWRAP_SYMBOL_ENTRY(fopen); #ifdef HAVE_FOPEN64 @@ -988,27 +1000,27 @@ arg = va_arg(ap, void *); - /* - * If fcntl64 exists then this is a system were fcntl is - * renamed (including when building this file), and so we must - * assume that the binary under test was built with - * -D_FILE_OFFSET_BITS=64 and pass on to fcntl64. - * - * If we are wrong, then fcntl is unwrapped, but while that is - * not ideal, is is also unlikely. - * - * In any case, it is always wrong to map fcntl64() to fcntl() - * as this will cause a thunk from struct flock -> flock64 - * that the caller had already prepared for. - */ + rc = swrap.libc.symbols._libc_fcntl.f(fd, cmd, arg); + + 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); -#else - rc = swrap.libc.symbols._libc_fcntl.f(fd, cmd, arg); -#endif return rc; } +#endif static int libc_getpeername(int sockfd, struct sockaddr *addr, @@ -1450,10 +1462,9 @@ swrap_bind_symbol_libsocket(connect); swrap_bind_symbol_libc(dup); swrap_bind_symbol_libc(dup2); + swrap_bind_symbol_libc(fcntl); #ifdef HAVE_FCNTL64 swrap_bind_symbol_libc(fcntl64); -#else - swrap_bind_symbol_libc(fcntl); #endif swrap_bind_symbol_libc(fopen); #ifdef HAVE_FOPEN64 @@ -4625,6 +4636,7 @@ return fp; } +#undef fopen /* Needed for LFS handling */ FILE *fopen(const char *name, const char *mode) { return swrap_fopen(name, mode); @@ -4676,6 +4688,7 @@ return ret; } +#undef open /* Needed for LFS handling */ int open(const char *pathname, int flags, ...) { va_list ap; @@ -4781,6 +4794,7 @@ return ret; } +#undef openat /* Needed for LFS handling */ int openat(int dirfd, const char *path, int flags, ...) { va_list ap; @@ -8505,6 +8519,7 @@ return rc; } +#undef fcntl /* Needed for LFS handling */ int fcntl(int fd, int cmd, ...) { va_list va; @@ -8520,6 +8535,80 @@ } /**************************** + * 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/tests/CMakeLists.txt new/socket_wrapper-1.4.2/tests/CMakeLists.txt --- old/socket_wrapper-1.4.1/tests/CMakeLists.txt 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/tests/CMakeLists.txt 2023-06-29 14:45:12.000000000 +0200 @@ -71,7 +71,6 @@ test_echo_udp_sendto_recvfrom test_echo_udp_send_recv test_echo_udp_sendmsg_recvmsg - test_swrap_unit test_max_sockets test_public_functions test_close_failure @@ -128,8 +127,16 @@ endfunction() if (CMAKE_SIZEOF_VOID_P EQUAL 4) - message(STATUS "Enabling large file support for tests") - set(LFS_CFLAGS "-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64") + execute_process( + COMMAND getconf LFS_CFLAGS + OUTPUT_VARIABLE GETCONF_LFS_CFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + # Create a list from the string + set(LFS_CFLAGS) + if (GETCONF_LFS_CFLAGS) + string(REPLACE " " ";" LFS_CFLAGS ${GETCONF_LFS_CFLAGS}) + endif() + message(STATUS "Enabling large file support for tests: ${LFS_CFLAGS}") endif() foreach(_SWRAP_TEST ${SWRAP_TESTS}) @@ -167,6 +174,14 @@ endif() endif() +# test_swrap_unit (don't use LFS) +add_cmocka_test(test_swrap_unit + SOURCES test_swrap_unit.c + COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} -D_GNU_SOURCE + LINK_LIBRARIES ${TORTURE_LIBRARY} socket_wrapper_noop + LINK_OPTIONS ${DEFAULT_LINK_FLAGS}) +add_cmocka_test_environment(test_swrap_unit) + # test_fork_pthread add_library(thread_deadlock SHARED thread_deadlock.c) target_link_libraries(thread_deadlock ${CMAKE_THREAD_LIBS_INIT}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socket_wrapper-1.4.1/tests/test_fcntl_lock.c new/socket_wrapper-1.4.2/tests/test_fcntl_lock.c --- old/socket_wrapper-1.4.1/tests/test_fcntl_lock.c 2023-06-21 12:27:11.000000000 +0200 +++ new/socket_wrapper-1.4.2/tests/test_fcntl_lock.c 2023-06-29 14:45:12.000000000 +0200 @@ -49,34 +49,56 @@ static void test_fcntl_lock(void **state) { char file[PATH_MAX]; - int fd, rc; - struct flock lock; + char buf[16]; + int fd, rc, len; char *s = (char *)*state; + struct flock lock = { + .l_type = F_WRLCK, + .l_whence = SEEK_SET, + .l_start = 0, + .l_len = 1, + }; int cmd = F_SETLK; -#ifdef F_SETLK64 - cmd = F_SETLK64; -#endif + +/* Prefer OFD locks on Linux with _GNU_SOURCE set */ #ifdef F_OFD_SETLK - cmd = F_OFD_SETLK; + if (sizeof(lock) >= 24) { + cmd = F_OFD_SETLK; + } +#endif + + printf("sizeof(lock)=%zu\n", sizeof(lock)); +#ifdef __USE_LARGEFILE64 + printf("__USE_LARGEFILE64\n"); +#endif +#ifdef __USE_FILE_OFFSET64 + printf("__USE_FILE_OFFSET64\n"); #endif rc = snprintf(file, sizeof(file), "%s/file", s); assert_in_range(rc, 0, PATH_MAX); - fd = open(file, O_CREAT, 0600); + fd = open(file, O_RDWR|O_CREAT, 0600); assert_return_code(fd, errno); - lock.l_type = F_RDLCK; - lock.l_whence = SEEK_SET; - lock.l_start = 0; - lock.l_len = 4; - lock.l_pid = 0; + rc = fcntl(fd, cmd, &lock); + assert_return_code(rc, errno); + + len = snprintf(buf, sizeof(buf), "fd=%d\n", fd); + assert_in_range(len, 0, sizeof(buf)); + + rc = write(fd, buf, len); + assert_return_code(rc, errno); + lock.l_type = F_UNLCK; rc = fcntl(fd, cmd, &lock); assert_return_code(rc, errno); rc = unlink(file); assert_return_code(rc, errno); + + rc = close(fd); + assert_return_code(rc, errno); }
