util_errors.h revision fcbcfa69f9291936f01f24b5fcb5a7672dca46f3
1516N/A/*
1231N/A Copyright (C) 2012 Red Hat
1231N/A
1231N/A This program is free software; you can redistribute it and/or modify
1231N/A it under the terms of the GNU General Public License as published by
1231N/A the Free Software Foundation; either version 3 of the License, or
1231N/A (at your option) any later version.
1231N/A
1231N/A This program is distributed in the hope that it will be useful,
1231N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
1231N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1231N/A GNU General Public License for more details.
1231N/A
1231N/A You should have received a copy of the GNU General Public License
1231N/A along with this program. If not, see <http://www.gnu.org/licenses/>.
1231N/A
1231N/A Authors:
1231N/A Simo Sorce <ssorce@redhat.com>
1231N/A*/
1231N/A
1231N/A#ifndef __SSSD_UTIL_ERRORS_H__
1231N/A#define __SSSD_UTIL_ERRORS_H__
3329N/A
3143N/A#ifndef HAVE_ERRNO_T
3143N/A#define HAVE_ERRNO_T
3339N/Atypedef int errno_t;
1516N/A#endif
1516N/A
1715N/A/*
1516N/A * We define a specific number space so that we do not overlap with other
1231N/A * generic errors returned by various libraries. This will make it easy
1231N/A * to have functions that double check that what was returned was a SSSD
1580N/A * specific error where it matters. For example we may want to ensure some
1231N/A * particularly sensitive paths only return SSSD sepcific errors as that
1231N/A * will insure all error conditions have been explicitly dealt with,
1231N/A * and are not the result of assigning the wrong return result.
1231N/A *
1580N/A * Basic system errno errors can still be used, but when an error condition
1674N/A * does not properly map to a system error we should use a SSSD specific one
1674N/A */
1580N/A
1674N/A#define ERR_BASE 0x555D0000
1674N/A#define ERR_MASK 0x0000FFFF
1674N/A
1933N/A/* never use ERR_INVALID, it is used for catching and returning
1231N/A * information on invalid error numbers */
1580N/A/* never use ERR_LAST, this represent the maximum error value available
1580N/A * and is used to validate error codes */
1231N/Aenum sssd_errors {
1231N/A ERR_INVALID = ERR_BASE + 0,
1580N/A ERR_INTERNAL,
1580N/A ERR_SSSD_RUNNING,
1580N/A ERR_SSSD_NOT_RUNNING,
1580N/A ERR_OFFLINE,
1580N/A ERR_TERMINATED,
3177N/A ERR_INVALID_DATA_TYPE,
1580N/A ERR_MISSING_DP_TARGET,
1580N/A ERR_ACCOUNT_UNKNOWN,
1580N/A ERR_INVALID_CRED_TYPE,
3177N/A ERR_NO_CREDS,
2236N/A ERR_CREDS_EXPIRED,
2381N/A ERR_CREDS_EXPIRED_CCACHE,
3177N/A ERR_CREDS_INVALID,
2381N/A ERR_NO_CACHED_CREDS,
3177N/A ERR_CACHED_CREDS_EXPIRED,
2236N/A ERR_AUTH_DENIED,
2236N/A ERR_AUTH_FAILED,
1580N/A ERR_CHPASS_DENIED,
2221N/A ERR_CHPASS_FAILED,
3177N/A ERR_NETWORK_IO,
3177N/A ERR_ACCOUNT_EXPIRED,
1933N/A ERR_PASSWORD_EXPIRED,
1933N/A ERR_PASSWORD_EXPIRED_REJECT,
1933N/A ERR_PASSWORD_EXPIRED_WARN,
1933N/A ERR_PASSWORD_EXPIRED_RENEW,
1933N/A ERR_ACCESS_DENIED,
2291N/A ERR_SRV_NOT_FOUND,
1933N/A ERR_SRV_LOOKUP_ERROR,
1933N/A ERR_SRV_DUPLICATES,
2682N/A ERR_DYNDNS_FAILED,
2682N/A ERR_DYNDNS_TIMEOUT,
1933N/A ERR_DYNDNS_OFFLINE,
1933N/A ERR_INPUT_PARSE,
1933N/A ERR_NOT_FOUND,
1933N/A ERR_DOMAIN_NOT_FOUND,
2682N/A ERR_MISSING_CONF,
1933N/A ERR_INVALID_FILTER,
1933N/A ERR_NO_POSIX,
2682N/A ERR_DUP_EXTRA_ATTR,
1933N/A ERR_INVALID_EXTRA_ATTR,
1933N/A ERR_SBUS_GET_SENDER_ERROR,
1933N/A ERR_SBUS_NO_SENDER,
1933N/A ERR_SBUS_INVALID_PATH,
1580N/A ERR_NO_SIDS,
1231N/A ERR_SBUS_NOSUP,
3158N/A ERR_NO_SYSBUS,
3158N/A ERR_REFERRAL,
3158N/A ERR_SELINUX_CONTEXT,
3158N/A ERR_REGEX_NOMATCH,
1231N/A ERR_TIMESPEC_NOT_SUPPORTED,
1231N/A ERR_INVALID_CONFIG,
3158N/A ERR_MALFORMED_ENTRY,
3158N/A ERR_UNEXPECTED_ENTRY_TYPE,
3158N/A ERR_SIMPLE_GROUPS_MISSING,
1231N/A ERR_HOMEDIR_IS_NULL,
1231N/A ERR_TRUST_NOT_SUPPORTED,
3158N/A ERR_IPA_GETKEYTAB_FAILED,
1231N/A ERR_TRUST_FOREST_UNKNOWN,
3158N/A ERR_P11_CHILD,
1231N/A ERR_ADDR_FAMILY_NOT_SUPPORTED,
1580N/A ERR_SBUS_SENDER_BUS,
3158N/A ERR_SUBDOM_INACTIVE,
3158N/A ERR_ACCOUNT_LOCKED,
1231N/A ERR_RENEWAL_CHILD,
1580N/A ERR_SBUS_REQUEST_HANDLED,
3158N/A ERR_SYSDB_VERSION_TOO_OLD,
3158N/A ERR_SYSDB_VERSION_TOO_NEW,
3158N/A ERR_NO_TS,
1231N/A ERR_TS_CACHE_MISS,
1231N/A ERR_DEREF_THRESHOLD,
3158N/A ERR_NON_SSSD_USER,
3158N/A ERR_LAST /* ALWAYS LAST */
1231N/A};
1231N/A
3158N/A#define SSSD_ERR_BASE(err) ((err) & ~ERR_MASK)
3158N/A#define SSSD_ERR_IDX(err) ((err) & ERR_MASK)
3158N/A#define IS_SSSD_ERROR(err) \
1580N/A ((SSSD_ERR_BASE(err) == ERR_BASE) && ((err) <= ERR_LAST))
1231N/A
3158N/A#define ERR_OK 0
3158N/A/* Backwards compat */
1580N/A#ifndef EOK
1580N/A#define EOK ERR_OK
3158N/A#endif
3158N/A
1580N/A/**
2221N/A * @brief return a string descriing the error number like strerror()
3158N/A *
3177N/A * @param error An errno_t number, can be a SSSD error or a system error
3158N/A *
2221N/A * @return A statically allocated string.
2381N/A */
3158N/Aconst char *sss_strerror(errno_t error);
3158N/A
2381N/A#endif /* __SSSD_UTIL_ERRORS_H__ */
3158N/A