]> andersk Git - gssapi-openssh.git/blobdiff - openssh/openbsd-compat/port-aix.c
fix AIX build problem with T_NULL being redefined
[gssapi-openssh.git] / openssh / openbsd-compat / port-aix.c
index cf5d4b9a34e6c9b76146ae6f5e6230252baa378b..ce83043d939bdc20ff90f03d45c51be618dca57d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *
  * Copyright (c) 2001 Gert Doering.  All rights reserved.
- * Copyright (c) 2003,2004 Darren Tucker.  All rights reserved.
+ * Copyright (c) 2003,2004,2005 Darren Tucker.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  */
 #include "includes.h"
+
+#include "xmalloc.h"
+#include "buffer.h"
+#include "key.h"
+#include "hostfile.h"
 #include "auth.h"
 #include "ssh.h"
 #include "log.h"
-#include "xmalloc.h"
-#include "buffer.h"
 
 #ifdef _AIX
 
+#include <errno.h>
+#if defined(HAVE_NETDB_H)
+# include <netdb.h>
+#endif
 #include <uinfo.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/socket.h>
+
+#ifdef WITH_AIXAUTHENTICATE
+# include <login.h>
+# include <userpw.h>
+# if defined(HAVE_SYS_AUDIT_H) && defined(AIX_LOGINFAILED_4ARG)
+#  undef T_NULL
+#  include <sys/audit.h>
+# endif
+# include <usersec.h>
+#endif
+
 #include "port-aix.h"
 
 # ifdef HAVE_SETAUTHDB
@@ -42,14 +63,12 @@ static char old_registry[REGISTRY_SIZE] = "";
 # endif
 
 /*
- * AIX has a "usrinfo" area where logname and other stuff is stored - 
+ * AIX has a "usrinfo" area where logname and other stuff is stored -
  * a few applications actually use this and die if it's not set
  *
  * NOTE: TTY= should be set, but since no one uses it and it's hard to
  * acquire due to privsep code.  We will just drop support.
  */
-
-
 void
 aix_usrinfo(struct passwd *pw)
 {
@@ -60,7 +79,7 @@ aix_usrinfo(struct passwd *pw)
        len = sizeof("LOGNAME= NAME= ") + (2 * strlen(pw->pw_name));
        cp = xmalloc(len);
 
-       i = snprintf(cp, len, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, '\0', 
+       i = snprintf(cp, len, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, '\0',
            pw->pw_name, '\0');
        if (usrinfo(SETUINFO, cp, i) == -1)
                fatal("Couldn't set usrinfo: %s", strerror(errno));
@@ -153,14 +172,14 @@ aix_valid_authentications(const char *user)
 int
 sys_auth_passwd(Authctxt *ctxt, const char *password)
 {
-       char *authmsg = NULL, *msg, *name = ctxt->pw->pw_name;
+       char *authmsg = NULL, *msg = NULL, *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,
+               debug3("AIX/authenticate result %d, authmsg %.100s", result,
                    authmsg);
        } while (reenter);
 
@@ -170,7 +189,7 @@ sys_auth_passwd(Authctxt *ctxt, const char *password)
        if (result == 0) {
                authsuccess = 1;
 
-               /*
+               /*
                 * Record successful login.  We don't have a pty yet, so just
                 * label the line as "ssh"
                 */
@@ -257,16 +276,18 @@ int
 sys_auth_record_login(const char *user, const char *host, const char *ttynm,
     Buffer *loginmsg)
 {
-       char *msg;
+       char *msg = NULL;
+       static int msg_done = 0;
        int success = 0;
 
        aix_setauthdb(user);
        if (loginsuccess((char *)user, (char *)host, (char *)ttynm, &msg) == 0) {
                success = 1;
-               if (msg != NULL) {
+               if (msg != NULL && loginmsg != NULL && !msg_done) {
                        debug("AIX/loginsuccess: msg %s", msg);
                        buffer_append(loginmsg, msg, strlen(msg));
                        xfree(msg);
+                       msg_done = 1;
                }
        }
        aix_restoreauthdb();
This page took 0.045539 seconds and 4 git commands to generate.