Skip to content

Commit 70dc5be

Browse files
committed
Updated for UseAgentCert == false to prevent segfaults
1 parent eda43c9 commit 70dc5be

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

agent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern ScheduledJob_t* currentJob; /* Defined in schedule.c */
4747
#define AGENT_MAJOR 3ULL
4848
#define AGENT_MINOR 0ULL
4949
#define AGENT_MICRO 0ULL
50-
#define AGENT_BUILD 1ULL
50+
#define AGENT_BUILD 2ULL
5151

5252
#define AGENT_VERSION \
5353
((AGENT_MAJOR << 48) | \

enrollment.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,10 @@ int cms_job_enroll(SessionJob_t * jobInfo, char *sessionToken,
280280

281281
if (ConfigData->UseAgentCert) {
282282
/* Verify the target store isn't the Agent store */
283-
if (enrConf->StorePath) {
283+
if (enrConf->StorePath && ConfigData->UseAgentCert && ConfigData->AgentCert) {
284284
if (0 == strcasecmp(ConfigData->AgentCert, enrConf->StorePath)) {
285-
286-
log_warn("%s::%s(%d) : Attempting to re-enroll the agent "
287-
"cert is not allowed.", LOG_INF);
288-
append_linef(&statusMessage, "Attempting to re-enroll the "
289-
"agent cert is not allowed.");
285+
log_warn("%s::%s(%d) : Attempting to re-enroll the agent cert is not allowed.", LOG_INF);
286+
append_linef(&statusMessage, "Attempting to re-enroll the agent cert is not allowed.");
290287
failed = true;
291288
}
292289
}

inventory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ int cms_job_inventory(SessionJob_t * jobInfo, char *sessionToken)
414414
failed = true;
415415
}
416416

417-
if (ConfigData->UseAgentCert) {
417+
if (ConfigData->UseAgentCert && ConfigData->AgentCert) {
418418
/* Verify the target store isn't the Agent store */
419419
if (0 == strcasecmp(ConfigData->AgentCert, invConf->Job.StorePath)) {
420420

management.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,14 @@ static bool validate_management_store_configuration(ManagementConfigResp_t* manC
335335
append_linef(statusMessage, "The store path must be a file and not a directory.");
336336
failed = true;
337337
}
338-
/* Is the target store the Agent store? */
339-
if (0 == strcasecmp(ConfigData->AgentCert, manConf->Job.StorePath)) {
340-
log_warn("%s::%s(%d) : Attempting a Management job on the agent cert store is not allowed.", LOG_INF);
341-
append_linef(statusMessage, "Attempting a Management job the agent cert store is not allowed.");
342-
failed = true;
343-
}
338+
if (ConfigData->UseAgentCert && ConfigData->AgentCert) { /* If we have an agent cert, we can't manage it through this job */
339+
/* Is the target store the Agent store? */
340+
if (0 == strcasecmp(ConfigData->AgentCert, manConf->Job.StorePath)) {
341+
log_warn("%s::%s(%d) : Attempting a Management job on the agent cert store is not allowed.", LOG_INF);
342+
append_linef(statusMessage, "Attempting a Management job the agent cert store is not allowed.");
343+
failed = true;
344+
}
345+
}
344346
/* Verify the target store exists */
345347
if (!file_exists(manConf->Job.StorePath)) {
346348
log_warn("%s::%s(%d) : Attempting to manage a certificate store that does not exist yet.", LOG_INF);

0 commit comments

Comments
 (0)