diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc b/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc
index 0e139d7a6b496bb9fab35c4b7cfea02815882028..d52deed8416541e566e1044e473a3c34417d3238 100644 (file)
public $ignore_account = TRUE;
+
public $orig_dn;
+ private $systemEnabled = FALSE;
/*! \brief Returns to the base department for sudo roles.
This department is then used to store new roles.
{
plugin::plugin ($config, $dn);
+ $this->systemEnabled = class_available("systemSelect");
+
$this->trustModeDialog = new trustModeDialog($this->config, $this->dn,NULL);
$this->trustModeDialog->setAcl('sudo/sudo');
/* Call parent execute */
plugin::execute();
+ // Set list ACLs
+ foreach(array('sudoUser','sudoCommand','sudoHost','sudoRunAs') as $l){
+ $ll = $l."List";
+ $this->$ll->setAcl($this->getacl($l));
+ }
+
// Handle trust mode dialog
$trustModeDialog = $this->trustModeDialog->execute();
if($this->trustModeDialog->trustSelect){
return($trustModeDialog);
}
- $this->dialog = FALSE;
+
+ if(!is_object($this->dialog)){
+ $this->dialog = FALSE;
+ }
/*********************
Add users
if(isset($_POST['userGroupSelect_save']) && $this->dialog instanceof userGroupSelect){
if($this->acl_is_writeable("sudoUser")){
foreach($this->dialog->save() as $entry){
- if(in_array("posixGroup",$entry['objectClass'])){
+ if(in_array_strict("posixGroup",$entry['objectClass'])){
$name = trim("%".$entry['cn'][0]);
}elseif(isset($entry['uid'][0])){
$name = trim($entry['uid'][0]);
}
- if(!in_array($name,$this->sudoUser) && !in_array("!".$name,$this->sudoUser)){
+ if(!in_array_strict($name,$this->sudoUser) && !in_array_strict("!".$name,$this->sudoUser)){
$this->sudoUser[] = $name;
}
}
if($this->acl_is_writeable("sudoHost")){
foreach($this->dialog->save() as $entry){
$cn = trim($entry['cn'][0]);
- if(!in_array($cn,$this->sudoHost) && !in_array("!".$cn,$this->sudoHost)){
+ if(!in_array_strict($cn,$this->sudoHost) && !in_array_strict("!".$cn,$this->sudoHost)){
$this->sudoHost[] = $cn;
}
}
NEGATE values
*********************/
foreach($_POST as $name => $value){
+ $value =get_post($name);
if(preg_match("/^neg_/",$name)){
$attr = preg_replace("/^neg_([^_]*)_.*$/","\\1",$name);
$value= preg_replace("/^neg_[^_]*_([0-9]*)$/","\\1",$name);
Delete values
*********************/
foreach($_POST as $name => $value){
+ $value =get_post($name);
if(preg_match("/^delS_/",$name)){
$attr = preg_replace("/^delS_([^_]*).*$/","\\1",$name);
$value= preg_replace("/^delS_[^_]*_([0-9]*)$/","\\1",$name);
isset($_POST["add_".$attr]) &&
isset($_POST['new_'.$attr]) &&
!empty($_POST['new_'.$attr])){
- if(preg_match("/^[a-z\.0-9]*$/i",$_POST['new_'.$attr])){
+
+ $c = preg_quote(' *+-?_|!\'"()','/');
+ if(preg_match("/^[a-z0-9{$c}]*$/i",get_post('new_'.$attr))){
$attrs = $this->$attr;
- $attrs[] = trim($_POST['new_'.$attr]);
+ $attrs[] = trim(get_post('new_'.$attr));
$this->$attr = $attrs;
}else{
- msg_dialog::display(_("Error"),msgPool::invalid($attr,$_POST['new_'.$attr],"/[a-z0-9]/"));
+ msg_dialog::display(_("Error"),msgPool::invalid($attr,get_post('new_'.$attr),"/[a-z0-9{$c}]/i"));
}
}
}
foreach(array("sudoCommand") as $attr){
if($this->acl_is_writeable($attr) && isset($_POST["add_".$attr]) && isset($_POST['new_'.$attr])){
$attrs = $this->$attr;
- $attrs[] = trim($_POST['new_'.$attr]);
+ $attrs[] = trim(get_post('new_'.$attr));
$this->$attr = $attrs;
}
}
*********************/
$smarty = get_smarty();
+ $smarty->assign("systemEnabled", $this->systemEnabled);
$smarty->assign("trustModeDialog" , $trustModeDialog);
$smarty->assign("is_default",$this->is_default);
foreach($this->attributes as $attr){
- if(is_string($this->$attr)){
- $smarty->assign($attr,htmlentities($this->$attr));
- }else{
- $smarty->assign($attr,$this->$attr);
- }
+ $smarty->assign($attr, set_post($this->$attr));
$smarty->assign($attr."ACL",$this->getacl($attr));
}
$ldap->add($this->attrs);
/* Send signal to the world that we've done */
- $this->handle_post_events("create");
+ $this->handle_post_events("add");
}else{
$ldap->cd($this->dn);
$ldap->modify($this->attrs);;
"plSection" => array("administration"),
"plCategory" => array("sudo" => array("objectClass" => "sudoRole", "description" => _("Sudo role"))),
+ "plProperties" =>
array(
array(
"name" => "sudoRDN",
"type" => "rdn",
"default" => "ou=sudoers,",
- "description" => "The 'sudoRDN' statement defines the location where new sudo-roles will be created. The default is 'ou=sudoers,'.",
+ "description" => _("RDN for sudo rule storage."),
"check" => "gosaProperty::isRdn",
"migrate" => "migrate_sudoRDN",
"group" => "plugin",
"mandatory" => FALSE)),
- "plProvidedAcls" => array(
- "accessTo" => _("System trust"),
- "cn" => _("Name"),
- "description" => _("Description"),
- "sudoUser" => _("Users"),
- "sudoHost" => _("Host"),
- "sudoCommand" => _("Command"),
- "sudoRunAs" => _("Run as user"),
- "trustModel" => _("Access control list"))
- ));
+ "plProvidedAcls" => array(
+ "accessTo" => _("System trust"),
+ "cn" => _("Name"),
+ "description" => _("Description"),
+ "sudoUser" => _("Users"),
+ "sudoHost" => _("Host"),
+ "sudoCommand" => _("Command"),
+ "sudoRunAs" => _("Run as user"),
+ "trustModel" => _("Access control list"))
+ ));
}
function PrepareForCopyPaste($source)
{
plugin::PrepareForCopyPaste($source);
-
+
$this->trustModeDialog->PrepareForCopyPaste($source);
foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
{
$vars = array("cn");
$smarty = get_smarty();
- $smarty->assign("cn", htmlentities($this->cn));
+ $smarty->assign("cn", set_post($this->cn));
$str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
$ret = array();
$ret['string'] = $str;