aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2017-12-04swrap: Bind all symbols during prepareAndreas Schneider1-7/+72
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-12-04swrap: Whitespace fixesAndreas Schneider1-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-09-07swrap: Fix prototype of open[64] to prevent segfault on ppc64leAndreas Schneider1-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>
2017-09-07swrap: Improve argument handling for libc_vopen*()Andreas Schneider1-10/+16
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-09-07swrap: Improve argument handling for libc_vioctl()Andreas Schneider1-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>
2017-09-07swrap: Improve argument handling for libc_fcntl()Andreas Schneider1-11/+3
fcntl() has either one or no argument. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-09-07swrap: Simplify printing different log prefixesAndreas Schneider1-23/+18
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-09-07swrap: Do an early return if log level doesn't matchAndreas Schneider1-0/+4
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-09-07swrap: Always enable loggingAndreas Schneider1-7/+0
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-07-27swrap: Protect the FALL_THROUGH defineAndreas Schneider1-5/+7
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2017-07-27cmake: Replace deprecated get_target_property()Andreas Schneider1-6/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2017-07-27swrap: Add common exit point to swrap_setsockoptAnoop C S1-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>
2017-07-27swrap: Add common exit point to swrap_getsockoptAnoop C S1-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>
2017-07-27swrap: Add common exit point to swrap_connectAnoop C S1-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>
2017-07-27swrap: Add common exit point to swrap_auto_bindAnoop C S1-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>
2017-07-27swrap: Fix tab vs space in swrap_auto_bindMichael Adam1-2/+2
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2017-07-27swrap: Suppress intentional fall through warningAnoop C S1-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>
2017-04-06swrap: Add fopen64() on systems which provide itAndreas Schneider1-0/+40
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-04-06swrap: Add open64() on systems which provide itAndreas Schneider1-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>
2017-04-06swrap: Increase max wrapped interfacesAndreas Schneider1-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>
2017-03-02swrap: use proper blocks for early returnsMichael Adam1-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>
2017-03-02swrap: Add support for openat()Andreas Schneider1-0/+64
2017-02-10Avoid mutex lock wait in socket close failureAnoop C S1-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>
2016-11-04swrap: Add sanity check in socket_wrapper_max_sockets()Andreas Schneider1-0/+7
CID 153962 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-25swrap: Fix use-after-freeAnoop C S1-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>
2016-10-25swrap: fix SWRAP_DLIST_ADD_AFTERAnoop C S1-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>
2016-10-25swrap: fix use-after-free in swrap_remove_stale()Michael Adam1-2/+4
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-25swrap: slightly cleanup logic in swrap_closeMichael Adam1-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>
2016-10-25swrap: fix use-after-free in swrap_closeMichael Adam1-2/+4
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-25swrap: Fix build on SolarisAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-21swrap: Mark flags in swrap_accept4 as unusedAndreas Schneider1-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>
2016-10-21swrap: Fix the build on BSD and SolarisAndreas Schneider1-0/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-20swrap: Handle threads that forkAndreas Schneider1-0/+43
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-20cmake: Check for constructor attributeAndreas Schneider1-0/+6
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-20swrap: Make symbol loading thread-safeAndreas Schneider1-3/+22
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-20cmake: Link pthread library headersMichael Adam1-1/+1
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-20swrap: Fix strict-aliasing issues while loading symbolsAndreas Schneider1-143/+221
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-10-20swrap: Introduce a freelist in the socket_info arrayMichael Adam1-7/+37
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-20swrap: Replace linked list of socket_info with preallocated array of structuresAnoop C S1-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>
2016-10-20swrap: Optimization in (commented out) check_addr_port_in_use()Michael Adam1-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>
2016-10-20swrap: Improve vfcntl to add the dup'd fd after the source fdMichael Adam1-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>
2016-10-20swrap: Improve dup2 to add the dup'd fd after the source fdMichael Adam1-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>
2016-10-20swrap: Improve dup to add the dup'd fd after the source fdMichael Adam1-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>
2016-10-20swrap: Add SWRAP_DLIST_ADD_AFTER macroMichael Adam1-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>
2016-10-20swrap: Untangle socket_info_fd from socket_info structure.Anoop C S1-58/+76
This reverses the dependency of socket_info on socket_info_fd: Instead of maintaining the list of socket_info structures, and keeping a list of referencing fds (created by dup), we now maintain the list of fds with pointers to the corresponding socket_info structures, and count the references in the socket_info. This makes the treatment of the lists more obvious, especially seen in the removing part. This change is a preparatory step for implementing fd-passing in socket-wrapper. 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>
2016-08-23swrap: remove ununsed members from struct swrap.Michael Adam1-5/+0
These were used in removed swrap_init(). Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-08-23swrap: Treat the case of fd == newfd correctly in dup2()Michael Adam1-0/+10
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>
2016-08-12swrap: Delay addition of child socket_info_fd into socket_info listAnoop C S1-2/+1
In swrap_accept() we used to add new child socket_info_fd[child_fi] into newly created child socket_info struture[child_si] without considering the fact that we may return early in case of errors from subsequent calls to libc_getsockname() and sockaddr_convert_from_un() during which we free child_fi and child_si and return. So it is better to delay the addition of child_fi into child_si->fds until child_si is completely initialized. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-08-12swrap: Remove redunant check in swrap_socketAnoop C S1-4/+1
The very same check is also being made inside swrap_remove_stale(). So we can get rid of this early if condition. 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>
2016-08-12swrap: Simplify swrap_remove_stale by early returnAnoop C S1-14/+16
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>