switch to krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23273 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -115,14 +115,16 @@ init_ccapi(krb5_context context)
|
||||
cc_handle = dlopen(lib, RTLD_LAZY);
|
||||
if (cc_handle == NULL) {
|
||||
HEIMDAL_MUTEX_unlock(&acc_mutex);
|
||||
krb5_set_error_string(context, "Failed to load %s", lib);
|
||||
krb5_set_error_message(context, KRB5_CC_NOSUPP,
|
||||
"Failed to load %s", lib);
|
||||
return KRB5_CC_NOSUPP;
|
||||
}
|
||||
|
||||
init_func = (cc_initialize_func)dlsym(cc_handle, "cc_initialize");
|
||||
HEIMDAL_MUTEX_unlock(&acc_mutex);
|
||||
if (init_func == NULL) {
|
||||
krb5_set_error_string(context, "Failed to find cc_initialize"
|
||||
krb5_set_error_message(context, KRB5_CC_NOSUPP,
|
||||
"Failed to find cc_initialize"
|
||||
"in %s: %s", lib, dlerror());
|
||||
dlclose(cc_handle);
|
||||
return KRB5_CC_NOSUPP;
|
||||
@@ -131,7 +133,7 @@ init_ccapi(krb5_context context)
|
||||
return 0;
|
||||
#else
|
||||
HEIMDAL_MUTEX_unlock(&acc_mutex);
|
||||
krb5_set_error_string(context, "no support for shared object");
|
||||
krb5_set_error_message(context, KRB5_CC_NOSUPP, "no support for shared object");
|
||||
return KRB5_CC_NOSUPP;
|
||||
#endif
|
||||
}
|
||||
@@ -256,7 +258,7 @@ make_cred_from_ccred(krb5_context context,
|
||||
|
||||
nomem:
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ret, "malloc - out of memory");
|
||||
|
||||
fail:
|
||||
krb5_free_cred_contents(context, cred);
|
||||
@@ -623,7 +625,8 @@ acc_store_cred(krb5_context context,
|
||||
cc_int32 error;
|
||||
|
||||
if (a->ccache == NULL) {
|
||||
krb5_set_error_string(context, "No API credential found");
|
||||
krb5_set_error_message(context, KRB5_CC_NOTFOUND,
|
||||
"No API credential found");
|
||||
return KRB5_CC_NOTFOUND;
|
||||
}
|
||||
|
||||
@@ -656,7 +659,8 @@ acc_get_principal(krb5_context context,
|
||||
cc_string_t name;
|
||||
|
||||
if (a->ccache == NULL) {
|
||||
krb5_set_error_string(context, "No API credential found");
|
||||
krb5_set_error_message(context, KRB5_CC_NOTFOUND,
|
||||
"No API credential found");
|
||||
return KRB5_CC_NOTFOUND;
|
||||
}
|
||||
|
||||
@@ -682,7 +686,8 @@ acc_get_first (krb5_context context,
|
||||
int32_t error;
|
||||
|
||||
if (a->ccache == NULL) {
|
||||
krb5_set_error_string(context, "No API credential found");
|
||||
krb5_set_error_message(context, KRB5_CC_NOTFOUND,
|
||||
"No API credential found");
|
||||
return KRB5_CC_NOTFOUND;
|
||||
}
|
||||
|
||||
@@ -747,7 +752,8 @@ acc_remove_cred(krb5_context context,
|
||||
char *client, *server;
|
||||
|
||||
if (a->ccache == NULL) {
|
||||
krb5_set_error_string(context, "No API credential found");
|
||||
krb5_set_error_message(context, KRB5_CC_NOTFOUND,
|
||||
"No API credential found");
|
||||
return KRB5_CC_NOTFOUND;
|
||||
}
|
||||
|
||||
@@ -799,8 +805,8 @@ acc_remove_cred(krb5_context context,
|
||||
(*iter->func->release)(iter);
|
||||
|
||||
if (ret)
|
||||
krb5_set_error_string(context, "Can't find credential %s in cache",
|
||||
server);
|
||||
krb5_set_error_message(context, ret,
|
||||
"Can't find credential %s in cache", server);
|
||||
free(server);
|
||||
free(client);
|
||||
|
||||
@@ -840,7 +846,7 @@ acc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
|
||||
|
||||
iter = calloc(1, sizeof(*iter));
|
||||
if (iter == NULL) {
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc - out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -969,7 +975,7 @@ acc_get_default_name(krb5_context context, char **str)
|
||||
(*cc->func->release)(cc);
|
||||
|
||||
if (*str == NULL) {
|
||||
krb5_set_error_string(context, "out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
@@ -982,7 +988,8 @@ acc_set_default(krb5_context context, krb5_ccache id)
|
||||
cc_int32 error;
|
||||
|
||||
if (a->ccache == NULL) {
|
||||
krb5_set_error_string(context, "No API credential found");
|
||||
krb5_set_error_message(context, KRB5_CC_NOTFOUND,
|
||||
"No API credential found");
|
||||
return KRB5_CC_NOTFOUND;
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ acl_parse_format(krb5_context context,
|
||||
for(p = format; *p != '\0'; p++) {
|
||||
tmp = malloc(sizeof(*tmp));
|
||||
if(tmp == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
acl_free_list(acl, 0);
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ acl_parse_format(krb5_context context,
|
||||
tmp->u.retv = va_arg(ap, char **);
|
||||
*tmp->u.retv = NULL;
|
||||
} else {
|
||||
krb5_set_error_string(context, "acl_parse_format: "
|
||||
krb5_set_error_message(context, EINVAL, "acl_parse_format: "
|
||||
"unknown format specifier %c", *p);
|
||||
acl_free_list(acl, 0);
|
||||
free(tmp);
|
||||
@@ -220,7 +220,7 @@ krb5_acl_match_string(krb5_context context,
|
||||
if (found) {
|
||||
return 0;
|
||||
} else {
|
||||
krb5_set_error_string(context, "ACL did not match");
|
||||
krb5_set_error_message(context, EACCES, "ACL did not match");
|
||||
return EACCES;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,8 @@ krb5_acl_match_file(krb5_context context,
|
||||
if(f == NULL) {
|
||||
int save_errno = errno;
|
||||
|
||||
krb5_set_error_string(context, "open(%s): %s", file,
|
||||
krb5_set_error_message(context, save_errno,
|
||||
"open(%s): %s", file,
|
||||
strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
@@ -287,7 +288,7 @@ krb5_acl_match_file(krb5_context context,
|
||||
if (found) {
|
||||
return 0;
|
||||
} else {
|
||||
krb5_set_error_string(context, "ACL did not match");
|
||||
krb5_set_error_message(context, EACCES, "ACL did not match");
|
||||
return EACCES;
|
||||
}
|
||||
}
|
||||
|
@@ -202,7 +202,8 @@ ipv4_mask_boundary(krb5_context context, const krb5_address *inaddr,
|
||||
uint32_t l, h, m = 0xffffffff;
|
||||
|
||||
if (len > 32) {
|
||||
krb5_set_error_string(context, "IPv4 prefix too large (%ld)", len);
|
||||
krb5_set_error_message(context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"IPv4 prefix too large (%ld)", len);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
m = m << (32 - len);
|
||||
@@ -395,12 +396,14 @@ ipv6_mask_boundary(krb5_context context, const krb5_address *inaddr,
|
||||
int i, sub_len;
|
||||
|
||||
if (len > 128) {
|
||||
krb5_set_error_string(context, "IPv6 prefix too large (%ld)", len);
|
||||
krb5_set_error_message(context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"IPv6 prefix too large (%ld)", len);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
|
||||
if (inaddr->address.length != sizeof(addr)) {
|
||||
krb5_set_error_string(context, "IPv6 addr bad length");
|
||||
krb5_set_error_message(context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"IPv6 addr bad length");
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
|
||||
@@ -786,7 +789,8 @@ krb5_sockaddr2address (krb5_context context,
|
||||
{
|
||||
struct addr_operations *a = find_af(sa->sa_family);
|
||||
if (a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported",
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported",
|
||||
sa->sa_family);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
@@ -813,7 +817,8 @@ krb5_sockaddr2port (krb5_context context,
|
||||
{
|
||||
struct addr_operations *a = find_af(sa->sa_family);
|
||||
if (a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported",
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported",
|
||||
sa->sa_family);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
@@ -851,12 +856,14 @@ krb5_addr2sockaddr (krb5_context context,
|
||||
struct addr_operations *a = find_atype(addr->addr_type);
|
||||
|
||||
if (a == NULL) {
|
||||
krb5_set_error_string (context, "Address type %d not supported",
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address type %d not supported",
|
||||
addr->addr_type);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
if (a->addr2sockaddr == NULL) {
|
||||
krb5_set_error_string (context,
|
||||
krb5_set_error_message (context,
|
||||
KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Can't convert address type %d to sockaddr",
|
||||
addr->addr_type);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
@@ -935,7 +942,8 @@ krb5_h_addr2sockaddr (krb5_context context,
|
||||
{
|
||||
struct addr_operations *a = find_af(af);
|
||||
if (a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported", af);
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported", af);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
(*a->h_addr2sockaddr)(addr, sa, sa_size, port);
|
||||
@@ -963,7 +971,8 @@ krb5_h_addr2addr (krb5_context context,
|
||||
{
|
||||
struct addr_operations *a = find_af(af);
|
||||
if (a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported", af);
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported", af);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
return (*a->h_addr2addr)(haddr, addr);
|
||||
@@ -996,7 +1005,8 @@ krb5_anyaddr (krb5_context context,
|
||||
struct addr_operations *a = find_af (af);
|
||||
|
||||
if (a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported", af);
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported", af);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
|
||||
@@ -1089,7 +1099,8 @@ krb5_parse_address(krb5_context context,
|
||||
if((*at[i].parse_addr)(context, string, &addr) == 0) {
|
||||
ALLOC_SEQ(addresses, 1);
|
||||
if (addresses->val == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
addresses->val[0] = addr;
|
||||
@@ -1101,7 +1112,8 @@ krb5_parse_address(krb5_context context,
|
||||
error = getaddrinfo (string, NULL, NULL, &ai);
|
||||
if (error) {
|
||||
save_errno = errno;
|
||||
krb5_set_error_string (context, "%s: %s", string, gai_strerror(error));
|
||||
krb5_set_error_message (context, save_errno, "%s: %s",
|
||||
string, gai_strerror(error));
|
||||
return krb5_eai_to_heim_errno(error, save_errno);
|
||||
}
|
||||
|
||||
@@ -1111,7 +1123,8 @@ krb5_parse_address(krb5_context context,
|
||||
|
||||
ALLOC_SEQ(addresses, n);
|
||||
if (addresses->val == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"malloc: out of memory");
|
||||
freeaddrinfo(ai);
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -1154,7 +1167,8 @@ krb5_address_order(krb5_context context,
|
||||
struct addr_operations *a;
|
||||
a = find_atype(addr1->addr_type);
|
||||
if(a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported",
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported",
|
||||
addr1->addr_type);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
@@ -1162,7 +1176,8 @@ krb5_address_order(krb5_context context,
|
||||
return (*a->order_addr)(context, addr1, addr2);
|
||||
a = find_atype(addr2->addr_type);
|
||||
if(a == NULL) {
|
||||
krb5_set_error_string (context, "Address family %d not supported",
|
||||
krb5_set_error_message (context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d not supported",
|
||||
addr2->addr_type);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
@@ -1349,7 +1364,8 @@ krb5_append_addresses(krb5_context context,
|
||||
if(source->len > 0) {
|
||||
tmp = realloc(dest->val, (dest->len + source->len) * sizeof(*tmp));
|
||||
if(tmp == NULL) {
|
||||
krb5_set_error_string(context, "realloc: out of memory");
|
||||
krb5_set_error_message (context, ENOMEM,
|
||||
"realloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
dest->val = tmp;
|
||||
@@ -1391,13 +1407,15 @@ krb5_make_addrport (krb5_context context,
|
||||
|
||||
*res = malloc (sizeof(**res));
|
||||
if (*res == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message (context, ENOMEM,
|
||||
"malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
(*res)->addr_type = KRB5_ADDRESS_ADDRPORT;
|
||||
ret = krb5_data_alloc (&(*res)->address, len);
|
||||
if (ret) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message (context, ret,
|
||||
"malloc: out of memory");
|
||||
free (*res);
|
||||
*res = NULL;
|
||||
return ret;
|
||||
@@ -1457,7 +1475,8 @@ krb5_address_prefixlen_boundary(krb5_context context,
|
||||
struct addr_operations *a = find_atype (inaddr->addr_type);
|
||||
if(a != NULL && a->mask_boundary != NULL)
|
||||
return (*a->mask_boundary)(context, inaddr, prefixlen, low, high);
|
||||
krb5_set_error_string(context, "Address family %d doesn't support "
|
||||
krb5_set_error_message(context, KRB5_PROG_ATYPE_NOSUPP,
|
||||
"Address family %d doesn't support "
|
||||
"address mask operation", inaddr->addr_type);
|
||||
return KRB5_PROG_ATYPE_NOSUPP;
|
||||
}
|
||||
|
@@ -43,13 +43,13 @@ krb5_auth_con_init(krb5_context context,
|
||||
|
||||
ALLOC(p, 1);
|
||||
if(!p) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memset(p, 0, sizeof(*p));
|
||||
ALLOC(p->authenticator, 1);
|
||||
if (!p->authenticator) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
free(p);
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -174,7 +174,8 @@ krb5_auth_con_genaddrs(krb5_context context,
|
||||
len = sizeof(ss_local);
|
||||
if(getsockname(fd, local, &len) < 0) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "getsockname: %s",
|
||||
krb5_set_error_message(context, ret,
|
||||
"getsockname: %s",
|
||||
strerror(ret));
|
||||
goto out;
|
||||
}
|
||||
@@ -191,7 +192,8 @@ krb5_auth_con_genaddrs(krb5_context context,
|
||||
len = sizeof(ss_remote);
|
||||
if(getpeername(fd, remote, &len) < 0) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "getpeername: %s", strerror(ret));
|
||||
krb5_set_error_message(context, ret,
|
||||
"getpeername: %s", strerror(ret));
|
||||
goto out;
|
||||
}
|
||||
ret = krb5_sockaddr2address (context, remote, &remote_k_address);
|
||||
@@ -239,7 +241,7 @@ krb5_auth_con_getaddrs(krb5_context context,
|
||||
krb5_free_address (context, *local_addr);
|
||||
*local_addr = malloc (sizeof(**local_addr));
|
||||
if (*local_addr == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
krb5_copy_address(context,
|
||||
@@ -250,7 +252,7 @@ krb5_auth_con_getaddrs(krb5_context context,
|
||||
krb5_free_address (context, *remote_addr);
|
||||
*remote_addr = malloc (sizeof(**remote_addr));
|
||||
if (*remote_addr == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
krb5_free_address (context, *local_addr);
|
||||
*local_addr = NULL;
|
||||
return ENOMEM;
|
||||
@@ -450,7 +452,7 @@ krb5_auth_con_getauthenticator(krb5_context context,
|
||||
{
|
||||
*authenticator = malloc(sizeof(**authenticator));
|
||||
if (*authenticator == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
|
@@ -62,7 +62,7 @@ make_etypelist(krb5_context context,
|
||||
ALLOC_SEQ(&ad, 1);
|
||||
if (ad.val == NULL) {
|
||||
free(buf);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@ make_etypelist(krb5_context context,
|
||||
|
||||
ALLOC(*auth_data, 1);
|
||||
if (*auth_data == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ALLOC_SEQ(*auth_data, 1);
|
||||
if ((*auth_data)->val == NULL) {
|
||||
free(buf);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ krb5_build_authenticator (krb5_context context,
|
||||
|
||||
auth = calloc(1, sizeof(*auth));
|
||||
if (auth == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,8 @@ krb5_cc_register(krb5_context context,
|
||||
for(i = 0; i < context->num_cc_ops && context->cc_ops[i].prefix; i++) {
|
||||
if(strcmp(context->cc_ops[i].prefix, ops->prefix) == 0) {
|
||||
if(!override) {
|
||||
krb5_set_error_string(context,
|
||||
krb5_set_error_message(context,
|
||||
KRB5_CC_TYPE_EXISTS,
|
||||
"ccache type %s already exists",
|
||||
ops->prefix);
|
||||
return KRB5_CC_TYPE_EXISTS;
|
||||
@@ -72,7 +73,8 @@ krb5_cc_register(krb5_context context,
|
||||
(context->num_cc_ops + 1) *
|
||||
sizeof(*context->cc_ops));
|
||||
if(o == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, KRB5_CC_NOMEM,
|
||||
"malloc: out of memory");
|
||||
return KRB5_CC_NOMEM;
|
||||
}
|
||||
context->num_cc_ops++;
|
||||
@@ -98,7 +100,7 @@ _krb5_cc_allocate(krb5_context context,
|
||||
|
||||
p = malloc (sizeof(*p));
|
||||
if(p == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, KRB5_CC_NOMEM, "malloc: out of memory");
|
||||
return KRB5_CC_NOMEM;
|
||||
}
|
||||
p->ops = ops;
|
||||
@@ -166,7 +168,8 @@ krb5_cc_resolve(krb5_context context,
|
||||
if (strchr (name, ':') == NULL)
|
||||
return allocate_ccache (context, &krb5_fcc_ops, name, id);
|
||||
else {
|
||||
krb5_set_error_string(context, "unknown ccache type %s", name);
|
||||
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
||||
"unknown ccache type %s", name);
|
||||
return KRB5_CC_UNKNOWN_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -209,7 +212,7 @@ krb5_cc_new_unique(krb5_context context, const char *type,
|
||||
|
||||
ops = krb5_cc_get_prefix_ops(context, type);
|
||||
if (ops == NULL) {
|
||||
krb5_set_error_string(context,
|
||||
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
||||
"Credential cache type %s is unknown", type);
|
||||
return KRB5_CC_UNKNOWN_TYPE;
|
||||
}
|
||||
@@ -268,18 +271,20 @@ krb5_cc_get_full_name(krb5_context context,
|
||||
|
||||
type = krb5_cc_get_type(context, id);
|
||||
if (type == NULL) {
|
||||
krb5_set_error_string(context, "cache have no name of type");
|
||||
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
||||
"cache have no name of type");
|
||||
return KRB5_CC_UNKNOWN_TYPE;
|
||||
}
|
||||
|
||||
name = krb5_cc_get_name(context, id);
|
||||
if (name == NULL) {
|
||||
krb5_set_error_string(context, "cache of type %s have no name", type);
|
||||
krb5_set_error_message(context, KRB5_CC_BADNAME,
|
||||
"cache of type %s have no name", type);
|
||||
return KRB5_CC_BADNAME;
|
||||
}
|
||||
|
||||
if (asprintf(str, "%s:%s", type, name) == -1) {
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc - out of memory");
|
||||
*str = NULL;
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -325,7 +330,8 @@ _krb5_expand_default_cc_name(krb5_context context, const char *str, char **res)
|
||||
if (tmp2 == NULL) {
|
||||
free(*res);
|
||||
*res = NULL;
|
||||
krb5_set_error_string(context, "variable missing }");
|
||||
krb5_set_error_message(context, KRB5_CONFIG_BADFORMAT,
|
||||
"variable missing }");
|
||||
return KRB5_CONFIG_BADFORMAT;
|
||||
}
|
||||
if (strncasecmp(tmp, "%{uid}", 6) == 0)
|
||||
@@ -335,7 +341,8 @@ _krb5_expand_default_cc_name(krb5_context context, const char *str, char **res)
|
||||
else {
|
||||
free(*res);
|
||||
*res = NULL;
|
||||
krb5_set_error_string(context,
|
||||
krb5_set_error_message(context,
|
||||
KRB5_CONFIG_BADFORMAT,
|
||||
"expand default cache unknown "
|
||||
"variable \"%.*s\"",
|
||||
(int)(tmp2 - tmp) - 2, tmp + 2);
|
||||
@@ -349,7 +356,7 @@ _krb5_expand_default_cc_name(krb5_context context, const char *str, char **res)
|
||||
if (append == NULL) {
|
||||
free(*res);
|
||||
*res = NULL;
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc - out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -359,7 +366,8 @@ _krb5_expand_default_cc_name(krb5_context context, const char *str, char **res)
|
||||
free(append);
|
||||
free(*res);
|
||||
*res = NULL;
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"malloc - out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
*res = tmp;
|
||||
@@ -461,7 +469,8 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
|
||||
if (e) {
|
||||
ops = krb5_cc_get_prefix_ops(context, e);
|
||||
if (ops == NULL) {
|
||||
krb5_set_error_string(context,
|
||||
krb5_set_error_message(context,
|
||||
KRB5_CC_UNKNOWN_TYPE,
|
||||
"Credential cache type %s "
|
||||
"is unknown", e);
|
||||
return KRB5_CC_UNKNOWN_TYPE;
|
||||
@@ -479,7 +488,7 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
|
||||
}
|
||||
|
||||
if (p == NULL) {
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc - out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -526,7 +535,7 @@ krb5_cc_default(krb5_context context,
|
||||
const char *p = krb5_cc_default_name(context);
|
||||
|
||||
if (p == NULL) {
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc - out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
return krb5_cc_resolve(context, p, id);
|
||||
@@ -755,7 +764,8 @@ krb5_cc_remove_cred(krb5_context context,
|
||||
krb5_creds *cred)
|
||||
{
|
||||
if(id->ops->remove_cred == NULL) {
|
||||
krb5_set_error_string(context,
|
||||
krb5_set_error_message(context,
|
||||
EACCES,
|
||||
"ccache %s does not support remove_cred",
|
||||
id->ops->prefix);
|
||||
return EACCES; /* XXX */
|
||||
@@ -897,7 +907,7 @@ krb5_cc_get_prefix_ops(krb5_context context, const char *prefix)
|
||||
|
||||
p = strdup(prefix);
|
||||
if (p == NULL) {
|
||||
krb5_set_error_string(context, "malloc - out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc - out of memory");
|
||||
return NULL;
|
||||
}
|
||||
p1 = strchr(p, ':');
|
||||
@@ -942,7 +952,8 @@ krb5_cc_cache_get_first (krb5_context context,
|
||||
|
||||
ops = krb5_cc_get_prefix_ops(context, type);
|
||||
if (ops == NULL) {
|
||||
krb5_set_error_string(context, "Unknown type \"%s\" when iterating "
|
||||
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
||||
"Unknown type \"%s\" when iterating "
|
||||
"trying to iterate the credential caches", type);
|
||||
return KRB5_CC_UNKNOWN_TYPE;
|
||||
}
|
||||
@@ -1059,8 +1070,10 @@ krb5_cc_cache_match (krb5_context context,
|
||||
|
||||
krb5_unparse_name(context, client, &str);
|
||||
|
||||
krb5_set_error_string(context, "Principal %s not found in a "
|
||||
"credential cache", str ? str : "<out of memory>");
|
||||
krb5_set_error_message(context, KRB5_CC_NOTFOUND,
|
||||
"Principal %s not found in a "
|
||||
"credential cache",
|
||||
str ? str : "<out of memory>");
|
||||
if (str)
|
||||
free(str);
|
||||
return KRB5_CC_NOTFOUND;
|
||||
@@ -1090,7 +1103,8 @@ krb5_cc_move(krb5_context context, krb5_ccache from, krb5_ccache to)
|
||||
krb5_error_code ret;
|
||||
|
||||
if (strcmp(from->ops->prefix, to->ops->prefix) != 0) {
|
||||
krb5_set_error_string(context, "Moving credentials between diffrent "
|
||||
krb5_set_error_message(context, KRB5_CC_NOSUPP,
|
||||
"Moving credentials between diffrent "
|
||||
"types not yet supported");
|
||||
return KRB5_CC_NOSUPP;
|
||||
}
|
||||
|
@@ -141,7 +141,8 @@ chgpw_send_request (krb5_context context,
|
||||
|
||||
if (sendmsg (sock, &msghdr, 0) < 0) {
|
||||
ret = errno;
|
||||
krb5_set_error_string(context, "sendmsg %s: %s", host, strerror(ret));
|
||||
krb5_set_error_message(context, ret, "sendmsg %s: %s",
|
||||
host, strerror(ret));
|
||||
}
|
||||
|
||||
krb5_data_free (&krb_priv_data);
|
||||
@@ -250,7 +251,8 @@ setpw_send_request (krb5_context context,
|
||||
|
||||
if (sendmsg (sock, &msghdr, 0) < 0) {
|
||||
ret = errno;
|
||||
krb5_set_error_string(context, "sendmsg %s: %s", host, strerror(ret));
|
||||
krb5_set_error_message(context, ret, "sendmsg %s: %s",
|
||||
host, strerror(ret));
|
||||
}
|
||||
|
||||
krb5_data_free (&krb_priv_data);
|
||||
@@ -286,11 +288,12 @@ process_reply (krb5_context context,
|
||||
0, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
save_errno = errno;
|
||||
krb5_set_error_string(context, "recvfrom %s: %s",
|
||||
krb5_set_error_message(context, save_errno,
|
||||
"recvfrom %s: %s",
|
||||
host, strerror(save_errno));
|
||||
return save_errno;
|
||||
} else if (ret == 0) {
|
||||
krb5_set_error_string(context, "recvfrom timeout %s", host);
|
||||
krb5_set_error_string(context, 1, "recvfrom timeout %s", host);
|
||||
return 1;
|
||||
}
|
||||
len += ret;
|
||||
@@ -304,7 +307,8 @@ process_reply (krb5_context context,
|
||||
break;
|
||||
}
|
||||
if (len == sizeof(reply)) {
|
||||
krb5_set_error_string(context, "message too large from %s",
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"message too large from %s",
|
||||
host);
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -312,7 +316,8 @@ process_reply (krb5_context context,
|
||||
ret = recvfrom (sock, reply, sizeof(reply), 0, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
save_errno = errno;
|
||||
krb5_set_error_string(context, "recvfrom %s: %s",
|
||||
krb5_set_error_message(context, save_errno,
|
||||
"recvfrom %s: %s",
|
||||
host, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
@@ -607,8 +612,9 @@ change_password_loop (krb5_context context,
|
||||
}
|
||||
|
||||
if (sock >= FD_SETSIZE) {
|
||||
krb5_set_error_string(context, "fd %d too large", sock);
|
||||
ret = ERANGE;
|
||||
krb5_set_error_message(context, ret,
|
||||
"fd %d too large", sock);
|
||||
close (sock);
|
||||
goto out;
|
||||
}
|
||||
@@ -649,7 +655,8 @@ change_password_loop (krb5_context context,
|
||||
krb5_auth_con_free (context, auth_context);
|
||||
|
||||
if (ret == KRB5_KDC_UNREACH) {
|
||||
krb5_set_error_string(context,
|
||||
krb5_set_error_message(context,
|
||||
ret,
|
||||
"unable to reach any changepw server "
|
||||
" in realm %s", realm);
|
||||
*result_code = KRB5_KPASSWD_HARDERROR;
|
||||
|
@@ -295,7 +295,8 @@ krb5_config_parse_string_multi(krb5_context context,
|
||||
|
||||
ret = krb5_config_parse_debug (&f, res, &lineno, &str);
|
||||
if (ret) {
|
||||
krb5_set_error_string (context, "%s:%u: %s", "<constant>", lineno, str);
|
||||
krb5_set_error_message (context, ret, "%s:%u: %s",
|
||||
"<constant>", lineno, str);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
@@ -314,7 +315,8 @@ krb5_config_parse_file_multi (krb5_context context,
|
||||
f.s = NULL;
|
||||
if(f.f == NULL) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "open %s: %s", fname, strerror(ret));
|
||||
krb5_set_error_message (context, ret, "open %s: %s",
|
||||
fname, strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -38,54 +38,66 @@ RCSID("$Id$");
|
||||
#undef __attribute__
|
||||
#define __attribute__(X)
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
krb5_free_error_string(krb5_context context, char *str)
|
||||
{
|
||||
HEIMDAL_MUTEX_lock(context->mutex);
|
||||
if (str != context->error_buf)
|
||||
free(str);
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
}
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
krb5_clear_error_string(krb5_context context)
|
||||
{
|
||||
HEIMDAL_MUTEX_lock(context->mutex);
|
||||
if (context->error_string != NULL
|
||||
&& context->error_string != context->error_buf)
|
||||
if (context->error_string)
|
||||
free(context->error_string);
|
||||
context->error_code = 0;
|
||||
context->error_string = NULL;
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
}
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
krb5_set_error_string(krb5_context context, const char *fmt, ...)
|
||||
__attribute__((format (printf, 2, 3)))
|
||||
/**
|
||||
* Set the context full error string for a specific error code.
|
||||
*
|
||||
* @param context Kerberos 5 context
|
||||
* @param ret The error code
|
||||
* @param fmt Error string for the error code
|
||||
* @param ... printf(3) style parameters.
|
||||
*
|
||||
* @ingroup krb5_error
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
krb5_set_error_message(krb5_context context, krb5_error_code ret,
|
||||
const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 3, 4)))
|
||||
{
|
||||
krb5_error_code ret;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = krb5_vset_error_string (context, fmt, ap);
|
||||
krb5_vset_error_message (context, ret, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
krb5_vset_error_string(krb5_context context, const char *fmt, va_list args)
|
||||
__attribute__ ((format (printf, 2, 0)))
|
||||
/**
|
||||
* Set the context full error string for a specific error code.
|
||||
*
|
||||
* @param context Kerberos 5 context
|
||||
* @param ret The error code
|
||||
* @param fmt Error string for the error code
|
||||
* @param args printf(3) style parameters.
|
||||
*
|
||||
* @ingroup krb5_error
|
||||
*/
|
||||
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
krb5_vset_error_message (krb5_context context, krb5_error_code ret,
|
||||
const char *fmt, va_list args)
|
||||
__attribute__ ((format (printf, 3, 0)))
|
||||
{
|
||||
|
||||
krb5_clear_error_string(context);
|
||||
HEIMDAL_MUTEX_lock(context->mutex);
|
||||
context->error_code = ret;
|
||||
vasprintf(&context->error_string, fmt, args);
|
||||
if(context->error_string == NULL) {
|
||||
vsnprintf (context->error_buf, sizeof(context->error_buf), fmt, args);
|
||||
context->error_string = context->error_buf;
|
||||
}
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the error message in context. On error or no error string,
|
||||
* the function returns NULL.
|
||||
@@ -93,7 +105,7 @@ krb5_vset_error_string(krb5_context context, const char *fmt, va_list args)
|
||||
* @param context Kerberos 5 context
|
||||
*
|
||||
* @return an error string, needs to be freed with
|
||||
* krb5_free_error_string(). The functions return NULL on error.
|
||||
* krb5_free_error_message(). The functions return NULL on error.
|
||||
*
|
||||
* @ingroup krb5_error
|
||||
*/
|
||||
@@ -121,8 +133,8 @@ krb5_have_error_string(krb5_context context)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error message for `code' in context. On error the
|
||||
* function returns NULL.
|
||||
* Return the error message for `code' in context. On memory
|
||||
* allocation error the function returns NULL.
|
||||
*
|
||||
* @param context Kerberos 5 context
|
||||
* @param code Error code related to the error
|
||||
@@ -139,9 +151,17 @@ krb5_get_error_message(krb5_context context, krb5_error_code code)
|
||||
const char *cstr;
|
||||
char *str;
|
||||
|
||||
cstr = krb5_get_error_string(context);
|
||||
if (cstr)
|
||||
return cstr;
|
||||
HEIMDAL_MUTEX_lock(context->mutex);
|
||||
if (context->error_string &&
|
||||
(code == context->error_code || context->error_code == 0))
|
||||
{
|
||||
str = strdup(context->error_string);
|
||||
if (str) {
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
|
||||
cstr = krb5_get_err_text(context, code);
|
||||
if (cstr)
|
||||
@@ -158,7 +178,8 @@ krb5_get_error_message(krb5_context context, krb5_error_code code)
|
||||
* Free the error message returned by krb5_get_error_message().
|
||||
*
|
||||
* @param context Kerberos context
|
||||
* @param msg error message to free
|
||||
* @param msg error message to free, returned byg
|
||||
* krb5_get_error_message().
|
||||
*
|
||||
* @ingroup krb5_error
|
||||
*/
|
||||
@@ -168,3 +189,40 @@ krb5_free_error_message(krb5_context context, const char *msg)
|
||||
{
|
||||
free(rk_UNCONST(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the error message returned by krb5_get_error_string(),
|
||||
* deprecated, use krb5_free_error_message().
|
||||
*
|
||||
* @param context Kerberos context
|
||||
* @param msg error message to free
|
||||
*
|
||||
* @ingroup krb5_error
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION __attribute__((deprecated))
|
||||
krb5_free_error_string(krb5_context context, char *str)
|
||||
{
|
||||
krb5_free_error_message(context, str);
|
||||
}
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
krb5_set_error_string(krb5_context context, const char *fmt, ...)
|
||||
__attribute__((format (printf, 2, 3))) __attribute__((deprecated))
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
krb5_vset_error_message (context, 0, fmt, ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
krb5_vset_error_string(krb5_context context, const char *fmt, va_list args)
|
||||
__attribute__ ((format (printf, 2, 0))) __attribute__((deprecated))
|
||||
{
|
||||
krb5_vset_error_message(context, 0, fmt, args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user