summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/lite_entries.c
blob: f97bff599e13b763bc5815be9d3c44429a8f93a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/** BEGIN COPYRIGHT BLOCK
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
/* lite_entries.c - 
 *
 * These entries are added under cn=options,cn=features,cn=config for 
 * Directory Lite. These entries tell the console which modules ( ds features )
 * are disabled, and which attributes in cn=config are disabled.
 */

   
   

#include "slap.h"

static void  del_dslite_entries();
static void  add_dslite_entries();
static const char *lite_entries[] = 
{
  "dn:" LITE_DISABLED_ATTRS_DN "\n"
  "cn:attributes\n"
  "objectclass:top\n"
  "objectclass:extensibleObject\n"
  "objectclass:directoryServerFeature\n"
  "cn=config|nsslapd-referral:off\n"
  "cn=config|nsslapd-maxdescriptors:off\n",
  
  "dn:" LITE_DISABLED_MODULES_DN "\n"
  "objectclass:top\n"
  "objectclass:directoryServerFeature\n"
  "objectclass:extensibleObject\n"
  "cn:modules\n"
  "replication:off\n"
  "passwordpolicy:off\n"
  "accountlockout:off\n"
  "snmpsettings:off\n"
  "backup:off\n",

  NULL
};

/* add_dslite_entries: 
 *
 * Add the DirLite specific entries.
 * First we try to delete them in case they were already loaded from dse.ldif
 * but are in some sort of invalid state.
 * Then we add them back.
 * It would have been better to make sure that these entries never get written
 * to dse.ldif, but it doesn't look like we're able to add a dse_callback function
 * on the DN's of these entries but they get added at the wrong time.
 */
   
   
   
static void
add_dslite_entries() {
  int i;

  del_dslite_entries();
  LDAPDebug( LDAP_DEBUG_TRACE, "Adding lite entries.\n",0,0,0);
  for( i = 0; lite_entries[i]; i++ ) {
	Slapi_PBlock *resultpb;
	char *estr = slapi_ch_strdup ( lite_entries[i] );
  	Slapi_Entry *e = slapi_str2entry( estr, 0 );
	if ( NULL != e ) {
	  resultpb = slapi_add_entry_internal( e, NULL, 0 );
	  slapi_ch_free ( (void **) &resultpb );
	  slapi_ch_free ( (void **) &estr );
	}
  }
}


/* del_dslite_entries: delete the DirLite specific entries */
static void 
del_dslite_entries() {
  Slapi_PBlock *resultpb;
  LDAPDebug( LDAP_DEBUG_TRACE, "Deleting lite entries if they exist\n",0,0,0);
  resultpb = slapi_delete_internal (  LITE_DISABLED_ATTRS_DN, NULL, 0 );
  slapi_pblock_destroy ( resultpb );
  resultpb = slapi_delete_internal (  LITE_DISABLED_MODULES_DN,  NULL, 0 );
  slapi_pblock_destroy ( resultpb );
}

/* lite_entries_init()
 * Add the appropriate entries under cn=options,cn=features,cn=config if the
 * server is running as Directory Lite.
 *
 * Otherwise, if the server is the Full Directory, try to delete the entries if
 * they're already there.
 */
   
void
lite_entries_init() {
  if ( config_is_slapd_lite() ) {
	add_dslite_entries();
  }
  else {
	del_dslite_entries();
  }
}