1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
Index: shadow-4.1.5/lib/groupio.c
===================================================================
--- shadow-4.1.5.orig/lib/groupio.c 2012-05-29 01:52:46.829380353 +0000
+++ shadow-4.1.5/lib/groupio.c 2012-05-29 01:54:54.027846005 +0000
@@ -44,6 +44,46 @@
#include "getdef.h"
#include "groupio.h"
+#ifndef HAVE_PUTGRENT
+#define _nn(x) x ? x : ""
+int putgrent (const struct group *gr, FILE *fp)
+{
+ int rc;
+ int i;
+
+ if ((NULL == gr) || (NULL == fp)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ flockfile(fp);
+ if (gr->gr_name[0] == '+' || gr->gr_name[0] == '-') {
+ rc = fprintf(fp, "%s:%s::", gr->gr_name, _nn(gr->gr_passwd));
+ } else {
+ rc = fprintf(fp, "%s:%s:%lu:", gr->gr_name, _nn(gr->gr_passwd), (unsigned long int) gr->gr_gid);
+ }
+
+ if (rc < 0) {
+ funlockfile(fp);
+ return -1;
+ }
+
+ if (NULL != gr->gr_mem) {
+ for (i = 0; gr->gr_mem[i] != NULL; ++i) {
+ if (0 > fprintf(fp, i == 0 ? "%s" : ",%s", gr->gr_mem[i])) {
+ funlockfile(fp);
+ return -1;
+ }
+ }
+ }
+
+ putc_unlocked('\n', fp);
+ funlockfile(fp);
+ return 0;
+}
+#undef _nn
+#endif /* HAVE_PUTGRENT */
+
static /*@null@*/struct commonio_entry *merge_group_entries (
/*@null@*/ /*@returned@*/struct commonio_entry *gr1,
/*@null@*/struct commonio_entry *gr2);
|