Bladeren bron

Fix for certain configuration options like ssh_command impacting Borg invocations for separate configuration files (#323).

Dan Helfman 5 jaren geleden
bovenliggende
commit
a155eefa23
3 gewijzigde bestanden met toevoegingen van 16 en 0 verwijderingen
  1. 2 0
      NEWS
  2. 2 0
      borgmatic/borg/environment.py
  3. 12 0
      tests/unit/borg/test_environment.py

+ 2 - 0
NEWS

@@ -5,6 +5,8 @@
    still trigger a monitoring "fail" status.
    still trigger a monitoring "fail" status.
  * #316: Fix hang when a stale database dump named pipe from an aborted borgmatic run remains on
  * #316: Fix hang when a stale database dump named pipe from an aborted borgmatic run remains on
    disk.
    disk.
+ * #323: Fix for certain configuration options like ssh_command impacting Borg invocations for
+   separate configuration files.
  * Tweak comment indentation in generated configuration file for clarity.
  * Tweak comment indentation in generated configuration file for clarity.
  * Link to Borgmacator GNOME AppIndicator from monitoring documentation.
  * Link to Borgmacator GNOME AppIndicator from monitoring documentation.
 
 

+ 2 - 0
borgmatic/borg/environment.py

@@ -22,6 +22,8 @@ def initialize(storage_config):
         value = storage_config.get(option_name)
         value = storage_config.get(option_name)
         if value:
         if value:
             os.environ[environment_variable_name] = value
             os.environ[environment_variable_name] = value
+        else:
+            os.environ.pop(environment_variable_name, None)
 
 
     for (
     for (
         option_name,
         option_name,

+ 12 - 0
tests/unit/borg/test_environment.py

@@ -60,3 +60,15 @@ def test_initialize_with_relocated_repo_access_should_override_default():
         assert os.environ.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'yes'
         assert os.environ.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'yes'
     finally:
     finally:
         os.environ = orig_environ
         os.environ = orig_environ
+
+
+def test_initialize_is_not_effected_by_existing_environment():
+    orig_environ = os.environ
+
+    try:
+        os.environ = {'BORG_PASSPHRASE': 'pass', 'BORG_SSH': 'mosh'}
+        module.initialize({'ssh_command': 'ssh -C'})
+        assert 'BORG_PASSPHRASE' not in os.environ
+        assert os.environ.get('BORG_RSH') == 'ssh -C'
+    finally:
+        os.environ = orig_environ