From bc54283667a1977bfcd775baeb4f6eae3a1d7de6e8636fd2225d5722e3e23195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Wed, 18 Oct 2023 08:58:47 +0000 Subject: [PATCH] Accepting request 1118342 from home:mczernek:branches:systemsmanagement:saltstack - Allow all primitive grain types for autosign_grains (bsc#1214477) - Added: * allow-all-primitive-grain-types-for-autosign_grains-.patch OBS-URL: https://build.opensuse.org/request/show/1118342 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=220 --- _lastrevision | 2 +- ...ive-grain-types-for-autosign_grains-.patch | 97 +++++++++++++++++++ salt.changes | 8 ++ salt.spec | 2 + 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 allow-all-primitive-grain-types-for-autosign_grains-.patch diff --git a/_lastrevision b/_lastrevision index 65e7121..5131d8f 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -a07e4ffc42dc0bcf9a52cea8d681ed46dba2505a \ No newline at end of file +98760e99efa76ce0a348adb87dbd36511a748edf \ No newline at end of file diff --git a/allow-all-primitive-grain-types-for-autosign_grains-.patch b/allow-all-primitive-grain-types-for-autosign_grains-.patch new file mode 100644 index 0000000..ee1b7e3 --- /dev/null +++ b/allow-all-primitive-grain-types-for-autosign_grains-.patch @@ -0,0 +1,97 @@ +From ae4e1d1cc15b3c510bdd774a1dfeff67c522324a Mon Sep 17 00:00:00 2001 +From: Marek Czernek +Date: Tue, 17 Oct 2023 13:05:00 +0200 +Subject: [PATCH] Allow all primitive grain types for autosign_grains + (#607) + +* Allow all primitive grain types for autosign_grains + +Signed-off-by: Marek Czernek + +* blacken daemons/masterapi.py and its test_auto_key + +Signed-off-by: Marek Czernek + +--------- + +Signed-off-by: Marek Czernek +Co-authored-by: Alexander Graul +--- + changelog/61416.fixed.md | 1 + + changelog/63708.fixed.md | 1 + + salt/daemons/masterapi.py | 2 +- + .../pytests/unit/daemons/masterapi/test_auto_key.py | 13 +++++++------ + 4 files changed, 10 insertions(+), 7 deletions(-) + create mode 100644 changelog/61416.fixed.md + create mode 100644 changelog/63708.fixed.md + +diff --git a/changelog/61416.fixed.md b/changelog/61416.fixed.md +new file mode 100644 +index 0000000000..3203a0a1c6 +--- /dev/null ++++ b/changelog/61416.fixed.md +@@ -0,0 +1 @@ ++Allow all primitive grain types for autosign_grains +diff --git a/changelog/63708.fixed.md b/changelog/63708.fixed.md +new file mode 100644 +index 0000000000..3203a0a1c6 +--- /dev/null ++++ b/changelog/63708.fixed.md +@@ -0,0 +1 @@ ++Allow all primitive grain types for autosign_grains +diff --git a/salt/daemons/masterapi.py b/salt/daemons/masterapi.py +index 3716c63d99..54aca64a76 100644 +--- a/salt/daemons/masterapi.py ++++ b/salt/daemons/masterapi.py +@@ -366,7 +366,7 @@ class AutoKey: + line = salt.utils.stringutils.to_unicode(line).strip() + if line.startswith("#"): + continue +- if autosign_grains[grain] == line: ++ if str(autosign_grains[grain]) == line: + return True + return False + +diff --git a/tests/pytests/unit/daemons/masterapi/test_auto_key.py b/tests/pytests/unit/daemons/masterapi/test_auto_key.py +index b3657b7f1b..54c3f22d2a 100644 +--- a/tests/pytests/unit/daemons/masterapi/test_auto_key.py ++++ b/tests/pytests/unit/daemons/masterapi/test_auto_key.py +@@ -17,11 +17,11 @@ def gen_permissions(owner="", group="", others=""): + """ + ret = 0 + for c in owner: +- ret |= getattr(stat, "S_I{}USR".format(c.upper()), 0) ++ ret |= getattr(stat, f"S_I{c.upper()}USR", 0) + for c in group: +- ret |= getattr(stat, "S_I{}GRP".format(c.upper()), 0) ++ ret |= getattr(stat, f"S_I{c.upper()}GRP", 0) + for c in others: +- ret |= getattr(stat, "S_I{}OTH".format(c.upper()), 0) ++ ret |= getattr(stat, f"S_I{c.upper()}OTH", 0) + return ret + + +@@ -256,16 +256,17 @@ def test_check_autosign_grains_no_autosign_grains_dir(auto_key): + _test_check_autosign_grains(test_func, auto_key, autosign_grains_dir=None) + + +-def test_check_autosign_grains_accept(auto_key): ++@pytest.mark.parametrize("grain_value", ["test_value", 123, True]) ++def test_check_autosign_grains_accept(grain_value, auto_key): + """ + Asserts that autosigning from grains passes when a matching grain value is in an + autosign_grain file. + """ + + def test_func(*args): +- assert auto_key.check_autosign_grains({"test_grain": "test_value"}) is True ++ assert auto_key.check_autosign_grains({"test_grain": grain_value}) is True + +- file_content = "#test_ignore\ntest_value" ++ file_content = f"#test_ignore\n{grain_value}" + _test_check_autosign_grains(test_func, auto_key, file_content=file_content) + + +-- +2.42.0 + diff --git a/salt.changes b/salt.changes index 30755e4..2831fc5 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Oct 17 15:28:22 UTC 2023 - Marek Czernek + +- Allow all primitive grain types for autosign_grains (bsc#1214477) + +- Added: + * allow-all-primitive-grain-types-for-autosign_grains-.patch + ------------------------------------------------------------------- Mon Oct 2 12:49:41 UTC 2023 - Victor Zhestkov diff --git a/salt.spec b/salt.spec index c406934..d9ce5eb 100644 --- a/salt.spec +++ b/salt.spec @@ -316,6 +316,8 @@ Patch84: use-salt-call-from-salt-bundle-with-transactional_up.patch Patch85: improve-salt.utils.json.find_json-bsc-1213293.patch # PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/65266 Patch86: fix-optimization_order-opt-to-prevent-test-fails.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/65232 +Patch87: allow-all-primitive-grain-types-for-autosign_grains-.patch ### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### SALT PATCHES LIST END