mirror of
https://github.com/shadow-maint/shadow.git
synced 2024-11-23 01:56:51 +08:00
lib/, libsubid/, po/, src/: get_gid(): Move function to "atoi/getnum.h"
Implement it as an inline function, and add restrict and ATTR_STRING() and ATTR_ACCESS() as appropriate. Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
74a2ed4537
commit
f85a07f140
@ -33,6 +33,8 @@ libshadow_la_SOURCES = \
|
||||
alloc.h \
|
||||
atoi/a2i.c \
|
||||
atoi/a2i.h \
|
||||
atoi/getnum.c \
|
||||
atoi/getnum.h \
|
||||
atoi/str2i.c \
|
||||
atoi/str2i.h \
|
||||
atoi/strtoi.c \
|
||||
@ -71,7 +73,6 @@ libshadow_la_SOURCES = \
|
||||
find_new_sub_gids.c \
|
||||
find_new_sub_uids.c \
|
||||
fputsx.c \
|
||||
get_gid.c \
|
||||
get_pid.c \
|
||||
get_uid.c \
|
||||
getdate.h \
|
||||
|
13
lib/atoi/getnum.c
Normal file
13
lib/atoi/getnum.c
Normal file
@ -0,0 +1,13 @@
|
||||
// SPDX-FileCopyrightText: 2009, Nicolas François
|
||||
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "atoi/getnum.h"
|
||||
|
||||
|
||||
extern inline int get_gid(const char *restrict gidstr, gid_t *restrict gid);
|
@ -3,19 +3,29 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_ATOI_GETNUM_H_
|
||||
#define SHADOW_INCLUDE_LIB_ATOI_GETNUM_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id$"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "atoi/a2i.h"
|
||||
#include "attr.h"
|
||||
#include "typetraits.h"
|
||||
|
||||
|
||||
int
|
||||
get_gid(const char *gidstr, gid_t *gid)
|
||||
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
|
||||
inline int get_gid(const char *restrict gidstr, gid_t *restrict gid);
|
||||
|
||||
|
||||
inline int
|
||||
get_gid(const char *restrict gidstr, gid_t *restrict gid)
|
||||
{
|
||||
return a2i(gid_t, gid, gidstr, NULL, 10, type_min(gid_t), type_max(gid_t));
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
@ -142,10 +142,6 @@ extern int find_new_sub_gids (gid_t *range_start, unsigned long *range_count);
|
||||
extern int find_new_sub_uids (uid_t *range_start, unsigned long *range_count);
|
||||
#endif /* ENABLE_SUBIDS */
|
||||
|
||||
|
||||
/* get_gid.c */
|
||||
extern int get_gid (const char *gidstr, gid_t *gid);
|
||||
|
||||
/* getgr_nam_gid.c */
|
||||
extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname);
|
||||
|
||||
|
@ -17,9 +17,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "atoi/getnum.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
|
||||
#define NFIELDS 4
|
||||
|
||||
/*
|
||||
|
@ -16,10 +16,12 @@
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atoi/getnum.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
|
||||
#define NFIELDS 7
|
||||
|
||||
/*
|
||||
|
@ -12,11 +12,13 @@
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "subordinateio.h"
|
||||
#include "idmapping.h"
|
||||
#include "subid.h"
|
||||
#include "shadowlog.h"
|
||||
|
||||
|
||||
bool subid_init(const char *progname, FILE * logfd)
|
||||
{
|
||||
FILE *shadow_logfd;
|
||||
|
@ -22,7 +22,6 @@ lib/find_new_sub_gids.c
|
||||
lib/find_new_sub_uids.c
|
||||
lib/find_new_uid.c
|
||||
lib/fputsx.c
|
||||
lib/get_gid.c
|
||||
lib/get_uid.c
|
||||
lib/getdef.c
|
||||
lib/getgr_nam_gid.c
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <pwd.h>
|
||||
#endif /* USE_PAM */
|
||||
#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
#include "atoi/getnum.h"
|
||||
#include "chkname.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
@ -37,6 +39,7 @@
|
||||
#include "shadowlog.h"
|
||||
#include "run_part.h"
|
||||
|
||||
|
||||
/*
|
||||
* exit status values
|
||||
*/
|
||||
|
@ -27,6 +27,7 @@
|
||||
#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
#include "alloc.h"
|
||||
#include "atoi/getnum.h"
|
||||
#include "chkname.h"
|
||||
#include "defines.h"
|
||||
#include "groupio.h"
|
||||
@ -40,6 +41,8 @@
|
||||
#include "shadowlog.h"
|
||||
#include "string/stpecpy.h"
|
||||
#include "string/stpeprintf.h"
|
||||
|
||||
|
||||
/*
|
||||
* exit status values
|
||||
*/
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "atoi/getnum.h"
|
||||
#include "atoi/str2i.h"
|
||||
#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
|
Loading…
Reference in New Issue
Block a user