summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f82a2b)
raw | patch | inline | side by side (parent: 2f82a2b)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 3 Apr 2008 09:52:45 +0000 (09:52 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 3 Apr 2008 09:52:45 +0000 (09:52 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10133 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/admin/sudo/class_sudoOptions.inc | patch | blob | history | |
gosa-core/plugins/admin/sudo/options.tpl | patch | blob | history |
diff --git a/gosa-core/plugins/admin/sudo/class_sudoOptions.inc b/gosa-core/plugins/admin/sudo/class_sudoOptions.inc
index 0b1572211b94b18e4d0da7e5706c217ed6201ad9..2bf27f8234157e9387d1e5b1439f13ea023e2d91 100644 (file)
{
plugin::plugin ($config, $dn);
+ /****
+ Create a list of known options
+ ****/
$options = array();
-
- $option['long_otp_prompt']= array('NAME' =>'long_otp_prompt' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['ignore_dot']= array('NAME' =>'ignore_dot' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['mail_always']= array('NAME' =>'mail_always' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['mail_badpass']= array('NAME' =>'mail_badpass' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['mail_no_user']= array('NAME' =>'mail_no_user' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['mail_no_host']= array('NAME' =>'mail_no_host' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['mail_no_perms']= array('NAME' =>'mail_no_perms' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['tty_tickets']= array('NAME' =>'tty_tickets' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['authenticate']= array('NAME' =>'authenticate' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['root_sudo']= array('NAME' =>'root_sudo' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['log_host']= array('NAME' =>'log_host' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['log_year']= array('NAME' =>'log_year' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['shell_noargs']= array('NAME' =>'shell_noargs' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['set_home']= array('NAME' =>'set_home' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['always_set_home']= array('NAME' =>'always_set_home' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['path_info']= array('NAME' =>'path_info' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['preserve_groups']= array('NAME' =>'preserve_groups' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['fqdn']= array('NAME' =>'fqdn' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['insults']= array('NAME' =>'insults' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['requiretty']= array('NAME' =>'requiretty' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['env_editor']= array('NAME' =>'env_editor' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['rootpw']= array('NAME' =>'rootpw' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['runaspw']= array('NAME' =>'runaspw' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['targetpw']= array('NAME' =>'targetpw' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['set_logname']= array('NAME' =>'set_logname' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['stay_setuid']= array('NAME' =>'stay_setuid' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['env_reset']= array('NAME' =>'env_reset' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['use_loginclass']= array('NAME' =>'use_loginclass' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['noexec']= array('NAME' =>'noexec' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['ignore_local_sudoers']= array('NAME' =>'ignore_local_sudoers' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
- $option['passwd_tries']= array('NAME' =>'passwd_tries' , 'TYPE' => 'INTEGER' , 'DEFAULT' => '');
- $option['loglinelen']= array('NAME' =>'loglinelen' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
- $option['timestamp_timeout']= array('NAME' =>'timestamp_timeout' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
- $option['passwd_timeout']= array('NAME' =>'passwd_timeout' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
- $option['umask']= array('NAME' =>'umask' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
- $option['mailsub']= array('NAME' =>'mailsub' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['badpass_message']= array('NAME' =>'badpass_message' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['timestampdir']= array('NAME' =>'timestampdir' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['timestampowner']= array('NAME' =>'timestampowner' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['passprompt']= array('NAME' =>'passprompt' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['runas_default']= array('NAME' =>'runas_default' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['syslog_goodpri']= array('NAME' =>'syslog_goodpri' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['syslog_badpri']= array('NAME' =>'syslog_badpri' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['editor']= array('NAME' =>'editor' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['noexec_file']= array('NAME' =>'noexec_file' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['lecture']= array('NAME' =>'lecture' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['lecture_file']= array('NAME' =>'lecture_file' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['logfile']= array('NAME' =>'logfile' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['syslog']= array('NAME' =>'syslog' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['mailerpath']= array('NAME' =>'mailerpath' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['mailerflags']= array('NAME' =>'mailerflags' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['mailto']= array('NAME' =>'mailto' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['exempt_group']= array('NAME' =>'exempt_group' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['verifypw']= array('NAME' =>'verifypw' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['listpw']= array('NAME' =>'listpw' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
- $option['env_check']= array('NAME' =>'env_check' , 'TYPE' => 'LISTS' , 'DEFAULT' => '');
- $option['env_delete']= array('NAME' =>'env_delete' , 'TYPE' => 'LISTS' , 'DEFAULT' => '');
- $option['env_keep']= array('NAME' =>'env_keep' , 'TYPE' => 'LISTS' , 'DEFAULT' => '');
$option['long_otp_prompt']= array('NAME' =>'long_otp_prompt' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
$option['ignore_dot']= array('NAME' =>'ignore_dot' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
$option['mail_always']= array('NAME' =>'mail_always' , 'TYPE' => 'BOOLEAN' , 'DEFAULT' => '');
$option['timestamp_timeout']= array('NAME' =>'timestamp_timeout' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
$option['passwd_timeout']= array('NAME' =>'passwd_timeout' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
$option['umask']= array('NAME' =>'umask' , 'TYPE' => 'BOOL_INTEGER' , 'DEFAULT' => '');
- $option['mailsub']= array('NAME' =>'mailsub' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['badpass_message']= array('NAME' =>'badpass_message' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['timestampdir']= array('NAME' =>'timestampdir' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['timestampowner']= array('NAME' =>'timestampowner' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['passprompt']= array('NAME' =>'passprompt' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['runas_default']= array('NAME' =>'runas_default' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['syslog_goodpri']= array('NAME' =>'syslog_goodpri' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['syslog_badpri']= array('NAME' =>'syslog_badpri' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['editor']= array('NAME' =>'editor' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
- $option['noexec_file']= array('NAME' =>'noexec_file' , 'TYPE' => 'STRINGS' , 'DEFAULT' => '');
+ $option['mailsub']= array('NAME' =>'mailsub' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['badpass_message']= array('NAME' =>'badpass_message' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['timestampdir']= array('NAME' =>'timestampdir' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['timestampowner']= array('NAME' =>'timestampowner' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['passprompt']= array('NAME' =>'passprompt' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['runas_default']= array('NAME' =>'runas_default' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['syslog_goodpri']= array('NAME' =>'syslog_goodpri' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['syslog_badpri']= array('NAME' =>'syslog_badpri' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['editor']= array('NAME' =>'editor' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
+ $option['noexec_file']= array('NAME' =>'noexec_file' , 'TYPE' => 'STRING' , 'DEFAULT' => '');
$option['lecture']= array('NAME' =>'lecture' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
$option['lecture_file']= array('NAME' =>'lecture_file' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
$option['logfile']= array('NAME' =>'logfile' , 'TYPE' => 'STRING_BOOL' , 'DEFAULT' => '');
ksort($option);
$this->options = $option;
-
+ /****
+ Parse given sudoOption attributes
+ ****/
$this->sudoOption = array();
-
if(isset($this->attrs['sudoOption'])){
for($i = 0 ; $i < $this->attrs['sudoOption']['count']; $i++){
- $negation = FALSE;
- $value = "";
-
+ /****
+ Detect attribute name/value/negation
+ ****/
$opt = $this->attrs['sudoOption'][$i];
+
+ /* Get negation */
+ $negation = FALSE;
if(preg_match("/^!/",$opt)){
$negation = TRUE;
$opt = preg_replace("/^!/","",$opt);
}
+ /* Get value / name*/
+ $value = "";
if(preg_match("/=/",$opt)){
$value = preg_replace("/^[^=]*+=/","",$opt);
$opt = preg_replace("/=.*$/","",$opt);
}
+ /* Check if the given value is part of our options list.
+ If it is not, add it as type STRING and display a warning.
+ */
+ if(!isset($this->options[$opt])){
+ $this->options[$opt]=array('NAME'=>$opt,'TYPE'=>'STRING','DEFAULT' => '');
+ msg_dialog::display(_("Unknown option"),
+ sprintf(_("The sudo option '%s' is unkown to GOsa, it is now temporarily added as type string."),
+ $opt),WARNING_DIALOG);
+ }
+
+ /* Create internal sudoOption object */
$option = array();
$option['NAME'] = $opt;
$option['VALUE'] = array($value);
}
}
+ /* Special handling for BOOLEAN values */
if(in_array($this->options[$opt]['TYPE'],array("BOOLEAN"))){
$option['NEGATE'] = FALSE;
if($negation){
}
}
+ /* Append values */
if(!isset($this->sudoOption[$opt])){
$this->sudoOption[$opt] = $option;
}else{
/* Call parent execute */
plugin::execute();
+ /*****
+ Handle Posts
+ *****/
foreach($_POST as $name => $value){
if(preg_match("/^negOption_/",$name)){
$opt = preg_replace("/^negOption_/","",$name);
}
break;
}
+
+ if(preg_match("/^delOption_/",$name)){
+
+ /*****
+ Remove options
+ *****/
+ $opt = preg_replace("/^delOption_/","",$name);
+ $opt = preg_replace("/_[^_]*$/","",$opt);
+ if(isset($this->sudoOption[$opt])){
+ unset($this->sudoOption[$opt]);
+ }
+ break;
+ }
}
$smarty = get_smarty();
- $smarty->assign("map", array("STRINGS" => _("string"), "BOOLEAN" => _("bool"),
+ $smarty->assign("map", array("STRING" => _("string"), "BOOLEAN" => _("bool"),
"INTEGER" => _("integer") , "BOOL_INTEGER" => _("integer")."-"._("bool") ,
"STRING_BOOL" => _("string")."-"._("bool"),"LISTS" => _("lists")));
$smarty->assign("sudoOption",$this->sudoOption);
{
plugin::save_object();
+ if(isset($_POST['add_option']) && isset($_POST['option'])){
+ $opt = get_post("option");
+ if(isset($this->options[$opt]) && !isset($this->sudoOption[$opt])){
+ $type = $this->options[$opt]['TYPE'];
+ $val = array($this->options[$opt]['DEFAULT']);
+ $option = array("NAME" => $opt, "VALUE" => $val , "NEGATE" => FALSE);
+ $this->sudoOption[$opt] = $option;
+ }
+ }
+
foreach($this->sudoOption as $name => $opt){
/****
Get posted value for BOOLEAN
****/
if(in_array($this->options[$name]['TYPE'],array("BOOLEAN"))){
- $this->sudoOption[$name]['VALUE'][0] = get_post('option_value__'.$name);
+ if(isset($_POST['option_value__'.$name])){
+ $this->sudoOption[$name]['VALUE'][0] = get_post('option_value__'.$name);
+ }
}
/****
index 94685e32e3988ebc431f6f0acd9308b7a5cd9d30..c1dbe46da84f24553fb2f8d4ae92d9691f50ce71 100644 (file)
<select name='option'>
{foreach from=$options item=item key=key}
+ {if !isset($sudoOption.$key)}
<option value='{$key}'>{$item.NAME} ({$map[$item.TYPE]})</option>
+ {/if}
{/foreach}
</select>
-
+<input type="submit" name="add_option" value="{msgPool type=addButton}">
<table>
{foreach from=$sudoOption item=item key=key}