check uploaded keys (RFE 124)
This commit is contained in:
parent
4e3041eee1
commit
75e7924770
|
@ -107,6 +107,7 @@ class ldapPublicKey extends baseModule {
|
||||||
**/
|
**/
|
||||||
function load_Messages() {
|
function load_Messages() {
|
||||||
$this->messages['file'][0] = array('ERROR', _('No file selected.'));
|
$this->messages['file'][0] = array('ERROR', _('No file selected.'));
|
||||||
|
$this->messages['file'][1] = array('ERROR', _('The uploaded file seems to be no valid public key.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,6 +146,17 @@ class ldapPublicKey extends baseModule {
|
||||||
$handle = fopen($_FILES['sshPublicKeyFile']['tmp_name'], "r");
|
$handle = fopen($_FILES['sshPublicKeyFile']['tmp_name'], "r");
|
||||||
$data = fread($handle, 10000000);
|
$data = fread($handle, 10000000);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
$isOk = true;
|
||||||
|
if (is_executable('/usr/bin/ssh-keygen')) {
|
||||||
|
$out = array();
|
||||||
|
$retVal = 0;
|
||||||
|
exec('/usr/bin/ssh-keygen -l -f ' . escapeshellarg($_FILES['sshPublicKeyFile']['tmp_name']), $out, $retVal);
|
||||||
|
if ($retVal !== 0) {
|
||||||
|
$messages[] = $this->messages['file'][1];
|
||||||
|
$isOk = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($isOk) {
|
||||||
$data = str_replace("\r\n", "\n", $data);
|
$data = str_replace("\r\n", "\n", $data);
|
||||||
$data = str_replace("\r", "\n", $data);
|
$data = str_replace("\r", "\n", $data);
|
||||||
$lines = explode("\n", $data);
|
$lines = explode("\n", $data);
|
||||||
|
@ -154,6 +166,7 @@ class ldapPublicKey extends baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$messages[] = $this->messages['file'][0];
|
$messages[] = $this->messages['file'][0];
|
||||||
}
|
}
|
||||||
|
@ -497,6 +510,16 @@ class ldapPublicKey extends baseModule {
|
||||||
$handle = fopen($_FILES['qqfile']['tmp_name'], "r");
|
$handle = fopen($_FILES['qqfile']['tmp_name'], "r");
|
||||||
$data = fread($handle, 100000000);
|
$data = fread($handle, 100000000);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
if (is_executable('/usr/bin/ssh-keygen')) {
|
||||||
|
$out = array();
|
||||||
|
$retVal = 0;
|
||||||
|
exec('/usr/bin/ssh-keygen -l -f ' . escapeshellarg($_FILES['qqfile']['tmp_name']), $out, $retVal);
|
||||||
|
if ($retVal !== 0) {
|
||||||
|
$result = array('error' => $this->messages['file'][1][1]);
|
||||||
|
echo json_encode($result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
$data = str_replace("\r\n", "\n", $data);
|
$data = str_replace("\r\n", "\n", $data);
|
||||||
$data = str_replace("\r", "\n", $data);
|
$data = str_replace("\r", "\n", $data);
|
||||||
$lines = explode("\n", $data);
|
$lines = explode("\n", $data);
|
||||||
|
|
Loading…
Reference in New Issue