Skip to content

Commit

Permalink
Fixing #5170 - Deny Remote Agent
Browse files Browse the repository at this point in the history
If you only have on poller or one active poller, disable the remote agent.
  • Loading branch information
TheWitness committed Jan 19, 2023
1 parent 0dea3cf commit 7cdb6cb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions remote_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function remote_agent_strip_domain($host) {
}

function remote_client_authorized() {
global $poller_db_cnn_id;
global $config, $poller_db_cnn_id;

/* don't allow to run from the command line */
$client_addr = get_client_addr();
Expand All @@ -142,6 +142,10 @@ function remote_client_authorized() {
return false;
}

if ($config['poller_id'] == 1) {
return false;
}

if (!filter_var($client_addr, FILTER_VALIDATE_IP)) {
cacti_log('ERROR: Invalid remote agent client IP Address. Exiting');

Expand All @@ -156,9 +160,9 @@ function remote_client_authorized() {
$client_name = remote_agent_strip_domain($client_name);
}

$pollers = db_fetch_assoc('SELECT * FROM poller', true, $poller_db_cnn_id);
$pollers = db_fetch_assoc('SELECT * FROM poller WHERE disabled = ""', true, $poller_db_cnn_id);

if (cacti_sizeof($pollers)) {
if (cacti_sizeof($pollers) > 1) {
foreach ($pollers as $poller) {
if (remote_agent_strip_domain($poller['hostname']) == $client_name) {
return true;
Expand Down

0 comments on commit 7cdb6cb

Please sign in to comment.