X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-shell%2Fconfig.c;h=ff0d1cbcb0601427d0197dbdbe4bd5faba24628f;hb=0fc0ccdc0c66c4948a5d8bc51ddc6c622df6a3a0;hp=a9ec0a95eae9b9db9a8dbbfa87119187509c4f73;hpb=6939c531700652491f4be4688c6a1f35a1ab8a18;p=openldap
diff --git a/servers/slapd/back-shell/config.c b/servers/slapd/back-shell/config.c
index a9ec0a95ea..ff0d1cbcb0 100644
--- a/servers/slapd/back-shell/config.c
+++ b/servers/slapd/back-shell/config.c
@@ -1,8 +1,31 @@
/* config.c - shell backend configuration file routine */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2012 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
+ */
+/* Portions Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).
*/
#include "portable.h"
@@ -14,120 +37,101 @@
#include "slap.h"
#include "shell.h"
-
-int
-shell_back_db_config(
- BackendDB *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
+#include "config.h"
+
+static ConfigDriver shell_cf;
+
+enum {
+ SHELL_BIND = 0,
+ SHELL_UNBIND = 1,
+ SHELL_SEARCH,
+ SHELL_COMPARE,
+ SHELL_MODIFY,
+ SHELL_MODRDN,
+ SHELL_ADD,
+ SHELL_DELETE
+};
+
+static ConfigTable shellcfg[] = {
+ { "bind", "args", 2, 0, 0, ARG_MAGIC|SHELL_BIND, shell_cf,
+ "( OLcfgDbAt:10.1 NAME 'olcShellBind' "
+ "DESC 'Bind command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "unbind", "args", 2, 0, 0, ARG_MAGIC|SHELL_UNBIND, shell_cf,
+ "( OLcfgDbAt:10.2 NAME 'olcShellUnbind' "
+ "DESC 'Unbind command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "search", "args", 2, 0, 0, ARG_MAGIC|SHELL_SEARCH, shell_cf,
+ "( OLcfgDbAt:10.3 NAME 'olcShellSearch' "
+ "DESC 'Search command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "compare", "args", 2, 0, 0, ARG_MAGIC|SHELL_COMPARE, shell_cf,
+ "( OLcfgDbAt:10.4 NAME 'olcShellCompare' "
+ "DESC 'Compare command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "modify", "args", 2, 0, 0, ARG_MAGIC|SHELL_MODIFY, shell_cf,
+ "( OLcfgDbAt:10.5 NAME 'olcShellModify' "
+ "DESC 'Modify command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "modrdn", "args", 2, 0, 0, ARG_MAGIC|SHELL_MODRDN, shell_cf,
+ "( OLcfgDbAt:10.6 NAME 'olcShellModRDN' "
+ "DESC 'ModRDN command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "add", "args", 2, 0, 0, ARG_MAGIC|SHELL_ADD, shell_cf,
+ "( OLcfgDbAt:10.7 NAME 'olcShellAdd' "
+ "DESC 'Add command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { "delete", "args", 2, 0, 0, ARG_MAGIC|SHELL_DELETE, shell_cf,
+ "( OLcfgDbAt:10.8 NAME 'olcShellDelete' "
+ "DESC 'Delete command and arguments' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
+ { NULL }
+};
+
+static ConfigOCs shellocs[] = {
+ { "( OLcfgDbOc:10.1 "
+ "NAME 'olcShellConfig' "
+ "DESC 'Shell backend configuration' "
+ "SUP olcDatabaseConfig "
+ "MAY ( olcShellBind $ olcShellUnbind $ olcShellSearch $ "
+ "olcShellCompare $ olcShellModify $ olcShellModRDN $ "
+ "olcShellAdd $ olcShellDelete ) )",
+ Cft_Database, shellcfg },
+ { NULL }
+};
+
+static int
+shell_cf( ConfigArgs *c )
{
- struct shellinfo *si = (struct shellinfo *) be->be_private;
-
- if ( si == NULL ) {
- fprintf( stderr, "%s: line %d: shell backend info is null!\n",
- fname, lineno );
- return( 1 );
- }
-
- /* command + args to exec for binds */
- if ( strcasecmp( argv[0], "bind" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"bind \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_bind = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for unbinds */
- } else if ( strcasecmp( argv[0], "unbind" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"unbind \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_unbind = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for searches */
- } else if ( strcasecmp( argv[0], "search" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"search \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_search = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for compares */
- } else if ( strcasecmp( argv[0], "compare" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"compare \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_compare = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for modifies */
- } else if ( strcasecmp( argv[0], "modify" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"modify \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_modify = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for modrdn */
- } else if ( strcasecmp( argv[0], "modrdn" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"modrdn \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_modrdn = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for add */
- } else if ( strcasecmp( argv[0], "add" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"add \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_add = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for delete */
- } else if ( strcasecmp( argv[0], "delete" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"delete \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_delete = ldap_charray_dup( &argv[1] );
-
- /* command + args to exec for abandon */
- } else if ( strcasecmp( argv[0], "abandon" ) == 0 ) {
- if ( argc < 2 ) {
- fprintf( stderr,
- "%s: line %d: missing executable in \"abandon \" line\n",
- fname, lineno );
- return( 1 );
- }
- si->si_abandon = ldap_charray_dup( &argv[1] );
-
- /* anything else */
+ struct shellinfo *si = (struct shellinfo *) c->be->be_private;
+ char ***arr = &si->si_bind;
+
+ if ( c->op == SLAP_CONFIG_EMIT ) {
+ struct berval bv;
+ if ( !arr[c->type] ) return 1;
+ bv.bv_val = ldap_charray2str( arr[c->type], " " );
+ bv.bv_len = strlen( bv.bv_val );
+ ber_bvarray_add( &c->rvalue_vals, &bv );
+ } else if ( c->op == LDAP_MOD_DELETE ) {
+ ldap_charray_free( arr[c->type] );
+ arr[c->type] = NULL;
} else {
- fprintf( stderr,
-"%s: line %d: unknown directive \"%s\" in shell database definition (ignored)\n",
- fname, lineno, argv[0] );
+ arr[c->type] = ldap_charray_dup( &c->argv[1] );
}
-
return 0;
}
+
+int
+shell_back_init_cf( BackendInfo *bi )
+{
+ bi->bi_cf_ocs = shellocs;
+ return config_register_schema( shellcfg, shellocs );
+}