socket_wrapper.git
3 years agodoc: Define doctype for manpage
Andreas Schneider [Tue, 2 Feb 2021 09:28:59 +0000 (10:28 +0100)]
doc: Define doctype for manpage

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agodoc: Rename socket_wrapper.1.txt to socket_wrapper.1.adoc
Andreas Schneider [Tue, 2 Feb 2021 09:26:07 +0000 (10:26 +0100)]
doc: Rename socket_wrapper.1.txt to socket_wrapper.1.adoc

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agoswrap: add basic support for fd-passing via SCM_RIGHTS
Stefan Metzmacher [Mon, 29 Jun 2020 12:10:54 +0000 (14:10 +0200)]
swrap: add basic support for fd-passing via SCM_RIGHTS

We only allow passing up to 6 fds in a single sendmsg call,
in order to keep the logic simple.

That's more than enough for Samba's use of fd-passing,
there we only pass a single fd and the fd will be
closed in the sender on success. It means it's ok
to keep the socket_info.io.pck_{snd,rcv} fields per process
and the PCAP generation will still work as expected.

If these constraints turn out to be a problem for other applications,
we need to change to a more complex design and move the socket_info array
into a shared memory file and use shared robust mutexes.

But for now we just want to support multi-channel testing in Samba.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11899

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agotests: Add test for socket_wrapper fd-passing support
Anoop C S [Thu, 23 Jul 2020 10:29:29 +0000 (15:59 +0530)]
tests: Add test for socket_wrapper fd-passing support

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: always check new fd's against socket_fds_max and use libc_close() for cleanup
Stefan Metzmacher [Tue, 30 Jun 2020 15:53:20 +0000 (17:53 +0200)]
swrap: always check new fd's against socket_fds_max and use libc_close() for cleanup

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: add const to swrap_add_socket_info()
Stefan Metzmacher [Tue, 30 Jun 2020 15:51:29 +0000 (17:51 +0200)]
swrap: add const to swrap_add_socket_info()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: let swrap_sendmsg_before_unix() create a copy of msg_tmp.msg_control
Stefan Metzmacher [Mon, 29 Jun 2020 07:39:22 +0000 (09:39 +0200)]
swrap: let swrap_sendmsg_before_unix() create a copy of msg_tmp.msg_control

With fd-passing we'll have to modify the content of it.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: add stubs for swrap_{sendmsg,recvmsg}_{before,after}_unix()
Stefan Metzmacher [Mon, 29 Jun 2020 07:27:24 +0000 (09:27 +0200)]
swrap: add stubs for swrap_{sendmsg,recvmsg}_{before,after}_unix()

In order to implement fd-passing of socket_wrapper simulated sockets
we need to modify the msghdr structures from the callers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: filter out SCM_{RIGHTS,CREDENTIALS} on inet socket
Stefan Metzmacher [Mon, 29 Jun 2020 11:07:26 +0000 (13:07 +0200)]
swrap: filter out SCM_{RIGHTS,CREDENTIALS} on inet socket

These are only valid on unix domain sockets and ignored otherwise (at
least on Linux).

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: add error checking/cleanup to swrap_sendmsg_filter_cmsghdr()
Stefan Metzmacher [Mon, 29 Jun 2020 08:12:07 +0000 (10:12 +0200)]
swrap: add error checking/cleanup to swrap_sendmsg_filter_cmsghdr()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: Fix MSGHDR check in sendmsg()
Anoop C S [Wed, 22 May 2019 05:15:37 +0000 (10:45 +0530)]
swrap: Fix MSGHDR check in sendmsg()

Check for msg_controllen and msg_control data members from msghdr
structure needs to be validated on the received omsg pointer rather
than on newly created msghdr struture inside the wrapper.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoswrap: print out SOCKET_WRAPPER_PACKAGE and SOCKET_WRAPPER_VERSION on first use
Stefan Metzmacher [Thu, 28 Jan 2021 11:40:14 +0000 (12:40 +0100)]
swrap: print out SOCKET_WRAPPER_PACKAGE and SOCKET_WRAPPER_VERSION on first use

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agosrc/socket_wrapper.c: Improve checks and debug output of socket_wrapper_dir()
Andreas Schneider [Thu, 28 Jan 2021 19:06:11 +0000 (20:06 +0100)]
src/socket_wrapper.c: Improve checks and debug output of socket_wrapper_dir()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosrc/socket_wrapper.c: fix mutex fork handling
Stefan Metzmacher [Tue, 26 Jan 2021 12:14:41 +0000 (13:14 +0100)]
src/socket_wrapper.c: fix mutex fork handling

We need to use pthread_mutex_init in the child handler...
See https://sourceware.org/bugzilla/show_bug.cgi?id=2745

Valgrind tools like helgrind and drd don't understand this
(at least in 3.15.0), they require a pthread_mutex_unlock()
in the child in order work.

Pair-Programmed-With: Andreas Schneider <asn@samba.org>

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
3 years agogitlab-ci: Add job for ThreadSanitizer
Andreas Schneider [Wed, 12 Feb 2020 09:56:13 +0000 (10:56 +0100)]
gitlab-ci: Add job for ThreadSanitizer

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agocmake: Add ThreadSanitizer compile flags
Andreas Schneider [Wed, 12 Feb 2020 09:56:13 +0000 (10:56 +0100)]
cmake: Add ThreadSanitizer compile flags

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosrc/socket_wrapper.c: always go through swrap_bind_symbol_all() protected by pthread_...
Stefan Metzmacher [Thu, 28 Jan 2021 13:31:31 +0000 (14:31 +0100)]
src/socket_wrapper.c: always go through swrap_bind_symbol_all() protected by pthread_once()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agosrc/socket_wrapper.c: split out _swrap_bind_symbol_generic()
Stefan Metzmacher [Thu, 28 Jan 2021 12:11:51 +0000 (13:11 +0100)]
src/socket_wrapper.c: split out _swrap_bind_symbol_generic()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agosrc/socket_wrapper.c: remove unused swrap_bind_symbol_libnsl()
Stefan Metzmacher [Thu, 28 Jan 2021 12:11:16 +0000 (13:11 +0100)]
src/socket_wrapper.c: remove unused swrap_bind_symbol_libnsl()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agosocket_wrapper.c/tests: fall back to pragma init/fini for constructor/destructor...
Björn Jacke [Fri, 30 Oct 2020 14:44:53 +0000 (15:44 +0100)]
socket_wrapper.c/tests: fall back to pragma init/fini for constructor/destructor if possible

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoconfigure: check for pragma init/fini for constructors/destructors
Björn Jacke [Fri, 30 Oct 2020 14:31:42 +0000 (15:31 +0100)]
configure: check for pragma init/fini for constructors/destructors

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoBump version to 1.2.5 socket_wrapper-1.2.5
Andreas Schneider [Mon, 22 Jun 2020 14:53:36 +0000 (16:53 +0200)]
Bump version to 1.2.5

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosocket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly
Stefan Metzmacher [Mon, 8 Jun 2020 12:21:25 +0000 (14:21 +0200)]
socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly

They are used to ask for the number of unacked bytes in the send queue,
with AF_UNIX sockets get strange result, on linux 5.3 I get more bytes
reported than I sent into the socket. All bytes reach the destination
directly, so we can just always report 0 unacked bytes.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit f317ebcdcdd626ed9e06de2eb60031306994c803)

3 years agosocket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()
Stefan Metzmacher [Mon, 8 Jun 2020 12:18:44 +0000 (14:18 +0200)]
socket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()

We should only dereference the va args when the kernel already checked
they are valid.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit c95b7cb1d7b9348472276edceff71889aa676d25)

3 years agotest_echo_tcp_socket_options.c: add tests for TCP_INFO
Stefan Metzmacher [Fri, 19 Jun 2020 18:52:23 +0000 (20:52 +0200)]
test_echo_tcp_socket_options.c: add tests for TCP_INFO

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit a37c0175492fb1b35257b785c71dea4e4f6d4750)

3 years agosocket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it
Stefan Metzmacher [Mon, 8 Jun 2020 08:32:28 +0000 (10:32 +0200)]
socket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it

This just implements a few basics, which are required by Samba.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 300de6e099ea82ee5361918de8c3abb389e0782d)

3 years agodoc: Document SOCKET_WRAPPER_DIR_ALLOW_ORIG
Martin Schwenke [Wed, 13 May 2020 23:57:24 +0000 (09:57 +1000)]
doc: Document SOCKET_WRAPPER_DIR_ALLOW_ORIG

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agoswrap: Add SOCKET_WRAPPER_DIR_ALLOW_ORIG to allow fall back
Martin Schwenke [Thu, 14 May 2020 00:01:54 +0000 (10:01 +1000)]
swrap: Add SOCKET_WRAPPER_DIR_ALLOW_ORIG to allow fall back

Instead of failing when the path returned by realpath(3) is too long,
if SOCKET_WRAPPER_DIR_ALLOW_ORIG is set then fall back to the
original value.  If this original path is too long or something else
fails then abort.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agoswrap: Abort if socket wrapper directory is too long to be usable
Martin Schwenke [Wed, 13 May 2020 03:45:02 +0000 (13:45 +1000)]
swrap: Abort if socket wrapper directory is too long to be usable

If the socket wrapper directory path is too long to allow reliable
construction of the required Unix domain socket paths then
convert_in_un_alloc() can return ENFILE if paths are truncated in
unfortunate ways.  This can be very hard to debug since, for example,
bind(2) should never return ENFILE.

Instead, abort if the path returned by realpath(3) is unusable.

The code structure is slightly weird but this accommodates an
additional change.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agoswrap: Add abstractions to construct Unix domain socket paths
Martin Schwenke [Wed, 13 May 2020 03:23:21 +0000 (13:23 +1000)]
swrap: Add abstractions to construct Unix domain socket paths

These include overflow checks but the results of the checks are not
yet used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agoswrap: Abort on failure to use SOCKET_WRAPPER_DIR
Martin Schwenke [Sat, 13 Jun 2020 10:50:42 +0000 (20:50 +1000)]
swrap: Abort on failure to use SOCKET_WRAPPER_DIR

If SOCKET_WRAPPER_DIR is set the intention is to use socket wrapper.
Returning NULL means socket wrapper is disabled.  The only sure way to
avoid running without socket wrapper is to abort.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agoRevert "socket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it"
Stefan Metzmacher [Fri, 19 Jun 2020 21:26:28 +0000 (23:26 +0200)]
Revert "socket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it"

This reverts commit 300de6e099ea82ee5361918de8c3abb389e0782d.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoRevert "test_echo_tcp_socket_options.c: add tests for TCP_INFO"
Stefan Metzmacher [Fri, 19 Jun 2020 21:26:25 +0000 (23:26 +0200)]
Revert "test_echo_tcp_socket_options.c: add tests for TCP_INFO"

This reverts commit a37c0175492fb1b35257b785c71dea4e4f6d4750.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoRevert "socket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()"
Stefan Metzmacher [Fri, 19 Jun 2020 21:26:22 +0000 (23:26 +0200)]
Revert "socket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()"

This reverts commit c95b7cb1d7b9348472276edceff71889aa676d25.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoRevert "socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE expli...
Stefan Metzmacher [Fri, 19 Jun 2020 21:25:40 +0000 (23:25 +0200)]
Revert "socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly"

This reverts commit f317ebcdcdd626ed9e06de2eb60031306994c803.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoMerge branch 'tcp_info' into 'master'
Stefan Metzmacher [Fri, 19 Jun 2020 21:07:09 +0000 (21:07 +0000)]
Merge branch 'tcp_info' into 'master'

Add support for TCP_INFO and SIOCOUTQ/TIOCOUTQ/FIONWRITE

See merge request cwrap/socket_wrapper!11

3 years agosocket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly
Stefan Metzmacher [Mon, 8 Jun 2020 12:21:25 +0000 (14:21 +0200)]
socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly

They are used to ask for the number of unacked bytes in the send queue,
with AF_UNIX sockets get strange result, on linux 5.3 I get more bytes
reported than I sent into the socket. All bytes reach the destination
directly, so we can just always report 0 unacked bytes.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agosocket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()
Stefan Metzmacher [Mon, 8 Jun 2020 12:18:44 +0000 (14:18 +0200)]
socket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()

We should only dereference the va args when the kernel already checked
they are valid.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agotest_echo_tcp_socket_options.c: add tests for TCP_INFO
Stefan Metzmacher [Fri, 19 Jun 2020 18:52:23 +0000 (20:52 +0200)]
test_echo_tcp_socket_options.c: add tests for TCP_INFO

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agosocket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it
Stefan Metzmacher [Mon, 8 Jun 2020 08:32:28 +0000 (10:32 +0200)]
socket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it

This just implements a few basics, which are required by Samba.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
4 years agotests: do not truncate pid to 16 bits
Mike Gilbert [Fri, 8 May 2020 03:28:50 +0000 (23:28 -0400)]
tests: do not truncate pid to 16 bits

On Linux, pid_t is a 32-bit type, and the kernel permits pids up to 22
bits in length.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14373

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoswrap: Remove extra new line towards end of SWRAP_LOG()
Anoop C S [Tue, 7 Apr 2020 08:53:09 +0000 (14:23 +0530)]
swrap: Remove extra new line towards end of SWRAP_LOG()

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoBump version to 1.2.4 socket_wrapper-1.2.4
Andreas Schneider [Mon, 23 Mar 2020 08:47:32 +0000 (09:47 +0100)]
Bump version to 1.2.4

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agoRename CHANGELOG
Andreas Schneider [Mon, 23 Mar 2020 08:14:06 +0000 (09:14 +0100)]
Rename CHANGELOG

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agogitlab-ci: Add ubuntu runner
Andreas Schneider [Tue, 24 Mar 2020 07:44:20 +0000 (08:44 +0100)]
gitlab-ci: Add ubuntu runner

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agogitlab-ci: Remove debian cross mips build
Andreas Schneider [Tue, 24 Mar 2020 07:54:59 +0000 (08:54 +0100)]
gitlab-ci: Remove debian cross mips build

This isn't supported by Debian anymore.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agotests: Fix a compile warning on Ubuntu
Andreas Schneider [Tue, 24 Mar 2020 07:53:55 +0000 (08:53 +0100)]
tests: Fix a compile warning on Ubuntu

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agotests: Fix a coverty warning in echo_srv
Andreas Schneider [Mon, 23 Mar 2020 08:13:20 +0000 (09:13 +0100)]
tests: Fix a coverty warning in echo_srv

CID #288875

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agoswrap: add support for SOCKET_WRAPPER_IPV4_NETWORK=10.53.57.0
Stefan Metzmacher [Wed, 23 Jan 2019 18:41:36 +0000 (19:41 +0100)]
swrap: add support for SOCKET_WRAPPER_IPV4_NETWORK=10.53.57.0

With this 10.53.57.XX/8 addresses are used instead of
127.0.0.XX/8. Note the broadcast address is 127.255.255.255
or 10.255.255.255 (and not 10.53.57.255!).

Some applications, e.g. Samba have some special behavior for
loopback addresses.

This allows more realistic tests and triggers the more common
code paths.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoswrap: implement swrap_ipv4_{net,bcast,iface}() helper functions
Stefan Metzmacher [Wed, 23 Jan 2019 18:41:36 +0000 (19:41 +0100)]
swrap: implement swrap_ipv4_{net,bcast,iface}() helper functions

This makes it easier to implement SOCKET_WRAPPER_IPV4_NETWORK in
the next step.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agodoc/socket_wrapper.1: clarify the possible values for SOCKET_WRAPPER_DEFAULT_IFACE
Stefan Metzmacher [Fri, 20 Mar 2020 09:28:04 +0000 (10:28 +0100)]
doc/socket_wrapper.1: clarify the possible values for SOCKET_WRAPPER_DEFAULT_IFACE

The valid range for <ID> starts with 1 (the default) and ends with 64.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agogitlab-ci: Whitelist metze to use the FreeBSD runner
Andreas Schneider [Sat, 21 Mar 2020 09:02:40 +0000 (10:02 +0100)]
gitlab-ci: Whitelist metze to use the FreeBSD runner

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agoswrap: provide _{socket,close,connect,...} symbols on FreeBSD
Stefan Metzmacher [Wed, 18 Mar 2020 07:55:23 +0000 (08:55 +0100)]
swrap: provide _{socket,close,connect,...} symbols on FreeBSD

Maybe that's not FreeBSD only, but at least this fixes the interaction
of resolv_wrapper and socket_wrapper on FreeBSD 12.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoswrap: detect stale fd for socket(PF_UNIX) and accept()
Stefan Metzmacher [Thu, 27 Feb 2020 16:47:35 +0000 (16:47 +0000)]
swrap: detect stale fd for socket(PF_UNIX) and accept()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoswrap: trace the SOCKET_WRAPPER_PCAP_FILE location
Stefan Metzmacher [Wed, 11 Mar 2020 16:10:05 +0000 (17:10 +0100)]
swrap: trace the SOCKET_WRAPPER_PCAP_FILE location

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoswrap: Do not leak buf in swrap_sendmsg() socket_wrapper-1.2.3
Andreas Schneider [Thu, 21 Mar 2019 13:59:30 +0000 (14:59 +0100)]
swrap: Do not leak buf in swrap_sendmsg()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoBump version to 1.2.3
Andreas Schneider [Thu, 21 Mar 2019 13:18:12 +0000 (14:18 +0100)]
Bump version to 1.2.3

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Add missing NULL checks to socket_wrapper_dir()
Andreas Schneider [Thu, 21 Mar 2019 13:09:37 +0000 (14:09 +0100)]
swrap: Add missing NULL checks to socket_wrapper_dir()

This return either malloc'ed memory or NULL. Make sure there is no
problem.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Print a warning if SOCKET_WRAPPER_DIR is not set
Andreas Schneider [Thu, 21 Mar 2019 13:09:19 +0000 (14:09 +0100)]
swrap: Print a warning if SOCKET_WRAPPER_DIR is not set

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoBump version to 1.2.2 socket_wrapper-1.2.2
Andreas Schneider [Thu, 21 Mar 2019 07:47:24 +0000 (08:47 +0100)]
Bump version to 1.2.2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Add paranoia NULL checks
Andreas Schneider [Fri, 15 Mar 2019 13:59:14 +0000 (14:59 +0100)]
swrap: Add paranoia NULL checks

csbuild complains about missing NULL checks here.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Fix strict aliasing issues in swrap_pcap_packet_init()
Andreas Schneider [Thu, 28 Feb 2019 12:00:40 +0000 (13:00 +0100)]
swrap: Fix strict aliasing issues in swrap_pcap_packet_init()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Fix "Value stored never used" warning
Anoop C S [Fri, 15 Mar 2019 13:18:40 +0000 (18:48 +0530)]
swrap: Fix "Value stored never used" warning

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Fix typo in echo_srv help
Andreas Schneider [Thu, 28 Feb 2019 12:02:35 +0000 (13:02 +0100)]
tests: Fix typo in echo_srv help

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agodoc: Fix some typos in the manpage
Andreas Schneider [Thu, 28 Feb 2019 12:02:08 +0000 (13:02 +0100)]
doc: Fix some typos in the manpage

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Do not use FALL_THROUGH for empty case statements
Amitay Isaacs [Thu, 21 Feb 2019 03:04:21 +0000 (14:04 +1100)]
swrap: Do not use FALL_THROUGH for empty case statements

Signed-off-by: Amitay Isaacs <amitay@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoREADME: Create a markdown file
Andreas Schneider [Tue, 19 Feb 2019 15:18:10 +0000 (16:18 +0100)]
README: Create a markdown file

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 years agogitlab-ci: Check last 20 commits on force push
Andreas Schneider [Tue, 19 Feb 2019 15:10:16 +0000 (16:10 +0100)]
gitlab-ci: Check last 20 commits on force push

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 years agocmake: Remove unused config.h variables
Andreas Schneider [Wed, 20 Feb 2019 09:34:04 +0000 (10:34 +0100)]
cmake: Remove unused config.h variables

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 years agocmake: Use GNUInstallDirs
Andreas Schneider [Fri, 15 Feb 2019 12:09:28 +0000 (13:09 +0100)]
cmake: Use GNUInstallDirs

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 years agoswrap: Fix a TODO
Anoop C S [Thu, 6 Dec 2018 05:46:15 +0000 (11:16 +0530)]
swrap: Fix a TODO

Use realpath(3) instead of strncmp(3)

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoRemove thread-safety task from TODO
Anoop C S [Thu, 6 Dec 2018 05:45:46 +0000 (11:15 +0530)]
Remove thread-safety task from TODO

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agocmake: Disable deep binding for helgrind
Andreas Schneider [Wed, 28 Nov 2018 08:23:52 +0000 (09:23 +0100)]
cmake: Disable deep binding for helgrind

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Add env variable to disable deep binding
Andreas Schneider [Wed, 28 Nov 2018 08:20:58 +0000 (09:20 +0100)]
swrap: Add env variable to disable deep binding

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Use #ifdef instead of #if for config.h definitions
Andreas Schneider [Tue, 20 Nov 2018 13:16:17 +0000 (14:16 +0100)]
swrap: Use #ifdef instead of #if for config.h definitions

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agoswrap: Add an overflow check
Volker Lendecke [Sat, 29 Dec 2018 19:20:13 +0000 (20:20 +0100)]
swrap: Add an overflow check

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoBump version to 1.2.1 socket_wrapper-1.2.1
Andreas Schneider [Wed, 14 Nov 2018 07:04:42 +0000 (08:04 +0100)]
Bump version to 1.2.1

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Karolin Seeger <kseeger@samba.org>
5 years agoswrap: Do not log if we are over the limit in find_socket_info_index()
Andreas Schneider [Tue, 13 Nov 2018 17:44:39 +0000 (18:44 +0100)]
swrap: Do not log if we are over the limit in find_socket_info_index()

There are applications which do:

    for (fd = 0; fd <= getdtablesize(); fd++) {
        close(fd)
    };

This produced millions of error messsages.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Also log the fd in swrap_socket()
Andreas Schneider [Tue, 13 Nov 2018 17:18:22 +0000 (18:18 +0100)]
swrap: Also log the fd in swrap_socket()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Fix comparison of different signedness
Andreas Schneider [Tue, 13 Nov 2018 13:28:17 +0000 (14:28 +0100)]
swrap: Fix comparison of different signedness

Found by csbuild.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoBump version to 1.2.0 socket_wrapper-1.2.0
Andreas Schneider [Mon, 12 Nov 2018 10:14:20 +0000 (11:14 +0100)]
Bump version to 1.2.0

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Also log the process name
Andreas Schneider [Mon, 12 Nov 2018 14:22:35 +0000 (15:22 +0100)]
swrap: Also log the process name

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Better handling for default values in socket_wrapper_max_sockets()
Andreas Schneider [Tue, 13 Nov 2018 07:31:43 +0000 (08:31 +0100)]
swrap: Better handling for default values in socket_wrapper_max_sockets()

Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Always allocate the socket fd array to the maximum
Andreas Schneider [Mon, 12 Nov 2018 16:34:08 +0000 (17:34 +0100)]
swrap: Always allocate the socket fd array to the maximum

This will allow that we can deal with duplicates if the default value is
used.

Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Rename global variable for max sockets
Andreas Schneider [Mon, 12 Nov 2018 16:00:09 +0000 (17:00 +0100)]
swrap: Rename global variable for max sockets

We also need a mutex to protect access to it.

Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Enable threaded test cases on FreeBSD
Anoop C S [Sat, 10 Nov 2018 05:27:27 +0000 (10:57 +0530)]
tests: Enable threaded test cases on FreeBSD

It was previously judged as a bug which now turned to be due to
wrong backlog count set in echo_srv while listening on socket.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Increase backlog count for listen() in echo_srv
Anoop C S [Sat, 10 Nov 2018 05:26:24 +0000 (10:56 +0530)]
tests: Increase backlog count for listen() in echo_srv

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agogitlab-ci: Add csbuild
Andreas Schneider [Wed, 7 Nov 2018 07:31:50 +0000 (08:31 +0100)]
gitlab-ci: Add csbuild

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Protect IPv6 in st_echo_tcp_get_peer_sock_name
Andreas Schneider [Wed, 7 Nov 2018 08:05:30 +0000 (09:05 +0100)]
tests: Protect IPv6 in st_echo_tcp_get_peer_sock_name

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agocmake: SWRAP_REQUIRED_LIBRARIES should be a list
Andreas Schneider [Wed, 7 Nov 2018 08:02:35 +0000 (09:02 +0100)]
cmake: SWRAP_REQUIRED_LIBRARIES should be a list

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agocmake: Set LINK_FLAGS for echo_srv
Andreas Schneider [Wed, 7 Nov 2018 08:14:40 +0000 (09:14 +0100)]
cmake: Set LINK_FLAGS for echo_srv

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agocmake: Set LINK_FLAGS for socket_wrapper
Andreas Schneider [Wed, 7 Nov 2018 08:13:26 +0000 (09:13 +0100)]
cmake: Set LINK_FLAGS for socket_wrapper

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agocmake: Only set default flags if they have been detected
Andreas Schneider [Wed, 7 Nov 2018 08:25:54 +0000 (09:25 +0100)]
cmake: Only set default flags if they have been detected

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agocmake: Disable stack protector on Solaris
Andreas Schneider [Wed, 7 Nov 2018 08:27:38 +0000 (09:27 +0100)]
cmake: Disable stack protector on Solaris

They don't work.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agogitlab-ci: Enable freebsd runner
Andreas Schneider [Tue, 30 Oct 2018 12:01:27 +0000 (13:01 +0100)]
gitlab-ci: Enable freebsd runner

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Disable failing tests as on FreeBSD
Andreas Schneider [Tue, 30 Oct 2018 12:00:51 +0000 (13:00 +0100)]
tests: Disable failing tests as on FreeBSD

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agocmake: Create a list with required libraries
Andreas Schneider [Wed, 31 Oct 2018 07:07:17 +0000 (08:07 +0100)]
cmake: Create a list with required libraries

This should fix the build on OmniOS.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Protect IPv6 function in setup_echo_srv_tcp_ipv6
Andreas Schneider [Mon, 5 Nov 2018 07:29:25 +0000 (08:29 +0100)]
tests: Protect IPv6 function in setup_echo_srv_tcp_ipv6

Fixes the build on OmniOS.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotests: Protect IPv6 case in echo_srv
Andreas Schneider [Wed, 31 Oct 2018 07:04:03 +0000 (08:04 +0100)]
tests: Protect IPv6 case in echo_srv

This fixes the build on OmniOS.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoswrap: Protect IPv6 case in swrap_socket()
Andreas Schneider [Wed, 31 Oct 2018 07:02:25 +0000 (08:02 +0100)]
swrap: Protect IPv6 case in swrap_socket()

Fixes the build on OmniOS

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>