1
0
Fork 0
shadow/lib/getgr_nam_gid.c
Daniel Baumann 09a180ea01
Adding upstream version 1:4.17.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-22 05:06:56 +02:00

39 lines
938 B
C

// SPDX-FileCopyrightText: 1991-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-2000, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2000-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#ident "$Id$"
#include <stdlib.h>
#include <errno.h>
#include <grp.h>
#include <sys/types.h>
#include "atoi/getnum.h"
#include "prototypes.h"
/*
* getgr_nam_gid - Return a pointer to the group specified by a string.
* The string may be a valid GID or a valid groupname.
* If the group does not exist on the system, NULL is returned.
*/
extern /*@only@*//*@null@*/struct group *
getgr_nam_gid(/*@null@*/const char *grname)
{
gid_t gid;
if (NULL == grname)
return NULL;
if (get_gid(grname, &gid) == 0)
return xgetgrgid(gid);
return xgetgrnam(grname);
}