File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ class Account {
5454 void set_gecos (StringView gecos) { m_gecos = gecos; }
5555 void set_deleted () { m_deleted = true ; }
5656 void set_extra_gids (Vector<gid_t > extra_gids) { m_extra_gids = move (extra_gids); }
57+ void add_extra_gid (gid_t gid) { m_extra_gids.append (gid); }
58+
59+ void remove_extra_gid (gid_t gid)
60+ {
61+ m_extra_gids.remove_all_matching ([gid](auto g) { return g == gid; });
62+ }
63+
5764 void delete_password ();
5865
5966 // A nonexistent password means that this account was missing from /etc/shadow.
Original file line number Diff line number Diff line change @@ -188,19 +188,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
188188 }
189189
190190 if (append_extra_gids) {
191- for (auto gid : target_account.extra_gids ())
192- extra_gids.append (gid);
193- }
194-
195- if (remove_extra_gids) {
196- Vector<gid_t > current_extra_gids = target_account.extra_gids ();
197191 for (auto gid : extra_gids)
198- current_extra_gids.remove_all_matching ([gid](auto current_gid) { return current_gid == gid; });
199-
200- extra_gids = move (current_extra_gids);
201- }
202-
203- if (!extra_gids.is_empty () || remove_extra_gids) {
192+ target_account.add_extra_gid (gid);
193+ } else if (remove_extra_gids) {
194+ for (auto gid : extra_gids)
195+ target_account.remove_extra_gid (gid);
196+ } else {
204197 target_account.set_extra_gids (extra_gids);
205198 }
206199
You can’t perform that action at this time.
0 commit comments