sssd  2.2.3
About: SSSD provides a set of daemons to manage access to remote directories and authentication mechanisms such as LDAP, Kerberos or FreeIPA. It provides also an NSS and PAM interface toward the system.
  Fossies Dox: sssd-2.2.3.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

util_errors.c
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Red Hat
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17  Authors:
18  Simo Sorce <ssorce@redhat.com>
19 */
20 
21 #include "util/util.h"
22 #include <ldb.h>
23 
24 struct err_string {
25  const char *msg;
26 };
27 
29  { "Invalid Error" }, /* ERR_INVALID */
30  { "Internal Error" }, /* ERR_INTERNAL */
31  { "SSSD is running" }, /* ERR_SSSD_RUNNING */
32  { "SSSD is not running" }, /* ERR_SSSD_NOT_RUNNING */
33  { "SSSD is offline" }, /* ERR_OFFLINE */
34  { "Terminated" }, /* ERR_TERMINATED */
35  { "Invalid data type" }, /* ERR_INVALID_DATA_TYPE */
36  { "DP target is not configured" }, /* ERR_MISSING_DP_TARGET */
37  { "Account Unknown" }, /* ERR_ACCOUNT_UNKNOWN */
38  { "No suitable principal found in keytab" }, /* ERR_KRB5_PRINCIPAL_NOT_FOUND */
39  { "Invalid credential type" }, /* ERR_INVALID_CRED_TYPE */
40  { "No credentials available" }, /* ERR_NO_CREDS */
41  { "Credentials are expired" }, /* ERR_CREDS_EXPIRED */
42  { "Credentials are expired, old ccache was removed" }, /* ERR_CREDS_EXPIRED_CCACHE */
43  { "Failure setting user credentials"}, /* ERR_CREDS_INVALID */
44  { "No cached credentials available" }, /* ERR_NO_CACHED_CREDS */
45  { "No matching credentials found" }, /* ERR_NO_MATCHING_CREDS */
46  { "Cached credentials are expired" }, /* ERR_CACHED_CREDS_EXPIRED */
47  { "Authentication Denied" }, /* ERR_AUTH_DENIED */
48  { "Authentication Failed" }, /* ERR_AUTH_FAILED */
49  { "Password Change Denied" }, /* ERR_CHPASS_DENIED */
50  { "Password Change Failed" }, /* ERR_CHPASS_FAILED */
51  { "Network I/O Error" }, /* ERR_NETWORK_IO */
52  { "Account Expired" }, /* ERR_ACCOUNT_EXPIRED */
53  { "Password Expired" }, /* ERR_PASSWORD_EXPIRED */
54  { "Password Expired (reject access)" }, /* ERR_PASSWORD_EXPIRED_REJECT */
55  { "Password Expired (warn user)" }, /* ERR_PASSWORD_EXPIRED_WARN */
56  { "Password Expired (ask for new password)" }, /* ERR_PASSWORD_EXPIRED_RENEW */
57  { "Host Access Denied" }, /* ERR_ACCESS_DENIED */
58  { "SRV record not found" }, /* ERR_SRV_NOT_FOUND */
59  { "SRV lookup error" }, /* ERR_SRV_LOOKUP_ERROR */
60  { "SRV lookup did not return any new server" }, /* ERR_SRV_DUPLICATES */
61  { "Dynamic DNS update failed" }, /* ERR_DYNDNS_FAILED */
62  { "Dynamic DNS update timed out" }, /* ERR_DYNDNS_TIMEOUT */
63  { "Dynamic DNS update not possible while offline" }, /* ERR_DYNDNS_OFFLINE */
64  { "Cannot parse input" }, /* ERR_INPUT_PARSE */
65  { "Entry not found" }, /* ERR_NOT_FOUND */
66  { "Domain not found" }, /* ERR_DOMAIN_NOT_FOUND */
67  { "Malformed search filter" }, /* ERR_INVALID_FILTER, */
68  { "No POSIX attributes detected" }, /* ERR_NO_POSIX */
69  { "Extra attribute is a duplicate" }, /* ERR_DUP_EXTRA_ATTR */
70  { "Malformed extra attribute" }, /* ERR_INVALID_EXTRA_ATTR */
71  { "Cannot get bus message sender" }, /* ERR_SBUS_GET_SENDER_ERROR */
72  { "Bus message has no sender" }, /* ERR_SBUS_NO_SENDER */
73  { "Invalid SBUS path provided" }, /* ERR_SBUS_INVALID_PATH */
74  { "User/Group SIDs not found" }, /* ERR_NO_SIDS */
75  { "Bus method not supported" }, /* ERR_SBUS_NOSUP */
76  { "Cannot connect to system bus" }, /* ERR_NO_SYSBUS */
77  { "LDAP search returned a referral" }, /* ERR_REFERRAL */
78  { "Error setting SELinux user context" }, /* ERR_SELINUX_CONTEXT */
79  { "SELinux is not managed by libsemanage" }, /* ERR_SELINUX_NOT_MANAGED */
80  { "SELinux user does not exist" }, /* ERR_SELINUX_USER_NOT_FOUND */
81  { "Username format not allowed by re_expression" }, /* ERR_REGEX_NOMATCH */
82  { "Time specification not supported" }, /* ERR_TIMESPEC_NOT_SUPPORTED */
83  { "Invalid SSSD configuration detected" }, /* ERR_INVALID_CONFIG */
84  { "Malformed cache entry" }, /* ERR_MALFORMED_ENTRY */
85  { "Unexpected cache entry type" }, /* ERR_UNEXPECTED_ENTRY_TYPE */
86  { "Failed to resolve one of user groups" }, /* ERR_SIMPLE_GROUPS_MISSING */
87  { "Home directory is NULL" }, /* ERR_HOMEDIR_IS_NULL */
88  { "Unsupported trust direction" }, /* ERR_TRUST_NOT_SUPPORTED */
89  { "Retrieving keytab failed" }, /* ERR_IPA_GETKEYTAB_FAILED */
90  { "Trusted forest root unknown" }, /* ERR_TRUST_FOREST_UNKNOWN */
91  { "p11_child failed" }, /* ERR_P11_CHILD */
92  { "p11_child timeout" }, /* ERR_P11_CHILD_TIMEOUT */
93  { "Address family not supported" }, /* ERR_ADDR_FAMILY_NOT_SUPPORTED */
94  { "Message sender is the bus" }, /* ERR_SBUS_SENDER_BUS */
95  { "Subdomain is inactive" }, /* ERR_SUBDOM_INACTIVE */
96  { "Account is locked" }, /* ERR_ACCOUNT_LOCKED */
97  { "AD renewal child failed" }, /* ERR_RENEWAL_CHILD */
98  { "SBUS request already handled" }, /* ERR_SBUS_REQUEST_HANDLED */
99  { "Sysdb version is too old" }, /* ERR_SYSDB_VERSION_TOO_OLD */
100  { "Sysdb version is too new" }, /* ERR_SYSDB_VERSION_TOO_NEW */
101  { "Domain has to timestamp cache" }, /* ERR_NO_TS */
102  { "No timestamp cache record" }, /* ERR_TS_CACHE_MISS */
103  { "Dereference threshold reached" }, /* ERR_DEREF_THRESHOLD */
104  { "The user is not handled by SSSD" }, /* ERR_NON_SSSD_USER */
105  { "The internal name format cannot be parsed" }, /* ERR_WRONG_NAME_FORMAT */
106  { "The maximum level of nested containers has been reached" }, /* ERR_SEC_INVALID_CONTAINERS_NEST_LEVEL */
107  { "No proxy server for secrets available"}, /* ERR_SEC_NO_PROXY */
108  { "The maximum number of stored secrets has been reached" }, /* ERR_SEC_INVALID_TOO_MANY_SECRETS */
109  { "The secret payload size is too large" }, /* ERR_SEC_PAYLOAD_SIZE_IS_TOO_LARGE */
110  { "No authentication method available" }, /* ERR_NO_AUTH_METHOD_AVAILABLE */
111  { "Smartcard authentication not supported" }, /* ERR_SC_AUTH_NOT_SUPPORTED */
112  { "Malformed input KCM packet" }, /* ERR_KCM_MALFORMED_IN_PKT */
113  { "KCM operation not implemented" }, /* ERR_KCM_OP_NOT_IMPLEMENTED */
114  { "End of credential cache reached" }, /* ERR_KCM_CC_END */
115  { "Credential cache name not allowed" }, /* ERR_KCM_WRONG_CCNAME_FORMAT */
116  { "Cannot encode a JSON object to string" }, /* ERR_JSON_ENCODING */
117  { "Cannot decode a JSON object from string" }, /* ERR_JSON_DECODING */
118  { "Invalid certificate provided" }, /* ERR_INVALID_CERT */
119  { "Unable to initialize SSL" }, /* ERR_SSL_FAILURE */
120  { "Unable to verify peer" }, /* ERR_UNABLE_TO_VERIFY_PEER */
121  { "Unable to resolve host" }, /* ERR_UNABLE_TO_RESOLVE_HOST */
122  { "GetAccountDomain() not supported" }, /* ERR_GET_ACCT_DOM_NOT_SUPPORTED */
123  { "The last GetAccountDomain() result is still valid" }, /* ERR_GET_ACCT_DOM_CACHED */
124  { "ID is outside the allowed range" }, /* ERR_ID_OUTSIDE_RANGE */
125  { "Group ID is duplicated" }, /* ERR_GID_DUPLICATED */
126  { "Multiple objects were found when only one was expected" }, /* ERR_MULTIPLE_ENTRIES */
127 
128  /* DBUS Errors */
129  { "Connection was killed on demand" }, /* ERR_SBUS_KILL_CONNECTION */
130  { "NULL string cannot be sent over D-Bus" }, /* ERR_SBUS_EMPTY_STRING */
131  { "Maximum number of connections was reached" }, /* ERR_SBUS_CONNECTION_LIMIT */
132  { "String contains invalid characters" }, /* ERR_SBUS_INVALID_STRING */
133  { "Unexpected argument type provided" }, /* ERR_SBUS_INVALID_TYPE */
134  { "Unknown service" }, /* ERR_SBUS_UNKNOWN_SERVICE */
135  { "Unknown interface" }, /* ERR_SBUS_UNKNOWN_INTERFACE */
136  { "Unknown property" }, /* ERR_SBUS_UNKNOWN_PROPERTY */
137  { "Unknown bus owner" }, /* ERR_SBUS_UNKNOWN_OWNER */
138  { "No reply was received" }, /* ERR_SBUS_NO_REPLY */
139 
140  /* ini parsing errors */
141  { "Failed to open configuration" }, /* ERR_INI_OPEN_FAILED */
142  { "File ownership and permissions check failed" }, /* ERR_INI_INVALID_PERMISSION */
143  { "Error while parsing configuration file" }, /* ERR_INI_PARSE_FAILED */
144  { "Failed to add configuration snippets" }, /* ERR_INI_ADD_SNIPPETS_FAILED */
145 
146  { "ERR_LAST" } /* ERR_LAST */
147 };
148 
149 
151 {
152  if (IS_SSSD_ERROR(error)) {
154  }
155 
156  return strerror(error);
157 }
158 
159 /* TODO: make a more complete and precise mapping */
161 {
162  switch (ldberr) {
163  case LDB_SUCCESS:
164  return EOK;
165  case LDB_ERR_OPERATIONS_ERROR:
166  return EIO;
167  case LDB_ERR_NO_SUCH_OBJECT:
168  return ENOENT;
169  case LDB_ERR_BUSY:
170  return EBUSY;
171  case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS:
172  case LDB_ERR_ENTRY_ALREADY_EXISTS:
173  return EEXIST;
174  case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX:
175  return EINVAL;
176  default:
178  "LDB returned unexpected error: [%i]\n",
179  ldberr);
180  return EFAULT;
181  }
182 }
sss_strerror
const char * sss_strerror(errno_t error)
return a string describing the error number like strerror()
Definition: util_errors.c:150
SSSD_ERR_IDX
#define SSSD_ERR_IDX(err)
Definition: util_errors.h:171
EOK
#define EOK
Definition: hbac_evaluator.c:40
DEBUG
#define DEBUG(level, format,...)
macro to generate debug messages
Definition: debug.h:123
errno_t
int errno_t
Definition: hbac_evaluator.c:36
sss_ldb_error_to_errno
errno_t sss_ldb_error_to_errno(int ldberr)
Definition: util_errors.c:160
IS_SSSD_ERROR
#define IS_SSSD_ERROR(err)
Definition: util_errors.h:172
error_to_str
struct err_string error_to_str[]
Definition: util_errors.c:28
err_string::msg
const char * msg
Definition: util_errors.c:25
SSSDConfigTest.error
int error
Definition: SSSDConfigTest.py:2129
SSSDBG_CRIT_FAILURE
#define SSSDBG_CRIT_FAILURE
Definition: debug.h:75
err_string
Definition: util_errors.c:24
util.h