Nas backup restore fails if the backup repository mount options have a trailing space
- Lingua principale
- Java
- Stelle
- 3.1k
- Fork
- 1.4k
- Merge medio
- 6g 19h
- PR unite (30g)
- 32
Descrizione
### 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da LibvirtRestoreBackupCommandWrapper e analizza come mountOptions viene passato a Script.executeCommand; confronta questo comportamento con la gestione della shell in nasbackup.sh. Riproduci il ripristino utilizzando un’opzione del repository con spazi bianchi finali, quindi verifica che il ripristino abbia esito positivo e che il comportamento esistente del comando di mount rimanga invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java, shell
- Ambito
- backend, infrastructure
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 76/100