summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* 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>
* 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>
* swrap: Whitespace fixesAndreas Schneider2017-12-041-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@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>
* 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-271-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -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>
* 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>
* 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>
* 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
|
* Avoid mutex lock wait in socket close failureAnoop C S2017-02-101-4/+0
| | | | | | | | | | | | | | | 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>
* 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>
* swrap: fix use-after-free in swrap_closeMichael Adam2016-10-251-2/+4
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Fix build on SolarisAndreas Schneider2016-10-251-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Mark flags in swrap_accept4 as unusedAndreas Schneider2016-10-211-0/+4
| | | | | | | This removes a compiler warning on non-Linux systems. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Fix the build on BSD and SolarisAndreas Schneider2016-10-211-0/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Handle threads that forkAndreas Schneider2016-10-201-0/+43
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* cmake: Check for constructor attributeAndreas Schneider2016-10-201-0/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Make symbol loading thread-safeAndreas Schneider2016-10-201-3/+22
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* cmake: Link pthread library headersMichael Adam2016-10-201-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Fix strict-aliasing issues while loading symbolsAndreas Schneider2016-10-201-143/+221
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Introduce a freelist in the socket_info arrayMichael Adam2016-10-201-7/+37
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Replace linked list of socket_info with preallocated array of structuresAnoop C S2016-10-201-28/+120
| | | | | | | | 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: Optimization in (commented out) check_addr_port_in_use()Michael Adam2016-10-201-0/+6
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Improve vfcntl to add the dup'd fd after the source fdMichael Adam2016-10-201-7/+7
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Improve dup2 to add the dup'd fd after the source fdMichael Adam2016-10-201-5/+6
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Improve dup to add the dup'd fd after the source fdMichael Adam2016-10-201-5/+6
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Add SWRAP_DLIST_ADD_AFTER macroMichael Adam2016-10-201-0/+14
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>