mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Cache the value of ca_is_enabled in the request context
This may be called multiple times in a request and should be impossible to change. https://pagure.io/freeipa/issue/8797 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
@@ -1812,10 +1812,7 @@ class cert_find(Search, CertMethod):
|
||||
|
||||
def execute(self, criteria=None, all=False, raw=False, pkey_only=False,
|
||||
no_members=True, timelimit=None, sizelimit=None, **options):
|
||||
# Store ca_enabled status in the context to save making the API
|
||||
# call multiple times.
|
||||
ca_enabled = self.api.Command.ca_is_enabled()['result']
|
||||
setattr(context, 'ca_enabled', ca_enabled)
|
||||
|
||||
if 'cacn' in options:
|
||||
ca_obj = api.Command.ca_show(options['cacn'])['result']
|
||||
@@ -1933,5 +1930,12 @@ class ca_is_enabled(Command):
|
||||
has_output = output.standard_value
|
||||
|
||||
def execute(self, *args, **options):
|
||||
result = is_service_enabled('CA', conn=self.api.Backend.ldap2)
|
||||
# Store ca_enabled status in the context to save making the API
|
||||
# call multiple times.
|
||||
ca_enabled = getattr(context, 'ca_enabled', None)
|
||||
if ca_enabled is not None and api.env.context in ('lite', 'server',):
|
||||
result = ca_enabled
|
||||
else:
|
||||
result = is_service_enabled('CA', conn=self.api.Backend.ldap2)
|
||||
setattr(context, 'ca_enabled', result)
|
||||
return dict(result=result, value=pkey_to_value(None, options))
|
||||
|
||||
Reference in New Issue
Block a user