1 /* config.c - sock backend configuration file routine */ 2 /* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/config.c,v 1.5.2.1 2008/02/09 00:46:09 quanah Exp $ */ 3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>. 4 * 5 * Copyright 2007-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 /* ACKNOWLEDGEMENTS: 17 * This work was initially developed by Brian Candler for inclusion 18 * in OpenLDAP Software. Dynamic config support by Howard Chu. 19 */ 20 21 #include "portable.h" 22 23 #include <stdio.h> 24 25 #include <ac/string.h> 26 #include <ac/socket.h> 27 28 #include "slap.h" 29 #include "config.h" 30 #include "back-sock.h" 31 32 static ConfigDriver bs_cf_gen; 33 34 enum { 35 BS_EXT = 1 36 }; 37 38 static ConfigTable bscfg[] = { 39 { "socketpath", "pathname", 2, 2, 0, ARG_STRING|ARG_OFFSET, 40 (void *)offsetof(struct sockinfo, si_sockpath), 41 "( OLcfgDbAt:7.1 NAME 'olcDbSocketPath' " 42 "DESC 'Pathname for Unix domain socket' " 43 "EQUALITY caseExactMatch " 44 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, 45 { "extensions", "ext", 2, 0, 0, ARG_MAGIC|BS_EXT, 46 bs_cf_gen, "( OLcfgDbAt:7.2 NAME 'olcDbSocketExtensions' " 47 "DESC 'binddn, peername, or ssf' " 48 "EQUALITY caseIgnoreMatch " 49 "SYNTAX OMsDirectoryString )", NULL, NULL }, 50 { NULL, NULL } 51 }; 52 53 static ConfigOCs bsocs[] = { 54 { "( OLcfgDbOc:7.1 " 55 "NAME 'olcDbSocketConfig' " 56 "DESC 'Socket backend configuration' " 57 "SUP olcDatabaseConfig " 58 "MUST olcDbSocketPath " 59 "MAY olcDbSocketExtensions )", 60 Cft_Database, bscfg }, 61 { NULL, 0, NULL } 62 }; 63 64 static slap_verbmasks bs_exts[] = { 65 { BER_BVC("binddn"), SOCK_EXT_BINDDN }, 66 { BER_BVC("peername"), SOCK_EXT_PEERNAME }, 67 { BER_BVC("ssf"), SOCK_EXT_SSF }, 68 { BER_BVNULL, 0 } 69 }; 70 71 static int 72 bs_cf_gen( ConfigArgs *c ) 73 { 74 struct sockinfo *si = c->be->be_private; 75 int rc; 76 77 if ( c->op == SLAP_CONFIG_EMIT ) { 78 switch( c->type ) { 79 case BS_EXT: 80 return mask_to_verbs( bs_exts, si->si_extensions, &c->rvalue_vals ); 81 } 82 } else if ( c->op == LDAP_MOD_DELETE ) { 83 switch( c->type ) { 84 case BS_EXT: 85 if ( c->valx < 0 ) { 86 si->si_extensions = 0; 87 rc = 0; 88 } else { 89 slap_mask_t dels = 0; 90 rc = verbs_to_mask( c->argc, c->argv, bs_exts, &dels ); 91 if ( rc == 0 ) 92 si->si_extensions ^= dels; 93 } 94 return rc; 95 } 96 97 } else { 98 switch( c->type ) { 99 case BS_EXT: 100 return verbs_to_mask( c->argc, c->argv, bs_exts, &si->si_extensions ); 101 } 102 } 103 return 1; 104 } 105 106 int 107 sock_back_init_cf( BackendInfo *bi ) 108 { 109 bi->bi_cf_ocs = bsocs; 110 111 return config_register_schema( bscfg, bsocs ); 112 } 113