[systemd-devel] [PATCH] sysusers: remove additional finger information from gecos

Sami Kerola kerolasa at iki.fi
Sat Feb 7 15:38:12 PST 2015


This change removes garbage from authentication messages if chfn(1) has
been used.  For example;

$ timedatectl set-timezone Europe/London
[...]
Authenticating as: Sami Kerola,office,officephone,homephone, (kerolasa)
---
 src/sysusers/sysusers.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index f25ece0..c94fe58 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -885,12 +885,16 @@ static int add_user(Item *i) {
                 errno = 0;
                 p = getpwnam(i->name);
                 if (p) {
+                        char *comma;
+
                         log_debug("User %s already exists.", i->name);
                         i->uid = p->pw_uid;
                         i->uid_set = true;
 
                         free(i->description);
                         i->description = strdup(p->pw_gecos);
+                        if ((comma = strchr(i->description, ',')))
+                                *comma = '\0';
                         return 0;
                 }
                 if (!IN_SET(errno, 0, ENOENT))
-- 
2.3.0



More information about the systemd-devel mailing list