From 8ce9a1d686bc078dcf7d26559c9145ee86f181e3 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Thu, 1 Aug 2013 20:13:47 -0500 Subject: [PATCH] Allow batch mode in kinit with password file --- kuser/kinit.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kuser/kinit.c b/kuser/kinit.c index 602c31c6e..98a879e2c 100644 --- a/kuser/kinit.c +++ b/kuser/kinit.c @@ -363,12 +363,16 @@ get_new_tickets(krb5_context context, krb5_ccache tempccache = NULL; krb5_init_creds_context ctx = NULL; krb5_get_init_creds_opt *opt = NULL; + krb5_prompter_fct prompter = krb5_prompter_posix; #ifndef NO_NTLM struct ntlm_buf ntlmkey; memset(&ntlmkey, 0, sizeof(ntlmkey)); #endif passwd[0] = '\0'; + if (!interactive) + prompter = NULL; + if (password_file) { FILE *f; @@ -454,7 +458,7 @@ get_new_tickets(krb5_context context, NULL, pk_use_enckey ? 2 : 0 | anonymous_flag ? 4 : 0, - krb5_prompter_posix, + prompter, NULL, passwd); if (ret) { @@ -509,7 +513,7 @@ get_new_tickets(krb5_context context, etype_str.num_strings); } - ret = krb5_init_creds_init(context, principal, krb5_prompter_posix, NULL, start_time, opt, &ctx); + ret = krb5_init_creds_init(context, principal, prompter, NULL, start_time, opt, &ctx); if (ret) { krb5_warn(context, ret, "krb5_init_creds_init"); goto out; @@ -547,7 +551,7 @@ get_new_tickets(krb5_context context, } } else if (pk_user_id || ent_user_id || anonymous_flag) { - } else if (!interactive) { + } else if (!interactive && passwd[0] == '\0') { static int already_warned = 0; if (!already_warned)