/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*
* Copyright (c) 2004-2005, Novell, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* * The copyright holder's name is not used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
#include "ldap_main.h"
#include "ldap_realm.h"
#include "ldap_principal.h"
#include "ldap_pwd_policy.h"
#include "ldap_err.h"
#include <libintl.h> /* Solaris Kerberos */
"krbMaxTicketLife", "krbMaxRenewableAge",
"krbTicketFlags", "krbUpEnabled",
"krbTicketPolicyReference",
"krbLdapServers",
"krbKdcServers", "krbAdmServers",
"krbPwdServers", NULL};
"krbMaxRenewableAge",
"krbTicketFlags",
NULL };
/*
* list realms from eDirectory
*/
/*
* Function to remove all special characters from a string (rfc2254).
* Use whenever exact matching is to be done ...
*/
char *
{
switch (in[i]) {
case '*':
case '(':
case ')':
case '\\':
case '\0':
count ++;
}
switch (in[i]) {
case '*':
ptr[0] = '\\';
ptr += 3;
break;
case '(':
ptr[0] = '\\';
ptr += 3;
break;
case ')':
ptr[0] = '\\';
ptr += 3;
break;
case '\\':
ptr[0] = '\\';
ptr += 3;
break;
case '\0':
ptr[0] = '\\';
ptr += 3;
break;
default:
ptr += 1;
break;
}
/* ptr[count - 1] = '\0'; */
return out;
}
static int
/* Cross realm trust ... */
return 0;
return 1;
return 1;
return 0;
}
/*
* Lists the realms in the Directory.
*/
{
unsigned int i = 0;
int count = 0;
SETUP_CONTEXT ();
/* get the kerberos container DN information */
&(ldap_context->krbcontainer))) != 0)
goto cleanup;
}
/* get ldap handle */
GET_HANDLE ();
{
"(objectclass=krbRealmContainer)",
cn);
}
if (count == -1) {
goto cleanup;
}
CHECK_NULL(*realms);
count += 1;
}
} /* for (ent= ... */
/* some error, free up all the memory */
if (st != 0) {
if (*realms) {
}
}
}
/* If there are no elements, still return a NULL terminated array */
return st;
}
/*
* Delete the realm along with the principals belonging to the realm in the Directory.
*/
static void
{
}
{
SETUP_CONTEXT ();
goto cleanup;
}
goto cleanup;
/* get ldap handle */
GET_HANDLE ();
/* delete all the principals belonging to the realm in the tree */
{
/* LDAP_SEARCH(NULL, LDAP_SCOPE_SUBTREE, filter, attr); */
goto cleanup;
sizeof(LDAPMessage *));
if (result_arr == NULL) {
goto cleanup;
}
for (l=0; l < ntree; ++l) {
result_arr[l] = result;
}
}
/* NOTE: Here all the principals should be cached and the ldap handle should be freed,
* as a DAL-LDAP interface is called right down here. Caching might be constrained by
* availability of the memory. The caching is not done, however there would be limit
* on the minimum number of handles for a server and it is 2. As the DAL-LDAP is not
* thread-safe this should suffice.
*/
int nent = 0;
&nent)) != LDAP_SUCCESS)
goto cleanup;
}
}
}
}
}
/* Delete all password policies */
/* Delete all ticket policies */
{
goto cleanup;
}
}
/* Delete the realm object */
}
/* Solaris Kerberos */
if (result_arr)
if (subtrees) {
for (l=0; l < ntree; ++l) {
if (subtrees[l])
}
}
}
return st;
}
/*
* Modify the realm attributes in the Directory.
*/
int mask)
{
#ifdef HAVE_EDIRECTORY
int count=0;
#endif
#ifdef HAVE_EDIRECTORY
int i=0;
#endif
/* Solaris kerberos: oldmask isn't used */
/* int oldmask=0, objectmask=0,k=0; */
int objectmask=0,k=0;
if (mask == 0)
return 0;
return st;
}
SETUP_CONTEXT ();
/* Check validity of arguments */
#ifdef HAVE_EDIRECTORY
#endif
0) {
goto cleanup;
}
/* get ldap handle */
GET_HANDLE ();
/* Solaris kerberos: oldmask isn't used */
#if 0 /************** Begin IFDEF'ed OUT *******************************/
/* get the oldmask obtained from the krb5_ldap_read_realm_params */
{
} else {
return st;
}
}
#endif /**************** END IFDEF'ed OUT *******************************/
/* SUBTREE ATTRIBUTE */
if (mask & LDAP_REALM_SUBTREE) {
/*replace the subtrees with the present if the subtrees are present*/
&objectmask);
}
}
strval)) != 0) {
goto cleanup;
}
}
}
/* CONTAINERREF ATTRIBUTE */
if (mask & LDAP_REALM_CONTREF) {
&objectmask);
strvalprc)) != 0)
goto cleanup;
}
}
/* SEARCHSCOPE ATTRIBUTE */
if (mask & LDAP_REALM_SEARCHSCOPE) {
goto cleanup;
}
if (mask & LDAP_REALM_MAXRENEWLIFE) {
rparams->max_renewable_life)) != 0)
goto cleanup;
}
/* krbMaxTicketLife ATTRIBUTE */
if (mask & LDAP_REALM_MAXTICKETLIFE) {
goto cleanup;
}
/* krbTicketFlags ATTRIBUTE */
if (mask & LDAP_REALM_KRBTICKETFLAGS) {
goto cleanup;
}
#ifdef HAVE_EDIRECTORY
/* KDCSERVERS ATTRIBUTE */
if (mask & LDAP_REALM_KDCSERVERS) {
/* validate the server list */
&objectmask);
}
rparams->kdcservers)) != 0)
goto cleanup;
}
/* ADMINSERVERS ATTRIBUTE */
if (mask & LDAP_REALM_ADMINSERVERS) {
/* validate the server list */
&objectmask);
}
rparams->adminservers)) != 0)
goto cleanup;
}
/* PASSWDSERVERS ATTRIBUTE */
if (mask & LDAP_REALM_PASSWDSERVERS) {
/* validate the server list */
&objectmask);
}
rparams->passwdservers)) != 0)
goto cleanup;
}
/*
* Read the old values of the krbkdcservers, krbadmservers and
* krbpwdservers. This information is later used to decided the
*/
0,
0,
NULL,
NULL,
NULL,
0,
&result)) != LDAP_SUCCESS) {
goto cleanup;
}
if (ent) {
goto cleanup;
}
goto cleanup;
}
goto cleanup;
}
}
}
#endif
/* Realm modify opearation */
goto cleanup;
}
}
#ifdef HAVE_EDIRECTORY
* to the 4 servers' list.
*/
if (mask & LDAP_REALM_KDCSERVERS) {
goto cleanup;
/* find the deletions and additions to the server list */
if (oldkdcservers && newkdcservers)
/* delete the krbRealmReferences attribute from the servers that are dis-associated. */
if (oldkdcservers)
for (i=0; oldkdcservers[i]; ++i)
oldkdcservers[i]);
goto cleanup;
}
/* add the krbRealmReferences attribute from the servers that are associated. */
if (newkdcservers)
for (i=0; newkdcservers[i]; ++i)
newkdcservers[i]);
goto cleanup;
}
if (newkdcservers)
}
if (mask & LDAP_REALM_ADMINSERVERS) {
goto cleanup;
/* find the deletions and additions to the server list */
if (oldadminservers && newadminservers)
/* delete the krbRealmReferences attribute from the servers that are dis-associated. */
if (oldadminservers)
for (i=0; oldadminservers[i]; ++i)
"%s: ", oldadminservers[i]);
goto cleanup;
}
/* add the krbRealmReferences attribute from the servers that are associated. */
if (newadminservers)
for (i=0; newadminservers[i]; ++i)
newadminservers[i]);
goto cleanup;
}
if (newadminservers)
}
if (mask & LDAP_REALM_PASSWDSERVERS) {
goto cleanup;
/* find the deletions and additions to the server list */
if (oldpasswdservers && newpasswdservers)
/* delete the krbRealmReferences attribute from the servers that are dis-associated. */
if (oldpasswdservers)
for (i=0; oldpasswdservers[i]; ++i)
"%s: ", oldpasswdservers[i]);
goto cleanup;
}
/* add the krbRealmReferences attribute from the servers that are associated. */
if (newpasswdservers)
for (i=0; newpasswdservers[i]; ++i)
newpasswdservers[i]);
goto cleanup;
}
if (newpasswdservers)
}
#endif
#ifdef HAVE_EDIRECTORY
if (oldkdcservers) {
for (i=0; oldkdcservers[i]; ++i)
free(oldkdcservers[i]);
}
if (oldadminservers) {
for (i=0; oldadminservers[i]; ++i)
free(oldadminservers[i]);
}
if (oldpasswdservers) {
for (i=0; oldpasswdservers[i]; ++i)
free(oldpasswdservers[i]);
}
#endif
return st;
}
/*
* Create the Kerberos container in the Directory
*/
const
{
int pmask=0;
#ifdef HAVE_EDIRECTORY
int crmask=0;
#endif
SETUP_CONTEXT ();
/* get ldap handle */
GET_HANDLE ();
} else {
/* If the user has not given, use the default cn=Kerberos,cn=Security */
#ifdef HAVE_EDIRECTORY
#else
goto cleanup;
#endif
}
strval[0] = "krbContainer";
goto cleanup;
goto cleanup;
}
goto cleanup;
/* check if the policy reference value exists and is of krbticketpolicyreference object class */
&pmask);
strval)) != 0)
goto cleanup;
}
/* create the kerberos container */
krb5_set_error_message (context, st, gettext("Kerberos Container create FAILED: %s"), ldap_err2string(ost));
goto cleanup;
}
#ifdef HAVE_EDIRECTORY
/* free the mods array */
/* check whether the security container is bound to krbcontainerrefaux object class */
krbContainerRefclass, &crmask)) != 0) {
/* delete Kerberos Container, status ignored intentionally */
goto cleanup;
}
if (crmask == 0) {
/* Security Container is extended with krbcontainerrefaux object class */
strval[0] = "krbContainerRefAux";
goto cleanup;
}
strval[0] = kerberoscontdn;
goto cleanup;
/* update the security container with krbContainerReference attribute */
krb5_set_error_message (context, st, gettext("Security Container update FAILED: %s"), ldap_err2string(ost));
/* delete Kerberos Container, status ignored intentionally */
goto cleanup;
}
#endif
if (rdns)
return(st);
}
/*
* Delete the Kerberos container in the Directory
*/
const
{
SETUP_CONTEXT ();
/* get ldap handle */
GET_HANDLE ();
} else {
/* If the user has not given, use the default cn=Kerberos,cn=Security */
#ifdef HAVE_EDIRECTORY
#else
goto cleanup;
#endif
}
/* delete the kerberos container */
krb5_set_error_message (context, st, gettext("Kerberos Container delete FAILED: %s"), ldap_err2string(ost));
goto cleanup;
}
return(st);
}
/*
* Create Realm in eDirectory. This is used by kdb5_util
*/
int mask)
{
#ifdef HAVE_EDIRECTORY
#endif
char *realm_name;
SETUP_CONTEXT ();
/* Check input validity ... */
#ifdef HAVE_EDIRECTORY
#endif
0) {
return st;
}
&(ldap_context->krbcontainer))) != 0)
goto cleanup;
}
/* get ldap handle */
GET_HANDLE ();
CHECK_NULL(dn);
strval[0] = realm_name;
goto cleanup;
strval[0] = "top";
goto cleanup;
/* SUBTREE ATTRIBUTE */
if (mask & LDAP_REALM_SUBTREE) {
&objectmask);
}
}
goto cleanup;
}
}
}
/* CONTAINER REFERENCE ATTRIBUTE */
if (mask & LDAP_REALM_CONTREF) {
&objectmask);
contref)) != 0)
goto cleanup;
}
}
/* SEARCHSCOPE ATTRIBUTE */
if (mask & LDAP_REALM_SEARCHSCOPE) {
goto cleanup;
}
if (mask & LDAP_REALM_MAXRENEWLIFE) {
rparams->max_renewable_life)) != 0)
goto cleanup;
}
/* krbMaxTicketLife ATTRIBUTE */
if (mask & LDAP_REALM_MAXTICKETLIFE) {
goto cleanup;
}
/* krbTicketFlags ATTRIBUTE */
if (mask & LDAP_REALM_KRBTICKETFLAGS) {
goto cleanup;
}
#ifdef HAVE_EDIRECTORY
/* KDCSERVERS ATTRIBUTE */
if (mask & LDAP_REALM_KDCSERVERS) {
/* validate the server list */
&objectmask);
}
rparams->kdcservers)) != 0)
goto cleanup;
}
/* ADMINSERVERS ATTRIBUTE */
if (mask & LDAP_REALM_ADMINSERVERS) {
/* validate the server list */
&objectmask);
}
rparams->adminservers)) != 0)
goto cleanup;
}
/* PASSWDSERVERS ATTRIBUTE */
if (mask & LDAP_REALM_PASSWDSERVERS) {
/* validate the server list */
&objectmask);
}
rparams->passwdservers)) != 0)
goto cleanup;
}
#endif
/* realm creation operation */
goto cleanup;
}
#ifdef HAVE_EDIRECTORY
if (mask & LDAP_REALM_KDCSERVERS)
for (i=0; rparams->kdcservers[i]; ++i)
rparams->kdcservers[i]);
/* delete Realm, status ignored intentionally */
goto cleanup;
}
if (mask & LDAP_REALM_ADMINSERVERS)
for (i=0; rparams->adminservers[i]; ++i)
rparams->adminservers[i]);
/* delete Realm, status ignored intentionally */
goto cleanup;
}
if (mask & LDAP_REALM_PASSWDSERVERS)
for (i=0; rparams->passwdservers[i]; ++i)
rparams->passwdservers[i]);
/* delete Realm, status ignored intentionally */
goto cleanup;
}
#endif
if (dn)
return st;
}
/*
* Read the realm container configuration from eDirectory for the specified realm.
*/
{
#ifdef HAVE_EDIRECTORY
unsigned int count=0;
#endif
int x=0;
SETUP_CONTEXT ();
/* validate the input parameter */
goto cleanup;
}
/* read kerberos container, if not read already */
&(ldap_context->krbcontainer))) != 0)
goto cleanup;
}
/* get ldap handle */
GET_HANDLE ();
/* Initialize realm container structure */
/* allocate tl_data structure to store MASK information */
goto cleanup;
}
/* set the mask parameter to 0 */
*mask = 0;
/* set default values */
goto cleanup;
}
/* populate the realm name in the structure */
LDAP_SEARCH(rlparams->realmdn, LDAP_SCOPE_BASE, "(objectclass=krbRealmContainer)", realm_attributes);
/* This could happen when the DN used to bind and read the realm object
* does not have sufficient rights to read its attributes
*/
goto cleanup;
}
#if 0
#endif
goto cleanup;
}
/* Read the attributes */
{
goto cleanup;
}
for (x=0; x<rlparams->subtreecount; x++) {
goto cleanup;
}
}
*mask |= LDAP_REALM_SUBTREE;
}
goto cleanup;
}
*mask |= LDAP_REALM_CONTREF;
}
/* searchscope can be ONE-LEVEL or SUBTREE, else default to SUBTREE */
}
}
}
}
#ifdef HAVE_EDIRECTORY
goto cleanup;
}
goto cleanup;
}
goto cleanup;
}
#endif
}
/*
* If all of maxtktlife, maxrenewlife and ticketflags are not directly
* available, use the policy dn from the policy reference attribute, if
* available, to fetch the missing.
*/
krb5_set_error_message (context, st, gettext("Policy object read failed: %s"), ldap_err2string(ost));
goto cleanup;
}
if ((*mask & LDAP_REALM_MAXTICKETLIFE) == 0) {
}
}
if ((*mask & LDAP_REALM_MAXRENEWLIFE) == 0) {
}
}
if ((*mask & LDAP_REALM_KRBTICKETFLAGS) == 0) {
}
}
}
}
/* if there is an error, free allocated structures */
if (st != 0) {
}
return st;
}
/*
Free the krb5_ldap_realm_params.
*/
void
{
int i=0;
if (rparams) {
if (rparams->realm_name)
}
if (rparams->kdcservers) {
for (i=0; rparams->kdcservers[i]; ++i)
}
if (rparams->adminservers) {
for (i=0; rparams->adminservers[i]; ++i)
}
if (rparams->passwdservers) {
for (i=0; rparams->passwdservers[i]; ++i)
}
}
}
}
return;
}
/*
* ******************************************************************************
* DAL functions
* ******************************************************************************
*/
char **db_args)
{
return status;
}