4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
31 * Routines to add tnrhdb and tnrhtp from /etc/security/tsol into LDAP.
32 * Can also be used to dump entries from a ldap container in /etc format.
41 #include <sys/tsol/tndb.h>
42 #include "ldapaddent.h"
44 extern int genent_attr(char *, int, entry_col
**);
47 genent_tnrhdb(char *line
, int (*cback
)())
54 * parse entry into columns
56 res
= genent_attr(line
, TNRHDB_NCOL
, &ecol
);
60 data
.address
= _do_unescape(ecol
[0].ec_value
.ec_value_val
);
61 data
.template = ecol
[1].ec_value
.ec_value_val
;
62 if (strchr(data
.address
, ':') == NULL
)
63 data
.family
= AF_INET
;
65 data
.family
= AF_INET6
;
67 if (flags
& F_VERBOSE
)
68 (void) printf(gettext("Adding entry : %s\n"), data
.address
);
70 retval
= (*cback
)(&data
, 1);
80 dump_tnrhdb(ns_ldap_result_t
*res
)
84 value
= __ns_ldap_getAttr(res
->entry
, "ipTnetNumber");
85 if (value
&& value
[0])
86 (void) printf("%s", value
[0]);
91 value
= __ns_ldap_getAttr(res
->entry
, "ipTnetTemplateName");
92 if (value
&& value
[0])
93 (void) printf("%s", value
[0]);
98 genent_tnrhtp(char *line
, int (*cback
)())
105 * parse entry into columns
107 res
= genent_attr(line
, TNRHTP_NCOL
, &ecol
);
108 if (res
!= GENENT_OK
)
111 data
.template = ecol
[0].ec_value
.ec_value_val
;
112 data
.attrs
= ecol
[1].ec_value
.ec_value_val
;
114 if (flags
& F_VERBOSE
)
115 (void) printf(gettext("Adding entry : %s\n"), data
.template);
117 retval
= (*cback
)(&data
, 1);
127 dump_tnrhtp(ns_ldap_result_t
*res
)
131 value
= __ns_ldap_getAttr(res
->entry
, "ipTnetTemplateName");
132 if (value
&& value
[0])
133 (void) printf("%s", value
[0]);
138 value
= __ns_ldap_getAttr(res
->entry
, "SolarisAttrKeyValue");
139 if (value
&& value
[0])
140 (void) printf("%s", value
[0]);
141 (void) putchar('\n');