summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* swrap: set errno to ENFILE if there is no more free socket_infoMichael Adam2018-05-022-4/+3
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: New helper functions to treat next_freeMichael Adam2018-05-021-10/+20
| | | | | | | | | | - swrap_get_next_free - swrap_set_next_free to avoid accessing socket_info.next_free directly Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Use helper functions to manage refcountAnoop C S2018-05-021-9/+24
| | | | | | | | | - swrap_get_refcount - swrap_alter_refcount Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Use helper function swrap_get_socket_infoAnoop C S2018-05-021-12/+20
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Make early-libc-out more obvious by removing elseMichael Adam2018-05-021-1/+3
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* tests: Increase wait time for setup and teardown to 5msAndreas Schneider2018-05-021-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* tests: Remove extra test by moving getsockname() to anotherAnoop C S2018-03-263-70/+2
| | | | | | | | | | | | | | test_echo_tcp_socket currently tests socket() and getsockname() network calls. The test name was misleading as it does not require echo server to be setup. Moreover it failed to create socket_wrapper directory which is the pre-requisite for testing with libsocket_wrapper. Therefore it is better to integrate getsockname() test into existing test_tcp_listen test and remove useless test_echo_tcp_socket Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlet <abartlet@samba.org>
* cmake: Fix configure check for fall-through attributeAndreas Schneider2018-03-221-13/+4
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Fix checks for attributesAndreas Schneider2018-02-221-5/+11
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Avoid double semicolons in the codeAndreas Schneider2018-02-201-1/+1
| | | | | | | | Compilers that don't support fallthrough will end up with an empty FALL_THROUGH define and just see a semicolon. The probably will warn that there are double semicolons in the code. Signed-off-by: Andreas Schneider <asn@samba.org>
* Bump version to 1.1.9socket_wrapper-1.1.9Andreas Schneider2017-12-042-2/+5
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Add a thread deadlock reproducerAndreas Schneider2017-12-043-1/+175
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Avoid symbol binding deadlocks during forkAndreas Schneider2017-12-041-15/+21
| | | | | | | | | | | | | | | | | | | | | | | If there is a signal handler defined, e.g. for SIGCHILD and this signal handler is called during pthread_atfork() has just locked all mutexes and we want to check if a symbol is bound, we end up in a deadlock. (gdb) bt 0 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 1 0x00007fe48837aef5 in __GI___pthread_mutex_lock (mutex=0x7fe4889a71c0 <libc_symbol_binding_mutex>) at ../nptl/pthread_mutex_lock.c:80 2 0x00007fe48879b2f1 in libc_write (fd=14, buf=0x7ffdad6436e8, count=8) at /home/asn/workspace/projects/socket_wrapper/src/socket_wrapper.c:1070 3 0x00007fe4887a21cb in swrap_write (s=14, buf=0x7ffdad6436e8, len=8) at /home/asn/workspace/projects/socket_wrapper/src/socket_wrapper.c:5137 4 0x00007fe4887a2359 in write (s=14, buf=0x7ffdad6436e8, len=8) at /home/asn/workspace/projects/socket_wrapper/src/socket_wrapper.c:5171 5 0x00007fe48713e5f2 in tevent_common_wakeup_fd (fd=14) at ../lib/tevent/tevent.c:959 6 0x00007fe48713e61f in tevent_common_wakeup (ev=ev@entry=0x55d04922e280) at ../lib/tevent/tevent.c:975 7 0x00007fe487141d38 in tevent_common_signal_handler (signum=<optimized out>) at ../lib/tevent/tevent_signal.c:109 8 <signal handler called> 9 0x00007fe4844de081 in __libc_fork () at ../sysdeps/nptl/fork.c:135 10 0x000055d047e8ddb3 in smbd_accept_connection (ev=0x55d04922e280, fde=<optimized out>, flags=<optimized out>, private_data=<optimized out>) at ../source3/smbd/server.c:992 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Bind all symbols during prepareAndreas Schneider2017-12-041-7/+72
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Fix sa_socklen for sockaddr_inAndreas Schneider2017-12-041-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Whitespace fixesAndreas Schneider2017-12-041-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* Bump version to 1.1.8socket_wrapper-1.1.8Andreas Schneider2017-10-132-2/+12
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Fix prototype of open[64] to prevent segfault on ppc64leAndreas Schneider2017-09-071-2/+2
| | | | | | | | | | The calling conventions for vaarg are different on ppc64le. The patch fixes segfaults on that platform. Thanks to Florian Weimer who helped debugging it! Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Improve argument handling for libc_vopen*()Andreas Schneider2017-09-071-10/+16
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Improve argument handling for libc_vioctl()Andreas Schneider2017-09-071-11/+3
| | | | | | | The ioctl() only takes one or no argument. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Improve argument handling for libc_fcntl()Andreas Schneider2017-09-071-11/+3
| | | | | | | fcntl() has either one or no argument. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Add a simple fnctl() testAndreas Schneider2017-09-072-0/+68
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Simplify printing different log prefixesAndreas Schneider2017-09-071-23/+18
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Do an early return if log level doesn't matchAndreas Schneider2017-09-071-0/+4
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Always enable loggingAndreas Schneider2017-09-071-7/+0
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Protect the FALL_THROUGH defineAndreas Schneider2017-07-271-5/+7
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* cmake: Replace deprecated get_target_property()Andreas Schneider2017-07-271-6/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add common exit point to swrap_setsockoptAnoop C S2017-07-271-6/+16
| | | | | | | | In preparation of thread safety. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add common exit point to swrap_getsockoptAnoop C S2017-07-271-14/+27
| | | | | | | | In preparation of thread safety. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add common exit point to swrap_connectAnoop C S2017-07-271-4/+7
| | | | | | | | In preparation of thread safety. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add common exit point to swrap_auto_bindAnoop C S2017-07-271-7/+15
| | | | | | | | In preparation for thread safety. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Fix tab vs space in swrap_auto_bindMichael Adam2017-07-271-2/+2
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Suppress intentional fall through warningAnoop C S2017-07-273-5/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -Wimplicit-fallthrough compiler flag introduced with gcc v7 results in the following warning during compilation: [ 7%] Building C object src/CMakeFiles/socket_wrapper.dir/socket_wrapper.c.o src/socket_wrapper.c: In function ‘sockaddr_convert_to_un’: src/socket_wrapper.c:1846:18: warning: this statement may fall through [-Wimplicit-fallthrough=] case AF_UNSPEC: { ^ /src/socket_wrapper.c:1866:2: note: here case AF_INET: ^~~~ Default level for -Wimplicit-fallthrough(which is 3) allows us to get rid of the above warning using specific comments made within switch cases matching the regular expressions outlined in gcc docs[1]. But for us the presence of preprocessor directives in the vicinity of such comments nullifies its effect[2]. So our best bet would be to make use of the reliable fallthrough attribute and supress such warnings in future. [1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77817 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add fopen64() on systems which provide itAndreas Schneider2017-04-061-0/+40
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* cmake: Check for fopen64() functionAndreas Schneider2017-04-062-0/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Add open64() on systems which provide itAndreas Schneider2017-04-061-0/+57
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12694 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* cmake: Check for open64() functionAndreas Schneider2017-04-062-0/+2
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12694 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* cmake: Do not check for LFS supportAndreas Schneider2017-04-061-29/+0
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12694 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Increase max wrapped interfacesAndreas Schneider2017-04-061-1/+1
| | | | | | | | We are hitting the limit of 40 interfaces with Samba. So increase it to 64. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Fix test_close_failure test caseMichael Adam2017-03-171-3/+1
| | | | | | | Found by valgrind. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: use proper blocks for early returnsMichael Adam2017-03-021-17/+51
| | | | | | | | This is better to read and might reduce the diff of later patches. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Add support for openat()Andreas Schneider2017-03-021-0/+64
|
* Increase wait time during echo_server's pid-file checkAnoop C S2017-02-271-1/+1
| | | | | | | | | | | | We used to sleep for 200 microseconds in each iteration for checking the existence of echo server's pid file which seems to be very short. In order to avoid chances of failures to detect this pid file within 100 such iterations its better to increase this wait time to 2000 microseconds. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* Avoid mutex lock wait in socket close failureAnoop C S2017-02-103-5/+52
| | | | | | | | | | | | | | | In case of absence to close a socket fd during an exit from application we try to close the same by traversing the socket_fds in swrap_destructor. But the early lock taken on libc_symbol_binding_mutex inside the destructor blocks the subsequent request for locking the same while loading libc_close within swrap_close. Also added a test case to verify this flaw in destructor. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add sanity check in socket_wrapper_max_sockets()Andreas Schneider2016-11-041-0/+7
| | | | | | | CID 153962 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* tests: Clean-up max_sockets test caseAnoop C S2016-10-271-20/+4
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Fix use-after-freeAnoop C S2016-10-251-1/+1
| | | | | | | | This was introduced by commit 9ce583b6cd6f55d473e5b54794fb06450997ebc8 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: fix SWRAP_DLIST_ADD_AFTERAnoop C S2016-10-251-1/+1
| | | | | | | | Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: fix use-after-free in swrap_remove_stale()Michael Adam2016-10-251-2/+4
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: slightly cleanup logic in swrap_closeMichael Adam2016-10-251-3/+3
| | | | | | | | | This moves the libc_close() to one central point, thereby grouping the fd-related operations together and the the socket-info related operations after that. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>