dovecot-2.1: doveadm pw: Use i_error()/i_fatal() instead of fpri...

dovecot at dovecot.org dovecot at dovecot.org
Sun Feb 12 19:20:10 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/7c36dea5605a
changeset: 14136:7c36dea5605a
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Feb 12 19:20:03 2012 +0200
description:
doveadm pw: Use i_error()/i_fatal() instead of fprintf(stderr)

diffstat:

 src/doveadm/doveadm-pw.c |  26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)

diffs (56 lines):

diff -r ccad37bc242f -r 7c36dea5605a src/doveadm/doveadm-pw.c
--- a/src/doveadm/doveadm-pw.c	Sun Feb 12 19:16:34 2012 +0200
+++ b/src/doveadm/doveadm-pw.c	Sun Feb 12 19:20:03 2012 +0200
@@ -87,17 +87,15 @@
 		plaintext = t_askpass("Enter new password: ");
 		check = t_askpass("Retype new password: ");
 		if (strcmp(plaintext, check) != 0) {
-			fprintf(stderr, "Passwords don't match!\n");
+			i_error("Passwords don't match!");
 			if (--lives == 0)
 				exit(1);
 			plaintext = NULL;
 		}
 	}
 
-	if (!password_generate_encoded(plaintext, user, scheme, &hash)) {
-		fprintf(stderr, "Unknown scheme: %s\n", scheme);
-		exit(1);
-	}
+	if (!password_generate_encoded(plaintext, user, scheme, &hash))
+		i_fatal("Unknown scheme: %s", scheme);
 	if (reverse_verify) {
 		const unsigned char *raw_password;
 		size_t size;
@@ -105,25 +103,19 @@
 
 		if (test_hash != NULL) {
 			scheme = password_get_scheme(&test_hash);
-			if (scheme == NULL) {
-				fprintf(stderr, "Missing {scheme} prefix from hash\n");
-				exit(2);
-			}
+			if (scheme == NULL)
+				i_fatal("Missing {scheme} prefix from hash");
 			hash = test_hash;
 		}
 
 		if (password_decode(hash, scheme, &raw_password, &size,
-				    &error) <= 0) {
-			fprintf(stderr, "reverse decode check failed: %s\n",
-				error);
-			exit(2);
-		}
+				    &error) <= 0)
+			i_fatal("reverse decode check failed: %s", error);
 
 		if (password_verify(plaintext, user, scheme,
 				    raw_password, size, &error) <= 0) {
-			fprintf(stderr,
-				"reverse password verification check failed: %s\n", error);
-			exit(2);
+			i_fatal("reverse password verification check failed: %s",
+				error);
 		}
 
 		printf("{%s}%s (verified)\n", scheme, hash);


More information about the dovecot-cvs mailing list