6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek/*
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek SSSD
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek Authentication utility functions
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek Authors:
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek Copyright (C) 2012 Red Hat
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek This program is free software; you can redistribute it and/or modify
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek it under the terms of the GNU General Public License as published by
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek the Free Software Foundation; either version 3 of the License, or
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek (at your option) any later version.
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek This program is distributed in the hope that it will be useful,
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek GNU General Public License for more details.
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek You should have received a copy of the GNU General Public License
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek*/
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek#include <errno.h>
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek#include <security/pam_appl.h>
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozekstatic inline int cached_login_pam_status(int auth_res)
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek{
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek switch (auth_res) {
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce case EOK:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce return PAM_SUCCESS;
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce case ERR_ACCOUNT_UNKNOWN:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce return PAM_AUTHINFO_UNAVAIL;
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce case ERR_NO_CACHED_CREDS:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce case ERR_CACHED_CREDS_EXPIRED:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce case ERR_AUTH_DENIED:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce return PAM_PERM_DENIED;
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce case ERR_AUTH_FAILED:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce return PAM_AUTH_ERR;
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce default:
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce return PAM_SYSTEM_ERR;
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek }
6c7584a32899bf573f62cf8c3fb37410a8ec05bbJakub Hrozek}