2 # Update local LDAP server configuration options
4 require './ldap-server-lib.pl';
5 &error_setup($text{'slapd_err'});
6 $access{'slapd'} || &error($text{'slapd_ecannot'});
7 &local_ldap_server() == 1 || &error($text{'slapd_elocal'});
11 $conf = &get_config();
13 # Validate and store inputs
16 $in{'suffix'} =~ /=/ || &error($text{'slapd_esuffix'});
17 &save_directive($conf, 'suffix', $in{'suffix'});
20 $in{'rootdn'} =~ /=/ || &error($text{'slapd_erootdn'});
21 &save_directive($conf, 'rootdn', $in{'rootdn'});
24 if (!$in{'rootchange_def'}) {
25 $in{'rootchange'} =~ /\S/ || &error($text{'slapd_erootpw'});
26 $crypt = &unix_crypt($in{'rootchange'}, substr(time(), -2));
27 &save_directive($conf, 'rootpw', "{crypt}".$crypt);
28 $config{'pass'} = $in{'rootchange'};
33 if (!$in{'cachesize_def'}) {
34 $in{'cachesize'} =~ /^\d+$/ || &error($text{'slapd_ecachesize'});
35 &save_directive($conf, 'cachesize', $in{'cachesize'});
38 &save_directive($conf, 'cachesize', undef);
40 if (!$in{'dbcachesize_def'}) {
41 $in{'dbcachesize'} =~ /^\d+$/ || &error($text{'slapd_edbcachesize'});
42 &save_directive($conf, 'dbcachesize', $in{'dbcachesize'});
45 &save_directive($conf, 'dbcachesize', undef);
48 # Access control options
49 @allow = split(/\0/, $in{'allow'});
50 &save_directive($conf, 'allow', @allow ? \@allow : undef);
52 # Size and time limits
53 if ($in{'sizelimit_def'}) {
54 &save_directive($conf, 'sizelimit', undef);
57 $in{'sizelimit'} =~ /^[1-9]\d*$/ || &error($text{'slapd_esizelimit'});
58 &save_directive($conf, 'sizelimit', $in{'sizelimit'});
60 if ($in{'timelimit_def'}) {
61 &save_directive($conf, 'timelimit', undef);
64 $in{'timelimit'} =~ /^[1-9]\d*$/ || &error($text{'slapd_etimelimit'});
65 &save_directive($conf, 'timelimit', $in{'timelimit'});
69 if (&can_get_ldap_protocols()) {
70 @newprotos = split(/\0/, $in{'protos'});
71 @newprotos || &error($text{'slapd_eprotos'});
75 foreach $s ([ 'TLSCertificateFile', 'cert' ],
76 [ 'TLSCertificateKeyFile', 'key' ],
77 [ 'TLSCACertificateFile', 'ca' ]) {
78 if ($in{$s->[1].'_def'}) {
79 &save_directive($conf, $s->[0], undef);
82 &valid_pem_file($in{$s->[1]}, $s->[1]) ||
83 &error($text{'slapd_e'.$s->[1]});
84 &save_directive($conf, $s->[0], $in{$s->[1]});
89 &flush_file_lines($config{'config_file'});
90 &unlock_slapd_files();
92 &lock_file($module_config_file);
93 &save_module_config();
94 &unlock_file($module_config_file);
96 if (&can_get_ldap_protocols()) {
97 $protos = &get_ldap_protocols();
98 foreach $p (keys %$protos) {
101 foreach $p (@newprotos) {
104 &save_ldap_protocols($protos);
106 &webmin_log('slapd');