Commit af808203 authored by Brandon Carpenter's avatar Brandon Carpenter

Fix failing test case in test_filter_ipc.

Add explicit check for primary group.
parent f5b6bd70
...@@ -170,7 +170,6 @@ case "${host_os}" in ...@@ -170,7 +170,6 @@ case "${host_os}" in
fi fi
AC_DEFINE(ZMQ_HAVE_LINUX, 1, [Have Linux OS]) AC_DEFINE(ZMQ_HAVE_LINUX, 1, [Have Linux OS])
libzmq_on_linux="yes" libzmq_on_linux="yes"
AC_CHECK_DECLS([SO_PEERCRED], [AC_DEFINE(ZMQ_HAVE_SO_PEERCRED, 1, [Have SO_PEERCRED socket option])], [], [#include <sys/socket.h>])
if test "x$libzmq_tipc_support" = "xyes"; then if test "x$libzmq_tipc_support" = "xyes"; then
AC_DEFINE(ZMQ_HAVE_TIPC, 1, [Have TIPC support]) AC_DEFINE(ZMQ_HAVE_TIPC, 1, [Have TIPC support])
...@@ -216,7 +215,6 @@ case "${host_os}" in ...@@ -216,7 +215,6 @@ case "${host_os}" in
libzmq_pedantic="no" libzmq_pedantic="no"
libzmq_werror="no" libzmq_werror="no"
AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS])
AC_CHECK_DECLS([LOCAL_PEERCRED], [AC_DEFINE(ZMQ_HAVE_LOCAL_PEERCRED, 1, [Have LOCAL_PEERCRED socket option])], [], [#include <sys/socket.h>])
AC_LANG_PUSH([C++]) AC_LANG_PUSH([C++])
LIBZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-uninitialized]) LIBZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-uninitialized])
AC_LANG_POP([C++]) AC_LANG_POP([C++])
...@@ -351,6 +349,9 @@ if test "x$zmq_disable_eventfd" != "xyes"; then ...@@ -351,6 +349,9 @@ if test "x$zmq_disable_eventfd" != "xyes"; then
[AC_DEFINE(ZMQ_HAVE_EVENTFD, 1, [Have eventfd extension.])]) [AC_DEFINE(ZMQ_HAVE_EVENTFD, 1, [Have eventfd extension.])])
fi fi
AC_CHECK_DECLS([SO_PEERCRED], [AC_DEFINE(ZMQ_HAVE_SO_PEERCRED, 1, [Have SO_PEERCRED socket option])], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([LOCAL_PEERCRED], [AC_DEFINE(ZMQ_HAVE_LOCAL_PEERCRED, 1, [Have LOCAL_PEERCRED socket option])], [], [#include <sys/socket.h>])
# Use c++ in subsequent tests # Use c++ in subsequent tests
AC_LANG_PUSH(C++) AC_LANG_PUSH(C++)
......
...@@ -215,6 +215,7 @@ bool zmq::ipc_listener_t::filter (fd_t sock) ...@@ -215,6 +215,7 @@ bool zmq::ipc_listener_t::filter (fd_t sock)
if (getsockopt (sock, SOL_SOCKET, SO_PEERCRED, &cred, &size)) if (getsockopt (sock, SOL_SOCKET, SO_PEERCRED, &cred, &size))
return false; return false;
if (options.ipc_uid_accept_filters.find (cred.uid) != options.ipc_uid_accept_filters.end () || if (options.ipc_uid_accept_filters.find (cred.uid) != options.ipc_uid_accept_filters.end () ||
options.ipc_gid_accept_filters.find (cred.gid) != options.ipc_gid_accept_filters.end () ||
options.ipc_pid_accept_filters.find (cred.pid) != options.ipc_pid_accept_filters.end ()) options.ipc_pid_accept_filters.find (cred.pid) != options.ipc_pid_accept_filters.end ())
return true; return true;
...@@ -227,10 +228,11 @@ bool zmq::ipc_listener_t::filter (fd_t sock) ...@@ -227,10 +228,11 @@ bool zmq::ipc_listener_t::filter (fd_t sock)
it != options.ipc_gid_accept_filters.end (); it++) { it != options.ipc_gid_accept_filters.end (); it++) {
if (!(gr = getgrgid (*it))) if (!(gr = getgrgid (*it)))
continue; continue;
for (char **mem = gr->gr_mem; *mem; mem++) for (char **mem = gr->gr_mem; *mem; mem++) {
if (!strcmp (*mem, pw->pw_name)) if (!strcmp (*mem, pw->pw_name))
return true; return true;
} }
}
return false; return false;
} }
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <string>
#include <sstream>
#include "testutil.hpp" #include "testutil.hpp"
static void bounce_fail (void *server, void *client) static void bounce_fail (void *server, void *client)
...@@ -52,6 +55,8 @@ static void bounce_fail (void *server, void *client) ...@@ -52,6 +55,8 @@ static void bounce_fail (void *server, void *client)
template <class T> template <class T>
static void run_test (int opt, T optval, int expected_error, int bounce_test) static void run_test (int opt, T optval, int expected_error, int bounce_test)
{ {
int rc;
void *ctx = zmq_ctx_new (); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
...@@ -59,7 +64,7 @@ static void run_test (int opt, T optval, int expected_error, int bounce_test) ...@@ -59,7 +64,7 @@ static void run_test (int opt, T optval, int expected_error, int bounce_test)
assert (sb); assert (sb);
if (opt) { if (opt) {
int rc = zmq_setsockopt(sb, opt, &optval, sizeof (optval)); rc = zmq_setsockopt(sb, opt, &optval, sizeof (optval));
if (expected_error) { if (expected_error) {
assert (rc == -1); assert (rc == -1);
assert (zmq_errno () == expected_error); assert (zmq_errno () == expected_error);
...@@ -71,6 +76,20 @@ static void run_test (int opt, T optval, int expected_error, int bounce_test) ...@@ -71,6 +76,20 @@ static void run_test (int opt, T optval, int expected_error, int bounce_test)
void *sc = zmq_socket (ctx, ZMQ_PAIR); void *sc = zmq_socket (ctx, ZMQ_PAIR);
assert (sc); assert (sc);
// If a test fails, don't hang for too long
int timeout = 1500;
rc = zmq_setsockopt (sb, ZMQ_RCVTIMEO, &timeout, sizeof (int));
assert (rc == 0);
rc = zmq_setsockopt (sb, ZMQ_SNDTIMEO, &timeout, sizeof (int));
assert (rc == 0);
rc = zmq_setsockopt (sc, ZMQ_RCVTIMEO, &timeout, sizeof (int));
assert (rc == 0);
rc = zmq_setsockopt (sc, ZMQ_SNDTIMEO, &timeout, sizeof (int));
assert (rc == 0);
int interval = -1;
rc = zmq_setsockopt (sc, ZMQ_RECONNECT_IVL, &interval, sizeof (int));
assert (rc == 0);
if (bounce_test) { if (bounce_test) {
int rc = zmq_bind (sb, "ipc://@/tmp/test"); int rc = zmq_bind (sb, "ipc://@/tmp/test");
assert (rc == 0); assert (rc == 0);
...@@ -87,7 +106,7 @@ static void run_test (int opt, T optval, int expected_error, int bounce_test) ...@@ -87,7 +106,7 @@ static void run_test (int opt, T optval, int expected_error, int bounce_test)
close_zero_linger (sc); close_zero_linger (sc);
close_zero_linger (sb); close_zero_linger (sb);
int rc = zmq_ctx_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment