]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sock/config.c
Forced commit, partially revert prev commit
[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 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by Brian Candler for inclusion
18  * in OpenLDAP Software.
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 "back-sock.h"
30
31 int
32 sock_back_db_config(
33     BackendDB   *be,
34     const char  *fname,
35     int         lineno,
36     int         argc,
37     char        **argv
38 )
39 {
40         struct sockinfo *si = (struct sockinfo *) be->be_private;
41
42         if ( si == NULL ) {
43                 fprintf( stderr, "%s: line %d: sock backend info is null!\n",
44                     fname, lineno );
45                 return( 1 );
46         }
47
48         /* socketpath */
49         if ( strcasecmp( argv[0], "socketpath" ) == 0 ) {
50                 if ( argc != 2 ) {
51                         fprintf( stderr,
52         "%s: line %d: exactly one parameter needed for \"socketpath\"\n",
53                             fname, lineno );
54                         return( 1 );
55                 }
56                 si->si_sockpath = ch_strdup( argv[1] );
57
58         /* extensions */
59         } else if ( strcasecmp( argv[0], "extensions" ) == 0 ) {
60                 int i;
61                 for ( i=1; i<argc; i++ ) {
62                         if ( strcasecmp( argv[i], "binddn" ) == 0 )
63                                 si->si_extensions |= SOCK_EXT_BINDDN;
64                         else if ( strcasecmp( argv[i], "peername" ) == 0 )
65                                 si->si_extensions |= SOCK_EXT_PEERNAME;
66                         else if ( strcasecmp( argv[i], "ssf" ) == 0 )
67                                 si->si_extensions |= SOCK_EXT_SSF;
68                         else {
69                                 fprintf( stderr,
70         "%s: line %d: unknown extension \"%s\"\n",
71                             fname, lineno, argv[i] );
72                                 return( 1 );
73                         }
74                 }
75
76         /* anything else */
77         } else {
78                 return SLAP_CONF_UNKNOWN;
79         }
80
81         return 0;
82 }