From 5ea0612ca9ee684b8ae1c5287db2346509ddf5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 10 Jul 2006 14:47:45 +0000 Subject: [PATCH] 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 --- kuser/kinit.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kuser/kinit.c b/kuser/kinit.c index 2f91ea2df..c6b6e55da 100644 --- a/kuser/kinit.c +++ b/kuser/kinit.c @@ -449,11 +449,19 @@ get_new_tickets(krb5_context context, if (password_file) { 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) krb5_errx(context, 1, - "failed to read password from file %s", password_file); - fclose(f); + "Failed to read password from file %s", password_file); + if (f != stdin) + fclose(f); passwd[strcspn(passwd, "\n")] = '\0'; }