Skip to content

Commit

Permalink
Remove cs.type param
Browse files Browse the repository at this point in the history
The cs.type param has been removed from CS.cfg since subsystem
type is not actually changeable and this param might introduce
configuration issues.

The code that uses the subsystem type has been modified to call
CMSEngine.getName() (for uppercase subsystem type) and getID()
for (for lower case subsystem type) instead.

The PKISubsystem.create_conf() has been modified to no longer
add the param if it's missing. The load() has also been updated
to no longer read the param.

The upgrade script has been modified to remove the param from
existing instances.
  • Loading branch information
edewata committed May 15, 2024
1 parent 09ea4f7 commit 0f7647f
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 60 deletions.
1 change: 0 additions & 1 deletion base/ca/shared/conf/CS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cs.state._001=## cs.state=0 (pre-operational)
cs.state._002=## cs.state=1 (running)
cs.state._003=##
cs.state=0
cs.type=CA
authType=pwd
admin.interface.uri=ca/admin/console/config/wizard
ee.interface.uri=ca/ee/ca
Expand Down
1 change: 0 additions & 1 deletion base/kra/shared/conf/CS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ _002=##
installDate=[pki_install_time]
cms.product.version=@APPLICATION_VERSION@
cs.state=0
cs.type=KRA
admin.interface.uri=kra/admin/console/config/wizard
agent.interface.uri=kra/agent/kra
authType=pwd
Expand Down
1 change: 0 additions & 1 deletion base/ocsp/shared/conf/CS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ _001=## Online Certificate Status Protocol (OCSP) Responder Configuration File
_002=##
pidDir=/var/run/pki/tomcat
installDate=[pki_install_time]
cs.type=OCSP
admin.interface.uri=ocsp/admin/console/config/wizard
agent.interface.uri=ocsp/agent/ocsp
cms.product.version=@APPLICATION_VERSION@
Expand Down
5 changes: 0 additions & 5 deletions base/server/python/pki/server/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ def create_conf(self, exist_ok=False):
if os.path.exists(self.cs_conf):
pki.util.load_properties(self.cs_conf, self.config)

if 'cs.type' not in self.config:
self.set_config('cs.type', self.type)

logger.info('Storing subsystem config: %s', self.cs_conf)
self.instance.store_properties(self.cs_conf, self.config)

Expand Down Expand Up @@ -254,8 +251,6 @@ def load(self):
logger.info('Loading subsystem config: %s', self.cs_conf)
pki.util.load_properties(self.cs_conf, self.config)

self.type = self.config['cs.type']

self.registry.clear()

if os.path.exists(self.registry_conf):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void init(LoggerConfig config) throws IOException, EBaseException {
mLevel = config.getLevel();

try {
String subsystem = cs.getType().toLowerCase();
String subsystem = engine.getID();
String instID = CMS.getInstanceID();

// build the default signedAudit file name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void setServerConfig(ServerConfig serverConfig) throws Exception {

public String getInstallToken(String sdhost, int sdport, String user, String passwd) throws Exception {

String csType = cs.getType();
String csType = engine.getName();

ClientConfig config = new ClientConfig();
config.setServerURL("https://" + sdhost + ":" + sdport);
Expand Down Expand Up @@ -134,7 +134,7 @@ public String getOldCookie(String sdhost, int sdport, String user, String passwd

String subca_url = "https://" + cs.getHostname() + ":"
+ engine.getAdminPort() + "/ca/admin/console/config/wizard" +
"?p=5&subsystem=" + cs.getType();
"?p=5&subsystem=" + engine.getName();

MultivaluedMap<String, String> content = new MultivaluedHashMap<>();
content.putSingle("uid", user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected void process(CMSRequest cmsReq) throws EBaseException {
EngineConfig config = engine.getConfig();

int state = config.getState();
String type = config.getType();
String type = engine.getName();
String status = engine.isReady() ? "running" : "starting";
String version = GetStatus.class.getPackage().getImplementationVersion();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ protected void process(CMSRequest cmsReq) throws EBaseException {

EngineConfig cs = engine.getConfig();
DatabaseConfig dbConfig = cs.getDatabaseConfig();
String cstype = cs.getType();

auditParams += "+type;;" + type;

Expand Down
41 changes: 7 additions & 34 deletions base/server/src/main/java/com/netscape/cmscore/apps/CMSEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ public void initSubsystemListeners() throws Exception {
listenersConfig = config.getSubStore("startupNotifiers", ConfigStore.class);

if (listenersConfig.size() > 0) {
String subsystem = config.getType().toLowerCase();
String configPath = instanceDir + "/conf/" + subsystem + "/CS.cfg";
String configPath = instanceDir + "/conf/" + id + "/CS.cfg";
logger.warn("The 'startupNotifiers' property in " + configPath + " has been deprecated. Use 'listeners' instead.");
}
}
Expand Down Expand Up @@ -683,8 +682,7 @@ public void initDatabase() throws Exception {

public void initPluginRegistry() throws Exception {
ConfigStore pluginRegistryConfig = config.getSubStore(PluginRegistry.ID, ConfigStore.class);
String subsystem = config.getType().toLowerCase();
String defaultRegistryFile = instanceDir + "/conf/" + subsystem + "/registry.cfg";
String defaultRegistryFile = instanceDir + "/conf/" + id + "/registry.cfg";
pluginRegistry.init(pluginRegistryConfig, defaultRegistryFile);
pluginRegistry.startup();
}
Expand Down Expand Up @@ -1073,8 +1071,6 @@ public void configureAutoShutdown() throws Exception {

public void configureServerCertNickname() throws EBaseException {

String id = mConfig.getType().toLowerCase();

if (id.equals("ca") || id.equals("ocsp") ||
id.equals("kra") || id.equals("tks")) {

Expand Down Expand Up @@ -1898,32 +1894,17 @@ public void verifySystemCerts(boolean checkValidityOnly) throws Exception {
String auditMessage = null;

try {
String subsysType = config.getType();
if (subsysType == null || subsysType.equals("")) {
logger.error("CMSEngine: Missing cs.type in CS.cfg");
auditMessage = CMS.getLogMessage(
AuditEvent.CIMC_CERT_VERIFICATION,
ILogger.SYSTEM_UID,
ILogger.FAILURE,
"");

auditor.log(auditMessage);
throw new Exception("Missing cs.type in CS.cfg");
}

subsysType = subsysType.toLowerCase();

String certlist = config.getString(subsysType + ".cert.list", "");
String certlist = config.getString(id + ".cert.list", "");
if (certlist.equals("")) {
logger.error("CMSEngine: Missing " + subsysType + ".cert.list in CS.cfg");
logger.error("CMSEngine: Missing " + id + ".cert.list in CS.cfg");
auditMessage = CMS.getLogMessage(
AuditEvent.CIMC_CERT_VERIFICATION,
ILogger.SYSTEM_UID,
ILogger.FAILURE,
"");

auditor.log(auditMessage);
throw new Exception("Missing " + subsysType + ".cert.list in CS.cfg");
throw new Exception("Missing " + id + ".cert.list in CS.cfg");
}

StringTokenizer tokenizer = new StringTokenizer(certlist, ",");
Expand Down Expand Up @@ -1972,21 +1953,13 @@ public void verifySystemCertByTag(String tag, boolean checkValidityOnly) throws
String auditMessage = null;

try {
String subsysType = config.getType();
if (subsysType == null || subsysType.equals("")) {
logger.error("CMSEngine: Missing cs.type in CS.cfg");
throw new Exception("Missing cs.type in CS.cfg");
}

subsysType = subsysType.toLowerCase();

String nickname = config.getString(subsysType + ".cert." + tag + ".nickname", "");
String nickname = config.getString(id + ".cert." + tag + ".nickname", "");
if (nickname.equals("")) {
logger.error("CMSEngine: verifySystemCertByTag() nickname for cert tag " + tag + " undefined in CS.cfg");
throw new Exception("Missing nickname for " + tag + " certificate");
}

String certusage = config.getString(subsysType + ".cert." + tag + ".certusage", "");
String certusage = config.getString(id + ".cert." + tag + ".certusage", "");
if (certusage.equals("")) {
logger.warn("CMSEngine: verifySystemCertByTag() certusage for cert tag "
+ tag + " undefined in CS.cfg, getting current certificate usage");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ public void setPasswordFile(String passwordFile) throws EBaseException {
putString("passwordFile", passwordFile);
}

public String getType() throws EBaseException {
return getString("cs.type");
}

public void setType(String type) throws EBaseException {
putString("cs.type", type);
}

public int getState() throws EBaseException {
return getInteger("cs.state");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public UserData getUserData(String userID) {
if (!StringUtils.isEmpty(type)) userData.setType(type);

// TODO: refactor into TPSUserService
String csType = cs.getType();
String csType = engine.getName();
if (csType.equals("TPS")) {

List<String> profiles = user.getTpsProfiles();
Expand Down Expand Up @@ -348,7 +348,7 @@ public Response addUser(UserData userData) {
}

// TODO: refactor into TPSUserService
String csType = cs.getType();
String csType = engine.getName();
if (csType.equals("TPS")) {

String tpsProfiles = userData.getAttribute(ATTR_TPS_PROFILES);
Expand Down Expand Up @@ -460,7 +460,7 @@ public Response modifyUser(String userID, UserData userData) {
}

// TODO: refactor into TPSUserService
String csType = cs.getType();
String csType = engine.getName();
if (csType.equals("TPS")) {

String tpsProfiles = userData.getAttribute(ATTR_TPS_PROFILES);
Expand Down
4 changes: 4 additions & 0 deletions base/server/upgrade/11.6.0/01-CleanUpSubsystemConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def upgrade_subsystem(self, instance, subsystem):
logger.info('Removing instanceId')
subsystem.config.pop('instanceId', None)

if subsystem.config.get('cs.type'):
logger.info('Removing cs.type')
subsystem.config.pop('cs.type', None)

param = '%s.admin.cert' % subsystem.name
if subsystem.config.get(param):
logger.info('Removing %s', param)
Expand Down
1 change: 0 additions & 1 deletion base/tks/shared/conf/CS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ _001=## Token Key Service (TKS) Configuration File
_002=##
pidDir=/var/run/pki/tomcat
installDate=[pki_install_time]
cs.type=TKS
admin.interface.uri=tks/admin/console/config/wizard
cms.product.version=@APPLICATION_VERSION@
cms.passwordlist=internaldb,replicationdb
Expand Down
1 change: 0 additions & 1 deletion base/tps/shared/conf/CS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ cms.passwordlist=internaldb
config.Generals.General.state=Enabled
config.Generals.General.timestamp=1280283607424406
cs.state=0
cs.type=TPS
dbs.ldap=internaldb
dbs.newSchemaEntryAdded=true
debug.level=10
Expand Down
1 change: 1 addition & 0 deletions docs/changes/v11.6.0/Server-Changes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The following parameters in `CS.cfg` are no longer used
so they have been removed:

* `instanceId`
* `cs.type`
* `<subsystem>.admin.cert`
* `<subsystem>.standalone`

Expand Down

0 comments on commit 0f7647f

Please sign in to comment.