Stop/start/apply buttons, size and time limits

This commit is contained in:
Jamie Cameron
2007-11-18 07:57:22 +00:00
parent 32fc33df97
commit b15b52090e
7 changed files with 95 additions and 1 deletions

View File

@@ -9,3 +9,8 @@ config_file=OpenLDAP server configuration file,8
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

View File

@@ -68,6 +68,16 @@ print &ui_table_row($text{'slapd_allow'},
( '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'} ] ]);

View File

@@ -47,6 +47,11 @@ slapd_bind_v2=Allow LDAP v2 clients
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
@@ -123,8 +128,13 @@ create_title=Create Tree
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

View File

@@ -6,7 +6,6 @@
# XXX install ldap server
# XXX more slapd.conf options
# XXX SSL certs
# XXX sizelimit / timelimit
# XXX schemacheck / gentlehup
do '../web-lib.pl';
@@ -231,16 +230,48 @@ for(my $i=0; $i<@old || $i<@values; $i++) {
}
}
# 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()

View File

@@ -38,6 +38,22 @@ $in{'dbcachesize'} =~ /^\d+$/ || &error($text{'slapd_edbcachesize'});
@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'});

11
ldap-server/start.cgi Normal file
View File

@@ -0,0 +1,11 @@
#!/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("");

11
ldap-server/stop.cgi Normal file
View File

@@ -0,0 +1,11 @@
#!/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("");