X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-shell%2Fconfig.c;h=ff0d1cbcb0601427d0197dbdbe4bd5faba24628f;hb=0fc0ccdc0c66c4948a5d8bc51ddc6c622df6a3a0;hp=6a4f191088862931d0dc41421400a0988711013c;hpb=4af9eb971559e3a1f0432615e93ec870dc753ddb;p=openldap diff --git a/servers/slapd/back-shell/config.c b/servers/slapd/back-shell/config.c index 6a4f191088..ff0d1cbcb0 100644 --- a/servers/slapd/back-shell/config.c +++ b/servers/slapd/back-shell/config.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2009 The OpenLDAP Foundation. + * Copyright 1998-2012 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,108 +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] ); - - /* 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 { - return SLAP_CONF_UNKNOWN; + 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 ); +}