If --password-file gets STDIN, read the password from the standard input.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17823 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -449,11 +449,19 @@ get_new_tickets(krb5_context context,
|
|||||||
if (password_file) {
|
if (password_file) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(password_file, "r");
|
if (strcasecmp("STDIN", password_file) == 0)
|
||||||
|
f = stdin;
|
||||||
|
else
|
||||||
|
f = fopen(password_file, "r");
|
||||||
|
if (f == NULL)
|
||||||
|
krb5_errx(context, 1, "Failed to open the password file %s",
|
||||||
|
password_file);
|
||||||
|
|
||||||
if (fgets(passwd, sizeof(passwd), f) == NULL)
|
if (fgets(passwd, sizeof(passwd), f) == NULL)
|
||||||
krb5_errx(context, 1,
|
krb5_errx(context, 1,
|
||||||
"failed to read password from file %s", password_file);
|
"Failed to read password from file %s", password_file);
|
||||||
fclose(f);
|
if (f != stdin)
|
||||||
|
fclose(f);
|
||||||
passwd[strcspn(passwd, "\n")] = '\0';
|
passwd[strcspn(passwd, "\n")] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user