Skip to content

Commit

Permalink
Add PKISubsystem.get_subsystem_index()
Browse files Browse the repository at this point in the history
The PKISubsystem.get_subsystem_index() has been added to get
the subsystem index in CS.cfg. The code that configures the
LDAPProfileSubsystem has been updated to use this method.
  • Loading branch information
edewata committed May 4, 2023
1 parent 679c07f commit 7d6ab78
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ def spawn(self, deployer):
subsystem.config['preop.cert.signing.profile'] = 'caInstallCACert'

if config.str2bool(deployer.mdict['pki_profiles_in_ldap']):
subsystem.config['subsystem.1.class'] = \
index = subsystem.get_subsystem_index('profile')
subsystem.config['subsystem.%d.class' % index] = \
'com.netscape.cmscore.profile.LDAPProfileSubsystem'

# configure OCSP
Expand Down
24 changes: 24 additions & 0 deletions base/server/python/pki/server/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,30 @@ def remove(self, force=False):
logger.info('Removing %s', self.base_dir)
pki.util.rmtree(self.base_dir, force=force)

def get_subsystem_index(self, subsystem_id):
'''
Get index of subsystem in CS.cfg.
'''

# find subsystem.<index>.id params
pattern = re.compile(r'^subsystem\.(.*)\.id$')

for key, value in self.config.items():

m = pattern.match(key)
if not m:
continue

value = self.config[key]
if value != subsystem_id:
continue

# param value matches subsystem ID -> return index
index = m.group(1)
return int(index)

return None

def find_system_certs(self):

cert_ids = self.config['%s.cert.list' % self.name].split(',')
Expand Down

0 comments on commit 7d6ab78

Please sign in to comment.