Skip to content

Commit 820f872

Browse files
devdeepDaanHoogland
authored andcommitted
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.
1 parent f0dcf47 commit 820f872

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import com.cloud.storage.DataStoreRole;
6464
import com.cloud.storage.StoragePool;
6565
import com.cloud.storage.VolumeVO;
66+
import com.cloud.storage.Storage.StoragePoolType;
6667
import com.cloud.storage.dao.VolumeDao;
6768
import com.cloud.utils.NumbersUtil;
6869
import com.cloud.utils.db.DB;
@@ -389,10 +390,16 @@ protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) {
389390
VolumeVO volumeVo = volDao.findById(volume.getId());
390391
Long oldPoolId = volume.getPoolId();
391392
volumeVo.setPath(((MigrateVolumeAnswer)answer).getVolumePath());
392-
volumeVo.setFolder(destPool.getPath());
393393
volumeVo.setPodId(destPool.getPodId());
394394
volumeVo.setPoolId(destPool.getId());
395395
volumeVo.setLastPoolId(oldPoolId);
396+
// For SMB, pool credentials are also stored in the uri query string. We trim the query string
397+
// part here to make sure the credentials do not get stored in the db unencrypted.
398+
String folder = destPool.getPath();
399+
if (destPool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
400+
folder = folder.substring(0, folder.indexOf("?"));
401+
}
402+
volumeVo.setFolder(folder);
396403
volDao.update(volume.getId(), volumeVo);
397404
}
398405

‎plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.cloud.hypervisor.Hypervisor.HypervisorType;
5151
import com.cloud.storage.StoragePool;
5252
import com.cloud.storage.VolumeVO;
53+
import com.cloud.storage.Storage.StoragePoolType;
5354
import com.cloud.storage.dao.VolumeDao;
5455
import com.cloud.utils.Pair;
5556
import com.cloud.utils.exception.CloudRuntimeException;
@@ -161,10 +162,17 @@ private void updateVolumePathsAfterMigration(Map<VolumeInfo, DataStore> volumeTo
161162
VolumeVO volumeVO = volDao.findById(volume.getId());
162163
Long oldPoolId = volumeVO.getPoolId();
163164
volumeVO.setPath(volumeTo.getPath());
164-
volumeVO.setFolder(pool.getPath());
165165
volumeVO.setPodId(pool.getPodId());
166166
volumeVO.setPoolId(pool.getId());
167167
volumeVO.setLastPoolId(oldPoolId);
168+
// For SMB, pool credentials are also stored in the uri query string. We trim the query string
169+
// part here to make sure the credentials do not get stored in the db unencrypted.
170+
String folder = pool.getPath();
171+
if (pool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
172+
folder = folder.substring(0, folder.indexOf("?"));
173+
}
174+
volumeVO.setFolder(folder);
175+
168176
volDao.update(volume.getId(), volumeVO);
169177
updated = true;
170178
break;

0 commit comments

Comments
 (0)