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