From 2f0ceefb352b214e1015600c314e350f427c1305 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 1 Sep 2011 06:58:28 +0000 Subject: [PATCH] Fixed samba hash generation - error handling. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20975 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/functions.inc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 57f61321e..3c1ac16f2 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -2907,9 +2907,14 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password $attrs= array(); if (!$mode && !empty($tmp)){ $attrs= generate_smb_nt_hash($password); - $shadow = (isset($attrs["shadowLastChange"][0]))?(int)(date("U") / 86400):0; - if ($shadow != 0){ - $attrs['shadowLastChange']= $shadow; + if(!count($attrs) || !is_array($attrs)){ + msg_dialog::display(tr("Error"),tr("Cannot generate SAMBA hash!"),ERROR_DIALOG); + return(FALSE); + }else{ + $shadow = (isset($attrs["shadowLastChange"][0]))?(int)(date("U") / 86400):0; + if ($shadow != 0){ + $attrs['shadowLastChange']= $shadow; + } } } @@ -3063,7 +3068,7 @@ function generate_smb_nt_hash($password) $hash = $rpc->mksmbhash($password); if(!$rpc->success()){ msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG); - return(""); + return(array()); } }elseif ($config->get_cfg_value("core","gosaSupportURI") != ""){ @@ -3093,7 +3098,7 @@ function generate_smb_nt_hash($password) if ($hash == "") { msg_dialog::display(_("Configuration error"), sprintf(_("Generating SAMBA hash by running %s failed: check %s!"), bold($config->get_cfg_value("core",'sambaHashHook'), bold("sambaHashHook"))), ERROR_DIALOG); - return (""); + return(array()); } } -- 2.30.2