schema_dir=OpenLDAP schema directory,7
line2=User interface settings,11
+
+line3=LDAP server commands,11
+start_cmd=Command to start LDAP server,3,Just run <tt>slapd</tt>
+stop_cmd=Command to stop LDAP server,3,Just kill process
+apply_cmd=Command to apply configuration,3,Just stop and re-start
( 'bind_v2', 'bind_anon_cred',
'bind_anon_dn', 'update_anon' ) ], 4, 1, 1));
+# Size and time limits
+$sizelimit = &find_value('sizelimit', $conf);
+print &ui_table_row($text{'slapd_sizelimit'},
+ &ui_opt_textbox('sizelimit', $sizelimit, 10, $text{'default'}." (500)"));
+$timelimit = &find_value('timelimit', $conf);
+print &ui_table_row($text{'slapd_timelimit'},
+ &ui_opt_textbox('timelimit', $timelimit, 10,
+ $text{'default'}." (3600 $text{'slapd_secs'})").
+ " ".$text{'slapd_secs'});
+
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'save'} ] ]);
slapd_bind_anon_cred=Allow anonymous login with credentials
slapd_bind_anon_dn=Allow anonymous login with DN
slapd_update_anon=Allow updates by anonymous logins
+slapd_sizelimit=Maximum number of search results to return
+slapd_timelimit=Maximum time for searches
+slapd_secs=seconds
+slapd_esizelimit=Missing or non-numeric maximum number of search results to return
+slapd_etimelimit=Missing or non-numeric maximum time for searches
schema_title=Manage Schema
eunknown=Unknown error
apply_err=Failed to apply configuration
+apply_ecmd=$1 failed : $2
stop_err=Failed to stop LDAP server
+stop_ecmd=$1 failed : $2
+stop_egone=No longer running!
+stop_ekill=Kill process failed : $1
start_err=Failed to start LDAP server
+start_ecmd=$1 failed : $2
# XXX install ldap server
# XXX more slapd.conf options
# XXX SSL certs
-# XXX sizelimit / timelimit
# XXX schemacheck / gentlehup
do '../web-lib.pl';
}
}
+# start_ldap_server()
+# Attempts to start the LDAP server process. Returns undef on success or an
+# error message on failure.
sub start_ldap_server
{
+local $cmd = $config{'start_cmd'} || $config{'slapd'};
+local $out = &backquote_logged("$cmd 2>&1 </dev/null");
+return $? ? &text('start_ecmd', "<tt>$cmd</tt>",
+ "<pre>".&html_escape($out)."</pre>") : undef;
}
+# stop_ldap_server()
+# Attempts to stop the running LDAP server. Returns undef on success or an
+# error message on failure.
sub stop_ldap_server
{
+if ($config{'stop_cmd'}) {
+ local $out = &backquote_logged("$config{'stop_cmd'} 2>&1 </dev/null");
+ return $? ? &text('stop_ecmd', "<tt>$cmd</tt>",
+ "<pre>".&html_escape($out)."</pre>") : undef;
+ }
+else {
+ local $pid = &is_ldap_server_running();
+ $pid || return $text{'stop_egone'};
+ return kill('TERM', $pid) ? undef : &text('stop_ekill', $!);
+ }
}
+# apply_configuration()
+# Apply the current LDAP server configuration with a HUP signal
sub apply_configuration
{
+if ($config{'apply_cmd'}) {
+ local $out = &backquote_logged("$config{'apply_cmd'} 2>&1 </dev/null");
+ return $? ? &text('apply_ecmd', "<tt>$cmd</tt>",
+ "<pre>".&html_escape($out)."</pre>") : undef;
+ }
+else {
+ local $err = &stop_ldap_server();
+ return $err if ($err);
+ return &start_ldap_server();
+ }
}
# is_ldap_server_running()
@allow = split(/\0/, $in{'allow'});
&save_directive($conf, 'allow', @allow ? \@allow : undef);
+# Size and time limits
+if ($in{'sizelimit_def'}) {
+ &save_directive($conf, 'sizelimit', undef);
+ }
+else {
+ $in{'sizelimit'} =~ /^[1-9]\d*$/ || &error($text{'slapd_esizelimit'});
+ &save_directive($conf, 'sizelimit', $in{'sizelimit'});
+ }
+if ($in{'timelimit_def'}) {
+ &save_directive($conf, 'timelimit', undef);
+ }
+else {
+ $in{'timelimit'} =~ /^[1-9]\d*$/ || &error($text{'slapd_etimelimit'});
+ &save_directive($conf, 'timelimit', $in{'timelimit'});
+ }
+
# Write out the files
&flush_file_lines($config{'config_file'});
&unlock_file($config{'config_file'});
--- /dev/null
+#!/usr/local/bin/perl
+# Start the LDAP server
+
+require './ldap-server-lib.pl';
+&error_setup($text{'start_err'});
+$err = &start_ldap_server();
+&error($err) if ($err);
+&webmin_log('start');
+&redirect("");
+
+
--- /dev/null
+#!/usr/local/bin/perl
+# Stop the LDAP server
+
+require './ldap-server-lib.pl';
+&error_setup($text{'stop_err'});
+$err = &stop_ldap_server();
+&error($err) if ($err);
+&webmin_log('stop');
+&redirect("");
+
+