]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sock/config.c
back-sock by Brian Candler (B.Candler@pobox.com) ITS#4094 (untested)
[openldap] / servers / slapd / back-sock / config.c
1 /* config.c - sock backend configuration file routine */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2007 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
17 #include "portable.h"
18
19 #include <stdio.h>
20
21 #include <ac/string.h>
22 #include <ac/socket.h>
23
24 #include "slap.h"
25 #include "back-sock.h"
26
27 int
28 sock_back_db_config(
29     BackendDB   *be,
30     const char  *fname,
31     int         lineno,
32     int         argc,
33     char        **argv
34 )
35 {
36         struct sockinfo *si = (struct sockinfo *) be->be_private;
37
38         if ( si == NULL ) {
39                 fprintf( stderr, "%s: line %d: sock backend info is null!\n",
40                     fname, lineno );
41                 return( 1 );
42         }
43
44         /* socketpath */
45         if ( strcasecmp( argv[0], "socketpath" ) == 0 ) {
46                 if ( argc != 2 ) {
47                         fprintf( stderr,
48         "%s: line %d: exactly one parameter needed for \"socketpath\"\n",
49                             fname, lineno );
50                         return( 1 );
51                 }
52                 si->si_sockpath = ch_strdup( argv[1] );
53
54         /* extensions */
55         } else if ( strcasecmp( argv[0], "extensions" ) == 0 ) {
56                 int i;
57                 for ( i=1; i<argc; i++ ) {
58                         if ( strcasecmp( argv[i], "binddn" ) == 0 )
59                                 si->si_extensions |= SOCK_EXT_BINDDN;
60                         else if ( strcasecmp( argv[i], "peername" ) == 0 )
61                                 si->si_extensions |= SOCK_EXT_PEERNAME;
62                         else if ( strcasecmp( argv[i], "ssf" ) == 0 )
63                                 si->si_extensions |= SOCK_EXT_SSF;
64                         else {
65                                 fprintf( stderr,
66         "%s: line %d: unknown extension \"%s\"\n",
67                             fname, lineno, argv[i] );
68                                 return( 1 );
69                         }
70                 }
71
72         /* anything else */
73         } else {
74                 return SLAP_CONF_UNKNOWN;
75         }
76
77         return 0;
78 }