• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define _GNU_SOURCE
2 #include <grp.h>
3 #include <stdio.h>
4 
putgrent(const struct group * gr,FILE * f)5 int putgrent(const struct group *gr, FILE *f)
6 {
7 	int r;
8 	size_t i;
9 	flockfile(f);
10 	if ((r = fprintf(f, "%s:%s:%u:", gr->gr_name, gr->gr_passwd, gr->gr_gid))<0) goto done;
11 	if (gr->gr_mem) for (i=0; gr->gr_mem[i]; i++)
12 		if ((r = fprintf(f, "%s%s", i?",":"", gr->gr_mem[i]))<0) goto done;
13 	r = fputc('\n', f);
14 done:
15 	funlockfile(f);
16 	return r<0 ? -1 : 0;
17 }
18