summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2005-02-15 21:45:57 +1100
committerDarren Tucker <dtucker@zip.com.au>2005-02-15 21:45:57 +1100
commit691d5235ca9485877e8345269b1be4b2cf1be322 (patch)
tree7adbbdbb837a6d3d4953a6ea339ad9d9e6d289ce /openbsd-compat
parentf04c3616756831fe987fe3e474c8c234c298e4cb (diff)
- (dtucker) [README.platform auth.c configure.ac loginrec.c
openbsd-compat/port-aix.c openbsd-compat/port-aix.h] Bug #835: enable IPv6 on AIX where possible (see README.platform for details) and work around a misfeature of AIX's getnameinfo. ok djm@
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/port-aix.c45
-rw-r--r--openbsd-compat/port-aix.h22
2 files changed, 56 insertions, 11 deletions
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c
index b1698854..8ab862f9 100644
--- a/openbsd-compat/port-aix.c
+++ b/openbsd-compat/port-aix.c
@@ -34,14 +34,13 @@
#ifdef _AIX
#include <uinfo.h>
+#include <sys/socket.h>
#include "port-aix.h"
/* These should be in the system headers but are not. */
int usrinfo(int, char *, int);
int setauthdb(const char *, char *);
-extern Buffer loginmsg;
-
# ifdef HAVE_SETAUTHDB
static char old_registry[REGISTRY_SIZE] = "";
# endif
@@ -156,7 +155,7 @@ aix_valid_authentications(const char *user)
* returns 0.
*/
int
-sys_auth_passwd(Authctxt *ctxt, const char *password)
+sys_auth_passwd(Authctxt *ctxt, const char *password, Buffer *loginmsg)
{
char *authmsg = NULL, *msg, *name = ctxt->pw->pw_name;
int authsuccess = 0, expired, reenter, result;
@@ -186,7 +185,7 @@ sys_auth_passwd(Authctxt *ctxt, const char *password)
*/
expired = passwdexpired(name, &msg);
if (msg && *msg) {
- buffer_append(&loginmsg, msg, strlen(msg));
+ buffer_append(loginmsg, msg, strlen(msg));
aix_remove_embedded_newlines(msg);
}
debug3("AIX/passwdexpired returned %d msg %.100s", expired, msg);
@@ -219,7 +218,7 @@ sys_auth_passwd(Authctxt *ctxt, const char *password)
* Returns 1 if login is allowed, 0 if not allowed.
*/
int
-sys_auth_allowed_user(struct passwd *pw)
+sys_auth_allowed_user(struct passwd *pw, Buffer *loginmsg)
{
char *msg = NULL;
int result, permitted = 0;
@@ -246,7 +245,7 @@ sys_auth_allowed_user(struct passwd *pw)
if (result == -1 && errno == EPERM && stat(_PATH_NOLOGIN, &st) == 0)
permitted = 1;
else if (msg != NULL)
- buffer_append(&loginmsg, msg, strlen(msg));
+ buffer_append(loginmsg, msg, strlen(msg));
if (msg == NULL)
msg = xstrdup("(none)");
aix_remove_embedded_newlines(msg);
@@ -259,7 +258,8 @@ sys_auth_allowed_user(struct passwd *pw)
}
int
-sys_auth_record_login(const char *user, const char *host, const char *ttynm)
+sys_auth_record_login(const char *user, const char *host, const char *ttynm,
+ Buffer *loginmsg)
{
char *msg;
int success = 0;
@@ -269,7 +269,7 @@ sys_auth_record_login(const char *user, const char *host, const char *ttynm)
success = 1;
if (msg != NULL) {
debug("AIX/loginsuccess: msg %s", msg);
- buffer_append(&loginmsg, msg, strlen(msg));
+ buffer_append(loginmsg, msg, strlen(msg));
xfree(msg);
}
}
@@ -349,4 +349,33 @@ aix_restoreauthdb(void)
# endif /* WITH_AIXAUTHENTICATE */
+# if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_ADDRINFO)
+# undef getnameinfo
+/*
+ * For some reason, AIX's getnameinfo will refuse to resolve the all-zeros
+ * IPv6 address into its textual representation ("::"), so we wrap it
+ * with a function that will.
+ */
+int
+sshaix_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
+ size_t hostlen, char *serv, size_t servlen, int flags)
+{
+ struct sockaddr_in6 *sa6;
+ u_int32_t *a6;
+
+ if (flags & (NI_NUMERICHOST|NI_NUMERICSERV) &&
+ sa->sa_family == AF_INET6) {
+ sa6 = (struct sockaddr_in6 *)sa;
+ a6 = sa6->sin6_addr.u6_addr.u6_addr32;
+
+ if (a6[0] == 0 && a6[1] == 0 && a6[2] == 0 && a6[3] == 0) {
+ strlcpy(host, "::", hostlen);
+ snprintf(serv, servlen, "%d", sa6->sin6_port);
+ return 0;
+ }
+ }
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+}
+# endif /* AIX_GETNAMEINFO_HACK */
+
#endif /* _AIX */
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h
index 75113900..cc7c43cd 100644
--- a/openbsd-compat/port-aix.h
+++ b/openbsd-compat/port-aix.h
@@ -1,4 +1,4 @@
-/* $Id: port-aix.h,v 1.22 2005/02/02 06:10:11 dtucker Exp $ */
+/* $Id: port-aix.h,v 1.23 2005/02/15 10:45:58 dtucker Exp $ */
/*
*
@@ -27,6 +27,10 @@
#ifdef _AIX
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
#ifdef WITH_AIXAUTHENTICATE
# include <login.h>
# include <userpw.h>
@@ -36,6 +40,8 @@
# include <usersec.h>
#endif
+#include "buffer.h"
+
/* Some versions define r_type in the above headers, which causes a conflict */
#ifdef r_type
# undef r_type
@@ -64,13 +70,23 @@ void aix_usrinfo(struct passwd *);
#ifdef WITH_AIXAUTHENTICATE
# define CUSTOM_SYS_AUTH_PASSWD 1
# define CUSTOM_SYS_AUTH_ALLOWED_USER 1
-int sys_auth_allowed_user(struct passwd *);
+int sys_auth_allowed_user(struct passwd *, Buffer *);
# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1
-int sys_auth_record_login(const char *, const char *, const char *);
+int sys_auth_record_login(const char *, const char *, const char *, Buffer *);
# define CUSTOM_FAILED_LOGIN 1
#endif
void aix_setauthdb(const char *);
void aix_restoreauthdb(void);
void aix_remove_embedded_newlines(char *);
+
+#if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_GETADDRINFO)
+# ifdef getnameinfo
+# undef getnameinfo
+# endif
+int sshaix_getnameinfo(const struct sockaddr *, size_t, char *, size_t,
+ char *, size_t, int);
+# define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g))
+#endif
+
#endif /* _AIX */