track kdc offset better
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
* Portions Copyright (c) 2009 Apple Inc. All rights reserved.
|
||||||
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
@@ -507,13 +509,17 @@ static krb5_error_code
|
|||||||
init_fcc (krb5_context context,
|
init_fcc (krb5_context context,
|
||||||
krb5_ccache id,
|
krb5_ccache id,
|
||||||
krb5_storage **ret_sp,
|
krb5_storage **ret_sp,
|
||||||
int *ret_fd)
|
int *ret_fd,
|
||||||
|
krb5_deltat *kdc_offset)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int8_t pvno, tag;
|
int8_t pvno, tag;
|
||||||
krb5_storage *sp;
|
krb5_storage *sp;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
|
|
||||||
|
if (kdc_offset)
|
||||||
|
*kdc_offset = 0;
|
||||||
|
|
||||||
ret = fcc_open(context, id, &fd, O_RDONLY | O_BINARY | O_CLOEXEC, 0);
|
ret = fcc_open(context, id, &fd, O_RDONLY | O_BINARY | O_CLOEXEC, 0);
|
||||||
if(ret)
|
if(ret)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -589,8 +595,11 @@ init_fcc (krb5_context context,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
switch (dtag) {
|
switch (dtag) {
|
||||||
case FCC_TAG_DELTATIME :
|
case FCC_TAG_DELTATIME : {
|
||||||
ret = krb5_ret_int32 (sp, &context->kdc_sec_offset);
|
int32_t offset;
|
||||||
|
|
||||||
|
ret = krb5_ret_int32 (sp, &offset);
|
||||||
|
ret |= krb5_ret_int32 (sp, &context->kdc_usec_offset);
|
||||||
if(ret) {
|
if(ret) {
|
||||||
ret = KRB5_CC_FORMAT;
|
ret = KRB5_CC_FORMAT;
|
||||||
krb5_set_error_message(context, ret,
|
krb5_set_error_message(context, ret,
|
||||||
@@ -599,16 +608,11 @@ init_fcc (krb5_context context,
|
|||||||
FILENAME(id));
|
FILENAME(id));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
ret = krb5_ret_int32 (sp, &context->kdc_usec_offset);
|
context->kdc_sec_offset = offset;
|
||||||
if(ret) {
|
if (kdc_offset)
|
||||||
ret = KRB5_CC_FORMAT;
|
*kdc_offset = offset;
|
||||||
krb5_set_error_message(context, ret,
|
|
||||||
N_("Error reading kdc_usec in "
|
|
||||||
"cache file: %s", ""),
|
|
||||||
FILENAME(id));
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default :
|
default :
|
||||||
for (i = 0; i < data_len; ++i) {
|
for (i = 0; i < data_len; ++i) {
|
||||||
ret = krb5_ret_int8 (sp, &dummy);
|
ret = krb5_ret_int8 (sp, &dummy);
|
||||||
@@ -660,7 +664,7 @@ fcc_get_principal(krb5_context context,
|
|||||||
int fd;
|
int fd;
|
||||||
krb5_storage *sp;
|
krb5_storage *sp;
|
||||||
|
|
||||||
ret = init_fcc (context, id, &sp, &fd);
|
ret = init_fcc (context, id, &sp, &fd, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = krb5_ret_principal(sp, principal);
|
ret = krb5_ret_principal(sp, principal);
|
||||||
@@ -693,7 +697,7 @@ fcc_get_first (krb5_context context,
|
|||||||
memset(*cursor, 0, sizeof(struct fcc_cursor));
|
memset(*cursor, 0, sizeof(struct fcc_cursor));
|
||||||
|
|
||||||
ret = init_fcc (context, id, &FCC_CURSOR(*cursor)->sp,
|
ret = init_fcc (context, id, &FCC_CURSOR(*cursor)->sp,
|
||||||
&FCC_CURSOR(*cursor)->fd);
|
&FCC_CURSOR(*cursor)->fd, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
free(*cursor);
|
free(*cursor);
|
||||||
*cursor = NULL;
|
*cursor = NULL;
|
||||||
@@ -863,7 +867,17 @@ fcc_get_cache_next(krb5_context context, krb5_cc_cursor cursor, krb5_ccache *id)
|
|||||||
return ret;
|
return ret;
|
||||||
fn = expandedfn;
|
fn = expandedfn;
|
||||||
}
|
}
|
||||||
|
/* check if file exists, don't return a non existant "next" */
|
||||||
|
if (strncasecmp(fn, "FILE:", 5) == 0) {
|
||||||
|
struct stat sb;
|
||||||
|
ret = stat(fn + 5, &sb);
|
||||||
|
if (ret) {
|
||||||
|
ret = KRB5_CC_END;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
ret = krb5_cc_resolve(context, fn, id);
|
ret = krb5_cc_resolve(context, fn, id);
|
||||||
|
out:
|
||||||
if (expandedfn)
|
if (expandedfn)
|
||||||
free(expandedfn);
|
free(expandedfn);
|
||||||
|
|
||||||
@@ -947,7 +961,7 @@ fcc_move(krb5_context context, krb5_ccache from, krb5_ccache to)
|
|||||||
{
|
{
|
||||||
krb5_storage *sp;
|
krb5_storage *sp;
|
||||||
int fd;
|
int fd;
|
||||||
ret = init_fcc (context, to, &sp, &fd);
|
ret = init_fcc (context, to, &sp, &fd, NULL);
|
||||||
if (sp)
|
if (sp)
|
||||||
krb5_storage_free(sp);
|
krb5_storage_free(sp);
|
||||||
fcc_unlock(context, fd);
|
fcc_unlock(context, fd);
|
||||||
@@ -988,6 +1002,28 @@ fcc_lastchange(krb5_context context, krb5_ccache id, krb5_timestamp *mtime)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static krb5_error_code
|
||||||
|
fcc_set_kdc_offset(krb5_context context, krb5_ccache id, krb5_deltat kdc_offset)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static krb5_error_code
|
||||||
|
fcc_get_kdc_offset(krb5_context context, krb5_ccache id, krb5_deltat *kdc_offset)
|
||||||
|
{
|
||||||
|
krb5_error_code ret;
|
||||||
|
krb5_storage *sp;
|
||||||
|
int fd;
|
||||||
|
ret = init_fcc(context, id, &sp, &fd, kdc_offset);
|
||||||
|
if (sp)
|
||||||
|
krb5_storage_free(sp);
|
||||||
|
fcc_unlock(context, fd);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variable containing the FILE based credential cache implemention.
|
* Variable containing the FILE based credential cache implemention.
|
||||||
*
|
*
|
||||||
@@ -1018,5 +1054,7 @@ KRB5_LIB_VARIABLE const krb5_cc_ops krb5_fcc_ops = {
|
|||||||
fcc_move,
|
fcc_move,
|
||||||
fcc_get_default_name,
|
fcc_get_default_name,
|
||||||
NULL,
|
NULL,
|
||||||
fcc_lastchange
|
fcc_lastchange,
|
||||||
|
fcc_set_kdc_offset,
|
||||||
|
fcc_get_kdc_offset
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user