From b893574f32a420a256596da6c795cf48e5f50cf0 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 7 May 2008 06:44:17 +0000 Subject: [PATCH] Fixed add/remove of policies. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10797 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../services/kerberos/class_goKrbServer.inc | 31 +++++++------ .../services/kerberos/class_krb5_policy.inc | 44 ++++++++++++++++--- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc index 9478b9c0b..707b80f55 100644 --- a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc +++ b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc @@ -301,33 +301,36 @@ class goKrbServer extends goService{ foreach($this->policies as $policy){ switch($policy['STATUS']){ case "REMOVED" : $actions['del'] [] = $policy;break; - case "ADDED" : $actions['add'] [] = $policy;break; - case "EDITED" : $actions['edit'][] = $policy;break; + case "ADDED" : + case "EDITED" : $actions['add_edit'] [] = $policy;break; } } $o = new gosaSupportDaemon(); + $policies = $o->krb5_list_policies($this->macAddress); + /* Send remove policy event */ foreach($actions['del'] as $policy){ + if(!in_array($policy['NAME'],$policies)) continue; if(!$o->krb5_del_policy($this->macAddress,$policy['NAME'])){ msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG); } } - /* Send add new policy event - */ - foreach($actions['add'] as $policy){ - if(!$o->krb5_add_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){ - msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG); - } - } - - /* Send update policy event + /* Send add new/edit policy event */ - foreach($actions['edit'] as $policy){ - if(!$o->krb5_set_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){ - msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG); + foreach($actions['add_edit'] as $policy){ + if(in_array($policy['NAME'],$policies)){ + if(!$o->krb5_set_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG); + } + }else{ + unset($policy['DATA']['MASK']); + unset($policy['DATA']['POLICY_REFCNT']); + if(!$o->krb5_add_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG); + } } } } diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc index 7dac3ac5f..24df26203 100644 --- a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc +++ b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc @@ -21,9 +21,13 @@ class krb5_policy extends plugin $this->name = $entry['NAME']; $this->data = $entry['DATA']; }else{ - foreach($this->attributes as $attr){ - $this->data[$attr] = 0; - } + $this->data['MASK'] = 0; + $this->data['POLICY_REFCNT'] = 0; + $this->data['PW_HISTORY_NUM'] = 5; + $this->data['PW_MAX_LIFE'] = 604800; + $this->data['PW_MIN_CLASSES'] = 3; + $this->data['PW_MIN_LENGTH'] = 6; + $this->data['PW_MIN_LIFE'] = 36000; } $this->init_name = $this->name; } @@ -58,12 +62,40 @@ class krb5_policy extends plugin public function check() { - $messages = array(); + $message = array(); $names = $this->parent->getPolicyNames(); if($this->name != $this->init_name && in_array($this->name,$names)){ - $messages[] = msgPool::duplicated(_("Name")); + $message[] = msgPool::duplicated(_("Name")); + } + if(empty($this->name)){ + $message[] = msgPool::required(_("Name")); + } + + if(!preg_match("/^[a-z0-9\@\.\-_]*$/i",$this->name)){ + $message[] = msgPool::invalid(_("Name"),$this->name,"/[a-z0-9]/i"); + } + + /* Check password history */ + if(!is_numeric($this->data['PW_HISTORY_NUM'])){ + $message[] = msgPool::invalid(_("Password history")); + }elseif($this->data['PW_HISTORY_NUM'] <= 0){ + $message[] = msgPool::toosmall(_("Password history")); + } + + /* Check password */ + if(!is_numeric($this->data['PW_MIN_LENGTH'])){ + $message[] = msgPool::invalid(_("Password minimum length")); + }elseif($this->data['PW_MIN_LENGTH'] <= 0){ + $message[] = msgPool::toosmall(_("Password minimum length")); + } + + /* Check password history */ + if(!is_numeric($this->data['PW_MIN_LENGTH'])){ + $message[] = msgPool::invalid(_("Password minimum length")); + }elseif($this->data['PW_MIN_LENGTH'] <= 0){ + $message[] = msgPool::toosmall(_("Password minimum length")); } - return($messages); + return($message); } -- 2.30.2