swrap: Use a sockaddr_un for the unix path in socket_info.
authorAndreas Schneider <asn@samba.org>
Thu, 2 Oct 2014 05:16:25 +0000 (07:16 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 2 Oct 2014 07:35:10 +0000 (09:35 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/socket_wrapper/socket_wrapper.c

index b6f86ebbcfe123f8ed586eaf77452ef3443aeb36..b5c5b4671a1c6db49d1800551e781b9e517e2564 100644 (file)
@@ -242,7 +242,8 @@ struct socket_info
        int defer_connect;
        int pktinfo;
 
-       char *tmp_path;
+       /* The unix path so we can unlink it on close() */
+       struct sockaddr_un un_addr;
 
        struct sockaddr *bindname;
        socklen_t bindname_len;
@@ -2739,7 +2740,8 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
                ret = libc_bind(fd, &un_addr.sa.s, un_addr.sa_socklen);
                if (ret == -1) return ret;
 
-               si->tmp_path = strdup(un_addr.sa.un.sun_path);
+               si->un_addr = un_addr.sa.un;
+
                si->bound = 1;
                autobind_start = port + 1;
                break;
@@ -4789,9 +4791,9 @@ static int swrap_close(int fd)
 
        if (si->myname) free(si->myname);
        if (si->peername) free(si->peername);
-       if (si->tmp_path) {
-               unlink(si->tmp_path);
-               free(si->tmp_path);
+
+       if (si->un_addr.sun_path[0] != '\0') {
+               unlink(si->un_addr.sun_path);
        }
        free(si);