]> git.sur5r.net Git - openldap/blob - servers/slapd/frontend.c
Happy new year! (belated)
[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-2008 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 static BackendInfo      slap_frontendInfo;
42 static BackendDB        slap_frontendDB;
43 BackendDB       *frontendDB;
44
45 int
46 frontend_init( void )
47 {
48         /* data */
49         frontendDB = &slap_frontendDB;
50
51         /* ACLs */
52         frontendDB->be_dfltaccess = ACL_READ;
53
54         /* limits */
55         frontendDB->be_def_limit.lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;  /* backward compatible limits */
56         frontendDB->be_def_limit.lms_t_hard = 0;
57         frontendDB->be_def_limit.lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;  /* backward compatible limits */
58         frontendDB->be_def_limit.lms_s_hard = 0;
59         frontendDB->be_def_limit.lms_s_unchecked = -1;                  /* no limit on unchecked size */
60         frontendDB->be_def_limit.lms_s_pr = 0;                          /* page limit */
61         frontendDB->be_def_limit.lms_s_pr_hide = 0;                     /* don't hide number of entries left */
62         frontendDB->be_def_limit.lms_s_pr_total = 0;                    /* number of total entries returned by pagedResults equal to hard limit */
63
64 #if 0
65         /* FIXME: do we need this? */
66         frontendDB->be_pcl_mutexp = &frontendDB->be_pcl_mutex;
67         ldap_pvt_thread_mutex_init( frontendDB->be_pcl_mutexp );
68 #endif
69
70         /* suffix */
71         frontendDB->be_suffix = ch_calloc( 2, sizeof( struct berval ) );
72         ber_str2bv( "", 0, 1, &frontendDB->be_suffix[0] );
73         BER_BVZERO( &frontendDB->be_suffix[1] );
74         frontendDB->be_nsuffix = ch_calloc( 2, sizeof( struct berval ) );
75         ber_str2bv( "", 0, 1, &frontendDB->be_nsuffix[0] );
76         BER_BVZERO( &frontendDB->be_nsuffix[1] );
77
78         /* info */
79         frontendDB->bd_info = &slap_frontendInfo;
80
81         SLAP_BFLAGS(frontendDB) |= SLAP_BFLAG_FRONTEND;
82
83         /* name */
84         frontendDB->bd_info->bi_type = "frontend";
85
86         /* known controls */
87         if ( slap_known_controls ) {
88                 int     i;
89
90                 frontendDB->bd_info->bi_controls = slap_known_controls;
91
92                 for ( i = 0; slap_known_controls[ i ]; i++ ) {
93                         int     cid;
94
95                         if ( slap_find_control_id( slap_known_controls[ i ], &cid )
96                                         == LDAP_CONTROL_NOT_FOUND )
97                         {
98                                 assert( 0 );
99                                 return -1;
100                         }
101
102                         frontendDB->bd_info->bi_ctrls[ cid ] = 1;
103                         frontendDB->be_ctrls[ cid ] = 1;
104                 }
105         }
106
107         /* calls */
108         frontendDB->bd_info->bi_op_abandon = fe_op_abandon;
109         frontendDB->bd_info->bi_op_add = fe_op_add;
110         frontendDB->bd_info->bi_op_bind = fe_op_bind;
111         frontendDB->bd_info->bi_op_compare = fe_op_compare;
112         frontendDB->bd_info->bi_op_delete = fe_op_delete;
113         frontendDB->bd_info->bi_op_modify = fe_op_modify;
114         frontendDB->bd_info->bi_op_modrdn = fe_op_modrdn;
115         frontendDB->bd_info->bi_op_search = fe_op_search;
116         frontendDB->bd_info->bi_extended = fe_extended;
117         frontendDB->bd_info->bi_operational = fe_aux_operational;
118 #if 0
119         frontendDB->bd_info->bi_entry_get_rw = fe_entry_get_rw;
120         frontendDB->bd_info->bi_entry_release_rw = fe_entry_release_rw;
121 #endif
122 #ifdef SLAP_OVERLAY_ACCESS
123         frontendDB->bd_info->bi_access_allowed = fe_access_allowed;
124         frontendDB->bd_info->bi_acl_group = fe_acl_group;
125         frontendDB->bd_info->bi_acl_attribute = fe_acl_attribute;
126 #endif /* SLAP_OVERLAY_ACCESS */
127
128 #if 0
129         /* FIXME: is this too early? */
130         return backend_startup_one( frontendDB );
131 #endif
132
133         return 0;
134 }
135