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