X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_userinfo.inc;h=992f3da004b79c77a9db20bd85d77452b4b13287;hb=ec7198b4b87d963ce804f052eafc90e69858f93f;hp=f6de37d19a33ab88a6433a59b338c4306ca78cbe;hpb=92ff1c041db9c645b1c93509df1cf089bcd5f082;p=gosa.git diff --git a/gosa-core/include/class_userinfo.inc b/gosa-core/include/class_userinfo.inc index f6de37d19..992f3da00 100644 --- a/gosa-core/include/class_userinfo.inc +++ b/gosa-core/include/class_userinfo.inc @@ -80,7 +80,7 @@ class userinfo public function reset_acl_cache() { /* Initialize ACL_CACHE */ - session::set('ACL_CACHE',array()); + session::global_set('ACL_CACHE',array()); } function loadACL() @@ -158,8 +158,9 @@ class userinfo /* Inspect members... */ foreach ($type['members'] as $grp => $grpdsc){ + /* Some group inside the members that is relevant for us? */ - if (in_array_ics(preg_replace('/^G:/', '', $grp), $this->groups)){ + if (in_array_ics(@LDAP::convert(preg_replace('/^G:/', '', $grp)), $this->groups)){ $interresting= TRUE; } @@ -181,29 +182,63 @@ class userinfo /* Create an array which represenet all relevant permissions settings per dn. + + The array will look like this: + + . ['ou=base'] ['ou=base'] = array(ACLs); + . + . ['ou=dep1,ou=base']['ou=dep1,ou=base'] = array(ACLs); + . ['ou=base'] = array(ACLs); + + + For object located in 'ou=dep1,ou=base' we have to both ACLs, + for objects in 'ou=base' we only have to apply on ACL. */ - $tmp = array(); + $without_self_acl = $all_acl = array(); foreach($this->ACL as $dn => $acl){ $sdn =$dn; - while(strpos($dn,",") !== FALSE){ + $first= TRUE; // Run at least once + while(strpos($dn,",") !== FALSE || $first){ + $first = FALSE; if(isset($this->ACL[$dn])){ - $tmp[$sdn][$dn] = $this->ACL[$dn]; - foreach($this->ACL[$dn] as $aclset){ - if(isset($aclset['filter']{1})){ + $all_acl[$sdn][$dn] = $this->ACL[$dn]; + $without_self_acl[$sdn][$dn] = $this->ACL[$dn]; + foreach($without_self_acl[$sdn][$dn] as $acl_id => $acl_set){ + + /* Remember which ACL set has speicial user filter + */ + if(isset($acl_set['filter']{1})){ $this->ACLperPath_usesFilter[$sdn] = TRUE; } + + /* Remove all acl entries which are especially for the current user (self acl) + */ + foreach($acl_set['acl'] as $object => $object_acls){ + if(strpos($object_acls[0],"s")){ + unset($without_self_acl[$sdn][$dn][$acl_id]['acl'][$object]); + } + } } } $dn = preg_replace("/^[^,]*+,/","",$dn); } } - $this->ACLperPath =$tmp; + $this->ACLperPath =$without_self_acl; + + /* Append Self entry */ + $dn = $this->dn; + while(strpos($dn,",") && !isset($all_acl[$dn])){ + $dn = preg_replace("/^[^,]*+,/","",$dn); + } + if(isset($all_acl[$dn])){ + $this->ACLperPath[$this->dn] = $all_acl[$dn]; + } } function get_category_permissions($dn, $category, $any_acl = FALSE) { - return(@$this->get_permissions($dn,$category.'/0')); + return(@$this->get_permissions($dn,$category.'/0',"")); } @@ -295,11 +330,11 @@ class userinfo } /* Push cache answer? */ - $ACL_CACHE = &session::get('ACL_CACHE'); + $ACL_CACHE = &session::global_get('ACL_CACHE'); if (isset($ACL_CACHE["$dn+$object+$attribute"])){ $ret = $ACL_CACHE["$dn+$object+$attribute"]; if($skip_write){ - $ret = preg_replace('/w/', '',$ret); + $ret = str_replace(array('w','c','d','m'), '',$ret); } return($ret); } @@ -329,7 +364,7 @@ class userinfo $ACL_CACHE["$orig_dn+$object+$attribute"] = $ACL_CACHE["$dn+$object+$attribute"]; } if($skip_write){ - $ret = preg_replace('/w/','',$ret); + $ret = str_replace('w','',$ret); } return($ret); } @@ -389,7 +424,7 @@ class userinfo /* Self ACLs? */ - if($dn != $this->dn && isset($subacl['acl'][$object][0]) && strpos($subacl['acl'][$object][0],"s")){ + if($dn != $this->dn && isset($subacl['acl'][$object][0]) && (strpos($subacl['acl'][$object][0],"s") !== FALSE)){ continue; } @@ -421,13 +456,32 @@ class userinfo continue; } - /* Category ACLs */ + /* Category ACLs (e.g. $object = "user/0") + */ if(strstr($object,"/0")){ $ocs = preg_replace("/\/0$/","",$object); - if(isset($this->ocMapping[$ocs])) - foreach($this->ocMapping[$ocs] as $oc){ - if(isset($subacl['acl'][$ocs.'/'.$oc][0])){ - $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][0]); + if(isset($this->ocMapping[$ocs])){ + + /* if $attribute is "", then check every single attribute for this object. + if it is 0, then just check the object category ACL. + */ + if($attribute == ""){ + foreach($this->ocMapping[$ocs] as $oc){ + if (isset($subacl['acl'][$ocs.'/'.$oc])){ + + if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue; + + foreach($subacl['acl'][$ocs.'/'.$oc] as $attr => $dummy){ + $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][$attr]); + } + continue; + } + } + }else{ + if(isset($subacl['acl'][$ocs.'/'.$oc][0])){ + if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue; + $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][0]); + } } } continue; @@ -456,7 +510,7 @@ class userinfo /* Remove write if needed */ if ($skip_write){ - $ret= preg_replace('/w/', '', $ret); + $ret = str_replace(array('w','c','d','m'), '',$ret); } return ($ret); } @@ -474,7 +528,7 @@ class userinfo } /* Use cached results if possilbe */ - $ACL_CACHE = &session::get('ACL_CACHE'); + $ACL_CACHE = &session::global_get('ACL_CACHE'); if(!is_array($module)){ $module = array($module); @@ -497,8 +551,8 @@ class userinfo foreach($info['acl'] as $cat => $data){ /* Skip self acls? */ - if($skip_self_acls && isset($data['0']) && strpos($data['0'], "s")) continue; - if(preg_match("/^".normalizePreg($mod)."/",$cat)){ + if($skip_self_acls && isset($data['0']) && (strpos($data['0'], "s") !== FALSE)) continue; + if(preg_match("/^".preg_quote($mod, '/')."/",$cat)){ $found =TRUE; break; } @@ -509,7 +563,7 @@ class userinfo $dn = preg_replace("/^[^,]+,/","",$dn); } if(isset($this->config->idepartments[$dn])){ - $deps[] = $dn; + $deps[$dn] = $dn; } } } @@ -517,7 +571,7 @@ class userinfo /* For all gosaDepartments */ foreach ($this->config->departments as $dn){ - if(in_array($dn,$deps)) continue; + if(isset($deps[$dn])) continue; $acl = ""; if(strpos($mod, '/')){ $acl.= $this->get_permissions($dn,$mod); @@ -525,14 +579,15 @@ class userinfo $acl.= $this->get_category_permissions($dn,$mod,TRUE); } if(!empty($acl)) { - $deps[] = $dn; + $deps[$dn] = $dn; } } $ACL_CACHE['MODULE_DEPARTMENTS'][$mod] = $deps; $res = array_merge($res,$deps); - } - return ($res); + } + + return (array_values($res)); } @@ -549,6 +604,11 @@ class userinfo foreach(str_split($newACL) as $char){ + /* Skip "self" ACLs without combination of rwcdm, they have no effect. + -self flag without read/write/create/... + */ + if(empty($char)) continue; + /* Skip permanent and subtree entries */ if (preg_match('/[sp]/', $acl[$char])){ continue;