]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/config.c
Happy New Year (belated)
[openldap] / servers / slapd / back-shell / config.c
1 /* config.c - shell backend configuration file routine */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2008 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
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>.
15  */
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17  * All rights reserved.
18  *
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.
25  */
26 /* ACKNOWLEDGEMENTS:
27  * This work was originally developed by the University of Michigan
28  * (as part of U-MICH LDAP).
29  */
30
31 #include "portable.h"
32
33 #include <stdio.h>
34
35 #include <ac/string.h>
36 #include <ac/socket.h>
37
38 #include "slap.h"
39 #include "shell.h"
40
41 int
42 shell_back_db_config(
43     BackendDB   *be,
44     const char  *fname,
45     int         lineno,
46     int         argc,
47     char        **argv
48 )
49 {
50         struct shellinfo        *si = (struct shellinfo *) be->be_private;
51
52         if ( si == NULL ) {
53                 fprintf( stderr, "%s: line %d: shell backend info is null!\n",
54                     fname, lineno );
55                 return( 1 );
56         }
57
58         /* command + args to exec for binds */
59         if ( strcasecmp( argv[0], "bind" ) == 0 ) {
60                 if ( argc < 2 ) {
61                         fprintf( stderr,
62         "%s: line %d: missing executable in \"bind <executable>\" line\n",
63                             fname, lineno );
64                         return( 1 );
65                 }
66                 si->si_bind = ldap_charray_dup( &argv[1] );
67
68         /* command + args to exec for unbinds */
69         } else if ( strcasecmp( argv[0], "unbind" ) == 0 ) {
70                 if ( argc < 2 ) {
71                         fprintf( stderr,
72         "%s: line %d: missing executable in \"unbind <executable>\" line\n",
73                             fname, lineno );
74                         return( 1 );
75                 }
76                 si->si_unbind = ldap_charray_dup( &argv[1] );
77
78         /* command + args to exec for searches */
79         } else if ( strcasecmp( argv[0], "search" ) == 0 ) {
80                 if ( argc < 2 ) {
81                         fprintf( stderr,
82         "%s: line %d: missing executable in \"search <executable>\" line\n",
83                             fname, lineno );
84                         return( 1 );
85                 }
86                 si->si_search = ldap_charray_dup( &argv[1] );
87
88         /* command + args to exec for compares */
89         } else if ( strcasecmp( argv[0], "compare" ) == 0 ) {
90                 if ( argc < 2 ) {
91                         fprintf( stderr,
92         "%s: line %d: missing executable in \"compare <executable>\" line\n",
93                             fname, lineno );
94                         return( 1 );
95                 }
96                 si->si_compare = ldap_charray_dup( &argv[1] );
97
98         /* command + args to exec for modifies */
99         } else if ( strcasecmp( argv[0], "modify" ) == 0 ) {
100                 if ( argc < 2 ) {
101                         fprintf( stderr,
102         "%s: line %d: missing executable in \"modify <executable>\" line\n",
103                             fname, lineno );
104                         return( 1 );
105                 }
106                 si->si_modify = ldap_charray_dup( &argv[1] );
107
108         /* command + args to exec for modrdn */
109         } else if ( strcasecmp( argv[0], "modrdn" ) == 0 ) {
110                 if ( argc < 2 ) {
111                         fprintf( stderr,
112         "%s: line %d: missing executable in \"modrdn <executable>\" line\n",
113                             fname, lineno );
114                         return( 1 );
115                 }
116                 si->si_modrdn = ldap_charray_dup( &argv[1] );
117
118         /* command + args to exec for add */
119         } else if ( strcasecmp( argv[0], "add" ) == 0 ) {
120                 if ( argc < 2 ) {
121                         fprintf( stderr,
122         "%s: line %d: missing executable in \"add <executable>\" line\n",
123                             fname, lineno );
124                         return( 1 );
125                 }
126                 si->si_add = ldap_charray_dup( &argv[1] );
127
128         /* command + args to exec for delete */
129         } else if ( strcasecmp( argv[0], "delete" ) == 0 ) {
130                 if ( argc < 2 ) {
131                         fprintf( stderr,
132         "%s: line %d: missing executable in \"delete <executable>\" line\n",
133                             fname, lineno );
134                         return( 1 );
135                 }
136                 si->si_delete = ldap_charray_dup( &argv[1] );
137
138         /* anything else */
139         } else {
140                 return SLAP_CONF_UNKNOWN;
141         }
142
143         return 0;
144 }