summaryrefslogtreecommitdiff
path: root/usr.bin/passwd
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2021-08-28 06:46:50 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2021-08-28 06:46:50 +0000
commitfdbe8d15bb28ced371ff5d9dc1006a645eb53528 (patch)
tree9ccf05ac5e51d39d7cb9c035b2c73ffe94356963 /usr.bin/passwd
parent63d1d60cdc7e3c94a503ec7f05a4d331ca46cbaf (diff)
use stderr for printing error and informational messages
this makes it easier to parse what passwd(1) is doing if spawned from a GUI ok millert@
Diffstat (limited to 'usr.bin/passwd')
-rw-r--r--usr.bin/passwd/local_passwd.c14
-rw-r--r--usr.bin/passwd/pwd_check.c10
2 files changed, 12 insertions, 12 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c
index 97720018337..9735b346b39 100644
--- a/usr.bin/passwd/local_passwd.c
+++ b/usr.bin/passwd/local_passwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local_passwd.c,v 1.59 2021/07/12 15:09:20 beck Exp $ */
+/* $OpenBSD: local_passwd.c,v 1.60 2021/08/28 06:46:49 robert Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -176,14 +176,14 @@ getnewpasswd(struct passwd *pw, login_cap_t *lc, int authenticated)
savequit = signal(SIGQUIT, kbintr);
if (!authenticated) {
- (void)printf("Changing password for %s.\n", pw->pw_name);
+ fprintf(stderr, "Changing password for %s.\n", pw->pw_name);
if (uid != 0 && pw->pw_passwd[0] != '\0') {
char oldpass[1024];
p = readpassphrase("Old password:", oldpass,
sizeof(oldpass), RPP_ECHO_OFF);
if (p == NULL || *p == '\0') {
- (void)printf("%s\n", UNCHANGED_MSG);
+ fprintf(stderr, "%s\n", UNCHANGED_MSG);
pw_abort();
exit(p == NULL ? 1 : 0);
}
@@ -204,12 +204,12 @@ getnewpasswd(struct passwd *pw, login_cap_t *lc, int authenticated)
p = readpassphrase("New password:", newpass, sizeof(newpass),
RPP_ECHO_OFF);
if (p == NULL || *p == '\0') {
- (void)printf("%s\n", UNCHANGED_MSG);
+ fprintf(stderr, "%s\n", UNCHANGED_MSG);
pw_abort();
exit(p == NULL ? 1 : 0);
}
if (strcmp(p, "s/key") == 0) {
- printf("That password collides with a system feature. Choose another.\n");
+ fprintf(stderr, "That password collides with a system feature. Choose another.\n");
continue;
}
@@ -222,7 +222,7 @@ getnewpasswd(struct passwd *pw, login_cap_t *lc, int authenticated)
explicit_bzero(repeat, sizeof(repeat));
break;
}
- (void)printf("Mismatch; try again, EOF to quit.\n");
+ fprintf(stderr, "Mismatch; try again, EOF to quit.\n");
explicit_bzero(repeat, sizeof(repeat));
explicit_bzero(newpass, sizeof(newpass));
}
@@ -232,7 +232,7 @@ getnewpasswd(struct passwd *pw, login_cap_t *lc, int authenticated)
pref = login_getcapstr(lc, "localcipher", NULL, NULL);
if (crypt_newhash(newpass, pref, hash, sizeof(hash)) != 0) {
- (void)printf("Couldn't generate hash.\n");
+ fprintf(stderr, "Couldn't generate hash.\n");
explicit_bzero(newpass, sizeof(newpass));
pw_error(NULL, 0, 0);
}
diff --git a/usr.bin/passwd/pwd_check.c b/usr.bin/passwd/pwd_check.c
index cfdd1f65ed2..a1b4eca739e 100644
--- a/usr.bin/passwd/pwd_check.c
+++ b/usr.bin/passwd/pwd_check.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwd_check.c,v 1.16 2017/08/21 21:41:13 deraadt Exp $ */
+/* $OpenBSD: pwd_check.c,v 1.17 2021/08/28 06:46:49 robert Exp $ */
/*
* Copyright 2000 Niels Provos <provos@citi.umich.edu>
@@ -97,7 +97,7 @@ pwd_check(login_cap_t *lc, char *password)
min_len = (int)login_getcapnum(lc, "minpasswordlen", 6, 6);
if (min_len > 0 && strlen(password) < min_len) {
- printf("Please enter a longer password.\n");
+ fprintf(stderr, "Please enter a longer password.\n");
return (0);
}
@@ -146,7 +146,7 @@ pwd_check(login_cap_t *lc, char *password)
ret = regexec(&rgx, password, 0, NULL, 0);
regfree(&rgx);
if (ret == 0) {
- printf("%s\n", patterns[i].response);
+ fprintf(stderr, "%s\n", patterns[i].response);
exit(1);
}
}
@@ -194,8 +194,8 @@ pwd_check(login_cap_t *lc, char *password)
out:
free(checker);
- printf("Please use a different password. Unusual capitalization,\n");
- printf("control characters, or digits are suggested.\n");
+ fprintf(stderr, "Please use a different password. Unusual capitalization,\n");
+ fprintf(stderr, "control characters, or digits are suggested.\n");
return (0);
}