mapping.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <libintl.h>
#include <strings.h>
#include <stdio.h>
#include "../../../lib/libsldap/common/ns_sldap.h"
#define MAXLINE 2000
#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"},
};
void
{
int i;
gettext("database default type objectclass\n"));
gettext("============= ================= =============\n"));
/* first dump auto_* and automount which are not in maplist[] */
"automount");
"automountMap");
/* skip printing shadow */
}
}
char *
{
char typeeq[100];
char buf[100];
char *k, **karray;
return (NULL);
if (attrtype) {
}
keyfilter[0] = '\0';
if (key[1])
while (k = *karray) {
gettext("***ERROR: ldapfilter too long\n"));
exit(2);
}
karray++;
}
if (key[1])
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 pre_filter[MAXLINE];
char buf[100];
char *k, **karray;
int count = 0;
return (-1);
}
keyfilter[0] = '\0';
pre_filter[0] = '\0';
while (k = *karray) {
if (keyeq)
else {
/* user type keys */
/* hosts type keys */
} else {
karray++;
continue;
}
}
gettext("***ERROR: ldapfilter too long\n"));
exit(2);
}
karray++;
count++;
}
if (count > 1) {
gettext("***ERROR: ldapfilter too long\n"));
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 *filter;
char *userdata;
char *keyfilter;
int rc;
if (!database) {
return (NULL);
}
if (!udata) {
return (NULL);
}
if (!filter) {
return (NULL);
}
filter[0] = '\0';
if (!userdata) {
return (NULL);
}
userdata[0] = '\0';
&keyfilter);
switch (rc) {
case -1:
break;
case 0:
return (NULL);
default:
}
} else {
} else {
}
}
#ifdef DEBUG
#endif /* DEBUG */
return (filter);
}
/* generic set_filter, this function is not thread safe */
char *
{
char *filter;
char *userdata;
char *keyfilter;
int i;
if (!database) {
return (NULL);
}
if (!udata) {
return (NULL);
}
if (!filter) {
return (NULL);
}
filter[0] = '\0';
if (!userdata) {
return (NULL);
}
userdata[0] = '\0';
/*
* 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.
*/
== NULL) {
maplist[i].objectclass);
} else {
"(&(objectclass=%s)%s)",
#ifdef DEBUG
#endif /* DEBUG */
}
return (filter);
}
}
/* special cases for automounter and other services */
/* auto_* services */
if (v2) {
!= NULL) {
"(&(objectclass=automount)%s)", keyfilter);
} else {
}
} else {
!= NULL) {
"(&(objectclass=nisObject)%s)", keyfilter);
} else {
}
}
goto done;
}
/* automount service */
if (v2) {
!= NULL) {
"(&(objectclass=automountMap)%s)", keyfilter);
} else {
}
} else {
!= NULL) {
} else {
}
}
goto done;
}
/* other services (catch all) */
} else {
}
done:
#ifdef DEBUG
#endif /* DEBUG */
return (filter);
}