From 91002093104478981171b9a58ded2248bd296b08 Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 16 Jun 2005 11:49:57 +0000 Subject: [PATCH] Updated functionality for postmodify and passwords git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@734 594d385d-05f5-0310-b6e9-bd551577e9d8 --- Changelog | 1 + include/class_password-methods.inc | 26 +++++++-- include/class_plugin.inc | 35 ++--------- include/functions.inc | 58 +++++++++++++------ plugins/admin/ogroups/class_termgroup.inc | 6 +- plugins/admin/systems/class_servGeneric.inc | 6 +- .../admin/systems/class_terminalGeneric.inc | 6 +- .../systems/class_workstationGeneric.inc | 6 +- 8 files changed, 80 insertions(+), 64 deletions(-) diff --git a/Changelog b/Changelog index 659be4f5d..579171152 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,7 @@ GOsa2 changelog automatically if the revision changes - Improved W3C compatibility - Added checks that remove the contents of /var/spool/gosa/* + - Added postmodify for password change operations * gosa 2.4beta1 - Override automatically detected user bases if they don't exist diff --git a/include/class_password-methods.inc b/include/class_password-methods.inc index 52b862873..cfa7b8aed 100644 --- a/include/class_password-methods.inc +++ b/include/class_password-methods.inc @@ -91,7 +91,6 @@ class passwordMethod // change_password, changes the Password, of the given dn function change_password ($dn, $password, $mode=0, $hash= "") { - global $config; $newpass= ""; @@ -130,8 +129,6 @@ function change_password ($dn, $password, $mode=0, $hash= "") $newpass = $test->generate_hash($password); } - - // Update shadow timestamp? if (isset($attrs["shadowLastChange"][0])){ $shadow= (int)(date("U") / 86400); @@ -151,7 +148,7 @@ function change_password ($dn, $password, $mode=0, $hash= "") } // Create SMB Password - $attrs = generate_smb_nt_hash($password); + $attrs= generate_smb_nt_hash($password); } $attrs['userPassword']= array(); @@ -161,10 +158,27 @@ function change_password ($dn, $password, $mode=0, $hash= "") $ldap->modify($attrs); - if ($ldap->error != 'Success') - { + if ($ldap->error != 'Success') { print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."), $ldap->get_error())); + } else { + + /* Find postmodify entries for this class */ + $command= search_config($config->data['MENU'], "password", "POSTMODIFY"); + + if ($command != ""){ + /* Walk through attribute list */ + $command= preg_replace("/%userPassword/", $password, $command); + $command= preg_replace("/%dn/", $dn, $command); + + if (check_command($command)){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute"); + exec($command); + } else { + $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password"); + print_red ($message); + } + } } } diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 2a50b4737..e7c01c3aa 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -366,9 +366,9 @@ class plugin function postcreate() { /* Find postcreate entries for this class */ - $command= $this->search($this->config->data['MENU'], get_class($this), "POSTCREATE"); + $command= search_config($this->config->data['MENU'], get_class($this), "POSTCREATE"); if ($command == ""){ - $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTCREATE"); + $command= search_config($this->config->data['SERVICE'], get_class($this), "POSTCREATE"); } if ($command != ""){ @@ -392,9 +392,9 @@ class plugin function postmodify() { /* Find postcreate entries for this class */ - $command= $this->search($this->config->data['MENU'], get_class($this), "POSTMODIFY"); + $command= search_config($this->config->data['MENU'], get_class($this), "POSTMODIFY"); if ($command == ""){ - $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTMODIFY"); + $command= search_config($this->config->data['SERVICE'], get_class($this), "POSTMODIFY"); } if ($command != ""){ @@ -418,9 +418,9 @@ class plugin function postremove() { /* Find postremove entries for this class */ - $command= $this->search($this->config->data['MENU'], get_class($this), "POSTREMOVE"); + $command= search_config($this->config->data['MENU'], get_class($this), "POSTREMOVE"); if ($command == ""){ - $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTREMOVE"); + $command= search_config($this->config->data['SERVICE'], get_class($this), "POSTREMOVE"); } if ($command != ""){ @@ -441,29 +441,6 @@ class plugin } } - function search($arr, $name, $return) - { - if (is_array($arr)){ - foreach ($arr as $a){ - if (isset($a['CLASS']) && - strtolower($a['CLASS']) == strtolower($name)){ - - if (isset($a[$return])){ - return ($a[$return]); - } else { - return (""); - } - } else { - $res= $this->search ($a, $name, $return); - if ($res != ""){ - return $res; - } - } - } - } - return (""); - } - /* Create unique DN */ function create_unique_dn($attribute, $base) { diff --git a/include/functions.inc b/include/functions.inc index 54ecb36a4..30c6d0529 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1752,7 +1752,7 @@ function compare_revision($revision_file, $revision) } function progressbar($percentage,$width=100,$height=15,$showvalue=false) - { +{ $str = ""; // Our return value will be saved in this var $color = dechex($percentage+150); @@ -1766,30 +1766,54 @@ function progressbar($percentage,$width=100,$height=15,$showvalue=false) /* If theres a better solution for this, use it... */ $str = " -
+
+ background-color:#$bgcolor; +height:".($height)."px;\"> + +
"; -
"; + if(($height >10)&&($showvalue)){ + $str.= " + ".$percentage."% + "; + } - if(($height >10)&&($showvalue)){ - $str.= " - ".$percentage."% - "; - } + $str.= "
"; + + return($str); +} - $str.= "
"; - return($str); +function search_config($arr, $name, $return) +{ + if (is_array($arr)){ + foreach ($arr as $a){ + if (isset($a['CLASS']) && + strtolower($a['CLASS']) == strtolower($name)){ + + if (isset($a[$return])){ + return ($a[$return]); + } else { + return (""); + } + } else { + $res= search_config ($a, $name, $return); + if ($res != ""){ + return $res; + } + } + } } + return (""); +} // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/ogroups/class_termgroup.inc b/plugins/admin/ogroups/class_termgroup.inc index 01d0e0d97..76b54705a 100644 --- a/plugins/admin/ogroups/class_termgroup.inc +++ b/plugins/admin/ogroups/class_termgroup.inc @@ -50,7 +50,7 @@ class termgroup extends plugin switch($_POST['saction']){ case 'wake': - $cmd= $this->search($this->config->data['TABS'], "terminfo", "WAKECMD"); + $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD"); if ($cmd == ""){ print_red(_("No WAKECMD definition found in your gosa.conf")); } else { @@ -62,7 +62,7 @@ class termgroup extends plugin break; case 'reboot': - $cmd= $this->search($this->config->data['TABS'], "terminfo", "REBOOTCMD"); + $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD"); if ($cmd == ""){ print_red(_("No REBOOTCMD definition found in your gosa.conf")); } else { @@ -74,7 +74,7 @@ class termgroup extends plugin break; case 'halt': - $cmd= $this->search($this->config->data['TABS'], "terminfo", "HALTCMD"); + $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD"); if ($cmd == ""){ print_red(_("No HALTCMD definition found in your gosa.conf")); } else { diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index 12c1c309d..ee9c214a0 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -54,7 +54,7 @@ class servgeneric extends plugin if (isset($_POST['action'])){ switch($_POST['action']){ case 'wake': - $cmd= $this->search($this->config->data['TABS'], "servgeneric", "WAKECMD"); + $cmd= search_config($this->config->data['TABS'], "servgeneric", "WAKECMD"); if ($cmd == ""){ print_red(_("No WAKECMD definition found in your gosa.conf")); } else { @@ -66,7 +66,7 @@ class servgeneric extends plugin break; case 'reboot': - $cmd= $this->search($this->config->data['TABS'], "servgeneric", "REBOOTCMD"); + $cmd= search_config($this->config->data['TABS'], "servgeneric", "REBOOTCMD"); if ($cmd == ""){ print_red(_("No REBOOTCMD definition found in your gosa.conf")); } else { @@ -78,7 +78,7 @@ class servgeneric extends plugin break; case 'halt': - $cmd= $this->search($this->config->data['TABS'], "servgeneric", "HALTCMD"); + $cmd= search_config($this->config->data['TABS'], "servgeneric", "HALTCMD"); if ($cmd == ""){ print_red(_("No HALTCMD definition found in your gosa.conf")); } else { diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index e639e1636..f95685e7e 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -84,7 +84,7 @@ class termgeneric extends plugin if (isset($_POST['action'])){ switch($_POST['saction']){ case 'wake': - $cmd= $this->search($this->config->data['TABS'], "termgeneric", "WAKECMD"); + $cmd= search_config($this->config->data['TABS'], "termgeneric", "WAKECMD"); if ($cmd == ""){ print_red(_("No WAKECMD definition found in your gosa.conf")); } else { @@ -96,7 +96,7 @@ class termgeneric extends plugin break; case 'reboot': - $cmd= $this->search($this->config->data['TABS'], "termgeneric", "REBOOTCMD"); + $cmd= search_config($this->config->data['TABS'], "termgeneric", "REBOOTCMD"); if ($cmd == ""){ print_red(_("No REBOOTCMD definition found in your gosa.conf")); } else { @@ -108,7 +108,7 @@ class termgeneric extends plugin break; case 'halt': - $cmd= $this->search($this->config->data['TABS'], "termgeneric", "HALTCMD"); + $cmd= search_config($this->config->data['TABS'], "termgeneric", "HALTCMD"); if ($cmd == ""){ print_red(_("No HALTCMD definition found in your gosa.conf")); } else { diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 1a82a1ae0..1b8775ece 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -93,7 +93,7 @@ class workgeneric extends plugin if (isset($_POST['action'])){ switch($_POST['saction']){ case 'wake': - $cmd= $this->search($this->config->data['TABS'], "terminfo", "WAKECMD"); + $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD"); if ($cmd == ""){ print_red(_("No WAKECMD definition found in your gosa.conf")); } else { @@ -105,7 +105,7 @@ class workgeneric extends plugin break; case 'reboot': - $cmd= $this->search($this->config->data['TABS'], "terminfo", "REBOOTCMD"); + $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD"); if ($cmd == ""){ print_red(_("No REBOOTCMD definition found in your gosa.conf")); } else { @@ -117,7 +117,7 @@ class workgeneric extends plugin break; case 'halt': - $cmd= $this->search($this->config->data['TABS'], "terminfo", "HALTCMD"); + $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD"); if ($cmd == ""){ print_red(_("No HALTCMD definition found in your gosa.conf")); } else { -- 2.30.2