util_errors.h revision 7171a7584dda534dde5409f3e7f4657e845ece15
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#ifndef __SSSD_UTIL_ERRORS_H__
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define __SSSD_UTIL_ERRORS_H__
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#ifndef HAVE_ERRNO_T
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define HAVE_ERRNO_T
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcetypedef int errno_t;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#endif
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/*
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * We define a specific number space so that we do not overlap with other
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * generic errors returned by various libraries. This will make it easy
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * to have functions that double check that what was returned was a SSSD
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * specific error where it matters. For example we may want to ensure some
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * particularly sensitive paths only return SSSD sepcific errors as that
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * will insure all error conditions have been explicitly dealt with,
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * and are not the result of assigning the wrong return result.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce *
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * Basic system errno errors can still be used, but when an error condition
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * does not properly map to a system error we should use a SSSD specific one
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define ERR_BASE 0x555D0000
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define ERR_MASK 0x0000FFFF
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/* never use ERR_INVALID, it is used for catching and returning
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * information on invalid error numbers */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/* never use ERR_LAST, this represent the maximum error value available
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * and is used to validate error codes */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorceenum sssd_errors {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce ERR_INVALID = ERR_BASE + 0,
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce ERR_INTERNAL,
edaadf8de0c86a2cfff2d29215775d42919476f3Pavel Březina ERR_SSSD_RUNNING,
edaadf8de0c86a2cfff2d29215775d42919476f3Pavel Březina ERR_SSSD_NOT_RUNNING,
4ebab24f65b54720a6672898b76185462015ababPavel Březina ERR_OFFLINE,
75d66aea7accc842e68c88f085f9053112b20eccPavel Březina ERR_TERMINATED,
c1058e96679c7ed1372825bf5226ce7d28a8e6ffPavel Březina ERR_INVALID_DATA_TYPE,
dee7a89098b698e756f63e4041734d7322ad8b1ePavel Březina ERR_MISSING_DP_TARGET,
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce ERR_ACCOUNT_UNKNOWN,
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce ERR_INVALID_CRED_TYPE,
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce ERR_NO_CREDS,
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce ERR_CREDS_EXPIRED,
7c69221077c780e62f6c536e78675f2dc1c131bcMichal Zidek ERR_CREDS_EXPIRED_CCACHE,
22a21e910fd216ec1468fe769dcc29f1621a52a4Ondrej Kos ERR_CREDS_INVALID,
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce ERR_NO_CACHED_CREDS,
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce ERR_CACHED_CREDS_EXPIRED,
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce ERR_AUTH_DENIED,
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce ERR_AUTH_FAILED,
233a3c6c48972b177e60d6ef4cecfacd3cf31659Simo Sorce ERR_CHPASS_DENIED,
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce ERR_CHPASS_FAILED,
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce ERR_NETWORK_IO,
233a3c6c48972b177e60d6ef4cecfacd3cf31659Simo Sorce ERR_ACCOUNT_EXPIRED,
233a3c6c48972b177e60d6ef4cecfacd3cf31659Simo Sorce ERR_PASSWORD_EXPIRED,
c9b0071bfcb8eb8c71e40248de46d23aceecc0f3Pavel Reichl ERR_PASSWORD_EXPIRED_REJECT,
c9b0071bfcb8eb8c71e40248de46d23aceecc0f3Pavel Reichl ERR_PASSWORD_EXPIRED_WARN,
c9b0071bfcb8eb8c71e40248de46d23aceecc0f3Pavel Reichl ERR_PASSWORD_EXPIRED_RENEW,
dfd71fc92db940b2892cc996911cec03d7b6c52bSimo Sorce ERR_ACCESS_DENIED,
f9961e5f82e0ef474d6492371bfdf9e74e208a99Pavel Březina ERR_SRV_NOT_FOUND,
f9961e5f82e0ef474d6492371bfdf9e74e208a99Pavel Březina ERR_SRV_LOOKUP_ERROR,
e5f455afbc2d149527bfd08f4e89903a3a8da17aPavel Březina ERR_SRV_DUPLICATES,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ERR_DYNDNS_FAILED,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ERR_DYNDNS_TIMEOUT,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ERR_DYNDNS_OFFLINE,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ERR_INPUT_PARSE,
dcc6877aa2e2dd63a9dc9c411a9c58feaeb36b9aStephen Gallagher ERR_NOT_FOUND,
bc30ce9b7d588a17e58012e699986f0d6898b791Pavel Březina ERR_DOMAIN_NOT_FOUND,
b5ee224324b0158641d9b110f81d2bc6eddddc13Pavel Reichl ERR_MISSING_CONF,
2a96981a0ac781d01e5bba473409ed2bdf4cd4e0Jakub Hrozek ERR_INVALID_FILTER,
e81deec535d11912b87954c81a1edd768c1386c9Jakub Hrozek ERR_NO_POSIX,
4dd38025efda88f123eac672f87d3cda12f050c8Jakub Hrozek ERR_DUP_EXTRA_ATTR,
4dd38025efda88f123eac672f87d3cda12f050c8Jakub Hrozek ERR_INVALID_EXTRA_ATTR,
0161a3c5637a0c0092bf54c436bb3d6508d7df26Jakub Hrozek ERR_SBUS_GET_SENDER_ERROR,
0161a3c5637a0c0092bf54c436bb3d6508d7df26Jakub Hrozek ERR_SBUS_NO_SENDER,
10a28f461c25d788ff4dcffefa881e7aa724a25dPavel Březina ERR_SBUS_INVALID_PATH,
60cab26b12df9a2153823972cde0c38ca86e01b9Yassir Elley ERR_NO_SIDS,
1319e71fd1680ca4864afe0b1aca2b8c8e4a1ee4Stef Walter ERR_SBUS_NOSUP,
0c1d65998907930678da2d091789446f2c344d5dJakub Hrozek ERR_NO_SYSBUS,
a2ea3f5d9ef9f17efbb61e942c2bc6cff7d1ebf2Jakub Hrozek ERR_REFERRAL,
f3a25949de81f80c136bb073e4a8f504b080c20cJakub Hrozek ERR_SELINUX_CONTEXT,
8394eddba54b5d3e3fda868145e3751247bdbdb2Michal Zidek ERR_REGEX_NOMATCH,
5a5c5cdeb92f4012fc75fd717bfea06598f68f12Pavel Reichl ERR_TIMESPEC_NOT_SUPPORTED,
804df4040eb142f82a44c019c7a55b5ce524583cMichal Zidek ERR_INVALID_CONFIG,
1243e093fd31c5660adf1bb3dd477d6935a755beJakub Hrozek ERR_MALFORMED_ENTRY,
1243e093fd31c5660adf1bb3dd477d6935a755beJakub Hrozek ERR_UNEXPECTED_ENTRY_TYPE,
82a958e6592c4a4078e45b7197bbe4751b70f511Pavel Reichl ERR_SIMPLE_GROUPS_MISSING,
979e8d8d6ed444007eeff6be5269e8dc5d2bdf68Pavel Reichl ERR_HOMEDIR_IS_NULL,
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek ERR_TRUST_NOT_SUPPORTED,
64ea4127f463798410a2c20e0261c6b15f60257fJakub Hrozek ERR_IPA_GETKEYTAB_FAILED,
64ea4127f463798410a2c20e0261c6b15f60257fJakub Hrozek ERR_TRUST_FOREST_UNKNOWN,
a8d887323f83984679a7d9b827a70146656bb7b2Sumit Bose ERR_P11_CHILD,
b42bf6c0c01db08208fb81d8295a2909d307284aPavel Reichl ERR_ADDR_FAMILY_NOT_SUPPORTED,
9118a539a5d59f669f551114f880fe91d6bb8741Jakub Hrozek ERR_SBUS_SENDER_BUS,
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek ERR_SUBDOM_INACTIVE,
19e44537c28f6d5f011cd7ac885c74c1e892605fSimo Sorce ERR_ACCOUNT_LOCKED,
5f7cd30c865046a7ea69944f7e07c85b4c43465aSumit Bose ERR_RENEWAL_CHILD,
c30b7a1931211fdcae0564551a7625cc4f6dee9fJakub Hrozek ERR_SBUS_REQUEST_HANDLED,
e732d23f3ec986a463d757781a334040e03d1f59Jakub Hrozek ERR_SYSDB_VERSION_TOO_OLD,
e732d23f3ec986a463d757781a334040e03d1f59Jakub Hrozek ERR_SYSDB_VERSION_TOO_NEW,
dd285415d7a8d8376207960cfa3e977524c3b98cJakub Hrozek ERR_NO_TS,
dd285415d7a8d8376207960cfa3e977524c3b98cJakub Hrozek ERR_TS_CACHE_MISS,
beec1ee5799570f34a51ea57674c7291c15f7022Jakub Hrozek ERR_DEREF_THRESHOLD,
fcbcfa69f9291936f01f24b5fcb5a7672dca46f3Jakub Hrozek ERR_NON_SSSD_USER,
4714118890e51b365fbce543d0a042b4b59b2b25Michal Zidek ERR_WRONG_NAME_FORMAT,
efc65e78fa4e01e6cecc8690a9899af61213be62Fabiano Fidêncio ERR_SEC_INVALID_CONTAINERS_NEST_LEVEL,
41cd6072648bb7a9e14e56ed38004a2947f67657Jakub Hrozek ERR_SEC_NO_PROXY,
65a38b8c9cabde6c46cc0e9868f54cb9bb10afbfFabiano Fidêncio ERR_SEC_INVALID_TOO_MANY_SECRETS,
7171a7584dda534dde5409f3e7f4657e845ece15Fabiano Fidêncio ERR_SEC_PAYLOAD_SIZE_IS_TOO_LARGE,
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce ERR_LAST /* ALWAYS LAST */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce};
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
0c16d2eefbc6ac8331078a4cdcecfee817a71bc6Simo Sorce#define SSSD_ERR_BASE(err) ((err) & ~ERR_MASK)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define SSSD_ERR_IDX(err) ((err) & ERR_MASK)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define IS_SSSD_ERROR(err) \
7650ded4ffa87fcf7ce5adf00920fecf89cffcf5Michal Zidek ((SSSD_ERR_BASE(err) == ERR_BASE) && ((err) <= ERR_LAST))
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define ERR_OK 0
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/* Backwards compat */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#ifndef EOK
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#define EOK ERR_OK
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#endif
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/**
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * @brief return a string descriing the error number like strerror()
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce *
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * @param error An errno_t number, can be a SSSD error or a system error
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce *
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce * @return A statically allocated string.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorceconst char *sss_strerror(errno_t error);
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce#endif /* __SSSD_UTIL_ERRORS_H__ */