Fix for incorrect /etc/borgmatic.d/ configuration path probing on macOS.

This commit is contained in:
Dan 2017-11-10 21:33:29 -08:00
parent 5ce25e2790
commit 3e26e70d0c
4 changed files with 22 additions and 5 deletions

4
NEWS
View file

@ -1,5 +1,7 @@
1.1.11.dev0 1.1.11
* #25: Add "ssh_command" to configuration for specifying a custom SSH command or options. * #25: Add "ssh_command" to configuration for specifying a custom SSH command or options.
* Fix for incorrect /etc/borgmatic.d/ configuration path probing on macOS. This problem manifested
as an error on startup: "[Errno 2] No such file or directory: '/etc/borgmatic.d'".
1.1.10 1.1.10
* Pass several Unix signals through to child processes like Borg. This means that Borg now properly * Pass several Unix signals through to child processes like Borg. This means that Borg now properly

View file

@ -11,13 +11,15 @@ def collect_config_filenames(config_paths):
files. This is non-recursive, so any directories within the given directories are ignored. files. This is non-recursive, so any directories within the given directories are ignored.
Return paths even if they don't exist on disk, so the user can find out about missing Return paths even if they don't exist on disk, so the user can find out about missing
configuration paths. However, skip /etc/borgmatic.d if it's missing, so the user doesn't have to configuration paths. However, skip a default config path if it's missing, so the user doesn't
create it unless they need it. have to create a default config path unless they need it.
''' '''
real_default_config_paths = set(map(os.path.realpath, DEFAULT_CONFIG_PATHS))
for path in config_paths: for path in config_paths:
exists = os.path.exists(path) exists = os.path.exists(path)
if os.path.realpath(path) in DEFAULT_CONFIG_PATHS and not exists: if os.path.realpath(path) in real_default_config_paths and not exists:
continue continue
if not os.path.isdir(path) or not exists: if not os.path.isdir(path) or not exists:

View file

@ -58,6 +58,19 @@ def test_collect_config_filenames_skips_etc_borgmatic_dot_d_if_it_does_not_exist
assert config_filenames == ('config.yaml',) assert config_filenames == ('config.yaml',)
def test_collect_config_filenames_skips_non_canonical_etc_borgmatic_dot_d_if_it_does_not_exist():
config_paths = ('config.yaml', '/etc/../etc/borgmatic.d')
mock_path = flexmock(module.os.path)
mock_path.should_receive('exists').with_args('config.yaml').and_return(True)
mock_path.should_receive('exists').with_args('/etc/../etc/borgmatic.d').and_return(False)
mock_path.should_receive('isdir').with_args('config.yaml').and_return(False)
mock_path.should_receive('isdir').with_args('/etc/../etc/borgmatic.d').and_return(True)
config_filenames = tuple(module.collect_config_filenames(config_paths))
assert config_filenames == ('config.yaml',)
def test_collect_config_filenames_includes_other_directory_if_it_does_not_exist(): def test_collect_config_filenames_includes_other_directory_if_it_does_not_exist():
config_paths = ('config.yaml', '/my/directory') config_paths = ('config.yaml', '/my/directory')
mock_path = flexmock(module.os.path) mock_path = flexmock(module.os.path)

View file

@ -1,7 +1,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
VERSION = '1.1.11.dev0' VERSION = '1.1.11'
setup( setup(