summaryrefslogtreecommitdiff
path: root/daemon/gdm-display-access-file.c
diff options
context:
space:
mode:
authorAlessandro Bono <alessandro.bono369@gmail.com>2022-09-29 11:26:45 +0200
committerRay Strode <halfline@gmail.com>2022-10-27 19:28:33 +0000
commita5cb3677cff6d2e1246dbc13962ca9e788c6338b (patch)
treebe6d32407f177ac6ed51724d6921fb02ca5869dd /daemon/gdm-display-access-file.c
parentd4c06667b707bab5668846fa93189c26be9c7d10 (diff)
downloadgdm-a5cb3677cff6d2e1246dbc13962ca9e788c6338b.tar.gz
gdm-display-access-file: Check _get_uid_and_gid_for_user() return value
While it is unlikely that the gdm user is not installed on the system, check the returning value of _get_uid_and_gid_for_user(), so that we are not going to read a garbage value from the gid variable.
Diffstat (limited to 'daemon/gdm-display-access-file.c')
-rw-r--r--daemon/gdm-display-access-file.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/daemon/gdm-display-access-file.c b/daemon/gdm-display-access-file.c
index 36258a11..ed0a146d 100644
--- a/daemon/gdm-display-access-file.c
+++ b/daemon/gdm-display-access-file.c
@@ -278,7 +278,15 @@ _create_xauth_file_for_user (const char *username,
}
g_chmod (GDM_XAUTH_DIR, 0711);
- _get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid);
+ if (!_get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid)) {
+ g_set_error (error,
+ GDM_DISPLAY_ERROR,
+ GDM_DISPLAY_ERROR_GETTING_USER_INFO,
+ _("Could not find user ā€œ%sā€ on system"),
+ GDM_USERNAME);
+ goto out;
+ }
+
if (chown (GDM_XAUTH_DIR, 0, gid) != 0) {
g_warning ("Unable to change owner of '%s'",
GDM_XAUTH_DIR);