Enable/disable at boot
authorJamie Cameron <jcameron@webmin.com>
Sat, 15 Dec 2007 00:37:55 +0000 (00:37 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 15 Dec 2007 00:37:55 +0000 (00:37 +0000)
ldap-server/acl_security.pl
ldap-server/apply.cgi
ldap-server/bootup.cgi [new file with mode: 0644]
ldap-server/index.cgi
ldap-server/lang/en
ldap-server/ldap-server-lib.pl
ldap-server/start.cgi
ldap-server/stop.cgi

index fcdeb43..7e7d255 100644 (file)
@@ -1,6 +1,7 @@
 
 do 'ldap-server-lib.pl';
-@acl_functions = ( 'slapd', 'schema', 'acl', 'browser', 'create' );
+@acl_functions = ( 'slapd', 'schema', 'acl', 'browser', 'create', 'start',
+                  'apply' );
 
 # acl_security_form(&options)
 # Output HTML for editing security options for the acl module
index 2760c8b..b672901 100644 (file)
@@ -3,6 +3,7 @@
 
 require './ldap-server-lib.pl';
 &error_setup($text{'apply_err'});
+$access{'apply'} || &error($text{'apply_ecannot'});
 $err = &apply_configuration();
 &error($err) if ($err);
 &webmin_log('apply');
diff --git a/ldap-server/bootup.cgi b/ldap-server/bootup.cgi
new file mode 100644 (file)
index 0000000..171d27d
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/local/bin/perl
+# Enable or disable the LDAP server at boot
+
+require './ldap-server-lib.pl';
+&error_setup($text{'bootup_err'});
+&local_ldap_server() == 1 || &error($text{'slapd_elocal'});
+$access{'start'} || &error($text{'bootup_ecannot'});
+&ReadParse();
+
+&foreign_require("init", "init-lib.pl");
+$iname = $config{'init_name'} || $module_name;
+if ($in{'boot'}) {
+       $conf = &get_config();
+       $pidfile = &find_value("pidfile", $conf);
+       &init::enable_at_boot($iname, "Start OpenLDAP server",
+                             "$config{'slapd'} 2>&1 </dev/null",
+                             "kill `cat $pidfile`");
+       }
+else {
+       &init::disable_at_boot($iname);
+       }
+&webmin_log("boot", undef, $in{'boot'});
+&redirect("");
+
index 9577441..7426d6b 100644 (file)
@@ -54,24 +54,30 @@ if ($local == 1) {
        print "<hr>\n";
        print &ui_buttons_start();
        if (&is_ldap_server_running()) {
-               print &ui_buttons_row("apply.cgi", $text{'index_apply'},
-                                     $text{'index_applydesc'});
-               print &ui_buttons_row("stop.cgi", $text{'index_stop'},
-                                     $text{'index_stopdesc'});
+               if ($access{'apply'}) {
+                       print &ui_buttons_row("apply.cgi", $text{'index_apply'},
+                                             $text{'index_applydesc'});
+                       }
+               if ($access{'start'}) {
+                       print &ui_buttons_row("stop.cgi", $text{'index_stop'},
+                                             $text{'index_stopdesc'});
+                       }
                }
        else {
-               print &ui_buttons_row("start.cgi", $text{'index_start'},
-                                     $text{'index_startdesc'});
+               if ($access{'start'}) {
+                       print &ui_buttons_row("start.cgi", $text{'index_start'},
+                                             $text{'index_startdesc'});
+                       }
                }
 
        # Start at boot button
-       if (&foreign_check("init")) {
-               $iname = $config{'init_name'} || $module_name;
+       if (&foreign_check("init") && $access{'start'}) {
                &foreign_require("init", "init-lib.pl");
+               $iname = $config{'init_name'} || $module_name;
                $st = &init::action_status($iname);
                print &ui_buttons_row("bootup.cgi", $text{'index_boot'},
                                      $text{'index_bootdesc'},
-                                     &ui_hidden("iname", $iname),
+                                     undef,
                                      &ui_yesno_radio("boot",$st == 2 ? 1 : 0));
                }
        print &ui_buttons_end();
index b2880c6..e82974f 100644 (file)
@@ -185,14 +185,17 @@ eunknown=Unknown error
 
 apply_err=Failed to apply configuration
 apply_ecmd=$1 failed : $2
+apply_ecannot=You are not allowed to apply the configuration
 
 stop_err=Failed to stop LDAP server
 stop_ecmd=$1 failed : $2
 stop_egone=No longer running!
 stop_ekill=Kill process failed : $1
+stop_ecannot=You are not allowed to stop the LDAP server
 
 start_err=Failed to start LDAP server
 start_ecmd=$1 failed : $2
+start_ecannot=You are not allowed to start the LDAP server
 
 log_create_dn=Created object $1
 log_delete_dn=Deleted object $1
@@ -231,3 +234,5 @@ acl_schema=Can manage schema?
 acl_acl=Can edit access control?
 acl_browser=Can browse and edit database?
 acl_create=Can create new tree?
+acl_start=Can start and stop LDAP server?
+acl_apply=Can apply configuration changes?
index 57d6c61..7777c3d 100644 (file)
@@ -1,7 +1,7 @@
 # Functions for configuring and talking to an LDAP server
 # XXX help pages
 # XXX init ldap server
-# XXX start at boot
+# XXX acl section
 
 do '../web-lib.pl';
 &init_config();
index a68dd1d..6fb2c92 100644 (file)
@@ -3,6 +3,7 @@
 
 require './ldap-server-lib.pl';
 &error_setup($text{'start_err'});
+$access{'start'} || &error($text{'start_ecannot'});
 $err = &start_ldap_server();
 &error($err) if ($err);
 &webmin_log('start');
index b2240c1..9097729 100644 (file)
@@ -3,6 +3,7 @@
 
 require './ldap-server-lib.pl';
 &error_setup($text{'stop_err'});
+$access{'start'} || &error($text{'stop_ecannot'});
 $err = &stop_ldap_server();
 &error($err) if ($err);
 &webmin_log('stop');