You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/05/13 10:52:47 UTC

[2/2] git commit: updated refs/heads/4.4 to 820f872

CLOUDSTACK-6622: After a volume was live migrated, the destination smb storage path was added to
the folder column. For an smb share the smb credentials are in the query string of the path.
Before adding the path, smb shares query string should be cleaned up.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/820f8724
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/820f8724
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/820f8724

Branch: refs/heads/4.4
Commit: 820f8724fa7d701fd1cc5169315cf8e7d17c07d2
Parents: f0dcf47
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri May 9 15:54:56 2014 +0530
Committer: Daan Hoogland <da...@onecht.net>
Committed: Tue May 13 10:52:35 2014 +0200

----------------------------------------------------------------------
 .../storage/motion/AncientDataMotionStrategy.java         |  9 ++++++++-
 .../storage/motion/HypervStorageMotionStrategy.java       | 10 +++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/820f8724/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index fbdacfa..415a077 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -63,6 +63,7 @@ import com.cloud.host.Host;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.VolumeVO;
+import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.db.DB;
@@ -389,10 +390,16 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
             VolumeVO volumeVo = volDao.findById(volume.getId());
             Long oldPoolId = volume.getPoolId();
             volumeVo.setPath(((MigrateVolumeAnswer)answer).getVolumePath());
-            volumeVo.setFolder(destPool.getPath());
             volumeVo.setPodId(destPool.getPodId());
             volumeVo.setPoolId(destPool.getId());
             volumeVo.setLastPoolId(oldPoolId);
+            // For SMB, pool credentials are also stored in the uri query string.  We trim the query string
+            // part  here to make sure the credentials do not get stored in the db unencrypted.
+            String folder = destPool.getPath();
+            if (destPool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
+                folder = folder.substring(0, folder.indexOf("?"));
+            }
+            volumeVo.setFolder(folder);
             volDao.update(volume.getId(), volumeVo);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/820f8724/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java b/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java
index 011bd12..8a1c414 100644
--- a/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java
+++ b/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java
@@ -50,6 +50,7 @@ import com.cloud.host.Host;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.VolumeVO;
+import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.Pair;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -161,10 +162,17 @@ public class HypervStorageMotionStrategy implements DataMotionStrategy {
                     VolumeVO volumeVO = volDao.findById(volume.getId());
                     Long oldPoolId = volumeVO.getPoolId();
                     volumeVO.setPath(volumeTo.getPath());
-                    volumeVO.setFolder(pool.getPath());
                     volumeVO.setPodId(pool.getPodId());
                     volumeVO.setPoolId(pool.getId());
                     volumeVO.setLastPoolId(oldPoolId);
+                    // For SMB, pool credentials are also stored in the uri query string.  We trim the query string
+                    // part  here to make sure the credentials do not get stored in the db unencrypted.
+                    String folder = pool.getPath();
+                    if (pool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
+                        folder = folder.substring(0, folder.indexOf("?"));
+                    }
+                    volumeVO.setFolder(folder);
+
                     volDao.update(volume.getId(), volumeVO);
                     updated = true;
                     break;