Rename identity_key with private_key in ssh resource

refs #7595
This commit is contained in:
Alexander Fuhr 2015-05-28 14:09:13 +02:00
parent a47d05a038
commit 49589128ef
2 changed files with 19 additions and 19 deletions

View File

@ -65,7 +65,7 @@ class SshResourceForm extends Form
$this->addElement(
'textarea',
'identity_key',
'private_key',
array(
'required' => true,
'label' => $this->translate('Private Key'),
@ -78,7 +78,7 @@ class SshResourceForm extends Form
$resourceName = $formData['name'];
$this->addElement(
'note',
'identity_key_note',
'private_key_note',
array(
'escape' => false,
'label' => $this->translate('Private Key'),
@ -106,7 +106,7 @@ class SshResourceForm extends Form
*/
public static function beforeRemove(ConfigObject $config)
{
$file = $config->identity_key;
$file = $config->private_key;
if (file_exists($file)) {
unlink($file);
@ -138,9 +138,9 @@ class SshResourceForm extends Form
return false;
}
$file->fwrite($form->getElement('identity_key')->getValue());
$file->fwrite($form->getElement('private_key')->getValue());
$form->getElement('identity_key')->setValue($configDir . '/ssh/' . $user);
$form->getElement('private_key')->setValue($configDir . '/ssh/' . $user);
return true;
}

View File

@ -46,11 +46,11 @@ class RemoteCommandFile implements CommandTransportInterface
protected $user;
/**
* Path to the identity (private key) file for the key-based authentication
* Path to the private key file for the key-based authentication
*
* @var string
*/
protected $identityKey;
protected $privateKey;
/**
* Path to the Icinga command file on the remote host
@ -146,26 +146,26 @@ class RemoteCommandFile implements CommandTransportInterface
}
/**
* Set the path to the identity file
* Set the path to the private key file
*
* @param string $identityKey
* @param string $privateKey
*
* @return $this
*/
public function setIdentityKey($identityKey)
public function setPrivateKey($privateKey)
{
$this->identityKey = (string) $identityKey;
$this->privateKey = (string) $privateKey;
return $this;
}
/**
* Get the path to the identity path
* Get the path to the private key
*
* @return string
*/
public function getIdentityKey()
public function getPrivateKey()
{
return $this->identityKey;
return $this->privateKey;
}
/**
@ -184,14 +184,14 @@ class RemoteCommandFile implements CommandTransportInterface
t("Can't send external Icinga Command. Remote user is missing")
);
}
if (! isset($config->identity_key)) {
if (! isset($config->private_key)) {
throw new ConfigurationError(
t("Can't send external Icinga Command. The identity key for the remote user is missing")
t("Can't send external Icinga Command. The private key for the remote user is missing")
);
}
$this->setUser($config->user);
$this->setIdentityKey($config->identity_key);
$this->setPrivateKey($config->private_key);
}
/**
@ -249,8 +249,8 @@ class RemoteCommandFile implements CommandTransportInterface
if (isset($this->user)) {
$ssh .= sprintf(' -l %s', escapeshellarg($this->user));
}
if (isset($this->identityKey)) {
$ssh .= sprintf(' -o StrictHostKeyChecking=no -i %s', escapeshellarg($this->identityKey));
if (isset($this->privateKey)) {
$ssh .= sprintf(' -o StrictHostKeyChecking=no -i %s', escapeshellarg($this->privateKey));
}
$ssh .= sprintf(
' %s "echo %s > %s" 2>&1', // Redirect stderr to stdout