Blame SOURCES/0031-chfn-don-t-append-extra-tailing-commas.patch

936174
From 90d4faece26c328c40336a0e02b875515c503e30 Mon Sep 17 00:00:00 2001
936174
From: Karel Zak <kzak@redhat.com>
936174
Date: Mon, 19 Aug 2019 14:03:07 +0200
936174
Subject: [PATCH 31/32] chfn: don't append extra tailing commas
936174
936174
 # grep kzak /etc/passwd
936174
 kzak:x:1000:1000::/home/kzak:/bin/bash
936174
936174
 # chfn kzak
936174
 ...
936174
 grep kzak /etc/passwd
936174
936174
old version:
936174
 kzak:x:1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash
936174
936174
fixed version:
936174
 kzak:x:1000:1000:Karel Zak:/home/kzak:/bin/bash
936174
936174
Reported-by: Filip Dvorak <fdvorak@redhat.com>
936174
References: f723cbf544a7eac2927634f2cb6d802437a2d519
936174
Upstream: http://github.com/karelzak/util-linux/commit/9210c0d225fd808da451d86055bf243a8b47a525
936174
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1743555
936174
Signed-off-by: Karel Zak <kzak@redhat.com>
936174
---
936174
 login-utils/chfn.c | 2 +-
936174
 1 file changed, 1 insertion(+), 1 deletion(-)
936174
936174
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
936174
index c5312fa0c..4f32604c5 100644
936174
--- a/login-utils/chfn.c
936174
+++ b/login-utils/chfn.c
936174
@@ -377,7 +377,7 @@ static int save_new_data(struct chfn_control *ctl)
936174
 			ctl->newf.other);
936174
 
936174
 	/* remove trailing empty fields (but not subfields of ctl->newf.other) */
936174
-	if (!ctl->newf.other) {
936174
+	if (!ctl->newf.other || !*ctl->newf.other) {
936174
 		while (len > 0 && gecos[len - 1] == ',')
936174
 			len--;
936174
 		gecos[len] = 0;
936174
-- 
936174
2.21.0
936174