1#include <stdlib.h>
2#include <string.h>
3#include <stdio.h>
4#include <sys/socket.h>
5#include <sys/un.h>
6#include <errno.h>
7
8int main() {
9  int listen_fd;
10  struct sockaddr_un addr;
11
12  listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
13
14  if (listen_fd < 0)
15    {
16      fprintf (stderr, "socket() failed: %s\n", strerror (errno));
17      exit (1);
18    }
19
20  memset (&addr, '\0', sizeof (addr));
21  addr.sun_family = AF_UNIX;
22  strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
23  addr.sun_path[0] = '\0'; /* this is what makes it abstract */
24
25  if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
26    {
27      fprintf (stderr, "Abstract socket namespace bind() failed: %s\n",
28                strerror (errno));
29      exit (1);
30    }
31  else
32    exit (0);
33}