Damans227 commented on code in PR #14096:
URL: https://github.com/apache/cloudstack/pull/14096#discussion_r4273543961
##########
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:
should this trim happen where the stored options are read, so backup, delete
and stats get it too? once #14009 quotes them in the script, old rows with a
trailing space would break those as well
##########
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:
what happens with a cifs password that has a comma in it? cifs reads a
double comma as a real comma, and dropping the empty option here would change
the password
--
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]