1 /* Copyright (c) 1997 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 #include <rpcsvc/nis.h>
24 nis_print_group_entry (const_nis_name group
)
26 if (group
!= NULL
&& strlen (group
) > 0)
28 char buf
[strlen (group
) + 50];
29 char leafbuf
[strlen (group
) + 3];
30 char domainbuf
[strlen (group
) + 3];
31 unsigned long mem_exp_cnt
= 0, mem_imp_cnt
= 0, mem_rec_cnt
= 0;
32 unsigned long nomem_exp_cnt
= 0, nomem_imp_cnt
= 0, nomem_rec_cnt
= 0;
33 char **mem_exp
, **mem_imp
, **mem_rec
;
34 char **nomem_exp
, **nomem_imp
, **nomem_rec
;
39 cp
= stpcpy (buf
, nis_leaf_of_r (group
, leafbuf
, sizeof (leafbuf
) - 1));
40 cp
= stpcpy (cp
, ".groups_dir");
41 cp2
= nis_domain_of_r (group
, domainbuf
, sizeof (domainbuf
) - 1);
42 if (cp2
!= NULL
&& strlen (cp2
) > 0)
47 res
= nis_lookup (buf
, FOLLOW_LINKS
| EXPAND_NAME
);
49 if (NIS_RES_STATUS(res
) != NIS_SUCCESS
)
52 if ((NIS_RES_NUMOBJ (res
) != 1) ||
53 (__type_of (NIS_RES_OBJECT (res
)) != NIS_GROUP_OBJ
))
56 mem_exp
= malloc (sizeof (char *) * NIS_RES_NUMOBJ (res
));
57 mem_imp
= malloc (sizeof (char *) * NIS_RES_NUMOBJ (res
));
58 mem_rec
= malloc (sizeof (char *) * NIS_RES_NUMOBJ (res
));
59 nomem_exp
= malloc (sizeof (char *) * NIS_RES_NUMOBJ (res
));
60 nomem_imp
= malloc (sizeof (char *) * NIS_RES_NUMOBJ (res
));
61 nomem_rec
= malloc (sizeof (char *) * NIS_RES_NUMOBJ (res
));
64 i
< NIS_RES_OBJECT (res
)->GR_data
.gr_members
.gr_members_len
; ++i
)
67 NIS_RES_OBJECT (res
)->GR_data
.gr_members
.gr_members_val
[i
];
68 int neg
= grmem
[0] == '-';
75 nomem_imp
[nomem_imp_cnt
] = grmem
;
80 mem_imp
[mem_imp_cnt
] = grmem
;
87 nomem_rec
[nomem_rec_cnt
] = grmem
;
92 mem_rec
[mem_rec_cnt
] = grmem
;
99 nomem_exp
[nomem_exp_cnt
] = grmem
;
104 mem_exp
[mem_exp_cnt
] = grmem
;
111 char buf
[strlen (NIS_RES_OBJECT (res
)->zo_domain
) + 10];
112 printf (_("Group entry for \"%s.%s\" group:\n"),
113 NIS_RES_OBJECT (res
)->zo_name
,
114 nis_domain_of_r (NIS_RES_OBJECT (res
)->zo_domain
,
115 buf
, strlen (NIS_RES_OBJECT (res
)->zo_domain
)
120 fputs (_(" Explicit members:\n"), stdout
);
121 for (i
= 0; i
< mem_exp_cnt
; ++i
)
122 printf ("\t%s\n", mem_exp
[i
]);
125 fputs (_(" No explicit members\n"), stdout
);
128 fputs (_(" Implicit members:\n"), stdout
);
129 for (i
= 0; i
< mem_imp_cnt
; ++i
)
130 printf ("\t%s\n", &mem_imp
[i
][2]);
133 fputs (_(" No implicit members\n"), stdout
);
136 fputs (_(" Recursive members:\n"), stdout
);
137 for (i
= 0; i
< mem_rec_cnt
; ++i
)
138 printf ("\t%s\n", &mem_rec
[i
][1]);
141 fputs (_(" No recursive members\n"), stdout
);
144 fputs (_(" Explicit nonmembers:\n"), stdout
);
145 for (i
= 0; i
< nomem_exp_cnt
; ++i
)
146 printf ("\t%s\n", &nomem_exp
[i
][1]);
149 fputs (_(" No explicit nonmembers\n"), stdout
);
152 fputs (_(" Implicit nonmembers:\n"), stdout
);
153 for (i
= 0; i
< nomem_imp_cnt
; ++i
)
154 printf ("\t%s\n", &mem_imp
[i
][3]);
157 fputs (_(" No implicit nonmembers\n"), stdout
);
160 fputs (_(" Explicit nonmembers:\n"), stdout
);
161 for (i
= 0; i
< nomem_rec_cnt
; ++i
)
162 printf ("\t%s=n", &nomem_rec
[i
][2]);
165 fputs (_(" No recursive nonmembers\n"), stdout
);
173 nis_freeresult (res
);