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 logging
|
||||||
import six
|
import six
|
||||||
import abc
|
import abc
|
||||||
import re
|
|
||||||
|
|
||||||
from ipaplatform.paths import paths
|
from ipaplatform.paths import paths
|
||||||
from ipapython import ipautil
|
from ipapython import ipautil
|
||||||
@ -77,7 +76,7 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
|||||||
def _get_authselect_current_output(self):
|
def _get_authselect_current_output(self):
|
||||||
try:
|
try:
|
||||||
current = ipautil.run(
|
current = ipautil.run(
|
||||||
[paths.AUTHSELECT, "current"], env={"LC_ALL": "C.UTF8"})
|
[paths.AUTHSELECT, "current", "--raw"])
|
||||||
except ipautil.CalledProcessError:
|
except ipautil.CalledProcessError:
|
||||||
logger.debug("Current configuration not managed by authselect")
|
logger.debug("Current configuration not managed by authselect")
|
||||||
return None
|
return None
|
||||||
@ -95,19 +94,12 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
|||||||
if output_text is None:
|
if output_text is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
cfg_params = re.findall(
|
output_text = output_text.strip()
|
||||||
r"\s*Profile ID:\s*(\S+)\s*\n\s*Enabled features:\s*(.*)",
|
if not output_text:
|
||||||
output_text,
|
|
||||||
re.DOTALL
|
|
||||||
)
|
|
||||||
|
|
||||||
profile = cfg_params[0][0]
|
|
||||||
|
|
||||||
if not profile:
|
|
||||||
return None
|
return None
|
||||||
|
output_items = output_text.split(' ')
|
||||||
features = re.findall(r"-\s*(\S+)", cfg_params[0][1], re.DOTALL)
|
profile = output_items[0]
|
||||||
|
features = output_items[1:]
|
||||||
return profile, features
|
return profile, features
|
||||||
|
|
||||||
def configure(self, sssd, mkhomedir, statestore):
|
def configure(self, sssd, mkhomedir, statestore):
|
||||||
|
Loading…
Reference in New Issue
Block a user