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

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