Commit 2feb3e2e authored by Frank Osterfeld's avatar Frank Osterfeld Committed by unknown

add check for abstract sockets (cherry picked from commit 5b657984f4bc5544a8df560adcd224ed243972f1)

parent 7fac18bd
......@@ -49,6 +49,9 @@ find_package(LibXml2)
find_package(LibExpat)
find_package(X11)
OPTION(DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON)
# do config checks
INCLUDE(ConfigureChecks.cmake)
......
......@@ -130,3 +130,20 @@ else(DBUS_HAVE_VA_COPY)
SET(DBUS_VA_COPY_AS_ARRAY "1" CACHE STRING "'va_lists' cannot be copies as values")
endif(DBUS_HAVE___VA_COPY)
endif(DBUS_HAVE_VA_COPY)
#### Abstract sockets
if (DBUS_ENABLE_ABSTRACT_SOCKETS)
try_compile(HAVE_ABSTRACT_SOCKETS
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/modules/CheckForAbstractSockets.c)
endif(DBUS_ENABLE_ABSTRACT_SOCKETS)
if(HAVE_ABSTRACT_SOCKETS)
set(DBUS_PATH_OR_ABSTRACT_VALUE abstract)
else(HAVE_ABSTRACT_SOCKETS)
set(DBUS_PATH_OR_ABSTRACT_VALUE path)
endif(HAVE_ABSTRACT_SOCKETS)
......@@ -48,7 +48,21 @@
/* xmldocs */
/* doxygen */
#cmakedefine DBUS_GCOV_ENABLED 1
/* abstract-sockets */
#cmakedefine HAVE_ABSTRACT_SOCKETS 1
#cmakedefine DBUS_PATH_OR_ABSTRACT_VALUE 1
#if (defined DBUS_PATH_OR_ABSTRACT_VALUE)
#define DBUS_PATH_OR_ABSTRACT @DBUS_PATH_OR_ABSTRACT_VALUE@
#endif
#ifdef DBUS_PATH_OR_ABSTRACT_VALUE
#undef DBUS_PATH_OR_ABSTRACT_VALUE
#endif
/* selinux */
#cmakedefine DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 1
/* kqueue */
......@@ -69,6 +83,10 @@
# define DBUS_VA_COPY @DBUS_VA_COPY_FUNC@
#endif
#ifdef DBUS_VA_COPY_FUNC
#undef DBUS_VA_COPY_FUNC
#endif
#cmakedefine DBUS_VA_COPY_AS_ARRAY 1
// headers
......
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
int main() {
int listen_fd;
struct sockaddr_un addr;
listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
if (listen_fd < 0)
{
fprintf (stderr, "socket() failed: %s\n", strerror (errno));
exit (1);
}
memset (&addr, '\0', sizeof (addr));
addr.sun_family = AF_UNIX;
strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
addr.sun_path[0] = '\0'; /* this is what makes it abstract */
if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
{
fprintf (stderr, "Abstract socket namespace bind() failed: %s\n",
strerror (errno));
exit (1);
}
else
exit (0);
}
\ No newline at end of file
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