1 /* config.c - shell backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2011 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
27 * This work was originally developed by the University of Michigan
28 * (as part of U-MICH LDAP).
35 #include <ac/string.h>
36 #include <ac/socket.h>
42 static ConfigDriver shell_cf;
55 static ConfigTable shellcfg[] = {
56 { "bind", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_BIND, shell_cf,
57 "( OLcfgDbAt:10.1 NAME 'olcShellBind' "
58 "DESC 'Bind command and arguments' "
59 "EQUALITY caseExactMatch "
60 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
61 { "unbind", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_UNBIND, shell_cf,
62 "( OLcfgDbAt:10.2 NAME 'olcShellUnbind' "
63 "DESC 'Unbind command and arguments' "
64 "EQUALITY caseExactMatch "
65 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
66 { "search", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_SEARCH, shell_cf,
67 "( OLcfgDbAt:10.3 NAME 'olcShellSearch' "
68 "DESC 'Search command and arguments' "
69 "EQUALITY caseExactMatch "
70 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
71 { "compare", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_COMPARE, shell_cf,
72 "( OLcfgDbAt:10.4 NAME 'olcShellCompare' "
73 "DESC 'Compare command and arguments' "
74 "EQUALITY caseExactMatch "
75 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
76 { "modify", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_MODIFY, shell_cf,
77 "( OLcfgDbAt:10.5 NAME 'olcShellModify' "
78 "DESC 'Modify command and arguments' "
79 "EQUALITY caseExactMatch "
80 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
81 { "modrdn", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_MODRDN, shell_cf,
82 "( OLcfgDbAt:10.6 NAME 'olcShellModRDN' "
83 "DESC 'ModRDN command and arguments' "
84 "EQUALITY caseExactMatch "
85 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
86 { "add", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_ADD, shell_cf,
87 "( OLcfgDbAt:10.7 NAME 'olcShellAdd' "
88 "DESC 'Add command and arguments' "
89 "EQUALITY caseExactMatch "
90 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
91 { "delete", "args", 2, 0, 0, ARG_STRING|ARG_MAGIC|SHELL_DELETE, shell_cf,
92 "( OLcfgDbAt:10.8 NAME 'olcShellDelete' "
93 "DESC 'Delete command and arguments' "
94 "EQUALITY caseExactMatch "
95 "SYNTAX OMsDirectoryString SINGLE-VALUE ) ", NULL, NULL },
99 static ConfigOCs shellocs[] = {
100 { "( OLcfgDbOc:10.1 "
101 "NAME 'olcShellConfig' "
102 "DESC 'Shell backend configuration' "
103 "SUP olcDatabaseConfig "
104 "MAY ( olcShellBind $ olcShellUnbind $ olcShellSearch $ "
105 "olcShellCompare $ olcShellModify $ olcShellModRDN $ "
106 "olcShellAdd $ olcShellDelete ) )",
107 Cft_Database, shellcfg },
112 shell_cf( ConfigArgs *c )
114 struct shellinfo *si = (struct shellinfo *) c->be->be_private;
115 char ***arr = &si->si_bind;
117 if ( c->op == SLAP_CONFIG_EMIT ) {
119 if ( !arr[c->type] ) return 1;
120 bv.bv_val = ldap_charray2str( arr[c->type], " " );
121 bv.bv_len = strlen( bv.bv_val );
122 ber_bvarray_add( &c->rvalue_vals, &bv );
123 } else if ( c->op == LDAP_MOD_DELETE ) {
124 ldap_charray_free( arr[c->type] );
127 arr[c->type] = ldap_charray_dup( &c->argv[1] );
133 shell_back_init_cf( BackendInfo *bi )
135 bi->bi_cf_ocs = shellocs;
136 return config_register_schema( shellcfg, shellocs );