fix incorrect -S output
There is a password information set in /etc/shadow,but the password field in /etc/passwd is empty. Signed-off-by: xueyamao <xueyamao@kylinos.cn>
This commit is contained in:
parent
852f752d43
commit
d445a991da
65
fix-incorrect-S-output.patch
Normal file
65
fix-incorrect-S-output.patch
Normal file
@ -0,0 +1,65 @@
|
||||
From c023fa6c17c083caefe4ef41627556c3232fea08 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Kucera <jkucera@redhat.com>
|
||||
Date: Dec 03 2019 13:41:36 +0000
|
||||
https://pagure.io/passwd/c/ff60631b73e48ab28fc984cd8f8206d18e369b82.patch
|
||||
|
||||
Subject: [PATCH] fix incorrect -S output
|
||||
|
||||
Fix incorrect -S output when password field in /etc/passwd is empty
|
||||
but the password information in /etc/shadow is set.
|
||||
|
||||
---
|
||||
libuser.c | 14 +++++++++++++-
|
||||
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libuser.c b/libuser.c
|
||||
index f5bedc1..4ccd74c 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);
|
||||
@@ -313,6 +315,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);
|
||||
@@ -322,6 +331,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"));
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
Name: passwd
|
||||
Version: 0.80
|
||||
Release: 9
|
||||
Release: 10
|
||||
Summary: An implementation of the password setting/changing utility through PAM and libuser libraries
|
||||
License: BSD or GPL+
|
||||
URL: https://pagure.io/passwd
|
||||
Source0: https://releases.pagure.org/passwd/passwd-%{version}.autotoolized.tar.bz2
|
||||
|
||||
Patch1: fix-incorrect-S-output.patch
|
||||
Patch9000: add-sm3-crypt-support.patch
|
||||
|
||||
BuildRequires:libselinux-devel >= 2.1.6-3 gcc glib2-devel, libuser-devel, pam-devel, libuser >= 0.53-1
|
||||
@ -57,6 +58,12 @@ make check
|
||||
%{_mandir}/man1/*.gz
|
||||
|
||||
%changelog
|
||||
* Mon Aug 15 2022 xueyamao <xueyamao@kylinos.cn> - 0.80-10
|
||||
- Type:defect
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix incorrect -S output
|
||||
|
||||
* Thu Oct 28 2021 lujie <lujie42@huawei.com> - 0.80-9
|
||||
- Type:requirement
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user