Allow batch mode in kinit with password file

This commit is contained in:
Nicolas Williams
2013-08-01 20:13:47 -05:00
parent 13c8a2c212
commit 8ce9a1d686

View File

@@ -363,12 +363,16 @@ get_new_tickets(krb5_context context,
krb5_ccache tempccache = NULL; krb5_ccache tempccache = NULL;
krb5_init_creds_context ctx = NULL; krb5_init_creds_context ctx = NULL;
krb5_get_init_creds_opt *opt = NULL; krb5_get_init_creds_opt *opt = NULL;
krb5_prompter_fct prompter = krb5_prompter_posix;
#ifndef NO_NTLM #ifndef NO_NTLM
struct ntlm_buf ntlmkey; struct ntlm_buf ntlmkey;
memset(&ntlmkey, 0, sizeof(ntlmkey)); memset(&ntlmkey, 0, sizeof(ntlmkey));
#endif #endif
passwd[0] = '\0'; passwd[0] = '\0';
if (!interactive)
prompter = NULL;
if (password_file) { if (password_file) {
FILE *f; FILE *f;
@@ -454,7 +458,7 @@ get_new_tickets(krb5_context context,
NULL, NULL,
pk_use_enckey ? 2 : 0 | pk_use_enckey ? 2 : 0 |
anonymous_flag ? 4 : 0, anonymous_flag ? 4 : 0,
krb5_prompter_posix, prompter,
NULL, NULL,
passwd); passwd);
if (ret) { if (ret) {
@@ -509,7 +513,7 @@ get_new_tickets(krb5_context context,
etype_str.num_strings); 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) { if (ret) {
krb5_warn(context, ret, "krb5_init_creds_init"); krb5_warn(context, ret, "krb5_init_creds_init");
goto out; goto out;
@@ -547,7 +551,7 @@ get_new_tickets(krb5_context context,
} }
} else if (pk_user_id || ent_user_id || anonymous_flag) { } else if (pk_user_id || ent_user_id || anonymous_flag) {
} else if (!interactive) { } else if (!interactive && passwd[0] == '\0') {
static int already_warned = 0; static int already_warned = 0;
if (!already_warned) if (!already_warned)