| 1 | /*- |
|---|
| 2 | * Copyright (c) 2002-2003 Networks Associates Technology, Inc. |
|---|
| 3 | * Copyright (c) 2004-2009 Dag-Erling Smørgrav |
|---|
| 4 | * All rights reserved. |
|---|
| 5 | * |
|---|
| 6 | * This software was developed for the FreeBSD Project by ThinkSec AS and |
|---|
| 7 | * Network Associates Laboratories, the Security Research Division of |
|---|
| 8 | * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 |
|---|
| 9 | * ("CBOSS"), as part of the DARPA CHATS research program. |
|---|
| 10 | * |
|---|
| 11 | * Redistribution and use in source and binary forms, with or without |
|---|
| 12 | * modification, are permitted provided that the following conditions |
|---|
| 13 | * are met: |
|---|
| 14 | * 1. Redistributions of source code must retain the above copyright |
|---|
| 15 | * notice, this list of conditions and the following disclaimer. |
|---|
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
|---|
| 17 | * notice, this list of conditions and the following disclaimer in the |
|---|
| 18 | * documentation and/or other materials provided with the distribution. |
|---|
| 19 | * 3. The name of the author may not be used to endorse or promote |
|---|
| 20 | * products derived from this software without specific prior written |
|---|
| 21 | * permission. |
|---|
| 22 | * |
|---|
| 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|---|
| 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|---|
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|---|
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|---|
| 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|---|
| 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|---|
| 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|---|
| 33 | * SUCH DAMAGE. |
|---|
| 34 | * |
|---|
| 35 | * $Id$ |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #ifdef HAVE_CONFIG_H |
|---|
| 39 | # include "config.h" |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | #include <stdio.h> |
|---|
| 43 | |
|---|
| 44 | #include <security/pam_appl.h> |
|---|
| 45 | |
|---|
| 46 | #include "openpam_impl.h" |
|---|
| 47 | |
|---|
| 48 | const char *_pam_err_name[PAM_NUM_ERRORS] = { |
|---|
| 49 | "PAM_SUCCESS", |
|---|
| 50 | "PAM_OPEN_ERR", |
|---|
| 51 | "PAM_SYMBOL_ERR", |
|---|
| 52 | "PAM_SERVICE_ERR", |
|---|
| 53 | "PAM_SYSTEM_ERR", |
|---|
| 54 | "PAM_BUF_ERR", |
|---|
| 55 | "PAM_CONV_ERR", |
|---|
| 56 | "PAM_PERM_DENIED", |
|---|
| 57 | "PAM_MAXTRIES", |
|---|
| 58 | "PAM_AUTH_ERR", |
|---|
| 59 | "PAM_NEW_AUTHTOK_REQD", |
|---|
| 60 | "PAM_CRED_INSUFFICIENT", |
|---|
| 61 | "PAM_AUTHINFO_UNAVAIL", |
|---|
| 62 | "PAM_USER_UNKNOWN", |
|---|
| 63 | "PAM_CRED_UNAVAIL", |
|---|
| 64 | "PAM_CRED_EXPIRED", |
|---|
| 65 | "PAM_CRED_ERR", |
|---|
| 66 | "PAM_ACCT_EXPIRED", |
|---|
| 67 | "PAM_AUTHTOK_EXPIRED", |
|---|
| 68 | "PAM_SESSION_ERR", |
|---|
| 69 | "PAM_AUTHTOK_ERR", |
|---|
| 70 | "PAM_AUTHTOK_RECOVERY_ERR", |
|---|
| 71 | "PAM_AUTHTOK_LOCK_BUSY", |
|---|
| 72 | "PAM_AUTHTOK_DISABLE_AGING", |
|---|
| 73 | "PAM_NO_MODULE_DATA", |
|---|
| 74 | "PAM_IGNORE", |
|---|
| 75 | "PAM_ABORT", |
|---|
| 76 | "PAM_TRY_AGAIN", |
|---|
| 77 | "PAM_MODULE_UNKNOWN", |
|---|
| 78 | "PAM_DOMAIN_UNKNOWN" |
|---|
| 79 | }; |
|---|
| 80 | |
|---|
| 81 | /* |
|---|
| 82 | * XSSO 4.2.1 |
|---|
| 83 | * XSSO 6 page 92 |
|---|
| 84 | * |
|---|
| 85 | * Get PAM standard error message string |
|---|
| 86 | */ |
|---|
| 87 | |
|---|
| 88 | const char * |
|---|
| 89 | pam_strerror(const pam_handle_t *pamh, |
|---|
| 90 | int error_number) |
|---|
| 91 | { |
|---|
| 92 | static char unknown[16]; |
|---|
| 93 | |
|---|
| 94 | (void)pamh; |
|---|
| 95 | |
|---|
| 96 | switch (error_number) { |
|---|
| 97 | case PAM_SUCCESS: |
|---|
| 98 | return ("success"); |
|---|
| 99 | case PAM_OPEN_ERR: |
|---|
| 100 | return ("failed to load module"); |
|---|
| 101 | case PAM_SYMBOL_ERR: |
|---|
| 102 | return ("invalid symbol"); |
|---|
| 103 | case PAM_SERVICE_ERR: |
|---|
| 104 | return ("error in service module"); |
|---|
| 105 | case PAM_SYSTEM_ERR: |
|---|
| 106 | return ("system error"); |
|---|
| 107 | case PAM_BUF_ERR: |
|---|
| 108 | return ("memory buffer error"); |
|---|
| 109 | case PAM_CONV_ERR: |
|---|
| 110 | return ("conversation failure"); |
|---|
| 111 | case PAM_PERM_DENIED: |
|---|
| 112 | return ("permission denied"); |
|---|
| 113 | case PAM_MAXTRIES: |
|---|
| 114 | return ("maximum number of tries exceeded"); |
|---|
| 115 | case PAM_AUTH_ERR: |
|---|
| 116 | return ("authentication error"); |
|---|
| 117 | case PAM_NEW_AUTHTOK_REQD: |
|---|
| 118 | return ("new authentication token required"); |
|---|
| 119 | case PAM_CRED_INSUFFICIENT: |
|---|
| 120 | return ("insufficient credentials"); |
|---|
| 121 | case PAM_AUTHINFO_UNAVAIL: |
|---|
| 122 | return ("authentication information is unavailable"); |
|---|
| 123 | case PAM_USER_UNKNOWN: |
|---|
| 124 | return ("unknown user"); |
|---|
| 125 | case PAM_CRED_UNAVAIL: |
|---|
| 126 | return ("failed to retrieve user credentials"); |
|---|
| 127 | case PAM_CRED_EXPIRED: |
|---|
| 128 | return ("user credentials have expired"); |
|---|
| 129 | case PAM_CRED_ERR: |
|---|
| 130 | return ("failed to set user credentials"); |
|---|
| 131 | case PAM_ACCT_EXPIRED: |
|---|
| 132 | return ("user account has expired"); |
|---|
| 133 | case PAM_AUTHTOK_EXPIRED: |
|---|
| 134 | return ("password has expired"); |
|---|
| 135 | case PAM_SESSION_ERR: |
|---|
| 136 | return ("session failure"); |
|---|
| 137 | case PAM_AUTHTOK_ERR: |
|---|
| 138 | return ("authentication token failure"); |
|---|
| 139 | case PAM_AUTHTOK_RECOVERY_ERR: |
|---|
| 140 | return ("failed to recover old authentication token"); |
|---|
| 141 | case PAM_AUTHTOK_LOCK_BUSY: |
|---|
| 142 | return ("authentication token lock busy"); |
|---|
| 143 | case PAM_AUTHTOK_DISABLE_AGING: |
|---|
| 144 | return ("authentication token aging disabled"); |
|---|
| 145 | case PAM_NO_MODULE_DATA: |
|---|
| 146 | return ("module data not found"); |
|---|
| 147 | case PAM_IGNORE: |
|---|
| 148 | return ("ignore this module"); |
|---|
| 149 | case PAM_ABORT: |
|---|
| 150 | return ("general failure"); |
|---|
| 151 | case PAM_TRY_AGAIN: |
|---|
| 152 | return ("try again"); |
|---|
| 153 | case PAM_MODULE_UNKNOWN: |
|---|
| 154 | return ("unknown module type"); |
|---|
| 155 | case PAM_DOMAIN_UNKNOWN: |
|---|
| 156 | return ("unknown authentication domain"); |
|---|
| 157 | default: |
|---|
| 158 | snprintf(unknown, sizeof unknown, "#%d", error_number); |
|---|
| 159 | return (unknown); |
|---|
| 160 | } |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | /** |
|---|
| 164 | * The =pam_strerror function returns a pointer to a string containing a |
|---|
| 165 | * textual description of the error indicated by the =error_number |
|---|
| 166 | * argument, in the context of the PAM transaction described by the =pamh |
|---|
| 167 | * argument. |
|---|
| 168 | */ |
|---|