Code

Fixed problem reported by 'mmerlone' closes #1122
[gosa.git] / gosa-core / plugins / admin / users / class_userManagement.inc
index c323b5af1a00259bacfa386cdfe4a85eadd7bee9..f15817603281d8ed9823003180d3b9f6383b5c57 100644 (file)
@@ -341,9 +341,20 @@ class userManagement extends management
                   $ldap->cd($this->config->current['BASE']);
                   $ldap->cat($this->dn,array('uid'));
                   $attrs = $ldap->fetch();
-                  exec($this->config->get_cfg_value("passwordHook")." ".$attrs['uid'][0]." ".$_POST['new_password'], $resarr);
+                  exec($this->config->get_cfg_value("passwordHook")." ".
+                          escapeshellarg($attrs['uid'][0])." ".escapeshellarg($new_password), $resarr);
+                  $check_hook_output = "";
+                  if(count($resarr) > 0) {
+                      $check_hook_output= join('\n', $resarr);
+                  }
+                  if(!empty($check_hook_output)){
+                      $message[] = sprintf(_("Check-hook reported a problem: %s. Password change canceled!"),$check_hook_output);
+                      msg_dialog::displayChecks($message);
+                      return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+                  }
               }
 
+
               // The user has to change his password on next login
               // - We are going to update samba and posix attributes here, to enforce
               //   such a password change.
@@ -377,10 +388,8 @@ class userManagement extends management
                   if($samba){
                       $sambaAccount = new sambaAccount($this->config, $this->dn);
                       $sambaAccount->is_modified=TRUE;
-                      $sambaAccount->enforcePasswordChange=TRUE;
-                      $sambaAccount->cannotChangePassword=FALSE;
-                      $sambaAccount->sambaPwdCanChange=0;
-                      $sambaAccount->sambaAcctFlags = preg_replace("/X/i","",$sambaAccount->sambaAcctFlags);
+                      $sambaAccount->flag_enforcePasswordChange = TRUE;
+                      $sambaAccount->flag_cannotChangePassword = FALSE;
                       $sambaAccount->save();
                   }
               }