]> git.sur5r.net Git - openldap/blob - servers/slapd/frontend.c
1d20ed7cc03507127a3ebf1215ba561aae26219a
[openldap] / servers / slapd / frontend.c
1 /* frontend.c - routines for dealing with frontend */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2005 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms are permitted
19  * provided that this notice is preserved and that due credit is given
20  * to the University of Michigan at Ann Arbor. The name of the University
21  * may not be used to endorse or promote products derived from this
22  * software without specific prior written permission. This software
23  * is provided ``as is'' without express or implied warranty.
24  */
25
26
27 #include "portable.h"
28
29 #include <stdio.h>
30
31 #include <ac/string.h>
32 #include <ac/socket.h>
33 #include <sys/stat.h>
34
35 #include "slap.h"
36 #include "lutil.h"
37 #include "lber_pvt.h"
38
39 #include "ldap_rq.h"
40
41 #ifdef LDAP_SLAPI
42 #include "slapi/slapi.h"
43 #endif
44
45 static BackendInfo      slap_frontendInfo;
46 static BackendDB        slap_frontendDB;
47 BackendDB       *frontendDB;
48
49 int
50 frontend_init( void )
51 {
52         /* data */
53         frontendDB = &slap_frontendDB;
54
55         /* ACLs */
56         frontendDB->be_dfltaccess = ACL_READ;
57
58         /* limits */
59         frontendDB->be_def_limit.lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;  /* backward compatible limits */
60         frontendDB->be_def_limit.lms_t_hard = 0;
61         frontendDB->be_def_limit.lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;  /* backward compatible limits */
62         frontendDB->be_def_limit.lms_s_hard = 0;
63         frontendDB->be_def_limit.lms_s_unchecked = -1;                  /* no limit on unchecked size */
64         frontendDB->be_def_limit.lms_s_pr = 0;                          /* page limit */
65         frontendDB->be_def_limit.lms_s_pr_hide = 0;                     /* don't hide number of entries left */
66         frontendDB->be_def_limit.lms_s_pr_total = 0;                    /* number of total entries returned by pagedResults equal to hard limit */
67
68 #if 0
69         /* FIXME: do we need this? */
70         frontendDB->be_pcl_mutexp = &frontendDB->be_pcl_mutex;
71         ldap_pvt_thread_mutex_init( frontendDB->be_pcl_mutexp );
72 #endif
73
74         /* suffix */
75         frontendDB->be_suffix = ch_calloc( 2, sizeof( struct berval ) );
76         ber_str2bv( "", 0, 1, &frontendDB->be_suffix[0] );
77         BER_BVZERO( &frontendDB->be_suffix[1] );
78         frontendDB->be_nsuffix = ch_calloc( 2, sizeof( struct berval ) );
79         ber_str2bv( "", 0, 1, &frontendDB->be_nsuffix[0] );
80         BER_BVZERO( &frontendDB->be_nsuffix[1] );
81
82         /* info */
83         frontendDB->bd_info = &slap_frontendInfo;
84
85         /* name */
86         frontendDB->bd_info->bi_type = "frontend";
87
88         /* known controls */
89         if ( slap_known_controls ) {
90                 int     i;
91
92                 frontendDB->bd_info->bi_controls = slap_known_controls;
93
94                 for ( i = 0; slap_known_controls[ i ]; i++ ) {
95                         int     cid;
96
97                         if ( slap_find_control_id( slap_known_controls[ i ], &cid )
98                                         == LDAP_CONTROL_NOT_FOUND )
99                         {
100                                 assert( 0 );
101                                 return -1;
102                         }
103
104                         frontendDB->bd_info->bi_ctrls[ cid ] = 1;
105                         frontendDB->be_ctrls[ cid ] = 1;
106                 }
107         }
108
109         /* calls */
110         frontendDB->bd_info->bi_op_abandon = fe_op_abandon;
111         frontendDB->bd_info->bi_op_add = fe_op_add;
112         frontendDB->bd_info->bi_op_bind = fe_op_bind;
113         frontendDB->bd_info->bi_op_compare = fe_op_compare;
114         frontendDB->bd_info->bi_op_delete = fe_op_delete;
115         frontendDB->bd_info->bi_op_modify = fe_op_modify;
116         frontendDB->bd_info->bi_op_modrdn = fe_op_modrdn;
117         frontendDB->bd_info->bi_op_search = fe_op_search;
118         frontendDB->bd_info->bi_extended = fe_extended;
119
120 #ifdef SLAP_OVERLAY_ACCESS
121         frontendDB->bd_info->bi_access_allowed = slap_access_allowed;
122 #endif /* SLAP_OVERLAY_ACCESS */
123
124 #if 0
125         /* FIXME: is this too early? */
126         return backend_startup_one( frontendDB );
127 #endif
128
129         return 0;
130 }
131