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 | |
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')
-rw-r--r-- | openbsd-compat/port-aix.c | 45 | ||||
-rw-r--r-- | openbsd-compat/port-aix.h | 22 |
2 files changed, 56 insertions, 11 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 */ |
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index 751139004..cc7c43cda 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: port-aix.h,v 1.22 2005/02/02 06:10:11 dtucker Exp $ */ | 1 | /* $Id: port-aix.h,v 1.23 2005/02/15 10:45:58 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * | 4 | * |
@@ -27,6 +27,10 @@ | |||
27 | 27 | ||
28 | #ifdef _AIX | 28 | #ifdef _AIX |
29 | 29 | ||
30 | #ifdef HAVE_SYS_SOCKET_H | ||
31 | # include <sys/socket.h> | ||
32 | #endif | ||
33 | |||
30 | #ifdef WITH_AIXAUTHENTICATE | 34 | #ifdef WITH_AIXAUTHENTICATE |
31 | # include <login.h> | 35 | # include <login.h> |
32 | # include <userpw.h> | 36 | # include <userpw.h> |
@@ -36,6 +40,8 @@ | |||
36 | # include <usersec.h> | 40 | # include <usersec.h> |
37 | #endif | 41 | #endif |
38 | 42 | ||
43 | #include "buffer.h" | ||
44 | |||
39 | /* Some versions define r_type in the above headers, which causes a conflict */ | 45 | /* Some versions define r_type in the above headers, which causes a conflict */ |
40 | #ifdef r_type | 46 | #ifdef r_type |
41 | # undef r_type | 47 | # undef r_type |
@@ -64,13 +70,23 @@ void aix_usrinfo(struct passwd *); | |||
64 | #ifdef WITH_AIXAUTHENTICATE | 70 | #ifdef WITH_AIXAUTHENTICATE |
65 | # define CUSTOM_SYS_AUTH_PASSWD 1 | 71 | # define CUSTOM_SYS_AUTH_PASSWD 1 |
66 | # define CUSTOM_SYS_AUTH_ALLOWED_USER 1 | 72 | # define CUSTOM_SYS_AUTH_ALLOWED_USER 1 |
67 | int sys_auth_allowed_user(struct passwd *); | 73 | int sys_auth_allowed_user(struct passwd *, Buffer *); |
68 | # define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 | 74 | # define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 |
69 | int sys_auth_record_login(const char *, const char *, const char *); | 75 | int sys_auth_record_login(const char *, const char *, const char *, Buffer *); |
70 | # define CUSTOM_FAILED_LOGIN 1 | 76 | # define CUSTOM_FAILED_LOGIN 1 |
71 | #endif | 77 | #endif |
72 | 78 | ||
73 | void aix_setauthdb(const char *); | 79 | void aix_setauthdb(const char *); |
74 | void aix_restoreauthdb(void); | 80 | void aix_restoreauthdb(void); |
75 | void aix_remove_embedded_newlines(char *); | 81 | void aix_remove_embedded_newlines(char *); |
82 | |||
83 | #if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_GETADDRINFO) | ||
84 | # ifdef getnameinfo | ||
85 | # undef getnameinfo | ||
86 | # endif | ||
87 | int sshaix_getnameinfo(const struct sockaddr *, size_t, char *, size_t, | ||
88 | char *, size_t, int); | ||
89 | # define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g)) | ||
90 | #endif | ||
91 | |||
76 | #endif /* _AIX */ | 92 | #endif /* _AIX */ |