Patch from Secure Endpoints/Asanka Herath for windows support
This commit is contained in:
@@ -242,6 +242,29 @@ cc_ops_register(krb5_context context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
cc_ops_copy(krb5_context context, const krb5_context src_context)
|
||||
{
|
||||
context->cc_ops = NULL;
|
||||
context->num_cc_ops = 0;
|
||||
|
||||
if (src_context->num_cc_ops == 0)
|
||||
return 0;
|
||||
|
||||
context->cc_ops = malloc(sizeof(context->cc_ops[0]) * src_context->num_cc_ops);
|
||||
if (context->cc_ops == NULL) {
|
||||
krb5_set_error_message(context, KRB5_CC_NOMEM,
|
||||
N_("malloc: out of memory", ""));
|
||||
return KRB5_CC_NOMEM;
|
||||
}
|
||||
|
||||
context->num_cc_ops = src_context->num_cc_ops;
|
||||
memcpy(context->cc_ops, src_context->cc_ops,
|
||||
sizeof(context->cc_ops[0]) * src_context->num_cc_ops);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
kt_ops_register(krb5_context context)
|
||||
{
|
||||
@@ -259,6 +282,28 @@ kt_ops_register(krb5_context context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
kt_ops_copy(krb5_context context, const krb5_context src_context)
|
||||
{
|
||||
context->num_kt_types = 0;
|
||||
context->kt_types = NULL;
|
||||
|
||||
if (src_context->num_kt_types == 0)
|
||||
return 0;
|
||||
|
||||
context->kt_types = malloc(sizeof(context->kt_types[0]) * src_context->num_kt_types);
|
||||
if (context->kt_types == NULL) {
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
N_("malloc: out of memory", ""));
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
context->num_kt_types = src_context->num_kt_types;
|
||||
memcpy(context->kt_types, src_context->kt_types,
|
||||
sizeof(context->kt_types[0]) * src_context->num_kt_types);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the context structure and reads the configuration file
|
||||
@@ -275,7 +320,7 @@ kt_ops_register(krb5_context context)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_init_context(krb5_context *context)
|
||||
{
|
||||
krb5_context p;
|
||||
@@ -318,6 +363,10 @@ krb5_init_context(krb5_context *context)
|
||||
if (ret)
|
||||
goto out;
|
||||
#endif
|
||||
#ifdef NEED_SOCK_INIT
|
||||
if (SOCK_INIT)
|
||||
p->flags |= KRB5_CTX_F_SOCKETS_INITIALIZED;
|
||||
#endif
|
||||
|
||||
out:
|
||||
if(ret) {
|
||||
@@ -368,7 +417,7 @@ copy_etypes (krb5_context context,
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_copy_context(krb5_context context, krb5_context *out)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
@@ -420,8 +469,9 @@ krb5_copy_context(krb5_context context, krb5_context *out)
|
||||
|
||||
/* XXX should copy */
|
||||
krb5_init_ets(p);
|
||||
cc_ops_register(p);
|
||||
kt_ops_register(p);
|
||||
|
||||
cc_ops_copy(p, context);
|
||||
kt_ops_copy(p, context);
|
||||
|
||||
#if 0 /* XXX */
|
||||
if(context->warn_dest != NULL)
|
||||
@@ -460,7 +510,7 @@ krb5_copy_context(krb5_context context, krb5_context *out)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
|
||||
krb5_free_context(krb5_context context)
|
||||
{
|
||||
if (context->default_cc_name)
|
||||
@@ -489,6 +539,11 @@ krb5_free_context(krb5_context context)
|
||||
|
||||
HEIMDAL_MUTEX_destroy(context->mutex);
|
||||
free(context->mutex);
|
||||
#ifdef NEED_SOCK_INIT
|
||||
if (context->flags & KRB5_CTX_F_SOCKETS_INITIALIZED) {
|
||||
SOCK_EXIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
free(context);
|
||||
@@ -506,7 +561,7 @@ krb5_free_context(krb5_context context)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_set_config_files(krb5_context context, char **filenames)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
@@ -561,7 +616,7 @@ add_file(char ***pfilenames, int *len, char *file)
|
||||
* `pq' isn't free, it's up the the caller
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_prepend_config_files(const char *filelist, char **pq, char ***ret_pp)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
@@ -626,7 +681,7 @@ krb5_prepend_config_files(const char *filelist, char **pq, char ***ret_pp)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_prepend_config_files_default(const char *filelist, char ***pfilenames)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
@@ -656,7 +711,7 @@ krb5_prepend_config_files_default(const char *filelist, char ***pfilenames)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_get_default_config_files(char ***pfilenames)
|
||||
{
|
||||
const char *files = NULL;
|
||||
@@ -683,7 +738,7 @@ krb5_get_default_config_files(char ***pfilenames)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
|
||||
krb5_free_config_files(char **filenames)
|
||||
{
|
||||
char **p;
|
||||
@@ -705,7 +760,7 @@ krb5_free_config_files(char **filenames)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
const krb5_enctype * KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION const krb5_enctype * KRB5_LIB_CALL
|
||||
krb5_kerberos_enctypes(krb5_context context)
|
||||
{
|
||||
static const krb5_enctype p[] = {
|
||||
@@ -766,7 +821,7 @@ default_etypes(krb5_context context, krb5_enctype **etype)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_set_default_in_tkt_etypes(krb5_context context,
|
||||
const krb5_enctype *etypes)
|
||||
{
|
||||
@@ -808,7 +863,7 @@ krb5_set_default_in_tkt_etypes(krb5_context context,
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_get_default_in_tkt_etypes(krb5_context context,
|
||||
krb5_enctype **etypes)
|
||||
{
|
||||
@@ -842,7 +897,7 @@ krb5_get_default_in_tkt_etypes(krb5_context context,
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
|
||||
krb5_init_ets(krb5_context context)
|
||||
{
|
||||
if(context->et_list == NULL){
|
||||
@@ -877,7 +932,7 @@ krb5_init_ets(krb5_context context)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
|
||||
krb5_set_use_admin_kdc (krb5_context context, krb5_boolean flag)
|
||||
{
|
||||
context->use_admin_kdc = flag;
|
||||
@@ -893,7 +948,7 @@ krb5_set_use_admin_kdc (krb5_context context, krb5_boolean flag)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_boolean KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
|
||||
krb5_get_use_admin_kdc (krb5_context context)
|
||||
{
|
||||
return context->use_admin_kdc;
|
||||
@@ -912,7 +967,7 @@ krb5_get_use_admin_kdc (krb5_context context)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_add_extra_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
{
|
||||
|
||||
@@ -936,7 +991,7 @@ krb5_add_extra_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_set_extra_addresses(krb5_context context, const krb5_addresses *addresses)
|
||||
{
|
||||
if(context->extra_addresses)
|
||||
@@ -972,7 +1027,7 @@ krb5_set_extra_addresses(krb5_context context, const krb5_addresses *addresses)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_get_extra_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
{
|
||||
if(context->extra_addresses == NULL) {
|
||||
@@ -995,7 +1050,7 @@ krb5_get_extra_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_add_ignore_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
{
|
||||
|
||||
@@ -1019,7 +1074,7 @@ krb5_add_ignore_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_set_ignore_addresses(krb5_context context, const krb5_addresses *addresses)
|
||||
{
|
||||
if(context->ignore_addresses)
|
||||
@@ -1054,7 +1109,7 @@ krb5_set_ignore_addresses(krb5_context context, const krb5_addresses *addresses)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_get_ignore_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
{
|
||||
if(context->ignore_addresses == NULL) {
|
||||
@@ -1076,7 +1131,7 @@ krb5_get_ignore_addresses(krb5_context context, krb5_addresses *addresses)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_set_fcache_version(krb5_context context, int version)
|
||||
{
|
||||
context->fcache_vno = version;
|
||||
@@ -1095,7 +1150,7 @@ krb5_set_fcache_version(krb5_context context, int version)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_get_fcache_version(krb5_context context, int *version)
|
||||
{
|
||||
*version = context->fcache_vno;
|
||||
@@ -1111,7 +1166,7 @@ krb5_get_fcache_version(krb5_context context, int *version)
|
||||
*/
|
||||
|
||||
|
||||
krb5_boolean KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
|
||||
krb5_is_thread_safe(void)
|
||||
{
|
||||
#ifdef ENABLE_PTHREAD_SUPPORT
|
||||
@@ -1130,7 +1185,7 @@ krb5_is_thread_safe(void)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
|
||||
krb5_set_dns_canonicalize_hostname (krb5_context context, krb5_boolean flag)
|
||||
{
|
||||
if (flag)
|
||||
@@ -1149,7 +1204,7 @@ krb5_set_dns_canonicalize_hostname (krb5_context context, krb5_boolean flag)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_boolean KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
|
||||
krb5_get_dns_canonicalize_hostname (krb5_context context)
|
||||
{
|
||||
return (context->flags & KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME) ? 1 : 0;
|
||||
@@ -1167,7 +1222,7 @@ krb5_get_dns_canonicalize_hostname (krb5_context context)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_get_kdc_sec_offset (krb5_context context, int32_t *sec, int32_t *usec)
|
||||
{
|
||||
if (sec)
|
||||
@@ -1189,7 +1244,7 @@ krb5_get_kdc_sec_offset (krb5_context context, int32_t *sec, int32_t *usec)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_set_kdc_sec_offset (krb5_context context, int32_t sec, int32_t usec)
|
||||
{
|
||||
context->kdc_sec_offset = sec;
|
||||
@@ -1208,7 +1263,7 @@ krb5_set_kdc_sec_offset (krb5_context context, int32_t sec, int32_t usec)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
time_t KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION time_t KRB5_LIB_CALL
|
||||
krb5_get_max_time_skew (krb5_context context)
|
||||
{
|
||||
return context->max_skew;
|
||||
@@ -1223,7 +1278,7 @@ krb5_get_max_time_skew (krb5_context context)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
void KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
|
||||
krb5_set_max_time_skew (krb5_context context, time_t t)
|
||||
{
|
||||
context->max_skew = t;
|
||||
@@ -1243,7 +1298,7 @@ krb5_set_max_time_skew (krb5_context context, time_t t)
|
||||
* @ingroup krb5
|
||||
*/
|
||||
|
||||
krb5_error_code KRB5_LIB_FUNCTION
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
krb5_init_etype (krb5_context context,
|
||||
unsigned *len,
|
||||
krb5_enctype **val,
|
||||
@@ -1291,9 +1346,11 @@ _krb5_homedir_access(krb5_context context)
|
||||
{
|
||||
krb5_boolean allow;
|
||||
|
||||
#ifdef HAVE_GETEUID
|
||||
/* is never allowed for root */
|
||||
if (geteuid() == 0)
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
if (context && (context->flags & KRB5_CTX_F_HOMEDIR_ACCESS) == 0)
|
||||
return FALSE;
|
||||
|
Reference in New Issue
Block a user