Line data Source code
1 : /*
2 : SSSD
3 :
4 : Authentication utility functions
5 :
6 : Authors:
7 : Jakub Hrozek <jhrozek@redhat.com>
8 :
9 : Copyright (C) 2012 Red Hat
10 :
11 : This program is free software; you can redistribute it and/or modify
12 : it under the terms of the GNU General Public License as published by
13 : the Free Software Foundation; either version 3 of the License, or
14 : (at your option) any later version.
15 :
16 : This program is distributed in the hope that it will be useful,
17 : but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : GNU General Public License for more details.
20 :
21 : You should have received a copy of the GNU General Public License
22 : along with this program. If not, see <http://www.gnu.org/licenses/>.
23 : */
24 :
25 : #include <errno.h>
26 : #include <security/pam_appl.h>
27 :
28 16 : static inline int cached_login_pam_status(int auth_res)
29 : {
30 16 : switch (auth_res) {
31 : case EOK:
32 7 : return PAM_SUCCESS;
33 : case ERR_ACCOUNT_UNKNOWN:
34 0 : return PAM_AUTHINFO_UNAVAIL;
35 : case ERR_NO_CACHED_CREDS:
36 : case ERR_CACHED_CREDS_EXPIRED:
37 : case ERR_AUTH_DENIED:
38 1 : return PAM_PERM_DENIED;
39 : case ERR_AUTH_FAILED:
40 8 : return PAM_AUTH_ERR;
41 : default:
42 0 : return PAM_SYSTEM_ERR;
43 : }
44 : }
|