Skip to content

Commit

Permalink
Rename identity_key with private_key in ssh resource
Browse files Browse the repository at this point in the history
refs #7595
  • Loading branch information
Alexander Fuhr committed May 28, 2015
1 parent a47d05a commit 4958912
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions application/forms/Config/Resource/SshResourceForm.php
Expand Up @@ -65,7 +65,7 @@ public function createElements(array $formData)

$this->addElement(
'textarea',
'identity_key',
'private_key',
array(
'required' => true,
'label' => $this->translate('Private Key'),
Expand All @@ -78,7 +78,7 @@ public function createElements(array $formData)
$resourceName = $formData['name'];
$this->addElement(
'note',
'identity_key_note',
'private_key_note',
array(
'escape' => false,
'label' => $this->translate('Private Key'),
Expand Down Expand Up @@ -106,7 +106,7 @@ public function createElements(array $formData)
*/
public static function beforeRemove(ConfigObject $config)
{
$file = $config->identity_key;
$file = $config->private_key;

if (file_exists($file)) {
unlink($file);
Expand Down Expand Up @@ -138,9 +138,9 @@ public static function beforeAdd(ResourceConfigForm $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;
}
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -146,26 +146,26 @@ public function getUser()
}

/**
* 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;
}

/**
Expand All @@ -184,14 +184,14 @@ public function setResource($resource = null)
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);
}

/**
Expand Down Expand Up @@ -249,8 +249,8 @@ public function send(IcingaCommand $command, $now = null)
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
Expand Down

0 comments on commit 4958912

Please sign in to comment.