Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 309025 Details for
Bug 450989
memberOf: Make group and memberOf attributes configurable
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
New memberof_config.c source file
memberof_config.c (text/plain), 8.09 KB, created by
Nathan Kinder
on 2008-06-12 04:16:21 UTC
(
hide
)
Description:
New memberof_config.c source file
Filename:
MIME Type:
Creator:
Nathan Kinder
Created:
2008-06-12 04:16:21 UTC
Size:
8.09 KB
patch
obsolete
>/** 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) 2008 Red Hat, Inc. > * All rights reserved. > * END COPYRIGHT BLOCK **/ > >#ifdef HAVE_CONFIG_H ># include <config.h> >#endif > >/* > * memberof_config.c - configuration-related code for memberOf plug-in > * > */ > >#include <plstr.h> > >#include "memberof.h" > >#define MEMBEROF_CONFIG_FILTER "(objectclass=*)" > >/* > * The configuration attributes are contained in the plugin entry e.g. > * cn=MemberOf Plugin,cn=plugins,cn=config > * > * Configuration is a two step process. The first pass is a validation step which > * occurs pre-op - check inputs and error out if bad. The second pass actually > * applies the changes to the run time config. > */ > > >/* > * function prototypes > */ >static int memberof_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, > int *returncode, char *returntext, void *arg); >static int memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, > int *returncode, char *returntext, void *arg); >static int memberof_search (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, > int *returncode, char *returntext, void *arg) >{ > return SLAPI_DSE_CALLBACK_OK; >} > >/* > * static variables > */ >/* for now, there is only one configuration and it is global to the plugin */ >static int inited = 0; > > >static int dont_allow_that(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, > int *returncode, char *returntext, void *arg) >{ > *returncode = LDAP_UNWILLING_TO_PERFORM; > return SLAPI_DSE_CALLBACK_ERROR; >} > >/* > * Read configuration and create a configuration data structure. > * This is called after the server has configured itself so we can > * perform checks with regards to suffixes if it ever becomes > * necessary. > * Returns an LDAP error code (LDAP_SUCCESS if all goes well). > */ >int >memberof_config(Slapi_Entry *config_e) >{ > int returncode = LDAP_SUCCESS; > char returntext[SLAPI_DSE_RETURNTEXT_SIZE]; > > if ( inited ) { > slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, > "only one memberOf plugin instance can be used\n" ); > return( LDAP_PARAM_ERROR ); > } > > /* initialize fields */ > if (SLAPI_DSE_CALLBACK_OK == memberof_validate_config(NULL, NULL, config_e, > &returncode, returntext, NULL)) { > memberof_apply_config(NULL, NULL, config_e, > &returncode, returntext, NULL); > } > > /* config DSE must be initialized before we get here */ > if (returncode == LDAP_SUCCESS) { > const char *config_dn = slapi_entry_get_dn_const(config_e); > slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE, > MEMBEROF_CONFIG_FILTER, memberof_validate_config,NULL); > slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_POSTOP, config_dn, LDAP_SCOPE_BASE, > MEMBEROF_CONFIG_FILTER, memberof_apply_config,NULL); > slapi_config_register_callback(SLAPI_OPERATION_MODRDN, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE, > MEMBEROF_CONFIG_FILTER, dont_allow_that, NULL); > slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE, > MEMBEROF_CONFIG_FILTER, dont_allow_that, NULL); > slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, config_dn, LDAP_SCOPE_BASE, > MEMBEROF_CONFIG_FILTER, memberof_search,NULL); > } > > inited = 1; > > if (returncode != LDAP_SUCCESS) { > slapi_log_error(SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM, > "Error %d: %s\n", returncode, returntext); > } > > return returncode; >} > > >/* > Validate the pending changes in the e entry. >*/ >static int >memberof_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, > int *returncode, char *returntext, void *arg) >{ > Slapi_Attr *attr = NULL; > > *returncode = LDAP_UNWILLING_TO_PERFORM; /* be pessimistic */ > > /* Make sure both the group attr and the memberOf attr > * config atributes are supplied. We don't care about &attr > * here, but slapi_entry_attr_find() requires us to pass it. */ > if (!slapi_entry_attr_find(e, MEMBEROF_GROUP_ATTR, &attr) && > !slapi_entry_attr_find(e, MEMBEROF_ATTR, &attr)) > { > *returncode = LDAP_SUCCESS; > } else { > PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, > "The %s and %s configuration attributes must be provided", > MEMBEROF_GROUP_ATTR, MEMBEROF_ATTR); > } > > if (*returncode != LDAP_SUCCESS) > { > return SLAPI_DSE_CALLBACK_ERROR; > } > else > { > return SLAPI_DSE_CALLBACK_OK; > } >} > > >/* > Apply the pending changes in the e entry to our config struct. > validate must have already been called >*/ >static int >memberof_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, > int *returncode, char *returntext, void *arg) >{ > char *groupattr = NULL; > char *memberof_attr = NULL; > char *filter_str = NULL; > int filter_size = 0; > > *returncode = LDAP_SUCCESS; > > groupattr = slapi_entry_attr_get_charptr(e, MEMBEROF_GROUP_ATTR); > memberof_attr = slapi_entry_attr_get_charptr(e, MEMBEROF_ATTR); > > /* We want to be sure we don't change the config in the middle of > * a memberOf operation, so we obtain the lock here */ > memberof_lock(); > > if (!theConfig.groupattr || > (groupattr && PL_strcmp(theConfig.groupattr, groupattr))) { > slapi_ch_free_string(&theConfig.groupattr); > theConfig.groupattr = groupattr; > groupattr = NULL; /* config now owns memory */ > > /* The filter is based off of the groupattr, so we > * update it here too. */ > slapi_filter_free(theConfig.group_filter, 1); > filter_size = (strlen(theConfig.groupattr) + 5); /* 5 for (=*) + null */ > filter_str = (char*)slapi_ch_malloc(filter_size); > sprintf(filter_str, "(%s=*)", theConfig.groupattr); > theConfig.group_filter = slapi_str2filter(filter_str); > slapi_ch_free_string(&filter_str); > } > > if (!theConfig.memberof_attr || > (memberof_attr && PL_strcmp(theConfig.memberof_attr, memberof_attr))) { > slapi_ch_free_string(&theConfig.memberof_attr); > theConfig.memberof_attr = memberof_attr; > memberof_attr = NULL; /* config now owns memory */ > } > > /* release the lock */ > memberof_unlock(); > > slapi_ch_free_string(&groupattr); > slapi_ch_free_string(&memberof_attr); > > if (*returncode != LDAP_SUCCESS) > { > return SLAPI_DSE_CALLBACK_ERROR; > } > else > { > return SLAPI_DSE_CALLBACK_OK; > } >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 450989
:
309023
|
309024
|
309025
|
309681
|
309682
|
309683
|
309753
|
309754
|
309755
|
309804
|
309805
|
309806