1 /* Copyright (c) 1997-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
22 #include <rpcsvc/nis.h>
25 nis_print_group_entry (const_nis_name group
)
27 if (group
!= NULL
&& group
[0] != '\0')
29 size_t grouplen
= strlen (group
);
30 char buf
[grouplen
+ 50];
31 char leafbuf
[grouplen
+ 3];
32 char domainbuf
[grouplen
+ 3];
37 cp
= stpcpy (buf
, nis_leaf_of_r (group
, leafbuf
, sizeof (leafbuf
) - 1));
38 cp
= stpcpy (cp
, ".groups_dir");
39 cp2
= nis_domain_of_r (group
, domainbuf
, sizeof (domainbuf
) - 1);
40 if (cp2
!= NULL
&& cp2
[0] != '\0')
45 res
= nis_lookup (buf
, FOLLOW_LINKS
| EXPAND_NAME
);
50 if (NIS_RES_STATUS (res
) != NIS_SUCCESS
51 || NIS_RES_NUMOBJ (res
) != 1
52 || __type_of (NIS_RES_OBJECT (res
)) != NIS_GROUP_OBJ
)
58 char *mem_exp
[NIS_RES_NUMOBJ (res
)];
59 char *mem_imp
[NIS_RES_NUMOBJ (res
)];
60 char *mem_rec
[NIS_RES_NUMOBJ (res
)];
61 char *nomem_exp
[NIS_RES_NUMOBJ (res
)];
62 char *nomem_imp
[NIS_RES_NUMOBJ (res
)];
63 char *nomem_rec
[NIS_RES_NUMOBJ (res
)];
64 unsigned long mem_exp_cnt
= 0, mem_imp_cnt
= 0, mem_rec_cnt
= 0;
65 unsigned long nomem_exp_cnt
= 0, nomem_imp_cnt
= 0, nomem_rec_cnt
= 0;
68 i
< NIS_RES_OBJECT (res
)->GR_data
.gr_members
.gr_members_len
; ++i
)
71 NIS_RES_OBJECT (res
)->GR_data
.gr_members
.gr_members_val
[i
];
72 int neg
= grmem
[0] == '-';
79 nomem_imp
[nomem_imp_cnt
] = grmem
;
84 mem_imp
[mem_imp_cnt
] = grmem
;
91 nomem_rec
[nomem_rec_cnt
] = grmem
;
96 mem_rec
[mem_rec_cnt
] = grmem
;
103 nomem_exp
[nomem_exp_cnt
] = grmem
;
108 mem_exp
[mem_exp_cnt
] = grmem
;
115 char buf
[strlen (NIS_RES_OBJECT (res
)->zo_domain
) + 10];
116 printf (_("Group entry for \"%s.%s\" group:\n"),
117 NIS_RES_OBJECT (res
)->zo_name
,
118 nis_domain_of_r (NIS_RES_OBJECT (res
)->zo_domain
,
119 buf
, strlen (NIS_RES_OBJECT (res
)->zo_domain
)
124 fputs (_(" Explicit members:\n"), stdout
);
125 for (i
= 0; i
< mem_exp_cnt
; ++i
)
126 printf ("\t%s\n", mem_exp
[i
]);
129 fputs (_(" No explicit members\n"), stdout
);
132 fputs (_(" Implicit members:\n"), stdout
);
133 for (i
= 0; i
< mem_imp_cnt
; ++i
)
134 printf ("\t%s\n", &mem_imp
[i
][2]);
137 fputs (_(" No implicit members\n"), stdout
);
140 fputs (_(" Recursive members:\n"), stdout
);
141 for (i
= 0; i
< mem_rec_cnt
; ++i
)
142 printf ("\t%s\n", &mem_rec
[i
][1]);
145 fputs (_(" No recursive members\n"), stdout
);
148 fputs (_(" Explicit nonmembers:\n"), stdout
);
149 for (i
= 0; i
< nomem_exp_cnt
; ++i
)
150 printf ("\t%s\n", &nomem_exp
[i
][1]);
153 fputs (_(" No explicit nonmembers\n"), stdout
);
156 fputs (_(" Implicit nonmembers:\n"), stdout
);
157 for (i
= 0; i
< nomem_imp_cnt
; ++i
)
158 printf ("\t%s\n", &nomem_imp
[i
][3]);
161 fputs (_(" No implicit nonmembers\n"), stdout
);
164 fputs (_(" Recursive nonmembers:\n"), stdout
);
165 for (i
= 0; i
< nomem_rec_cnt
; ++i
)
166 printf ("\t%s=n", &nomem_rec
[i
][2]);
169 fputs (_(" No recursive nonmembers\n"), stdout
);
171 nis_freeresult (res
);