From 4ce24954aae5e0af666741e69d5b93a7ad8e97ec Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Sun, 6 May 2012 13:36:54 +0200 Subject: [PATCH] Strip gecos on Unix systems on user name only. Patch from Scott Kostyshak. --- src/support/userinfo.cpp | 4 +++- src/support/userinfo.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/support/userinfo.cpp b/src/support/userinfo.cpp index 5f2cfcab65..c873afe247 100644 --- a/src/support/userinfo.cpp +++ b/src/support/userinfo.cpp @@ -48,7 +48,9 @@ docstring const user_name() struct passwd * pw = getpwuid(geteuid()); LASSERT(pw, /**/); - string name = pw->pw_gecos; + const string gecos = pw->pw_gecos; + const size_t pos = gecos.find(","); + string name = gecos.substr(0, pos); if (name.empty()) name = pw->pw_name; return from_local8bit(name); diff --git a/src/support/userinfo.h b/src/support/userinfo.h index 2c482f475c..6232a2b427 100644 --- a/src/support/userinfo.h +++ b/src/support/userinfo.h @@ -18,7 +18,7 @@ namespace lyx { namespace support { -/// return the current user's real name +/// return the current user's real name or user name docstring const user_name(); /// return the current user's e-mail address