]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Use net_getunixname() instead of implementing it ourself.
authorTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2009 21:04:37 +0000 (17:04 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2009 21:04:37 +0000 (17:04 -0400)
--HG--
branch : HEAD

src/auth/main.c

index 1860a0b0eeaac96e5b0597bcdf0406f051e38e5e..b8ad57ff15cb542936c9027a5d0fb07161dc1d57 100644 (file)
@@ -124,23 +124,16 @@ static void worker_connected(const struct master_service_connection *conn)
 static void client_connected(const struct master_service_connection *conn)
 {
        enum auth_socket_type *type;
+       const char *name, *suffix;
 
        type = array_idx_modifiable(&listen_fd_types, conn->listen_fd);
        if (*type == AUTH_SOCKET_UNKNOWN) {
                /* figure out if this is a server or network socket by
                   checking the socket path name. */
-               struct sockaddr_un sa;
-               socklen_t addrlen = sizeof(sa);
-               const char *suffix;
-
-               if (getsockname(conn->listen_fd, (void *)&sa, &addrlen) < 0)
+               if (net_getunixname(conn->listen_fd, &name) < 0)
                        i_fatal("getsockname(%d) failed: %m", conn->listen_fd);
-               if (sa.sun_family != AF_UNIX) {
-                       i_fatal("getsockname(%d) isn't UNIX socket",
-                               conn->listen_fd);
-               }
 
-               suffix = strrchr(sa.sun_path, '-');
+               suffix = strrchr(name, '-');
                if (suffix == NULL)
                        *type = AUTH_SOCKET_CLIENT;
                else {