Skip to content

Plugin installs but stays in 'needs configuration' on a clean install #348

Description

@somethingwithproof

On a clean Cacti 1.2.31 install from a tarball:

NOTE: Plugin mactrack installed successfully.
NOTE: Plugin mactrack enabled.
Mactrack plugin is not enabled (status: 2)

Status 2 is "needs configuration". lib/plugins.php:773 sets it when api_plugin_check_config() returns false.

plugin_mactrack_check_config() gates enablement on loading Net_DNS2, whose autoloader resolves classes with a relative include:

// Net/DNS2.php:302
include str_replace('_', '/', $name) . '.php';

That only resolves when the plugin directory is the current directory or on include_path. mactrack_resolver.php calls chdir(__DIR__) before loading it, so that path is fine. Cacti calls plugin_mactrack_check_config() from the web root and from cli/plugin_manage.php, neither of which changes directory, so Net_DNS2_Resolver never loads and the check fails.

Reproduced directly inside the install:

Net/DNS2.php is_file: true
PHP Warning: include(Net/DNS2/Resolver.php): Failed to open stream: No such file or directory
             in .../plugins/mactrack/Net/DNS2.php on line 302
plugin_mactrack_check_config() => false

The gate did not exist before #336:

function plugin_mactrack_check_config() {
	// Here we will check to ensure everything is configured
	mactrack_check_upgrade();

	return true;
}

plugin_flowview vendors the same library and does not reference it in setup.php either. DNS resolution is an optional collector feature used by one CLI script, so it should not gate enablement.

Fixed in #345: restore the original body, and add the plugin directory to include_path in the resolver so the autoloader no longer depends on the chdir side effect. The resolver's require_once is also guarded with is_file() so the diagnostic below it is reachable, which is what turned the #336 mistake into a fatal instead of a log line.

Related to #346.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions