mirror of
https://github.com/borgbase/vorta
synced 2025-01-02 13:15:51 +00:00
Properly escape user commands. By @goebbe (#2171)
This commit is contained in:
parent
c64db22afd
commit
4e0c555933
2 changed files with 6 additions and 3 deletions
|
@ -234,7 +234,9 @@ def run(self):
|
||||||
profile=self.params.get('profile_id', None),
|
profile=self.params.get('profile_id', None),
|
||||||
)
|
)
|
||||||
log_entry.save()
|
log_entry.save()
|
||||||
logger.info('Running command %s', ' '.join(self.cmd))
|
cmd_log_tmp = [s.replace(" ", "\\ ") for s in self.cmd] # escape whitespace - for logs
|
||||||
|
logger.info('Running command %s', ' '.join(cmd_log_tmp))
|
||||||
|
del cmd_log_tmp
|
||||||
|
|
||||||
p = Popen(
|
p = Popen(
|
||||||
self.cmd,
|
self.cmd,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
|
@ -102,8 +103,8 @@ def prepare(cls, profile):
|
||||||
suffix_command = []
|
suffix_command = []
|
||||||
if profile.repo.create_backup_cmd:
|
if profile.repo.create_backup_cmd:
|
||||||
s1, sep, s2 = profile.repo.create_backup_cmd.partition('-- ')
|
s1, sep, s2 = profile.repo.create_backup_cmd.partition('-- ')
|
||||||
extra_cmd_options = s1.split()
|
extra_cmd_options = shlex.split(s1)
|
||||||
suffix_command = (sep + s2).split()
|
suffix_command = shlex.split(sep + s2)
|
||||||
|
|
||||||
if n_backup_folders == 0 and '--paths-from-command' not in extra_cmd_options:
|
if n_backup_folders == 0 and '--paths-from-command' not in extra_cmd_options:
|
||||||
ret['message'] = trans_late('messages', 'Add some folders to back up first.')
|
ret['message'] = trans_late('messages', 'Add some folders to back up first.')
|
||||||
|
|
Loading…
Reference in a new issue