b3yc0d3 / exas

Execute commands as another user

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimizing `hasgroup`

McModknower opened this issue · comments

You can optimize the hasgroup method by getting the group id of the given name via getgrnam once outside the loop and then just comparing the ids.
This allows you to do only minimal work in the group, optimizing your code directly by eliminating multiple calls for the group info and all calls to strcmp.