dovecot-2.0: auth: Use net_getunixname() instead of implementing...

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 1 00:21:47 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/4efd13c0f778
changeset: 9844:4efd13c0f778
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 31 17:04:37 2009 -0400
description:
auth: Use net_getunixname() instead of implementing it ourself.

diffstat:

1 file changed, 4 insertions(+), 11 deletions(-)
src/auth/main.c |   15 ++++-----------

diffs (31 lines):

diff -r 95fba8612a87 -r 4efd13c0f778 src/auth/main.c
--- a/src/auth/main.c	Mon Aug 31 17:04:27 2009 -0400
+++ b/src/auth/main.c	Mon Aug 31 17:04:37 2009 -0400
@@ -124,23 +124,16 @@ static void client_connected(const struc
 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 (net_getunixname(conn->listen_fd, &name) < 0)
+			i_fatal("getsockname(%d) failed: %m", conn->listen_fd);
 
-		if (getsockname(conn->listen_fd, (void *)&sa, &addrlen) < 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 {


More information about the dovecot-cvs mailing list