util_errors.c revision c6872e79e8496fd075e20aec0343ade99cca725c
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/*
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce Copyright (C) 2012 Red Hat
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce This program is free software; you can redistribute it and/or modify
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce it under the terms of the GNU General Public License as published by
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce the Free Software Foundation; either version 3 of the License, or
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce (at your option) any later version.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce This program is distributed in the hope that it will be useful,
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce but WITHOUT ANY WARRANTY; without even the implied warranty of
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce GNU General Public License for more details.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce You should have received a copy of the GNU General Public License
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce along with this program. If not, see <http://www.gnu.org/licenses/>.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce Authors:
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce Simo Sorce <ssorce@redhat.com>
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce*/
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#include "util/util.h"
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcestruct err_string {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce const char *msg;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce};
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcestruct err_string error_to_str[] = {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce { "Invalid Error" }, /* ERR_INVALID */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce { "Internal Error" }, /* ERR_INTERNAL */
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce { "Account Unknown" }, /* ERR_ACCOUNT_UNKNOWN */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce { "Invalid credential type" }, /* ERR_INVALID_CRED_TYPE */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce { "No credentials available" }, /* ERR_NO_CREDS */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce { "Credentials are expired" }, /* ERR_CREDS_EXPIRED */
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce { "No cached credentials available" }, /* ERR_NO_CACHED_CREDS */
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce { "Cached credentials are expired" }, /* ERR_CACHED_CREDS_EXPIRED */
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce { "Authentication Denied" }, /* ERR_AUTH_DENIED */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce { "Authentication Failed" }, /* ERR_AUTH_FAILED */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce { "Password Change Failed" }, /* ERR_CHPASS_FAILED */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce { "Network I/O Error" }, /* ERR_NETWORK_IO */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce};
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorceconst char *sss_strerror(errno_t error)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce{
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce if (IS_SSSD_ERROR(error)) {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce return error_to_str[SSSD_ERR_IDX(error)].msg;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce }
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce return strerror(error);
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce}
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce