Index: openbsd-compat/port-aix.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/openbsd-compat/port-aix.c,v
retrieving revision 1.20
diff -u -p -r1.20 port-aix.c
--- openbsd-compat/port-aix.c	16 Jun 2004 02:01:16 -0000	1.20
+++ openbsd-compat/port-aix.c	16 Jun 2004 02:26:04 -0000
@@ -1,6 +1,6 @@
 /*
- *
  * Copyright (c) 2001 Gert Doering.  All rights reserved.
+ * Copyright (c) 2003,2004 Darren Tucker.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -101,15 +101,20 @@ aix_remove_embedded_newlines(char *p)
 int
 sys_auth_passwd(Authctxt *ctxt, const char *password)
 {
-	char *authmsg = NULL, *host, *msg, *name = ctxt->pw->pw_name;
+	char *msg = NULL, *host, *name = ctxt->pw->pw_name;
 	int authsuccess = 0, expired, reenter, result;
 
 	do {
 		result = authenticate((char *)name, (char *)password, &reenter,
-		    &authmsg);
-		aix_remove_embedded_newlines(authmsg);	
-		debug3("AIX/authenticate result %d, msg %.100s", result,
-		    authmsg);
+		    &msg);
+		if (!reenter && result == 0 && msg != NULL)
+			/* save final success message for display to user */
+			buffer_append(&loginmsg, msg, strlen(msg));
+		if (msg == NULL)
+			msg = xstrdup("(none)");
+		aix_remove_embedded_newlines(msg);	
+		debug3("AIX/authenticate result %d, msg %.100s", result, msg);
+		xfree(msg);
 	} while (reenter);
 
 	if (result == 0) {
@@ -122,22 +127,24 @@ sys_auth_passwd(Authctxt *ctxt, const ch
 		 * label the line as "ssh"
 		 */
 		aix_setauthdb(name);
-	       	if (loginsuccess((char *)name, (char *)host, "ssh", &msg) == 0) {
-			if (msg != NULL) {
-				debug("%s: msg %s", __func__, msg);
-				buffer_append(&loginmsg, msg, strlen(msg));
-				xfree(msg);
-			}
-		}
+		result = loginsuccess((char *)name, (char *)host, "ssh", &msg);
+		if (msg != NULL)
+			buffer_append(&loginmsg, msg, strlen(msg));
+		else
+			msg = xstrdup("(none)");
+		aix_remove_embedded_newlines(msg);
+		debug("AIX/loginsuccess returned %d msg %s", result, msg);
+		xfree(msg);
 
 		/*
 		 * Check if the user's password is expired.
 		 */
 		expired = passwdexpired(name, &msg);
-		if (msg && *msg) {
+		if (msg != NULL)
 			buffer_append(&loginmsg, msg, strlen(msg));
-			aix_remove_embedded_newlines(msg);
-		}
+		else
+			msg = xstrdup("(none)");
+		aix_remove_embedded_newlines(msg);
 		debug3("AIX/passwdexpired returned %d msg %.100s", expired, msg);
 
 		switch (expired) {
@@ -150,16 +157,11 @@ sys_auth_passwd(Authctxt *ctxt, const ch
 		default: /* user can't change(2) or other error (-1) */
 			logit("Password can't be changed for user %s: %.100s",
 			    name, msg);
-			if (msg)
-				xfree(msg);
 			authsuccess = 0;
 		}
-
+		xfree(msg);
 		aix_restoreauthdb();
 	}
-
-	if (authmsg != NULL)
-		xfree(authmsg);
 
 	return authsuccess;
 }
