diff options
author | Karel Zak | 2019-08-19 14:03:07 +0200 |
---|---|---|
committer | Karel Zak | 2019-08-19 14:03:07 +0200 |
commit | 9210c0d225fd808da451d86055bf243a8b47a525 (patch) | |
tree | 13a29ff17733fa19b55f937b3d867b8a45c16c84 | |
parent | Remove unused utime.h header (diff) | |
download | kernel-qcow2-util-linux-9210c0d225fd808da451d86055bf243a8b47a525.tar.gz kernel-qcow2-util-linux-9210c0d225fd808da451d86055bf243a8b47a525.tar.xz kernel-qcow2-util-linux-9210c0d225fd808da451d86055bf243a8b47a525.zip |
chfn: don't append extra tailing commas
# grep kzak /etc/passwd
kzak:x:1000:1000::/home/kzak:/bin/bash
# chfn kzak
...
grep kzak /etc/passwd
old version:
kzak:x:1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash
fixed version:
kzak:x:1000:1000:Karel Zak:/home/kzak:/bin/bash
Reported-by: Filip Dvorak <fdvorak@redhat.com>
References: f723cbf544a7eac2927634f2cb6d802437a2d519
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | login-utils/chfn.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/login-utils/chfn.c b/login-utils/chfn.c index a2e6e099e..b7395552b 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -376,7 +376,7 @@ static int save_new_data(struct chfn_control *ctl) ctl->newf.other); /* remove trailing empty fields (but not subfields of ctl->newf.other) */ - if (!ctl->newf.other) { + if (!ctl->newf.other || !*ctl->newf.other) { while (len > 0 && gecos[len - 1] == ',') len--; gecos[len] = 0; |