lib/: Don't open-code get_gid()

These functions were open-coding get_gid().  Use the actual function.

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-06-29 20:00:18 +02:00
parent f85a07f140
commit 509e3bcbf8
3 changed files with 28 additions and 45 deletions
+7 -13
View File
@@ -38,6 +38,7 @@
#include "alloc.h"
#include "atoi/str2i.h"
#include "atoi/getnum.h"
#include "chkname.h"
#include "defines.h"
#include "faillog.h"
@@ -853,21 +854,14 @@ static int get_groups (char *list)
*/
static struct group * get_local_group(char * grp_name)
{
char *end;
const struct group *grp;
struct group *result_grp = NULL;
long long gid;
gid_t gid;
struct group *result_grp = NULL;
const struct group *grp;
gid = strtoll(grp_name, &end, 10);
if ( ('\0' != *grp_name)
&& ('\0' == *end)
&& (ERANGE != errno)
&& (gid == (gid_t)gid)) {
grp = gr_locate_gid (gid);
}
else {
if (get_gid(grp_name, &gid) == 0)
grp = gr_locate_gid(gid);
else
grp = gr_locate(grp_name);
}
if (grp != NULL) {
result_grp = __gr_dup (grp);