r17586: merge lib/netif into lib/socket and use -lnsl -lsocket on the
[sfrench/samba-autobuild/.git] / source4 / nsswitch / wb_common.c
index a26e430db4fe1ab4b06e28214d39909b4510024c..98eeb279f84f2c9c2784a089fa8760a94863320b 100644 (file)
@@ -25,6 +25,7 @@
 */
 
 #include "includes.h"
+#include "nsswitch/winbind_client.h"
 
 /* Global variables.  These are effectively the client state information */
 
@@ -171,7 +172,7 @@ static int winbind_named_pipe_sock(const char *dir)
 {
        struct sockaddr_un sunaddr;
        struct stat st;
-       pstring path;
+       char *path;
        int fd;
        int wait_time;
        int slept;
@@ -189,8 +190,7 @@ static int winbind_named_pipe_sock(const char *dir)
        
        /* Connect to socket */
 
-       snprintf(path, sizeof(path), "%s%s", dir, "/" WINBINDD_SOCKET_NAME);
-       
+       asprintf(&path, "%s%s", dir, "/" WINBINDD_SOCKET_NAME);
        ZERO_STRUCT(sunaddr);
        sunaddr.sun_family = AF_UNIX;
        strncpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path) - 1);
@@ -200,8 +200,11 @@ static int winbind_named_pipe_sock(const char *dir)
           the winbindd daemon is not running. */
 
        if (lstat(path, &st) == -1) {
+               SAFE_FREE(path);
                return -1;
        }
+
+       SAFE_FREE(path);
        
        /* Check permissions on unix socket file */
        
@@ -227,7 +230,8 @@ static int winbind_named_pipe_sock(const char *dir)
                struct timeval tv;
                fd_set w_fds;
                int ret;
-               int connect_errno = 0, errnosize;
+               int connect_errno = 0;
+               socklen_t errnosize;
 
                if (wait_time >= CONNECT_TIMEOUT)
                        goto error_out;