Back to index

openldap  2.4.31
config.c
Go to the documentation of this file.
00001 /* config.c - shell backend configuration file routine */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
00017  * All rights reserved.
00018  *
00019  * Redistribution and use in source and binary forms are permitted
00020  * provided that this notice is preserved and that due credit is given
00021  * to the University of Michigan at Ann Arbor. The name of the University
00022  * may not be used to endorse or promote products derived from this
00023  * software without specific prior written permission. This software
00024  * is provided ``as is'' without express or implied warranty.
00025  */
00026 /* ACKNOWLEDGEMENTS:
00027  * This work was originally developed by the University of Michigan
00028  * (as part of U-MICH LDAP).
00029  */
00030 
00031 #include "portable.h"
00032 
00033 #include <stdio.h>
00034 
00035 #include <ac/string.h>
00036 #include <ac/socket.h>
00037 
00038 #include "slap.h"
00039 #include "shell.h"
00040 #include "config.h"
00041 
00042 static ConfigDriver shell_cf;
00043 
00044 enum {
00045        SHELL_BIND = 0,
00046        SHELL_UNBIND = 1,
00047        SHELL_SEARCH,
00048        SHELL_COMPARE,
00049        SHELL_MODIFY,
00050        SHELL_MODRDN,
00051        SHELL_ADD,
00052        SHELL_DELETE
00053 };
00054 
00055 static ConfigTable shellcfg[] = {
00056        { "bind", "args", 2, 0, 0, ARG_MAGIC|SHELL_BIND, shell_cf,
00057               "( OLcfgDbAt:10.1 NAME 'olcShellBind' "
00058                      "DESC 'Bind command and arguments' "
00059                      "EQUALITY caseExactMatch "
00060                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00061        { "unbind", "args", 2, 0, 0, ARG_MAGIC|SHELL_UNBIND, shell_cf,
00062               "( OLcfgDbAt:10.2 NAME 'olcShellUnbind' "
00063                      "DESC 'Unbind command and arguments' "
00064                      "EQUALITY caseExactMatch "
00065                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00066        { "search", "args", 2, 0, 0, ARG_MAGIC|SHELL_SEARCH, shell_cf,
00067               "( OLcfgDbAt:10.3 NAME 'olcShellSearch' "
00068                      "DESC 'Search command and arguments' "
00069                      "EQUALITY caseExactMatch "
00070                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00071        { "compare", "args", 2, 0, 0, ARG_MAGIC|SHELL_COMPARE, shell_cf,
00072               "( OLcfgDbAt:10.4 NAME 'olcShellCompare' "
00073                      "DESC 'Compare command and arguments' "
00074                      "EQUALITY caseExactMatch "
00075                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00076        { "modify", "args", 2, 0, 0, ARG_MAGIC|SHELL_MODIFY, shell_cf,
00077               "( OLcfgDbAt:10.5 NAME 'olcShellModify' "
00078                      "DESC 'Modify command and arguments' "
00079                      "EQUALITY caseExactMatch "
00080                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00081        { "modrdn", "args", 2, 0, 0, ARG_MAGIC|SHELL_MODRDN, shell_cf,
00082               "( OLcfgDbAt:10.6 NAME 'olcShellModRDN' "
00083                      "DESC 'ModRDN command and arguments' "
00084                      "EQUALITY caseExactMatch "
00085                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00086        { "add", "args", 2, 0, 0, ARG_MAGIC|SHELL_ADD, shell_cf,
00087               "( OLcfgDbAt:10.7 NAME 'olcShellAdd' "
00088                      "DESC 'Add command and arguments' "
00089                      "EQUALITY caseExactMatch "
00090                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00091        { "delete", "args", 2, 0, 0, ARG_MAGIC|SHELL_DELETE, shell_cf,
00092               "( OLcfgDbAt:10.8 NAME 'olcShellDelete' "
00093                      "DESC 'Delete command and arguments' "
00094                      "EQUALITY caseExactMatch "
00095                      "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
00096        { NULL }
00097 };
00098 
00099 static ConfigOCs shellocs[] = {
00100        { "( OLcfgDbOc:10.1 "
00101               "NAME 'olcShellConfig'  "
00102               "DESC 'Shell backend configuration' "
00103               "SUP olcDatabaseConfig "
00104               "MAY ( olcShellBind $ olcShellUnbind $ olcShellSearch $ "
00105                      "olcShellCompare $ olcShellModify $ olcShellModRDN $ "
00106                      "olcShellAdd $ olcShellDelete ) )",
00107                             Cft_Database, shellcfg },
00108        { NULL }
00109 };
00110 
00111 static int
00112 shell_cf( ConfigArgs *c )
00113 {
00114        struct shellinfo     *si = (struct shellinfo *) c->be->be_private;
00115        char ***arr = &si->si_bind;
00116 
00117        if ( c->op == SLAP_CONFIG_EMIT ) {
00118               struct berval bv;
00119               if ( !arr[c->type] ) return 1;
00120               bv.bv_val = ldap_charray2str( arr[c->type], " " );
00121               bv.bv_len = strlen( bv.bv_val );
00122               ber_bvarray_add( &c->rvalue_vals, &bv );
00123        } else if ( c->op == LDAP_MOD_DELETE ) {
00124               ldap_charray_free( arr[c->type] );
00125               arr[c->type] = NULL;
00126        } else {
00127               arr[c->type] = ldap_charray_dup( &c->argv[1] );
00128        }
00129        return 0;
00130 }
00131 
00132 int
00133 shell_back_init_cf( BackendInfo *bi )
00134 {
00135        bi->bi_cf_ocs = shellocs;
00136        return config_register_schema( shellcfg, shellocs );
00137 }