#include "alloc/malloc.h"
#include "alloc/reallocf.h"
-#include "search/l/lfind.h"
+#include "search/l/lsearch.h"
#include "shadowlog.h"
#ident "$Id$"
add_groups(const char *list)
{
GETGROUPS_T *grouplist;
- int ngroups;
char *g, *p;
char buf[1024];
FILE *shadow_logfd = log_get_logfd();
+ size_t ngroups;
if (strlen (list) >= sizeof (buf)) {
errno = EINVAL;
if (grouplist == NULL)
return -1;
- if (LFIND(&grp->gr_gid, grouplist, ngroups) != NULL)
- continue;
-
- grouplist[ngroups] = grp->gr_gid;
- ngroups++;
+ LSEARCH(&grp->gr_gid, grouplist, &ngroups);
}
if (setgroups(ngroups, grouplist) == -1) {
#include "getdef.h"
#include "prototypes.h"
#include "search/l/lfind.h"
+#include "search/l/lsearch.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/strcmp/streq.h"
extern char **newenvp;
-static int ngroups;
+static size_t ngroups;
static /*@null@*/ /*@only@*/GETGROUPS_T *grouplist;
static bool is_newgrp;
*/
grouplist = XREALLOC(grouplist, ngroups + 1, GETGROUPS_T);
- if (LFIND(&gid, grouplist, ngroups) == NULL) {
- grouplist[ngroups++] = gid;
- }
+ LSEARCH(&gid, grouplist, &ngroups);
if (setgroups(ngroups, grouplist) == -1)
perror("setgroups");