From a8cf9c5a3ffd1601872d1ab14c5be00fde29209c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 4 Jul 2017 18:49:24 +0200 Subject: libbb: new function bb_getgroups() - allocating wrapper around getgroups() function old new delta bb_getgroups - 111 +111 nexpr 843 757 -86 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/1 up/down: 111/-86) Total: 25 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index 557978e66..1c9de3af0 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1033,6 +1033,15 @@ void die_if_bad_username(const char* name) FAST_FUNC; #else #define die_if_bad_username(name) ((void)(name)) #endif +/* + * Returns (-1) terminated malloced result of getgroups(). + * Reallocs group_array (useful for repeated calls). + * ngroups is an initial size of array. It is rounded up to 32 for realloc. + * ngroups is updated on return. + * ngroups can be NULL: bb_getgroups(NULL, NULL) is valid usage. + * Dies on errors (on Linux, only xrealloc can cause this, not internal getgroups call). + */ +gid_t *bb_getgroups(int *ngroups, gid_t *group_array) FAST_FUNC; #if ENABLE_FEATURE_UTMP void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname); -- cgit v1.2.3