You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2020/04/14 14:19:37 UTC
[cloudstack] branch master updated: FIX: prevent empty sshkey name.
(#4023)
This is an automated email from the ASF dual-hosted git repository.
andrijapanic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 208e185 FIX: prevent empty sshkey name. (#4023)
208e185 is described below
commit 208e1857148929a9d0602307a210ab1715706dee
Author: Sina Kashipazha <so...@users.noreply.github.com>
AuthorDate: Tue Apr 14 16:19:24 2020 +0200
FIX: prevent empty sshkey name. (#4023)
* FIX: prevent empty sshkey name.
* Move sshKeyName check before database access.
Co-authored-by: Sina Kashipazha <s....@global.leaseweb.com>
---
server/src/main/java/com/cloud/server/ManagementServerImpl.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index a3e9bb6..1ef96f2 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -3701,6 +3701,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
final Long domainId = cmd.getDomainId();
final Long projectId = cmd.getProjectId();
+ final String name = cmd.getName();
+
+ if (StringUtils.isBlank(name)) {
+ throw new InvalidParameterValueException("Please specify a valid name for the key pair. The key name can't be empty");
+ }
+
final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, projectId);
final SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), cmd.getName());
@@ -3709,8 +3715,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
final SSHKeysHelper keys = new SSHKeysHelper(sshKeyLength.value());
-
- final String name = cmd.getName();
final String publicKey = keys.getPublicKey();
final String fingerprint = keys.getPublicKeyFingerPrint();
final String privateKey = keys.getPrivateKey();