SSH2 Keys bei Webspace Master #869

This commit is contained in:
Ulrich Block 2016-06-01 20:55:57 +02:00
parent 6348dd86e3
commit 406c8951a5
3 changed files with 28 additions and 17 deletions

View File

@ -361,7 +361,12 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$vhostObject = new HttpdManagement($webMasterID, $resellerLockupID);
if ($vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) {
if ($vhostObject == false) {
$template_file = 'Unknown Error';
} else if (!$vhostObject->ssh2Connect() or !$vhostObject->sftpConnect()) {
$template_file = $gsprache->error_connect;
} else {
if ($ui->st('action', 'post') == 'ad') {
@ -446,7 +451,11 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$vhostObject = new HttpdManagement($webMasterID, $resellerLockupID);
if ($vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) {
if ($vhostObject == false) {
$template_file = 'Unknown Error';
} else if (!$vhostObject->ssh2Connect() or !$vhostObject->sftpConnect()) {
$template_file = $gsprache->error_connect;
} else {
$vhostObject->vhostDelete($id);
$vhostObject->restartHttpdServer();
}
@ -497,7 +506,11 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$vhostObject = new HttpdManagement($webMasterID, $resellerLockupID);
if ($vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) {
if ($vhostObject == false) {
$template_file = 'Unknown Error';
} else if (!$vhostObject->ssh2Connect() or !$vhostObject->sftpConnect()) {
$template_file = $gsprache->error_connect;
} else {
$vhostObject->vhostReinstall($id);
$vhostObject->restartHttpdServer();
@ -506,7 +519,6 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$loguseraction = '%ri% %webvhost% ' . $dns;
$insertlog->execute();
} else {
$template_file = $spracheResponse->error_table;
}

View File

@ -108,15 +108,13 @@ class HttpdManagement {
$this->ssh2Pass = new phpseclib\Crypt\RSA();
if ($row['publickey'] == 'B') {
$this->ssh2Pass->setPassword($row['pass']);
$this->ssh2Pass->setPassword($row['decryptedpass']);
}
$this->ssh2Pass->loadKey(file_get_contents($privateKey));
} else {
$this->ssh2Pass = $row['decryptedpass'];
}
$this->dataPrepared = true;
@ -280,7 +278,7 @@ class HttpdManagement {
}
}
public function changePassword ($vhostID, $newPassword = false) {
public function changePassword($vhostID, $newPassword = false) {
if ($this->getVhostData($vhostID) != false) {
if ($this->ssh2Object != false) {
@ -297,7 +295,7 @@ class HttpdManagement {
}
}
public function sftpConnect () {
public function sftpConnect() {
if ($this->dataPrepared == false) {
return false;
@ -313,7 +311,7 @@ class HttpdManagement {
}
public function ssh2Connect () {
public function ssh2Connect() {
if ($this->dataPrepared == false) {
return false;
@ -329,7 +327,7 @@ class HttpdManagement {
}
public function setInactive ($vhostID) {
public function setInactive($vhostID) {
$this->changePassword($vhostID, passwordgenerate(10));
$this->removeVhost($vhostID, false);
@ -338,7 +336,7 @@ class HttpdManagement {
}
public function vhostMod ($vhostID) {
public function vhostMod($vhostID) {
$this->addVhost($vhostID, false);
$this->changePassword ($vhostID);

View File

@ -318,17 +318,18 @@ if (isset($webMasterID) and $ui->st('d', 'get') == 'pw' and $ui->id('id', 10, 'g
$vhostObject = new HttpdManagement($webMasterID, $reseller_id);
if ($vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) {
if ($vhostObject == false) {
$template_file = 'Unknown Error';
} else if (!$vhostObject->ssh2Connect() or !$vhostObject->sftpConnect()) {
$template_file = $gsprache->error_connect;
} else {
$vhostObject->vhostReinstall($id);
$vhostObject->restartHttpdServer();
$template_file = $spracheResponse->table_del;
$template_file = $gsprache->reinstall;
$loguseraction = '%ri% %webvhost% ' . $dns;
$insertlog->execute();
} else {
$template_file = $spracheResponse->error_table;
}
// Request did not add up. Display 404 error.