/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <ctype.h>
#include <libintl.h>
#include <strings.h>
#include <stdio.h>
#include "../../../lib/libsldap/common/ns_sldap.h"
#define SAME 0
struct mapping {
char *database;
char *def_type;
char *objectclass;
char *actual_db;
};
#define PUBLICKEY 0
{"publickey", "uidnumber", "niskeyobject", "passwd"},
{"publickey", "cn", "niskeyobject", "host"},
};
#define PROF_ATTR_FILTER \
"(&(objectclass=SolarisProfAttr)(!(SolarisKernelSecurityPolicy=*))%s)"
#define TNRHTP_FILTER \
"(&(objectclass=ipTnetTemplate)(!(objectclass=ipTnetHost))%s)"
/* Malloc and print error message in case of failure */
}
/*
* Allocate memory for filter and user data. Set
* error to 1 if either of the mallocs fail.
* In addition, free the memory allocated for filter,
* if memory allocation for user data fails.
*/
error = 0; \
if (!ptr1) { \
error = 1; \
} \
else { \
if (!ptr2) { \
error = 1; \
} \
}
void
{
int i;
gettext("database default type objectclass\n"));
gettext("============= ================= =============\n"));
/* first dump auto_* and automount which are not in maplist[] */
"automount");
"automountMapName", "automountMap");
/* skip printing shadow */
continue;
if (!is_system_labeled()) {
/*
* do not print tnrhdb and tnrhtp if system is
* not configured with Trusted Extensions
*/
continue;
}
}
}
/*
* set_key routine to handle user specified keys.
* A key can be of the form: attribute=value or value.
* A filter is constructed from a set of keys specified in
* the form (|(key1)(key2)...(keyn))
* It returns: NULL if no keys are defined or
* the keyfilter as constructed above.
*/
char *
{
char *k, **karray;
char *tmpptr;
return (NULL);
if (key[1]) {
totlen += 3;
/* Allocate memory for '(|)' */
if (!keyfilter)
exit(2);
}
while ((k = *karray) != 0) {
if (keyeq) {
/* make enough room for (%s) */
} else {
/* make enough room for (%s=%s) */
}
if (keyfilter)
exit(2);
}
if (keyeq) {
"(%s)", k);
} else {
"(%s=%s)", attrtype, k);
}
karray++;
}
if (key[1]) {
/* We allocated memory for this earlier */
}
return (keyfilter);
}
/*
* A special set_key routine for to handle public keys.
* If the key starts with a digiti, view it as a user id.
* Otherwise, view it as a hostname.
* It returns: -1 no keys defined, 0 key defined but none for type
* specified, n>0 number of matches found.
*/
int
{
char *k, **karray;
int count = 0;
char *tmpptr;
return (-1);
}
while ((k = *karray) != 0) {
if (keyeq) {
/* make enough room for (%s) */
} else {
/* user type keys */
/* hosts type keys */
/* make enough room for (%s=%s) */
} else {
karray++;
continue;
}
}
if (pre_filter)
exit(2);
}
pre_filter = tmpptr;
if (keyeq) {
"(%s)", k);
} else {
"(%s=%s)", attrtype, k);
}
karray++;
count++;
}
if (count > 1) {
exit(2);
}
} else
*ret = pre_filter;
return (count);
}
/*
* publickey specific set_filter
* type 0 -> check for user publickeys
* type 1 -> check for hosts publickeys
*/
char *
{
char *userdata;
int rc;
short nomem = 0;
return (NULL);
}
switch (rc) {
case -1:
udatalen = 3;
if (!nomem) {
"objectclass=%s",
}
break;
case 0:
return (NULL);
default:
if (!nomem) {
"(&(objectclass=%s)%s)",
"(&(%%s)%s)", keyfilter);
}
}
} else {
filterlen = 14;
udatalen = 3;
if (!nomem) {
"objectclass=*");
}
} else {
if (!nomem) {
"(&(%%s)%s)", keyfilter);
}
}
}
#ifdef DEBUG
#endif /* DEBUG */
if (keyfilter)
if (nomem)
exit(2);
return (filter);
}
/* generic set_filter, this function is not thread safe */
char *
{
char *keyfilter;
short nomem;
return (NULL);
}
/*
* Check for version of the profile the client is using
*
* For version 1 profiles we do use nisMap and nisObject schema
* for backward compatibility with Solaris 8 clients.
*
* For version 2 profiles we use automountMap and automount as
* default attributes (which can then be overridden in libsldap
* if schema mapping is configured in the profile).
*
* If profile version is not available, use version 2 as default.
*/
/* should print a message here: using v2 defaults */
(void) __ns_ldap_freeError(&errorp);
} else {
v2 = 0;
(void) __ns_ldap_freeParam(¶mVal);
}
/*
* starts at 2 to skip over publickey databases.
* These databases are handled separately.
*/
dbpf = 1;
dbtp = 1;
== NULL) {
udatalen = 3;
if (dbpf)
+ 1;
else if (dbtp)
else
if (nomem)
goto done;
if (dbpf)
PROF_ATTR_FILTER, "");
else if (dbtp)
TNRHTP_FILTER, "");
else
maplist[i].objectclass);
} else {
if (dbpf)
+ 1;
else if (dbtp)
else
if (nomem)
goto done;
if (dbpf)
else if (dbtp)
else
"(&(%%s)%s)", keyfilter);
}
goto done;
}
}
/* special cases for automounter and other services */
/* auto_* services */
if (v2) {
!= NULL) {
if (!nomem) {
"(&(objectclass=automount)%s)",
"(&(%%s)%s)", keyfilter);
}
} else {
filterlen = 22;
udatalen = 3;
if (!nomem) {
"objectclass=automount", filterlen);
udatalen);
}
}
} else {
if (!nomem) {
"(&(objectclass=nisObject)%s)",
"(&(%%s)%s)", keyfilter);
}
} else {
filterlen = 22;
udatalen = 3;
if (!nomem) {
"objectclass=nisObject", filterlen);
udatalen);
}
}
}
goto done;
}
/* automount service */
if (v2) {
!= NULL) {
if (!nomem) {
"(&(objectclass=automountMap)%s)",
"(&(%%s)%s)", keyfilter);
}
} else {
filterlen = 25;
udatalen = 3;
if (!nomem) {
"objectclass=automountMap",
udatalen);
}
}
} else {
!= NULL) {
if (!nomem) {
"(&(objectclass=nisMap)%s)",
"(&(%%s)%s)", keyfilter);
}
} else {
filterlen = 19;
udatalen = 3;
if (!nomem) {
"objectclass=nisMap", filterlen);
udatalen);
}
}
}
goto done;
}
/* other services (catch all) */
filterlen = 14;
udatalen = 3;
nomem);
if (!nomem) {
}
} else {
nomem);
if (!nomem) {
}
}
done:
#ifdef DEBUG
#endif /* DEBUG */
if (keyfilter)
if (nomem)
exit(2);
return (filter);
}