1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved.
24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate #include "ldap_util.h"
30*7c478bd9Sstevel@tonic-gate #include "ldap_print.h"
31*7c478bd9Sstevel@tonic-gate
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate void
printMappingFormat(__nis_mapping_format_t * f)34*7c478bd9Sstevel@tonic-gate printMappingFormat(__nis_mapping_format_t *f) {
35*7c478bd9Sstevel@tonic-gate __nis_value_t *val = getMappingFormat(f, 0, fa_any, 0, 0);
36*7c478bd9Sstevel@tonic-gate int i;
37*7c478bd9Sstevel@tonic-gate char *myself = "printMappingFormat";
38*7c478bd9Sstevel@tonic-gate
39*7c478bd9Sstevel@tonic-gate if (val == 0)
40*7c478bd9Sstevel@tonic-gate return;
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gate for (i = 0; i < val->numVals; i++) {
43*7c478bd9Sstevel@tonic-gate c2buf(myself, val->val[i].value, val->val[i].length);
44*7c478bd9Sstevel@tonic-gate }
45*7c478bd9Sstevel@tonic-gate freeValue(val, 1);
46*7c478bd9Sstevel@tonic-gate }
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gate void
printMappingFormatArray(__nis_mapping_format_t * a)49*7c478bd9Sstevel@tonic-gate printMappingFormatArray(__nis_mapping_format_t *a) {
50*7c478bd9Sstevel@tonic-gate __nis_value_t *val = getMappingFormatArray(a, 0, fa_any, 0, 0);
51*7c478bd9Sstevel@tonic-gate char *myself = "printMappingFormatArray";
52*7c478bd9Sstevel@tonic-gate
53*7c478bd9Sstevel@tonic-gate if (val != 0) {
54*7c478bd9Sstevel@tonic-gate if (val->type == vt_string) {
55*7c478bd9Sstevel@tonic-gate int i;
56*7c478bd9Sstevel@tonic-gate
57*7c478bd9Sstevel@tonic-gate if (a[0].type != mmt_begin)
58*7c478bd9Sstevel@tonic-gate p2buf(myself, "\"");
59*7c478bd9Sstevel@tonic-gate for (i = 0; i < val->numVals; i++) {
60*7c478bd9Sstevel@tonic-gate sc2buf(myself, val->val[i].value,
61*7c478bd9Sstevel@tonic-gate val->val[i].length);
62*7c478bd9Sstevel@tonic-gate }
63*7c478bd9Sstevel@tonic-gate } else {
64*7c478bd9Sstevel@tonic-gate p2buf(myself, "<illegal>");
65*7c478bd9Sstevel@tonic-gate }
66*7c478bd9Sstevel@tonic-gate freeValue(val, 1);
67*7c478bd9Sstevel@tonic-gate } else {
68*7c478bd9Sstevel@tonic-gate p2buf(myself, "<novals>");
69*7c478bd9Sstevel@tonic-gate }
70*7c478bd9Sstevel@tonic-gate }
71*7c478bd9Sstevel@tonic-gate
72*7c478bd9Sstevel@tonic-gate void
printIndex(__nis_index_t * i)73*7c478bd9Sstevel@tonic-gate printIndex(__nis_index_t *i) {
74*7c478bd9Sstevel@tonic-gate int len = 0;
75*7c478bd9Sstevel@tonic-gate char *str = getIndex(i, &len);
76*7c478bd9Sstevel@tonic-gate char *myself = "printIndex";
77*7c478bd9Sstevel@tonic-gate
78*7c478bd9Sstevel@tonic-gate sc2buf(myself, str, len);
79*7c478bd9Sstevel@tonic-gate sfree(str);
80*7c478bd9Sstevel@tonic-gate }
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gate void
printObjSpec(__nis_obj_spec_t * o)83*7c478bd9Sstevel@tonic-gate printObjSpec(__nis_obj_spec_t *o) {
84*7c478bd9Sstevel@tonic-gate int len = 0;
85*7c478bd9Sstevel@tonic-gate char *str = getObjSpec(o, &len);
86*7c478bd9Sstevel@tonic-gate char *myself = "printObjSpec";
87*7c478bd9Sstevel@tonic-gate
88*7c478bd9Sstevel@tonic-gate sc2buf(myself, str, len);
89*7c478bd9Sstevel@tonic-gate sfree(str);
90*7c478bd9Sstevel@tonic-gate }
91*7c478bd9Sstevel@tonic-gate
92*7c478bd9Sstevel@tonic-gate void
printSearchTriple(__nis_search_triple_t * s)93*7c478bd9Sstevel@tonic-gate printSearchTriple(__nis_search_triple_t *s) {
94*7c478bd9Sstevel@tonic-gate int len = 0;
95*7c478bd9Sstevel@tonic-gate char *str = getSearchTriple(s, &len);
96*7c478bd9Sstevel@tonic-gate char *myself = "printSearchTriple";
97*7c478bd9Sstevel@tonic-gate
98*7c478bd9Sstevel@tonic-gate sc2buf(myself, str, len);
99*7c478bd9Sstevel@tonic-gate sfree(str);
100*7c478bd9Sstevel@tonic-gate }
101*7c478bd9Sstevel@tonic-gate
102*7c478bd9Sstevel@tonic-gate void
printMappingItem(__nis_mapping_item_t * i,__nis_mapping_item_type_t native)103*7c478bd9Sstevel@tonic-gate printMappingItem(__nis_mapping_item_t *i, __nis_mapping_item_type_t native) {
104*7c478bd9Sstevel@tonic-gate __nis_value_t *val = getMappingItem(i, native, 0, 0, NULL);
105*7c478bd9Sstevel@tonic-gate int j;
106*7c478bd9Sstevel@tonic-gate char *myself = "printMappingItem";
107*7c478bd9Sstevel@tonic-gate
108*7c478bd9Sstevel@tonic-gate if (val == 0)
109*7c478bd9Sstevel@tonic-gate return;
110*7c478bd9Sstevel@tonic-gate
111*7c478bd9Sstevel@tonic-gate if (i->repeat)
112*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
113*7c478bd9Sstevel@tonic-gate for (j = 0; j < val->numVals; j++) {
114*7c478bd9Sstevel@tonic-gate c2buf(myself, val->val[j].value, val->val[j].length);
115*7c478bd9Sstevel@tonic-gate }
116*7c478bd9Sstevel@tonic-gate if (i->repeat)
117*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
118*7c478bd9Sstevel@tonic-gate freeValue(val, 1);
119*7c478bd9Sstevel@tonic-gate }
120*7c478bd9Sstevel@tonic-gate
121*7c478bd9Sstevel@tonic-gate void
printMappingSubElement(__nis_mapping_sub_element_t * e,__nis_mapping_item_type_t native)122*7c478bd9Sstevel@tonic-gate printMappingSubElement(__nis_mapping_sub_element_t *e,
123*7c478bd9Sstevel@tonic-gate __nis_mapping_item_type_t native) {
124*7c478bd9Sstevel@tonic-gate int i;
125*7c478bd9Sstevel@tonic-gate char *myself = "printMappingSubElement";
126*7c478bd9Sstevel@tonic-gate
127*7c478bd9Sstevel@tonic-gate switch (e->type) {
128*7c478bd9Sstevel@tonic-gate case me_item:
129*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.item, native);
130*7c478bd9Sstevel@tonic-gate break;
131*7c478bd9Sstevel@tonic-gate case me_print:
132*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
133*7c478bd9Sstevel@tonic-gate printMappingFormatArray(e->element.print.fmt);
134*7c478bd9Sstevel@tonic-gate for (i = 0; i < e->element.print.numItems; i++) {
135*7c478bd9Sstevel@tonic-gate p2buf(myself, ", ");
136*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.print.item[i], native);
137*7c478bd9Sstevel@tonic-gate }
138*7c478bd9Sstevel@tonic-gate if (e->element.print.doElide) {
139*7c478bd9Sstevel@tonic-gate p2buf(myself, ", \"%c\"", e->element.print.elide);
140*7c478bd9Sstevel@tonic-gate }
141*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
142*7c478bd9Sstevel@tonic-gate break;
143*7c478bd9Sstevel@tonic-gate case me_split:
144*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
145*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.split.item, native);
146*7c478bd9Sstevel@tonic-gate p2buf(myself, ", \"%c\")", e->element.split.delim);
147*7c478bd9Sstevel@tonic-gate break;
148*7c478bd9Sstevel@tonic-gate case me_match:
149*7c478bd9Sstevel@tonic-gate p2buf(myself, "<me_match>");
150*7c478bd9Sstevel@tonic-gate break;
151*7c478bd9Sstevel@tonic-gate case me_extract:
152*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
153*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.extract.item, native);
154*7c478bd9Sstevel@tonic-gate p2buf(myself, ", ");
155*7c478bd9Sstevel@tonic-gate printMappingFormatArray(e->element.extract.fmt);
156*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
157*7c478bd9Sstevel@tonic-gate break;
158*7c478bd9Sstevel@tonic-gate default:
159*7c478bd9Sstevel@tonic-gate p2buf(myself, "(<unknown>)");
160*7c478bd9Sstevel@tonic-gate break;
161*7c478bd9Sstevel@tonic-gate }
162*7c478bd9Sstevel@tonic-gate }
163*7c478bd9Sstevel@tonic-gate
164*7c478bd9Sstevel@tonic-gate void
printMappingElement(__nis_mapping_element_t * e,__nis_mapping_item_type_t native)165*7c478bd9Sstevel@tonic-gate printMappingElement(__nis_mapping_element_t *e,
166*7c478bd9Sstevel@tonic-gate __nis_mapping_item_type_t native) {
167*7c478bd9Sstevel@tonic-gate int i;
168*7c478bd9Sstevel@tonic-gate char *myself = "printMappingElement";
169*7c478bd9Sstevel@tonic-gate
170*7c478bd9Sstevel@tonic-gate switch (e->type) {
171*7c478bd9Sstevel@tonic-gate case me_item:
172*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.item, native);
173*7c478bd9Sstevel@tonic-gate break;
174*7c478bd9Sstevel@tonic-gate case me_print:
175*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
176*7c478bd9Sstevel@tonic-gate printMappingFormatArray(e->element.print.fmt);
177*7c478bd9Sstevel@tonic-gate for (i = 0; i < e->element.print.numSubElements; i++) {
178*7c478bd9Sstevel@tonic-gate p2buf(myself, ", ");
179*7c478bd9Sstevel@tonic-gate printMappingSubElement(
180*7c478bd9Sstevel@tonic-gate &e->element.print.subElement[i], native);
181*7c478bd9Sstevel@tonic-gate }
182*7c478bd9Sstevel@tonic-gate if (e->element.print.doElide) {
183*7c478bd9Sstevel@tonic-gate p2buf(myself, ", \"%c\"", e->element.print.elide);
184*7c478bd9Sstevel@tonic-gate }
185*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
186*7c478bd9Sstevel@tonic-gate break;
187*7c478bd9Sstevel@tonic-gate case me_split:
188*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
189*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.split.item, native);
190*7c478bd9Sstevel@tonic-gate p2buf(myself, ", \"%c\")", e->element.split.delim);
191*7c478bd9Sstevel@tonic-gate break;
192*7c478bd9Sstevel@tonic-gate case me_match:
193*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
194*7c478bd9Sstevel@tonic-gate printMappingFormatArray(e->element.match.fmt);
195*7c478bd9Sstevel@tonic-gate for (i = 0; i < e->element.match.numItems; i++) {
196*7c478bd9Sstevel@tonic-gate p2buf(myself, ", ");
197*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.match.item[i], native);
198*7c478bd9Sstevel@tonic-gate }
199*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
200*7c478bd9Sstevel@tonic-gate break;
201*7c478bd9Sstevel@tonic-gate case me_extract:
202*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
203*7c478bd9Sstevel@tonic-gate printMappingItem(&e->element.extract.item, native);
204*7c478bd9Sstevel@tonic-gate p2buf(myself, ", ");
205*7c478bd9Sstevel@tonic-gate printMappingFormatArray(e->element.extract.fmt);
206*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
207*7c478bd9Sstevel@tonic-gate break;
208*7c478bd9Sstevel@tonic-gate default:
209*7c478bd9Sstevel@tonic-gate p2buf(myself, "(<unknown>)");
210*7c478bd9Sstevel@tonic-gate break;
211*7c478bd9Sstevel@tonic-gate }
212*7c478bd9Sstevel@tonic-gate }
213*7c478bd9Sstevel@tonic-gate
214*7c478bd9Sstevel@tonic-gate void
printMappingRLHS(__nis_mapping_rlhs_t * m,__nis_mapping_item_type_t native)215*7c478bd9Sstevel@tonic-gate printMappingRLHS(__nis_mapping_rlhs_t *m, __nis_mapping_item_type_t native) {
216*7c478bd9Sstevel@tonic-gate int i;
217*7c478bd9Sstevel@tonic-gate char *myself = "printMappingRLHS";
218*7c478bd9Sstevel@tonic-gate
219*7c478bd9Sstevel@tonic-gate if (m->numElements > 1)
220*7c478bd9Sstevel@tonic-gate p2buf(myself, "(");
221*7c478bd9Sstevel@tonic-gate for (i = 0; i < m->numElements; i++) {
222*7c478bd9Sstevel@tonic-gate printMappingElement(&m->element[i], native);
223*7c478bd9Sstevel@tonic-gate }
224*7c478bd9Sstevel@tonic-gate if (m->numElements > 1)
225*7c478bd9Sstevel@tonic-gate p2buf(myself, ")");
226*7c478bd9Sstevel@tonic-gate }
227*7c478bd9Sstevel@tonic-gate
228*7c478bd9Sstevel@tonic-gate void
printMappingRule(__nis_mapping_rule_t * r,__nis_mapping_item_type_t nativeLhs,__nis_mapping_item_type_t nativeRhs)229*7c478bd9Sstevel@tonic-gate printMappingRule(__nis_mapping_rule_t *r,
230*7c478bd9Sstevel@tonic-gate __nis_mapping_item_type_t nativeLhs,
231*7c478bd9Sstevel@tonic-gate __nis_mapping_item_type_t nativeRhs) {
232*7c478bd9Sstevel@tonic-gate char *myself = "printMappingRule";
233*7c478bd9Sstevel@tonic-gate
234*7c478bd9Sstevel@tonic-gate printMappingRLHS(&r->lhs, nativeLhs);
235*7c478bd9Sstevel@tonic-gate p2buf(myself, "=");
236*7c478bd9Sstevel@tonic-gate printMappingRLHS(&r->rhs, nativeRhs);
237*7c478bd9Sstevel@tonic-gate }
238*7c478bd9Sstevel@tonic-gate
239*7c478bd9Sstevel@tonic-gate void
printObjName(__nis_index_t * index,char * name)240*7c478bd9Sstevel@tonic-gate printObjName(__nis_index_t *index, char *name) {
241*7c478bd9Sstevel@tonic-gate char *myself = "printObjName";
242*7c478bd9Sstevel@tonic-gate
243*7c478bd9Sstevel@tonic-gate printIndex(index);
244*7c478bd9Sstevel@tonic-gate p2buf(myself, "%s", NIL(name));
245*7c478bd9Sstevel@tonic-gate }
246*7c478bd9Sstevel@tonic-gate
247*7c478bd9Sstevel@tonic-gate void
printobjectDN(__nis_object_dn_t * o)248*7c478bd9Sstevel@tonic-gate printobjectDN(__nis_object_dn_t *o) {
249*7c478bd9Sstevel@tonic-gate char *myself = "printobjectDN";
250*7c478bd9Sstevel@tonic-gate int i;
251*7c478bd9Sstevel@tonic-gate
252*7c478bd9Sstevel@tonic-gate p2buf(myself, "\t");
253*7c478bd9Sstevel@tonic-gate printSearchTriple(&o->read);
254*7c478bd9Sstevel@tonic-gate p2buf(myself, ":\n\t");
255*7c478bd9Sstevel@tonic-gate printSearchTriple(&o->write);
256*7c478bd9Sstevel@tonic-gate switch (o->delDisp) {
257*7c478bd9Sstevel@tonic-gate case dd_always:
258*7c478bd9Sstevel@tonic-gate p2buf(myself, ":\n\t\talways");
259*7c478bd9Sstevel@tonic-gate break;
260*7c478bd9Sstevel@tonic-gate case dd_perDbId:
261*7c478bd9Sstevel@tonic-gate p2buf(myself, ":\n\t\tdbid=%s\n", NIL(o->dbIdName));
262*7c478bd9Sstevel@tonic-gate for (i = 0; i < o->numDbIds; i++) {
263*7c478bd9Sstevel@tonic-gate p2buf(myself, "\t\t\t");
264*7c478bd9Sstevel@tonic-gate printMappingRule(o->dbId[i], mit_ldap, mit_nisplus);
265*7c478bd9Sstevel@tonic-gate }
266*7c478bd9Sstevel@tonic-gate break;
267*7c478bd9Sstevel@tonic-gate case dd_never:
268*7c478bd9Sstevel@tonic-gate p2buf(myself, ":\n\t\tnever");
269*7c478bd9Sstevel@tonic-gate break;
270*7c478bd9Sstevel@tonic-gate default:
271*7c478bd9Sstevel@tonic-gate p2buf(myself, ":\n\t\t<unknown>");
272*7c478bd9Sstevel@tonic-gate }
273*7c478bd9Sstevel@tonic-gate }
274*7c478bd9Sstevel@tonic-gate
275*7c478bd9Sstevel@tonic-gate void
printTableMapping(__nis_table_mapping_t * t)276*7c478bd9Sstevel@tonic-gate printTableMapping(__nis_table_mapping_t *t) {
277*7c478bd9Sstevel@tonic-gate __nis_object_dn_t *o;
278*7c478bd9Sstevel@tonic-gate int i;
279*7c478bd9Sstevel@tonic-gate char *myself = "printTableMapping";
280*7c478bd9Sstevel@tonic-gate
281*7c478bd9Sstevel@tonic-gate p2buf(myself, "\n%s:", NIL(t->dbId));
282*7c478bd9Sstevel@tonic-gate printObjName(&t->index, t->objName);
283*7c478bd9Sstevel@tonic-gate p2buf(myself, "\n\t%s \t%s", NIL(t->objName), NIL(t->objPath));
284*7c478bd9Sstevel@tonic-gate p2buf(myself, "\n\tTTL = (%d - %d) -> %d\n",
285*7c478bd9Sstevel@tonic-gate t->initTtlLo, t->initTtlHi, t->ttl);
286*7c478bd9Sstevel@tonic-gate
287*7c478bd9Sstevel@tonic-gate for (o = t->objectDN; o != 0; o = o->next) {
288*7c478bd9Sstevel@tonic-gate printobjectDN(o);
289*7c478bd9Sstevel@tonic-gate p2buf(myself, "\n");
290*7c478bd9Sstevel@tonic-gate }
291*7c478bd9Sstevel@tonic-gate
292*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tLDAP -> NIS+\n");
293*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tRules:\n");
294*7c478bd9Sstevel@tonic-gate for (i = 0; i < t->numRulesFromLDAP; i++) {
295*7c478bd9Sstevel@tonic-gate p2buf(myself, "\t\t");
296*7c478bd9Sstevel@tonic-gate printMappingRule(t->ruleFromLDAP[i], mit_nisplus, mit_ldap);
297*7c478bd9Sstevel@tonic-gate p2buf(myself, "\n");
298*7c478bd9Sstevel@tonic-gate }
299*7c478bd9Sstevel@tonic-gate
300*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tNIS+ -> LDAP\n");
301*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tRules:\n");
302*7c478bd9Sstevel@tonic-gate for (i = 0; i < t->numRulesToLDAP; i++) {
303*7c478bd9Sstevel@tonic-gate p2buf(myself, "\t\t");
304*7c478bd9Sstevel@tonic-gate printMappingRule(t->ruleToLDAP[i], mit_ldap, mit_nisplus);
305*7c478bd9Sstevel@tonic-gate p2buf(myself, "\n");
306*7c478bd9Sstevel@tonic-gate }
307*7c478bd9Sstevel@tonic-gate }
308*7c478bd9Sstevel@tonic-gate
309*7c478bd9Sstevel@tonic-gate void
printRuleValue(__nis_rule_value_t * rv)310*7c478bd9Sstevel@tonic-gate printRuleValue(__nis_rule_value_t *rv) {
311*7c478bd9Sstevel@tonic-gate int i, j;
312*7c478bd9Sstevel@tonic-gate __nis_buffer_t b = {0, 0};
313*7c478bd9Sstevel@tonic-gate char *myself = "printRuleValue";
314*7c478bd9Sstevel@tonic-gate
315*7c478bd9Sstevel@tonic-gate if (rv == 0)
316*7c478bd9Sstevel@tonic-gate return;
317*7c478bd9Sstevel@tonic-gate
318*7c478bd9Sstevel@tonic-gate if (rv->colName != 0) {
319*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "Columns:\n");
320*7c478bd9Sstevel@tonic-gate for (i = 0; i < rv->numColumns; i++) {
321*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\t%s", NIL(rv->colName[i]));
322*7c478bd9Sstevel@tonic-gate if (rv->colVal[i].numVals == 1) {
323*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "=");
324*7c478bd9Sstevel@tonic-gate if (rv->colVal[i].type == vt_string)
325*7c478bd9Sstevel@tonic-gate sbc2buf(myself,
326*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[0].value,
327*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[0].length, &b);
328*7c478bd9Sstevel@tonic-gate else
329*7c478bd9Sstevel@tonic-gate bc2buf(myself,
330*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[0].value,
331*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[0].length, &b);
332*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\n");
333*7c478bd9Sstevel@tonic-gate } else {
334*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\n");
335*7c478bd9Sstevel@tonic-gate for (j = 0; j < rv->colVal[i].numVals; j++) {
336*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\t\t");
337*7c478bd9Sstevel@tonic-gate if (rv->colVal[i].type == vt_string)
338*7c478bd9Sstevel@tonic-gate sbc2buf(myself,
339*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[j].value,
340*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[j].length,
341*7c478bd9Sstevel@tonic-gate &b);
342*7c478bd9Sstevel@tonic-gate else
343*7c478bd9Sstevel@tonic-gate bc2buf(myself,
344*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[j].value,
345*7c478bd9Sstevel@tonic-gate rv->colVal[i].val[j].length,
346*7c478bd9Sstevel@tonic-gate &b);
347*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\n");
348*7c478bd9Sstevel@tonic-gate }
349*7c478bd9Sstevel@tonic-gate }
350*7c478bd9Sstevel@tonic-gate }
351*7c478bd9Sstevel@tonic-gate }
352*7c478bd9Sstevel@tonic-gate
353*7c478bd9Sstevel@tonic-gate if (rv->attrName != 0) {
354*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "Attributes:\n");
355*7c478bd9Sstevel@tonic-gate for (i = 0; i < rv->numAttrs; i++) {
356*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\t%s", NIL(rv->attrName[i]));
357*7c478bd9Sstevel@tonic-gate if (rv->attrVal[i].numVals == 1) {
358*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "=");
359*7c478bd9Sstevel@tonic-gate if (rv->attrVal[i].type == vt_string)
360*7c478bd9Sstevel@tonic-gate sbc2buf(myself,
361*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[0].value,
362*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[0].length,
363*7c478bd9Sstevel@tonic-gate &b);
364*7c478bd9Sstevel@tonic-gate else
365*7c478bd9Sstevel@tonic-gate bc2buf(myself,
366*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[0].value,
367*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[0].length,
368*7c478bd9Sstevel@tonic-gate &b);
369*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\n");
370*7c478bd9Sstevel@tonic-gate } else {
371*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\n");
372*7c478bd9Sstevel@tonic-gate for (j = 0; j < rv->attrVal[i].numVals; j++) {
373*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\t\t");
374*7c478bd9Sstevel@tonic-gate if (rv->attrVal[i].type == vt_string)
375*7c478bd9Sstevel@tonic-gate sbc2buf(myself,
376*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[j].value,
377*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[j].length,
378*7c478bd9Sstevel@tonic-gate &b);
379*7c478bd9Sstevel@tonic-gate else
380*7c478bd9Sstevel@tonic-gate bc2buf(myself,
381*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[j].value,
382*7c478bd9Sstevel@tonic-gate rv->attrVal[i].val[j].length,
383*7c478bd9Sstevel@tonic-gate &b);
384*7c478bd9Sstevel@tonic-gate bp2buf(myself, &b, "\n");
385*7c478bd9Sstevel@tonic-gate }
386*7c478bd9Sstevel@tonic-gate }
387*7c478bd9Sstevel@tonic-gate }
388*7c478bd9Sstevel@tonic-gate }
389*7c478bd9Sstevel@tonic-gate
390*7c478bd9Sstevel@tonic-gate c2buf(myself, b.buf, b.len);
391*7c478bd9Sstevel@tonic-gate sfree(b.buf);
392*7c478bd9Sstevel@tonic-gate printbuf();
393*7c478bd9Sstevel@tonic-gate }
394*7c478bd9Sstevel@tonic-gate
395*7c478bd9Sstevel@tonic-gate void
printLdapMod(LDAPMod ** mods,__nis_buffer_t * b)396*7c478bd9Sstevel@tonic-gate printLdapMod(LDAPMod **mods, __nis_buffer_t *b) {
397*7c478bd9Sstevel@tonic-gate LDAPMod *m;
398*7c478bd9Sstevel@tonic-gate char *s;
399*7c478bd9Sstevel@tonic-gate char *myself = "printLdapMod";
400*7c478bd9Sstevel@tonic-gate
401*7c478bd9Sstevel@tonic-gate if (mods == 0)
402*7c478bd9Sstevel@tonic-gate return;
403*7c478bd9Sstevel@tonic-gate
404*7c478bd9Sstevel@tonic-gate if (b == 0)
405*7c478bd9Sstevel@tonic-gate b = &pb;
406*7c478bd9Sstevel@tonic-gate
407*7c478bd9Sstevel@tonic-gate while ((m = *mods) != 0) {
408*7c478bd9Sstevel@tonic-gate if ((m->mod_op & LDAP_MOD_ADD) != 0 ||
409*7c478bd9Sstevel@tonic-gate (m->mod_op & ~LDAP_MOD_BVALUES) == 0) {
410*7c478bd9Sstevel@tonic-gate s = "ADD ";
411*7c478bd9Sstevel@tonic-gate } else if ((m->mod_op & LDAP_MOD_DELETE) != 0) {
412*7c478bd9Sstevel@tonic-gate s = "DELETE ";
413*7c478bd9Sstevel@tonic-gate } else if ((m->mod_op & LDAP_MOD_REPLACE) != 0) {
414*7c478bd9Sstevel@tonic-gate s = "REPLACE";
415*7c478bd9Sstevel@tonic-gate } else {
416*7c478bd9Sstevel@tonic-gate s = "UNKNOWN";
417*7c478bd9Sstevel@tonic-gate }
418*7c478bd9Sstevel@tonic-gate bp2buf(myself, b, "%s: %s\n", s, m->mod_type);
419*7c478bd9Sstevel@tonic-gate if ((m->mod_op & LDAP_MOD_BVALUES) == 0) {
420*7c478bd9Sstevel@tonic-gate char **v = m->mod_values;
421*7c478bd9Sstevel@tonic-gate
422*7c478bd9Sstevel@tonic-gate if (v != 0) {
423*7c478bd9Sstevel@tonic-gate while (*v != 0) {
424*7c478bd9Sstevel@tonic-gate bp2buf(myself, b, "\t%s\n", *v);
425*7c478bd9Sstevel@tonic-gate v++;
426*7c478bd9Sstevel@tonic-gate }
427*7c478bd9Sstevel@tonic-gate }
428*7c478bd9Sstevel@tonic-gate } else {
429*7c478bd9Sstevel@tonic-gate struct berval **bv = m->mod_bvalues;
430*7c478bd9Sstevel@tonic-gate
431*7c478bd9Sstevel@tonic-gate if (bv != 0) {
432*7c478bd9Sstevel@tonic-gate while (*bv != 0) {
433*7c478bd9Sstevel@tonic-gate bp2buf(myself, b, "\t<ber> %d bytes\n",
434*7c478bd9Sstevel@tonic-gate (*bv)->bv_len);
435*7c478bd9Sstevel@tonic-gate bv++;
436*7c478bd9Sstevel@tonic-gate }
437*7c478bd9Sstevel@tonic-gate }
438*7c478bd9Sstevel@tonic-gate }
439*7c478bd9Sstevel@tonic-gate mods++;
440*7c478bd9Sstevel@tonic-gate }
441*7c478bd9Sstevel@tonic-gate }
442*7c478bd9Sstevel@tonic-gate
443*7c478bd9Sstevel@tonic-gate static void
printObjRights(char * msg,void * access)444*7c478bd9Sstevel@tonic-gate printObjRights(char *msg, void *access) {
445*7c478bd9Sstevel@tonic-gate uchar_t *a = access;
446*7c478bd9Sstevel@tonic-gate int i;
447*7c478bd9Sstevel@tonic-gate
448*7c478bd9Sstevel@tonic-gate if (a == 0)
449*7c478bd9Sstevel@tonic-gate return;
450*7c478bd9Sstevel@tonic-gate
451*7c478bd9Sstevel@tonic-gate for (i = 0; i < 4; i++) {
452*7c478bd9Sstevel@tonic-gate p2buf(msg, "%s", (a[i] & NIS_READ_ACC) ? "r" : "-");
453*7c478bd9Sstevel@tonic-gate p2buf(msg, "%s", (a[i] & NIS_MODIFY_ACC) ? "m" : "-");
454*7c478bd9Sstevel@tonic-gate p2buf(msg, "%s", (a[i] & NIS_CREATE_ACC) ? "c" : "-");
455*7c478bd9Sstevel@tonic-gate p2buf(msg, "%s", (a[i] & NIS_DESTROY_ACC) ? "d" : "-");
456*7c478bd9Sstevel@tonic-gate }
457*7c478bd9Sstevel@tonic-gate }
458*7c478bd9Sstevel@tonic-gate
459*7c478bd9Sstevel@tonic-gate void
printObjAttr(__nis_obj_attr_t * attr)460*7c478bd9Sstevel@tonic-gate printObjAttr(__nis_obj_attr_t *attr) {
461*7c478bd9Sstevel@tonic-gate char *myself = "printObjAttr";
462*7c478bd9Sstevel@tonic-gate
463*7c478bd9Sstevel@tonic-gate if (attr == 0)
464*7c478bd9Sstevel@tonic-gate return;
465*7c478bd9Sstevel@tonic-gate
466*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tzo_owner = %s\n", NIL(attr->zo_owner));
467*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tzo_group = %s\n", NIL(attr->zo_group));
468*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tzo_domain = %s\n", NIL(attr->zo_domain));
469*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tzo_access = ");
470*7c478bd9Sstevel@tonic-gate printObjRights(myself, &attr->zo_access);
471*7c478bd9Sstevel@tonic-gate p2buf(myself, " (0x%08x)\n", attr->zo_access);
472*7c478bd9Sstevel@tonic-gate p2buf(myself, "\tzo_ttl = %d\n", attr->zo_ttl);
473*7c478bd9Sstevel@tonic-gate }
474