diff options
author | Alessandro Bono <alessandro.bono369@gmail.com> | 2022-09-29 11:26:45 +0200 |
---|---|---|
committer | Ray Strode <halfline@gmail.com> | 2022-10-27 19:28:33 +0000 |
commit | a5cb3677cff6d2e1246dbc13962ca9e788c6338b (patch) | |
tree | be6d32407f177ac6ed51724d6921fb02ca5869dd | |
parent | d4c06667b707bab5668846fa93189c26be9c7d10 (diff) | |
download | gdm-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.
-rw-r--r-- | daemon/gdm-display-access-file.c | 10 |
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); |