noman / rpms / passwd

Forked from rpms/passwd 4 years ago
Clone

Blame SOURCES/passwd-0.79-incorrect-S-report.patch

088265
diff --git a/libuser.c b/libuser.c
088265
index 7a36520..06c6200 100644
088265
--- a/libuser.c
088265
+++ b/libuser.c
088265
@@ -233,6 +233,7 @@ pwdb_display_status(const char *username)
088265
 	struct lu_ent *ent;
088265
 	struct lu_error *error = NULL;
088265
 	char *current;
088265
+	char *current_user;
088265
 	char *realname;
088265
 	const char *msg;
088265
 	int shadow = 1;
088265
@@ -256,9 +257,10 @@ pwdb_display_status(const char *username)
088265
 			goto bail;
088265
 		}
088265
 		current = lu_ent_get_first_value_strdup(ent, LU_SHADOWPASSWORD);
088265
+		current_user = lu_ent_get_first_value_strdup(ent, LU_USERPASSWORD);
088265
 		if (current == NULL) {
088265
 			shadow = 0;
088265
-			current = lu_ent_get_first_value_strdup(ent, LU_USERPASSWORD);
088265
+			current = current_user;
088265
 		} else {
088265
 			sp_lstchg = (time_t) ent_value_int64(ent, LU_SHADOWLASTCHANGE);
088265
 			sp_min = ent_value_int64(ent, LU_SHADOWMIN);
088265
@@ -298,6 +300,13 @@ pwdb_display_status(const char *username)
088265
 				msg = _("Password set, DES crypt.");
088265
 			}
088265
 			if (shadow) {
088265
+				if (status[0] != 'N' && current_user && strlen(current_user) == 0) {
088265
+					fprintf(stderr, "%s: %s\n", progname,
088265
+						_("There is a password information set in /etc/shadow,"
088265
+						  " but the password field in /etc/passwd is empty."));
088265
+					msg = _("Empty password.");
088265
+					status = "NP";
088265
+				}
088265
 				sp_lstchg = sp_lstchg * 24L * 3600L;
088265
 				localtime_r(&sp_lstchg, &tm;;
088265
 				strftime(date, sizeof(date), "%Y-%m-%d", &tm;;
088265
@@ -307,6 +316,9 @@ pwdb_display_status(const char *username)
088265
 				printf("%s %s (%s)\n", realname, status, msg);
088265
 			}
088265
 			g_free(current);
088265
+			if (shadow && current_user) {
088265
+				g_free(current_user);
088265
+			}
088265
 		} else {
088265
 			printf(_("No password set.\n"));
088265
 		}