27aee8f99b
- Create minion_id with reproducible mtime - Fix detection of Salt codename by "salt_version" execution module - Fix regression: multiple values for keyword argument 'saltenv' (bsc#1212844) - Fix the regression of user.present state when group is unset (bsc#1212855) - Fix zypper repositories always being reconfigured - Fix utf8 handling in 'pass' renderer and make it more robust - Prevent _pygit2.GitError: error loading known_hosts when $HOME is not set (bsc#1210994) - Fix ModuleNotFoundError and other issues raised by salt-support module (bsc#1211591) - tornado: Fix an open redirect in StaticFileHandler (CVE-2023-28370, bsc#1211741) - Make master_tops compatible with Salt 3000 and older minions (bsc#1212516) (bsc#1212517) - Avoid failures due transactional_update module not available in Salt 3006.0 (bsc#1211754) - Avoid conflicts with Salt dependencies versions (bsc#1211612) - Added: * fix-utf8-handling-in-pass-renderer-and-make-it-more-.patch * fix-the-regression-of-user.present-state-when-group-.patch * make-master_tops-compatible-with-salt-3000-and-older.patch * avoid-conflicts-with-dependencies-versions-bsc-12116.patch * tornado-fix-an-open-redirect-in-staticfilehandler-cv.patch * fix-regression-multiple-values-for-keyword-argument-.patch * zypper-pkgrepo-alreadyconfigured-585.patch * mark-salt-3006-as-released-586.patch * fix-some-issues-detected-in-salt-support-cli-module-.patch * define-__virtualname__-for-transactional_update-modu.patch * 3006.0-prevent-_pygit2.giterror-error-loading-known_.patch OBS-URL: https://build.opensuse.org/request/show/1103185 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=212
72 lines
2.9 KiB
Diff
72 lines
2.9 KiB
Diff
From 40a57afc65e71835127a437248ed655404cff0e8 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
|
<psuarezhernandez@suse.com>
|
|
Date: Tue, 27 Jun 2023 11:24:39 +0100
|
|
Subject: [PATCH] 3006.0: Prevent _pygit2.GitError: error loading
|
|
known_hosts when $HOME is not set (bsc#1210994) (#588)
|
|
|
|
* Prevent _pygit2.GitError: error loading known_hosts when $HOME is not set
|
|
|
|
* Add unit test to cover case of unset home
|
|
---
|
|
salt/utils/gitfs.py | 5 +++++
|
|
tests/unit/utils/test_gitfs.py | 14 ++++++++++++++
|
|
2 files changed, 19 insertions(+)
|
|
|
|
diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py
|
|
index cc9895d8ab..38e84f38aa 100644
|
|
--- a/salt/utils/gitfs.py
|
|
+++ b/salt/utils/gitfs.py
|
|
@@ -34,6 +34,7 @@ import salt.utils.stringutils
|
|
import salt.utils.url
|
|
import salt.utils.user
|
|
import salt.utils.versions
|
|
+import salt.syspaths
|
|
from salt.config import DEFAULT_MASTER_OPTS as _DEFAULT_MASTER_OPTS
|
|
from salt.exceptions import FileserverConfigError, GitLockError, get_error_message
|
|
from salt.utils.event import tagify
|
|
@@ -1867,6 +1868,10 @@ class Pygit2(GitProvider):
|
|
# pruning only available in pygit2 >= 0.26.2
|
|
pass
|
|
try:
|
|
+ # Make sure $HOME env variable is set to prevent
|
|
+ # _pygit2.GitError: error loading known_hosts in some libgit2 versions.
|
|
+ if "HOME" not in os.environ:
|
|
+ os.environ["HOME"] = salt.syspaths.HOME_DIR
|
|
fetch_results = origin.fetch(**fetch_kwargs)
|
|
except GitError as exc: # pylint: disable=broad-except
|
|
exc_str = get_error_message(exc).lower()
|
|
diff --git a/tests/unit/utils/test_gitfs.py b/tests/unit/utils/test_gitfs.py
|
|
index b99da3ef91..7c400b69af 100644
|
|
--- a/tests/unit/utils/test_gitfs.py
|
|
+++ b/tests/unit/utils/test_gitfs.py
|
|
@@ -14,6 +14,7 @@ import salt.utils.gitfs
|
|
import salt.utils.platform
|
|
import tests.support.paths
|
|
from salt.exceptions import FileserverConfigError
|
|
+from tests.support.helpers import patched_environ
|
|
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
|
|
from tests.support.mock import MagicMock, patch
|
|
from tests.support.unit import TestCase
|
|
@@ -335,3 +336,16 @@ class TestPygit2(TestCase):
|
|
self.assertIn(provider.cachedir, provider.checkout())
|
|
provider.branch = "does_not_exist"
|
|
self.assertIsNone(provider.checkout())
|
|
+
|
|
+ def test_checkout_with_home_env_unset(self):
|
|
+ remote = os.path.join(tests.support.paths.TMP, "pygit2-repo")
|
|
+ cache = os.path.join(tests.support.paths.TMP, "pygit2-repo-cache")
|
|
+ self._prepare_remote_repository(remote)
|
|
+ provider = self._prepare_cache_repository(remote, cache)
|
|
+ provider.remotecallbacks = None
|
|
+ provider.credentials = None
|
|
+ with patched_environ(__cleanup__=["HOME"]):
|
|
+ self.assertTrue("HOME" not in os.environ)
|
|
+ provider.init_remote()
|
|
+ provider.fetch()
|
|
+ self.assertTrue("HOME" in os.environ)
|
|
--
|
|
2.41.0
|
|
|
|
|