mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
authselect migration: use stable interface to query current config
The code currently parses the output of "authselect current" in order to extract the current profile and options. Example: $ authselect current Profile ID: sssd Enabled features: - with-mkhomedir It is easier to use the output of "authselect current --raw". Example: $ authselect current --raw sssd with-mkhomedir Related to https://pagure.io/freeipa/issue/7377 Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
parent
63a5feb19f
commit
aa64ef03a0
@ -22,7 +22,6 @@ from __future__ import absolute_import
|
||||
import logging
|
||||
import six
|
||||
import abc
|
||||
import re
|
||||
|
||||
from ipaplatform.paths import paths
|
||||
from ipapython import ipautil
|
||||
@ -77,7 +76,7 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
||||
def _get_authselect_current_output(self):
|
||||
try:
|
||||
current = ipautil.run(
|
||||
[paths.AUTHSELECT, "current"], env={"LC_ALL": "C.UTF8"})
|
||||
[paths.AUTHSELECT, "current", "--raw"])
|
||||
except ipautil.CalledProcessError:
|
||||
logger.debug("Current configuration not managed by authselect")
|
||||
return None
|
||||
@ -95,19 +94,12 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
||||
if output_text is None:
|
||||
return None
|
||||
|
||||
cfg_params = re.findall(
|
||||
r"\s*Profile ID:\s*(\S+)\s*\n\s*Enabled features:\s*(.*)",
|
||||
output_text,
|
||||
re.DOTALL
|
||||
)
|
||||
|
||||
profile = cfg_params[0][0]
|
||||
|
||||
if not profile:
|
||||
output_text = output_text.strip()
|
||||
if not output_text:
|
||||
return None
|
||||
|
||||
features = re.findall(r"-\s*(\S+)", cfg_params[0][1], re.DOTALL)
|
||||
|
||||
output_items = output_text.split(' ')
|
||||
profile = output_items[0]
|
||||
features = output_items[1:]
|
||||
return profile, features
|
||||
|
||||
def configure(self, sssd, mkhomedir, statestore):
|
||||
|
Loading…
Reference in New Issue
Block a user