]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (c) 1997-2019 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 | |
41bdb6e2 AJ |
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. | |
51702635 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
51702635 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
51702635 | 18 | |
0a55a284 | 19 | #include <alloca.h> |
51702635 | 20 | #include <string.h> |
4360eafd | 21 | #include <libintl.h> |
51702635 | 22 | #include <rpcsvc/nis.h> |
82f43dd2 | 23 | #include <shlib-compat.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]; | |
51702635 UD |
34 | nis_result *res; |
35 | char *cp, *cp2; | |
36 | u_int i; | |
37 | ||
38 | cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); | |
39 | cp = stpcpy (cp, ".groups_dir"); | |
40 | cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); | |
a53bad16 | 41 | if (cp2 != NULL && cp2[0] != '\0') |
51702635 | 42 | { |
714a562f UD |
43 | *cp++ = '.'; |
44 | stpcpy (cp, cp2); | |
51702635 | 45 | } |
dfd2257a | 46 | res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME); |
51702635 | 47 | |
0292b0dd | 48 | if (res == NULL) |
51702635 UD |
49 | return; |
50 | ||
0292b0dd UD |
51 | if (NIS_RES_STATUS (res) != NIS_SUCCESS |
52 | || NIS_RES_NUMOBJ (res) != 1 | |
53 | || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ) | |
54 | { | |
55 | nis_freeresult (res); | |
56 | return; | |
57 | } | |
51702635 | 58 | |
db2f05ba RM |
59 | char *mem_exp[NIS_RES_NUMOBJ (res)]; |
60 | char *mem_imp[NIS_RES_NUMOBJ (res)]; | |
61 | char *mem_rec[NIS_RES_NUMOBJ (res)]; | |
62 | char *nomem_exp[NIS_RES_NUMOBJ (res)]; | |
63 | char *nomem_imp[NIS_RES_NUMOBJ (res)]; | |
64 | char *nomem_rec[NIS_RES_NUMOBJ (res)]; | |
65 | unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0; | |
66 | unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0; | |
dfd2257a | 67 | |
51702635 | 68 | for (i = 0; |
e88e03a0 | 69 | i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i) |
dfd2257a UD |
70 | { |
71 | char *grmem = | |
e88e03a0 | 72 | NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i]; |
dfd2257a UD |
73 | int neg = grmem[0] == '-'; |
74 | ||
75 | switch (grmem[neg]) | |
76 | { | |
77 | case '*': | |
78 | if (neg) | |
79 | { | |
80 | nomem_imp[nomem_imp_cnt] = grmem; | |
81 | ++nomem_imp_cnt; | |
82 | } | |
83 | else | |
84 | { | |
85 | mem_imp[mem_imp_cnt] = grmem; | |
86 | ++mem_imp_cnt; | |
87 | } | |
88 | break; | |
89 | case '@': | |
90 | if (neg) | |
91 | { | |
92 | nomem_rec[nomem_rec_cnt] = grmem; | |
93 | ++nomem_rec_cnt; | |
94 | } | |
95 | else | |
96 | { | |
97 | mem_rec[mem_rec_cnt] = grmem; | |
98 | ++mem_rec_cnt; | |
99 | } | |
100 | break; | |
101 | default: | |
102 | if (neg) | |
103 | { | |
104 | nomem_exp[nomem_exp_cnt] = grmem; | |
105 | ++nomem_exp_cnt; | |
106 | } | |
107 | else | |
108 | { | |
109 | mem_exp[mem_exp_cnt] = grmem; | |
110 | ++mem_exp_cnt; | |
111 | } | |
112 | break; | |
113 | } | |
114 | } | |
115 | { | |
116 | char buf[strlen (NIS_RES_OBJECT (res)->zo_domain) + 10]; | |
117 | printf (_("Group entry for \"%s.%s\" group:\n"), | |
118 | NIS_RES_OBJECT (res)->zo_name, | |
119 | nis_domain_of_r (NIS_RES_OBJECT (res)->zo_domain, | |
120 | buf, strlen (NIS_RES_OBJECT (res)->zo_domain) | |
121 | + 10)); | |
122 | } | |
123 | if (mem_exp_cnt) | |
124 | { | |
125 | fputs (_(" Explicit members:\n"), stdout); | |
126 | for (i = 0; i < mem_exp_cnt; ++i) | |
127 | printf ("\t%s\n", mem_exp[i]); | |
128 | } | |
129 | else | |
130 | fputs (_(" No explicit members\n"), stdout); | |
131 | if (mem_imp_cnt) | |
132 | { | |
133 | fputs (_(" Implicit members:\n"), stdout); | |
134 | for (i = 0; i < mem_imp_cnt; ++i) | |
135 | printf ("\t%s\n", &mem_imp[i][2]); | |
136 | } | |
137 | else | |
138 | fputs (_(" No implicit members\n"), stdout); | |
139 | if (mem_rec_cnt) | |
140 | { | |
141 | fputs (_(" Recursive members:\n"), stdout); | |
142 | for (i = 0; i < mem_rec_cnt; ++i) | |
143 | printf ("\t%s\n", &mem_rec[i][1]); | |
144 | } | |
145 | else | |
146 | fputs (_(" No recursive members\n"), stdout); | |
147 | if (nomem_exp_cnt) | |
148 | { | |
149 | fputs (_(" Explicit nonmembers:\n"), stdout); | |
150 | for (i = 0; i < nomem_exp_cnt; ++i) | |
151 | printf ("\t%s\n", &nomem_exp[i][1]); | |
152 | } | |
153 | else | |
154 | fputs (_(" No explicit nonmembers\n"), stdout); | |
155 | if (nomem_imp_cnt) | |
156 | { | |
157 | fputs (_(" Implicit nonmembers:\n"), stdout); | |
158 | for (i = 0; i < nomem_imp_cnt; ++i) | |
5615eaf2 | 159 | printf ("\t%s\n", &nomem_imp[i][3]); |
dfd2257a UD |
160 | } |
161 | else | |
162 | fputs (_(" No implicit nonmembers\n"), stdout); | |
163 | if (nomem_rec_cnt) | |
164 | { | |
11bf311e | 165 | fputs (_(" Recursive nonmembers:\n"), stdout); |
dfd2257a UD |
166 | for (i = 0; i < nomem_rec_cnt; ++i) |
167 | printf ("\t%s=n", &nomem_rec[i][2]); | |
168 | } | |
169 | else | |
170 | fputs (_(" No recursive nonmembers\n"), stdout); | |
171 | ||
dfd2257a | 172 | nis_freeresult (res); |
51702635 UD |
173 | } |
174 | } | |
1e4d83f6 | 175 | libnsl_hidden_nolink_def (nis_print_group_entry, GLIBC_2_1) |