|
|
fc3955 |
From 320168071ff56c00ff65870e781a261075fccc66 Mon Sep 17 00:00:00 2001
|
|
|
fc3955 |
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
|
|
|
fc3955 |
Date: Wed, 21 Sep 2022 18:28:55 -0300
|
|
|
fc3955 |
Subject: [PATCH] ipaconfig: Do not allow enable_sid set to False.
|
|
|
fc3955 |
|
|
|
fc3955 |
Once enabled, SID cannot be disabled. This patch ensures that an error
|
|
|
fc3955 |
is raised if one tries to disable SID.
|
|
|
fc3955 |
---
|
|
|
fc3955 |
README-config.md | 2 +-
|
|
|
fc3955 |
plugins/modules/ipaconfig.py | 15 ++++++++-------
|
|
|
fc3955 |
tests/config/test_config_sid.yml | 13 +++++++++++++
|
|
|
fc3955 |
3 files changed, 22 insertions(+), 8 deletions(-)
|
|
|
fc3955 |
|
|
|
fc3955 |
diff --git a/README-config.md b/README-config.md
|
|
|
fc3955 |
index 13023ea..d6fe40a 100644
|
|
|
fc3955 |
--- a/README-config.md
|
|
|
fc3955 |
+++ b/README-config.md
|
|
|
fc3955 |
@@ -148,7 +148,7 @@ Variable | Description | Required
|
|
|
fc3955 |
`user_auth_type` \| `ipauserauthtype` | set default types of supported user authentication (choices: `password`, `radius`, `otp`, `disabled`). Use `""` to clear this variable. | no
|
|
|
fc3955 |
`domain_resolution_order` \| `ipadomainresolutionorder` | Set list of domains used for short name qualification | no
|
|
|
fc3955 |
`ca_renewal_master_server` \| `ipacarenewalmasterserver`| Renewal master for IPA certificate authority. | no
|
|
|
fc3955 |
-`enable_sid` | New users and groups automatically get a SID assigned. Requires IPA 4.9.8+. (bool) | no
|
|
|
fc3955 |
+`enable_sid` | New users and groups automatically get a SID assigned. Cannot be deactivated once activated. Requires IPA 4.9.8+. (bool) | no
|
|
|
fc3955 |
`netbios_name` | NetBIOS name of the IPA domain. Requires IPA 4.9.8+ and 'enable_sid: yes'. | no
|
|
|
fc3955 |
`add_sids` | Add SIDs for existing users and groups. Requires IPA 4.9.8+ and 'enable_sid: yes'. (bool) | no
|
|
|
fc3955 |
|
|
|
fc3955 |
diff --git a/plugins/modules/ipaconfig.py b/plugins/modules/ipaconfig.py
|
|
|
fc3955 |
index 87810b2..9c19afb 100644
|
|
|
fc3955 |
--- a/plugins/modules/ipaconfig.py
|
|
|
fc3955 |
+++ b/plugins/modules/ipaconfig.py
|
|
|
fc3955 |
@@ -175,7 +175,7 @@ options:
|
|
|
fc3955 |
enable_sid:
|
|
|
fc3955 |
description: >
|
|
|
fc3955 |
New users and groups automatically get a SID assigned.
|
|
|
fc3955 |
- Requires IPA 4.9.8+.
|
|
|
fc3955 |
+ Cannot be deactivated once activated. Requires IPA 4.9.8+.
|
|
|
fc3955 |
required: false
|
|
|
fc3955 |
type: bool
|
|
|
fc3955 |
netbios_name:
|
|
|
fc3955 |
@@ -525,11 +525,16 @@ def main():
|
|
|
fc3955 |
result = config_show(ansible_module)
|
|
|
fc3955 |
|
|
|
fc3955 |
if params:
|
|
|
fc3955 |
+ enable_sid = params.get("enable_sid")
|
|
|
fc3955 |
+ sid_is_enabled = has_enable_sid and is_enable_sid(ansible_module)
|
|
|
fc3955 |
+
|
|
|
fc3955 |
+ if sid_is_enabled and enable_sid is False:
|
|
|
fc3955 |
+ ansible_module.fail_json(msg="SID cannot be disabled.")
|
|
|
fc3955 |
+
|
|
|
fc3955 |
netbios_name = params.get("netbios_name")
|
|
|
fc3955 |
if netbios_name:
|
|
|
fc3955 |
netbios_name = netbios_name.upper()
|
|
|
fc3955 |
add_sids = params.get("add_sids")
|
|
|
fc3955 |
- enable_sid = params.get("enable_sid")
|
|
|
fc3955 |
required_sid = any([netbios_name, add_sids])
|
|
|
fc3955 |
if required_sid and not enable_sid:
|
|
|
fc3955 |
ansible_module.fail_json(
|
|
|
fc3955 |
@@ -551,13 +556,9 @@ def main():
|
|
|
fc3955 |
del params["add_sids"]
|
|
|
fc3955 |
if (
|
|
|
fc3955 |
not any([netbios_name, add_sids])
|
|
|
fc3955 |
- and is_enable_sid(ansible_module)
|
|
|
fc3955 |
+ and sid_is_enabled
|
|
|
fc3955 |
):
|
|
|
fc3955 |
del params["enable_sid"]
|
|
|
fc3955 |
- else:
|
|
|
fc3955 |
- for param in ["enable_sid", "netbios_name", "add_sids"]:
|
|
|
fc3955 |
- if param in params:
|
|
|
fc3955 |
- del params[params]
|
|
|
fc3955 |
|
|
|
fc3955 |
params = {
|
|
|
fc3955 |
k: v for k, v in params.items()
|
|
|
fc3955 |
diff --git a/tests/config/test_config_sid.yml b/tests/config/test_config_sid.yml
|
|
|
fc3955 |
index 1761795..bd550a5 100644
|
|
|
fc3955 |
--- a/tests/config/test_config_sid.yml
|
|
|
fc3955 |
+++ b/tests/config/test_config_sid.yml
|
|
|
fc3955 |
@@ -6,6 +6,9 @@
|
|
|
fc3955 |
|
|
|
fc3955 |
tasks:
|
|
|
fc3955 |
|
|
|
fc3955 |
+ - name: Set FreeIPA facts.
|
|
|
fc3955 |
+ include_tasks: ../env_freeipa_facts.yml
|
|
|
fc3955 |
+
|
|
|
fc3955 |
# GET CURRENT CONFIG
|
|
|
fc3955 |
|
|
|
fc3955 |
- name: Return current values of the global configuration options
|
|
|
fc3955 |
@@ -32,6 +35,14 @@
|
|
|
fc3955 |
register: result
|
|
|
fc3955 |
failed_when: result.failed or result.changed
|
|
|
fc3955 |
|
|
|
fc3955 |
+ - name: Try to Ensure SID is disabled.
|
|
|
fc3955 |
+ ipaconfig:
|
|
|
fc3955 |
+ ipaadmin_password: SomeADMINpassword
|
|
|
fc3955 |
+ ipaapi_context: "{{ ipa_context | default(omit) }}"
|
|
|
fc3955 |
+ enable_sid: no
|
|
|
fc3955 |
+ register: result
|
|
|
fc3955 |
+ failed_when: not result.failed or "SID cannot be disabled." not in result.msg
|
|
|
fc3955 |
+
|
|
|
fc3955 |
- name: Ensure netbios_name is "IPATESTPLAY"
|
|
|
fc3955 |
ipaconfig:
|
|
|
fc3955 |
ipaadmin_password: SomeADMINpassword
|
|
|
fc3955 |
@@ -59,6 +70,8 @@
|
|
|
fc3955 |
enable_sid: yes
|
|
|
fc3955 |
add_sids: yes
|
|
|
fc3955 |
|
|
|
fc3955 |
+ # only run tests if version supports enable-sid
|
|
|
fc3955 |
+ when: ipa_version is version("4.9.8", ">=")
|
|
|
fc3955 |
# REVERT TO PREVIOUS CONFIG
|
|
|
fc3955 |
always:
|
|
|
fc3955 |
# Once SID is enabled, it cannot be reverted.
|
|
|
fc3955 |
--
|
|
|
fc3955 |
2.37.3
|
|
|
fc3955 |
|