Fix manpage and incorrect -S output

Resolves: #1612221, #1740166
This commit is contained in:
Jiri Kucera 2019-12-04 15:45:04 +01:00
parent 4862706116
commit 1f800c5031
3 changed files with 106 additions and 1 deletions

View File

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

48
passwd-0.80-manpage.patch Normal file
View File

@ -0,0 +1,48 @@
diff --git a/man/passwd.1 b/man/passwd.1
index 1bc2a6e..9727b88 100644
--- a/man/passwd.1
+++ b/man/passwd.1
@@ -40,7 +40,7 @@
passwd \- update user's authentication tokens
.SH SYNOPSIS
-.B passwd [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w warndays] [-i inactivedays] [-S] [--stdin] [username]
+.B passwd [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w warndays] [-i inactivedays] [-S] [--stdin] [-?] [--usage] [username]
.sp 2
.SH DESCRIPTION
The passwd utility is used to update user's authentication token(s).
@@ -82,7 +82,7 @@ function correctly.
.SH OPTIONS
.TP
-\fB\-k\fR, \fB\-\-keep\fR
+\fB\-k\fR, \fB\-\-keep\-tokens\fR
The option
.B \-k
is used to indicate that the update should only be for expired
@@ -158,8 +158,8 @@ root only.
This will output a short information about the status of the password
for a given account. The status information consists of 7 fields. The
first field is the user's login name. The second field indicates if the
-user account has a locked password (L), has no password (NP), or has a
-usable password (P). The third field gives the date of the last password
+user account has a locked password (LK), has no password (NP), or has a
+usable password (PS). The third field gives the date of the last password
change. The next four fields are the minimum age, maximum age, warning
period, and inactivity period for the password. These ages are expressed
in days.
@@ -174,6 +174,14 @@ from the real date of the last password change by ±1 day.
.sp
This option is available to root only.
+.TP
+\fB\-?\fR, \fB\-\-help\fR
+Print a help message and exit.
+
+.TP
+\fB\-\-usage\fR
+Print a short usage message and exit.
+
.SH "Remember the following two principles"
.IP \fBProtect\ your\ password.\fR

View File

@ -7,10 +7,12 @@
Summary: An utility for setting or changing passwords using PAM
Name: passwd
Version: 0.80
Release: 6%{?dist}
Release: 7%{?dist}
License: BSD or GPL+
URL: https://pagure.io/passwd
Source: https://releases.pagure.org/passwd/passwd-%{version}.autotoolized.tar.bz2
Patch0: passwd-0.80-manpage.patch
Patch1: passwd-0.80-S-output.patch
Requires: pam >= 1.0.90, /etc/pam.d/system-auth
%if %{WITH_SELINUX}
Requires: libselinux >= 2.1.6-3
@ -32,6 +34,8 @@ Modules) library.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1 -b .manpage
%patch1 -p1 -b .S-output
%build
%configure \
@ -70,6 +74,11 @@ done
%{_mandir}/man1/passwd.1*
%changelog
* Wed Dec 04 2019 Jiri Kucera <jkucera@redhat.com> - 0.80-7
- fix inconsistencies in manpage
- fix incorrect -S output
Resolves: #1612221, #1740166
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.80-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild