diff options
author | Darren Tucker <dtucker@zip.com.au> | 2005-02-15 21:45:57 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2005-02-15 21:45:57 +1100 |
commit | 691d5235ca9485877e8345269b1be4b2cf1be322 (patch) | |
tree | 7adbbdbb837a6d3d4953a6ea339ad9d9e6d289ce /openbsd-compat/port-aix.c | |
parent | f04c3616756831fe987fe3e474c8c234c298e4cb (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/port-aix.c')
-rw-r--r-- | openbsd-compat/port-aix.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index b16988543..8ab862f98 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c | |||
@@ -34,14 +34,13 @@ | |||
34 | #ifdef _AIX | 34 | #ifdef _AIX |
35 | 35 | ||
36 | #include <uinfo.h> | 36 | #include <uinfo.h> |
37 | #include <sys/socket.h> | ||
37 | #include "port-aix.h" | 38 | #include "port-aix.h" |
38 | 39 | ||
39 | /* These should be in the system headers but are not. */ | 40 | /* These should be in the system headers but are not. */ |
40 | int usrinfo(int, char *, int); | 41 | int usrinfo(int, char *, int); |
41 | int setauthdb(const char *, char *); | 42 | int setauthdb(const char *, char *); |
42 | 43 | ||
43 | extern Buffer loginmsg; | ||
44 | |||
45 | # ifdef HAVE_SETAUTHDB | 44 | # ifdef HAVE_SETAUTHDB |
46 | static char old_registry[REGISTRY_SIZE] = ""; | 45 | static char old_registry[REGISTRY_SIZE] = ""; |
47 | # endif | 46 | # endif |
@@ -156,7 +155,7 @@ aix_valid_authentications(const char *user) | |||
156 | * returns 0. | 155 | * returns 0. |
157 | */ | 156 | */ |
158 | int | 157 | int |
159 | sys_auth_passwd(Authctxt *ctxt, const char *password) | 158 | sys_auth_passwd(Authctxt *ctxt, const char *password, Buffer *loginmsg) |
160 | { | 159 | { |
161 | char *authmsg = NULL, *msg, *name = ctxt->pw->pw_name; | 160 | char *authmsg = NULL, *msg, *name = ctxt->pw->pw_name; |
162 | int authsuccess = 0, expired, reenter, result; | 161 | int authsuccess = 0, expired, reenter, result; |
@@ -186,7 +185,7 @@ sys_auth_passwd(Authctxt *ctxt, const char *password) | |||
186 | */ | 185 | */ |
187 | expired = passwdexpired(name, &msg); | 186 | expired = passwdexpired(name, &msg); |
188 | if (msg && *msg) { | 187 | if (msg && *msg) { |
189 | buffer_append(&loginmsg, msg, strlen(msg)); | 188 | buffer_append(loginmsg, msg, strlen(msg)); |
190 | aix_remove_embedded_newlines(msg); | 189 | aix_remove_embedded_newlines(msg); |
191 | } | 190 | } |
192 | debug3("AIX/passwdexpired returned %d msg %.100s", expired, msg); | 191 | debug3("AIX/passwdexpired returned %d msg %.100s", expired, msg); |
@@ -219,7 +218,7 @@ sys_auth_passwd(Authctxt *ctxt, const char *password) | |||
219 | * Returns 1 if login is allowed, 0 if not allowed. | 218 | * Returns 1 if login is allowed, 0 if not allowed. |
220 | */ | 219 | */ |
221 | int | 220 | int |
222 | sys_auth_allowed_user(struct passwd *pw) | 221 | sys_auth_allowed_user(struct passwd *pw, Buffer *loginmsg) |
223 | { | 222 | { |
224 | char *msg = NULL; | 223 | char *msg = NULL; |
225 | int result, permitted = 0; | 224 | int result, permitted = 0; |
@@ -246,7 +245,7 @@ sys_auth_allowed_user(struct passwd *pw) | |||
246 | if (result == -1 && errno == EPERM && stat(_PATH_NOLOGIN, &st) == 0) | 245 | if (result == -1 && errno == EPERM && stat(_PATH_NOLOGIN, &st) == 0) |
247 | permitted = 1; | 246 | permitted = 1; |
248 | else if (msg != NULL) | 247 | else if (msg != NULL) |
249 | buffer_append(&loginmsg, msg, strlen(msg)); | 248 | buffer_append(loginmsg, msg, strlen(msg)); |
250 | if (msg == NULL) | 249 | if (msg == NULL) |
251 | msg = xstrdup("(none)"); | 250 | msg = xstrdup("(none)"); |
252 | aix_remove_embedded_newlines(msg); | 251 | aix_remove_embedded_newlines(msg); |
@@ -259,7 +258,8 @@ sys_auth_allowed_user(struct passwd *pw) | |||
259 | } | 258 | } |
260 | 259 | ||
261 | int | 260 | int |
262 | sys_auth_record_login(const char *user, const char *host, const char *ttynm) | 261 | sys_auth_record_login(const char *user, const char *host, const char *ttynm, |
262 | Buffer *loginmsg) | ||
263 | { | 263 | { |
264 | char *msg; | 264 | char *msg; |
265 | int success = 0; | 265 | int success = 0; |
@@ -269,7 +269,7 @@ sys_auth_record_login(const char *user, const char *host, const char *ttynm) | |||
269 | success = 1; | 269 | success = 1; |
270 | if (msg != NULL) { | 270 | if (msg != NULL) { |
271 | debug("AIX/loginsuccess: msg %s", msg); | 271 | debug("AIX/loginsuccess: msg %s", msg); |
272 | buffer_append(&loginmsg, msg, strlen(msg)); | 272 | buffer_append(loginmsg, msg, strlen(msg)); |
273 | xfree(msg); | 273 | xfree(msg); |
274 | } | 274 | } |
275 | } | 275 | } |
@@ -349,4 +349,33 @@ aix_restoreauthdb(void) | |||
349 | 349 | ||
350 | # endif /* WITH_AIXAUTHENTICATE */ | 350 | # endif /* WITH_AIXAUTHENTICATE */ |
351 | 351 | ||
352 | # if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_ADDRINFO) | ||
353 | # undef getnameinfo | ||
354 | /* | ||
355 | * For some reason, AIX's getnameinfo will refuse to resolve the all-zeros | ||
356 | * IPv6 address into its textual representation ("::"), so we wrap it | ||
357 | * with a function that will. | ||
358 | */ | ||
359 | int | ||
360 | sshaix_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | ||
361 | size_t hostlen, char *serv, size_t servlen, int flags) | ||
362 | { | ||
363 | struct sockaddr_in6 *sa6; | ||
364 | u_int32_t *a6; | ||
365 | |||
366 | if (flags & (NI_NUMERICHOST|NI_NUMERICSERV) && | ||
367 | sa->sa_family == AF_INET6) { | ||
368 | sa6 = (struct sockaddr_in6 *)sa; | ||
369 | a6 = sa6->sin6_addr.u6_addr.u6_addr32; | ||
370 | |||
371 | if (a6[0] == 0 && a6[1] == 0 && a6[2] == 0 && a6[3] == 0) { | ||
372 | strlcpy(host, "::", hostlen); | ||
373 | snprintf(serv, servlen, "%d", sa6->sin6_port); | ||
374 | return 0; | ||
375 | } | ||
376 | } | ||
377 | return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); | ||
378 | } | ||
379 | # endif /* AIX_GETNAMEINFO_HACK */ | ||
380 | |||
352 | #endif /* _AIX */ | 381 | #endif /* _AIX */ |