summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2010-10-08 13:10:43 -0700
committerNathan Kinder <nkinder@redhat.com>2010-10-08 13:10:43 -0700
commite766b5a9e07666b95d8ba505bd512adccd41d8a3 (patch)
tree17a0658dc44db9c9441e5dbc30d8fa2a26546018 /ldap/servers/plugins
parent3604c48b86e6b6feea63f99bebfecaa346d2bf59 (diff)
downloadds-e766b5a9e07666b95d8ba505bd512adccd41d8a3.tar.gz
ds-e766b5a9e07666b95d8ba505bd512adccd41d8a3.tar.xz
ds-e766b5a9e07666b95d8ba505bd512adccd41d8a3.zip
Bug 631993 - Log authzid when proxy auth control is used
This patch makes the access log entries for search, add, mod, del, and modrdn operations display the authzid that is used when the proxy authorization control is sent by the client.
Diffstat (limited to 'ldap/servers/plugins')
-rw-r--r--ldap/servers/plugins/acl/acl.h2
-rw-r--r--ldap/servers/plugins/acl/acleffectiverights.c2
-rw-r--r--ldap/servers/plugins/acl/aclplugin.c2
-rw-r--r--ldap/servers/plugins/acl/aclproxy.c247
4 files changed, 2 insertions, 251 deletions
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index 3f4b4e62..9634f05c 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -822,8 +822,6 @@ void acl_set_aclsignature( short value);
void acl_regen_aclsignature();
struct acl_pblock * acl_new_proxy_aclpb( Slapi_PBlock *pb );
void acl_set_authorization_dn( Slapi_PBlock *pb, char *dn, int type );
-int acl_get_proxyauth_dn( Slapi_PBlock *pb, char **proxydnp,
- char **errtextp );
void acl_init_aclpb ( Slapi_PBlock *pb , Acl_PBlock *aclpb,
const char *dn, int copy_from_aclcb);
int acl_create_aclpb_pool ();
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index 5edce85b..0335a1e1 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -124,7 +124,7 @@ _ger_g_permission_granted (
/*
* The requestor may be either the bind dn or a proxy dn
*/
- acl_get_proxyauth_dn ( pb, &proxydn, &errtext );
+ proxyauth_get_dn ( pb, &proxydn, &errtext );
if ( proxydn != NULL )
{
requestor_sdn = slapi_sdn_new_dn_passin ( proxydn );
diff --git a/ldap/servers/plugins/acl/aclplugin.c b/ldap/servers/plugins/acl/aclplugin.c
index d54250d5..66ef7071 100644
--- a/ldap/servers/plugins/acl/aclplugin.c
+++ b/ldap/servers/plugins/acl/aclplugin.c
@@ -220,7 +220,7 @@ aclplugin_preop_common( Slapi_PBlock *pb )
* is the "proxy master".
*/
proxy_dn = NULL;
- if ( LDAP_SUCCESS != ( lderr = acl_get_proxyauth_dn( pb, &proxy_dn,
+ if ( LDAP_SUCCESS != ( lderr = proxyauth_get_dn( pb, &proxy_dn,
&errtext ))) {
/*
* Fatal error -- send a result to the client and arrange to skip
diff --git a/ldap/servers/plugins/acl/aclproxy.c b/ldap/servers/plugins/acl/aclproxy.c
deleted file mode 100644
index 46eb437a..00000000
--- a/ldap/servers/plugins/acl/aclproxy.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * In addition, as a special exception, Red Hat, Inc. gives You the additional
- * right to link the code of this Program with code not covered under the GNU
- * General Public License ("Non-GPL Code") and to distribute linked combinations
- * including the two, subject to the limitations in this paragraph. Non-GPL Code
- * permitted under this exception must only link to the code of this Program
- * through those well defined interfaces identified in the file named EXCEPTION
- * found in the source code files (the "Approved Interfaces"). The files of
- * Non-GPL Code may instantiate templates or use macros or inline functions from
- * the Approved Interfaces without causing the resulting work to be covered by
- * the GNU General Public License. Only Red Hat, Inc. may make changes or
- * additions to the list of Approved Interfaces. You must obey the GNU General
- * Public License in all respects for all of the Program code and other code used
- * in conjunction with the Program except the Non-GPL Code covered by this
- * exception. If you modify this file, you may extend this exception to your
- * version of the file, but you are not obligated to do so. If you do not wish to
- * provide this exception without modification, you must delete this exception
- * statement from your version and license this file solely under the GPL without
- * exception.
- *
- *
- * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "acl.h"
-
-#define BEGIN do {
-#define END } while(0);
-
-/* ------------------------------------------------------------
- * LDAPProxyAuth
- *
- * ProxyAuthControl ::= SEQUENCE {
- * authorizationDN LDAPDN
- * }
- */
-struct LDAPProxyAuth
-{
- char *auth_dn;
-};
-typedef struct LDAPProxyAuth LDAPProxyAuth;
-
-/*
- * delete_LDAPProxyAuth
- */
-static void
-delete_LDAPProxyAuth(LDAPProxyAuth *spec)
-{
- if (!spec) return;
-
- slapi_ch_free((void**)&spec->auth_dn);
- slapi_ch_free((void**)&spec);
-}
-
-/*
- * parse_LDAPProxyAuth
- *
- * Parse a BER encoded value into the compoents of the LDAP ProxyAuth control.
- * The 'version' parameter should be 1 or 2.
- *
- * Returns an LDAP error code (LDAP_SUCCESS if all goes well) and sets
- * *errtextp if appropriate.
- */
-static int
-parse_LDAPProxyAuth(struct berval *spec_ber, int version, char **errtextp,
- LDAPProxyAuth **out)
-{
- int lderr = LDAP_OPERATIONS_ERROR; /* pessimistic */
- LDAPProxyAuth *spec = NULL;
- BerElement *ber = NULL;
- char *errstring = "unable to parse proxied authorization control";
- int rc = 0;
- char *normed = NULL;
- size_t dnlen = 0;
-
- BEGIN
- ber_tag_t tag;
-
- if ( version != 1 && version != 2 ) {
- break;
- }
-
- if ( !spec_ber || !spec_ber->bv_val ) {
- break;
- }
-
- /* create_LDAPProxyAuth */
- spec = (LDAPProxyAuth*)slapi_ch_calloc(1,sizeof (LDAPProxyAuth));
- if (!spec) {
- break;
- }
-
- ber = ber_init(spec_ber);
- if (!ber) {
- break;
- }
-
- if ( version == 1 ) {
- tag = ber_scanf(ber, "{a}", &spec->auth_dn);
- } else {
- tag = ber_scanf(ber, "a", &spec->auth_dn);
- }
- if (tag == LBER_ERROR) {
- lderr = LDAP_PROTOCOL_ERROR;
- break;
- }
-
- /*
- * In version 2 of the control, the control value is actually an
- * authorization ID (see section 9 of RFC 2829). We only support
- * the "dnAuthzId" flavor, which looks like "dn:<DN>" where <DN> is
- * an actual DN, e.g., "dn:uid=bjensen,dc=example,dc=com". So we
- * need to strip off the dn: if present and reject the operation if
- * not.
- */
- if (2 == version) {
- if ( NULL == spec->auth_dn || strlen( spec->auth_dn ) < 3 ||
- strncmp( "dn:", spec->auth_dn, 3 ) != 0 ) {
- lderr = LDAP_INSUFFICIENT_ACCESS; /* per Proxied Auth. I-D */
- errstring = "proxied authorization id must be a DN (dn:...)";
- break;
- }
- /* memmove is safe for overlapping copy */
- memmove ( spec->auth_dn, spec->auth_dn + 3, strlen(spec->auth_dn) - 2);/* 1 for '\0' */
- }
-
- lderr = LDAP_SUCCESS; /* got it! */
- rc = slapi_dn_normalize_ext(spec->auth_dn, 0, &normed, &dnlen);
- if (rc < 0) {
- lderr = LDAP_INVALID_SYNTAX;
- } else if (rc == 0) { /* spec->auth_dn is passed in; not terminated */
- *(normed + dnlen) = '\0';
- } else {
- slapi_ch_free_string(&spec->auth_dn);
- spec->auth_dn = normed;
- }
- END
-
- /* Cleanup */
- if (ber) ber_free(ber, 0);
-
- if ( LDAP_SUCCESS != lderr)
- {
- if (spec) delete_LDAPProxyAuth(spec);
- spec = 0;
- if ( NULL != errtextp ) {
- *errtextp = errstring;
- }
- }
-
- *out = spec;
-
- return lderr;
-}
-
-/*
- * proxyauth_dn - find the users DN in the proxyauth control if it is
- * present. The return value has been malloced for you.
- *
- * Returns an LDAP error code. If anything than LDAP_SUCCESS is returned,
- * the error should be returned to the client. LDAP_SUCCESS is always
- * returned if the proxy auth control is not present or not critical.
- */
-int
-acl_get_proxyauth_dn( Slapi_PBlock *pb, char **proxydnp, char **errtextp )
-{
- char *dn = 0;
- LDAPProxyAuth *spec = 0;
- int rv, lderr = LDAP_SUCCESS; /* optimistic */
-
- BEGIN
- struct berval *spec_ber;
- LDAPControl **controls;
- int present;
- int critical;
- int version = 1;
-
- rv = slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
- if (rv) break;
-
- present = slapi_control_present( controls, LDAP_CONTROL_PROXYAUTH,
- &spec_ber, &critical );
- if (!present) {
- present = slapi_control_present( controls, LDAP_CONTROL_PROXIEDAUTH,
- &spec_ber, &critical );
- if (!present) break;
- version = 2;
- /*
- * Note the according to the Proxied Authorization I-D, the
- * control is always supposed to be marked critical by the
- * client. If it is not, we return a protocolError.
- */
- if ( !critical ) {
- lderr = LDAP_PROTOCOL_ERROR;
- if ( NULL != errtextp ) {
- *errtextp = "proxy control must be marked critical";
- }
- break;
- }
- }
-
- rv = parse_LDAPProxyAuth(spec_ber, version, errtextp, &spec);
- if (LDAP_SUCCESS != rv) {
- if ( critical ) {
- lderr = rv;
- }
- break;
- }
-
- dn = slapi_ch_strdup(spec->auth_dn);
- if (slapi_dn_isroot(dn) ) {
- lderr = LDAP_UNWILLING_TO_PERFORM;
- *errtextp = "Proxy dn should not be rootdn";
- break;
-
- }
- END
-
- if (spec) delete_LDAPProxyAuth(spec);
-
- if ( NULL != proxydnp ) {
- *proxydnp = dn;
- } else {
- slapi_ch_free( (void **)&dn );
- }
-
- return lderr;
-}
-