1998-08-09 08:43:13 +08:00
|
|
|
/* config.c - shell backend configuration file routine */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 14:35:49 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2004-01-02 03:15:16 +08:00
|
|
|
* Copyright 1998-2004 The OpenLDAP Foundation.
|
2003-11-27 14:35:49 +08:00
|
|
|
* 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
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* 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).
|
2000-05-16 00:35:48 +08:00
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "slap.h"
|
|
|
|
#include "shell.h"
|
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
int
|
|
|
|
shell_back_db_config(
|
|
|
|
BackendDB *be,
|
1999-08-21 03:29:43 +08:00
|
|
|
const char *fname,
|
1998-08-09 08:43:13 +08:00
|
|
|
int lineno,
|
|
|
|
int argc,
|
|
|
|
char **argv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
struct shellinfo *si = (struct shellinfo *) be->be_private;
|
|
|
|
|
|
|
|
if ( si == NULL ) {
|
|
|
|
fprintf( stderr, "%s: line %d: shell backend info is null!\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* command + args to exec for binds */
|
|
|
|
if ( strcasecmp( argv[0], "bind" ) == 0 ) {
|
|
|
|
if ( argc < 2 ) {
|
|
|
|
fprintf( stderr,
|
|
|
|
"%s: line %d: missing executable in \"bind <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_bind = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_unbind = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_search = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_compare = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_modify = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_modrdn = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_add = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* 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 <executable>\" line\n",
|
|
|
|
fname, lineno );
|
1999-02-05 17:03:47 +08:00
|
|
|
return( 1 );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2002-10-11 04:28:36 +08:00
|
|
|
si->si_delete = ldap_charray_dup( &argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* anything else */
|
|
|
|
} else {
|
2003-12-07 15:07:00 +08:00
|
|
|
return SLAP_CONF_UNKNOWN;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
1999-02-05 17:03:47 +08:00
|
|
|
|
|
|
|
return 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|