diff options
author | Darren Tucker <dtucker@zip.com.au> | 2009-12-21 10:49:21 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2009-12-21 10:49:21 +1100 |
commit | 1bf3503c9d5f0c79a108ea0060bcec3e0efe2b37 (patch) | |
tree | 8821d5df4418bb67f6cf1c4ab5f01a94cf27fcf0 /openbsd-compat | |
parent | c8802aac28470714ec204d00342f6ecbca45908f (diff) |
- (dtucker) [auth-krb5.c platform.{c,h} openbsd-compat/port-aix.{c,h}]
Bug #1583: Use system's kerberos principal name on AIX if it's available.
Based on a patch from and tested by Miguel Sanders.
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/port-aix.c | 25 | ||||
-rw-r--r-- | openbsd-compat/port-aix.h | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index d9c0876f3..0bdefbf6d 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c | |||
@@ -374,6 +374,31 @@ aix_restoreauthdb(void) | |||
374 | 374 | ||
375 | # endif /* WITH_AIXAUTHENTICATE */ | 375 | # endif /* WITH_AIXAUTHENTICATE */ |
376 | 376 | ||
377 | # ifdef USE_AIX_KRB_NAME | ||
378 | /* | ||
379 | * aix_krb5_get_principal_name: returns the user's kerberos client principal name if | ||
380 | * configured, otherwise NULL. Caller must free returned string. | ||
381 | */ | ||
382 | char * | ||
383 | aix_krb5_get_principal_name(char *pw_name) | ||
384 | { | ||
385 | char *authname = NULL, *authdomain = NULL, *principal = NULL; | ||
386 | |||
387 | setuserdb(S_READ); | ||
388 | if (getuserattr(pw_name, S_AUTHDOMAIN, &authdomain, SEC_CHAR) != 0) | ||
389 | debug("AIX getuserattr S_AUTHDOMAIN: %s", strerror(errno)); | ||
390 | if (getuserattr(pw_name, S_AUTHNAME, &authname, SEC_CHAR) != 0) | ||
391 | debug("AIX getuserattr S_AUTHNAME: %s", strerror(errno)); | ||
392 | |||
393 | if (authdomain != NULL) | ||
394 | xasprintf(&principal, "%s@%s", authname ? authname : pw_name, authdomain); | ||
395 | else if (authname != NULL) | ||
396 | principal = xstrdup(authname); | ||
397 | enduserdb(); | ||
398 | return principal; | ||
399 | } | ||
400 | # endif /* USE_AIX_KRB_NAME */ | ||
401 | |||
377 | # if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_ADDRINFO) | 402 | # if defined(AIX_GETNAMEINFO_HACK) && !defined(BROKEN_ADDRINFO) |
378 | # undef getnameinfo | 403 | # undef getnameinfo |
379 | /* | 404 | /* |
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index 3ac76ae15..53e4e88a0 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: port-aix.h,v 1.31 2009/08/20 06:20:50 dtucker Exp $ */ | 1 | /* $Id: port-aix.h,v 1.32 2009/12/20 23:49:22 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * | 4 | * |
@@ -95,6 +95,10 @@ int sys_auth_record_login(const char *, const char *, const char *, Buffer *); | |||
95 | # define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG | 95 | # define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG |
96 | char *sys_auth_get_lastlogin_msg(const char *, uid_t); | 96 | char *sys_auth_get_lastlogin_msg(const char *, uid_t); |
97 | # define CUSTOM_FAILED_LOGIN 1 | 97 | # define CUSTOM_FAILED_LOGIN 1 |
98 | # if defined(S_AUTHDOMAIN) && defined (S_AUTHNAME) | ||
99 | # define USE_AIX_KRB_NAME | ||
100 | char *aix_krb5_get_principal_name(char *); | ||
101 | # endif | ||
98 | #endif | 102 | #endif |
99 | 103 | ||
100 | void aix_setauthdb(const char *); | 104 | void aix_setauthdb(const char *); |