]> git.sur5r.net Git - openldap/blob - servers/slapd/configinfo.c
import localtime -> gmtime change from -devel
[openldap] / servers / slapd / configinfo.c
1 /*
2  * Copyright (c) 1995 Regents of the University of Michigan.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of Michigan at Ann Arbor. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16 #include <string.h>
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include "slap.h"
20 #include "ldapconfig.h"
21
22 #if defined( SLAPD_CONFIG_DN )
23
24 extern int              nbackends;
25 extern Backend          *backends;
26 extern char             *default_referral;
27
28 /*
29  * no mutex protection in here - take our chances!
30  */
31
32 void
33 config_info( Connection *conn, Operation *op )
34 {
35         Entry           *e;
36         char            buf[BUFSIZ];
37         struct berval   val;
38         struct berval   *vals[2];
39         int             i, j;
40
41         vals[0] = &val;
42         vals[1] = NULL;
43
44         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
45         /* initialize reader/writer lock */
46         entry_rdwr_init(e);
47
48         e->e_attrs = NULL;
49         e->e_dn = strdup( SLAPD_CONFIG_DN );
50
51         for ( i = 0; i < nbackends; i++ ) {
52                 strcpy( buf, backends[i].be_type );
53                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
54                         strcat( buf, " : " );
55                         strcat( buf, backends[i].be_suffix[j] );
56                 }
57                 val.bv_val = buf;
58                 val.bv_len = strlen( buf );
59                 attr_merge( e, "database", vals );
60         }
61
62         if ( default_referral != NULL ) {
63                 strcpy( buf, default_referral );
64                 val.bv_val = buf;
65                 val.bv_len = strlen( buf );
66                 attr_merge( e, "database", vals );
67         }
68
69         send_search_entry( &backends[0], conn, op, e, NULL, 0 );
70         send_ldap_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, 1 );
71
72         entry_free( e );
73 }
74
75 #endif /* slapd_config_dn */