From 6594b1f262ffaa3d120c0b23f92bad2802f17e4a Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 27 Sep 2017 20:51:47 +0800 Subject: common: Also set GROUP in scripts https://bugzilla.gnome.org/show_bug.cgi?id=787287 --- common/gdm-common.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/common/gdm-common.c b/common/gdm-common.c index 31fc810a..0bc2b417 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -97,6 +98,24 @@ gdm_get_pwent_for_name (const char *name, return (pwent != NULL); } +gboolean +gdm_get_grent_for_gid (gint gid, + struct grent **grentp) +{ + struct group *grent; + + do { + errno = 0; + grent = getgrgid (gid); + } while (grent == NULL && errno == EINTR); + + if (pwentp != NULL) { + *grentp = grent; + } + + return (grent != NULL); +} + int gdm_wait_on_and_disown_pid (int pid, int timeout) @@ -586,6 +605,13 @@ gdm_get_script_environment (const char *username, g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell)); + + /* Also get group name and propagate down */ + struct group *grent; + + if (gdm_get_grent_for_gid (pwent->pw_gid, &grent)) { + g_hash_table_insert (hash, g_strdup ("GROUP"), g_strdup (grent->gr_name)); + } } } -- cgit v1.2.1