diff options
author | Frank Osterfeld <frank@kdab.net> | 2009-04-22 11:49:58 +0200 |
---|---|---|
committer | unknown <Administrator@.(none)> | 2009-11-30 10:54:32 +0100 |
commit | 2feb3e2e653be1ef1292b92036f919bb990586c9 (patch) | |
tree | 924d6da6c7513169335a32b936d07ae8073e7e1c /cmake/modules | |
parent | 7fac18bd153f8d9184a9c5b41af70258aa62b680 (diff) | |
download | dbus-2feb3e2e653be1ef1292b92036f919bb990586c9.tar.gz |
add check for abstract sockets (cherry picked from commit 5b657984f4bc5544a8df560adcd224ed243972f1)
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/CheckForAbstractSockets.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cmake/modules/CheckForAbstractSockets.c b/cmake/modules/CheckForAbstractSockets.c new file mode 100644 index 00000000..062b846c --- /dev/null +++ b/cmake/modules/CheckForAbstractSockets.c @@ -0,0 +1,33 @@ +#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 |