1/* $NetBSD: config.c,v 1.1.1.3 2010/12/12 15:23:21 adam Exp $ */ 2 3/* config.c - shell backend configuration file routine */ 4/* OpenLDAP: pkg/ldap/servers/slapd/back-shell/config.c,v 1.18.2.5 2010/04/13 20:23:39 kurt Exp */ 5/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 1998-2010 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18/* Portions Copyright (c) 1995 Regents of the University of Michigan. 19 * All rights reserved. 20 * 21 * Redistribution and use in source and binary forms are permitted 22 * provided that this notice is preserved and that due credit is given 23 * to the University of Michigan at Ann Arbor. The name of the University 24 * may not be used to endorse or promote products derived from this 25 * software without specific prior written permission. This software 26 * is provided ``as is'' without express or implied warranty. 27 */ 28/* ACKNOWLEDGEMENTS: 29 * This work was originally developed by the University of Michigan 30 * (as part of U-MICH LDAP). 31 */ 32 33#include "portable.h" 34 35#include <stdio.h> 36 37#include <ac/string.h> 38#include <ac/socket.h> 39 40#include "slap.h" 41#include "shell.h" 42 43int 44shell_back_db_config( 45 BackendDB *be, 46 const char *fname, 47 int lineno, 48 int argc, 49 char **argv 50) 51{ 52 struct shellinfo *si = (struct shellinfo *) be->be_private; 53 54 if ( si == NULL ) { 55 fprintf( stderr, "%s: line %d: shell backend info is null!\n", 56 fname, lineno ); 57 return( 1 ); 58 } 59 60 /* command + args to exec for binds */ 61 if ( strcasecmp( argv[0], "bind" ) == 0 ) { 62 if ( argc < 2 ) { 63 fprintf( stderr, 64 "%s: line %d: missing executable in \"bind <executable>\" line\n", 65 fname, lineno ); 66 return( 1 ); 67 } 68 si->si_bind = ldap_charray_dup( &argv[1] ); 69 70 /* command + args to exec for unbinds */ 71 } else if ( strcasecmp( argv[0], "unbind" ) == 0 ) { 72 if ( argc < 2 ) { 73 fprintf( stderr, 74 "%s: line %d: missing executable in \"unbind <executable>\" line\n", 75 fname, lineno ); 76 return( 1 ); 77 } 78 si->si_unbind = ldap_charray_dup( &argv[1] ); 79 80 /* command + args to exec for searches */ 81 } else if ( strcasecmp( argv[0], "search" ) == 0 ) { 82 if ( argc < 2 ) { 83 fprintf( stderr, 84 "%s: line %d: missing executable in \"search <executable>\" line\n", 85 fname, lineno ); 86 return( 1 ); 87 } 88 si->si_search = ldap_charray_dup( &argv[1] ); 89 90 /* command + args to exec for compares */ 91 } else if ( strcasecmp( argv[0], "compare" ) == 0 ) { 92 if ( argc < 2 ) { 93 fprintf( stderr, 94 "%s: line %d: missing executable in \"compare <executable>\" line\n", 95 fname, lineno ); 96 return( 1 ); 97 } 98 si->si_compare = ldap_charray_dup( &argv[1] ); 99 100 /* command + args to exec for modifies */ 101 } else if ( strcasecmp( argv[0], "modify" ) == 0 ) { 102 if ( argc < 2 ) { 103 fprintf( stderr, 104 "%s: line %d: missing executable in \"modify <executable>\" line\n", 105 fname, lineno ); 106 return( 1 ); 107 } 108 si->si_modify = ldap_charray_dup( &argv[1] ); 109 110 /* command + args to exec for modrdn */ 111 } else if ( strcasecmp( argv[0], "modrdn" ) == 0 ) { 112 if ( argc < 2 ) { 113 fprintf( stderr, 114 "%s: line %d: missing executable in \"modrdn <executable>\" line\n", 115 fname, lineno ); 116 return( 1 ); 117 } 118 si->si_modrdn = ldap_charray_dup( &argv[1] ); 119 120 /* command + args to exec for add */ 121 } else if ( strcasecmp( argv[0], "add" ) == 0 ) { 122 if ( argc < 2 ) { 123 fprintf( stderr, 124 "%s: line %d: missing executable in \"add <executable>\" line\n", 125 fname, lineno ); 126 return( 1 ); 127 } 128 si->si_add = ldap_charray_dup( &argv[1] ); 129 130 /* command + args to exec for delete */ 131 } else if ( strcasecmp( argv[0], "delete" ) == 0 ) { 132 if ( argc < 2 ) { 133 fprintf( stderr, 134 "%s: line %d: missing executable in \"delete <executable>\" line\n", 135 fname, lineno ); 136 return( 1 ); 137 } 138 si->si_delete = ldap_charray_dup( &argv[1] ); 139 140 /* anything else */ 141 } else { 142 return SLAP_CONF_UNKNOWN; 143 } 144 145 return 0; 146} 147