summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* swrap: Untangle socket_info_fd from socket_info structure.Anoop C S2016-10-201-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>
* swrap: remove ununsed members from struct swrap.Michael Adam2016-08-231-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>
* swrap: Treat the case of fd == newfd correctly in dup2()Michael Adam2016-08-231-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>
* swrap: Delay addition of child socket_info_fd into socket_info listAnoop C S2016-08-121-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>
* swrap: Remove redunant check in swrap_socketAnoop C S2016-08-121-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>
* swrap: Simplify swrap_remove_stale by early returnAnoop C S2016-08-121-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>
* swrap: Fix sendto() with connected socketsRichard Sharpe2016-05-171-9/+28
| | | | | | | | | | | | | | | | | | | | | | | Let the socket wrapper code work with the net ads dns gethostbyname etc code (lib/addn/dnssock.c) which uses connect on a UDP socket before then using sendto and recvfrom. Here, we make sure we don't error out in that case. Tested by creating a test case for this and then observing that: 1. The test case works when the socket wrapper lib is not being used ie, run the test directly after defining some SHELL variables. 2. That the test case fails when run with the un modified socket wrapper code. 3. Apply this fix and observe that it runs correctly. Pair-Programmed-With: Andreas Schneider <asn@samba.org> Signed-off-by: Richard Sharpe <rsharpe@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Allow to open RAW sockets when loadedAndreas Schneider2016-05-171-0/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Add support for accept4()Andreas Schneider2016-05-031-2/+41
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* swrap: Add support for running on OpenBSDAndreas Schneider2016-05-031-0/+10
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* swrap: Fix buliding on unix systems without AF_NETLINKAndreas Schneider2016-03-021-0/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Use calloc() instead of malloc and memsetAndreas Schneider2016-02-241-6/+8
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Allow to open NETLINK sockets when loadedAndreas Schneider2016-02-241-0/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Automatically bind an ephemeral port if neededAndreas Schneider2015-11-041-0/+8
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Add a wrapper for write()Andreas Schneider2015-10-281-0/+60
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix recvmsg() with UDPAndreas Schneider2015-10-271-0/+10
| | | | | | | | | | | This worked if the unix path was bigger than sizeof(struct sockaddr_in6). With a short unix socket pathname the buffer was to small to store the address and convert_un_in() failed. Thanks to Grigorij Demidov <grigorii.demidov@nic.cz> Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix compare of signed and unsigned integer expressionsAndreas Schneider2015-10-191-2/+4
| | | | | | | | Make sure the values are compared as the same type. iov_len is size_t on Linux and int on Solaris. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Simplify cmspace calculation in swrap_sendmsg_copy_cmsg()Ralph Boehme2015-10-141-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | With cmsg->cmsg_len = CMSG_LEN(len) => CMSG_ALIGN(cmsg->cmsg_len) = CMSG_ALIGN(CMSG_LEN(len)) = CMSG_ALIGN(CMSG_ALIGN(sizeof(struct cmsghdr)) + len) = CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len) = CMSG_SPACE(len) = CMSG_SPACE(CMSG_ALIGN(sizeof(struct cmsghdr)) + len - CMSG_ALIGN(sizeof(struct cmsghdr))) = CMSG_SPACE(CMSG_LEN(len) - CMSG_ALIGN(sizeof(struct cmsghdr))) = CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) :) Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Add support for TCP_NODELAY in getsockopt()Andreas Schneider2015-10-141-0/+23
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add support for TCP_NODELAY in setsockopt()Andreas Schneider2015-10-141-0/+30
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Call dlclose() in the destructorAndreas Schneider2015-08-171-0/+7
| | | | Signed-off-by: Andreas Schneider <asn@samba.org>
* swrap: Fix signed comparsion warningsAndreas Schneider2015-08-171-2/+2
| | | | Signed-off-by: Andreas Schneider <asn@samba.org>
* swrap: Add enviornment variable to specify mtu sizeAndreas Schneider2015-08-111-12/+50
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix TCP support with sendmsg/recvmsgAndreas Schneider2015-08-111-5/+10
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Correctly update the msg_name in recvmsg()Andreas Schneider2015-08-111-13/+30
| | | | | | | This has been found while debugging nsupdate. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: If we remove the socket_info also unlink the unix socketAndreas Schneider2015-02-181-0/+3
| | | | | Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Do not leak the socket_info we just removed.Andreas Schneider2014-10-241-0/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* src: Add support for running with address sanitizer.Andreas Schneider2014-10-201-0/+8
| | | | | | | | It address sanitzer will complain about our hack with variable function attributes. This disables the checking of it. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
* swrap: Fix the loop for older gcc versions.Andreas Schneider2014-10-011-2/+8
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* swrap: Add support for eventfd with unsigned count variable.Andreas Schneider2014-10-011-0/+4
| | | | | | | The prototype in glibc 2.20.90 changed. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Add a trace message for swrap_socket().Andreas Schneider2014-10-011-0/+5
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Implement fcntl() to catch F_DUPFD.Andreas Schneider2014-10-011-1/+86
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Include the function name in the debug output.Andreas Schneider2014-10-011-11/+13
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix out of bound access.Andreas Schneider2014-09-031-1/+1
| | | | | | | CID #72659 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Silence alignment warnings.Andreas Schneider2014-09-021-16/+16
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix type punning warnings when loading functions.Andreas Schneider2014-09-021-1/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix access to struct members in log messages.Andreas Schneider2014-09-021-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix whitespace errors.Andreas Schneider2014-09-011-16/+16
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Update copyright notice.Andreas Schneider2014-09-011-3/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Wrap fopen to detect stale file descriptors.Andreas Schneider2014-09-011-0/+31
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Use swrap_address in swrap_accept().Andreas Schneider2014-09-011-28/+23
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Remove unused sockaddr_dup() function.Andreas Schneider2014-09-011-7/+0
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Use swrap_address in the socket_info struct.Andreas Schneider2014-09-011-107/+109
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Use a sockaddr_un for the unix path in socket_info.Andreas Schneider2014-09-011-5/+7
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Rename swrap_pcap_dump_packet().Andreas Schneider2014-09-011-29/+29
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Rename swrap_pcap_get_fd().Andreas Schneider2014-09-011-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Rename swrap_marshall_packet().Andreas Schneider2014-09-011-8/+13
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Rename swrap_packet_init().Andreas Schneider2014-09-011-15/+22
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Rename socket_wrapper_pcap_file().Andreas Schneider2014-09-011-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix type punning warnings.Andreas Schneider2014-09-011-75/+127
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>