diff --git a/Userland/Libraries/LibCore/Account.cpp b/Userland/Libraries/LibCore/Account.cpp index 8f56e53193..af52c709af 100644 --- a/Userland/Libraries/LibCore/Account.cpp +++ b/Userland/Libraries/LibCore/Account.cpp @@ -39,10 +39,13 @@ static String get_salt() return builder.build(); } -static Vector get_gids(const StringView& username) +static Vector get_extra_gids(const passwd& pwd) { + StringView username { pwd.pw_name }; Vector extra_gids; for (auto* group = getgrent(); group; group = getgrent()) { + if (group->gr_gid == pwd.pw_gid) + continue; for (size_t i = 0; group->gr_mem[i]; ++i) { if (username == group->gr_mem[i]) { extra_gids.append(group->gr_gid); @@ -56,7 +59,7 @@ static Vector get_gids(const StringView& username) Result Account::from_passwd(const passwd& pwd, const spwd& spwd) { - Account account(pwd, spwd, get_gids(pwd.pw_name)); + Account account(pwd, spwd, get_extra_gids(pwd)); endpwent(); #ifndef AK_OS_MACOS endspent();