- (dtucker) [acconfig.h configure.ac port-aix.c] Older AIXes don't declare
   loginfailed at all, so assume 3-arg loginfailed if not declared.
diff --git a/ChangeLog b/ChangeLog
index 89adc12..cddfe3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,11 @@
+20030714
+ - (dtucker) [acconfig.h configure.ac port-aix.c] Older AIXes don't declare
+   loginfailed at all, so assume 3-arg loginfailed if not declared.
+
 20030708
  - (dtucker) [acconfig.h auth-passwd.c configure.ac session.c port-aix.[ch]]
    Include AIX headers for authentication functions and make calls match
-   prototypes.  Test for and handle 3-args and 4-arg variants of loginfailed.
+   prototypes.  Test for and handle 3-arg and 4-arg variants of loginfailed.
  - (dtucker) [session.c] Check return value of setpcred().
  - (dtucker) [auth-passwd.c auth.c session.c sshd.c port-aix.c port-aix.h]
    Convert aixloginmsg into platform-independant Buffer loginmsg.
@@ -670,4 +674,4 @@
  - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
    Report from murple@murple.net, diagnosis from dtucker@zip.com.au
 
-$Id: ChangeLog,v 1.2849 2003/07/08 12:59:59 dtucker Exp $
+$Id: ChangeLog,v 1.2850 2003/07/14 06:21:44 dtucker Exp $
diff --git a/acconfig.h b/acconfig.h
index 23cc9c8..0af9366 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,4 +1,4 @@
-/* $Id: acconfig.h,v 1.158 2003/07/08 10:52:13 dtucker Exp $ */
+/* $Id: acconfig.h,v 1.159 2003/07/14 06:21:44 dtucker Exp $ */
 
 /*
  * Copyright (c) 1999-2003 Damien Miller.  All rights reserved.
@@ -110,8 +110,8 @@
 /* Define if you want to enable AIX4's authenticate function */
 #undef WITH_AIXAUTHENTICATE
 
-/* Define if your AIX loginfailed() function takes 3 arguments (AIX <= 5.1) */
-#undef AIX_LOGINFAILED_3ARG
+/* Define if your AIX loginfailed() function takes 4 arguments (AIX >= 5.2) */
+#undef AIX_LOGINFAILED_4ARG
 
 /* Define if you have/want arrays (cluster-wide session managment, not C arrays) */
 #undef WITH_IRIX_ARRAY
diff --git a/configure.ac b/configure.ac
index 431c644..8a23469 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.132 2003/07/08 10:52:13 dtucker Exp $
+# $Id: configure.ac,v 1.133 2003/07/14 06:21:44 dtucker Exp $
 
 AC_INIT
 AC_CONFIG_SRCDIR([ssh.c])
@@ -75,25 +75,26 @@
 		AC_MSG_RESULT($blibflags)
 	fi
 	LDFLAGS="$saved_LDFLAGS"
-	# Check for authenticate.  Might be in libs.a on older AIXes
-	AC_CHECK_FUNC(authenticate, [with_aixauthenticate=1],
+	dnl Check for authenticate.  Might be in libs.a on older AIXes
+	AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE)],
 		[AC_CHECK_LIB(s,authenticate,
-			[ 	with_aixaixauthenticate=1
+			[ AC_DEFINE(WITH_AIXAUTHENTICATE)
 				LIBS="$LIBS -ls"
 			])
 		])
-	# Check if loginfailed takes 3 arguments (AIX <= 5.1)
-	if (test "x$with_aixauthenticate" = "x1" ); then
-		AC_DEFINE(WITH_AIXAUTHENTICATE)
-		AC_MSG_CHECKING(if loginfailed takes 3 arguments)
-		AC_TRY_COMPILE(
+	dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
+	AC_CHECK_DECL(loginfailed,
+		 [AC_MSG_CHECKING(if loginfailed takes 4 arguments)
+		  AC_TRY_COMPILE(
 			[#include <usersec.h>],
-			[(void)loginfailed("user","host","tty");],
- 			[AC_MSG_RESULT(yes)
-			 AC_DEFINE(AIX_LOGINFAILED_3ARG)],
+			[(void)loginfailed("user","host","tty",0);],
+			[AC_MSG_RESULT(yes)
+			 AC_DEFINE(AIX_LOGINFAILED_4ARG)],
 			[AC_MSG_RESULT(no)]
-		)
-	fi
+		)],
+		[],
+		[#include <usersec.h>]
+	)
 	AC_DEFINE(BROKEN_GETADDRINFO)
 	AC_DEFINE(BROKEN_REALPATH)
 	dnl AIX handles lastlog as part of its login message
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c
index cc6190c..5629237 100644
--- a/openbsd-compat/port-aix.c
+++ b/openbsd-compat/port-aix.c
@@ -92,10 +92,10 @@
 {
 	char *hostname = get_canonical_hostname(options.use_dns);
 
-#  ifdef AIX_LOGINFAILED_3ARG
-	loginfailed((char *)user, hostname, (char *)ttyname);
-#  else
+#  ifdef AIX_LOGINFAILED_4ARG
 	loginfailed((char *)user, hostname, (char *)ttyname, AUDIT_FAIL_AUTH);
+#  else
+	loginfailed((char *)user, hostname, (char *)ttyname);
 #  endif
 }
 # endif /* CUSTOM_FAILED_LOGIN */