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( $this->addElement(
'textarea', 'textarea',
'identity_key', 'private_key',
array( array(
'required' => true, 'required' => true,
'label' => $this->translate('Private Key'), 'label' => $this->translate('Private Key'),
@ -78,7 +78,7 @@ class SshResourceForm extends Form
$resourceName = $formData['name']; $resourceName = $formData['name'];
$this->addElement( $this->addElement(
'note', 'note',
'identity_key_note', 'private_key_note',
array( array(
'escape' => false, 'escape' => false,
'label' => $this->translate('Private Key'), 'label' => $this->translate('Private Key'),
@ -106,7 +106,7 @@ class SshResourceForm extends Form
*/ */
public static function beforeRemove(ConfigObject $config) public static function beforeRemove(ConfigObject $config)
{ {
$file = $config->identity_key; $file = $config->private_key;
if (file_exists($file)) { if (file_exists($file)) {
unlink($file); unlink($file);
@ -138,9 +138,9 @@ class SshResourceForm extends Form
return false; 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; return true;
} }

View File

@ -46,11 +46,11 @@ class RemoteCommandFile implements CommandTransportInterface
protected $user; 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 * @var string
*/ */
protected $identityKey; protected $privateKey;
/** /**
* Path to the Icinga command file on the remote host * 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 * @return $this
*/ */
public function setIdentityKey($identityKey) public function setPrivateKey($privateKey)
{ {
$this->identityKey = (string) $identityKey; $this->privateKey = (string) $privateKey;
return $this; return $this;
} }
/** /**
* Get the path to the identity path * Get the path to the private key
* *
* @return string * @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") t("Can't send external Icinga Command. Remote user is missing")
); );
} }
if (! isset($config->identity_key)) { if (! isset($config->private_key)) {
throw new ConfigurationError( 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->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)) { if (isset($this->user)) {
$ssh .= sprintf(' -l %s', escapeshellarg($this->user)); $ssh .= sprintf(' -l %s', escapeshellarg($this->user));
} }
if (isset($this->identityKey)) { if (isset($this->privateKey)) {
$ssh .= sprintf(' -o StrictHostKeyChecking=no -i %s', escapeshellarg($this->identityKey)); $ssh .= sprintf(' -o StrictHostKeyChecking=no -i %s', escapeshellarg($this->privateKey));
} }
$ssh .= sprintf( $ssh .= sprintf(
' %s "echo %s > %s" 2>&1', // Redirect stderr to stdout ' %s "echo %s > %s" 2>&1', // Redirect stderr to stdout