Nas backup restore fails if the backup repository mount options have a trailing space
- Langage dominant
- Java
- Étoiles
- 3.1k
- Forks
- 1.4k
- Merge moyen
- 6 j 19 h
- PR mergées (30 j)
- 32
Description
### problem
Backup works because mount options are processed inside the shell script `nasbackup.sh` where trailing spaces are not a problem.
But restore (`LibvirtRestoreBackupCommandWrapper`) builds and runs mount in Java
```
if (StringUtils.isNotBlank(mountOptions)) {
mountCmd.add("-o");
mountCmd.add(mountOptions);
}
Script.executeCommand(mountCmd.toArray(new String[0]));
```
Script.executeCommand(String...) builds a ProcessBuilder argument list
mount receives the literal -o "vers=4.1 ". libmount splits options only on commas, so the trailing blank stays glued to the last option, and mount.nfs/the kernel rejects it as a malformed or unknown option ("an incorrect mount option was specified").
`WARN utils.script.Script (logid:435302bd) Process [445800] for command [sudo /usr/bin/mount -t nfs encountered the error: [mount.nfs: an incorrect mount option was specified for /usr/share/cloudstack-agent/tmp/csbackup...`
### versions
ACS 4.22.1
### The steps to reproduce the bug
1. Create a backup repository - specify mount options (`vers=4.1 `) with a trailing space
2. Create backup
3. Restore backup - it fails
...
### What to do about it?
Trim trailing whitespaces before using the mount options
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par LibvirtRestoreBackupCommandWrapper et examinez comment mountOptions est transmis à Script.executeCommand ; comparez cela avec le traitement du shell dans nasbackup.sh. Reproduisez la restauration à l’aide d’une option de dépôt comportant des espaces blancs en fin de chaîne, puis vérifiez que la restauration réussit et que le comportement existant de la commande de montage reste intact.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java, shell
- Domaine
- backend, infrastructure
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Active
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 76/100