From 16013c560e189bd0c4fb58e038c0f449542dba7a Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 16 Jul 2017 11:19:51 +0000 Subject: Add egidingroups sysdeps, change fd_close() to void and saving errno, propagate changes --- src/sysdeps/tryegidingroups.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/sysdeps/tryegidingroups.c (limited to 'src/sysdeps') diff --git a/src/sysdeps/tryegidingroups.c b/src/sysdeps/tryegidingroups.c new file mode 100644 index 0000000..687740d --- /dev/null +++ b/src/sysdeps/tryegidingroups.c @@ -0,0 +1,39 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif + +#ifndef _NETBSD_SOURCE +#define _NETBSD_SOURCE +#endif + +#ifndef __EXTENSIONS__ +#define __EXTENSIONS__ +#endif + +#include +#include +#include + +int main (void) +{ + gid_t gid = getegid() ; + gid_t list[NGROUPS_MAX] ; + int i = 0 ; + int r = getgroups(NGROUPS_MAX, list) ; + if (r < 0) return 111 ; + for (; i < r ; i++) if (list[i] == gid) return 0 ; + return 1 ; +} -- cgit v1.2.3