]>
Commit | Line | Data |
---|---|---|
5615eaf2 RM |
1 | /* Copyright (c) 1997,1998,2000,2004,2006,2011 |
2 | Free Software Foundation, Inc. | |
51702635 UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
51702635 UD |
10 | |
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
51702635 | 15 | |
41bdb6e2 AJ |
16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
51702635 | 20 | |
0a55a284 | 21 | #include <alloca.h> |
51702635 | 22 | #include <string.h> |
4360eafd | 23 | #include <libintl.h> |
51702635 | 24 | #include <rpcsvc/nis.h> |
51702635 UD |
25 | |
26 | void | |
27 | nis_print_group_entry (const_nis_name group) | |
28 | { | |
a53bad16 | 29 | if (group != NULL && group[0] != '\0') |
51702635 | 30 | { |
a53bad16 UD |
31 | size_t grouplen = strlen (group); |
32 | char buf[grouplen + 50]; | |
33 | char leafbuf[grouplen + 3]; | |
34 | char domainbuf[grouplen + 3]; | |
51702635 UD |
35 | nis_result *res; |
36 | char *cp, *cp2; | |
37 | u_int i; | |
38 | ||
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); | |
a53bad16 | 42 | if (cp2 != NULL && cp2[0] != '\0') |
51702635 | 43 | { |
714a562f UD |
44 | *cp++ = '.'; |
45 | stpcpy (cp, cp2); | |
51702635 | 46 | } |
dfd2257a | 47 | res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME); |
51702635 | 48 | |
0292b0dd | 49 | if (res == NULL) |
51702635 UD |
50 | return; |
51 | ||
0292b0dd UD |
52 | if (NIS_RES_STATUS (res) != NIS_SUCCESS |
53 | || NIS_RES_NUMOBJ (res) != 1 | |
54 | || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ) | |
55 | { | |
56 | nis_freeresult (res); | |
57 | return; | |
58 | } | |
51702635 | 59 | |
db2f05ba RM |
60 | char *mem_exp[NIS_RES_NUMOBJ (res)]; |
61 | char *mem_imp[NIS_RES_NUMOBJ (res)]; | |
62 | char *mem_rec[NIS_RES_NUMOBJ (res)]; | |
63 | char *nomem_exp[NIS_RES_NUMOBJ (res)]; | |
64 | char *nomem_imp[NIS_RES_NUMOBJ (res)]; | |
65 | char *nomem_rec[NIS_RES_NUMOBJ (res)]; | |
66 | unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0; | |
67 | unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0; | |
dfd2257a | 68 | |
51702635 | 69 | for (i = 0; |
e88e03a0 | 70 | i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i) |
dfd2257a UD |
71 | { |
72 | char *grmem = | |
e88e03a0 | 73 | NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i]; |
dfd2257a UD |
74 | int neg = grmem[0] == '-'; |
75 | ||
76 | switch (grmem[neg]) | |
77 | { | |
78 | case '*': | |
79 | if (neg) | |
80 | { | |
81 | nomem_imp[nomem_imp_cnt] = grmem; | |
82 | ++nomem_imp_cnt; | |
83 | } | |
84 | else | |
85 | { | |
86 | mem_imp[mem_imp_cnt] = grmem; | |
87 | ++mem_imp_cnt; | |
88 | } | |
89 | break; | |
90 | case '@': | |
91 | if (neg) | |
92 | { | |
93 | nomem_rec[nomem_rec_cnt] = grmem; | |
94 | ++nomem_rec_cnt; | |
95 | } | |
96 | else | |
97 | { | |
98 | mem_rec[mem_rec_cnt] = grmem; | |
99 | ++mem_rec_cnt; | |
100 | } | |
101 | break; | |
102 | default: | |
103 | if (neg) | |
104 | { | |
105 | nomem_exp[nomem_exp_cnt] = grmem; | |
106 | ++nomem_exp_cnt; | |
107 | } | |
108 | else | |
109 | { | |
110 | mem_exp[mem_exp_cnt] = grmem; | |
111 | ++mem_exp_cnt; | |
112 | } | |
113 | break; | |
114 | } | |
115 | } | |
116 | { | |
117 | char buf[strlen (NIS_RES_OBJECT (res)->zo_domain) + 10]; | |
118 | printf (_("Group entry for \"%s.%s\" group:\n"), | |
119 | NIS_RES_OBJECT (res)->zo_name, | |
120 | nis_domain_of_r (NIS_RES_OBJECT (res)->zo_domain, | |
121 | buf, strlen (NIS_RES_OBJECT (res)->zo_domain) | |
122 | + 10)); | |
123 | } | |
124 | if (mem_exp_cnt) | |
125 | { | |
126 | fputs (_(" Explicit members:\n"), stdout); | |
127 | for (i = 0; i < mem_exp_cnt; ++i) | |
128 | printf ("\t%s\n", mem_exp[i]); | |
129 | } | |
130 | else | |
131 | fputs (_(" No explicit members\n"), stdout); | |
132 | if (mem_imp_cnt) | |
133 | { | |
134 | fputs (_(" Implicit members:\n"), stdout); | |
135 | for (i = 0; i < mem_imp_cnt; ++i) | |
136 | printf ("\t%s\n", &mem_imp[i][2]); | |
137 | } | |
138 | else | |
139 | fputs (_(" No implicit members\n"), stdout); | |
140 | if (mem_rec_cnt) | |
141 | { | |
142 | fputs (_(" Recursive members:\n"), stdout); | |
143 | for (i = 0; i < mem_rec_cnt; ++i) | |
144 | printf ("\t%s\n", &mem_rec[i][1]); | |
145 | } | |
146 | else | |
147 | fputs (_(" No recursive members\n"), stdout); | |
148 | if (nomem_exp_cnt) | |
149 | { | |
150 | fputs (_(" Explicit nonmembers:\n"), stdout); | |
151 | for (i = 0; i < nomem_exp_cnt; ++i) | |
152 | printf ("\t%s\n", &nomem_exp[i][1]); | |
153 | } | |
154 | else | |
155 | fputs (_(" No explicit nonmembers\n"), stdout); | |
156 | if (nomem_imp_cnt) | |
157 | { | |
158 | fputs (_(" Implicit nonmembers:\n"), stdout); | |
159 | for (i = 0; i < nomem_imp_cnt; ++i) | |
5615eaf2 | 160 | printf ("\t%s\n", &nomem_imp[i][3]); |
dfd2257a UD |
161 | } |
162 | else | |
163 | fputs (_(" No implicit nonmembers\n"), stdout); | |
164 | if (nomem_rec_cnt) | |
165 | { | |
11bf311e | 166 | fputs (_(" Recursive nonmembers:\n"), stdout); |
dfd2257a UD |
167 | for (i = 0; i < nomem_rec_cnt; ++i) |
168 | printf ("\t%s=n", &nomem_rec[i][2]); | |
169 | } | |
170 | else | |
171 | fputs (_(" No recursive nonmembers\n"), stdout); | |
172 | ||
dfd2257a | 173 | nis_freeresult (res); |
51702635 UD |
174 | } |
175 | } |