From 1107a9f41a3103bfdcac3b07537f16fa386b35f6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Jan 2004 23:41:46 +0000 Subject: [PATCH] Don't treat the Win32 user name like a gecos field, and when extracting a Thu Jan 22 00:41:34 2004 Matthias Clasen * glib/gutils.c (g_get_any_init): Don't treat the Win32 user name like a gecos field, and when extracting a real name from a gecos field, replace '&' by the capitalized user name (a traditional passwd feature). (#118973, reported by Soeren Boll Overgaard) --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-12 | 8 ++++++++ ChangeLog.pre-2-4 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ glib/gutils.c | 29 +++++++++++++---------------- 7 files changed, 61 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0d9d0e..0a06bf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Jan 22 00:41:34 2004 Matthias Clasen + + * glib/gutils.c (g_get_any_init): Don't treat the Win32 + user name like a gecos field, and when extracting a real + name from a gecos field, replace '&' by the capitalized + user name (a traditional passwd feature). + (#118973, reported by Soeren Boll Overgaard) + Tue Jan 20 22:31:22 2004 Matthias Clasen * NEWS: Start of 2.3.2 section. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f0d9d0e..0a06bf8 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Thu Jan 22 00:41:34 2004 Matthias Clasen + + * glib/gutils.c (g_get_any_init): Don't treat the Win32 + user name like a gecos field, and when extracting a real + name from a gecos field, replace '&' by the capitalized + user name (a traditional passwd feature). + (#118973, reported by Soeren Boll Overgaard) + Tue Jan 20 22:31:22 2004 Matthias Clasen * NEWS: Start of 2.3.2 section. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index f0d9d0e..0a06bf8 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +Thu Jan 22 00:41:34 2004 Matthias Clasen + + * glib/gutils.c (g_get_any_init): Don't treat the Win32 + user name like a gecos field, and when extracting a real + name from a gecos field, replace '&' by the capitalized + user name (a traditional passwd feature). + (#118973, reported by Soeren Boll Overgaard) + Tue Jan 20 22:31:22 2004 Matthias Clasen * NEWS: Start of 2.3.2 section. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f0d9d0e..0a06bf8 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Thu Jan 22 00:41:34 2004 Matthias Clasen + + * glib/gutils.c (g_get_any_init): Don't treat the Win32 + user name like a gecos field, and when extracting a real + name from a gecos field, replace '&' by the capitalized + user name (a traditional passwd feature). + (#118973, reported by Soeren Boll Overgaard) + Tue Jan 20 22:31:22 2004 Matthias Clasen * NEWS: Start of 2.3.2 section. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f0d9d0e..0a06bf8 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Thu Jan 22 00:41:34 2004 Matthias Clasen + + * glib/gutils.c (g_get_any_init): Don't treat the Win32 + user name like a gecos field, and when extracting a real + name from a gecos field, replace '&' by the capitalized + user name (a traditional passwd feature). + (#118973, reported by Soeren Boll Overgaard) + Tue Jan 20 22:31:22 2004 Matthias Clasen * NEWS: Start of 2.3.2 section. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f0d9d0e..0a06bf8 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Thu Jan 22 00:41:34 2004 Matthias Clasen + + * glib/gutils.c (g_get_any_init): Don't treat the Win32 + user name like a gecos field, and when extracting a real + name from a gecos field, replace '&' by the capitalized + user name (a traditional passwd feature). + (#118973, reported by Soeren Boll Overgaard) + Tue Jan 20 22:31:22 2004 Matthias Clasen * NEWS: Start of 2.3.2 section. diff --git a/glib/gutils.c b/glib/gutils.c index 570eab9..f791005 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -957,8 +957,19 @@ g_get_any_init (void) } if (pw) { - g_user_name = g_strdup (pw->pw_name); - g_real_name = g_strdup (pw->pw_gecos); + gchar **gecos_fields; + gchar **name_parts; + + g_user_name = g_strdup (pw->pw_name); + + /* split the gecos field and substitute '&' */ + gecos_fields = g_strsplit (pw->pw_gecos, ",", 0); + name_parts = g_strsplit (gecos_fields[0], "&", 0); + pw->pw_name[0] = g_ascii_toupper (pw->pw_name[0]); + g_real_name = g_strjoinv (pw->pw_name, name_parts); + g_strfreev (gecos_fields); + g_strfreev (name_parts); + if (!g_home_dir) g_home_dir = g_strdup (pw->pw_dir); } @@ -993,20 +1004,6 @@ g_get_any_init (void) g_user_name = g_strdup ("somebody"); if (!g_real_name) g_real_name = g_strdup ("Unknown"); - else - { - gchar *p; - - for (p = g_real_name; *p; p++) - if (*p == ',') - { - *p = 0; - p = g_strdup (g_real_name); - g_free (g_real_name); - g_real_name = p; - break; - } - } } } -- 2.7.4