|
|
e58a44 |
From f181bf6ee4ff66489895a8c543521cbec253d1f9 Mon Sep 17 00:00:00 2001
|
|
|
e58a44 |
From: Greg Hudson <ghudson@mit.edu>
|
|
|
e58a44 |
Date: Wed, 17 May 2017 15:14:15 -0400
|
|
|
e58a44 |
Subject: [PATCH] Use krb5_timestamp where appropriate
|
|
|
e58a44 |
|
|
|
e58a44 |
Where krb5_int32 is used to hold the number of seconds since the
|
|
|
e58a44 |
epoch, use krb5_timestamp instead.
|
|
|
e58a44 |
|
|
|
e58a44 |
(cherry picked from commit ae25f6ec5558140a546db34fea389412d81c0631)
|
|
|
e58a44 |
---
|
|
|
e58a44 |
src/clients/klist/klist.c | 2 +-
|
|
|
e58a44 |
src/include/k5-int.h | 2 +-
|
|
|
e58a44 |
src/kadmin/server/misc.c | 2 +-
|
|
|
e58a44 |
src/kdc/dispatch.c | 4 ++--
|
|
|
e58a44 |
src/lib/kadm5/srv/server_acl.c | 2 +-
|
|
|
e58a44 |
src/lib/kadm5/srv/server_kdb.c | 2 +-
|
|
|
e58a44 |
src/lib/kadm5/srv/svr_principal.c | 10 +++++-----
|
|
|
e58a44 |
src/lib/krb5/krb/gen_save_subkey.c | 3 ++-
|
|
|
e58a44 |
src/lib/krb5/krb/get_in_tkt.c | 2 +-
|
|
|
e58a44 |
src/lib/krb5/krb/init_ctx.c | 3 ++-
|
|
|
e58a44 |
src/lib/krb5/os/c_ustime.c | 7 +++++--
|
|
|
e58a44 |
src/lib/krb5/os/toffset.c | 3 ++-
|
|
|
e58a44 |
src/lib/krb5/os/trace.c | 3 ++-
|
|
|
e58a44 |
src/lib/krb5/os/ustime.c | 3 ++-
|
|
|
e58a44 |
src/lib/krb5/rcache/rc_dfl.c | 10 +++++-----
|
|
|
e58a44 |
src/tests/create/kdb5_mkdums.c | 2 +-
|
|
|
e58a44 |
16 files changed, 34 insertions(+), 26 deletions(-)
|
|
|
e58a44 |
|
|
|
e58a44 |
diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c
|
|
|
e58a44 |
index ffeecc394..4334415be 100644
|
|
|
e58a44 |
--- a/src/clients/klist/klist.c
|
|
|
e58a44 |
+++ b/src/clients/klist/klist.c
|
|
|
e58a44 |
@@ -56,7 +56,7 @@ int show_adtype = 0, show_all = 0, list_all = 0, use_client_keytab = 0;
|
|
|
e58a44 |
int show_config = 0;
|
|
|
e58a44 |
char *defname;
|
|
|
e58a44 |
char *progname;
|
|
|
e58a44 |
-krb5_int32 now;
|
|
|
e58a44 |
+krb5_timestamp now;
|
|
|
e58a44 |
unsigned int timestamp_width;
|
|
|
e58a44 |
|
|
|
e58a44 |
krb5_context kcontext;
|
|
|
e58a44 |
diff --git a/src/include/k5-int.h b/src/include/k5-int.h
|
|
|
e58a44 |
index 82ee20760..ed9c7bf75 100644
|
|
|
e58a44 |
--- a/src/include/k5-int.h
|
|
|
e58a44 |
+++ b/src/include/k5-int.h
|
|
|
e58a44 |
@@ -721,7 +721,7 @@ krb5_error_code krb5int_c_copy_keyblock_contents(krb5_context context,
|
|
|
e58a44 |
const krb5_keyblock *from,
|
|
|
e58a44 |
krb5_keyblock *to);
|
|
|
e58a44 |
|
|
|
e58a44 |
-krb5_error_code krb5_crypto_us_timeofday(krb5_int32 *, krb5_int32 *);
|
|
|
e58a44 |
+krb5_error_code krb5_crypto_us_timeofday(krb5_timestamp *, krb5_int32 *);
|
|
|
e58a44 |
|
|
|
e58a44 |
/*
|
|
|
e58a44 |
* End "los-proto.h"
|
|
|
e58a44 |
diff --git a/src/kadmin/server/misc.c b/src/kadmin/server/misc.c
|
|
|
e58a44 |
index a75b65a26..ba672d714 100644
|
|
|
e58a44 |
--- a/src/kadmin/server/misc.c
|
|
|
e58a44 |
+++ b/src/kadmin/server/misc.c
|
|
|
e58a44 |
@@ -159,7 +159,7 @@ kadm5_ret_t
|
|
|
e58a44 |
check_min_life(void *server_handle, krb5_principal principal,
|
|
|
e58a44 |
char *msg_ret, unsigned int msg_len)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
kadm5_ret_t ret;
|
|
|
e58a44 |
kadm5_policy_ent_rec pol;
|
|
|
e58a44 |
kadm5_principal_ent_rec princ;
|
|
|
e58a44 |
diff --git a/src/kdc/dispatch.c b/src/kdc/dispatch.c
|
|
|
e58a44 |
index 16a35d2be..4ecc23481 100644
|
|
|
e58a44 |
--- a/src/kdc/dispatch.c
|
|
|
e58a44 |
+++ b/src/kdc/dispatch.c
|
|
|
e58a44 |
@@ -94,8 +94,8 @@ static void
|
|
|
e58a44 |
reseed_random(krb5_context kdc_err_context)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
- krb5_int32 now, now_usec;
|
|
|
e58a44 |
- krb5_int32 usec_difference;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
+ krb5_int32 now_usec, usec_difference;
|
|
|
e58a44 |
krb5_data data;
|
|
|
e58a44 |
|
|
|
e58a44 |
retval = krb5_crypto_us_timeofday(&now, &now_usec);
|
|
|
e58a44 |
diff --git a/src/lib/kadm5/srv/server_acl.c b/src/lib/kadm5/srv/server_acl.c
|
|
|
e58a44 |
index 656dddff5..c2cf69169 100644
|
|
|
e58a44 |
--- a/src/lib/kadm5/srv/server_acl.c
|
|
|
e58a44 |
+++ b/src/lib/kadm5/srv/server_acl.c
|
|
|
e58a44 |
@@ -375,7 +375,7 @@ kadm5int_acl_impose_restrictions(kcontext, recp, maskp, rp)
|
|
|
e58a44 |
restriction_t *rp;
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_error_code code;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
|
|
|
e58a44 |
DPRINT(DEBUG_CALLS, acl_debug_level,
|
|
|
e58a44 |
("* kadm5int_acl_impose_restrictions(..., *maskp=0x%08x, rp=0x%08x)\n",
|
|
|
e58a44 |
diff --git a/src/lib/kadm5/srv/server_kdb.c b/src/lib/kadm5/srv/server_kdb.c
|
|
|
e58a44 |
index 612553ba3..f4b8aef2b 100644
|
|
|
e58a44 |
--- a/src/lib/kadm5/srv/server_kdb.c
|
|
|
e58a44 |
+++ b/src/lib/kadm5/srv/server_kdb.c
|
|
|
e58a44 |
@@ -365,7 +365,7 @@ kdb_put_entry(kadm5_server_handle_t handle,
|
|
|
e58a44 |
krb5_db_entry *kdb, osa_princ_ent_rec *adb)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_error_code ret;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
XDR xdrs;
|
|
|
e58a44 |
krb5_tl_data tl_data;
|
|
|
e58a44 |
|
|
|
e58a44 |
diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c
|
|
|
e58a44 |
index f4a9a2ad2..0d4f0a632 100644
|
|
|
e58a44 |
--- a/src/lib/kadm5/srv/svr_principal.c
|
|
|
e58a44 |
+++ b/src/lib/kadm5/srv/svr_principal.c
|
|
|
e58a44 |
@@ -296,7 +296,7 @@ kadm5_create_principal_3(void *server_handle,
|
|
|
e58a44 |
osa_princ_ent_rec adb;
|
|
|
e58a44 |
kadm5_policy_ent_rec polent;
|
|
|
e58a44 |
krb5_boolean have_polent = FALSE;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
krb5_tl_data *tl_data_tail;
|
|
|
e58a44 |
unsigned int ret;
|
|
|
e58a44 |
kadm5_server_handle_t handle = server_handle;
|
|
|
e58a44 |
@@ -1322,7 +1322,7 @@ kadm5_chpass_principal_3(void *server_handle,
|
|
|
e58a44 |
int n_ks_tuple, krb5_key_salt_tuple *ks_tuple,
|
|
|
e58a44 |
char *password)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
kadm5_policy_ent_rec pol;
|
|
|
e58a44 |
osa_princ_ent_rec adb;
|
|
|
e58a44 |
krb5_db_entry *kdb;
|
|
|
e58a44 |
@@ -1544,7 +1544,7 @@ kadm5_randkey_principal_3(void *server_handle,
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_db_entry *kdb;
|
|
|
e58a44 |
osa_princ_ent_rec adb;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
kadm5_policy_ent_rec pol;
|
|
|
e58a44 |
int ret, last_pwd, n_new_keys;
|
|
|
e58a44 |
krb5_boolean have_pol = FALSE;
|
|
|
e58a44 |
@@ -1686,7 +1686,7 @@ kadm5_setv4key_principal(void *server_handle,
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_db_entry *kdb;
|
|
|
e58a44 |
osa_princ_ent_rec adb;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
kadm5_policy_ent_rec pol;
|
|
|
e58a44 |
krb5_keysalt keysalt;
|
|
|
e58a44 |
int i, kvno, ret;
|
|
|
e58a44 |
@@ -1888,7 +1888,7 @@ kadm5_setkey_principal_4(void *server_handle, krb5_principal principal,
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_db_entry *kdb;
|
|
|
e58a44 |
osa_princ_ent_rec adb;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
kadm5_policy_ent_rec pol;
|
|
|
e58a44 |
krb5_key_data *new_key_data = NULL;
|
|
|
e58a44 |
int i, j, ret, n_new_key_data = 0;
|
|
|
e58a44 |
diff --git a/src/lib/krb5/krb/gen_save_subkey.c b/src/lib/krb5/krb/gen_save_subkey.c
|
|
|
e58a44 |
index 61f36aa36..bc2c46d30 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/krb/gen_save_subkey.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/krb/gen_save_subkey.c
|
|
|
e58a44 |
@@ -38,7 +38,8 @@ k5_generate_and_save_subkey(krb5_context context,
|
|
|
e58a44 |
to guarantee randomness, but to make it less likely that multiple
|
|
|
e58a44 |
sessions could pick the same subkey. */
|
|
|
e58a44 |
struct {
|
|
|
e58a44 |
- krb5_int32 sec, usec;
|
|
|
e58a44 |
+ krb5_timestamp sec;
|
|
|
e58a44 |
+ krb5_int32 usec;
|
|
|
e58a44 |
} rnd_data;
|
|
|
e58a44 |
krb5_data d;
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c
|
|
|
e58a44 |
index 40aba1905..7178bd87b 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/krb/get_in_tkt.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/krb/get_in_tkt.c
|
|
|
e58a44 |
@@ -1788,7 +1788,7 @@ k5_populate_gic_opt(krb5_context context, krb5_get_init_creds_opt **out,
|
|
|
e58a44 |
krb5_creds *creds)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
int i;
|
|
|
e58a44 |
- krb5_int32 starttime;
|
|
|
e58a44 |
+ krb5_timestamp starttime;
|
|
|
e58a44 |
krb5_deltat lifetime;
|
|
|
e58a44 |
krb5_get_init_creds_opt *opt;
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c
|
|
|
e58a44 |
index cf226fdba..4246c5dd2 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/krb/init_ctx.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/krb/init_ctx.c
|
|
|
e58a44 |
@@ -139,7 +139,8 @@ krb5_init_context_profile(profile_t profile, krb5_flags flags,
|
|
|
e58a44 |
krb5_context ctx = 0;
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
struct {
|
|
|
e58a44 |
- krb5_int32 now, now_usec;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
+ krb5_int32 now_usec;
|
|
|
e58a44 |
long pid;
|
|
|
e58a44 |
} seed_data;
|
|
|
e58a44 |
krb5_data seed;
|
|
|
e58a44 |
diff --git a/src/lib/krb5/os/c_ustime.c b/src/lib/krb5/os/c_ustime.c
|
|
|
e58a44 |
index 68fb381f4..f69f2ea4c 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/os/c_ustime.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/os/c_ustime.c
|
|
|
e58a44 |
@@ -29,7 +29,10 @@
|
|
|
e58a44 |
|
|
|
e58a44 |
k5_mutex_t krb5int_us_time_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
|
|
|
e58a44 |
|
|
|
e58a44 |
-struct time_now { krb5_int32 sec, usec; };
|
|
|
e58a44 |
+struct time_now {
|
|
|
e58a44 |
+ krb5_timestamp sec;
|
|
|
e58a44 |
+ krb5_int32 usec;
|
|
|
e58a44 |
+};
|
|
|
e58a44 |
|
|
|
e58a44 |
#if defined(_WIN32)
|
|
|
e58a44 |
|
|
|
e58a44 |
@@ -73,7 +76,7 @@ get_time_now(struct time_now *n)
|
|
|
e58a44 |
static struct time_now last_time;
|
|
|
e58a44 |
|
|
|
e58a44 |
krb5_error_code
|
|
|
e58a44 |
-krb5_crypto_us_timeofday(krb5_int32 *seconds, krb5_int32 *microseconds)
|
|
|
e58a44 |
+krb5_crypto_us_timeofday(krb5_timestamp *seconds, krb5_int32 *microseconds)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
struct time_now now;
|
|
|
e58a44 |
krb5_error_code err;
|
|
|
e58a44 |
diff --git a/src/lib/krb5/os/toffset.c b/src/lib/krb5/os/toffset.c
|
|
|
e58a44 |
index 37bc69f49..4bbcdde52 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/os/toffset.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/os/toffset.c
|
|
|
e58a44 |
@@ -40,7 +40,8 @@ krb5_error_code KRB5_CALLCONV
|
|
|
e58a44 |
krb5_set_real_time(krb5_context context, krb5_timestamp seconds, krb5_int32 microseconds)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_os_context os_ctx = &context->os_context;
|
|
|
e58a44 |
- krb5_int32 sec, usec;
|
|
|
e58a44 |
+ krb5_timestamp sec;
|
|
|
e58a44 |
+ krb5_int32 usec;
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
|
|
|
e58a44 |
retval = krb5_crypto_us_timeofday(&sec, &usec);
|
|
|
e58a44 |
diff --git a/src/lib/krb5/os/trace.c b/src/lib/krb5/os/trace.c
|
|
|
e58a44 |
index 74c315c90..8750b7650 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/os/trace.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/os/trace.c
|
|
|
e58a44 |
@@ -340,7 +340,8 @@ krb5int_trace(krb5_context context, const char *fmt, ...)
|
|
|
e58a44 |
va_list ap;
|
|
|
e58a44 |
krb5_trace_info info;
|
|
|
e58a44 |
char *str = NULL, *msg = NULL;
|
|
|
e58a44 |
- krb5_int32 sec, usec;
|
|
|
e58a44 |
+ krb5_timestamp sec;
|
|
|
e58a44 |
+ krb5_int32 usec;
|
|
|
e58a44 |
|
|
|
e58a44 |
if (context == NULL || context->trace_callback == NULL)
|
|
|
e58a44 |
return;
|
|
|
e58a44 |
diff --git a/src/lib/krb5/os/ustime.c b/src/lib/krb5/os/ustime.c
|
|
|
e58a44 |
index 1c1b571eb..a80fdf68c 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/os/ustime.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/os/ustime.c
|
|
|
e58a44 |
@@ -40,7 +40,8 @@ krb5_error_code
|
|
|
e58a44 |
k5_time_with_offset(krb5_timestamp offset, krb5_int32 offset_usec,
|
|
|
e58a44 |
krb5_timestamp *time_out, krb5_int32 *usec_out)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
- krb5_int32 sec, usec;
|
|
|
e58a44 |
+ krb5_timestamp sec;
|
|
|
e58a44 |
+ krb5_int32 usec;
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
|
|
|
e58a44 |
retval = krb5_crypto_us_timeofday(&sec, &usec);
|
|
|
e58a44 |
diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c
|
|
|
e58a44 |
index 6b043844d..41ebf94da 100644
|
|
|
e58a44 |
--- a/src/lib/krb5/rcache/rc_dfl.c
|
|
|
e58a44 |
+++ b/src/lib/krb5/rcache/rc_dfl.c
|
|
|
e58a44 |
@@ -93,7 +93,7 @@ cmp(krb5_donot_replay *old, krb5_donot_replay *new1, krb5_deltat t)
|
|
|
e58a44 |
}
|
|
|
e58a44 |
|
|
|
e58a44 |
static int
|
|
|
e58a44 |
-alive(krb5_int32 mytime, krb5_donot_replay *new1, krb5_deltat t)
|
|
|
e58a44 |
+alive(krb5_timestamp mytime, krb5_donot_replay *new1, krb5_deltat t)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
if (mytime == 0)
|
|
|
e58a44 |
return CMP_HOHUM; /* who cares? */
|
|
|
e58a44 |
@@ -129,7 +129,7 @@ struct authlist
|
|
|
e58a44 |
|
|
|
e58a44 |
static int
|
|
|
e58a44 |
rc_store(krb5_context context, krb5_rcache id, krb5_donot_replay *rep,
|
|
|
e58a44 |
- krb5_int32 now, krb5_boolean fromfile)
|
|
|
e58a44 |
+ krb5_timestamp now, krb5_boolean fromfile)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
struct dfl_data *t = (struct dfl_data *)id->data;
|
|
|
e58a44 |
unsigned int rephash;
|
|
|
e58a44 |
@@ -536,7 +536,7 @@ krb5_rc_dfl_recover_locked(krb5_context context, krb5_rcache id)
|
|
|
e58a44 |
krb5_error_code retval;
|
|
|
e58a44 |
long max_size;
|
|
|
e58a44 |
int expired_entries = 0;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
|
|
|
e58a44 |
if ((retval = krb5_rc_io_open(context, &t->d, t->name))) {
|
|
|
e58a44 |
return retval;
|
|
|
e58a44 |
@@ -706,7 +706,7 @@ krb5_rc_dfl_store(krb5_context context, krb5_rcache id, krb5_donot_replay *rep)
|
|
|
e58a44 |
{
|
|
|
e58a44 |
krb5_error_code ret;
|
|
|
e58a44 |
struct dfl_data *t;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
|
|
|
e58a44 |
ret = krb5_timeofday(context, &now;;
|
|
|
e58a44 |
if (ret)
|
|
|
e58a44 |
@@ -762,7 +762,7 @@ krb5_rc_dfl_expunge_locked(krb5_context context, krb5_rcache id)
|
|
|
e58a44 |
struct authlist **qt;
|
|
|
e58a44 |
struct authlist *r;
|
|
|
e58a44 |
struct authlist *rt;
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
|
|
|
e58a44 |
if (krb5_timestamp(context, &now))
|
|
|
e58a44 |
now = 0;
|
|
|
e58a44 |
diff --git a/src/tests/create/kdb5_mkdums.c b/src/tests/create/kdb5_mkdums.c
|
|
|
e58a44 |
index 622f549f9..7c0666601 100644
|
|
|
e58a44 |
--- a/src/tests/create/kdb5_mkdums.c
|
|
|
e58a44 |
+++ b/src/tests/create/kdb5_mkdums.c
|
|
|
e58a44 |
@@ -247,7 +247,7 @@ add_princ(context, str_newprinc)
|
|
|
e58a44 |
|
|
|
e58a44 |
{
|
|
|
e58a44 |
/* Add mod princ to db entry */
|
|
|
e58a44 |
- krb5_int32 now;
|
|
|
e58a44 |
+ krb5_timestamp now;
|
|
|
e58a44 |
|
|
|
e58a44 |
retval = krb5_timeofday(context, &now;;
|
|
|
e58a44 |
if (retval) {
|