added error message for invalid lamdaemon admin users

This commit is contained in:
Roland Gruber 2006-09-14 20:08:29 +00:00
parent 46a7a5202a
commit 88471e845a
1 changed files with 10 additions and 3 deletions

View File

@ -112,10 +112,17 @@ function lamdaemonSSH($commands) {
$credentials = $_SESSION['ldap']->decrypt_login(); $credentials = $_SESSION['ldap']->decrypt_login();
$handle = ssh2_connect($_SESSION['config']->scriptServer); $handle = ssh2_connect($_SESSION['config']->scriptServer);
if ($handle) { if ($handle) {
$sr = ldap_read($_SESSION['ldap']->server(), $credentials[0], "objectClass=posixAccount", array('uid')); $sr = @ldap_read($_SESSION['ldap']->server(), $credentials[0], "objectClass=posixAccount", array('uid'));
$entry = ldap_get_entries($_SESSION['ldap']->server(), $sr); if (!$sr) {
$return = array("ERROR," . _("Your LAM admin user must be a valid Unix account to work with lamdaemon!") . ",");
return $return;
}
$entry = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
$userName = $entry[0]['uid'][0]; $userName = $entry[0]['uid'][0];
if (!$userName) return array(); if (!$userName) {
$return = array("ERROR," . _("Your LAM admin user must be a valid Unix account to work with lamdaemon!") . ",");
return $return;
}
if (@ssh2_auth_password($handle, $userName, $credentials[1])) { if (@ssh2_auth_password($handle, $userName, $credentials[1])) {
$shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->scriptPath); $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->scriptPath);
fwrite($shell, $commands); fwrite($shell, $commands);