* src/passwd.c: Add brackets and parenthesis.

* src/passwd.c: Avoid implicit conversion of pointers to booleans.
	* src/passwd.c: Avoid assignments in comparisons.
This commit is contained in:
nekral-guest 2008-08-31 17:29:51 +00:00
parent 687ae4f4a8
commit 6c5e97e745
2 changed files with 28 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2008-08-29 Nicolas François <nicolas.francois@centraliens.net>
* src/passwd.c: Add brackets and parenthesis.
* src/passwd.c: Avoid implicit conversion of pointers to booleans.
* src/passwd.c: Avoid assignments in comparisons.
2008-08-29 Nicolas François <nicolas.francois@centraliens.net> 2008-08-29 Nicolas François <nicolas.francois@centraliens.net>
* NEWS, src/groupmems.c, man/groupmems.8.xml: Added support for * NEWS, src/groupmems.c, man/groupmems.8.xml: Added support for

View File

@ -195,7 +195,7 @@ static int reuse (const char *pass, const struct passwd *pw)
reason = FascistHistory (pass, pw->pw_uid); reason = FascistHistory (pass, pw->pw_uid);
#endif #endif
if (reason) { if (NULL != reason) {
printf (_("Bad password: %s. "), reason); printf (_("Bad password: %s. "), reason);
return 1; return 1;
} }
@ -229,8 +229,10 @@ static int new_password (const struct passwd *pw)
*/ */
if (!amroot && crypt_passwd[0]) { if (!amroot && crypt_passwd[0]) {
if (!(clear = getpass (_("Old password: ")))) clear = getpass (_("Old password: "));
if (NULL == clear) {
return -1; return -1;
}
cipher = pw_encrypt (clear, crypt_passwd); cipher = pw_encrypt (clear, crypt_passwd);
if (strcmp (cipher, crypt_passwd) != 0) { if (strcmp (cipher, crypt_passwd) != 0) {
@ -256,19 +258,21 @@ static int new_password (const struct passwd *pw)
* for initial login passwords. * for initial login passwords.
*/ */
if ((method = getdef_str ("ENCRYPT_METHOD")) == NULL) { if ((method = getdef_str ("ENCRYPT_METHOD")) == NULL) {
if (!getdef_bool ("MD5_CRYPT_ENAB")) if (!getdef_bool ("MD5_CRYPT_ENAB")) {
pass_max_len = getdef_num ("PASS_MAX_LEN", 8); pass_max_len = getdef_num ("PASS_MAX_LEN", 8);
}
} else { } else {
if ( !strcmp (method, "MD5") if ( (strcmp (method, "MD5") == 0)
#ifdef USE_SHA_CRYPT #ifdef USE_SHA_CRYPT
|| !strcmp (method, "SHA256") || (strcmp (method, "SHA256") == 0)
|| !strcmp (method, "SHA512") || (strcmp (method, "SHA512") == 0)
#endif #endif
) ) {
pass_max_len = -1; pass_max_len = -1;
else } else {
pass_max_len = getdef_num ("PASS_MAX_LEN", 8); pass_max_len = getdef_num ("PASS_MAX_LEN", 8);
} }
}
if (!qflg) { if (!qflg) {
if (pass_max_len == -1) { if (pass_max_len == -1) {
printf (_( printf (_(
@ -285,12 +289,14 @@ static int new_password (const struct passwd *pw)
warned = 0; warned = 0;
for (i = getdef_num ("PASS_CHANGE_TRIES", 5); i > 0; i--) { for (i = getdef_num ("PASS_CHANGE_TRIES", 5); i > 0; i--) {
if (!(cp = getpass (_("New password: ")))) { cp = getpass (_("New password: "));
if (NULL == cp) {
memzero (orig, sizeof orig); memzero (orig, sizeof orig);
return -1; return -1;
} }
if (warned && strcmp (pass, cp) != 0) if (warned && (strcmp (pass, cp) != 0)) {
warned = 0; warned = 0;
}
STRFCPY (pass, cp); STRFCPY (pass, cp);
strzero (cp); strzero (cp);
@ -310,13 +316,14 @@ static int new_password (const struct passwd *pw)
warned++; warned++;
continue; continue;
} }
if (!(cp = getpass (_("Re-enter new password: ")))) { cp = getpass (_("Re-enter new password: "));
if (NULL == cp) {
memzero (orig, sizeof orig); memzero (orig, sizeof orig);
return -1; return -1;
} }
if (strcmp (cp, pass)) if (strcmp (cp, pass) != 0) {
fputs (_("They don't match; try again.\n"), stderr); fputs (_("They don't match; try again.\n"), stderr);
else { } else {
strzero (cp); strzero (cp);
break; break;
} }
@ -358,8 +365,9 @@ static void check_password (const struct passwd *pw, const struct spwd *sp)
* If not expired and the "change only if expired" option (idea from * If not expired and the "change only if expired" option (idea from
* PAM) was specified, do nothing. --marekm * PAM) was specified, do nothing. --marekm
*/ */
if (kflg && exp_status == 0) if (kflg && (0 == exp_status)) {
exit (E_SUCCESS); exit (E_SUCCESS);
}
/* /*
* Root can change any password any time. * Root can change any password any time.