Procházet zdrojové kódy

Revert "Ticket #47431 - Duplicate values for the attribute nsslapd-pluginarg are not handled correctly"

This reverts commit d2c5b35e20578043117f84e928d96d296bdfc046.

This commit caused a regression by introducing a hard-coded limit to
the number of plug-in arguments for some plug-ins.  This needs to be
solved in a different way that doesn't limit the number of arguments.
Nathan Kinder před 12 roky
rodič
revize
33da8586d7
2 změnil soubory, kde provedl 3 přidání a 98 odebrání
  1. 0 16
      ldap/schema/01core389.ldif
  2. 3 82
      ldap/servers/slapd/plugin.c

+ 0 - 16
ldap/schema/01core389.ldif

@@ -153,22 +153,6 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2152 NAME 'nsds5ReplicaProtocolTimeout'
 attributeTypes: ( 2.16.840.1.113730.3.1.2154 NAME 'nsds5ReplicaBackoffMin' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
 attributeTypes: ( 2.16.840.1.113730.3.1.2155 NAME 'nsds5ReplicaBackoffMax' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
 attributeTypes: ( 2.16.840.1.113730.3.1.2156 NAME 'nsslapd-sasl-max-buffer-size' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2161 NAME 'nsslapd-pluginArg0' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2162 NAME 'nsslapd-pluginArg1' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2163 NAME 'nsslapd-pluginArg2' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2164 NAME 'nsslapd-pluginArg3' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2165 NAME 'nsslapd-pluginArg4' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2166 NAME 'nsslapd-pluginArg5' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2167 NAME 'nsslapd-pluginArg6' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2168 NAME 'nsslapd-pluginArg7' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2169 NAME 'nsslapd-pluginArg8' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2170 NAME 'nsslapd-pluginArg9' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2171 NAME 'nsslapd-pluginArg10' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2172 NAME 'nsslapd-pluginArg11' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2173 NAME 'nsslapd-pluginArg12' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2174 NAME 'nsslapd-pluginArg13' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2175 NAME 'nsslapd-pluginArg14' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2176 NAME 'nsslapd-pluginArg15' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
 #
 # objectclasses
 #

+ 3 - 82
ldap/servers/slapd/plugin.c

@@ -54,11 +54,6 @@
 #define ROOT_BIND			"directory manager"
 #define ANONYMOUS_BIND		"anonymous"
 
-/* This defines the maximum number that an nsslapd-pluginArg attribute can have.
- * A plugin can have 16 arguments nsslapd-pluginArg0 to nsslapd-pluginArg15 
- */
-#define MAX_PLUGINARG_NUM 15
-
 /* Forward Declarations */
 static int plugin_call_list (struct slapdplugin *list, int operation, Slapi_PBlock *pb);
 static int plugin_call_one (struct slapdplugin *list, int operation, Slapi_PBlock *pb);
@@ -2106,19 +2101,8 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
 	int status = 0;
 	int enabled = 1;
 	char *configdir = 0;
-	int diff = 0;
-	int index_prev = 0;
-	char attr_prev[BUFSIZ];
- 	int rc = 0;
-        int num_args = 0;
-        Slapi_Attr *newattr = 0;
-        int arg_length = 0;
-	char *attrnamenum = NULL;
-	char *attr_prevnum = NULL;
-	int numsize = 0;
 
 	attrname[0] = '\0';
-	attr_prev[0] = '\0';
 
 	if (!slapi_entry_get_sdn_const(plugin_entry))
 	{
@@ -2298,78 +2282,15 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
 	}
 
 	/* add the plugin arguments */
-	rc = 0;
-	arg_length = strlen(ATTR_PLUGIN_ARG);
-
-        for (rc = slapi_entry_first_attr(plugin_entry, &newattr); !rc && newattr; rc = slapi_entry_next_attr(plugin_entry, newattr, &newattr))
-	{
-                char *type = NULL;
-                slapi_attr_get_type(newattr, &type);
-                if (strncasecmp(type, ATTR_PLUGIN_ARG, arg_length) == 0)
-		{
-			char *ptr = type;
-			ptr += arg_length;
-			int numdigits = 0;
-			char *ptr_num = ptr;
-			if ((*ptr == '\0') || ((*ptr == '0') && (*(ptr+1) != '\0')))
-			{
-				slapi_log_error( SLAPI_LOG_FATAL, plugin->plg_dn, "Invalid Plugin argument: %s. Argument ignored\n", type);
-				continue;
-			}
-			while(*ptr != '\0')
-			{
-				if (!isdigit(*ptr))
-				{
-					slapi_log_error( SLAPI_LOG_FATAL, plugin->plg_dn, "Invalid Plugin argument: %s. Argument ignored\n", type);
-					break;
-				}
-				numdigits++;
-				ptr++;
-			}
- 			if (*ptr == '\0') 
-			{
-				if ((numdigits < 3) && (atoi(ptr_num) <= MAX_PLUGINARG_NUM))
-					num_args++;
-				else
-				{
-					slapi_log_error( SLAPI_LOG_FATAL, plugin->plg_dn, "Plugin argument value nsslapd-pluginArg%s exceeded maximum allowed value nsslapd-pluginArg%d\n", ptr_num, MAX_PLUGINARG_NUM);
-					status = -1;
-                			goto PLUGIN_CLEANUP;
-				}
-			}
-		}
-        }
-
-	PR_snprintf(attrname, sizeof(attrname), "%s", ATTR_PLUGIN_ARG);
-	PR_snprintf(attr_prev, sizeof(attr_prev), "%s", ATTR_PLUGIN_ARG);
-	attrnamenum = attrname + sizeof(ATTR_PLUGIN_ARG) -1;
-	attr_prevnum = attr_prev + sizeof(ATTR_PLUGIN_ARG) -1;
-	numsize = sizeof(attrname) - sizeof(ATTR_PLUGIN_ARG);
 	value = 0;
 	ii = 0;
-	while (plugin->plg_argc < num_args)
+	PR_snprintf(attrname, sizeof(attrname), "%s%d", ATTR_PLUGIN_ARG, ii);
+	while ((value = slapi_entry_attr_get_charptr(plugin_entry, attrname)) != NULL)
 	{
-		PR_snprintf(attrnamenum, numsize, "%d", ii);
-		if (diff == 0)
-		{
-			strcpy(attr_prev, attrname);
-			index_prev = ii;
-		}
-		while ((value = slapi_entry_attr_get_charptr(plugin_entry, attrname)) == NULL)
-                {
-                        PR_snprintf(attrnamenum, numsize, "%d", ++ii);
-                }
-
-		if(strcmp(attrname, attr_prev) != 0)
-		{
-			slapi_entry_add_string(plugin_entry, attr_prev, value);
-			slapi_entry_attr_delete(plugin_entry, attrname);
-			diff = 1;
-			PR_snprintf(attr_prevnum, numsize, "%d", ++index_prev);
-		}
 		charray_add(&plugin->plg_argv, value);
 		plugin->plg_argc++;
 		++ii;
+		PR_snprintf(attrname, sizeof(attrname), "%s%d", ATTR_PLUGIN_ARG, ii);
 	}
 
 	memset((char *)&pb, '\0', sizeof(pb));