summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28fdac3)
raw | patch | inline | side by side (parent: 28fdac3)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 27 Aug 2010 12:22:21 +0000 (12:22 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 27 Aug 2010 12:22:21 +0000 (12:22 +0000) |
-Fixed execution method to hide the password from the process list
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19468 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19468 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-core/include/class_SnapshotHandler.inc b/gosa-core/include/class_SnapshotHandler.inc
index bc912bdbadbaab693e25699bb899c6f9eee834fa..cc3ec2477bff976ed8b4cb92ea0e784cfd3038d5 100644 (file)
/* Create object */
$data = $ldap->generateLdif(LDAP::fix($dn),
- "(&(!(objectClass=gosaDepartment))(!(objectClass=FAIclass)))",array(),'base');
+ "(&(!(objectClass=gosaDepartment))(!(objectClass=FAIclass)))",'base');
$newName = str_replace(".", "", $sec."-".$usec);
$target= array();
index bac40e5e07fd0a947cc96ca68801d06d1f1feb2b..6f88efbcf6826c7e1064811a64918544be06d5f9 100644 (file)
* @param $scope 'base', 'sub' .. see manpage for 'ldapmodify' for details.
* @param $limit Limits the result.
*/
- function generateLdif ($dn, $filter= "(objectClass=*)", $attributes= array(), $scope = 'sub', $limit=0)
+ function generateLdif ($dn, $filter= "(objectClass=*)", $scope = 'sub', $limit=0)
{
$attrs = (count($attributes))?implode($attributes,' '):'';
- $scope = (!empty($scope))?' -s '.$scope: '';
+
+ // Ensure that limit is numeric if not skip here.
+ if(!empty($limit) && !is_numeric($limit)){
+ trigger_error(sprintf("Invalid parameter for limit '%s', a numeric value is required."), $limit);
+ return(NULL);
+ }
$limit = (!$limit)?'':' -z '.$limit;
+
+ // Check scope values
+ $scope = trim($scope);
+ if(!empty($scope) && !in_array($scope, array('base', 'one', 'sub', 'children'))){
+ trigger_error(sprintf("Invalid parameter for scope '%s', please use 'base', 'one', 'sub' or 'children'."), $scope);
+ return(NULL);
+ }
+ $scope = (!empty($scope))?' -s '.$scope: '';
+
+ // Prepare paramters
$dn = escapeshellarg($dn);
+ $pwd = $this->bindpw;
+ $host = escapeshellarg($this->hostname);
$admin = escapeshellarg($this->binddn);
- $pwd = escapeshellarg($this->bindpw);
$filter = escapeshellarg($filter);
- $host = escapeshellarg($this->hostname);
- $cmd = "ldapsearch -x -LLLL -D {$admin} -w {$pwd} {$filter} {$limit} {$scope} -H {$host} -b {$dn} $attrs ";
- ob_start();
- passthru($cmd);
- $res=ob_get_contents();
- ob_end_clean();
+ $cmd = "ldapsearch -x -LLLL -D {$admin} {$filter} {$limit} {$scope} -H {$host} -b {$dn} -W ";
+
+ // Create list of process pipes
+ $descriptorspec = array(
+ 0 => array("pipe", "r"), // stdin
+ 1 => array("pipe", "w"), // stdout
+ 2 => array("pipe", "w")); // stderr
+
+ // Try to open the process
+ $process = proc_open($cmd, $descriptorspec, $pipes);
+ if (is_resource($process)) {
+
+ // Write the password to stdin
+ fwrite($pipes[0], $pwd);
+ fclose($pipes[0]);
+
+ // Get results from stdout and stderr
+ $res = stream_get_contents($pipes[1]);
+ $err = stream_get_contents($pipes[2]);
+ fclose($pipes[1]);
+
+ // Close the process and check its return value
+ if(proc_close($process) != 0){
+ trigger_error($err);
+ }
+ }
return($res);
}
diff --git a/gosa-core/plugins/generic/references/class_ldifViewer.inc b/gosa-core/plugins/generic/references/class_ldifViewer.inc
index 24d6d6911918a0671410399b20bad55465e329d7..cbe34f9cd02732859405e2b8c9def6b4d487af21 100644 (file)
$this->config = &$config;
$this->dn = $dn;
$ldap = $this->config->get_ldap_link();
- $this->ldif=$ldap->generateLdif(LDAP::fix($this->dn),'(objectClass=*)',array(),'base');
+ $this->ldif=$ldap->generateLdif(LDAP::fix($this->dn),'(objectClass=*)','base');
}
function execute()