diff options
author | Sam Spilsbury <sam@endlessm.com> | 2017-09-27 20:51:47 +0800 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2018-01-08 15:53:58 -0500 |
commit | bf0a66405dae3fadef187e72e41406f816f1d2e1 (patch) | |
tree | 0497eeedc9aa578f67725efb9368c9afd2b21944 /common/gdm-common.c | |
parent | 5dd631c9d5dbb1dc8e548c3dc6a21ef656f44944 (diff) | |
download | gdm-bf0a66405dae3fadef187e72e41406f816f1d2e1.tar.gz |
common: Also set GROUP in scripts
https://bugzilla.gnome.org/show_bug.cgi?id=787287
Diffstat (limited to 'common/gdm-common.c')
-rw-r--r-- | common/gdm-common.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/gdm-common.c b/common/gdm-common.c index c4fc7073..c44fa998 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -26,6 +26,7 @@ #include <locale.h> #include <fcntl.h> #include <sys/wait.h> +#include <grp.h> #include <pwd.h> #include <glib.h> @@ -97,6 +98,24 @@ gdm_get_pwent_for_name (const char *name, return (pwent != NULL); } +static gboolean +gdm_get_grent_for_gid (gint gid, + struct group **grentp) +{ + struct group *grent; + + do { + errno = 0; + grent = getgrgid (gid); + } while (grent == NULL && errno == EINTR); + + if (grentp != 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)); + } } } |