* Ident authentication
*----------------------------------------------------------------
*/
-/* Max size of username ident server can return */
+/* Max size of username ident server can return (per RFC 1413) */
#define IDENT_USERNAME_MAX 512
/* Standard TCP port number for Ident service. Assigned by IANA */
static int
auth_peer(hbaPort *port)
{
- char ident_user[IDENT_USERNAME_MAX + 1];
uid_t uid;
gid_t gid;
struct passwd *pw;
+ char *peer_user;
+ int ret;
if (getpeereid(port->sock, &uid, &gid) != 0)
{
return STATUS_ERROR;
}
- strlcpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
+ /* Make a copy of static getpw*() result area. */
+ peer_user = pstrdup(pw->pw_name);
+
+ ret = check_usermap(port->hba->usermap, port->user_name, peer_user, false);
- return check_usermap(port->hba->usermap, port->user_name, ident_user, false);
+ pfree(peer_user);
+
+ return ret;
}
#endif /* HAVE_UNIX_SOCKETS */