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