]>
Commit | Line | Data |
---|---|---|
e88e03a0 | 1 | /* Copyright (c) 1997, 1998, 2000 Free Software Foundation, Inc. |
51702635 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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. */ | |
19 | ||
0a55a284 | 20 | #include <alloca.h> |
51702635 | 21 | #include <string.h> |
4360eafd | 22 | #include <libintl.h> |
51702635 | 23 | #include <rpcsvc/nis.h> |
51702635 UD |
24 | |
25 | void | |
26 | nis_print_group_entry (const_nis_name group) | |
27 | { | |
a53bad16 | 28 | if (group != NULL && group[0] != '\0') |
51702635 | 29 | { |
a53bad16 UD |
30 | size_t grouplen = strlen (group); |
31 | char buf[grouplen + 50]; | |
32 | char leafbuf[grouplen + 3]; | |
33 | char domainbuf[grouplen + 3]; | |
dfd2257a UD |
34 | unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0; |
35 | unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0; | |
36 | char **mem_exp, **mem_imp, **mem_rec; | |
37 | char **nomem_exp, **nomem_imp, **nomem_rec; | |
51702635 UD |
38 | nis_result *res; |
39 | char *cp, *cp2; | |
40 | u_int i; | |
41 | ||
42 | cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); | |
43 | cp = stpcpy (cp, ".groups_dir"); | |
44 | cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); | |
a53bad16 | 45 | if (cp2 != NULL && cp2[0] != '\0') |
51702635 | 46 | { |
714a562f UD |
47 | *cp++ = '.'; |
48 | stpcpy (cp, cp2); | |
51702635 | 49 | } |
dfd2257a | 50 | res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME); |
51702635 | 51 | |
dfd2257a | 52 | if (NIS_RES_STATUS(res) != NIS_SUCCESS) |
51702635 UD |
53 | return; |
54 | ||
dfd2257a UD |
55 | if ((NIS_RES_NUMOBJ (res) != 1) || |
56 | (__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ)) | |
51702635 UD |
57 | return; |
58 | ||
e88e03a0 UD |
59 | mem_exp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res)); |
60 | mem_imp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res)); | |
61 | mem_rec = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res)); | |
62 | nomem_exp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res)); | |
63 | nomem_imp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res)); | |
64 | nomem_rec = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res)); | |
dfd2257a | 65 | |
51702635 | 66 | for (i = 0; |
e88e03a0 | 67 | i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i) |
dfd2257a UD |
68 | { |
69 | char *grmem = | |
e88e03a0 | 70 | NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i]; |
dfd2257a UD |
71 | int neg = grmem[0] == '-'; |
72 | ||
73 | switch (grmem[neg]) | |
74 | { | |
75 | case '*': | |
76 | if (neg) | |
77 | { | |
78 | nomem_imp[nomem_imp_cnt] = grmem; | |
79 | ++nomem_imp_cnt; | |
80 | } | |
81 | else | |
82 | { | |
83 | mem_imp[mem_imp_cnt] = grmem; | |
84 | ++mem_imp_cnt; | |
85 | } | |
86 | break; | |
87 | case '@': | |
88 | if (neg) | |
89 | { | |
90 | nomem_rec[nomem_rec_cnt] = grmem; | |
91 | ++nomem_rec_cnt; | |
92 | } | |
93 | else | |
94 | { | |
95 | mem_rec[mem_rec_cnt] = grmem; | |
96 | ++mem_rec_cnt; | |
97 | } | |
98 | break; | |
99 | default: | |
100 | if (neg) | |
101 | { | |
102 | nomem_exp[nomem_exp_cnt] = grmem; | |
103 | ++nomem_exp_cnt; | |
104 | } | |
105 | else | |
106 | { | |
107 | mem_exp[mem_exp_cnt] = grmem; | |
108 | ++mem_exp_cnt; | |
109 | } | |
110 | break; | |
111 | } | |
112 | } | |
113 | { | |
114 | char buf[strlen (NIS_RES_OBJECT (res)->zo_domain) + 10]; | |
115 | printf (_("Group entry for \"%s.%s\" group:\n"), | |
116 | NIS_RES_OBJECT (res)->zo_name, | |
117 | nis_domain_of_r (NIS_RES_OBJECT (res)->zo_domain, | |
118 | buf, strlen (NIS_RES_OBJECT (res)->zo_domain) | |
119 | + 10)); | |
120 | } | |
121 | if (mem_exp_cnt) | |
122 | { | |
123 | fputs (_(" Explicit members:\n"), stdout); | |
124 | for (i = 0; i < mem_exp_cnt; ++i) | |
125 | printf ("\t%s\n", mem_exp[i]); | |
126 | } | |
127 | else | |
128 | fputs (_(" No explicit members\n"), stdout); | |
129 | if (mem_imp_cnt) | |
130 | { | |
131 | fputs (_(" Implicit members:\n"), stdout); | |
132 | for (i = 0; i < mem_imp_cnt; ++i) | |
133 | printf ("\t%s\n", &mem_imp[i][2]); | |
134 | } | |
135 | else | |
136 | fputs (_(" No implicit members\n"), stdout); | |
137 | if (mem_rec_cnt) | |
138 | { | |
139 | fputs (_(" Recursive members:\n"), stdout); | |
140 | for (i = 0; i < mem_rec_cnt; ++i) | |
141 | printf ("\t%s\n", &mem_rec[i][1]); | |
142 | } | |
143 | else | |
144 | fputs (_(" No recursive members\n"), stdout); | |
145 | if (nomem_exp_cnt) | |
146 | { | |
147 | fputs (_(" Explicit nonmembers:\n"), stdout); | |
148 | for (i = 0; i < nomem_exp_cnt; ++i) | |
149 | printf ("\t%s\n", &nomem_exp[i][1]); | |
150 | } | |
151 | else | |
152 | fputs (_(" No explicit nonmembers\n"), stdout); | |
153 | if (nomem_imp_cnt) | |
154 | { | |
155 | fputs (_(" Implicit nonmembers:\n"), stdout); | |
156 | for (i = 0; i < nomem_imp_cnt; ++i) | |
157 | printf ("\t%s\n", &mem_imp[i][3]); | |
158 | } | |
159 | else | |
160 | fputs (_(" No implicit nonmembers\n"), stdout); | |
161 | if (nomem_rec_cnt) | |
162 | { | |
163 | fputs (_(" Explicit nonmembers:\n"), stdout); | |
164 | for (i = 0; i < nomem_rec_cnt; ++i) | |
165 | printf ("\t%s=n", &nomem_rec[i][2]); | |
166 | } | |
167 | else | |
168 | fputs (_(" No recursive nonmembers\n"), stdout); | |
169 | ||
dfd2257a | 170 | nis_freeresult (res); |
51702635 UD |
171 | } |
172 | } |