From 075289025c64774553d4b13f98a95fe7a1782f5c Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 10 Jul 2009 19:20:26 +0000 Subject: [PATCH] Add a new '-W' option to kadmind and kdb5_util create to allow reading weak random numbers on startup, to avoid long delays in testing situations. Use only for testing. Update testing scripts accordingly. ticket: 1233 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22434 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/dbutil/kdb5_create.c | 8 ++++++-- src/kadmin/server/ovsec_kadmd.c | 5 ++++- src/kadmin/testing/scripts/start_servers_local | 2 ++ src/tests/dejagnu/config/default.exp | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/kadmin/dbutil/kdb5_create.c b/src/kadmin/dbutil/kdb5_create.c index e8e489729..3cf84fee0 100644 --- a/src/kadmin/dbutil/kdb5_create.c +++ b/src/kadmin/dbutil/kdb5_create.c @@ -167,8 +167,9 @@ void kdb5_create(argc, argv) krb5_data pwd, seed; kdb_log_context *log_ctx; krb5_kvno mkey_kvno; + int strong_random = 1; - while ((optchar = getopt(argc, argv, "s")) != -1) { + while ((optchar = getopt(argc, argv, "sW")) != -1) { switch(optchar) { case 's': do_stash++; @@ -179,6 +180,9 @@ void kdb5_create(argc, argv) exit(1); } break; + case 'W': + strong_random = 0; + break; case '?': default: usage(); @@ -196,7 +200,7 @@ void kdb5_create(argc, argv) log_ctx = util_context->kdblog_context; printf ("Loading random data\n"); - retval = krb5_c_random_os_entropy (util_context, 1, NULL); + retval = krb5_c_random_os_entropy (util_context, strong_random, NULL); if (retval) { com_err (progname, retval, "Loading random data"); exit_status++; return; diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c index 97d714428..82ce71634 100644 --- a/src/kadmin/server/ovsec_kadmd.c +++ b/src/kadmin/server/ovsec_kadmd.c @@ -222,6 +222,7 @@ int main(int argc, char *argv[]) int db_args_size = 0; char *errmsg; int i; + int strong_random = 1; kdb_log_context *log_ctx; @@ -292,6 +293,8 @@ int main(int argc, char *argv[]) usage(); params.kadmind_port = atoi(*argv); params.mask |= KADM5_CONFIG_KADMIND_PORT; + } else if (strcmp(*argv, "-W") == 0) { + strong_random = 0; } else break; argc--; argv++; @@ -490,7 +493,7 @@ kterr: } krb5_klog_syslog(LOG_INFO, "Seeding random number generator"); - ret = krb5_c_random_os_entropy(context, 1, NULL); + ret = krb5_c_random_os_entropy(context, strong_random, NULL); if (ret) { krb5_klog_syslog(LOG_ERR, "Error getting random seed: %s, aborting", krb5_get_error_message(context, ret)); diff --git a/src/kadmin/testing/scripts/start_servers_local b/src/kadmin/testing/scripts/start_servers_local index 75b55ec19..ec4dab6d9 100755 --- a/src/kadmin/testing/scripts/start_servers_local +++ b/src/kadmin/testing/scripts/start_servers_local @@ -121,6 +121,8 @@ max_s=60 sofar_s=0 timewait_s=300 +ovadm_args=-W + while true; do rm -f $adm_start_file diff --git a/src/tests/dejagnu/config/default.exp b/src/tests/dejagnu/config/default.exp index 107e444b4..d6a600205 100644 --- a/src/tests/dejagnu/config/default.exp +++ b/src/tests/dejagnu/config/default.exp @@ -1224,7 +1224,7 @@ proc setup_kerberos_db { standalone } { } #exec xterm verbose "starting $test" - spawn $KDB5_UTIL -r $REALMNAME create + spawn $KDB5_UTIL -r $REALMNAME create -W expect_after $def_exp_after expect "Enter KDC database master key:" @@ -1775,7 +1775,7 @@ proc start_kerberos_daemons { standalone } { # removed when this is fixed envstack_push setup_kerberos_env kdc - spawn $BINSH -c "exec $KADMIND -r $REALMNAME -nofork 2>>$kadmind_lfile" + spawn $BINSH -c "exec $KADMIND -r $REALMNAME -W -nofork 2>>$kadmind_lfile" envstack_pop set kadmind_pid [exp_pid] set kadmind_spawn_id $spawn_id -- 2.26.2