From: hickert Date: Wed, 16 May 2007 08:20:20 +0000 (+0000) Subject: Added logging to FAI X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a61ad5ca2a3c14ec273eb2cb047a6a0efcdaa823;p=gosa.git Added logging to FAI git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6390 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiHook.inc b/plugins/admin/fai/class_faiHook.inc index 9fdb2b15d..1fdbd52ff 100644 --- a/plugins/admin/fai/class_faiHook.inc +++ b/plugins/admin/fai/class_faiHook.inc @@ -82,6 +82,8 @@ class faiHook extends plugin } } $this->ui = get_userinfo(); + + @log::log("view","fai/".get_class($this),$this->dn); } @@ -389,6 +391,8 @@ class faiHook extends plugin prepare_to_save_FAI_object($use_dn,array(),true); + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); + foreach($this->SubObjects as $name => $obj){ # $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); @@ -436,6 +440,12 @@ class faiHook extends plugin prepare_to_save_FAI_object($this->dn,$this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/hook with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + /* Do object tagging */ $this->handle_object_tagging(); diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index 71914a044..6934a0cc4 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -288,44 +288,48 @@ class faiManagement extends plugin ****************/ /* Deltetion was confirmed, so delete this entry - */ - if (isset($_POST['delete_terminal_confirm'])){ + */ + if (isset($_POST['delete_terminal_confirm'])){ - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ /* Find out more about the object type */ $ldap = $this->config->get_ldap_link(); $ldap->cat($this->dn, array('objectClass')); - $attrs = $ldap->fetch(); - $type = $this->get_type($attrs); + if($ldap->count()){ + $attrs = $ldap->fetch(); + $type = $this->get_type($attrs); - $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]); - if(preg_match("/d/",$acl)){ + $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]); + if(preg_match("/d/",$acl)){ - $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai"); - $this->dialog->set_acl_base($this->dn); - $this->dialog->by_object[$type[1]]->remove_from_parent (); - unset ($this->dialog); - gosa_log ("FAI class '".$this->dn."' has been tagged as removed"); - $this->dialog= NULL; - $to_del = clean_up_releases($this->dn); - save_release_changes_now(); + $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai"); + $this->dialog->set_acl_base($this->dn); + $this->dialog->by_object[$type[1]]->remove_from_parent (); + unset ($this->dialog); + gosa_log ("FAI class '".$this->dn."' has been tagged as removed"); + $this->dialog= NULL; + $to_del = clean_up_releases($this->dn); + save_release_changes_now(); - foreach($to_del as $dn){ - $ldap->rmdir_recursive($dn); - gosa_log(sprintf(_("Release cleanup : Removing object (tagged as remvoed) that is no longer in use '%s'."),$dn)); - } + foreach($to_del as $dn){ + $ldap->rmdir_recursive($dn); + gosa_log(sprintf(_("Release cleanup : Removing object (tagged as remvoed) that is no longer in use '%s'."),$dn)); + } - } else { + } else { - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this component!")); - gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ". - "deletion."); - } + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this component!")); + gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ". + "deletion."); + } + }else{ + print_red(sprintf(_("Object could not be deleted '%s', object does not exist."),$this->dn)); + } /* Remove lock file after successfull deletion */ del_lock ($this->dn); } diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index 9e45b692e..37b7f128a 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -37,7 +37,7 @@ class faiPackage extends plugin var $SubObjects = array(); // All leafobjects of this object var $FAIdebianRelease = ""; // The selected release - var $FAIdebianSection = ""; // selected section + var $FAIdebianSection = array(); // selected section var $FAIinstallMethod = "aptitude"; // hard coded var $mirror = ""; // selected mirror @@ -134,6 +134,7 @@ class faiPackage extends plugin $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; } } + @log::log("view","fai/".get_class($this),$this->dn); } if (isset($this->attrs['FAIdebianSection']['count'])){ @@ -338,6 +339,8 @@ class faiPackage extends plugin prepare_to_save_FAI_object($use_dn,array(),true); + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); + foreach($this->ConfiguredPackages as $pkgname => $attrs){ foreach($attrs as $name => $attr){ $pkgdn = "FAIvariable=".$name.",".$this->dn; @@ -417,7 +420,8 @@ class faiPackage extends plugin return($a_ret); } - function genPkgs(){ + function genPkgs() + { /* Generate a list off available packages for this mirror, section and release */ /* Only read this file if it wasn't read before */ @@ -473,6 +477,12 @@ class faiPackage extends plugin prepare_to_save_FAI_object($this->dn,$this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/package list with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } /* Do object tagging */ $this->handle_object_tagging(); diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc index 550e71999..cb8651c22 100644 --- a/plugins/admin/fai/class_faiPartitionTable.inc +++ b/plugins/admin/fai/class_faiPartitionTable.inc @@ -99,6 +99,8 @@ class faiPartitionTable extends plugin $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; } } + + @log::log("view","fai/".get_class($this),$this->dn); } ksort($this->disks); } @@ -342,7 +344,9 @@ class faiPartitionTable extends plugin } prepare_to_save_FAI_object($use_dn,array(),true); - + + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); + foreach($this->disks as $disk){ $disk_dn = "cn=".$disk['cn'].",".$this->dn; @@ -406,7 +410,13 @@ class faiPartitionTable extends plugin prepare_to_save_FAI_object($this->dn,$this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/partition table with dn '%s' failed."),$this->dn)); - + + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + /* Do object tagging */ $this->handle_object_tagging(); diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc index 568d120f2..52d87d9e4 100644 --- a/plugins/admin/fai/class_faiProfile.inc +++ b/plugins/admin/fai/class_faiProfile.inc @@ -100,6 +100,7 @@ class faiProfile extends plugin if($dn != "new"){ $this->dn =$dn; + @log::log("view","fai/".get_class($this),$this->dn); } $this->old_cn = $this->cn; } @@ -369,6 +370,7 @@ class faiProfile extends plugin $use_dn = $this->dn; } + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); prepare_to_save_FAI_object($use_dn,array(),true); $this->handle_post_events("remove"); } @@ -427,7 +429,13 @@ class faiProfile extends plugin $this->attrs['FAIclass']=trim($this->FAIclass); prepare_to_save_FAI_object($this->dn,$this->attrs); - + + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn)); /* Do object tagging */ diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc index c130a568d..edb3a03c8 100644 --- a/plugins/admin/fai/class_faiScript.inc +++ b/plugins/admin/fai/class_faiScript.inc @@ -84,6 +84,8 @@ class faiScript extends plugin $objects = $this->get_object_attributes($objects,$this->subAttributes); $this->SubObjects[$objects['cn']] = $objects; } + + @log::log("view","fai/".get_class($this),$this->dn); } $this->ui = get_userinfo(); } @@ -383,7 +385,9 @@ class faiScript extends plugin if($_SESSION['faifilter']['branch'] == "main"){ $use_dn = $this->dn; } - + + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); + prepare_to_save_FAI_object($use_dn,array(),true); foreach($this->SubObjects as $name => $obj){ @@ -433,6 +437,12 @@ class faiScript extends plugin prepare_to_save_FAI_object($this->dn,$this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Creating of FAI/script with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + /* Do object tagging */ $this->handle_object_tagging(); diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc index 83d556da9..8de436e3a 100644 --- a/plugins/admin/fai/class_faiTemplate.inc +++ b/plugins/admin/fai/class_faiTemplate.inc @@ -82,6 +82,8 @@ class faiTemplate extends plugin $objects = $this->get_object_attributes($objects,$this->subAttributes); $this->SubObjects[$objects['cn']] = $objects; } + + @log::log("view","fai/".get_class($this),$this->dn); } $this->ui = get_userinfo(); } @@ -371,6 +373,7 @@ class faiTemplate extends plugin } prepare_to_save_FAI_object($use_dn,array(),true); + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); foreach($this->SubObjects as $name => $obj){ # $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); @@ -414,6 +417,12 @@ class faiTemplate extends plugin prepare_to_save_FAI_object($this->dn,$this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/template with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + /* Do object tagging */ $this->handle_object_tagging(); diff --git a/plugins/admin/fai/class_faiVariable.inc b/plugins/admin/fai/class_faiVariable.inc index 60baec911..18d4c0368 100644 --- a/plugins/admin/fai/class_faiVariable.inc +++ b/plugins/admin/fai/class_faiVariable.inc @@ -85,6 +85,8 @@ class faiVariable extends plugin $this->SubObjects[$object['cn'][0]]['status'] = "edited"; $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; } + + @log::log("view","fai/".get_class($this),$this->dn); } $this->ui = get_userinfo(); } @@ -280,8 +282,9 @@ class faiVariable extends plugin if($_SESSION['faifilter']['branch'] == "main"){ $use_dn = $this->dn; } - + prepare_to_save_FAI_object($use_dn,array(),true); + @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes); foreach($this->SubObjects as $name => $obj){ $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); @@ -328,6 +331,12 @@ class faiVariable extends plugin $ldap = $this->config->get_ldap_link(); prepare_to_save_FAI_object($this->dn,$this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + @log::log("create","fai/".get_class($this),$this->dn,$this->attributes); + } /* Do object tagging */ $this->handle_object_tagging();