Damans227 commented on code in PR #14096:
URL: https://github.com/apache/cloudstack/pull/14096#discussion_r4297391582
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java:
##########
@@ -217,6 +217,7 @@ private String mountBackupDirectory(String
backupRepoAddress, String backupRepoT
mountCmd.add(backupRepoType);
mountCmd.add(backupRepoAddress);
mountCmd.add(mountDirectory);
+ mountOptions = normalizeMountOptions(mountOptions);
Review Comment:
that covers it, all five places now go through the one helper in 4b4dd3f
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java:
##########
@@ -242,6 +243,31 @@ private String mountBackupDirectory(String
backupRepoAddress, String backupRepoT
return mountDirectory;
}
+ /**
+ * Removes the whitespace around each option of a comma-separated mount
option list.
+ *
+ * mount(8) is handed the list as a single argument and libmount splits it
on commas only, so a
+ * blank next to a comma, or at either end of the list, stays glued to the
neighbouring option
+ * and is rejected as part of its name or value.
+ *
+ * Only the whitespace around the delimiters is removed. The option text
itself is passed
+ * through unchanged, as rejecting unsafe or malformed options belongs to
the API layer, not
+ * to the agent.
+ */
+ protected static String normalizeMountOptions(String mountOptions) {
+ if (StringUtils.isBlank(mountOptions)) {
+ return mountOptions;
+ }
+ List<String> options = new ArrayList<>();
+ for (String option : mountOptions.split(",")) {
+ String trimmedOption = option.trim();
+ if (!trimmedOption.isEmpty()) {
Review Comment:
that covers it, the new test keeps pa,,ss as it is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]