[SCM] Socket Wrapper Repository - branch master updated

2015-10-14 Thread Michael Adam
The branch, master has been updated
   via  84a4e23 tests: Add test for TCP_NODELAY setsockopt()
   via  96dbeb7 tests: Add test for TCP_NODELAY getsockopt()
   via  1db6130 swrap: Add support for TCP_NODELAY in getsockopt()
   via  e9e0dac swrap: Add support for TCP_NODELAY in setsockopt()
  from  40b1926 Bump version to 1.1.4

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 84a4e23728a558984f449610b9e84933acfb0515
Author: Andreas Schneider 
Date:   Thu Oct 8 11:02:10 2015 +0200

tests: Add test for TCP_NODELAY setsockopt()

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit 96dbeb75f78665cf81a4ef8e3842e819043f8d51
Author: Andreas Schneider 
Date:   Mon Sep 14 22:07:09 2015 +0200

tests: Add test for TCP_NODELAY getsockopt()

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit 1db61302b6036bdfabf0e3a1507e0e5573a57368
Author: Andreas Schneider 
Date:   Mon Sep 14 22:06:52 2015 +0200

swrap: Add support for TCP_NODELAY in getsockopt()

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

commit e9e0dac6d719304af8174f4b9119709afe71f508
Author: Andreas Schneider 
Date:   Thu Oct 8 10:51:02 2015 +0200

swrap: Add support for TCP_NODELAY in setsockopt()

Signed-off-by: Andreas Schneider 
Reviewed-by: Michael Adam 

---

Summary of changes:
 src/socket_wrapper.c | 53 
 tests/test_echo_tcp_socket_options.c | 49 +
 2 files changed, 102 insertions(+)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 45282ed..aad5f3e 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -248,6 +248,7 @@ struct socket_info
int connected;
int defer_connect;
int pktinfo;
+   int tcp_nodelay;
 
/* The unix path so we can unlink it on close() */
struct sockaddr_un un_addr;
@@ -3350,6 +3351,29 @@ static int swrap_getsockopt(int s, int level, int 
optname,
   optval,
   optlen);
}
+   } else if (level == IPPROTO_TCP) {
+   switch (optname) {
+#ifdef TCP_NODELAY
+   case TCP_NODELAY:
+   /*
+* This enables sending packets directly out over TCP.
+* As a unix socket is doing that any way, report it as
+* enabled.
+*/
+   if (optval == NULL || optlen == NULL ||
+   *optlen < (socklen_t)sizeof(int)) {
+   errno = EINVAL;
+   return -1;
+   }
+
+   *optlen = sizeof(int);
+   *(int *)optval = si->tcp_nodelay;
+
+   return 0;
+#endif /* TCP_NODELAY */
+   default:
+   break;
+   }
}
 
errno = ENOPROTOOPT;
@@ -3388,6 +3412,35 @@ static int swrap_setsockopt(int s, int level, int 
optname,
   optname,
   optval,
   optlen);
+   } else if (level == IPPROTO_TCP) {
+   switch (optname) {
+#ifdef TCP_NODELAY
+   case TCP_NODELAY: {
+   int i;
+
+   /*
+* This enables sending packets directly out over TCP.
+* A unix socket is doing that any way.
+*/
+   if (optval == NULL || optlen == 0 ||
+   optlen < (socklen_t)sizeof(int)) {
+   errno = EINVAL;
+   return -1;
+   }
+
+   i = *discard_const_p(int, optval);
+   if (i != 0 && i != 1) {
+   errno = EINVAL;
+   return -1;
+   }
+   si->tcp_nodelay = i;
+
+   return 0;
+   }
+#endif /* TCP_NODELAY */
+   default:
+   break;
+   }
}
 
switch (si->family) {
diff --git a/tests/test_echo_tcp_socket_options.c 
b/tests/test_echo_tcp_socket_options.c
index f068fb8..dfa46fe 100644
--- a/tests/test_echo_tcp_socket_options.c
+++ b/tests/test_echo_tcp_socket_options.c
@@ -10,6 +10,7 @@
 

[SCM] Socket Wrapper Repository - branch master updated

2015-08-25 Thread Andreas Schneider
The branch, master has been updated
   via  40b1926 Bump version to 1.1.4
  from  c3c5f02 swrap: Call dlclose() in the destructor

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 40b1926e42896bb977705ed155c385b413ddd517
Author: Andreas Schneider a...@samba.org
Date:   Mon Aug 24 17:53:28 2015 +0200

Bump version to 1.1.4

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Alexander Bokovoy a...@samba.org

---

Summary of changes:
 CMakeLists.txt | 4 ++--
 ChangeLog  | 6 ++
 2 files changed, 8 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ee6daa6..5407410 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 1)
-set(APPLICATION_VERSION_PATCH 3)
+set(APPLICATION_VERSION_PATCH 4)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.1.3)
+set(LIBRARY_VERSION 0.1.4)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index c5b6019..b3509ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 ChangeLog
 ==
 
+version 1.1.4 (released 2015-08-25)
+  * Fixed handling of msg_name in recvmsg()
+  * Fixed sendmsg()/recvmsg() TCP support
+  * Fixed several compile warnings
+  * Added environment variable to change MTU
+
 version 1.1.3 (released 2015-02-23)
   * Added support for address sanitizer.
   * Fixed leaking of memory and fds of stale sockets.


-- 
Socket Wrapper Repository



[SCM] Socket Wrapper Repository - branch master updated

2015-08-17 Thread Andreas Schneider
The branch, master has been updated
   via  c3c5f02 swrap: Call dlclose() in the destructor
   via  19fd43f tests: Rename s_addr to send_addr
   via  cf8fc6d tests: Fix memset() call in new tests
   via  94e6f3b tests: Fix passing pointer of incompatible type
   via  9434cdc swrap: Fix signed comparsion warnings
  from  6ece682 swrap: Add enviornment variable to specify mtu size

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit c3c5f02b0746958845eb825620765ac741920985
Author: Andreas Schneider a...@samba.org
Date:   Mon Aug 17 12:14:44 2015 +0200

swrap: Call dlclose() in the destructor

Signed-off-by: Andreas Schneider a...@samba.org

commit 19fd43f706cd73add4c7dd23613ceccf00fc0c84
Author: Andreas Schneider a...@samba.org
Date:   Mon Aug 17 12:06:30 2015 +0200

tests: Rename s_addr to send_addr

The preprocessor on Solaris replaces s_addr with S_un.S_addr.

Signed-off-by: Andreas Schneider a...@samba.org

commit cf8fc6d9572cf7800e46e68e3d01802345a7e54b
Author: Andreas Schneider a...@samba.org
Date:   Wed Aug 12 08:48:56 2015 +0200

tests: Fix memset() call in new tests

Signed-off-by: Andreas Schneider a...@samba.org

commit 94e6f3b24ad8e21857f3062a2a21429dea31b790
Author: Andreas Schneider a...@samba.org
Date:   Wed Aug 12 08:37:39 2015 +0200

tests: Fix passing pointer of incompatible type

Signed-off-by: Andreas Schneider a...@samba.org

commit 9434cdc6747b0837551bdd341d2f9b0f5479eb07
Author: Andreas Schneider a...@samba.org
Date:   Wed Aug 12 08:37:07 2015 +0200

swrap: Fix signed comparsion warnings

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 src/socket_wrapper.c | 11 --
 tests/test_echo_tcp_connect.c|  2 +-
 tests/test_echo_tcp_get_peer_sock_name.c |  2 +-
 tests/test_echo_tcp_sendmsg_recvmsg.c| 12 +--
 tests/test_echo_tcp_socket.c |  2 +-
 tests/test_echo_udp_sendmsg_recvmsg.c| 36 
 6 files changed, 36 insertions(+), 29 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 01ab8d5..45282ed 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3799,7 +3799,7 @@ static ssize_t swrap_sendmsg_before(int fd,
msg-msg_iovlen = i;
if (msg-msg_iovlen == 0) {
*tmp_iov = msg-msg_iov[0];
-   tmp_iov-iov_len = MIN(tmp_iov-iov_len, mtu);
+   tmp_iov-iov_len = MIN(tmp_iov-iov_len, (size_t)mtu);
msg-msg_iov = tmp_iov;
msg-msg_iovlen = 1;
}
@@ -4016,7 +4016,7 @@ static int swrap_recvmsg_before(int fd,
msg-msg_iovlen = i;
if (msg-msg_iovlen == 0) {
*tmp_iov = msg-msg_iov[0];
-   tmp_iov-iov_len = MIN(tmp_iov-iov_len, mtu);
+   tmp_iov-iov_len = MIN(tmp_iov-iov_len, (size_t)mtu);
msg-msg_iov = tmp_iov;
msg-msg_iovlen = 1;
}
@@ -5131,4 +5131,11 @@ void swrap_destructor(void)
}
s = sockets;
}
+
+   if (swrap.libc_handle != NULL) {
+   dlclose(swrap.libc_handle);
+   }
+   if (swrap.libsocket_handle) {
+   dlclose(swrap.libsocket_handle);
+   }
 }
diff --git a/tests/test_echo_tcp_connect.c b/tests/test_echo_tcp_connect.c
index f97b5ac..d2020c8 100644
--- a/tests/test_echo_tcp_connect.c
+++ b/tests/test_echo_tcp_connect.c
@@ -76,7 +76,7 @@ static void test_connect_downgrade_ipv6(void **state)
assert_int_equal(rc, 1);
 
/* Connect should downgrade to IPv4 and allow the connect */
-   rc = connect(s, addr.sa.in, addr.sa_socklen);
+   rc = connect(s, addr.sa.s, addr.sa_socklen);
assert_int_equal(rc, 0);
 
close(s);
diff --git a/tests/test_echo_tcp_get_peer_sock_name.c 
b/tests/test_echo_tcp_get_peer_sock_name.c
index 9a00255..ac369dd 100644
--- a/tests/test_echo_tcp_get_peer_sock_name.c
+++ b/tests/test_echo_tcp_get_peer_sock_name.c
@@ -413,7 +413,7 @@ static void test_connect_getsockname_getpeername_len(void 
**state)
assert_int_equal(rc, 1);
 
/* Connect */
-   rc = connect(s, addr.sa.in, addr.sa_socklen);
+   rc = connect(s, addr.sa.s, addr.sa_socklen);
assert_return_code(rc, errno);
 
/* Check with len=0 */
diff --git a/tests/test_echo_tcp_sendmsg_recvmsg.c 
b/tests/test_echo_tcp_sendmsg_recvmsg.c
index 2adaa75..4f7629e 100644
--- a/tests/test_echo_tcp_sendmsg_recvmsg.c
+++ b/tests/test_echo_tcp_sendmsg_recvmsg.c
@@ -193,7 +193,7 @@ static void test_sendmsg_recvmsg_ipv6(void **state)
 
 static void 

[SCM] Socket Wrapper Repository - branch master updated

2015-08-11 Thread Andreas Schneider
The branch, master has been updated
   via  6ece682 swrap: Add enviornment variable to specify mtu size
   via  c2d26a8 tests: Add tcp sendmsg/recvmsg test
   via  32f65ea swrap: Fix TCP support with sendmsg/recvmsg
   via  2e7cda5 tests: Tests for msg_name(len) in sendmsg/revcmsg
   via  73c2168 tests: Fix testname of sendmsg tests
   via  85b7f56 swrap: Correctly update the msg_name in recvmsg()
   via  055eb78 tests: Migrate to new cmocka API
  from  00eb315 Update TODO

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 6ece682ee36794aebd08503c60ecb1797c04849f
Author: Andreas Schneider a...@samba.org
Date:   Tue Aug 11 12:11:16 2015 +0200

swrap: Add enviornment variable to specify mtu size

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit c2d26a8dbd89d3db32461061e0b33df4f3eb87a1
Author: Andreas Schneider a...@samba.org
Date:   Tue Aug 11 11:40:30 2015 +0200

tests: Add tcp sendmsg/recvmsg test

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 32f65eaa9ad699898fa274ea1f29655e6a344fb9
Author: Andreas Schneider a...@samba.org
Date:   Tue Aug 11 11:39:52 2015 +0200

swrap: Fix TCP support with sendmsg/recvmsg

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 2e7cda5246b3b7565d376e9609b0e84b3cdff1d5
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Aug 10 16:09:16 2015 +0200

tests: Tests for msg_name(len) in sendmsg/revcmsg

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 73c2168291825fcbff4a4846a395793ceac46202
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Aug 10 13:39:09 2015 +0200

tests: Fix testname of sendmsg tests

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 85b7f564bd397e82cf847607f0bcee4e35f489ac
Author: Andreas Schneider a...@samba.org
Date:   Wed Aug 5 15:02:49 2015 +0200

swrap: Correctly update the msg_name in recvmsg()

This has been found while debugging nsupdate.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 055eb78f3690008021e17da8714da9db5247308c
Author: Andreas Schneider a...@samba.org
Date:   Thu Aug 6 16:08:32 2015 +0200

tests: Migrate to new cmocka API

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 doc/socket_wrapper.1 |  11 +-
 doc/socket_wrapper.1.txt |   9 +-
 src/socket_wrapper.c | 114 ++---
 tests/CMakeLists.txt |   1 +
 tests/test_echo_tcp_bind.c   |  30 ++--
 tests/test_echo_tcp_connect.c|  18 +-
 tests/test_echo_tcp_get_peer_sock_name.c |  44 ++---
 tests/test_echo_tcp_sendmsg_recvmsg.c| 273 +++
 tests/test_echo_tcp_socket.c |   8 +-
 tests/test_echo_tcp_socket_options.c |  40 +++--
 tests/test_echo_tcp_write_read.c |  24 ++-
 tests/test_echo_tcp_writev_readv.c   |  24 ++-
 tests/test_echo_udp_send_recv.c  |  24 ++-
 tests/test_echo_udp_sendmsg_recvmsg.c| 224 -
 tests/test_echo_udp_sendto_recvfrom.c|  24 ++-
 tests/test_ioctl.c   |  18 +-
 tests/test_sendmsg_recvmsg_fd.c  |   6 +-
 17 files changed, 760 insertions(+), 132 deletions(-)
 create mode 100644 tests/test_echo_tcp_sendmsg_recvmsg.c


Changeset truncated at 500 lines:

diff --git a/doc/socket_wrapper.1 b/doc/socket_wrapper.1
index 4e0dd01..c3cf835 100644
--- a/doc/socket_wrapper.1
+++ b/doc/socket_wrapper.1
@@ -2,12 +2,12 @@
 .\ Title: socket_wrapper
 .\Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\ Generator: DocBook XSL Stylesheets v1.78.1 http://docbook.sf.net/
-.\  Date: 2014-07-09
+.\  Date: 2015-08-11
 .\Manual: \ \
 .\Source: \ \
 .\  Language: English
 .\
-.TH SOCKET_WRAPPER 1 2014\-07\-09 \ \ \ \
+.TH SOCKET_WRAPPER 1 2015\-08\-11 \ \ \ \
 .\ -
 .\ * Define some portability stuff
 .\ -
@@ -85,6 +85,13 @@ Additionally, the default interface to be used by an 
application is defined with
 When debugging, it is often interesting to investigate the network traffic 
between the client and server within your application\. If you define 
SOCKET_WRAPPER_PCAP_FILE=/path/to/file\.pcap, socket_wrapper will dump all 
your network traffic to the specified file\. After the test has 

[SCM] Socket Wrapper Repository - branch master updated

2015-07-15 Thread Andreas Schneider
The branch, master has been updated
   via  00eb315 Update TODO
  from  c12981e Regenerate manpage.

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 00eb31542d26c4f4cfb245a58795fcaf5653c953
Author: Andreas Schneider a...@samba.org
Date:   Wed Jul 15 15:18:08 2015 +0200

Update TODO

---

Summary of changes:
 TODO | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/TODO b/TODO
index fe05c75..147c166 100644
--- a/TODO
+++ b/TODO
@@ -9,13 +9,19 @@ look at the list below.
 Library:
 -
 
-* Add support for fd passing in sendmsg/recvmsg.
-  Scenario:
-  We accept a connection from a client and need to pass the fd to another
-  child we forked. socket_wrapper then needs to send the 'struct socket_info'
-  to the child first and set it up there.
-  Or do it like swrap_accept() and call getpeername() and getsockname().
-* Add support for threading.
+Goals:
+* Thread safety
+* The proposed way == - fd-passing for tcp sockets (for free)
+  Approach:
+  - tdb in small. So a db file.
+- for each socket an entry in the db file
+  (file, mmap, robust mutex. e.g. one file per local ip addr)
+- socket_info : structure in db. protected by pthread robust mutexes
+- socket_info_fd : -- pointer into mmap area of db
+- free-list
+  - fd-passing: pass index in array
+- the last element we pass is not a fd but the index number in the
+  mmaped file
 * Use realpath() in socket_wrapper_dir().
 
 Testing:


-- 
Socket Wrapper Repository



[SCM] Socket Wrapper Repository - branch master updated

2015-04-20 Thread Andreas Schneider
The branch, master has been updated
   via  c12981e Regenerate manpage.
   via  7e0af39 doc: Add a specific date to manpage
  from  a6555e4 cmake: Drop test results via https.

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit c12981efec6967480a15e24a1ee9fa188365f85e
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 20 08:58:00 2015 +0200

Regenerate manpage.

Signed-off-by: Andreas Schneider a...@samba.org

commit 7e0af39a8a2eecc89ad0db609d95d08a25707904
Author: Jelmer Vernooij jel...@samba.org
Date:   Sat Apr 18 23:58:15 2015 +

doc: Add a specific date to manpage

This makes builds for socket wrapper reproducible.

Signed-off-by: Jelmer Vernooij jel...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 doc/socket_wrapper.1 | 4 ++--
 doc/socket_wrapper.1.txt | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/doc/socket_wrapper.1 b/doc/socket_wrapper.1
index 836bde5..4e0dd01 100644
--- a/doc/socket_wrapper.1
+++ b/doc/socket_wrapper.1
@@ -2,12 +2,12 @@
 .\ Title: socket_wrapper
 .\Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\ Generator: DocBook XSL Stylesheets v1.78.1 http://docbook.sf.net/
-.\  Date: 07/09/2014
+.\  Date: 2014-07-09
 .\Manual: \ \
 .\Source: \ \
 .\  Language: English
 .\
-.TH SOCKET_WRAPPER 1 07/09/2014 \ \ \ \
+.TH SOCKET_WRAPPER 1 2014\-07\-09 \ \ \ \
 .\ -
 .\ * Define some portability stuff
 .\ -
diff --git a/doc/socket_wrapper.1.txt b/doc/socket_wrapper.1.txt
index 45b81bd..2ab330e 100644
--- a/doc/socket_wrapper.1.txt
+++ b/doc/socket_wrapper.1.txt
@@ -1,5 +1,6 @@
 socket_wrapper(1)
 =
+:revdate: 2014-07-09
 
 NAME
 


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2015-02-25 Thread Andreas Schneider
The branch, master has been updated
   via  a6555e4 cmake: Drop test results via https.
  from  43d0166 Bump version to 1.1.3

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit a6555e464f41e396977d4b3a94f2a8403b96fc33
Author: Andreas Schneider a...@samba.org
Date:   Wed Feb 25 11:11:32 2015 +0100

cmake: Drop test results via https.

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 CTestConfig.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/CTestConfig.cmake b/CTestConfig.cmake
index 3642735..3c29af3 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -3,7 +3,7 @@ set(UPDATE_TYPE true)
 set(CTEST_PROJECT_NAME socketwrapper)
 set(CTEST_NIGHTLY_START_TIME 01:00:00 UTC)
 
-set(CTEST_DROP_METHOD http)
+set(CTEST_DROP_METHOD https)
 set(CTEST_DROP_SITE mock.cryptomilk.org)
 set(CTEST_DROP_LOCATION /submit.php?project=socketwrapper)
 set(CTEST_DROP_SITE_CDASH TRUE)


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2015-02-23 Thread Andreas Schneider
The branch, master has been updated
   via  4c44ee6 swrap: If we remove the socket_info also unlink the unix 
socket
  from  a12559d torture: Increase time to wait for pid file.

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 4c44ee6bdba65d2857d83e80ffc7b6a1dd478f45
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Feb 3 17:07:18 2015 +0100

swrap: If we remove the socket_info also unlink the unix socket

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 src/socket_wrapper.c | 3 +++
 1 file changed, 3 insertions(+)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index eb1d67f..1188c4e 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1418,6 +1418,9 @@ static void swrap_remove_stale(int fd)
 
if (si-fds == NULL) {
SWRAP_DLIST_REMOVE(sockets, si);
+   if (si-un_addr.sun_path[0] != '\0') {
+   unlink(si-un_addr.sun_path);
+   }
free(si);
}
}


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2015-02-23 Thread Andreas Schneider
The branch, master has been updated
   via  43d0166 Bump version to 1.1.3
   via  d459a08 Update ChangeLog
  from  4c44ee6 swrap: If we remove the socket_info also unlink the unix 
socket

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 43d01669351e007bda10810fea675c0297b9ecd1
Author: Andreas Schneider a...@samba.org
Date:   Mon Feb 23 15:24:26 2015 +0100

Bump version to 1.1.3

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit d459a08a80b9710cf93c11d320fda8a6c0e2e31d
Author: Andreas Schneider a...@samba.org
Date:   Mon Feb 23 15:23:47 2015 +0100

Update ChangeLog

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 CMakeLists.txt | 4 ++--
 ChangeLog  | 5 +
 2 files changed, 7 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c57a62..ee6daa6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 1)
-set(APPLICATION_VERSION_PATCH 2)
+set(APPLICATION_VERSION_PATCH 3)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.1.2)
+set(LIBRARY_VERSION 0.1.3)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 052abb6..c5b6019 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.1.3 (released 2015-02-23)
+  * Added support for address sanitizer.
+  * Fixed leaking of memory and fds of stale sockets.
+  * Fixed the library loading code.
+
 version 1.1.2 (released 2014-10-01)
   * Added support for fnctl(F_DUPFD).
   * Added support for glibc 2.20.90.


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-12-16 Thread Andreas Schneider
The branch, master has been updated
   via  a12559d torture: Increase time to wait for pid file.
  from  f05cbad swrap: Do not leak the socket_info we just removed.

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit a12559d7bd6c8c4a8d836c1228949125a16350e7
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 16 15:26:32 2014 +0100

torture: Increase time to wait for pid file.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 tests/torture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/tests/torture.c b/tests/torture.c
index eab36de..821f0ab 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -188,7 +188,7 @@ static void torture_setup_echo_srv_ip(void **state,
}
 
rc = stat(s-srv_pidfile, sb);
-   usleep(50);
+   usleep(200);
} while (rc != 0);
assert_int_equal(rc, 0);
 


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-10-24 Thread Andreas Schneider
The branch, master has been updated
   via  f05cbad swrap: Do not leak the socket_info we just removed.
   via  f0606cf cmake: Treat no_sanitize_address attribute warnings as 
error.
  from  db8edc8 src: Add support for running with address sanitizer.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit f05cbad1929ad0f144834b0df444239ab0c05a21
Author: Andreas Schneider a...@samba.org
Date:   Fri Oct 24 11:22:15 2014 +0200

swrap: Do not leak the socket_info we just removed.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit f0606cf44ac93c2105296d608f5e88ec0a9ba3c9
Author: Andreas Schneider a...@samba.org
Date:   Thu Oct 23 07:23:36 2014 +0200

cmake: Treat no_sanitize_address attribute warnings as error.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 ConfigureChecks.cmake |3 +++
 src/socket_wrapper.c  |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 32cd9bb..71e5056 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -194,6 +194,8 @@ int main(void) {
 return 0;
 } HAVE_FUNCTION_ATTRIBUTE_FORMAT)
 
+# If this produces a warning treat it as error!
+set(CMAKE_REQUIRED_FLAGS -Werror)
 check_c_source_compiles(
 void test_address_sanitizer_attribute(void) 
__attribute__((no_sanitize_address));
 
@@ -205,6 +207,7 @@ void test_address_sanitizer_attribute(void)
 int main(void) {
 return 0;
 } HAVE_ADDRESS_SANITIZER_ATTRIBUTE)
+set(CMAKE_REQUIRED_FLAGS)
 
 check_library_exists(dl dlopen  HAVE_LIBDL)
 if (HAVE_LIBDL)
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 82e5737..eb1d67f 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1418,6 +1418,7 @@ static void swrap_remove_stale(int fd)
 
if (si-fds == NULL) {
SWRAP_DLIST_REMOVE(sockets, si);
+   free(si);
}
}
 }


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-10-20 Thread Andreas Schneider
The branch, master has been updated
   via  db8edc8 src: Add support for running with address sanitizer.
   via  390cfbe torture: Check the return code of kill().
  from  95c39b3 swrap: Fix the loop for older gcc versions.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit db8edc87e6a1a771336d832a6da02c4760c74100
Author: Andreas Schneider a...@samba.org
Date:   Mon Oct 20 09:13:36 2014 +0200

src: Add support for running with address sanitizer.

It address sanitzer will complain about our hack with variable function
attributes. This disables the checking of it.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Guenther Deschner g...@samba.org

commit 390cfbef05e42439f82d301752b74f8865f32225
Author: Andreas Schneider a...@samba.org
Date:   Thu Oct 2 06:28:10 2014 +0200

torture: Check the return code of kill().

CID #73654

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Guenther Deschner g...@samba.org

---

Summary of changes:
 ConfigureChecks.cmake |   11 +++
 config.h.cmake|1 +
 src/socket_wrapper.c  |8 
 tests/torture.c   |   20 
 4 files changed, 36 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index ea0a208..32cd9bb 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -194,6 +194,17 @@ int main(void) {
 return 0;
 } HAVE_FUNCTION_ATTRIBUTE_FORMAT)
 
+check_c_source_compiles(
+void test_address_sanitizer_attribute(void) 
__attribute__((no_sanitize_address));
+
+void test_address_sanitizer_attribute(void)
+{
+return;
+}
+
+int main(void) {
+return 0;
+} HAVE_ADDRESS_SANITIZER_ATTRIBUTE)
 
 check_library_exists(dl dlopen  HAVE_LIBDL)
 if (HAVE_LIBDL)
diff --git a/config.h.cmake b/config.h.cmake
index 8b66420..91e1206 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -57,6 +57,7 @@
 
 #cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_ADDRESS_SANITIZER_ATTRIBUTE 1
 #cmakedefine HAVE_SOCKADDR_STORAGE 1
 #cmakedefine HAVE_IPV6 1
 #cmakedefine HAVE_FUNCTION_ATTRIBUTE_FORMAT 1
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index b30303f..82e5737 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -100,6 +100,12 @@ enum swrap_dbglvl_e {
 #define DESTRUCTOR_ATTRIBUTE
 #endif
 
+#ifdef HAVE_ADDRESS_SANITIZER_ATTRIBUTE
+#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE __attribute__((no_sanitize_address))
+#else
+#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
+#endif
+
 #ifdef HAVE_GCC_THREAD_LOCAL_STORAGE
 # define SWRAP_THREAD __thread
 #else
@@ -598,6 +604,7 @@ static int libc_eventfd(int count, int flags)
 }
 #endif
 
+DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
 static int libc_vfcntl(int fd, int cmd, va_list ap)
 {
long int args[4];
@@ -649,6 +656,7 @@ static int libc_getsockopt(int sockfd,
return swrap.fns.libc_getsockopt(sockfd, level, optname, optval, 
optlen);
 }
 
+DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
 static int libc_vioctl(int d, unsigned long int request, va_list ap)
 {
long int args[4];
diff --git a/tests/torture.c b/tests/torture.c
index 02ddc96..eab36de 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -48,6 +48,7 @@
 #include string.h
 #include unistd.h
 #include time.h
+#include stdbool.h
 
 #define TORTURE_ECHO_SRV_IPV4 127.0.0.10
 /* socket wrapper IPv6 prefix  fd00::5357:5fxx */
@@ -259,6 +260,8 @@ void torture_teardown_echo_srv(void **state)
ssize_t rc;
pid_t pid;
int fd;
+   bool is_running = true;
+   int count;
 
/* read the pidfile */
fd = open(s-srv_pidfile, O_RDONLY);
@@ -281,11 +284,20 @@ void torture_teardown_echo_srv(void **state)
 
pid = (pid_t)(tmp  0x);
 
-   /* Make sure the daemon goes away! */
-   kill(pid, SIGTERM);
+   for (count = 0; count  10; count++) {
+   /* Make sure the daemon goes away! */
+   kill(pid, SIGTERM);
 
-   kill(pid, 0);
-   if (rc == 0) {
+   usleep(200);
+
+   rc = kill(pid, 0);
+   if (rc != 0) {
+   is_running = false;
+   break;
+   }
+   }
+
+   if (is_running) {
fprintf(stderr,
WARNING the echo server is still running!\n);
}


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-10-01 Thread Andreas Schneider
The branch, master has been updated
   via  163f089 Bump version to 1.1.2.
   via  b6e69a3 swrap: Add support for eventfd with unsigned count variable.
   via  362136b swrap: Add a trace message for swrap_socket().
   via  0456896 swrap: Implement fcntl() to catch F_DUPFD.
   via  7dad23a swrap: Include the function name in the debug output.
  from  20555bf tests: Add missing breaks in sockaddr assert functions.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 163f08939567d5f837343ca6844c7121d6fe954e
Author: Andreas Schneider a...@samba.org
Date:   Wed Oct 1 12:56:21 2014 +0200

Bump version to 1.1.2.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit b6e69a39dd211626159865f1ece4989c7552a9ee
Author: Andreas Schneider a...@samba.org
Date:   Wed Oct 1 12:51:56 2014 +0200

swrap: Add support for eventfd with unsigned count variable.

The prototype in glibc 2.20.90 changed.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 362136b89adedbf112beb354e31b0e9b763db37f
Author: Andreas Schneider a...@samba.org
Date:   Wed Oct 1 12:48:13 2014 +0200

swrap: Add a trace message for swrap_socket().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 045689644b87a3f6a3f4c2baeb70d22d3f6c441c
Author: Andreas Schneider a...@samba.org
Date:   Thu Sep 11 10:17:06 2014 +0200

swrap: Implement fcntl() to catch F_DUPFD.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 7dad23ab56c707a0c5e3780436259781375be0e0
Author: Andreas Schneider a...@samba.org
Date:   Thu Sep 11 08:30:04 2014 +0200

swrap: Include the function name in the debug output.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 CMakeLists.txt|4 +-
 ChangeLog |4 ++
 ConfigureChecks.cmake |8 +++
 config.h.cmake|1 +
 src/socket_wrapper.c  |  120 -
 5 files changed, 123 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49e47a4..4c57a62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 1)
-set(APPLICATION_VERSION_PATCH 1)
+set(APPLICATION_VERSION_PATCH 2)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.1.1)
+set(LIBRARY_VERSION 0.1.2)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index e5eabfc..052abb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==
 
+version 1.1.2 (released 2014-10-01)
+  * Added support for fnctl(F_DUPFD).
+  * Added support for glibc 2.20.90.
+
 version 1.1.1 (released 2014-06-05)
   * Disable incomplete address in use check in bind().
 
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index fb73449..ea0a208 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -119,6 +119,14 @@ check_prototype_definition(ioctl
 unistd.h;sys/ioctl.h
 HAVE_IOCTL_INT)
 
+if (HAVE_EVENTFD)
+check_prototype_definition(eventfd
+int eventfd(unsigned int count, int flags)
+-1
+sys/eventfd.h
+HAVE_EVENTFD_UNSIGNED_INT)
+endif (HAVE_EVENTFD)
+
 # IPV6
 check_c_source_compiles(
 #include stdlib.h
diff --git a/config.h.cmake b/config.h.cmake
index 466b951..8b66420 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -42,6 +42,7 @@
 
 #cmakedefine HAVE_ACCEPT_PSOCKLEN_T 1
 #cmakedefine HAVE_IOCTL_INT 1
+#cmakedefine HAVE_EVENTFD_UNSIGNED_INT 1
 
 /*** LIBRARIES ***/
 
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 061a820..d5c343d 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -272,10 +272,12 @@ void swrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 # define SWRAP_LOG(...)
 #else
 
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...) 
PRINTF_ATTRIBUTE(2, 3);
-# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __VA_ARGS__)
+static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *func, const char 
*format, ...) 

[SCM] Socket Wrapper Repository - branch master updated

2014-10-01 Thread Andreas Schneider
The branch, master has been updated
   via  95c39b3 swrap: Fix the loop for older gcc versions.
  from  163f089 Bump version to 1.1.2.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 95c39b39f2f4529b9f59471fd3a99afdd57058ee
Author: Andreas Schneider a...@samba.org
Date:   Wed Oct 1 16:59:29 2014 +0200

swrap: Fix the loop for older gcc versions.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 src/socket_wrapper.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index d5c343d..b30303f 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -452,11 +452,14 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
 #ifdef HAVE_LIBSOCKET
handle = swrap.libsocket_handle;
if (handle == NULL) {
-   for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
+   for (i = 10; i = 0; i--) {
char soname[256] = {0};
 
snprintf(soname, sizeof(soname), 
libsocket.so.%d, i);
handle = dlopen(soname, flags);
+   if (handle != NULL) {
+   break;
+   }
}
 
swrap.libsocket_handle = handle;
@@ -474,11 +477,14 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
}
 #endif
if (handle == NULL) {
-   for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
+   for (i = 10; i = 0; i--) {
char soname[256] = {0};
 
snprintf(soname, sizeof(soname), libc.so.%d, 
i);
handle = dlopen(soname, flags);
+   if (handle != NULL) {
+   break;
+   }
}
 
swrap.libc_handle = handle;


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-09-03 Thread Andreas Schneider
The branch, master has been updated
   via  20555bf tests: Add missing breaks in sockaddr assert functions.
   via  8c6a8f3 swrap: Fix out of bound access.
  from  d3c101f tests: Pass the sockaddr structure to system functions.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 20555bf66a555a63a865bd1969a907533de4ccd2
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 3 09:04:02 2014 +0200

tests: Add missing breaks in sockaddr assert functions.

CID #72657
CID #72656

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 8c6a8f3703928820617187cf492645ef8b8256ba
Author: Andreas Schneider a...@samba.org
Date:   Wed Sep 3 08:59:26 2014 +0200

swrap: Fix out of bound access.

CID #72659

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 src/socket_wrapper.c |2 +-
 tests/test_echo_tcp_get_peer_sock_name.c |4 
 2 files changed, 5 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 13b24a0..061a820 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -2727,7 +2727,7 @@ static int swrap_auto_bind(int fd, struct socket_info 
*si, int family)
 
for (i = 0; i  SOCKET_MAX_SOCKETS; i++) {
port = autobind_start + i;
-   snprintf(un_addr.sa.un.sun_path, un_addr.sa_socklen,
+   snprintf(un_addr.sa.un.sun_path, sizeof(un_addr.sa.un.sun_path),
 %s/SOCKET_FORMAT, socket_wrapper_dir(),
 type, socket_wrapper_default_iface(), port);
if (stat(un_addr.sa.un.sun_path, st) == 0) continue;
diff --git a/tests/test_echo_tcp_get_peer_sock_name.c 
b/tests/test_echo_tcp_get_peer_sock_name.c
index 5f4a9e4..4be729c 100644
--- a/tests/test_echo_tcp_get_peer_sock_name.c
+++ b/tests/test_echo_tcp_get_peer_sock_name.c
@@ -59,8 +59,10 @@ static void _assert_sockaddr_port_equal(struct 
torture_address *addr,
switch(addr-sa.ss.ss_family) {
case AF_INET:
n_port = addr-sa.in.sin_port;
+   break;
case AF_INET6:
n_port = addr-sa.in6.sin6_port;
+   break;
default:
return;
}
@@ -83,8 +85,10 @@ static void _assert_sockaddr_port_range_equal(struct 
torture_address *addr,
switch(addr-sa.ss.ss_family) {
case AF_INET:
n_port = addr-sa.in.sin_port;
+   break;
case AF_INET6:
n_port = addr-sa.in6.sin6_port;
+   break;
default:
return;
}


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-09-01 Thread Andreas Schneider
The branch, master has been updated
   via  442ac15 swrap: Fix whitespace errors.
   via  98dda4f swrap: Update copyright notice.
   via  e3f7e8c swrap: Wrap fopen to detect stale file descriptors.
   via  9694d99 swrap: Use swrap_address in swrap_accept().
   via  3f53182 swrap: Remove unused sockaddr_dup() function.
   via  eedb8e7 swrap: Use swrap_address in the socket_info struct.
   via  bb76c42 swrap: Use a sockaddr_un for the unix path in socket_info.
   via  2b587c8 swrap: Rename swrap_pcap_dump_packet().
   via  7942896 swrap: Rename swrap_pcap_get_fd().
   via  d094f2c swrap: Rename swrap_marshall_packet().
   via  016569e swrap: Rename swrap_packet_init().
   via  8af84a5 swrap: Rename socket_wrapper_pcap_file().
   via  29ea9ce echo_srv: Fix type punning warnings.
   via  0c921aa tests: Fix type punning warnings.
   via  fa6fee0 swrap: Fix type punning warnings.
   via  6637a81 cmake: Set strict aliasing and strict overflow checks.
  from  c83b7d4 Add #define __APPLE_USE_RFC_3542 to CFLAGS

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 442ac150e96595ba4025f9f508ce25b9d8a62b23
Author: Andreas Schneider a...@samba.org
Date:   Mon Sep 1 09:17:06 2014 +0200

swrap: Fix whitespace errors.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 98dda4f6d01ebea315a7a3d335ae26064394bcf0
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 29 13:12:58 2014 +0200

swrap: Update copyright notice.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit e3f7e8ce9158420379fbba3164c05bd845708c60
Author: Andreas Schneider a...@samba.org
Date:   Wed Aug 27 16:00:43 2014 +0200

swrap: Wrap fopen to detect stale file descriptors.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 9694d9924f3f7e88852936a8a27101986bb47223
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 15:14:56 2014 +0200

swrap: Use swrap_address in swrap_accept().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 3f531827c0223be4a88ae8c09b4361c2c59a2769
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 15:15:38 2014 +0200

swrap: Remove unused sockaddr_dup() function.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit eedb8e72cf898d623dc93f881878ca2fcbbb7402
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 14:56:35 2014 +0200

swrap: Use swrap_address in the socket_info struct.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit bb76c424e29b17398c342cf64cadfe96ced7b997
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 14:06:05 2014 +0200

swrap: Use a sockaddr_un for the unix path in socket_info.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 2b587c81f8e29118206a40a20422d0f08f61da5c
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 11:01:46 2014 +0200

swrap: Rename swrap_pcap_dump_packet().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 7942896ce6bd0ad7a169aea5cba062f50727d265
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 10:59:29 2014 +0200

swrap: Rename swrap_pcap_get_fd().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit d094f2c18684755bb204bb29d74dc0fe6256fa81
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 10:58:48 2014 +0200

swrap: Rename swrap_marshall_packet().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 016569e151f8a7d238f2b3401aac80fbc78d2b87
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 10:57:36 2014 +0200

swrap: Rename swrap_packet_init().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 8af84a5b318e419dcd2ebfd4020d5792424a7240
Author: Andreas Schneider a...@samba.org
Date:   Wed May 21 10:55:48 2014 +0200

swrap: Rename socket_wrapper_pcap_file().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 29ea9ce132d2dca6b6de10b3d740b3ce38bccb55
Author: Andreas Schneider a...@samba.org
Date:   Fri Aug 29 17:37:51 2014 +0200

echo_srv: Fix type punning warnings.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 0c921aa3129a5b1b0ff9c7fae2c0b2ca6bde7510
Author: Andreas Schneider 

[SCM] Socket Wrapper Repository - branch master updated

2014-08-15 Thread Andreas Schneider
The branch, master has been updated
   via  c83b7d4 Add #define __APPLE_USE_RFC_3542 to CFLAGS
   via  bc546d0 Define _GNU_SOURCE on one place only.
  from  baa8b43 Provide a compatible declaration of CMSG_ALIGN

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit c83b7d4096ece0ca536c3028e59efc29eb438feb
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Tue Jul 29 08:19:34 2014 +0200

Add #define __APPLE_USE_RFC_3542 to CFLAGS

Unless __APPLE_USE_RFC_3542 is defined on OSX, constants from RFC 3542
such as IPV6_RECVPKTINFO are not usable.

The patch adds the #define unconditionally -- on other platforms, the
constant is harmless.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit bc546d05a93794b1f0f1ef02e96f918533c250c3
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Wed Aug 13 09:44:30 2014 +0200

Define _GNU_SOURCE on one place only.

There were several _GNU_SOURCE definitions scaterred in the build
system. This patch always adds -D_GNU_SOURCE to the CFLAGS if building
on a UNIX platform.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 ConfigureChecks.cmake   |2 --
 cmake/Modules/DefineCompilerFlags.cmake |5 +
 src/CMakeLists.txt  |5 -
 tests/CMakeLists.txt|1 -
 4 files changed, 5 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index df65411..fb73449 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -61,9 +61,7 @@ check_function_exists(snprintf HAVE_SNPRINTF)
 check_function_exists(signalfd HAVE_SIGNALFD)
 check_function_exists(eventfd HAVE_EVENTFD)
 check_function_exists(timerfd_create HAVE_TIMERFD_CREATE)
-set(CMAKE_REQUIRED_FLAGS -D_GNU_SOURCE)
 check_function_exists(bindresvport HAVE_BINDRESVPORT)
-set(CMAKE_REQUIRED_FLAGS)
 
 
 if (UNIX)
diff --git a/cmake/Modules/DefineCompilerFlags.cmake 
b/cmake/Modules/DefineCompilerFlags.cmake
index 218f4fe..4a747d2 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -19,6 +19,11 @@ if (UNIX AND NOT WIN32)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Werror=pointer-arith 
-Werror=declaration-after-statement)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} 
-Werror=implicit-function-declaration -Werror=write-strings)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Werror=int-to-pointer-cast 
-Werror=pointer-to-int-cast)
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -D_GNU_SOURCE)
+
+   if (OSX)
+   set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -D__APPLE_USE_RFC_3542)
+   endif (OSX)
 
 # with -fPIC
 check_c_compiler_flag(-fPIC WITH_FPIC)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b1ab95f..4b22d77 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,11 +2,6 @@ project(libsocket_wrapper C)
 
 include_directories(${CMAKE_BINARY_DIR})
 
-set_source_files_properties(socket_wrapper.c
-PROPERTIES
-COMPILE_DEFINITIONS
-_GNU_SOURCE)
-
 add_library(socket_wrapper SHARED socket_wrapper.c)
 
 target_link_libraries(socket_wrapper ${SWRAP_REQUIRED_LIBRARIES})
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index d3a4156..17b1212 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -6,7 +6,6 @@ include_directories(
   ${CMOCKA_INCLUDE_DIR}
 )
 
-add_definitions(-D_GNU_SOURCE)
 set(TORTURE_LIBRARY torture)
 
 # RFC862 echo server


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-07-29 Thread Andreas Schneider
The branch, master has been updated
   via  baa8b43 Provide a compatible declaration of CMSG_ALIGN
   via  d9bae3a SO_PROTOCOL is platform-dependent
  from  1fcf872 swrap: fix another discard const warning in swrap_bind()

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit baa8b438f76e66531b26a90c02ab11d4e6c09944
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Thu Jul 3 23:13:29 2014 +0200

Provide a compatible declaration of CMSG_ALIGN

Some platforms (like OSX) do support some of the CMGS macros, but don't
have a CMSG_ALIGN macro of their own.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit d9bae3a469d4803003711ae282a52d72905068e9
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Wed Jul 2 00:01:04 2014 +0200

SO_PROTOCOL is platform-dependent

SO_PROTOCOL is not defined on all platforms. In particular, OSX doesn't
include it and so far I haven't found any compatible declaration.

Signed-off-by: Jakub Hrozek jakub.hro...@gmail.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 src/socket_wrapper.c |5 -
 tests/test_echo_tcp_socket_options.c |   10 +-
 2 files changed, 13 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 7ee5b64..930ab58 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3169,6 +3169,8 @@ static int swrap_getsockopt(int s, int level, int optname,
*(int *)optval = si-family;
return 0;
 #endif /* SO_DOMAIN */
+
+#ifdef SO_PROTOCOL
case SO_PROTOCOL:
if (optval == NULL || optlen == NULL ||
*optlen  (socklen_t)sizeof(int)) {
@@ -3179,6 +3181,7 @@ static int swrap_getsockopt(int s, int level, int optname,
*optlen = sizeof(int);
*(int *)optval = si-protocol;
return 0;
+#endif /* SO_PROTOCOL */
case SO_TYPE:
if (optval == NULL || optlen == NULL ||
*optlen  (socklen_t)sizeof(int)) {
@@ -,7 +3336,7 @@ int ioctl(int s, unsigned long int r, ...)
 # ifdef _ALIGN /* BSD */
 #define CMSG_ALIGN _ALIGN
 # else
-#error NO_CMSG_ALIGN
+#define CMSG_ALIGN(len) (((len) + sizeof(size_t) - 1)  ~(sizeof(size_t) - 1))
 # endif /* _ALIGN */
 #endif /* CMSG_ALIGN */
 
diff --git a/tests/test_echo_tcp_socket_options.c 
b/tests/test_echo_tcp_socket_options.c
index 023ac72..3da4a95 100644
--- a/tests/test_echo_tcp_socket_options.c
+++ b/tests/test_echo_tcp_socket_options.c
@@ -101,8 +101,10 @@ static void test_sockopt_so(void **state)
 #ifdef SO_DOMAIN
int so_domain = -1;
 #endif /* SO_DOMAIN */
+#ifdef SO_PROTOCOL
int so_protocol = -1;
int so_type = -1;
+#endif /* SO_PROTOCOL */
int rc;
int s;
 
@@ -135,6 +137,7 @@ static void test_sockopt_so(void **state)
assert_int_equal(so_len, sizeof(int));
 #endif /* SO_DOMAIN */
 
+#ifdef SO_PROTOCOL
so_len = sizeof(so_protocol);
rc = getsockopt(s,
SOL_SOCKET,
@@ -154,6 +157,7 @@ static void test_sockopt_so(void **state)
assert_return_code(rc, errno);
assert_int_equal(so_type, SOCK_STREAM);
assert_int_equal(so_len, sizeof(int));
+#endif /* SO_PROTOCOL */
 
close(s);
 }
@@ -163,12 +167,14 @@ static void test_sockopt_so6(void **state)
 {
struct sockaddr_in6 sin6;
socklen_t slen = sizeof(struct sockaddr_in6);
-   socklen_t so_len;
 #ifdef SO_DOMAIN
int so_domain = -1;
 #endif /* SO_DOMAIN */
+#ifdef SO_PROTOCOL
+   socklen_t so_len;
int so_protocol = -1;
int so_type = -1;
+#endif /* SO_PROTOCOL */
int rc;
int s;
 
@@ -201,6 +207,7 @@ static void test_sockopt_so6(void **state)
assert_int_equal(so_len, sizeof(int));
 #endif /* SO_DOMAIN */
 
+#ifdef SO_PROTOCOL
so_len = sizeof(so_protocol);
rc = getsockopt(s,
SOL_SOCKET,
@@ -220,6 +227,7 @@ static void test_sockopt_so6(void **state)
assert_return_code(rc, errno);
assert_int_equal(so_type, SOCK_STREAM);
assert_int_equal(so_len, sizeof(int));
+#endif /* SO_PROTOCOL */
 
close(s);
 }


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-07-09 Thread Andreas Schneider
The branch, master has been updated
   via  f914a1e doc: Add a socket_wrapper manpage.
  from  5702910 Bump version to 1.1.1

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit f914a1eb570f63b1ba1f36a869b1809436df156d
Author: Andreas Schneider a...@samba.org
Date:   Wed Jul 9 10:15:30 2014 +0200

doc: Add a socket_wrapper manpage.

---

Summary of changes:
 CMakeLists.txt   |1 +
 README   |   68 ++--
 doc/CMakeLists.txt   |4 +
 doc/README   |3 +
 doc/socket_wrapper.1 |  197 ++
 doc/socket_wrapper.1.txt |   87 
 6 files changed, 316 insertions(+), 44 deletions(-)
 create mode 100644 doc/CMakeLists.txt
 create mode 100644 doc/README
 create mode 100644 doc/socket_wrapper.1
 create mode 100644 doc/socket_wrapper.1.txt


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8407053..49e47a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,3 +83,4 @@ install(
 devel
 )
 
+add_subdirectory(doc)
diff --git a/README b/README
index 58b5513..12494cf 100644
--- a/README
+++ b/README
@@ -1,44 +1,24 @@
-Socket wrapper library
-===
-
-This library makes possible to run several instances of the full software stack
-on the same machine and perform locally functional testing of complex network
-configurations. It passes all socket communication over unix domain sockets.
-
-The user defines a directory where to put all the unix sockets using the
-envionment variable SOCKET_WRAPPER_DIR=/path/to/socket_dir. When a server
-opens a port or a client wants to connect, socket_wrapper will translate IP
-addresses to a special socket_wrapper name and look for the relevant unix
-socket in the SOCKET_WRAPPER_DIR.
-
-Additionally, the default interface to be used by an application is defined
-with SOCKET_WRAPPER_DEFAULT_IFACE=ID where ID is between 2 and 254. This
-is analogous to use the IPv4 addresses 127.0.0.ID or IPv6 addresses
-fd00::5357:5fIDx (where IDx is a hexadecimal presentation of ID). You
-should always set the default interface. If you listen on INADDR_ANY then it
-will use the default interface to listen on.
-
-Example:
-LD_PRELOAD=libsocket_wrapper.so \
-SOCKET_WRAPPER_DIR=/path/to/socket_dir \
-./mydaemon
-
-The following environment variables could also be set:
-
-SOCKET_WRAPPER_DEFAULT_IFACE
-The default interface to use if nothing has
-been set trough the functions.
-Set it to '11' for '127.0.0.11'.
-
-SOCKET_WRAPPER_PCAP_FILE
-If set then all traffic will be written to the
-specified pcap file.
-
-SOCKET_WRAPPER_DEBUGLEVEL
-   If you socket_wrapper with with debug symbols
-   you can turn on logging by setting this to an
-   integer between 1 and 3.
-   0 = ERROR
-   1 = WARNING
-   2 = DEBUG
-   3 = TRACE
+SOCKET_WRAPPER
+==
+
+This is a library passing all socket communications through unix sockets.
+
+DESCRIPTION
+---
+
+More details can be found in the manpage:
+
+  man -l ./doc/socket_wrapper.1
+
+or the raw text version:
+
+  less ./doc/socket_wrapper.1.txt
+
+For installation instructions please take a look at the README.install file.
+
+MAILINGLIST
+---
+
+As the mailing list samba-technical is used and can be found here:
+
+https://lists.samba.org/mailman/listinfo/samba-technical
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 000..57552d6
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,4 @@
+install(FILES
+socket_wrapper.1
+DESTINATION
+${MAN_INSTALL_DIR}/man1)
diff --git a/doc/README b/doc/README
new file mode 100644
index 000..dbe07f7
--- /dev/null
+++ b/doc/README
@@ -0,0 +1,3 @@
+The manpage is written with asciidoc. To generate the manpage use:
+
+a2x --doctype manpage --format manpage doc/socket_wrapper.1.txt
diff --git a/doc/socket_wrapper.1 b/doc/socket_wrapper.1
new file mode 100644
index 000..836bde5
--- /dev/null
+++ b/doc/socket_wrapper.1
@@ -0,0 +1,197 @@
+'\ t
+.\ Title: socket_wrapper
+.\Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\ Generator: DocBook XSL Stylesheets v1.78.1 http://docbook.sf.net/
+.\  Date: 07/09/2014
+.\Manual: \ \
+.\Source: \ \
+.\  Language: English
+.\
+.TH SOCKET_WRAPPER 1 07/09/2014 \ \ \ \
+.\ -
+.\ * Define some portability stuff
+.\ -
+.\ ~
+.\ http://bugs.debian.org/507673
+.\ http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\ ~
+.ie \n(.g .ds Aq \(aq
+.el   

[SCM] Socket Wrapper Repository - branch master updated

2014-07-09 Thread Andreas Schneider
The branch, master has been updated
   via  1fcf872 swrap: fix another discard const warning in swrap_bind()
   via  2fb9110 swrap: fix discard const warning in swrap_bind()
   via  e520bb2 swrap: fix discard const warning in swrap_remove_stale()
   via  97bb223 swrap: fix build when neither HAVE_STRUCT_IN_PKTINFO nor 
IP_RECVDSTADDR is defined
   via  f0aeb93 torture: add HAVE_IPV6 guard to torture_server_address()
   via  647161c cmake: Add more build warnings and errors.
   via  248c7c2 fix .gitignore for vi backup files
  from  f914a1e doc: Add a socket_wrapper manpage.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 1fcf8726753f38651d009c63d12a179854b506b8
Author: Michael Adam ob...@samba.org
Date:   Tue Jun 3 21:50:11 2014 +0200

swrap: fix another discard const warning in swrap_bind()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit 2fb911049a5d5aaa51597458ee382b75121a6cef
Author: Michael Adam ob...@samba.org
Date:   Tue Jun 3 21:49:12 2014 +0200

swrap: fix discard const warning in swrap_bind()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit e520bb2cfb189750fd8656431156d44d7c3e3f91
Author: Michael Adam ob...@samba.org
Date:   Tue Jun 3 21:48:01 2014 +0200

swrap: fix discard const warning in swrap_remove_stale()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit 97bb22328076b5b067853be4c56dee4ac87e6420
Author: Michael Adam ob...@samba.org
Date:   Tue Jun 3 15:52:43 2014 +0200

swrap: fix build when neither HAVE_STRUCT_IN_PKTINFO nor IP_RECVDSTADDR is 
defined

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit f0aeb93c9b47a869bbeed422c77895d6cd3dd76f
Author: Michael Adam ob...@samba.org
Date:   Wed Jun 4 09:35:02 2014 +0200

torture: add HAVE_IPV6 guard to torture_server_address()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit 647161c0f7b0c3b86ec2dcca68cb0116755a3eab
Author: Andreas Schneider a...@samba.org
Date:   Tue Jun 3 15:52:43 2014 +0200

cmake: Add more build warnings and errors.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 248c7c2087cb73642866b557d69fe35a82147c0c
Author: Michael Adam ob...@samba.org
Date:   Fri Jun 6 00:55:11 2014 +0200

fix .gitignore for vi backup files

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 .gitignore  |2 +-
 cmake/Modules/DefineCompilerFlags.cmake |5 +++--
 src/socket_wrapper.c|   11 +--
 tests/torture.c |2 ++
 4 files changed, 11 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/.gitignore b/.gitignore
index 8fd1310..5d8f581 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,7 @@
 *.o
 .*
 *.swp
-*~$
+*~
 build
 obj
 cscope.*
diff --git a/cmake/Modules/DefineCompilerFlags.cmake 
b/cmake/Modules/DefineCompilerFlags.cmake
index e6fab88..218f4fe 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -14,10 +14,11 @@ if (UNIX AND NOT WIN32)
 
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow 
-Wmissing-prototypes -Wdeclaration-after-statement)
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wunused -Wfloat-equal 
-Wpointer-arith -Wwrite-strings -Wformat-security)
-set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wmissing-format-attribute)
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wmissing-format-attribute 
-Wcast-align -Wcast-qual)
 
 set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Werror=pointer-arith 
-Werror=declaration-after-statement)
-set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} 
-Werror=implicit-function-declaration)
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} 
-Werror=implicit-function-declaration -Werror=write-strings)
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Werror=int-to-pointer-cast 
-Werror=pointer-to-int-cast)
 
 # with -fPIC
 check_c_compiler_flag(-fPIC WITH_FPIC)
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index afd9343..7ee5b64 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1394,14 +1394,14 @@ static int sockaddr_convert_to_un(struct socket_info 
*si,
 
switch (in_addr-sa_family) {
case AF_UNSPEC: {
-   struct sockaddr_in *sin;
+   const struct sockaddr_in *sin;
if (si-family != AF_INET) {
break;
}
if (in_len  sizeof(struct sockaddr_in)) {
   

[SCM] Socket Wrapper Repository - branch master updated

2014-06-05 Thread Andreas Schneider
The branch, master has been updated
   via  5702910 Bump version to 1.1.1
   via  86114df swrap: Disable incomplete bind checks for EADDRINUSE.
   via  d768235 tests: Disable addr_in_use bind test while the swrap code 
is incomplete.
  from  3a05064 Bump version to 1.1.0.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 570291013b0844452219f76c3d5e1d78eb617d11
Author: Andreas Schneider a...@samba.org
Date:   Thu Jun 5 23:41:09 2014 +0200

Bump version to 1.1.1

commit 86114df0dfc8d74fc545d08c864f9045c70fe452
Author: Andreas Schneider a...@samba.org
Date:   Thu Jun 5 23:47:40 2014 +0200

swrap: Disable incomplete bind checks for EADDRINUSE.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit d768235f48622c89378cb32c48a65ecb97dd2780
Author: Andreas Schneider a...@samba.org
Date:   Thu Jun 5 23:46:31 2014 +0200

tests: Disable addr_in_use bind test while the swrap code is incomplete.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 CMakeLists.txt |4 ++--
 ChangeLog  |5 -
 src/socket_wrapper.c   |7 ++-
 tests/test_echo_tcp_bind.c |4 
 4 files changed, 16 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 307103c..8407053 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 1)
-set(APPLICATION_VERSION_PATCH 0)
+set(APPLICATION_VERSION_PATCH 1)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.1.0)
+set(LIBRARY_VERSION 0.1.1)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 7b3ed53..e5eabfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,10 @@
 ChangeLog
 ==
 
-version 1.0.3 (released 2014-06-02)
+version 1.1.1 (released 2014-06-05)
+  * Disable incomplete address in use check in bind().
+
+version 1.1.0 (released 2014-06-02)
   * Added support for IP_PKTINFO in recvmsg().
   * Added support for IPV6_PKTINFO in recvmsg().
   * Added support for IP_RECVDSTADDR in recvmsg() on BSD.
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index f6adc95..afd9343 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1267,6 +1267,7 @@ static struct socket_info *find_socket_info(int fd)
return NULL;
 }
 
+#if 0 /* FIXME */
 static bool check_addr_port_in_use(const struct sockaddr *sa, socklen_t len)
 {
struct socket_info *s;
@@ -1348,7 +1349,7 @@ static bool check_addr_port_in_use(const struct sockaddr 
*sa, socklen_t len)
 
return false;
 }
-
+#endif
 
 static void swrap_remove_stale(int fd)
 {
@@ -2829,7 +2830,9 @@ static int swrap_bind(int s, const struct sockaddr 
*myaddr, socklen_t addrlen)
struct sockaddr_un un_addr;
struct socket_info *si = find_socket_info(s);
int bind_error = 0;
+#if 0 /* FIXME */
bool in_use;
+#endif
 
if (!si) {
return libc_bind(s, myaddr, addrlen);
@@ -2885,11 +2888,13 @@ static int swrap_bind(int s, const struct sockaddr 
*myaddr, socklen_t addrlen)
return -1;
}
 
+#if 0 /* FIXME */
in_use = check_addr_port_in_use(myaddr, addrlen);
if (in_use) {
errno = EADDRINUSE;
return -1;
}
+#endif
 
free(si-myname);
si-myname_len = addrlen;
diff --git a/tests/test_echo_tcp_bind.c b/tests/test_echo_tcp_bind.c
index d42679a..c159206 100644
--- a/tests/test_echo_tcp_bind.c
+++ b/tests/test_echo_tcp_bind.c
@@ -154,6 +154,7 @@ static void test_bind_ipv4(void **state)
close(s);
 }
 
+#if 0 /* TODO */
 static void test_bind_ipv4_addr_in_use(void **state)
 {
struct sockaddr_in sin, sin2;
@@ -307,6 +308,7 @@ static void test_bind_ipv4_addr_in_use(void **state)
 
close(s);
 }
+#endif
 
 #ifdef HAVE_BINDRESVPORT
 static void test_bindresvport_ipv4(void **state)
@@ -469,9 +471,11 @@ int main(void) {
unit_test_setup_teardown(test_bind_ipv4,
 setup_echo_srv_tcp_ipv4,
 teardown),
+#if 0 /* TODO */
unit_test_setup_teardown(test_bind_ipv4_addr_in_use,
 

[SCM] Socket Wrapper Repository - branch master updated

2014-06-02 Thread Andreas Schneider
The branch, master has been updated
   via  23b4fa4 tests: Fix conflicting variable name on Solaris.
   via  52eabf4 tests: Fix building without bindresvport().
  from  9e91b00 tests: add new test test_bind_ipv4_addr_in_use()

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 23b4fa4519a128773cd99d85e3aa7288f08bbbd3
Author: Andreas Schneider a...@samba.org
Date:   Mon Jun 2 08:36:49 2014 +0200

tests: Fix conflicting variable name on Solaris.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 52eabf4b886135d8ace300b5e7f29b26c86a7c01
Author: Andreas Schneider a...@samba.org
Date:   Mon Jun 2 08:30:50 2014 +0200

tests: Fix building without bindresvport().

This fixes the build on Solaris.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 tests/test_echo_tcp_bind.c |   23 +++
 1 files changed, 15 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_echo_tcp_bind.c b/tests/test_echo_tcp_bind.c
index c699b06..d42679a 100644
--- a/tests/test_echo_tcp_bind.c
+++ b/tests/test_echo_tcp_bind.c
@@ -40,7 +40,7 @@ static void test_bind_ipv4(void **state)
socklen_t salen = sizeof(struct sockaddr);
struct sockaddr_in sin;
socklen_t slen = sizeof(struct sockaddr_in);
-   struct sockaddr_un sun;
+   struct sockaddr_un addr_un;
socklen_t sulen = sizeof(struct sockaddr_un);
int rc;
int s;
@@ -110,10 +110,10 @@ static void test_bind_ipv4(void **state)
assert_int_equal(rc, -1);
assert_int_equal(errno, EAFNOSUPPORT);
 
-   sun = (struct sockaddr_un) {
+   addr_un = (struct sockaddr_un) {
.sun_family = AF_UNIX,
};
-   rc = bind(s, (struct sockaddr *)sun, sulen);
+   rc = bind(s, (struct sockaddr *)addr_un, sulen);
assert_int_equal(rc, -1);
assert_int_equal(errno, EAFNOSUPPORT);
 
@@ -308,6 +308,7 @@ static void test_bind_ipv4_addr_in_use(void **state)
close(s);
 }
 
+#ifdef HAVE_BINDRESVPORT
 static void test_bindresvport_ipv4(void **state)
 {
struct sockaddr_in sin;
@@ -367,6 +368,7 @@ static void test_bindresvport_ipv4_null(void **state)
 
close(s);
 }
+#endif /* HAVE_BINDRESVPORT */
 
 #ifdef HAVE_IPV6
 static void test_bind_on_ipv6_sock(void **state)
@@ -375,7 +377,7 @@ static void test_bind_on_ipv6_sock(void **state)
socklen_t slen = sizeof(struct sockaddr_in);
struct sockaddr_in6 sin6;
socklen_t slen6 = sizeof(struct sockaddr_in6);
-   struct sockaddr_un sun;
+   struct sockaddr_un addr_un;
socklen_t sulen = sizeof(struct sockaddr_un);
int rc;
int s;
@@ -385,9 +387,9 @@ static void test_bind_on_ipv6_sock(void **state)
s = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
assert_return_code(s, errno);
 
-   ZERO_STRUCT(sun);
-   sun.sun_family = AF_UNIX;
-   rc = bind(s, (struct sockaddr *)sun, sulen);
+   ZERO_STRUCT(addr_un);
+   addr_un.sun_family = AF_UNIX;
+   rc = bind(s, (struct sockaddr *)addr_un, sulen);
assert_int_equal(rc, -1);
/* FreeBSD uses EINVAL here... */
assert_true(errno == EAFNOSUPPORT || errno == EINVAL);
@@ -417,6 +419,7 @@ static void test_bind_on_ipv6_sock(void **state)
close(s);
 }
 
+#ifdef HAVE_BINDRESVPORT
 static void test_bindresvport_on_ipv6_sock(void **state)
 {
struct sockaddr_in sin;
@@ -456,7 +459,7 @@ static void test_bindresvport_on_ipv6_sock_null(void 
**state)
 
close(s);
 }
-
+#endif /* HAVE_BINDRESVPORT */
 #endif /* HAVE_IPV6 */
 
 int main(void) {
@@ -469,22 +472,26 @@ int main(void) {
unit_test_setup_teardown(test_bind_ipv4_addr_in_use,
 setup_echo_srv_tcp_ipv4,
 teardown),
+#ifdef HAVE_BINDRESVPORT
unit_test_setup_teardown(test_bindresvport_ipv4,
 setup_echo_srv_tcp_ipv4,
 teardown),
unit_test_setup_teardown(test_bindresvport_ipv4_null,
 setup_echo_srv_tcp_ipv4,
 teardown),
+#endif /* HAVE_BINDRESVPORT */
 #ifdef HAVE_IPV6
unit_test_setup_teardown(test_bind_on_ipv6_sock,
 setup_echo_srv_tcp_ipv6,
 teardown),
+#ifdef HAVE_BINDRESVPORT
unit_test_setup_teardown(test_bindresvport_on_ipv6_sock,
 setup_echo_srv_tcp_ipv6,
 teardown),
 

[SCM] Socket Wrapper Repository - branch master updated

2014-06-02 Thread Andreas Schneider
The branch, master has been updated
   via  3a05064 Bump version to 1.1.0.
  from  23b4fa4 tests: Fix conflicting variable name on Solaris.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 3a05064e3c3161560ad6bb67c1d4e07a1a1bdce1
Author: Andreas Schneider a...@samba.org
Date:   Mon Jun 2 14:39:04 2014 +0200

Bump version to 1.1.0.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 CMakeLists.txt |6 +++---
 ChangeLog  |   11 +++
 2 files changed, 14 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e346e6..307103c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 2.8.5)
 set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
-set(APPLICATION_VERSION_MINOR 0)
-set(APPLICATION_VERSION_PATCH 2)
+set(APPLICATION_VERSION_MINOR 1)
+set(APPLICATION_VERSION_PATCH 0)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.0.2)
+set(LIBRARY_VERSION 0.1.0)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index 2bb84e9..7b3ed53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,17 @@
 ChangeLog
 ==
 
+version 1.0.3 (released 2014-06-02)
+  * Added support for IP_PKTINFO in recvmsg().
+  * Added support for IPV6_PKTINFO in recvmsg().
+  * Added support for IP_RECVDSTADDR in recvmsg() on BSD.
+  * Added support for more socket options in getsockopt().
+  * Added support for bindresvport().
+  * Fixed rebinding on connect().
+  * Fixed sockaddr buffer truncation in getsockname() and getpeername().
+  * Fixed special cases in bind().
+  * Fixed loading libc on some platforms.
+
 version 1.0.2 (released 2014-05-05)
   * Fixed memory leaks
   * Fixed calling open from libc.


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-06-01 Thread Michael Adam
The branch, master has been updated
   via  9e91b00 tests: add new test test_bind_ipv4_addr_in_use()
   via  0c3efeb tests: extend the ipv6 bind test
   via  a14a1af tests: greatly extend the ipv4 bind test
   via  f38c0b4 swrap: check whether an address:port is already in use in 
swrap_bind()
   via  da04f94 swrap: implement check_addr_port_in_use()
   via  f04ea32 swrap: fix AF_UNSPEC special case in swrap_bind()
   via  97a65a1 swrap: extend input checks in swrap_bind()
   via  af40930 Update the todo list.
   via  b357525 tests: Avoid using getenv() to retrieve the path.
   via  3029067 swrap: add check for rpc/rpc.h - needed on freebsd for 
bindresvport
   via  0025857 tests: Add tests for bindresvport().
   via  ccf4e64 swrap: Add support for bindresvport().
   via  b124fcb tests: Add tests for bind().
   via  45eb7c9 swrap: Add missing family check in bind().
   via  37b472d tests: Add test that getsockname is correct after socket().
   via  bdbbf38 swrap: Setup myname in swrap_socket() for getsockname().
   via  205d5c2 torture: Wait for the pidfile and then start the tests.
   via  323feb7 echo_srv: Write pidfile after we setup the listeners.
  from  1dbbd72 README.install: improvements and fixes.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 9e91b00ee329578987c579b2c9d6db967055a59a
Author: Michael Adam ob...@samba.org
Date:   Sat May 31 03:35:22 2014 +0200

tests: add new test test_bind_ipv4_addr_in_use()

This tests binding an address that is already in use.

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit 0c3efeb3b07083e36068e354b20208316d02c79a
Author: Michael Adam ob...@samba.org
Date:   Sat May 31 03:31:56 2014 +0200

tests: extend the ipv6 bind test

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit a14a1afe966a45000fa768df43a25d84a68772dd
Author: Michael Adam ob...@samba.org
Date:   Sat May 31 03:31:29 2014 +0200

tests: greatly extend the ipv4 bind test

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit f38c0b43d5620ab6457bf8a4fbdaf3a7bf90627c
Author: Michael Adam ob...@samba.org
Date:   Fri May 30 14:20:40 2014 +0200

swrap: check whether an address:port is already in use in swrap_bind()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit da04f94dd0575245424cf7853d0a9fc5b7caacee
Author: Michael Adam ob...@samba.org
Date:   Fri May 30 14:20:17 2014 +0200

swrap: implement check_addr_port_in_use()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit f04ea324f6079e74532ee1ae085945097073a305
Author: Michael Adam ob...@samba.org
Date:   Fri May 30 13:21:00 2014 +0200

swrap: fix AF_UNSPEC special case in swrap_bind()

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit 97a65a132d1b14cbfd539f327f260237c1afff3d
Author: Michael Adam ob...@samba.org
Date:   Fri May 30 13:06:02 2014 +0200

swrap: extend input checks in swrap_bind()

Not only check family, but depending on family, also check the length.

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit af40930bebe0322d5876bda2aa36598e1bae2056
Author: Andreas Schneider a...@samba.org
Date:   Wed May 28 10:04:04 2014 +0200

Update the todo list.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit b357525a2958e394fceb8c7b6165b572e944e8f2
Author: Andreas Schneider a...@samba.org
Date:   Wed May 28 09:46:57 2014 +0200

tests: Avoid using getenv() to retrieve the path.

CID 17221

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 3029067b21775c1f6fec43e0b03712defa69e9a6
Author: Michael Adam ob...@samba.org
Date:   Sun Jun 1 01:48:15 2014 +0200

swrap: add check for rpc/rpc.h - needed on freebsd for bindresvport

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit 00258577e86f4b6c15d504954ee6233086638a3e
Author: Andreas Schneider a...@samba.org
Date:   Wed May 28 09:46:40 2014 +0200

tests: Add tests for bindresvport().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit ccf4e64fe7bf788c17ca1a41e456e3b9ecdcb85b
Author: Andreas Schneider a...@samba.org
Date:   Tue May 20 20:04:02 2014 +0200

swrap: Add support for bindresvport().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 

[SCM] Socket Wrapper Repository - branch master updated

2014-05-28 Thread Michael Adam
The branch, master has been updated
   via  1dbbd72 README.install: improvements and fixes.
  from  5774897 Add README.install - instructions for building and 
installing.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 1dbbd7211cef0434d89d12fd28cfd28274b57956
Author: Michael Adam ob...@samba.org
Date:   Tue May 27 14:05:45 2014 +0200

README.install: improvements and fixes.

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 README.install |   24 ++--
 1 files changed, 14 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/README.install b/README.install
index e06a951..6fe012f 100644
--- a/README.install
+++ b/README.install
@@ -17,17 +17,18 @@ To create a local copy, run
 Building from sources
 =
 
-socket_wrapper uses cmake (www.cmake.org) as build system.
+socket_wrapper uses cmake (www.cmake.org) as its build system.
 
-In a unpacked sources base directory, create a directory to
-contain the build results:
+In an unpacked sources base directory, create a directory to
+contain the build results, e.g.
 
   $ mkdir obj
   $ cd obj
 
-Note this target directory can be named arbitrarily.
+Note that obj is just an example. The directory can
+be named arbitrarily.
 
-Next, run cmake to configure the build, e.g.:
+Next, run cmake to configure the build, e.g.
 
   $ cmake -DCMAKE_INSTALL_PREFIX=prefix ..
 
@@ -37,15 +38,18 @@ or on a 64 bit red hat system:
 
 The prefix should be replaced by the intended installation
 target prefix directory, typically /usr or /usr/local.
-If the build target directory is no a direct subdirectory
-of the source base directory, .. needs to be replaced
-by the relative or absolute path of that directory.
+
+Note that the target directory does not have to be a direct
+or indirect subdirectory of the source base directory: It can
+be an arbitrary directory in the system. In the general case,
+.. has to be replaced by a relative or absolute path of the
+source base directory in the cmake command line.
 
 One can control the build type with -DCMAKE_BUILD_TYPE=mode
 where mode can be one of Debug, Release, RelWithDebInfo, and
-some more (see cmake.org). The default is RelWithDebInfo.
+some more (see cmake.org). The default is RelWithDebInfo.
 
-Afterward configuring with cmake, run the build with
+After configuring with cmake, run the build with
 
   $ make
 


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-05-27 Thread Andreas Schneider
The branch, master has been updated
   via  5774897 Add README.install - instructions for building and 
installing.
   via  edaceb0 tests: Fix possible format string attack.
   via  43a39c5 swrap: Make sure cmbuf is not NULL.
   via  98441f8 swrap: We need to pass a pointer-pointer to not leak memory.
  from  096c9a7 tests: Add more tests for socket options.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 57748973ae70450c5f875f0ca577bbaed305d9ad
Author: Michael Adam ob...@samba.org
Date:   Tue May 27 07:57:20 2014 +0200

Add README.install - instructions for building and installing.

Signed-off-by: Michael Adam ob...@samba.org
Reviewed-by: Andreas Schneider a...@samba.org

commit edaceb0f8fd77cddb78616f3a854accf7175a64b
Author: Andreas Schneider a...@samba.org
Date:   Tue May 27 09:35:00 2014 +0200

tests: Fix possible format string attack.

Well, there is really not attack on a test but we want to silence
Coverity :)

CID 17221

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 43a39c5e288423d1be5b5544d8e13847726d7eda
Author: Andreas Schneider a...@samba.org
Date:   Tue May 27 09:09:24 2014 +0200

swrap: Make sure cmbuf is not NULL.

CID 63532

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 98441f8591ff6f57fe26f650b4028ac26cd75527
Author: Andreas Schneider a...@samba.org
Date:   Tue May 27 09:08:32 2014 +0200

swrap: We need to pass a pointer-pointer to not leak memory.

CID 63533

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 README.install   |   74 ++
 src/socket_wrapper.c |   24 
 tests/test_ioctl.c   |9 ++
 3 files changed, 89 insertions(+), 18 deletions(-)
 create mode 100644 README.install


Changeset truncated at 500 lines:

diff --git a/README.install b/README.install
new file mode 100644
index 000..e06a951
--- /dev/null
+++ b/README.install
@@ -0,0 +1,74 @@
+Obtaining the sources
+=
+
+Source tarballs for socket_wrapper can be downloaded from
+
+  https://ftp.samba.org/pub/cwrap/
+
+The source code repository for socket wrapper is located under
+
+  git://git.samba.org/socket_wrapper.git
+
+To create a local copy, run
+
+  $ git clone git://git.samba.org/socket_wrapper.git
+  $ cd socket_wrapper
+
+Building from sources
+=
+
+socket_wrapper uses cmake (www.cmake.org) as build system.
+
+In a unpacked sources base directory, create a directory to
+contain the build results:
+
+  $ mkdir obj
+  $ cd obj
+
+Note this target directory can be named arbitrarily.
+
+Next, run cmake to configure the build, e.g.:
+
+  $ cmake -DCMAKE_INSTALL_PREFIX=prefix ..
+
+or on a 64 bit red hat system:
+
+  $  cmake -DCMAKE_INSTALL_PREFIX=prefix -DLIB_SUFFIX=64 ..
+
+The prefix should be replaced by the intended installation
+target prefix directory, typically /usr or /usr/local.
+If the build target directory is no a direct subdirectory
+of the source base directory, .. needs to be replaced
+by the relative or absolute path of that directory.
+
+One can control the build type with -DCMAKE_BUILD_TYPE=mode
+where mode can be one of Debug, Release, RelWithDebInfo, and
+some more (see cmake.org). The default is RelWithDebInfo.
+
+Afterward configuring with cmake, run the build with
+
+  $ make
+
+Unit testing
+
+
+In order to support running the test suite after building,
+the cmocka unit test framework needs to be installed (cmocka.org),
+and you need to specify
+
+  -DUNIT_TESTING=ON
+
+in the cmake run. After running make,
+
+  $ make test
+
+runs the test suite.
+
+Installing
+==
+
+socket_wrapper is installed into the prefix directory
+after running cmake and make with
+
+  $ make install
+
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 19ac184..b8b1ca3 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3196,14 +3196,14 @@ static int swrap_msghdr_add_socket_info(struct 
socket_info *si,
 }
 
 static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg,
-  uint8_t *cm_data,
+  uint8_t **cm_data,
   size_t *cm_data_space);
 static int swrap_sendmsg_filter_cmsg_socket(struct cmsghdr *cmsg,
-   uint8_t *cm_data,
+   uint8_t **cm_data,
size_t *cm_data_space);
 
 static int swrap_sendmsg_filter_cmsghdr(struct msghdr *msg,
-   uint8_t *cm_data,
+

[SCM] Socket Wrapper Repository - branch master updated

2014-05-26 Thread Andreas Schneider
The branch, master has been updated
   via  096c9a7 tests: Add more tests for socket options.
   via  e7f7bec swrap: Support more socket options in getsockopt().
   via  c9b06b3 echo_srv: Add support for IP_SENDSRCADDR.
   via  27be91d swrap: Call swrap_msghdr_filter_cmsghdr in 
swrap_sendmsg_before().
   via  4849b2e swrap: Add swrap_msghdr_filter_cmsg_pktinfo().
   via  69f22c9 swrap: Add swrap_sendmsg_filter_cmsg_socket().
   via  63c59be swrap: Add swrap_sendmsg_copy_cmsg().
   via  c9332d4 swrap: Add swrap_sendmsg_filter_cmsghdr().
   via  3c55e35 echo_srv: Implement support for IP_RECVDSTADDR on BSD.
   via  29f24e5 swrap: Implement support for IP_RECVDSTADDR on BSD.
   via  75271e6 echo_srv: Fix building on OpenIndiana.
   via  13ea22c swrap: Check if the in_pktinfo structure is available.
   via  f81b6e8 swrap: Silence a warning on OpenIndiana.
   via  d977b0e tests: Fix assert_sockaddr_equal() file and line output.
   via  f60415a cmake: Add some warnings were we should error out.
   via  54d74cb swrap: Properly cache the handle also in LIBC_SO case.
  from  b9404d4 cmake: Fix a typo in socket_wrapper-config.cmake.in.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 096c9a7545ab5a406859a67374ca8a1c9d046f28
Author: Andreas Schneider a...@samba.org
Date:   Thu May 22 11:32:22 2014 +0200

tests: Add more tests for socket options.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit e7f7bec0b56acd7b9744af53f7d96a53abd46ad3
Author: Andreas Schneider a...@samba.org
Date:   Thu May 22 11:18:08 2014 +0200

swrap: Support more socket options in getsockopt().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit c9b06b39df767539e47da8b6ce2208a5463a5314
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 14:36:23 2014 +0200

echo_srv: Add support for IP_SENDSRCADDR.

Pair-Programmed-With: Michael Adam ob...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Michael Adam ob...@samba.org

commit 27be91da8fbb56826c361abd67ebb1e081540bfe
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 14:35:59 2014 +0200

swrap: Call swrap_msghdr_filter_cmsghdr in swrap_sendmsg_before().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 4849b2ebbfca6176e685ac9c6c933aad8470295f
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 14:35:34 2014 +0200

swrap: Add swrap_msghdr_filter_cmsg_pktinfo().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 69f22c94b4ad061263c40c8c271a86f444cee72d
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 15:44:23 2014 +0200

swrap: Add swrap_sendmsg_filter_cmsg_socket().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 63c59be9ace8282ed19b15fa9d66c7448c1bdd97
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 15:48:33 2014 +0200

swrap: Add swrap_sendmsg_copy_cmsg().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit c9332d48d55925c585641bbd7069f3a4c774e3c1
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 15:42:14 2014 +0200

swrap: Add swrap_sendmsg_filter_cmsghdr().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 3c55e35cad90ef3c1126b390cf53b860c99fdd6e
Author: Andreas Schneider a...@samba.org
Date:   Mon May 26 11:07:45 2014 +0200

echo_srv: Implement support for IP_RECVDSTADDR on BSD.

Pair-Programmed-With: Michael Adam ob...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Michael Adam ob...@samba.org

commit 29f24e5cc059ed37117126838045f85b494fc288
Author: Andreas Schneider a...@samba.org
Date:   Mon May 26 11:00:09 2014 +0200

swrap: Implement support for IP_RECVDSTADDR on BSD.

Pair-Programmed-With: Michael Adam ob...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Michael Adam ob...@samba.org

commit 75271e62121ba207076add1378d716adcf3ee47f
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 09:26:13 2014 +0200

echo_srv: Fix building on OpenIndiana.

Solaris doesn't have support for auxillary messages.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 13ea22cdaac3b5855232f1f59d910b628847ffe2
Author: Andreas Schneider a...@samba.org
Date:   Fri May 23 10:01:21 2014 +0200

swrap: Check if the in_pktinfo structure is available.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam 

[SCM] Socket Wrapper Repository - branch master updated

2014-05-22 Thread Andreas Schneider
The branch, master has been updated
   via  b9404d4 cmake: Fix a typo in socket_wrapper-config.cmake.in.
   via  71cc17a cmake: Require cmocka versin 0.4.1.
   via  916a02d tests: Add test for different length passed to 
get(sock|peer)name.
   via  9b45102 swrap: Truncate the address if the buffer is to small.
   via  b02ecdf tests: Add support to sending IP_PKTINFO in echo_srv.
   via  6f96c9d tests: Add support to receive IP_PKTINFO in echo_srv.
   via  d71c5d6 swrap: Process control messages in recvmsg().
   via  efb1249 swrap: Call swrap_msghdr_socket_info in 
swrap_recvmsg_after().
   via  1a3eac1 swrap: Add swrap_msghdr_socket_info().
   via  37dfa9b swrap: Add swrap_msghdr_add_pktinfo().
   via  c609a8a swrap: Add swrap_msghdr_add_cmsghdr().
   via  54d987e swrap: Add IP_PKTINFO support in setsockopt.
   via  ae3c84b cmake: Add check for HAVE_STRUCT_IN6_PKTINFO.
   via  0911cab cmake: Build swrap with _GNU_SOURCE.
  from  b37783b tests: Add test to verify that the binded iface address is 
correct.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit b9404d4a5f8d6295cc08514e57cc281efdcab6c6
Author: Andreas Schneider a...@samba.org
Date:   Thu May 22 14:56:09 2014 +0200

cmake: Fix a typo in socket_wrapper-config.cmake.in.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 71cc17ad79e186717c5e565369b860c0cc2f2d77
Author: Andreas Schneider a...@samba.org
Date:   Thu May 22 08:49:07 2014 +0200

cmake: Require cmocka versin 0.4.1.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 916a02d1f155c98f689e5ebb545331dc0f48ac2a
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed May 14 18:08:38 2014 +0200

tests: Add test for different length passed to get(sock|peer)name.

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Michael Adam ob...@samba.org

commit 9b45102df0bf3dc817533d6e478fdf56852d2db5
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed May 14 17:44:07 2014 +0200

swrap: Truncate the address if the buffer is to small.

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Michael Adam ob...@samba.org

commit b02ecdf338ce6bcefaa91ec0a8fe3dce5b8925a8
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed May 14 11:28:33 2014 +0200

tests: Add support to sending IP_PKTINFO in echo_srv.

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Michael Adam ob...@samba.org

commit 6f96c9df7cdc2e4b80bad9cd782a9256e1f03625
Author: Andreas Schneider a...@cryptomilk.org
Date:   Wed May 14 10:11:37 2014 +0200

tests: Add support to receive IP_PKTINFO in echo_srv.

Signed-off-by: Andreas Schneider a...@cryptomilk.org
Reviewed-by: Michael Adam ob...@samba.org

commit d71c5d60d54048fe649be332b4267d93ae19d7ce
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue May 13 16:06:13 2014 +0200

swrap: Process control messages in recvmsg().

Pair-Programmed-With: Stefan Metzmacher me...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Stefan Metzmacher me...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit efb124918850c340df711ed643a04fef1424c203
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue May 13 16:05:44 2014 +0200

swrap: Call swrap_msghdr_socket_info in swrap_recvmsg_after().

Pair-Programmed-With: Stefan Metzmacher me...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Stefan Metzmacher me...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 1a3eac1c6c8f739a1da0b40f683b651475808eae
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue May 13 16:02:26 2014 +0200

swrap: Add swrap_msghdr_socket_info().

Pair-Programmed-With: Stefan Metzmacher me...@samba.org
Pair-Programmed-With: Michael Adam ob...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Stefan Metzmacher me...@samba.org
Signed-off-by: Michael Adam ob...@samba.org

commit 37dfa9ba9484488995b4338b6e955b54ea1912aa
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue May 13 16:01:25 2014 +0200

swrap: Add swrap_msghdr_add_pktinfo().

Pair-Programmed-With: Stefan Metzmacher me...@samba.org
Pair-Programmed-With: Michael Adam ob...@samba.org
Signed-off-by: Andreas Schneider a...@samba.org
Signed-off-by: Stefan Metzmacher me...@samba.org
Signed-off-by: Michael Adam ob...@samba.org

commit c609a8a5547d0d1edc17069bcaf22bbb63802c3b
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 22 18:45:51 2014 +0100

swrap: Add swrap_msghdr_add_cmsghdr().

Pair-Programmed-With: Stefan Metzmacher me...@samba.org
Pair-Programmed-With: Michael Adam 

[SCM] Socket Wrapper Repository - branch master updated

2014-05-08 Thread Andreas Schneider
The branch, master has been updated
   via  b37783b tests: Add test to verify that the binded iface address is 
correct.
   via  06934c6 swrap: Correctly set the bind iface address on connect().
   via  0fa5690 swrap: use LIBC_SO from GNU libc, if available
  from  3d70059 Bump version to 1.0.2.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit b37783b6a6503b84363877023cb37618e7504d56
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 15 14:11:06 2014 +0200

tests: Add test to verify that the binded iface address is correct.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 06934c6f763a3cb12be6e02ba0823ce28534128d
Author: Andreas Schneider a...@samba.org
Date:   Wed May 7 18:31:00 2014 +0200

swrap: Correctly set the bind iface address on connect().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 0fa56909442c3cfea6a697681ea0e89ba5a0aa0f
Author: Pino Toscano toscano.p...@tiscali.it
Date:   Thu May 8 13:37:02 2014 +0200

swrap: use LIBC_SO from GNU libc, if available

Look for gnu/lib-names.h and use the LIBC_SO define to dlopen libc, so
the right library is loaded without manually searching for libc.so.N.

Signed-off-by: Pino Toscano toscano.p...@tiscali.it
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 ConfigureChecks.cmake|1 +
 config.h.cmake   |1 +
 src/socket_wrapper.c |   65 ++
 tests/CMakeLists.txt |1 +
 tests/test_echo_tcp_get_peer_sock_name.c |  355 ++
 5 files changed, 423 insertions(+), 0 deletions(-)
 create mode 100644 tests/test_echo_tcp_get_peer_sock_name.c


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index c05cbb9..8db5162 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -51,6 +51,7 @@ check_include_file(sys/filio.h HAVE_SYS_FILIO_H)
 check_include_file(sys/signalfd.h HAVE_SYS_SIGNALFD_H)
 check_include_file(sys/eventfd.h HAVE_SYS_EVENTFD_H)
 check_include_file(sys/timerfd.h HAVE_SYS_TIMERFD_H)
+check_include_file(gnu/lib-names.h HAVE_GNU_LIB_NAMES_H)
 
 # FUNCTIONS
 check_function_exists(strncpy HAVE_STRNCPY)
diff --git a/config.h.cmake b/config.h.cmake
index abbf133..efa519b 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -18,6 +18,7 @@
 #cmakedefine HAVE_SYS_SIGNALFD_H 1
 #cmakedefine HAVE_SYS_EVENTFD_H 1
 #cmakedefine HAVE_SYS_TIMERFD_H 1
+#cmakedefine HAVE_GNU_LIB_NAMES_H 1
 
 / STRUCT MEMBERS */
 
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 95643aa..4bca746 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -73,6 +73,9 @@
 #include stdarg.h
 #include stdbool.h
 #include unistd.h
+#ifdef HAVE_GNU_LIB_NAMES_H
+#include gnu/lib-names.h
+#endif
 
 enum swrap_dbglvl_e {
SWRAP_LOG_ERROR = 0,
@@ -199,6 +202,9 @@ struct socket_info
 
char *tmp_path;
 
+   struct sockaddr *bindname;
+   socklen_t bindname_len;
+
struct sockaddr *myname;
socklen_t myname_len;
 
@@ -418,6 +424,11 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
/* FALL TROUGH */
case SWRAP_LIBC:
handle = swrap.libc_handle;
+#ifdef LIBC_SO
+   if (handle == NULL) {
+   handle = dlopen(LIBC_SO, flags);
+   }
+#endif
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -1099,6 +1110,21 @@ static int convert_in_un_alloc(struct socket_info *si, 
const struct sockaddr *in
errno = EADDRNOTAVAIL;
return -1;
}
+
+   /* Store the bind address for connect() */
+   if (si-bindname == NULL) {
+   struct sockaddr_in bind_in;
+   socklen_t blen = sizeof(struct sockaddr_in);
+
+   ZERO_STRUCT(bind_in);
+   bind_in.sin_family = in-sin_family;
+   bind_in.sin_port = in-sin_port;
+   bind_in.sin_addr.s_addr = htonl(0x7F00 | iface);
+
+   si-bindname = sockaddr_dup(bind_in, blen);
+   si-bindname_len = blen;
+   }
+
break;
}
 #ifdef HAVE_IPV6
@@ -1136,6 +1162,22 @@ static int convert_in_un_alloc(struct socket_info *si, 
const struct sockaddr *in
return -1;
}
 
+   

[SCM] Socket Wrapper Repository - branch master updated

2014-05-05 Thread Andreas Schneider
The branch, master has been updated
   via  3d70059 Bump version to 1.0.2.
   via  eb6676b swrap: Fall back to RTLD_NEXT if we can't find libc.
   via  7f4d72e Fix some typos.
  from  fb8afa1 swrap: Use the loaded libc open() directly.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 3d70059d5465e8ae0a3149265ea7c04a78e480d2
Author: Andreas Schneider a...@samba.org
Date:   Mon May 5 09:35:36 2014 +0200

Bump version to 1.0.2.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit eb6676b6ed0f25a45fb3a7c04633aa83f378c23d
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 29 11:07:06 2014 +0200

swrap: Fall back to RTLD_NEXT if we can't find libc.

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

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 7f4d72e11bcdfc47d4e4980349a0b0250352e6ca
Author: Jakub Wilk jw...@jwilk.net
Date:   Tue Apr 29 10:55:04 2014 +0200

Fix some typos.

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

Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 CMakeLists.txt  |4 ++--
 ChangeLog   |5 +
 README  |2 +-
 cmake/Modules/DefineCMakeDefaults.cmake |2 +-
 cmake/Modules/DefineInstallationPaths.cmake |2 +-
 src/socket_wrapper.c|   16 
 6 files changed, 18 insertions(+), 13 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6c50c2c..33c2245 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 0)
-set(APPLICATION_VERSION_PATCH 1)
+set(APPLICATION_VERSION_PATCH 2)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
 # Increment AGE. Set REVISION to 0
 #   If the source code was changed, but there were no interface changes:
 # Increment REVISION.
-set(LIBRARY_VERSION 0.0.1)
+set(LIBRARY_VERSION 0.0.2)
 set(LIBRARY_SOVERSION 0)
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is 
checked
diff --git a/ChangeLog b/ChangeLog
index b15ee88..2bb84e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 ChangeLog
 ==
 
+version 1.0.2 (released 2014-05-05)
+  * Fixed memory leaks
+  * Fixed calling open from libc.
+  * Fixed loading libc functions on some platforms.
+
 version 1.0.1 (released 2014-02-04)
   * Added --libs to pkg-config.
   * Added socket_wrapper-config.cmake
diff --git a/README b/README
index 45b1be6..58b5513 100644
--- a/README
+++ b/README
@@ -18,7 +18,7 @@ is analogous to use the IPv4 addresses 127.0.0.ID or IPv6 
addresses
 should always set the default interface. If you listen on INADDR_ANY then it
 will use the default interface to listen on.
 
-Exmaple: 
+Example:
 LD_PRELOAD=libsocket_wrapper.so \
 SOCKET_WRAPPER_DIR=/path/to/socket_dir \
 ./mydaemon
diff --git a/cmake/Modules/DefineCMakeDefaults.cmake 
b/cmake/Modules/DefineCMakeDefaults.cmake
index 22eda6f..a6cd47e 100644
--- a/cmake/Modules/DefineCMakeDefaults.cmake
+++ b/cmake/Modules/DefineCMakeDefaults.cmake
@@ -6,7 +6,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 # Put the include dirs which are in the source or build tree
 # before all other include dirs, so the headers in the sources
-# are prefered over the already installed ones
+# are preferred over the already installed ones
 # since cmake 2.4.1
 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
 
diff --git a/cmake/Modules/DefineInstallationPaths.cmake 
b/cmake/Modules/DefineInstallationPaths.cmake
index 88e08ca..a415f3d 100644
--- a/cmake/Modules/DefineInstallationPaths.cmake
+++ b/cmake/Modules/DefineInstallationPaths.cmake
@@ -104,6 +104,6 @@ else()
   set(PLUGIN_INSTALL_DIR plugins CACHE PATH -)
   set(HTML_INSTALL_DIR doc/HTML CACHE PATH -)
   set(ICON_INSTALL_DIR icons CACHE PATH -)
-  set(SOUND_INSTALL_DIR soudns CACHE PATH -)
+  set(SOUND_INSTALL_DIR sounds CACHE PATH -)
   set(LOCALE_INSTALL_DIR lang CACHE PATH -)
 endif ()
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 3b99814..95643aa 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -393,10 +393,6 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
void *handle = NULL;
int i;
 
-#ifdef HAVE_APPLE
-   return RTLD_NEXT;
-#endif
-
 #ifdef RTLD_DEEPBIND
flags |= RTLD_DEEPBIND;
 #endif
@@ 

[SCM] Socket Wrapper Repository - branch master updated

2014-04-25 Thread Andreas Schneider
The branch, master has been updated
   via  fb8afa1 swrap: Use the loaded libc open() directly.
   via  08ffcf5 echo_srv: Fix possible resouce leaks on error in 
socket_dup().
   via  1d7993b tests: Fix use of tainted string in test_ioctl.
   via  7f10395 cmake: Fix policy check.
   via  f79b7fa cmake: Install cmake config in the correct directory.
  from  d242129 echo_srv: Improve reopening low fds.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit fb8afa1fb23135a8b7635f3f04d69a6c24626319
Author: Andreas Schneider a...@samba.org
Date:   Fri Apr 25 08:37:37 2014 +0200

swrap: Use the loaded libc open() directly.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 08ffcf57e38ca19d9a7535d61951dbd292f39bdb
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 14 21:57:15 2014 +0200

echo_srv: Fix possible resouce leaks on error in socket_dup().

CID: #17217

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 1d7993bd4076bf4b15807fcf340976123817bd0b
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 14 21:54:17 2014 +0200

tests: Fix use of tainted string in test_ioctl.

CID: #17221

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit 7f1039532d24908963a8f104b2c9c4d39998b701
Author: Andreas Schneider a...@samba.org
Date:   Fri Apr 25 13:57:38 2014 +0200

cmake: Fix policy check.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

commit f79b7fa04ba9e6da442e81e46080de5be19f0eac
Author: Andreas Schneider a...@samba.org
Date:   Wed Apr 16 15:44:10 2014 +0200

cmake: Install cmake config in the correct directory.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Michael Adam ob...@samba.org

---

Summary of changes:
 CMakeLists.txt   |2 +-
 src/CMakeLists.txt   |2 +-
 src/socket_wrapper.c |   16 ++--
 tests/echo_srv.c |8 
 tests/test_ioctl.c   |7 ++-
 5 files changed, 30 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9696f4d..6c50c2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,7 +77,7 @@ install(
 ${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config-version.cmake
 ${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config.cmake
 DESTINATION
-${CMAKE_INSTALL_DIR}
+${CMAKE_INSTALL_DIR}/socket_wrapper
 COMPONENT
 devel
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 50ac9ad..95a691f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,7 +23,7 @@ set_target_properties(
 )
 
 # This needs to be at the end
-if (CMAKE_VERSION VERSION_GREATER 2.8.13)
+if (POLICY CMP0026)
 cmake_policy(SET CMP0026 OLD)
 endif()
 get_target_property(SWRAP_LOCATION socket_wrapper LOCATION)
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 5ed9d9f..3b99814 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -608,6 +608,18 @@ static int libc_vopen(const char *pathname, int flags, 
va_list ap)
return fd;
 }
 
+static int libc_open(const char *pathname, int flags, ...)
+{
+   va_list ap;
+   int fd;
+
+   va_start(ap, flags);
+   fd = libc_vopen(pathname, flags, ap);
+   va_end(ap);
+
+   return fd;
+}
+
 static int libc_pipe(int pipefd[2])
 {
swrap_load_lib_function(SWRAP_LIBSOCKET, pipe);
@@ -1707,7 +1719,7 @@ static int swrap_get_pcap_fd(const char *fname)
 
if (fd != -1) return fd;
 
-   fd = open(fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0644);
+   fd = libc_open(fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0644);
if (fd != -1) {
struct swrap_file_hdr file_hdr;
file_hdr.magic  = 0xA1B2C3D4;
@@ -1725,7 +1737,7 @@ static int swrap_get_pcap_fd(const char *fname)
return fd;
}
 
-   fd = open(fname, O_WRONLY|O_APPEND, 0644);
+   fd = libc_open(fname, O_WRONLY|O_APPEND, 0644);
 
return fd;
 }
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index 9102a87..8f8f73f 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -262,6 +262,7 @@ static int socket_dup(int s)
 rc = getsockname(s2, (struct sockaddr *)srv_ss2, srv_ss2_len);
 if (rc == -1) {
 perror(getsockname);
+close(s2);
 return -1;
 }
 
@@ -270,12 +271,14 @@ static int socket_dup(int s)
 rc = getpeername(s2, (struct sockaddr *)cli_ss2, cli_ss2_len);
 if (rc == -1) {
 perror(getpeername);
+close(s2);
 return -1;
 }
 
 if (cli_ss1_len != cli_ss2_len ||
 srv_ss1_len != 

[SCM] Socket Wrapper Repository - branch master updated

2014-04-14 Thread Andreas Schneider
The branch, master has been updated
   via  d242129 echo_srv: Improve reopening low fds.
   via  32c9508 echo_srv: Don't leak client_sock on failures in echo_tcp
   via  4ed4524 tests: Fix an out of bound access.
   via  fab60bb tests: Fix a possible resource leak on error in sockopt 
test.
   via  efd810d swrap: Do not leak memory in swrap_recvmsg_after().
   via  3786fdc echo_srv: Fix resource leak of fd in pidfile().
   via  f165d65 echo_srv: Fix resource leak of s2 on error.
   via  2254633 echo_srv: Fix resource leak of sock.
   via  03726df tests: Fix creating remove_cmd.
   via  2fb2458 tests: Don't leak file description in test_ioctl.
   via  d5a37e5 cmake: Only set policy in cmake 3.0.
  from  af3c688 cmake: Fix configure warning with cmake 3.0.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit d242129438adb6560f9c31383981cad46588bd90
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 11:54:03 2014 +0200

echo_srv: Improve reopening low fds.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit 32c9508b13218d4594c9991d218c93eff1545c86
Author: Jakub Hrozek jhro...@redhat.com
Date:   Thu Apr 10 11:41:31 2014 +0200

echo_srv: Don't leak client_sock on failures in echo_tcp

Signed-off-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Simo Sorce i...@samba.org

commit 4ed4524c5851bbb042caa052f66263b734cf5546
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:49:01 2014 +0200

tests: Fix an out of bound access.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit fab60bb3f61c7dfd1f028a1f9821dab9ad826df7
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:46:18 2014 +0200

tests: Fix a possible resource leak on error in sockopt test.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit efd810d5e12e7b1409542874f5bf29ab0d431a7b
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:42:51 2014 +0200

swrap: Do not leak memory in swrap_recvmsg_after().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit 3786fdc51b18b74411a4d5cca9af2aa3ff250505
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:40:32 2014 +0200

echo_srv: Fix resource leak of fd in pidfile().

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit f165d65e82eaaf139a89cd8b3f58fbe60f8cbecd
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:30:40 2014 +0200

echo_srv: Fix resource leak of s2 on error.

Found by Coverity.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit 2254633003312b1f7462a408480483a2ec58d18a
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:28:46 2014 +0200

echo_srv: Fix resource leak of sock.

Found by Coverity.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit 03726df0861c1a4f85e938a77616ac8780aa4760
Author: Andreas Schneider a...@samba.org
Date:   Thu Apr 10 10:23:14 2014 +0200

tests: Fix creating remove_cmd.

Found by Coverity.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit 2fb245848b786cd8a3d776810f1faf27d8819097
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:34:43 2014 +0200

tests: Don't leak file description in test_ioctl.

Found by Coverity.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com
Reviewed-by: Simo Sorce i...@samba.org

commit d5a37e5661d6dd466cd5dd914300f06406b48f3d
Author: Andreas Schneider a...@samba.org
Date:   Tue Apr 8 09:34:11 2014 +0200

cmake: Only set policy in cmake 3.0.

Signed-off-by: Andreas Schneider a...@samba.org
Reviewed-by: Jakub Hrozek jhro...@redhat.com

---

Summary of changes:
 src/CMakeLists.txt   |4 ++-
 src/socket_wrapper.c |7 ++--
 tests/echo_srv.c |   56 ++---
 tests/test_echo_tcp_socket_options.c |4 +-
 tests/test_echo_tcp_writev_readv.c   |6 ++-
 

[SCM] Socket Wrapper Repository - branch master updated

2014-04-07 Thread Andreas Schneider
The branch, master has been updated
   via  af3c688 cmake: Fix configure warning with cmake 3.0.
   via  c97864a cmake: Create the compile command database by default.
  from  3a6f853 Bump version to 1.0.1.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit af3c688938be9f3a506107c65b964b362d2ef5c4
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 7 12:16:10 2014 +0200

cmake: Fix configure warning with cmake 3.0.

Signed-off-by: Andreas Schneider a...@samba.org

commit c97864a3da2f2554d02e7f1c312af4480f1a7027
Author: Andreas Schneider a...@samba.org
Date:   Mon Apr 7 12:15:51 2014 +0200

cmake: Create the compile command database by default.

Signed-off-by: Andreas Schneider a...@samba.org

---

Summary of changes:
 cmake/Modules/DefineCMakeDefaults.cmake |3 +++
 src/CMakeLists.txt  |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/cmake/Modules/DefineCMakeDefaults.cmake 
b/cmake/Modules/DefineCMakeDefaults.cmake
index 72893c3..22eda6f 100644
--- a/cmake/Modules/DefineCMakeDefaults.cmake
+++ b/cmake/Modules/DefineCMakeDefaults.cmake
@@ -25,3 +25,6 @@ if (NOT CMAKE_BUILD_TYPE)
   Choose the type of build, options are: None Debug Release 
RelWithDebInfo MinSizeRel.
   )
 endif (NOT CMAKE_BUILD_TYPE)
+
+# Create the compile command database for clang by default
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cf70501..449ed54 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,5 +23,6 @@ set_target_properties(
 )
 
 # This needs to be at the end
+cmake_policy(SET CMP0026 OLD)
 get_target_property(SWRAP_LOCATION socket_wrapper LOCATION)
 set(SOCKET_WRAPPER_LOCATION ${SWRAP_LOCATION} PARENT_SCOPE)


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-02-04 Thread Andreas Schneider
The branch, master has been updated
   via  3a6f853 Bump version to 1.0.1.
   via  7d020b0 cmake: Add socket_wrapper-config.cmake.
   via  c792dd7 cmake: Use SOCKET_WRAPPER_LOCATION.
   via  77944cd cmake: Add --libs output for pkg-config.
   via  23631b4 cpack: Don't package the obj directory.
  from  b136de0 src: Add a public socket_wrapper_enabled() function.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 3a6f8539bb6f31878bf7547bf71df63338771adb
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:01:39 2014 +0100

Bump version to 1.0.1.

commit 7d020b04d3f664b746a7aa4ef6add5b56ef94552
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:01:25 2014 +0100

cmake: Add socket_wrapper-config.cmake.

commit c792dd72777453d29da33a7474a6c893216cfd0c
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:43:12 2014 +0100

cmake: Use SOCKET_WRAPPER_LOCATION.

commit 77944cd180a758655e0c7863e19449adeecbf7dc
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 11:56:33 2014 +0100

cmake: Add --libs output for pkg-config.

commit 23631b4c920bdcf14d6151a1f4f89d49b78c2feb
Author: Andreas Schneider a...@samba.org
Date:   Tue Feb 4 12:03:53 2014 +0100

cpack: Don't package the obj directory.

---

Summary of changes:
 CMakeLists.txt |   23 ++-
 CPackConfig.cmake  |2 +-
 ChangeLog  |5 +
 socket_wrapper-config.cmake.in |1 +
 socket_wrapper.pc.cmake|1 +
 src/CMakeLists.txt |4 
 tests/CMakeLists.txt   |4 ++--
 7 files changed, 28 insertions(+), 12 deletions(-)
 create mode 100644 socket_wrapper-config.cmake.in


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 134960a..9696f4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR 1)
 set(APPLICATION_VERSION_MINOR 0)
-set(APPLICATION_VERSION_PATCH 0)
+set(APPLICATION_VERSION_PATCH 1)
 
 set(APPLICATION_VERSION 
${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH})
 
@@ -47,7 +47,18 @@ find_package(Threads)
 include(ConfigureChecks.cmake)
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
+# check subdirectories
+add_subdirectory(src)
+
+if (UNIT_TESTING)
+  find_package(CMocka REQUIRED)
+  include(AddCMockaTest)
+  add_subdirectory(tests)
+endif (UNIT_TESTING)
+
 # pkg-config file
+get_filename_component(SOCKET_WRAPPER_LIB ${SOCKET_WRAPPER_LOCATION} NAME)
+
 configure_file(socket_wrapper.pc.cmake 
${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper.pc @ONLY)
 install(
   FILES
@@ -60,20 +71,14 @@ install(
 
 # cmake config files
 configure_file(socket_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config-version.cmake @ONLY)
+configure_file(socket_wrapper-config.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config.cmake @ONLY)
 install(
 FILES
 ${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config-version.cmake
+${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config.cmake
 DESTINATION
 ${CMAKE_INSTALL_DIR}
 COMPONENT
 devel
 )
 
-# check subdirectories
-add_subdirectory(src)
-
-if (UNIT_TESTING)
-  find_package(CMocka REQUIRED)
-  include(AddCMockaTest)
-  add_subdirectory(tests)
-endif (UNIT_TESTING)
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index e5d1ce8..dc74dfa 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -19,7 +19,7 @@ set(CPACK_PACKAGE_VERSION 
${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO
 
 ### source generator
 set(CPACK_SOURCE_GENERATOR TGZ)
-set(CPACK_SOURCE_IGNORE_FILES 
~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*)
+set(CPACK_SOURCE_IGNORE_FILES 
~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;/obj/;tags;cscope.*)
 set(CPACK_SOURCE_PACKAGE_FILE_NAME 
${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
 
 if (WIN32)
diff --git a/ChangeLog b/ChangeLog
index d2f5d4e..b15ee88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 ChangeLog
 ==
 
+version 1.0.1 (released 2014-02-04)
+  * Added --libs to pkg-config.
+  * Added socket_wrapper-config.cmake
+  * Fixed a bug packaging the obj directory.
+
 version 1.0.0 (released 2014-02-02)
   * Initial release
diff --git a/socket_wrapper-config.cmake.in b/socket_wrapper-config.cmake.in
new file mode 100644
index 000..732d784
--- /dev/null
+++ b/socket_wrapper-config.cmake.in
@@ -0,0 +1 @@
+set(SOCKET_WRAPPER_LIRBARY @LIB_INSTALL_DIR@/@SOCKET_WRAPPER_LIB@)
diff --git a/socket_wrapper.pc.cmake b/socket_wrapper.pc.cmake
index e465733..6dc71f7 100644
--- a/socket_wrapper.pc.cmake
+++ b/socket_wrapper.pc.cmake
@@ -1,3 +1,4 @@
 Name: @APPLICATION_NAME@
 Description: The 

[SCM] Socket Wrapper Repository - branch master updated

2014-02-01 Thread Andreas Schneider
The branch, master has been updated
   via  b136de0 src: Add a public socket_wrapper_enabled() function.
  from  81ece35 src: Fix va arg passing in open().

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit b136de00e4ac63d2d5359782912c89ebf073cbf1
Author: Andreas Schneider a...@cryptomilk.org
Date:   Fri Jan 31 16:59:36 2014 +0100

src: Add a public socket_wrapper_enabled() function.

Reviewed-by: Jeremy Allison j...@samba.org

---

Summary of changes:
 src/socket_wrapper.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 6e38f32..c5b1fdf 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -221,6 +221,7 @@ struct socket_info *sockets;
 
 /* Function prototypes */
 
+bool socket_wrapper_enabled(void);
 void swrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 #ifdef NDEBUG
@@ -806,6 +807,13 @@ static const char *socket_wrapper_dir(void)
return s;
 }
 
+bool socket_wrapper_enabled(void)
+{
+   const char *s = socket_wrapper_dir();
+
+   return s != NULL ? true : false;
+}
+
 static unsigned int socket_wrapper_default_iface(void)
 {
const char *s = getenv(SOCKET_WRAPPER_DEFAULT_IFACE);
@@ -2063,7 +2071,7 @@ static int swrap_socket(int family, int type, int 
protocol)
real_type = ~SOCK_NONBLOCK;
 #endif
 
-   if (socket_wrapper_dir() == NULL) {
+   if (!socket_wrapper_enabled()) {
return libc_socket(family, type, protocol);
}
 


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-29 Thread Andreas Schneider
The branch, master has been updated
   via  81ece35 src: Fix va arg passing in open().
  from  bb4dd1f src: Handle stale fds in dup() and dup2().

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 81ece3533fa99b48b428870042246fb8dfdf36ad
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 29 08:41:15 2014 +0100

src: Fix va arg passing in open().

Reviewed-by: Stefan Metzmacher me...@samba.org

---

Summary of changes:
 src/socket_wrapper.c |   22 +++---
 1 files changed, 15 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 353a9a5..6e38f32 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -593,11 +593,18 @@ static int libc_listen(int sockfd, int backlog)
return swrap.fns.libc_listen(sockfd, backlog);
 }
 
-static int libc_open(const char *pathname, int flags, mode_t mode)
+static int libc_vopen(const char *pathname, int flags, va_list ap)
 {
+   long int mode = 0;
+   int fd;
+
swrap_load_lib_function(SWRAP_LIBC, open);
 
-   return swrap.fns.libc_open(pathname, flags, mode);
+   mode = va_arg(ap, long int);
+
+   fd = swrap.fns.libc_open(pathname, flags, (mode_t)mode);
+
+   return fd;
 }
 
 static int libc_pipe(int pipefd[2])
@@ -2630,11 +2637,11 @@ int listen(int s, int backlog)
  *   OPEN
  ***/
 
-static int swrap_open(const char *pathname, int flags, mode_t mode)
+static int swrap_vopen(const char *pathname, int flags, va_list ap)
 {
int ret;
 
-   ret = libc_open(pathname, flags, mode);
+   ret = libc_vopen(pathname, flags, ap);
if (ret != -1) {
/*
 * There are methods for closing descriptors (libc-internal code
@@ -2649,13 +2656,14 @@ static int swrap_open(const char *pathname, int flags, 
mode_t mode)
 
 int open(const char *pathname, int flags, ...)
 {
-   mode_t mode;
va_list ap;
+   int fd;
 
va_start(ap, flags);
-   mode = va_arg(ap, mode_t);
+   fd = swrap_vopen(pathname, flags, ap);
va_end(ap);
-   return swrap_open(pathname, flags, mode);
+
+   return fd;
 }
 
 /


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-28 Thread Andreas Schneider
The branch, master has been updated
   via  bb4dd1f src: Handle stale fds in dup() and dup2().
   via  9c03935 src: Add timerfd_create() to handle stale fds.
   via  f850820 src: Add eventfd() to handle stale fds.
   via  dc00232 src: Add signalfd() to handle stale fds.
   via  95520f6 src: Add socketpair() to handle stale fds.
   via  ea45102 src: Add pipe() to handle stale fds.
   via  0627527 src: Check for stale fds in swrap_accept().
   via  5acfcfe src: Check for stale fds in swrap_socket().
   via  05cb607 src: Handle stale fds in swrap_recvmsg_after().
   via  3ab00f5 src: Handle stale fds in swrap_sendmsg_after().
   via  de94be7 src: Try to recover when reading from a fd returns ENOTSOCK.
   via  27b2055 src: Try to recover when writing to fd returns ENOTSOCK.
   via  1462a69 src: Try to recover when sockets are closed elsewhere.
   via  019e4f3 src: Use swrap_recvmsg_(before|after) for swrap_readv().
   via  e200ed8 Update TODO.
   via  553d8a2 Update ChangeLog.
  from  bede01d Update TODO.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit bb4dd1f1733fe80493e3f165f206df675fb32beb
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 14:10:53 2014 +0100

src: Handle stale fds in dup() and dup2().

Reviewed-by: Stefan Metzmacher me...@samba.org

commit 9c03935fc0abb033a32683f5e9d8bd6b2136b8fd
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 13:48:52 2014 +0100

src: Add timerfd_create() to handle stale fds.

Reviewed-by: Stefan Metzmacher me...@samba.org

commit f8508200e90048523fc7c78467dc8e565744f7f9
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 13:42:38 2014 +0100

src: Add eventfd() to handle stale fds.

Reviewed-by: Stefan Metzmacher me...@samba.org

commit dc0023293292d5247a5984e78fc10de9399da5f5
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 13:33:23 2014 +0100

src: Add signalfd() to handle stale fds.

Reviewed-by: Stefan Metzmacher me...@samba.org

commit 95520f672f3cbf311b503d61e2ac9e2a22d209e9
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 13:20:20 2014 +0100

src: Add socketpair() to handle stale fds.

Reviewed-by: Stefan Metzmacher me...@samba.org

commit ea45102993c0800a8a62137da09dbb2787834ed4
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 13:15:34 2014 +0100

src: Add pipe() to handle stale fds.

Reviewed-by: Stefan Metzmacher me...@samba.org

commit 0627527da3abbafdb6f171dbdbc3b719a96a2b62
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 13:10:01 2014 +0100

src: Check for stale fds in swrap_accept().

Reviewed-by: Stefan Metzmacher me...@samba.org

commit 5acfcfea50ce2dd1b0388c33c849ce19007cf77b
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 10:33:36 2014 +0100

src: Check for stale fds in swrap_socket().

Reviewed-by: Stefan Metzmacher me...@samba.org

commit 05cb607f08321b1680e51cb3bb33222922f46401
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 11:34:03 2014 +0100

src: Handle stale fds in swrap_recvmsg_after().

Reviewed-by: Stefan Metzmacher me...@samba.org

commit 3ab00f5deaefa2dbdac9ba71841e178a78988dd2
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 28 11:30:20 2014 +0100

src: Handle stale fds in swrap_sendmsg_after().

Reviewed-by: Stefan Metzmacher me...@samba.org

commit de94be7e4b83283f3b46320706fef19b8203b52c
Author: Nalin Dahyabhai na...@dahyabhai.net
Date:   Tue Jan 28 11:25:40 2014 +0100

src: Try to recover when reading from a fd returns ENOTSOCK.

When attempting to read from a descriptor, if an underlying
autobind fails because it's not a socket, stop intercepting uses of that
descriptor.

Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 27b2055291caf67c6a23e829f596cc6751ce5aad
Author: Nalin Dahyabhai na...@dahyabhai.net
Date:   Tue Jan 28 11:24:27 2014 +0100

src: Try to recover when writing to fd returns ENOTSOCK.

When attempting to write to a descriptor, if an underlying autobind
fails because it's not a socket, stop intercepting uses of that
descriptor.

Reviewed-by: Andreas Schneider a...@samba.org
Reviewed-by: Stefan Metzmacher me...@samba.org

commit 1462a69c0a96605081f9f1c0dc5bb54aa98aa202
Author: Nalin Dahyabhai na...@dahyabhai.net
Date:   Tue Jan 28 11:22:26 2014 +0100

src: Try to recover when sockets are closed elsewhere.

There are methods for closing descriptors (libc-internal code paths,
direct syscalls) which close descriptors in ways that we
can't intercept, so try to recover when we notice that that's happened:
  * If we see a descriptor being handed back from open() that we thought
was a socket, stop 

[SCM] Socket Wrapper Repository - branch master updated

2014-01-24 Thread Andreas Schneider
The branch, master has been updated
   via  bede01d Update TODO.
  from  93b794d src: Fix warnings on Solaris.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit bede01de975cbde68d73cbf49d4e7351e3dc4228
Author: Andreas Schneider a...@samba.org
Date:   Fri Jan 24 10:39:57 2014 +0100

Update TODO.

---

Summary of changes:
 TODO |   22 +++---
 1 files changed, 19 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/TODO b/TODO
index f4b8a12..2ce46ff 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,19 @@
-* Add recvmsg() with support for IP_PKTINFO
-* We might need serialization so we don't call wrapper symbols recursively.
-* Add logging for debug.
+TODO
+=
+
+Library:
+-
+
+* Add IP_PKTINFO support for sendmsg/recvmsg.
+* Add support for fd passing in sendmsg/recvmsg.
+  Scenario:
+  We accept a connection from a client and need to pass the fd to another
+  child we forked. socket_wrapper then needs to send the 'struct socket_info'
+  to the child first and set it up there.
+
+Testing:
+-
+* Add a test to make sure detect stale file descriptors.
+* Add a test for sento() to broadcast 255.255.255.255.
+* Add a test to check that read/readv/send/ only work on connected sockets.
+* Add unit tests for conversion functions like convert_in_un_remote().


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-21 Thread Andreas Schneider
The branch, master has been updated
   via  d7e31ed src: Fix build on Solaris.
   via  ff36996 cmake: Check for HAVE_STRUCT_MSGHDR_MSG_CONTROL.
   via  803820f cmake: Fix HAVE_STRUCT_SOCKADDR_SA_LEN detection.
   via  7f5ead0 src: Fix build warnings on FreeBSD.
  from  980a30d cmake: Add cmake config version script.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit d7e31eddf4016eb3e12151d93d0372e5a7aabef3
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:34:55 2014 +0100

src: Fix build on Solaris.

commit ff36996f62e7dc9e713ceab823d7d19d8cd396a8
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:27:03 2014 +0100

cmake: Check for HAVE_STRUCT_MSGHDR_MSG_CONTROL.

commit 803820ffe778be5af68957bc46532e7c50243c9f
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:26:44 2014 +0100

cmake: Fix HAVE_STRUCT_SOCKADDR_SA_LEN detection.

commit 7f5ead0210c1b02f81dc16c627893502e7aabb71
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:17:01 2014 +0100

src: Fix build warnings on FreeBSD.

---

Summary of changes:
 ConfigureChecks.cmake |3 +-
 config.h.cmake|5 +++
 src/socket_wrapper.c  |   66 +---
 3 files changed, 47 insertions(+), 27 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 995f8ce..2d8e690 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -82,7 +82,8 @@ endif (UNIX)
 set(SWRAP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL 
socket_wrapper required system libraries)
 
 # STRUCT MEMBERS
-check_struct_has_member(struct sockaddr sa_len sys/socket.h netinet/in.h 
HAVE_STRUCT_SOCKADDR_SA_LEN)
+check_struct_has_member(struct sockaddr sa_len 
sys/types.h;sys/socket.h;netinet/in.h HAVE_STRUCT_SOCKADDR_SA_LEN)
+check_struct_has_member(struct msghdr msg_control sys/types.h;sys/socket.h 
HAVE_STRUCT_MSGHDR_MSG_CONTROL)
 
 # PROTOTYPES
 check_prototype_definition(gettimeofday
diff --git a/config.h.cmake b/config.h.cmake
index 4f912bd..63bbdb4 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -16,6 +16,10 @@
 
 #cmakedefine HAVE_SYS_FILIO_H 1
 
+/ STRUCT MEMBERS */
+
+#cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1
+#cmakedefine HAVE_STRUCT_MSGHDR_MSG_CONTROL 1
 
 /*** FUNCTIONS ***/
 
@@ -30,6 +34,7 @@
 #cmakedefine HAVE_GETTIMEOFDAY_TZ_VOID 1
 
 /*** DATA TYPES***/
+
 #cmakedefine SIZEOF_PID_T @SIZEOF_PID_T@
 
 / OPTIONS /
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index b85021a..205d457 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -2668,7 +2668,7 @@ static ssize_t swrap_sendmsg_before(int fd,
break;
}
 
-   for (i=0; i  msg-msg_iovlen; i++) {
+   for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
size_t nlen;
nlen = len + msg-msg_iov[i].iov_len;
if (nlen  SOCKET_MAX_PACKET) {
@@ -2767,7 +2767,7 @@ static void swrap_sendmsg_after(struct socket_info *si,
saved_errno = EHOSTUNREACH;
}
 
-   for (i=0; i  msg-msg_iovlen; i++) {
+   for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
avail += msg-msg_iov[i].iov_len;
}
 
@@ -2785,7 +2785,7 @@ static void swrap_sendmsg_after(struct socket_info *si,
return;
}
 
-   for (i=0; i  msg-msg_iovlen; i++) {
+   for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
size_t this_time = MIN(remain, msg-msg_iov[i].iov_len);
memcpy(buf + ofs,
   msg-msg_iov[i].iov_base,
@@ -2843,7 +2843,7 @@ static int swrap_recvmsg_before(int fd,
break;
}
 
-   for (i=0; i  msg-msg_iovlen; i++) {
+   for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
size_t nlen;
nlen = len + msg-msg_iov[i].iov_len;
if (nlen  SOCKET_MAX_PACKET) {
@@ -2902,7 +2902,7 @@ static int swrap_recvmsg_after(struct socket_info *si,
saved_errno = EHOSTUNREACH;
}
 
-   for (i=0; i  msg-msg_iovlen; i++) {
+   for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
avail += msg-msg_iov[i].iov_len;
}
 
@@ -2925,7 +2925,7 @@ static int swrap_recvmsg_after(struct socket_info *si,
return -1;
}
 
-   for (i=0; i  msg-msg_iovlen; i++) {
+   for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
size_t this_time = MIN(remain, msg-msg_iov[i].iov_len);

[SCM] Socket Wrapper Repository - branch master updated

2014-01-21 Thread Andreas Schneider
The branch, master has been updated
   via  e5df09b cmake: Only build test_sendmsg_recvmsg_fd if we have 
msg_control.
   via  b6161d0 src: Fix setting the temp iovec.
  from  d7e31ed src: Fix build on Solaris.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit e5df09bb2b7aaeef0d3127ad85371eab78702060
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:52:06 2014 +0100

cmake: Only build test_sendmsg_recvmsg_fd if we have msg_control.

commit b6161d0d94822608053de73b12600661daefabc7
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:45:05 2014 +0100

src: Fix setting the temp iovec.

---

Summary of changes:
 src/socket_wrapper.c |   18 +-
 tests/CMakeLists.txt |7 +--
 2 files changed, 14 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 205d457..2edc8df 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3342,10 +3342,8 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, 
int flags)
return libc_recvmsg(s, omsg, flags);
}
 
-   rc = swrap_recvmsg_before(s, si, omsg, tmp);
-   if (rc == -1) {
-   return -1;
-   }
+   tmp.iov_base = NULL;
+   tmp.iov_len = 0;
 
ZERO_STRUCT(msg);
msg.msg_name = (struct sockaddr *)from_addr; /* optional address */
@@ -3358,8 +3356,10 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, 
int flags)
msg.msg_flags = omsg-msg_flags;   /* flags on received message 
*/
 #endif
 
-   tmp.iov_base = omsg-msg_iov;
-   tmp.iov_len = omsg-msg_iovlen;
+   rc = swrap_recvmsg_before(s, si, msg, tmp);
+   if (rc == -1) {
+   return -1;
+   }
 
ret = libc_recvmsg(s, msg, flags);
 
@@ -3395,6 +3395,9 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
return libc_sendmsg(s, omsg, flags);
}
 
+   tmp.iov_base = NULL;
+   tmp.iov_len = 0;
+
ZERO_STRUCT(msg);
msg.msg_name = omsg-msg_name; /* optional address */
msg.msg_namelen = omsg-msg_namelen;   /* size of address */
@@ -3406,9 +3409,6 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
msg.msg_flags = omsg-msg_flags;   /* flags on received message 
*/
 #endif
 
-   tmp.iov_base = omsg-msg_iov;
-   tmp.iov_len = omsg-msg_iovlen;
-
ret = swrap_sendmsg_before(s, si, msg, tmp, un_addr, to_un, to, 
bcast);
if (ret == -1) return -1;
 
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c626c02..53d458c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -25,8 +25,11 @@ set(SWRAP_TESTS
 test_echo_tcp_writev_readv
 test_echo_udp_sendto_recvfrom
 test_echo_udp_send_recv
-test_echo_udp_sendmsg_recvmsg
-test_sendmsg_recvmsg_fd)
+test_echo_udp_sendmsg_recvmsg)
+
+if (HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+set(SWRAP_TESTS ${SWRAP_TESTS} test_sendmsg_recvmsg_fd)
+endif (HAVE_STRUCT_MSGHDR_MSG_CONTROL)
 
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
 add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-21 Thread Andreas Schneider
The branch, master has been updated
   via  b7ec347 src: Case pid_t to an int in SWRAP_LOG.
  from  e5df09b cmake: Only build test_sendmsg_recvmsg_fd if we have 
msg_control.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit b7ec347fca6b11a2297c4d637ec8d8d7b0aebfc6
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 09:57:47 2014 +0100

src: Case pid_t to an int in SWRAP_LOG.

---

Summary of changes:
 src/socket_wrapper.c |   24 
 1 files changed, 8 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 2edc8df..c5b94fb 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -95,14 +95,6 @@ enum swrap_dbglvl_e {
 #define MIN(a,b) ((a)(b)?(a):(b))
 #endif
 
-#if SIZEOF_PID_T == 8
-# define SPRIpid PRIu64
-#elif SIZEOF_UID_T == 4
-# define SPRIpid PRIu32
-#else
-# define SPRIpid %d  /* Sane default for most platforms */
-#endif /* SIZEOF_UID_T */
-
 #ifndef ZERO_STRUCT
 #define ZERO_STRUCT(x) memset((char *)(x), 0, sizeof(x))
 #endif
@@ -249,23 +241,23 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl, const 
char *format, ...)
switch (dbglvl) {
case SWRAP_LOG_ERROR:
fprintf(stderr,
-   SWRAP_ERROR(SPRIpid): %s\n,
-   getpid(), buffer);
+   SWRAP_ERROR(%d): %s\n,
+   (int)getpid(), buffer);
break;
case SWRAP_LOG_WARN:
fprintf(stderr,
-   SWRAP_WARN(SPRIpid): %s\n,
-   getpid(), buffer);
+   SWRAP_WARN(%d): %s\n,
+   (int)getpid(), buffer);
break;
case SWRAP_LOG_DEBUG:
fprintf(stderr,
-   SWRAP_DEBUG(SPRIpid): %s\n,
-   getpid(), buffer);
+   SWRAP_DEBUG(%d): %s\n,
+   (int)getpid(), buffer);
break;
case SWRAP_LOG_TRACE:
fprintf(stderr,
-   SWRAP_TRACE(SPRIpid): %s\n,
-   getpid(), buffer);
+   SWRAP_TRACE(%d): %s\n,
+   (int)getpid(), buffer);
break;
}
}


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-21 Thread Andreas Schneider
The branch, master has been updated
   via  1c15030 src: Initialize sockaddr_un.
   via  07ece11 src: Make sure the memory is zeroed.
  from  b7ec347 src: Case pid_t to an int in SWRAP_LOG.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 1c15030a8b35960c42a0579839fd382b5a38af48
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 12:24:54 2014 +0100

src: Initialize sockaddr_un.

Fixes a valgrind warning.

commit 07ece110085e3846c40e0e7408c591546ed23e4a
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 12:17:42 2014 +0100

src: Make sure the memory is zeroed.

---

Summary of changes:
 src/socket_wrapper.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index c5b94fb..64b76e0 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1463,7 +1463,10 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
}
 
base = (uint8_t *)malloc(alloc_len);
-   if (!base) return NULL;
+   if (base == NULL) {
+   return NULL;
+   }
+   memset(base, 0x0, alloc_len);
 
buf = base;
 
@@ -3376,7 +3379,7 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
 {
struct msghdr msg;
struct iovec tmp;
-   struct sockaddr_un un_addr;
+   struct sockaddr_un un_addr = {0};
const struct sockaddr_un *to_un = NULL;
const struct sockaddr *to = NULL;
ssize_t ret;


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-21 Thread Andreas Schneider
The branch, master has been updated
   via  93b794d src: Fix warnings on Solaris.
  from  1c15030 src: Initialize sockaddr_un.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 93b794d0f7a6b2661820002c853d1f519b1ae1ef
Author: Andreas Schneider a...@samba.org
Date:   Tue Jan 21 13:01:39 2014 +0100

src: Fix warnings on Solaris.

---

Summary of changes:
 src/socket_wrapper.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 64b76e0..2ea35a9 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -2781,7 +2781,7 @@ static void swrap_sendmsg_after(struct socket_info *si,
}
 
for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
-   size_t this_time = MIN(remain, msg-msg_iov[i].iov_len);
+   size_t this_time = MIN(remain, (size_t)msg-msg_iov[i].iov_len);
memcpy(buf + ofs,
   msg-msg_iov[i].iov_base,
   this_time);
@@ -2921,7 +2921,7 @@ static int swrap_recvmsg_after(struct socket_info *si,
}
 
for (i = 0; i  (size_t)msg-msg_iovlen; i++) {
-   size_t this_time = MIN(remain, msg-msg_iov[i].iov_len);
+   size_t this_time = MIN(remain, (size_t)msg-msg_iov[i].iov_len);
memcpy(buf + ofs,
   msg-msg_iov[i].iov_base,
   this_time);
@@ -3379,7 +3379,7 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
 {
struct msghdr msg;
struct iovec tmp;
-   struct sockaddr_un un_addr = {0};
+   struct sockaddr_un un_addr;
const struct sockaddr_un *to_un = NULL;
const struct sockaddr *to = NULL;
ssize_t ret;
@@ -3390,6 +3390,8 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
return libc_sendmsg(s, omsg, flags);
}
 
+   ZERO_STRUCT(un_addr);
+
tmp.iov_base = NULL;
tmp.iov_len = 0;
 
@@ -3432,7 +3434,7 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
}
 
for (i = 0; i  (size_t)msg.msg_iovlen; i++) {
-   size_t this_time = MIN(remain, msg.msg_iov[i].iov_len);
+   size_t this_time = MIN(remain, 
(size_t)msg.msg_iov[i].iov_len);
memcpy(buf + ofs,
   msg.msg_iov[i].iov_base,
   this_time);
@@ -3531,7 +3533,7 @@ static ssize_t swrap_readv(int s, const struct iovec 
*vector, int count)
}
 
for (i=0; i  count; i++) {
-   size_t this_time = MIN(remain, vector[i].iov_len);
+   size_t this_time = MIN(remain, 
(size_t)vector[i].iov_len);
memcpy(buf + ofs,
   vector[i].iov_base,
   this_time);


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-20 Thread Andreas Schneider
The branch, master has been updated
   via  98a05e5 tests: Add sendmsg_recvmsg_fd test.
   via  c29f759 tests: Add test_echo_udp_sendmsg_recvmsg.
   via  ae88bf8 swrap: Implement recvmsg().
   via  6d328a2 swrap: Fix DGRAM in swrap_recvmsg(before|after).
   via  11b077a swrap: Use swrap_recvmsg_* in swrap_read().
   via  7e5f1f5 swrap: Use swrap_recvmsg_* in swrap_recv().
   via  35bcc16 swrap: Use swrap_recvmsg_* in swrap_recvfrom().
   via  e11fd61 swrap: Add swrap_recvmsg_after().
   via  76ff3d4 swrap: Add swrap_recvmsg_before().
  from  e9de990 echo_srv: Add fd duplication and test it works.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 98a05e5b2ca9e3ac6ad22ae5c5bbb754ab8f6641
Author: Jakub Hrozek jhro...@redhat.com
Date:   Mon Jan 20 13:45:58 2014 +0100

tests: Add sendmsg_recvmsg_fd test.

commit c29f7596696ec67fdf9ad2c860362bd0fc1516ae
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 20 18:36:47 2014 +0100

tests: Add test_echo_udp_sendmsg_recvmsg.

commit ae88bf8a6894df56f0be77610d47a0f3730c8804
Author: Andreas Schneider a...@samba.org
Date:   Wed Jan 15 16:55:20 2014 +0100

swrap: Implement recvmsg().

commit 6d328a234f8e5557a2e6898aff4bc92ace4b8b01
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 24 13:06:40 2013 +0100

swrap: Fix DGRAM in swrap_recvmsg(before|after).

commit 11b077a674fa146b2744f6cd4c5f947e7d1f531d
Author: Stefan Metzmacher me...@samba.org
Date:   Tue Dec 24 11:37:29 2013 +0100

swrap: Use swrap_recvmsg_* in swrap_read().

commit 7e5f1f5abc66dff745cb4cc2bcf187189fa19d12
Author: Stefan Metzmacher me...@samba.org
Date:   Tue Dec 24 11:35:16 2013 +0100

swrap: Use swrap_recvmsg_* in swrap_recv().

commit 35bcc16674140864e2816cb6a5a536afaed9e597
Author: Stefan Metzmacher me...@samba.org
Date:   Tue Dec 24 11:31:50 2013 +0100

swrap: Use swrap_recvmsg_* in swrap_recvfrom().

commit e11fd61be098aed3ed2b16e6ed9fe12e6a8f2b13
Author: Stefan Metzmacher me...@samba.org
Date:   Tue Dec 24 11:28:29 2013 +0100

swrap: Add swrap_recvmsg_after().

commit 76ff3d42b48c0d25d505496d3e90f50fe7d6f9db
Author: Stefan Metzmacher me...@samba.org
Date:   Tue Dec 24 11:28:13 2013 +0100

swrap: Add swrap_recvmsg_before().

---

Summary of changes:
 src/socket_wrapper.c   |  349 ++--
 tests/CMakeLists.txt   |4 +-
 ..._recvfrom.c = test_echo_udp_sendmsg_recvmsg.c} |  111 +++
 tests/test_sendmsg_recvmsg_fd.c|  116 +++
 4 files changed, 487 insertions(+), 93 deletions(-)
 copy tests/{test_echo_udp_sendto_recvfrom.c = 
test_echo_udp_sendmsg_recvmsg.c} (71%)
 create mode 100644 tests/test_sendmsg_recvmsg_fd.c


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index dc6ffb1..b85021a 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -313,6 +313,7 @@ struct swrap_libc_fns {
 int flags,
 struct sockaddr *src_addr,
 socklen_t *addrlen);
+   int (*libc_recvmsg)(int sockfd, const struct msghdr *msg, int flags);
int (*libc_send)(int sockfd, const void *buf, size_t len, int flags);
int (*libc_sendmsg)(int sockfd, const struct msghdr *msg, int flags);
int (*libc_sendto)(int sockfd,
@@ -603,6 +604,13 @@ static int libc_recvfrom(int sockfd,
return swrap.fns.libc_recvfrom(sockfd, buf, len, flags, src_addr, 
addrlen);
 }
 
+static int libc_recvmsg(int sockfd, struct msghdr *msg, int flags)
+{
+   swrap_load_lib_function(SWRAP_LIBSOCKET, recvmsg);
+
+   return swrap.fns.libc_recvmsg(sockfd, msg, flags);
+}
+
 static int libc_send(int sockfd, const void *buf, size_t len, int flags)
 {
swrap_load_lib_function(SWRAP_LIBSOCKET, send);
@@ -2814,6 +2822,168 @@ static void swrap_sendmsg_after(struct socket_info *si,
errno = saved_errno;
 }
 
+static int swrap_recvmsg_before(int fd,
+   struct socket_info *si,
+   struct msghdr *msg,
+   struct iovec *tmp_iov)
+{
+   size_t i, len = 0;
+   ssize_t ret;
+
+   (void)fd; /* unused */
+
+   switch (si-type) {
+   case SOCK_STREAM:
+   if (!si-connected) {
+   errno = ENOTCONN;
+   return -1;
+   }
+
+   if (msg-msg_iovlen == 0) {
+   break;
+   }
+
+   for (i=0; i  msg-msg_iovlen; i++) {
+   size_t nlen;
+   nlen = len + msg-msg_iov[i].iov_len;
+   if (nlen  SOCKET_MAX_PACKET) {
+   break;
+   }
+  

[SCM] Socket Wrapper Repository - branch master updated

2014-01-20 Thread Andreas Schneider
The branch, master has been updated
   via  d78b20d Improve the README.
  from  98a05e5 tests: Add sendmsg_recvmsg_fd test.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit d78b20d999b0b26f9119dcd6430cbea595756f07
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 20 23:31:10 2014 +0100

Improve the README.

---

Summary of changes:
 README |   29 -
 1 files changed, 20 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/README b/README
index af94f6b..45b1be6 100644
--- a/README
+++ b/README
@@ -1,18 +1,29 @@
 Socket wrapper library
 ===
 
-This library passes all socket communication over unix domain sockets if the
-environment variable SOCKET_WRAPPER_DIR is set.
+This library makes possible to run several instances of the full software stack
+on the same machine and perform locally functional testing of complex network
+configurations. It passes all socket communication over unix domain sockets.
 
-To use socket_wrapper the following environment variables need to be set:
-LD_PRELOAD=libsocket_wrapper.so
-SOCKET_WRAPPER_DIR=/path/to/socket_dir
+The user defines a directory where to put all the unix sockets using the
+envionment variable SOCKET_WRAPPER_DIR=/path/to/socket_dir. When a server
+opens a port or a client wants to connect, socket_wrapper will translate IP
+addresses to a special socket_wrapper name and look for the relevant unix
+socket in the SOCKET_WRAPPER_DIR.
 
-On MacOSX it is:
-DYLD_INSERT_LIBRARIES=libsocket_wrapper.dylib
-SOCKET_WRAPPER_DIR=/path/to/socket_dir
+Additionally, the default interface to be used by an application is defined
+with SOCKET_WRAPPER_DEFAULT_IFACE=ID where ID is between 2 and 254. This
+is analogous to use the IPv4 addresses 127.0.0.ID or IPv6 addresses
+fd00::5357:5fIDx (where IDx is a hexadecimal presentation of ID). You
+should always set the default interface. If you listen on INADDR_ANY then it
+will use the default interface to listen on.
 
-The following environment variables could be set:
+Exmaple: 
+LD_PRELOAD=libsocket_wrapper.so \
+SOCKET_WRAPPER_DIR=/path/to/socket_dir \
+./mydaemon
+
+The following environment variables could also be set:
 
 SOCKET_WRAPPER_DEFAULT_IFACE
 The default interface to use if nothing has


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2014-01-20 Thread Andreas Schneider
The branch, master has been updated
   via  980a30d cmake: Add cmake config version script.
   via  de86e64 cmake: Add pkg-config file.
  from  d78b20d Improve the README.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 980a30d0a96ca22ee47aa60eb8504c77eae232b5
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 20 23:34:54 2014 +0100

cmake: Add cmake config version script.

commit de86e64888556301ea5fbed99da887772640a58c
Author: Andreas Schneider a...@samba.org
Date:   Mon Jan 20 23:33:18 2014 +0100

cmake: Add pkg-config file.

---

Summary of changes:
 CMakeLists.txt  |   22 
 cmake/Modules/DefineInstallationPaths.cmake |   29 +++---
 socket_wrapper-config-version.cmake.in  |   11 ++
 socket_wrapper.pc.cmake |3 ++
 4 files changed, 53 insertions(+), 12 deletions(-)
 create mode 100644 socket_wrapper-config-version.cmake.in
 create mode 100644 socket_wrapper.pc.cmake


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50674ba..134960a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,28 @@ find_package(Threads)
 include(ConfigureChecks.cmake)
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
+# pkg-config file
+configure_file(socket_wrapper.pc.cmake 
${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper.pc @ONLY)
+install(
+  FILES
+${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper.pc
+  DESTINATION
+${LIB_INSTALL_DIR}/pkgconfig
+  COMPONENT
+pkgconfig
+)
+
+# cmake config files
+configure_file(socket_wrapper-config-version.cmake.in 
${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config-version.cmake @ONLY)
+install(
+FILES
+${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config-version.cmake
+DESTINATION
+${CMAKE_INSTALL_DIR}
+COMPONENT
+devel
+)
+
 # check subdirectories
 add_subdirectory(src)
 
diff --git a/cmake/Modules/DefineInstallationPaths.cmake 
b/cmake/Modules/DefineInstallationPaths.cmake
index d857871..88e08ca 100644
--- a/cmake/Modules/DefineInstallationPaths.cmake
+++ b/cmake/Modules/DefineInstallationPaths.cmake
@@ -1,15 +1,4 @@
-if (WIN32)
-  # Same same
-  set(BIN_INSTALL_DIR bin CACHE PATH -)
-  set(SBIN_INSTALL_DIR . CACHE PATH -)
-  set(LIB_INSTALL_DIR lib CACHE PATH -)
-  set(INCLUDE_INSTALL_DIR include CACHE PATH -)
-  set(PLUGIN_INSTALL_DIR plugins CACHE PATH -)
-  set(HTML_INSTALL_DIR doc/HTML CACHE PATH -)
-  set(ICON_INSTALL_DIR . CACHE PATH -)
-  set(SOUND_INSTALL_DIR . CACHE PATH -)
-  set(LOCALE_INSTALL_DIR lang CACHE PATH -)
-elseif (UNIX OR OS2)
+if (UNIX OR OS2)
   IF (NOT APPLICATION_NAME)
 MESSAGE(STATUS ${PROJECT_NAME} is used as APPLICATION_NAME)
 SET(APPLICATION_NAME ${PROJECT_NAME})
@@ -58,6 +47,10 @@ elseif (UNIX OR OS2)
 CACHE PATH The subdirectory to the header prefix (default prefix/include)
   )
 
+  set(CMAKE_INSTALL_DIR
+${LIB_INSTALL_DIR}/cmake
+CACHE PATH The subdirectory to install cmake config files)
+
   SET(DATA_INSTALL_DIR
 ${DATA_INSTALL_PREFIX}
 CACHE PATH The parent directory where applications can install their data 
(default prefix/share/${APPLICATION_NAME})
@@ -101,4 +94,16 @@ elseif (UNIX OR OS2)
 ${SHARE_INSTALL_PREFIX}/info
 CACHE PATH The ${APPLICATION_NAME} info install dir (default prefix/info)
   )
+else()
+  # Same same
+  set(BIN_INSTALL_DIR bin CACHE PATH -)
+  set(SBIN_INSTALL_DIR sbin CACHE PATH -)
+  set(LIB_INSTALL_DIR lib${LIB_SUFFIX} CACHE PATH -)
+  set(INCLUDE_INSTALL_DIR include CACHE PATH -)
+  set(CMAKE_INSTALL_DIR CMake CACHE PATH -)
+  set(PLUGIN_INSTALL_DIR plugins CACHE PATH -)
+  set(HTML_INSTALL_DIR doc/HTML CACHE PATH -)
+  set(ICON_INSTALL_DIR icons CACHE PATH -)
+  set(SOUND_INSTALL_DIR soudns CACHE PATH -)
+  set(LOCALE_INSTALL_DIR lang CACHE PATH -)
 endif ()
diff --git a/socket_wrapper-config-version.cmake.in 
b/socket_wrapper-config-version.cmake.in
new file mode 100644
index 000..98f292c
--- /dev/null
+++ b/socket_wrapper-config-version.cmake.in
@@ -0,0 +1,11 @@
+set(PACKAGE_VERSION @APPLICATION_VERSION@)
+
+# Check whether the requested PACKAGE_FIND_VERSION is compatible
+if(${PACKAGE_VERSION} VERSION_LESS ${PACKAGE_FIND_VERSION})
+set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+set(PACKAGE_VERSION_COMPATIBLE TRUE)
+if (${PACKAGE_VERSION} VERSION_EQUAL ${PACKAGE_FIND_VERSION})
+set(PACKAGE_VERSION_EXACT TRUE)
+endif()
+endif()
diff --git a/socket_wrapper.pc.cmake b/socket_wrapper.pc.cmake
new file mode 100644
index 000..e465733
--- /dev/null
+++ b/socket_wrapper.pc.cmake
@@ -0,0 +1,3 @@
+Name: @APPLICATION_NAME@
+Description: The socket_wrapper library
+Version: @APPLICATION_VERSION@


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2013-12-24 Thread Andreas Schneider
The branch, master has been updated
   via  e9de990 echo_srv: Add fd duplication and test it works.
  from  b448961 test: Fix getsockopt on Solaris.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit e9de99075cb4361bdaa102851541b14681d8
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 24 11:02:27 2013 +0100

echo_srv: Add fd duplication and test it works.

---

Summary of changes:
 tests/echo_srv.c |  210 -
 1 files changed, 206 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index a207419..70d9a84 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -37,6 +37,10 @@
 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
 #endif
 
+#ifndef ZERO_STRUCT
+#define ZERO_STRUCT(x) memset((char *)(x), 0, sizeof(x))
+#endif
+
 struct echo_srv_opts {
 int port;
 int socktype;
@@ -187,20 +191,218 @@ static int setup_srv(struct echo_srv_opts *opts, int 
*_sock)
 return 0;
 }
 
+static int socket_dup(int s)
+{
+struct sockaddr_storage cli_ss1;
+socklen_t cli_ss1_len;
+struct sockaddr_storage srv_ss1;
+socklen_t srv_ss1_len;
+
+struct sockaddr_storage cli_ss2;
+socklen_t cli_ss2_len;
+struct sockaddr_storage srv_ss2;
+socklen_t srv_ss2_len;
+
+struct sockaddr_storage cli_ss3;
+socklen_t cli_ss3_len;
+struct sockaddr_storage srv_ss3;
+socklen_t srv_ss3_len;
+
+int s2;
+int rc;
+
+ZERO_STRUCT(srv_ss1);
+srv_ss1_len = sizeof(srv_ss1);
+rc = getsockname(s, (struct sockaddr *)srv_ss1, srv_ss1_len);
+if (rc == -1) {
+perror(getsockname);
+return -1;
+}
+
+ZERO_STRUCT(cli_ss1);
+cli_ss1_len = sizeof(cli_ss1);
+rc = getpeername(s, (struct sockaddr *)cli_ss1, cli_ss1_len);
+if (rc == -1) {
+perror(getpeername);
+return -1;
+}
+
+if (cli_ss1.ss_family != srv_ss1.ss_family) {
+perror(client/server family mismatch);
+return -1;
+}
+
+/* Test dup */
+s2 = dup(s);
+if (s2 == -1) {
+perror(dup);
+return -1;
+}
+close(s);
+
+ZERO_STRUCT(srv_ss2);
+srv_ss2_len = sizeof(srv_ss2);
+rc = getsockname(s2, (struct sockaddr *)srv_ss2, srv_ss2_len);
+if (rc == -1) {
+perror(getsockname);
+return -1;
+}
+
+ZERO_STRUCT(cli_ss2);
+cli_ss2_len = sizeof(cli_ss2);
+rc = getpeername(s2, (struct sockaddr *)cli_ss2, cli_ss2_len);
+if (rc == -1) {
+perror(getpeername);
+return -1;
+}
+
+if (cli_ss1_len != cli_ss2_len ||
+srv_ss1_len != srv_ss2_len) {
+perror(length mismatch);
+return -1;
+}
+
+switch(cli_ss1.ss_family) {
+case AF_INET: {
+struct sockaddr_in *cli_sinp1 = (struct sockaddr_in *)cli_ss1;
+struct sockaddr_in *cli_sinp2 = (struct sockaddr_in *)cli_ss2;
+
+struct sockaddr_in *srv_sinp1 = (struct sockaddr_in *)srv_ss1;
+struct sockaddr_in *srv_sinp2 = (struct sockaddr_in *)srv_ss2;
+
+rc = memcmp(cli_sinp1, cli_sinp2, sizeof(struct sockaddr_in));
+if (rc != 0) {
+perror(client mismatch);
+}
+
+rc = memcmp(srv_sinp1, srv_sinp2, sizeof(struct sockaddr_in));
+if (rc != 0) {
+perror(server mismatch);
+}
+break;
+}
+case AF_INET6: {
+struct sockaddr_in6 *cli_sinp1 = (struct sockaddr_in6 *)cli_ss1;
+struct sockaddr_in6 *cli_sinp2 = (struct sockaddr_in6 *)cli_ss2;
+
+struct sockaddr_in6 *srv_sinp1 = (struct sockaddr_in6 *)srv_ss1;
+struct sockaddr_in6 *srv_sinp2 = (struct sockaddr_in6 *)srv_ss2;
+
+rc = memcmp(cli_sinp1, cli_sinp2, sizeof(struct sockaddr_in6));
+if (rc != 0) {
+perror(client mismatch);
+}
+
+rc = memcmp(srv_sinp1, srv_sinp2, sizeof(struct sockaddr_in6));
+if (rc != 0) {
+perror(server mismatch);
+}
+break;
+}
+default:
+perror(family mismatch);
+return -1;
+}
+
+/* Test dup2 */
+s = dup2(s2, s);
+if (s == -1) {
+perror(dup);
+return -1;
+}
+close(s2);
+
+ZERO_STRUCT(srv_ss3);
+srv_ss3_len = sizeof(srv_ss3);
+rc = getsockname(s, (struct sockaddr *)srv_ss3, srv_ss3_len);
+if (rc == -1) {
+perror(getsockname);
+return -1;
+}
+
+ZERO_STRUCT(cli_ss3);
+cli_ss3_len = sizeof(cli_ss3);
+rc = getpeername(s, (struct sockaddr *)cli_ss3, cli_ss3_len);
+if (rc == -1) {
+perror(getpeername);
+return -1;
+}
+
+if (cli_ss2_len != cli_ss3_len ||
+srv_ss2_len != srv_ss3_len) {
+perror(length mismatch);
+return -1;
+}
+
+

[SCM] Socket Wrapper Repository - branch master updated

2013-12-23 Thread Andreas Schneider
The branch, master has been updated
   via  b7f7ed3 torture: Add TORTURE_SKIP_CLEANUP to not delete socket_dir.
   via  4373b71 torture: Generate network traces for each test.
   via  98fa90d tests: Add test_echo_tcp_socket_options().
   via  6876e0c tests: Add test_echo_tcp_connect test.
  from  8c561dd tests: Add missing include for writev/readv.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit b7f7ed387070f48f6ef4ebfe5a4d9315010b6288
Author: Andreas Schneider a...@samba.org
Date:   Mon Dec 23 12:17:46 2013 +0100

torture: Add TORTURE_SKIP_CLEANUP to not delete socket_dir.

commit 4373b7191f3533e1b19a6a848f4ce682cea09bfa
Author: Andreas Schneider a...@samba.org
Date:   Mon Dec 23 12:17:02 2013 +0100

torture: Generate network traces for each test.

commit 98fa90dcf36cd6f95c6d1468224e5f5e9314c079
Author: Andreas Schneider a...@samba.org
Date:   Mon Dec 23 11:58:19 2013 +0100

tests: Add test_echo_tcp_socket_options().

commit 6876e0ca0906c6438bd2eb6d6b64e28372359e40
Author: Andreas Schneider a...@samba.org
Date:   Mon Dec 23 10:59:59 2013 +0100

tests: Add test_echo_tcp_connect test.

This tests some corner cases we fixed in the past.

---

Summary of changes:
 tests/CMakeLists.txt |9 ++-
 tests/test_echo_tcp_connect.c|   95 +
 tests/test_echo_tcp_socket_options.c |  151 ++
 tests/torture.c  |   25 +-
 tests/torture.h  |1 +
 5 files changed, 276 insertions(+), 5 deletions(-)
 create mode 100644 tests/test_echo_tcp_connect.c
 create mode 100644 tests/test_echo_tcp_socket_options.c


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 23f362d..45db1db 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,7 +17,14 @@ target_link_libraries(${TORTURE_LIBRARY}
 ${CMOCKA_LIBRARY}
 ${SWRAP_REQUIRED_LIBRARIES})
 
-set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom 
test_echo_udp_send_recv test_echo_tcp_write_read test_echo_tcp_writev_readv)
+set(SWRAP_TESTS
+test_ioctl
+test_echo_tcp_connect
+test_echo_tcp_socket_options
+test_echo_tcp_write_read
+test_echo_tcp_writev_readv
+test_echo_udp_sendto_recvfrom
+test_echo_udp_send_recv)
 
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
 add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
diff --git a/tests/test_echo_tcp_connect.c b/tests/test_echo_tcp_connect.c
new file mode 100644
index 000..b20e453
--- /dev/null
+++ b/tests/test_echo_tcp_connect.c
@@ -0,0 +1,95 @@
+#include stdarg.h
+#include stddef.h
+#include setjmp.h
+#include cmocka.h
+
+#include config.h
+#include torture.h
+
+#include errno.h
+#include sys/types.h
+#include sys/socket.h
+#include netinet/in.h
+#include arpa/inet.h
+#include stdlib.h
+#include stdio.h
+#include unistd.h
+
+static void setup_echo_srv_tcp_ipv4(void **state)
+{
+   torture_setup_echo_srv_tcp_ipv4(state);
+}
+
+static void teardown(void **state)
+{
+   torture_teardown_echo_srv(state);
+}
+
+static void test_connect_broadcast_ipv4(void **state)
+{
+   struct sockaddr_in sin;
+   socklen_t slen = sizeof(struct sockaddr_in);
+   int rc;
+   int s;
+
+   (void) state; /* unused */
+
+   s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+   assert_int_not_equal(s, -1);
+
+   ZERO_STRUCT(sin);
+   sin.sin_family = AF_INET;
+   sin.sin_port = htons(torture_server_port());
+   sin.sin_addr.s_addr = INADDR_BROADCAST;
+
+   /* We don't allow connect to broadcast addresses */
+   rc = connect(s, (struct sockaddr *)sin, slen);
+   assert_int_equal(rc, -1);
+
+   close(s);
+}
+
+#ifdef HAVE_IPV6
+static void test_connect_downgrade_ipv6(void **state)
+{
+   struct sockaddr_in sin;
+   socklen_t slen = sizeof(struct sockaddr_in);
+   int rc;
+   int s;
+
+   (void) state; /* unused */
+
+   s = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
+   assert_int_not_equal(s, -1);
+
+   ZERO_STRUCT(sin);
+   sin.sin_family = AF_INET;
+   sin.sin_port = htons(torture_server_port());
+
+   rc = inet_pton(sin.sin_family,
+  torture_server_address(AF_INET),
+  sin.sin_addr);
+   assert_int_equal(rc, 1);
+
+   /* Connect should downgrade to IPv4 and allow the connect */
+   rc = connect(s, (struct sockaddr *)sin, slen);
+   assert_int_equal(rc, 0);
+
+   close(s);
+}
+#endif
+
+int main(void) {
+   int rc;
+
+   const UnitTest tests[] = {
+   unit_test_setup_teardown(test_connect_broadcast_ipv4, 
setup_echo_srv_tcp_ipv4, teardown),
+#ifdef HAVE_IPV6
+   unit_test_setup_teardown(test_connect_downgrade_ipv6, 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-23 Thread Andreas Schneider
The branch, master has been updated
   via  b448961 test: Fix getsockopt on Solaris.
   via  1544ad6 tests: Fix getsockopt() on Solaris.
   via  3c4759a tests: writev/readv must have iovec  0
   via  450f4f3 tests: Remove unused variable warning
  from  b7f7ed3 torture: Add TORTURE_SKIP_CLEANUP to not delete socket_dir.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit b44896165f3265b702e667550bbb6d4e1ec09b43
Author: Andreas Schneider a...@samba.org
Date:   Mon Dec 23 15:23:21 2013 +0100

test: Fix getsockopt on Solaris.

commit 1544ad632c71e2fe9d355baf639f2a9a0d479b0d
Author: Andreas Schneider a...@samba.org
Date:   Mon Dec 23 15:03:26 2013 +0100

tests: Fix getsockopt() on Solaris.

commit 3c4759afc44b73484e99b130e931b2779b1f956c
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Mon Dec 23 15:37:06 2013 +0100

tests: writev/readv must have iovec  0

writev/readv with iovec == 0 works on Linux, but that is not portable.

commit 450f4f31c5afe4516a5db5fc071aa012dfb64202
Author: Jakub Hrozek jakub.hro...@gmail.com
Date:   Mon Dec 23 14:57:14 2013 +0100

tests: Remove unused variable warning

The variables were unused if SIOCGPGRP wasn't defined.

---

Summary of changes:
 tests/test_echo_tcp_socket_options.c |9 +
 tests/test_echo_tcp_writev_readv.c   |4 ++--
 tests/test_ioctl.c   |2 ++
 3 files changed, 9 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_echo_tcp_socket_options.c 
b/tests/test_echo_tcp_socket_options.c
index 798d612..8ec631f 100644
--- a/tests/test_echo_tcp_socket_options.c
+++ b/tests/test_echo_tcp_socket_options.c
@@ -42,9 +42,9 @@ static void test_sockopt_sndbuf(void **state)
struct sockaddr_in sin;
socklen_t slen = sizeof(struct sockaddr_in);
int obufsize = 0;
-   socklen_t olen = 0;
+   socklen_t olen = sizeof(obufsize);
int gbufsize = 0;
-   socklen_t glen = 0;
+   socklen_t glen = sizeof(gbufsize);
int sbufsize = 0;
int rc;
int s;
@@ -69,14 +69,15 @@ static void test_sockopt_sndbuf(void **state)
rc = getsockopt(s, SOL_SOCKET, SO_SNDBUF, obufsize, olen);
assert_int_equal(rc, 0);
 
-   sbufsize = ((obufsize + 1023)  (~1023));
+   /* request 4k, on Linux the kernel doubles the value */
+   sbufsize = 4096;
rc = setsockopt(s, SOL_SOCKET, SO_SNDBUF, sbufsize, sizeof(sbufsize));
assert_int_equal(rc, 0);
 
rc = getsockopt(s, SOL_SOCKET, SO_SNDBUF, gbufsize, glen);
assert_int_equal(rc, 0);
 
-   assert_int_equal(gbufsize, sbufsize);
+   assert_true(sbufsize == gbufsize || sbufsize == gbufsize/2);
 
close(s);
 }
diff --git a/tests/test_echo_tcp_writev_readv.c 
b/tests/test_echo_tcp_writev_readv.c
index 0aa1ae2..9f6703f 100644
--- a/tests/test_echo_tcp_writev_readv.c
+++ b/tests/test_echo_tcp_writev_readv.c
@@ -59,7 +59,7 @@ static void test_writev_readv_ipv4(void **state)
rc = connect(s, (struct sockaddr *)sin, slen);
assert_int_equal(rc, 0);
 
-   for (i = 0; i  10; i++) {
+   for (i = 1; i  10; i++) {
char send_buf[10][64];
char recv_buf[10][64];
struct iovec iov_send[10];
@@ -123,7 +123,7 @@ static void test_writev_readv_ipv6(void **state)
rc = connect(s, (struct sockaddr *)sin6, slen);
assert_int_equal(rc, 0);
 
-   for (i = 0; i  10; i++) {
+   for (i = 1; i  10; i++) {
char send_buf[10][64];
char recv_buf[10][64];
struct iovec iov_send[10];
diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c
index 0c9bfc6..d365641 100644
--- a/tests/test_ioctl.c
+++ b/tests/test_ioctl.c
@@ -69,8 +69,10 @@ static void test_swrap_socket(void **state)
 static void test_swrap_ioctl_sock(void **state)
 {
int fd;
+#ifdef SIOCGPGRP
int rc;
int grp = -127;
+#endif
 
(void) state; /* unused */
 


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2013-12-21 Thread Andreas Schneider
The branch, master has been updated
   via  8c561dd tests: Add missing include for writev/readv.
  from  789118a tests: Add an ifdef around static IPv6 only functions

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 8c561dd419a414cd50d4a63fa988fd1162042e47
Author: Andreas Schneider a...@samba.org
Date:   Sat Dec 21 16:18:45 2013 +0100

tests: Add missing include for writev/readv.

---

Summary of changes:
 tests/test_echo_tcp_writev_readv.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/test_echo_tcp_writev_readv.c 
b/tests/test_echo_tcp_writev_readv.c
index 0b6fe1f..0aa1ae2 100644
--- a/tests/test_echo_tcp_writev_readv.c
+++ b/tests/test_echo_tcp_writev_readv.c
@@ -9,6 +9,7 @@
 #include errno.h
 #include sys/types.h
 #include sys/socket.h
+#include sys/uio.h
 #include netinet/in.h
 #include arpa/inet.h
 #include stdlib.h


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  1e413ec echo_srv: Add missing includes.
   via  0f203f2 torture: Set different default interface for client and 
server.
   via  b9b05b1 swrap: Add documentation for SOCK_CLOEXEC in socket().
  from  3c3b7f6 tests: Add test_echo_tcp_write_read.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 1e413ec5497c82375dd11739912ddedd4743bb5f
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 10:54:20 2013 +0100

echo_srv: Add missing includes.

This should fix the build on FreeBSD.

commit 0f203f240b884f71aa5b24887447581822121354
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 15:34:10 2013 +0100

torture: Set different default interface for client and server.

commit b9b05b13d2731fa287fed5ffb602844828e3bb50
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 19 14:29:52 2013 +0100

swrap: Add documentation for SOCK_CLOEXEC in socket().

---

Summary of changes:
 src/socket_wrapper.c |6 ++
 tests/echo_srv.c |   18 +++---
 tests/torture.c  |8 +++-
 3 files changed, 24 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 0fcdb99..62e83ef 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1929,6 +1929,12 @@ static int swrap_socket(int family, int type, int 
protocol)
struct socket_info_fd *fi;
int fd;
int real_type = type;
+
+   /*
+* Remove possible addition flags passed to socket() so
+* do not fail checking the type.
+* See https://lwn.net/Articles/281965/
+*/
 #ifdef SOCK_CLOEXEC
real_type = ~SOCK_CLOEXEC;
 #endif
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index dd6fafd..a207419 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -1,17 +1,21 @@
-#include stdio.h
-#include stdlib.h
 #include errno.h
-#include sys/socket.h
+
 #include sys/types.h
+#include sys/socket.h
 #include sys/stat.h
-#include resolv.h
+
 #include arpa/inet.h
-#include errno.h
+#include netinet/in.h
 #include netdb.h
-#include string.h
+#include resolv.h
+
+#include fcntl.h
 #include getopt.h
 #include unistd.h
-#include fcntl.h
+
+#include string.h
+#include stdio.h
+#include stdlib.h
 #include stdbool.h
 
 #ifndef PIDFILE
diff --git a/tests/torture.c b/tests/torture.c
index d44fa25..75a4280 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -75,7 +75,7 @@ void torture_setup_socket_dir(void **state)
snprintf(s-srv_pidfile, len, %s/%s, p, TORTURE_ECHO_SRV_PIDFILE);
 
setenv(SOCKET_WRAPPER_DIR, p, 1);
-   setenv(SOCKET_WRAPPER_DEFAULT_IFACE, 21, 1);
+   setenv(SOCKET_WRAPPER_DEFAULT_IFACE, 170, 1);
 
*state = s;
 }
@@ -105,6 +105,9 @@ static void torture_setup_echo_srv_ip(void **state,
break;
}
 
+   /* set default iface for the server */
+   setenv(SOCKET_WRAPPER_DEFAULT_IFACE, 10, 1);
+
snprintf(start_echo_srv, sizeof(start_echo_srv),
 %s/tests/echo_srv -b %s -D %s --pid %s,
 BINARYDIR, ip, t, s-srv_pidfile);
@@ -113,6 +116,9 @@ static void torture_setup_echo_srv_ip(void **state,
assert_int_equal(rc, 0);
 
sleep(1);
+
+   /* set default iface for the client */
+   setenv(SOCKET_WRAPPER_DEFAULT_IFACE, 170, 1);
 }
 
 void torture_setup_echo_srv_udp_ipv4(void **state)


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  38823ac swrap: Fix loading of system libraries.
  from  1e413ec echo_srv: Add missing includes.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 38823ac68e44c8084c98c8b869fb8b37abc38664
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 13:38:19 2013 +0100

swrap: Fix loading of system libraries.

---

Summary of changes:
 src/socket_wrapper.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 62e83ef..dc6ffb1 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -391,6 +391,7 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
/* FALL TROUGH */
case SWRAP_LIBSOCKET:
 #ifdef HAVE_LIBSOCKET
+   handle = swrap.libsocket_handle;
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -400,13 +401,12 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
}
 
swrap.libsocket_handle = handle;
-   } else {
-   handle = swrap.libsocket_handle;
}
break;
 #endif
/* FALL TROUGH */
case SWRAP_LIBC:
+   handle = swrap.libc_handle;
if (handle == NULL) {
for (handle = NULL, i = 10; handle == NULL  i = 0; 
i--) {
char soname[256] = {0};
@@ -416,8 +416,6 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
}
 
swrap.libc_handle = handle;
-   } else {
-   handle = swrap.libc_handle;
}
break;
}


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  7d0e5ef tests: Use torture_server_(address|port).
   via  f6f5e28 torture: Add torture_server_port().
   via  379af07 torture: Add torture_server_address().
   via  33404b4 torture: Let the echo server listen on anyaddr.
  from  38823ac swrap: Fix loading of system libraries.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 7d0e5efedce4cc338d0f9fb355793eba6542dfa9
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 17:09:56 2013 +0100

tests: Use torture_server_(address|port).

This makes it possible to run tests without socket_wrapper.

commit f6f5e28f3382d3828228089765040413682db85a
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 16:53:32 2013 +0100

torture: Add torture_server_port().

commit 379af0763be3c25d8b4ec75220d0f98007f9328b
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 16:37:59 2013 +0100

torture: Add torture_server_address().

This should make it easier to run the test without socket_wrapper.

commit 33404b45bcbca1691d3d9fb8bb5b4f2c15caef0e
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 20 16:31:00 2013 +0100

torture: Let the echo server listen on anyaddr.

---

Summary of changes:
 tests/README  |9 
 tests/test_echo_tcp_write_read.c  |   12 --
 tests/test_echo_udp_send_recv.c   |   12 --
 tests/test_echo_udp_sendto_recvfrom.c |   16 +---
 tests/torture.c   |   73 +
 tests/torture.h   |8 +--
 6 files changed, 103 insertions(+), 27 deletions(-)
 create mode 100644 tests/README


Changeset truncated at 500 lines:

diff --git a/tests/README b/tests/README
new file mode 100644
index 000..26bf1fb
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,9 @@
+In this directory you can find all socket_wrapper tests. All tests can also be
+executed outside of the 'make test' environment and without socket_wrapper.
+
+This can be done with:
+
+TORTURE_SERVER_ADDRESS_IPV4=127.0.0.1 \
+TORTURE_SERVER_ADDRESS_IPV6=::1 \
+TORTURE_SERVER_PORT= \
+./tests/test_echo_tcp_write_read
diff --git a/tests/test_echo_tcp_write_read.c b/tests/test_echo_tcp_write_read.c
index 389e400..e2ffe91 100644
--- a/tests/test_echo_tcp_write_read.c
+++ b/tests/test_echo_tcp_write_read.c
@@ -46,9 +46,11 @@ static void test_write_read_ipv4(void **state)
 
ZERO_STRUCT(sin);
sin.sin_family = AF_INET;
-   sin.sin_port = htons(TORTURE_ECHO_SRV_PORT);
+   sin.sin_port = htons(torture_server_port());
 
-   rc = inet_pton(sin.sin_family, TORTURE_ECHO_SRV_IPV4, sin.sin_addr);
+   rc = inet_pton(sin.sin_family,
+  torture_server_address(AF_INET),
+  sin.sin_addr);
assert_int_equal(rc, 1);
 
rc = connect(s, (struct sockaddr *)sin, slen);
@@ -93,9 +95,11 @@ static void test_write_read_ipv6(void **state)
 
ZERO_STRUCT(sin6);
sin6.sin6_family = AF_INET6;
-   sin6.sin6_port = htons(TORTURE_ECHO_SRV_PORT);
+   sin6.sin6_port = htons(torture_server_port());
 
-   rc = inet_pton(AF_INET6, TORTURE_ECHO_SRV_IPV6, sin6.sin6_addr);
+   rc = inet_pton(AF_INET6,
+  torture_server_address(AF_INET6),
+  sin6.sin6_addr);
assert_int_equal(rc, 1);
 
rc = connect(s, (struct sockaddr *)sin6, slen);
diff --git a/tests/test_echo_udp_send_recv.c b/tests/test_echo_udp_send_recv.c
index c197251..4ea6812 100644
--- a/tests/test_echo_udp_send_recv.c
+++ b/tests/test_echo_udp_send_recv.c
@@ -46,9 +46,11 @@ static void test_send_recv_ipv4(void **state)
 
ZERO_STRUCT(sin);
sin.sin_family = AF_INET;
-   sin.sin_port = htons(TORTURE_ECHO_SRV_PORT);
+   sin.sin_port = htons(torture_server_port());
 
-   rc = inet_pton(sin.sin_family, TORTURE_ECHO_SRV_IPV4, sin.sin_addr);
+   rc = inet_pton(AF_INET,
+  torture_server_address(AF_INET),
+  sin.sin_addr);
assert_int_equal(rc, 1);
 
rc = connect(s, (struct sockaddr *)sin, slen);
@@ -95,9 +97,11 @@ static void test_send_recv_ipv6(void **state)
 
ZERO_STRUCT(sin6);
sin6.sin6_family = AF_INET6;
-   sin6.sin6_port = htons(TORTURE_ECHO_SRV_PORT);
+   sin6.sin6_port = htons(torture_server_port());
 
-   rc = inet_pton(AF_INET6, TORTURE_ECHO_SRV_IPV6, sin6.sin6_addr);
+   rc = inet_pton(AF_INET6,
+  torture_server_address(AF_INET6),
+  sin6.sin6_addr);
assert_int_equal(rc, 1);
 
rc = connect(s, (struct sockaddr *)sin6, slen);
diff --git a/tests/test_echo_udp_sendto_recvfrom.c 
b/tests/test_echo_udp_sendto_recvfrom.c
index f68cef9..a7ed474 100644
--- 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-20 Thread Andreas Schneider
The branch, master has been updated
   via  789118a tests: Add an ifdef around static IPv6 only functions
   via  b11ceab tests: Add test_echo_tcp_write_readv
  from  7d0e5ef tests: Use torture_server_(address|port).

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 789118aee6683b8bfafac4ea24c6c9a160ad9e59
Author: Jakub Hrozek jhro...@redhat.com
Date:   Fri Dec 20 16:53:59 2013 +0100

tests: Add an ifdef around static IPv6 only functions

This would prevent an uninitialized function warning in case IPv6 was not
available.

commit b11ceabbfc505ab08f101d4a5ca6b498c30c98d1
Author: Jakub Hrozek jhro...@redhat.com
Date:   Fri Dec 20 16:50:42 2013 +0100

tests: Add test_echo_tcp_write_readv

---

Summary of changes:
 tests/CMakeLists.txt   |2 +-
 tests/test_echo_tcp_write_read.c   |2 +
 ...p_write_read.c = test_echo_tcp_writev_readv.c} |   88 +--
 tests/test_echo_udp_send_recv.c|2 +
 tests/test_echo_udp_sendto_recvfrom.c  |2 +
 5 files changed, 67 insertions(+), 29 deletions(-)
 copy tests/{test_echo_tcp_write_read.c = test_echo_tcp_writev_readv.c} (50%)


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 63b0046..23f362d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,7 +17,7 @@ target_link_libraries(${TORTURE_LIBRARY}
 ${CMOCKA_LIBRARY}
 ${SWRAP_REQUIRED_LIBRARIES})
 
-set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom 
test_echo_udp_send_recv test_echo_tcp_write_read)
+set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom 
test_echo_udp_send_recv test_echo_tcp_write_read test_echo_tcp_writev_readv)
 
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
 add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
diff --git a/tests/test_echo_tcp_write_read.c b/tests/test_echo_tcp_write_read.c
index e2ffe91..4437de9 100644
--- a/tests/test_echo_tcp_write_read.c
+++ b/tests/test_echo_tcp_write_read.c
@@ -20,10 +20,12 @@ static void setup_echo_srv_tcp_ipv4(void **state)
torture_setup_echo_srv_tcp_ipv4(state);
 }
 
+#ifdef HAVE_IPV6
 static void setup_echo_srv_tcp_ipv6(void **state)
 {
torture_setup_echo_srv_tcp_ipv6(state);
 }
+#endif
 
 static void teardown(void **state)
 {
diff --git a/tests/test_echo_tcp_write_read.c 
b/tests/test_echo_tcp_writev_readv.c
similarity index 50%
copy from tests/test_echo_tcp_write_read.c
copy to tests/test_echo_tcp_writev_readv.c
index e2ffe91..0b6fe1f 100644
--- a/tests/test_echo_tcp_write_read.c
+++ b/tests/test_echo_tcp_writev_readv.c
@@ -20,17 +20,19 @@ static void setup_echo_srv_tcp_ipv4(void **state)
torture_setup_echo_srv_tcp_ipv4(state);
 }
 
+#ifdef HAVE_IPV6
 static void setup_echo_srv_tcp_ipv6(void **state)
 {
torture_setup_echo_srv_tcp_ipv6(state);
 }
+#endif
 
 static void teardown(void **state)
 {
torture_teardown_echo_srv(state);
 }
 
-static void test_write_read_ipv4(void **state)
+static void test_writev_readv_ipv4(void **state)
 {
struct sockaddr_in sin;
socklen_t slen = sizeof(struct sockaddr_in);
@@ -49,37 +51,52 @@ static void test_write_read_ipv4(void **state)
sin.sin_port = htons(torture_server_port());
 
rc = inet_pton(sin.sin_family,
-  torture_server_address(AF_INET),
-  sin.sin_addr);
+   torture_server_address(AF_INET),
+   sin.sin_addr);
assert_int_equal(rc, 1);
 
rc = connect(s, (struct sockaddr *)sin, slen);
assert_int_equal(rc, 0);
 
for (i = 0; i  10; i++) {
-   char send_buf[64] = {0};
-   char recv_buf[64] = {0};
+   char send_buf[10][64];
+   char recv_buf[10][64];
+   struct iovec iov_send[10];
+   struct iovec iov_recv[10];
+   int j;
+
+   for (j = 0; j  i; j++) {
+   memset(send_buf[j], 0, 64);
+   snprintf(send_buf[j], sizeof(send_buf), packet.%d, j);
+
+   iov_send[j].iov_base = send_buf[j];
+   iov_send[j].iov_len = strlen(send_buf[j]);
 
-   snprintf(send_buf, sizeof(send_buf), packet.%d, i);
+   iov_recv[j].iov_base = recv_buf[j];
+   iov_recv[j].iov_len = strlen(send_buf[j]);
+   }
 
-   ret = write(s,
-   send_buf,
-   sizeof(send_buf));
+   ret = writev(s, iov_send, j);
assert_int_not_equal(ret, -1);
 
-   ret = read(s,
-  recv_buf,
-  sizeof(recv_buf));
+   ret = readv(s, 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-17 Thread Andreas Schneider
The branch, master has been updated
   via  3c3b7f6 tests: Add test_echo_tcp_write_read.
   via  0d87b9e torture: Add tcp function to setup echo server.
   via  e778fa2 torture: Pass socket type to torture_setup_echo_srv_ip().
   via  356fc98 torture: Add torture_generate_random_buffer().
  from  2ee37e0 tests: Add test_echo_udp_send_recv test.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 3c3b7f69d283fc6407a146b412df00517e500b01
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 14:48:38 2013 +0100

tests: Add test_echo_tcp_write_read.

commit 0d87b9e18aa400844c18639e575d95b2f98266d5
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 14:44:54 2013 +0100

torture: Add tcp function to setup echo server.

commit e778fa214fb69b2119f7f5e5ebbf21476cd8b0a8
Author: Andreas Schneider a...@samba.org
Date:   Tue Dec 17 14:44:08 2013 +0100

torture: Pass socket type to torture_setup_echo_srv_ip().

commit 356fc983ec7f3147b5685fa6dc586959ec50b0ea
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 13 14:49:13 2013 +0100

torture: Add torture_generate_random_buffer().

---

Summary of changes:
 tests/CMakeLists.txt   |2 +-
 ..._udp_send_recv.c = test_echo_tcp_write_read.c} |   44 -
 tests/torture.c|   52 ++--
 tests/torture.h|5 ++
 4 files changed, 73 insertions(+), 30 deletions(-)
 copy tests/{test_echo_udp_send_recv.c = test_echo_tcp_write_read.c} (72%)


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ec5f238..63b0046 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,7 +17,7 @@ target_link_libraries(${TORTURE_LIBRARY}
 ${CMOCKA_LIBRARY}
 ${SWRAP_REQUIRED_LIBRARIES})
 
-set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom 
test_echo_udp_send_recv)
+set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom 
test_echo_udp_send_recv test_echo_tcp_write_read)
 
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
 add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
diff --git a/tests/test_echo_udp_send_recv.c b/tests/test_echo_tcp_write_read.c
similarity index 72%
copy from tests/test_echo_udp_send_recv.c
copy to tests/test_echo_tcp_write_read.c
index c197251..389e400 100644
--- a/tests/test_echo_udp_send_recv.c
+++ b/tests/test_echo_tcp_write_read.c
@@ -15,14 +15,14 @@
 #include stdio.h
 #include unistd.h
 
-static void setup_echo_srv_udp_ipv4(void **state)
+static void setup_echo_srv_tcp_ipv4(void **state)
 {
-   torture_setup_echo_srv_udp_ipv4(state);
+   torture_setup_echo_srv_tcp_ipv4(state);
 }
 
-static void setup_echo_srv_udp_ipv6(void **state)
+static void setup_echo_srv_tcp_ipv6(void **state)
 {
-   torture_setup_echo_srv_udp_ipv6(state);
+   torture_setup_echo_srv_tcp_ipv6(state);
 }
 
 static void teardown(void **state)
@@ -30,7 +30,7 @@ static void teardown(void **state)
torture_teardown_echo_srv(state);
 }
 
-static void test_send_recv_ipv4(void **state)
+static void test_write_read_ipv4(void **state)
 {
struct sockaddr_in sin;
socklen_t slen = sizeof(struct sockaddr_in);
@@ -41,7 +41,7 @@ static void test_send_recv_ipv4(void **state)
 
(void) state; /* unused */
 
-   s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+   s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
assert_int_not_equal(s, -1);
 
ZERO_STRUCT(sin);
@@ -60,16 +60,14 @@ static void test_send_recv_ipv4(void **state)
 
snprintf(send_buf, sizeof(send_buf), packet.%d, i);
 
-   ret = send(s,
-  send_buf,
-  sizeof(send_buf),
-  0);
+   ret = write(s,
+   send_buf,
+   sizeof(send_buf));
assert_int_not_equal(ret, -1);
 
-   ret = recv(s,
+   ret = read(s,
   recv_buf,
-  sizeof(recv_buf),
-  0);
+  sizeof(recv_buf));
assert_int_not_equal(ret, -1);
 
assert_memory_equal(send_buf, recv_buf, sizeof(send_buf));
@@ -79,7 +77,7 @@ static void test_send_recv_ipv4(void **state)
 }
 
 #ifdef HAVE_IPV6
-static void test_send_recv_ipv6(void **state)
+static void test_write_read_ipv6(void **state)
 {
struct sockaddr_in6 sin6;
socklen_t slen = sizeof(struct sockaddr_in6);
@@ -90,7 +88,7 @@ static void test_send_recv_ipv6(void **state)
 
(void) state; /* unused */
 
-   s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+   s = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);

[SCM] Socket Wrapper Repository - branch master updated

2013-12-13 Thread Andreas Schneider
The branch, master has been updated
   via  2ee37e0 tests: Add test_echo_udp_send_recv test.
   via  13c38c4 tests: Use inet_pton() instead of inet_aton().
  from  bfeac80 tests: Rename testsuite to test_ioctl.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 2ee37e01cf0a48553a19f2714fb4252d967711df
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 13 14:22:55 2013 +0100

tests: Add test_echo_udp_send_recv test.

commit 13c38c4b417540a237f0158c7f6e21f531e071d4
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 13 14:22:24 2013 +0100

tests: Use inet_pton() instead of inet_aton().

---

Summary of changes:
 tests/CMakeLists.txt  |2 +-
 tests/test_echo_udp_send_recv.c   |  144 +
 tests/test_echo_udp_sendto_recvfrom.c |2 +-
 3 files changed, 146 insertions(+), 2 deletions(-)
 create mode 100644 tests/test_echo_udp_send_recv.c


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index cce34a2..ec5f238 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,7 +17,7 @@ target_link_libraries(${TORTURE_LIBRARY}
 ${CMOCKA_LIBRARY}
 ${SWRAP_REQUIRED_LIBRARIES})
 
-set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom)
+set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom 
test_echo_udp_send_recv)
 
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
 add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
diff --git a/tests/test_echo_udp_send_recv.c b/tests/test_echo_udp_send_recv.c
new file mode 100644
index 000..c197251
--- /dev/null
+++ b/tests/test_echo_udp_send_recv.c
@@ -0,0 +1,144 @@
+#include stdarg.h
+#include stddef.h
+#include setjmp.h
+#include cmocka.h
+
+#include config.h
+#include torture.h
+
+#include errno.h
+#include sys/types.h
+#include sys/socket.h
+#include netinet/in.h
+#include arpa/inet.h
+#include stdlib.h
+#include stdio.h
+#include unistd.h
+
+static void setup_echo_srv_udp_ipv4(void **state)
+{
+   torture_setup_echo_srv_udp_ipv4(state);
+}
+
+static void setup_echo_srv_udp_ipv6(void **state)
+{
+   torture_setup_echo_srv_udp_ipv6(state);
+}
+
+static void teardown(void **state)
+{
+   torture_teardown_echo_srv(state);
+}
+
+static void test_send_recv_ipv4(void **state)
+{
+   struct sockaddr_in sin;
+   socklen_t slen = sizeof(struct sockaddr_in);
+   ssize_t ret;
+   int rc;
+   int i;
+   int s;
+
+   (void) state; /* unused */
+
+   s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+   assert_int_not_equal(s, -1);
+
+   ZERO_STRUCT(sin);
+   sin.sin_family = AF_INET;
+   sin.sin_port = htons(TORTURE_ECHO_SRV_PORT);
+
+   rc = inet_pton(sin.sin_family, TORTURE_ECHO_SRV_IPV4, sin.sin_addr);
+   assert_int_equal(rc, 1);
+
+   rc = connect(s, (struct sockaddr *)sin, slen);
+   assert_int_equal(rc, 0);
+
+   for (i = 0; i  10; i++) {
+   char send_buf[64] = {0};
+   char recv_buf[64] = {0};
+
+   snprintf(send_buf, sizeof(send_buf), packet.%d, i);
+
+   ret = send(s,
+  send_buf,
+  sizeof(send_buf),
+  0);
+   assert_int_not_equal(ret, -1);
+
+   ret = recv(s,
+  recv_buf,
+  sizeof(recv_buf),
+  0);
+   assert_int_not_equal(ret, -1);
+
+   assert_memory_equal(send_buf, recv_buf, sizeof(send_buf));
+   }
+
+   close(s);
+}
+
+#ifdef HAVE_IPV6
+static void test_send_recv_ipv6(void **state)
+{
+   struct sockaddr_in6 sin6;
+   socklen_t slen = sizeof(struct sockaddr_in6);
+   ssize_t ret;
+   int rc;
+   int i;
+   int s;
+
+   (void) state; /* unused */
+
+   s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+   assert_int_not_equal(s, -1);
+
+   ZERO_STRUCT(sin6);
+   sin6.sin6_family = AF_INET6;
+   sin6.sin6_port = htons(TORTURE_ECHO_SRV_PORT);
+
+   rc = inet_pton(AF_INET6, TORTURE_ECHO_SRV_IPV6, sin6.sin6_addr);
+   assert_int_equal(rc, 1);
+
+   rc = connect(s, (struct sockaddr *)sin6, slen);
+   assert_int_equal(rc, 0);
+
+   for (i = 0; i  10; i++) {
+   char send_buf[64] = {0};
+   char recv_buf[64] = {0};
+
+   snprintf(send_buf, sizeof(send_buf), packet.%d, i);
+
+   ret = send(s,
+  send_buf,
+  sizeof(send_buf),
+  0);
+   assert_int_not_equal(ret, -1);
+
+   ret = recv(s,
+  recv_buf,
+  sizeof(recv_buf),
+  0);
+   assert_int_not_equal(ret, 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-12 Thread Andreas Schneider
The branch, master has been updated
   via  25d0e92 echo_srv: Fix a build warning.
   via  04d0275 swrap: Don't build with swrap_str_lib() if NDEBUG is 
defined.
   via  48db034 cmake: Fix linking echo_srv on Solaris.
   via  26019f9 cmake: Increase required cmake version number.
  from  c01846d Fix formatting of variables of type pid_t

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 25d0e92c8c4ca13b5275448a67e5f6c5690a1d0e
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 12 09:07:54 2013 +0100

echo_srv: Fix a build warning.

commit 04d0275dd1d7c937076857547aaa9fc6afb3c8a8
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 12 09:05:55 2013 +0100

swrap: Don't build with swrap_str_lib() if NDEBUG is defined.

This fixes a compile warning on optimized builds.

commit 48db0346ceb93254ffbe7ffdf795e162867aa8e8
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 12 08:50:43 2013 +0100

cmake: Fix linking echo_srv on Solaris.

commit 26019f9dfaad0840742938d4aff904584eb01edf
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 11 19:50:59 2013 +0100

cmake: Increase required cmake version number.

We need CheckPrototypeDefinition.

---

Summary of changes:
 CMakeLists.txt   |2 +-
 src/socket_wrapper.c |2 ++
 tests/CMakeLists.txt |1 +
 tests/echo_srv.c |2 +-
 4 files changed, 5 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9dfe3ed..50674ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 project(socket_wrapper C)
 
 # Required cmake version
-cmake_minimum_required(VERSION 2.8.0)
+cmake_minimum_required(VERSION 2.8.5)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index addcc17..0fcdb99 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -355,6 +355,7 @@ enum swrap_lib {
 SWRAP_LIBSOCKET,
 };
 
+#ifndef NDEBUG
 static const char *swrap_str_lib(enum swrap_lib lib)
 {
switch (lib) {
@@ -369,6 +370,7 @@ static const char *swrap_str_lib(enum swrap_lib lib)
/* Compiler would warn us about unhandled enum value if we get here */
return unknown;
 }
+#endif
 
 static void *swrap_load_lib_handle(enum swrap_lib lib)
 {
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1154561..9de698e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,6 +10,7 @@ set(TORTURE_LIBRARY torture)
 
 # RFC862 echo server
 add_executable(echo_srv echo_srv.c)
+target_link_libraries(echo_srv ${SWRAP_REQUIRED_LIBRARIES})
 
 add_library(${TORTURE_LIBRARY} STATIC torture.c)
 target_link_libraries(${TORTURE_LIBRARY}
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index b290ca8..dd6fafd 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -260,7 +260,7 @@ static void echo(int sock, struct echo_srv_opts *opts)
 int main(int argc, char **argv)
 {
 int ret;
-int sock;
+int sock = -1;
 struct echo_srv_opts opts;
 int opt;
 int optindex;


-- 
Socket Wrapper Repository


[SCM] Socket Wrapper Repository - branch master updated

2013-12-12 Thread Andreas Schneider
The branch, master has been updated
   via  bfeac80 tests: Rename testsuite to test_ioctl.
   via  580a75e tests: Remove unused code.
   via  17c7a05 tests: Remove FIONBIO cause it doesn't work on x86.
  from  25d0e92 echo_srv: Fix a build warning.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit bfeac80c3ca82acd9fba6fafcf92f6201b1be906
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 12 21:26:15 2013 +0100

tests: Rename testsuite to test_ioctl.

commit 580a75ec306dc939f0d325ed639ea41ea7e482e2
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 12 21:25:01 2013 +0100

tests: Remove unused code.

commit 17c7a05f564d7349503b6effed3e4ddb6eb1e87e
Author: Andreas Schneider a...@samba.org
Date:   Thu Dec 12 21:24:07 2013 +0100

tests: Remove FIONBIO cause it doesn't work on x86.

---

Summary of changes:
 tests/CMakeLists.txt |2 +-
 tests/test_ioctl.c   |   99 
 tests/testsuite.c|  136 --
 3 files changed, 100 insertions(+), 137 deletions(-)
 create mode 100644 tests/test_ioctl.c
 delete mode 100644 tests/testsuite.c


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9de698e..cce34a2 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,7 +17,7 @@ target_link_libraries(${TORTURE_LIBRARY}
 ${CMOCKA_LIBRARY}
 ${SWRAP_REQUIRED_LIBRARIES})
 
-set(SWRAP_TESTS testsuite test_echo_udp_sendto_recvfrom)
+set(SWRAP_TESTS test_ioctl test_echo_udp_sendto_recvfrom)
 
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
 add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c
new file mode 100644
index 000..0c9bfc6
--- /dev/null
+++ b/tests/test_ioctl.c
@@ -0,0 +1,99 @@
+#include stdarg.h
+#include stddef.h
+#include setjmp.h
+#include cmocka.h
+
+#include sys/types.h
+#include sys/socket.h
+#include sys/ioctl.h
+
+#include errno.h
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include unistd.h
+
+static void setup(void **state)
+{
+   char test_tmpdir[256];
+   const char *p;
+
+   (void) state; /* unused */
+
+   snprintf(test_tmpdir, sizeof(test_tmpdir), 
/tmp/test_socket_wrapper_XX);
+
+   p = mkdtemp(test_tmpdir);
+   assert_non_null(p);
+
+   setenv(SOCKET_WRAPPER_DIR, p, 1);
+   setenv(SOCKET_WRAPPER_DEFAULT_IFACE, 11, 1);
+}
+
+static void teardown(void **state)
+{
+   char remove_cmd[256] = {0};
+   const char *swrap_dir = getenv(SOCKET_WRAPPER_DIR);
+   int rc;
+
+   (void) state; /* unused */
+
+   if (swrap_dir != NULL) {
+   snprintf(remove_cmd, sizeof(remove_cmd), rm -rf %s, 
swrap_dir);
+   }
+
+   rc = system(remove_cmd);
+   if (rc  0) {
+   fprintf(stderr, %s failed: %s, remove_cmd, strerror(errno));
+   }
+}
+
+static void test_swrap_socket(void **state)
+{
+   int rc;
+
+   (void) state; /* unused */
+
+   rc = socket(1337, 1337, 0);
+   assert_int_equal(rc, -1);
+   assert_int_equal(errno, EAFNOSUPPORT);
+
+   rc = socket(AF_INET, 1337, 0);
+   assert_int_equal(rc, -1);
+   assert_int_equal(errno, EPROTONOSUPPORT);
+
+   rc = socket(AF_INET, SOCK_DGRAM, 10);
+   assert_int_equal(rc, -1);
+   assert_int_equal(errno, EPROTONOSUPPORT);
+}
+
+static void test_swrap_ioctl_sock(void **state)
+{
+   int fd;
+   int rc;
+   int grp = -127;
+
+   (void) state; /* unused */
+
+   fd = socket(AF_INET, SOCK_DGRAM, 0);
+   assert_int_not_equal(fd, -1);
+
+#ifdef SIOCGPGRP
+   rc = ioctl(fd, SIOCGPGRP, grp);
+   assert_int_equal(rc, 0);
+
+   assert_int_not_equal(grp, -127);
+#endif
+}
+
+int main(void) {
+   int rc;
+
+   const UnitTest tests[] = {
+   unit_test_setup_teardown(test_swrap_socket, setup, teardown),
+   unit_test_setup_teardown(test_swrap_ioctl_sock, setup, 
teardown),
+   };
+
+   rc = run_tests(tests);
+
+   return rc;
+}
diff --git a/tests/testsuite.c b/tests/testsuite.c
deleted file mode 100644
index 70ffe8e..000
--- a/tests/testsuite.c
+++ /dev/null
@@ -1,136 +0,0 @@
-#include stdarg.h
-#include stddef.h
-#include setjmp.h
-#include cmocka.h
-
-#include sys/types.h
-#include sys/socket.h
-#include sys/ioctl.h
-
-#include errno.h
-#include stdlib.h
-#include stdio.h
-#include string.h
-#include unistd.h
-
-static void setup(void **state)
-{
-   char test_tmpdir[256];
-   const char *p;
-
-   (void) state; /* unused */
-
-   snprintf(test_tmpdir, sizeof(test_tmpdir), 
/tmp/test_socket_wrapper_XX);
-
-   p = mkdtemp(test_tmpdir);
-   assert_non_null(p);
-
-   setenv(SOCKET_WRAPPER_DIR, p, 1);
-   

[SCM] Socket Wrapper Repository - branch master updated

2013-12-11 Thread Andreas Schneider
The branch, master has been updated
   via  c01846d Fix formatting of variables of type pid_t
   via  2046732 tests: use discard_const to get rid of a warning on Solaris
   via  11146ca logging: log creating the sockets
   via  f6e30ff logging: Add logging when loading system functions
   via  46e034b cmake: Detect attribute format
   via  ddcd744 tests: Also check recvfrom() with NULL pointer.
   via  6419e8f tests: Check the returned ip from recvfrom.
   via  63c9d85 tests: Fix passing uninitialized values.
  from  76c7df9 tests: Add test_sendto_recvfrom_ipv6().

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit c01846db2d31b2125d0b1e6bcfc4c38de345d52a
Author: Jakub Hrozek jhro...@redhat.com
Date:   Wed Dec 11 15:03:32 2013 +0100

Fix formatting of variables of type pid_t

commit 20467324a5508d8efafb087faf1914c87529f052
Author: Jakub Hrozek jhro...@redhat.com
Date:   Wed Dec 11 14:17:02 2013 +0100

tests: use discard_const to get rid of a warning on Solaris

commit 11146ca50aa4f2ae55d0a61f3d7dae92c8bca63f
Author: Jakub Hrozek jhro...@redhat.com
Date:   Tue Dec 10 16:13:20 2013 +0100

logging: log creating the sockets

commit f6e30ff7e990c6fcef205602388149ce6de9da93
Author: Jakub Hrozek jhro...@redhat.com
Date:   Tue Dec 10 15:44:27 2013 +0100

logging: Add logging when loading system functions

Also fix some whitespace errors

commit 46e034bb06093990fe885f8dbdef825bc0eb39e3
Author: Jakub Hrozek jhro...@redhat.com
Date:   Tue Dec 10 15:29:13 2013 +0100

cmake: Detect attribute format

commit ddcd744708f11d52c28400f3ff22c52b7ebc52b5
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 11 13:03:35 2013 +0100

tests: Also check recvfrom() with NULL pointer.

commit 6419e8f9a1f09017964ebbb1fb971083bd876e48
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 11 12:56:21 2013 +0100

tests: Check the returned ip from recvfrom.

commit 63c9d85b6bb13f5e1649323980bc0f3f94b8ee40
Author: Andreas Schneider a...@samba.org
Date:   Wed Dec 11 12:03:47 2013 +0100

tests: Fix passing uninitialized values.

---

Summary of changes:
 ConfigureChecks.cmake |   10 
 config.h.cmake|3 +
 src/socket_wrapper.c  |   73 
 tests/echo_srv.c  |   22 +++---
 tests/test_echo_udp_sendto_recvfrom.c |   75 +++-
 tests/torture.h   |4 +-
 6 files changed, 158 insertions(+), 29 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index dd3fdb8..995f8ce 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -169,6 +169,14 @@ int main(void) {
 return 0;
 } HAVE_GCC_THREAD_LOCAL_STORAGE)
 
+check_c_source_compiles(
+void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+
+int main(void) {
+return 0;
+} HAVE_FUNCTION_ATTRIBUTE_FORMAT)
+
+
 check_library_exists(dl dlopen  HAVE_LIBDL)
 if (HAVE_LIBDL)
 find_library(DLFCN_LIBRARY dl)
@@ -184,4 +192,6 @@ if (NOT WIN32)
 test_big_endian(WORDS_BIGENDIAN)
 endif (NOT WIN32)
 
+check_type_size(pid_t SIZEOF_PID_T)
+
 set(SWRAP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL swrap 
required system libraries)
diff --git a/config.h.cmake b/config.h.cmake
index 3def5e7..4f912bd 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -29,6 +29,8 @@
 #cmakedefine HAVE_GETTIMEOFDAY_TZ 1
 #cmakedefine HAVE_GETTIMEOFDAY_TZ_VOID 1
 
+/*** DATA TYPES***/
+#cmakedefine SIZEOF_PID_T @SIZEOF_PID_T@
 
 / OPTIONS /
 
@@ -36,6 +38,7 @@
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_SOCKADDR_STORAGE 1
 #cmakedefine HAVE_IPV6 1
+#cmakedefine HAVE_FUNCTION_ATTRIBUTE_FORMAT 1
 
 #cmakedefine HAVE_APPLE 1
 #cmakedefine HAVE_LIBSOCKET 1
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 4964ec1..addcc17 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -73,11 +73,11 @@ enum swrap_dbglvl_e {
 };
 
 /* GCC have printf type attribute check. */
-#ifdef __GNUC__
+#ifdef HAVE_FUNCTION_ATTRIBUTE_FORMAT
 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
 #else
 #define PRINTF_ATTRIBUTE(a,b)
-#endif /* __GNUC__ */
+#endif /* HAVE_FUNCTION_ATTRIBUTE_FORMAT */
 
 #ifdef HAVE_DESTRUCTOR_ATTRIBUTE
 #define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
@@ -95,6 +95,14 @@ enum swrap_dbglvl_e {
 #define MIN(a,b) ((a)(b)?(a):(b))
 #endif
 
+#if SIZEOF_PID_T == 8
+# define SPRIpid PRIu64
+#elif SIZEOF_UID_T == 4
+# define SPRIpid PRIu32
+#else
+# define SPRIpid %d  /* Sane default for most platforms */
+#endif /* SIZEOF_UID_T */
+
 #ifndef 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-10 Thread Andreas Schneider
The branch, master has been updated
   via  9f7d7b4 swrap: Remove obsolete init functions.
   via  e5899b8 swrap: Add libc_writev().
   via  d344002 swrap: Add libc_socket().
   via  4b72d30 swrap: Add libc_setsockopt().
   via  a6bbc38 swrap: Add libc_sendto().
   via  5b7e896 swrap: Add libc_sendmsg().
   via  ab6f0be swrap: Add libc_send().
   via  fb02405 swrap: Add libc_recv().
   via  c7b7039 swrap: Add libc_recvfrom().
   via  c1b2021 swrap: Add libc_readv().
   via  430abba swrap: Add libc_read().
   via  89fcdfb swrap: Add libc_listen().
   via  6015f67 swrap: Correctly load ioctl().
   via  5a34128 squash swrap_load_lib_handle
   via  7af4d58 swrap: Add libc_getsockopt().
   via  9dd5276 swrap: Add libc_getsockname().
   via  3c67ca0 swrap: Add libc_getpeername().
   via  999ace2 swrap: Add libc_dup2().
   via  84e6729 swrap: Add libc_dup().
   via  2cfbea1 swrap: Add libc_connect().
   via  f3b03d7 swrap: Add libc_close().
   via  f7d9020 swrap: Add libc_bind().
   via  5f0fa21 swrap: Add libc_accept().
   via  2947b39 swrap: Add a swrap_load_lib_function macro.
   via  e69f51d swrap: Add new function to load libraries.
  from  76baedf swrap: Remove deprecated functions.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 9f7d7b4bdf1a17619fc4b1bb9569621e6f0b20c9
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 08:21:12 2013 +0100

swrap: Remove obsolete init functions.

This fixes preloading libsocket_wrapper.so with gdb.

commit e5899b84480c46c3ba5d7d24a97d9bc63d7baa7c
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 08:16:53 2013 +0100

swrap: Add libc_writev().

commit d344002876675e8a77f4d93303b8c2448fe02489
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 08:15:08 2013 +0100

swrap: Add libc_socket().

commit 4b72d3005246fb31ec038fc908729672df47364d
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 08:12:16 2013 +0100

swrap: Add libc_setsockopt().

commit a6bbc3867e96fb30a53ffacda28ee4e8344f8542
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 08:08:19 2013 +0100

swrap: Add libc_sendto().

commit 5b7e8960a325e7c3a9c08b24ce1079c0faa3c12d
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 07:57:26 2013 +0100

swrap: Add libc_sendmsg().

commit ab6f0beb78d2c0b4af1c47f1d816829b9abac003
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 07:54:21 2013 +0100

swrap: Add libc_send().

commit fb02405c73358d36e2cd08bd8d170bf2bbdb5b54
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 07:43:43 2013 +0100

swrap: Add libc_recv().

commit c7b7039a4643a975697615d263c1e30e126b9c37
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 07:41:43 2013 +0100

swrap: Add libc_recvfrom().

commit c1b2021ede8f3e2527ec0d5b28dd5bef259fca8a
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:46:00 2013 +0100

swrap: Add libc_readv().

commit 430abbadb0fdbc49879ce5bf02066f0194384fdb
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:44:09 2013 +0100

swrap: Add libc_read().

commit 89fcdfbf7bf162a950c52692e677f80c266971cf
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:42:03 2013 +0100

swrap: Add libc_listen().

commit 6015f679bcb6fff32660b39bc42ac2b2362ab72e
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:39:52 2013 +0100

swrap: Correctly load ioctl().

commit 5a34128deac0c456d973f851a728966c87964e6c
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:39:37 2013 +0100

squash swrap_load_lib_handle

commit 7af4d587f80f4f981fdd45404a7e1ac725647c75
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:36:02 2013 +0100

swrap: Add libc_getsockopt().

commit 9dd5276ce25f10278aca8342adfc5bcf332cbeb7
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:33:45 2013 +0100

swrap: Add libc_getsockname().

commit 3c67ca0e9eedd2db2d5b6c052935fbe43d140703
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:31:46 2013 +0100

swrap: Add libc_getpeername().

commit 999ace2a21cd6793d3502321ab0fd961e8c80f65
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:25:43 2013 +0100

swrap: Add libc_dup2().

commit 84e6729c4946b7b154e90ea347fcdc5aa42dc4ee
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:24:30 2013 +0100

swrap: Add libc_dup().

commit 2cfbea1bf2ff5f1edf1512cea5fbb12e87e0a800
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:22:42 2013 +0100

swrap: Add libc_connect().

commit f3b03d777e9da4fb70360219bd0ef4535028971e
Author: Andreas Schneider a...@cryptomilk.org
Date:   Mon Dec 9 19:18:39 2013 +0100

swrap: Add libc_close().

commit 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-10 Thread Andreas Schneider
The branch, master has been updated
   via  2b53d42 tests: Add test_echo_udp_sendto_recvfrom.
   via  b853eac cmake: Remove swrap env variables.
   via  76c362f tests: Add a simple echo server
  from  9f7d7b4 swrap: Remove obsolete init functions.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 2b53d420caa157aa7084ace2c07365bd675e026a
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 6 12:03:24 2013 +0100

tests: Add test_echo_udp_sendto_recvfrom.

commit b853eac01a7c79b280410b5bdc3eadfce4d1ee27
Author: Andreas Schneider a...@samba.org
Date:   Fri Dec 6 12:02:46 2013 +0100

cmake: Remove swrap env variables.

They should be set up in the test!

commit 76c362fa3be7c65e5c50b9400cbc52a8cc81ed3b
Author: Jakub Hrozek jhro...@redhat.com
Date:   Thu Dec 5 20:36:05 2013 +0100

tests: Add a simple echo server

---

Summary of changes:
 tests/CMakeLists.txt  |   45 ++---
 tests/echo_srv.c  |  330 +
 tests/test_echo_udp_sendto_recvfrom.c |  200 
 tests/torture.h   |   45 +
 4 files changed, 595 insertions(+), 25 deletions(-)
 create mode 100644 tests/echo_srv.c
 create mode 100644 tests/test_echo_udp_sendto_recvfrom.c
 create mode 100644 tests/torture.h


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ab55d07..49cd62a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -6,29 +6,24 @@ include_directories(
   ${CMOCKA_INCLUDE_DIR}
 )
 
+add_executable(echo_srv echo_srv.c)
+
 add_cmocka_test(testsuite testsuite.c ${CMOCKA_LIBRARY} 
${SWRAP_REQUIRED_LIBRARIES})
-if (OSX)
-set_property(
-TEST
-testsuite
-PROPERTY
-ENVIRONMENT 
DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${CMAKE_BINARY_DIR}/src/libsocket_wrapper.dylib)
-else ()
-set_property(
-TEST
-testsuite
-PROPERTY
-ENVIRONMENT LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libsocket_wrapper.so)
-endif()
-set_property(
-TEST
-testsuite
-APPEND
-PROPERTY
-ENVIRONMENT SOCKET_WRAPPER_DIR=${CMAKE_CURRENT_BINARY_DIR})
-set_property(
-TEST
-testsuite
-APPEND
-PROPERTY
-ENVIRONMENT SOCKET_WRAPPER_DEFAULT_IFACE=11)
+add_cmocka_test(test_echo_udp_sendto_recvfrom test_echo_udp_sendto_recvfrom.c 
${CMOCKA_LIBRARY} ${SWRAP_REQUIRED_LIBRARIES})
+
+set(SWRAP_TESTS testsuite test_echo_udp_sendto_recvfrom)
+foreach(_SWRAP_TEST ${SWRAP_TESTS})
+if (OSX)
+set_property(
+TEST
+${_SWRAP_TEST}
+PROPERTY
+ENVIRONMENT 
DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${CMAKE_BINARY_DIR}/src/libsocket_wrapper.dylib)
+else ()
+set_property(
+TEST
+${_SWRAP_TEST}
+PROPERTY
+ENVIRONMENT 
LD_PRELOAD=${CMAKE_BINARY_DIR}/src/libsocket_wrapper.so)
+endif()
+endforeach()
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
new file mode 100644
index 000..13e2bc3
--- /dev/null
+++ b/tests/echo_srv.c
@@ -0,0 +1,330 @@
+#include stdio.h
+#include stdlib.h
+#include errno.h
+#include sys/socket.h
+#include sys/types.h
+#include sys/stat.h
+#include resolv.h
+#include arpa/inet.h
+#include errno.h
+#include netdb.h
+#include string.h
+#include getopt.h
+#include unistd.h
+#include fcntl.h
+#include stdbool.h
+
+#ifndef PIDFILE
+#define PIDFILE echo_srv.pid
+#endif  /* PIDFILE */
+
+#define DFL_PORT7
+#define BACKLOG 5
+
+#ifndef BUFSIZE
+#define BUFSIZE 4194304
+#endif /* BUFSIZE */
+
+struct echo_srv_opts {
+int port;
+int socktype;
+bool daemon;
+char *bind;
+const char *pidfile;
+};
+
+static int pidfile(const char *path)
+{
+int err;
+int fd;
+char pid_str[32];
+
+fd = open(path, O_RDONLY, 0644);
+err = errno;
+if (fd != -1) {
+close(fd);
+return EEXIST;
+} else if (err != ENOENT) {
+return err;
+}
+
+fd = open(path, O_CREAT | O_WRONLY | O_EXCL, 0644);
+err = errno;
+if (fd == -1) {
+return err;
+}
+
+memset(pid_str, 0, sizeof(pid_str));
+snprintf(pid_str, sizeof(pid_str) -1, %u\n, (unsigned int) getpid());
+write(fd, pid_str, strlen(pid_str));
+
+return 0;
+}
+
+static int become_daemon(struct echo_srv_opts *opts)
+{
+int ret;
+pid_t child_pid;
+int fd;
+
+if (getppid() == 1) {
+return 0;
+}
+
+child_pid = fork();
+if (child_pid == -1) {
+ret = errno;
+perror(fork);
+return ret;
+} else if (child_pid  0) {
+exit(0);
+}
+
+/* If a working directory was defined, go there */
+#ifdef WORKING_DIR
+chdir(WORKING_DIR);
+#endif
+
+ret = pidfile(opts-pidfile);
+if (ret != 0) 

[SCM] Socket Wrapper Repository - branch master updated

2013-12-10 Thread Andreas Schneider
The branch, master has been updated
   via  76c7df9 tests: Add test_sendto_recvfrom_ipv6().
   via  fe78b28 torture: Add torture_setup_echo_srv_udp_ipv6().
   via  88aeb65 torture_teardown_echo_srv
   via  0c4a784 tests: Use torture helpers in test_echo_udp_sendto_recvfrom.
   via  c6c0669 tests: Add teardown functions to torture lib.
   via  1e12eb0 tests: Add a torture library with helpers.
   via  78cc4fb tests: Fix the help output of the echo server
  from  2b53d42 tests: Add test_echo_udp_sendto_recvfrom.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 76c7df9fceb992e3d9de2f29d9dfb508f60df0de
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 11:46:03 2013 +0100

tests: Add test_sendto_recvfrom_ipv6().

commit fe78b28f689201617bc8312378f3c7f59239eb1b
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 11:38:08 2013 +0100

torture: Add torture_setup_echo_srv_udp_ipv6().

commit 88aeb652d94f7f951ca9cd41322202f7f02e8acb
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 11:37:44 2013 +0100

torture_teardown_echo_srv

commit 0c4a784047a6a8eda69d31e6db49a5904836e2de
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 11:19:34 2013 +0100

tests: Use torture helpers in test_echo_udp_sendto_recvfrom.

commit c6c0669a2a9c4141693a7cf1d8f5f35ee9bda7ac
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 11:14:04 2013 +0100

tests: Add teardown functions to torture lib.

commit 1e12eb0b3e4f974c33a2b628d0857e137fce8cfa
Author: Andreas Schneider a...@cryptomilk.org
Date:   Tue Dec 10 11:03:12 2013 +0100

tests: Add a torture library with helpers.

commit 78cc4fb76d14d4df313e412bf148312eea2c706b
Author: Jakub Hrozek jhro...@redhat.com
Date:   Tue Dec 10 10:57:24 2013 +0100

tests: Fix the help output of the echo server

---

Summary of changes:
 tests/CMakeLists.txt  |   12 ++-
 tests/echo_srv.c  |   11 ++-
 tests/test_echo_udp_sendto_recvfrom.c |  175 +++--
 tests/torture.c   |  170 
 tests/torture.h   |   26 +-
 5 files changed, 272 insertions(+), 122 deletions(-)
 create mode 100644 tests/torture.c


Changeset truncated at 500 lines:

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 49cd62a..1154561 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -6,13 +6,21 @@ include_directories(
   ${CMOCKA_INCLUDE_DIR}
 )
 
+set(TORTURE_LIBRARY torture)
+
+# RFC862 echo server
 add_executable(echo_srv echo_srv.c)
 
-add_cmocka_test(testsuite testsuite.c ${CMOCKA_LIBRARY} 
${SWRAP_REQUIRED_LIBRARIES})
-add_cmocka_test(test_echo_udp_sendto_recvfrom test_echo_udp_sendto_recvfrom.c 
${CMOCKA_LIBRARY} ${SWRAP_REQUIRED_LIBRARIES})
+add_library(${TORTURE_LIBRARY} STATIC torture.c)
+target_link_libraries(${TORTURE_LIBRARY}
+${CMOCKA_LIBRARY}
+${SWRAP_REQUIRED_LIBRARIES})
 
 set(SWRAP_TESTS testsuite test_echo_udp_sendto_recvfrom)
+
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
+add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
+
 if (OSX)
 set_property(
 TEST
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index 13e2bc3..32a03da 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -296,8 +296,15 @@ int main(int argc, char **argv)
 opts.daemon = true;
 break;
 default: /* '?' */
-fprintf(stderr, Usage: %s [-p port] [-u] [-t] [--pid 
pidfile]\n,
-argv[0]);
+fprintf(stderr, Usage: %s [-p port] [-u] [-t] [-b bind_addr] 
 \
+[-D] [--pid pidfile]\n
+-t makes the server listen on TCP\n
+-u makes the server listen on UDP\n
+-D tells the server to become a deamon and  \
+write a PIDfile\n
+The default port is 7, the default PIDfile is 
 \
+echo_srv.pid in the current directory\n,
+argv[0]);
 ret = 1;
 goto done;
 }
diff --git a/tests/test_echo_udp_sendto_recvfrom.c 
b/tests/test_echo_udp_sendto_recvfrom.c
index 9596e5e..7139656 100644
--- a/tests/test_echo_udp_sendto_recvfrom.c
+++ b/tests/test_echo_udp_sendto_recvfrom.c
@@ -11,138 +11,77 @@
 #include sys/socket.h
 #include netinet/in.h
 #include arpa/inet.h
-#include string.h
 #include stdlib.h
 #include stdio.h
 
-#include signal.h
-
-#include sys/stat.h
-#include fcntl.h
-
-#include unistd.h
-
-#define ECHO_SRV_IP 127.0.0.10
-#define ECHO_SRV_PORT 7
-
-#define ECHO_SRV_PIDFILE echo_srv.pid
-

[SCM] Socket Wrapper Repository - branch master updated

2013-12-05 Thread Andreas Schneider
The branch, master has been updated
   via  76baedf swrap: Remove deprecated functions.
   via  fe9d674 swrap: Use swrap structure for writev.
   via  5387e90 swrap: Use swrap structure for socket.
   via  d5581e7 swrap: Use swrap structure for setsockopt.
   via  156ba02 swrap: Use swrap structure for sendto.
   via  bb16b46 swrap: Use swrap structure for sendmsg.
   via  f146e8f swrap: Use swrap structure for send.
   via  9edc0af swrap: Use swrap structure for recvfrom.
   via  063c81a swrap: Use swrap structure for recv.
   via  bc81181 swrap: Use swrap structure for readv.
   via  7c271fd swrap: Use swrap structure for read.
   via  134903a swrap: Use swrap structure for listen.
   via  a1e494b swrap: Use swrap structure for ioctl.
   via  e0767c2 swrap: Use swrap structure for getsockopt.
   via  8745a7f swrap: Use swrap structure for getsockname.
   via  ee6466e swrap: Use swrap structure for getpeername.
   via  9a391ba swrap: Use swrap structure for dup2.
   via  2cd7116 swrap: Use swrap structure for dup.
   via  8e1dcb5 swrap: Use swrap structure for connect.
   via  0beaff2 swrap: Use swrap structure for close.
   via  19ada82 swrap: Use swrap structure for bind.
   via  bc5ff6a swrap: Use swrap structure for accept.
   via  0e3ebfe swrap: Add swrap_init() and swrap_enabled().
   via  2ca8c44 swrap: Add swrap_libc_init() function.
   via  fcbfac3 swrap: Add a swrap structure.
   via  883231b Add .gitignore.
   via  6dddbf0 cmake: Set _FORTIFY_SOURCE only for optimized builds.
  from  2af983f tests: Fix test on Solaris.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 76baedfc887b61c8b98d37b21348cb49c1545381
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:55:43 2013 +0100

swrap: Remove deprecated functions.

commit fe9d674f431957f4068e5ad512abd7db4cf7cd35
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:54:49 2013 +0100

swrap: Use swrap structure for writev.

commit 5387e90765707cc14c8d6d010134ec8c452570f7
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:54:17 2013 +0100

swrap: Use swrap structure for socket.

commit d5581e77abb06960868798f2f5f2263626d57003
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:53:01 2013 +0100

swrap: Use swrap structure for setsockopt.

commit 156ba02ef15dcdf0d45e3be9fe06fe8acccf5607
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:51:21 2013 +0100

swrap: Use swrap structure for sendto.

commit bb16b4616bc07a506ff99e50477abb9407722688
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:50:15 2013 +0100

swrap: Use swrap structure for sendmsg.

commit f146e8ff232566fb50bb460649280cf4953d6446
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:49:27 2013 +0100

swrap: Use swrap structure for send.

commit 9edc0af55a62b06e3dd41d2ad388064b2c1a3a79
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:47:47 2013 +0100

swrap: Use swrap structure for recvfrom.

commit 063c81a918b899b35645d238063f9c6a11881a32
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:46:26 2013 +0100

swrap: Use swrap structure for recv.

commit bc81181b2dfea7eb99cec9003f62705f6797d0dc
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 13:45:19 2013 +0100

swrap: Use swrap structure for readv.

commit 7c271fdbba87b4cc782077126c8ac4b0795b6b29
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:19:48 2013 +0100

swrap: Use swrap structure for read.

commit 134903a7c4622a7971e7d4cc7f0fbfc1350beb82
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:18:31 2013 +0100

swrap: Use swrap structure for listen.

commit a1e494ba5d4a7badafc0c3debfddfd9f6d3e4e61
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:17:27 2013 +0100

swrap: Use swrap structure for ioctl.

commit e0767c253ec920044c93b8c14cdf64e953fc8e49
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:14:32 2013 +0100

swrap: Use swrap structure for getsockopt.

commit 8745a7f2752a747655499ecc290c91390e4caaa7
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:13:04 2013 +0100

swrap: Use swrap structure for getsockname.

commit ee6466ee26d8642137959d8d17029736a35cdb96
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:11:57 2013 +0100

swrap: Use swrap structure for getpeername.

commit 9a391bab56829a6881b48de96a86b7cba1668d45
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:11:01 2013 +0100

swrap: Use swrap structure for dup2.

commit 2cd71169229374e0b83dbc2a4bcdd2d84a4aad6a
Author: Andreas Schneider a...@cryptomilk.org
Date:   Thu Dec 5 12:10:10 2013 +0100

swrap: Use swrap structure for 

<    1   2