From 91b2cbb33f0dcb9fb5a72db1795003e07afeded9 Mon Sep 17 00:00:00 2001 From: gww Date: Mon, 12 Apr 2010 16:53:16 -0700 Subject: 6935410 setting audit context when audit is not enabled should be more tolerant of getaddrinfo failure --- usr/src/lib/pam_modules/unix_cred/unix_cred.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'usr/src/lib/pam_modules') diff --git a/usr/src/lib/pam_modules/unix_cred/unix_cred.c b/usr/src/lib/pam_modules/unix_cred/unix_cred.c index d862b2f652..c7c35c70a7 100644 --- a/usr/src/lib/pam_modules/unix_cred/unix_cred.c +++ b/usr/src/lib/pam_modules/unix_cred/unix_cred.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. */ #include @@ -264,31 +263,45 @@ pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv) errno = 0; if ((rhost == NULL || *rhost == '\0')) { if (adt_load_ttyname(tty, &termid) != 0) { - if (errno != 0) + if (errno == ENETDOWN) { + /* + * tolerate not being able to + * translate local hostname + * to a termid -- it will be + * "loopback". + */ + syslog(LOG_AUTH | LOG_ERR, + "pam_unix_cred: cannot load " + "ttyname: %m, continuing."); + goto adt_setuser; + } else if (errno != 0) { syslog(LOG_AUTH | LOG_ERR, "pam_unix_cred: cannot load " "ttyname: %m."); - else + } else { syslog(LOG_AUTH | LOG_ERR, "pam_unix_cred: cannot load " "ttyname."); + } ret = PAM_SYSTEM_ERR; goto adt_done; } } else { if (adt_load_hostname(rhost, &termid) != 0) { - if (errno != 0) + if (errno != 0) { syslog(LOG_AUTH | LOG_ERR, "pam_unix_cred: cannot load " "hostname: %m."); - else + } else { syslog(LOG_AUTH | LOG_ERR, "pam_unix_cred: cannot load " "hostname."); + } ret = PAM_SYSTEM_ERR; goto adt_done; } } +adt_setuser: if ((auser != NULL) && (*auser != '\0') && (getpwnam_r(auser, &apwd, apwbuf, sizeof (apwbuf)) != NULL)) { -- cgit v1.2.3