The webserver where I run cacti on already has a user account/password setup in front of it, so having to login in twice to get to Cacti was being a PITA.
Turning off authentication in Cacti (see cacti/settings.php?tab=authentication, or the Authentication Tab in Configuration/Settings) means the weathermap would emit some weird messages and not work.
I found two files so far that needed to be fixed to make it work with no Cacti authentication
weathermap-cacti-plugin.php
Code: Select all
weathermap # diff -u weathermap-cacti-plugin.php /var/srv/www/cacti/plugins/weathermap/weathermap-cacti-plugin.php
--- weathermap-cacti-plugin.php 2006-06-27 14:51:47.273243112 -0700
+++ /var/srv/www/cacti/plugins/weathermap/weathermap-cacti-plugin.php 2006-06-27 12:29:04.178031456 -0700
@@ -74,7 +74,12 @@
$confdir = dirname(__FILE__).'/configs/';
# $map = db_fetch_assoc("select * from weathermap_maps where id=".$mapid);
- $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) and weathermap_maps.id=".$mapid);
+
+ if (read_config_option("global_auth") == "on") {
+ $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) and weathermap_maps.id=".$mapid);
+ } else {
+ $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and weathermap_maps.id=".$mapid);
+ }
if(sizeof($map))
{
@@ -118,8 +123,8 @@
if (isset($user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'])) {
$realm_id2 = $user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'];
- }
- if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {
+ }
+ if ((read_config_option("global_auth") == "off") || (db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {
print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin-mgmt.php">Manage Maps</a>';
}
@@ -129,7 +134,12 @@
{
global $colors;
- $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+
+ if (read_config_option("global_auth") == "on") {
+ $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+ } else {
+ $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' order by sortorder, id");
+ }
if(sizeof($maplist) == 1)
@@ -204,7 +214,11 @@
$_SESSION['custom']=false;
- $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+ if (read_config_option("global_auth") == "on") {
+ $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id");
+ } else {
+ $maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and order by sortorder, id");
+ }
html_graph_start_box(2,true);
if(sizeof($maplist) == 1)
setup.php, function weathermap_show_tab()
Code: Select all
function weathermap_show_tab () {
global $config, $user_auth_realms, $user_auth_realm_filenames;
$realm_id2 = 0;
if (isset($user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')])) {
$realm_id2 = $user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')];
}
if (read_config_option("global_auth") == "on") {
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {
print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin.php"><img src="' . $config['url_path'] . 'plugins/weathermap/images/tab_weathermap.png" alt="Weathermap" align="absmiddle" border="0"></a>';
}
} else {
print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin.php"><img src="' . $config['url_path'] . 'plugins/weathermap/images/tab_weathermap.png" alt="Weathermap" align="absmiddle" border="0"></a>';
}
basically, where-ever sess_user_id is used, if the config_option global_auth is off we just ignore any userid and pull all information.
I also had to change cacti/include/top_graph_header.php:
Code: Select all
diff -u top_graph_header.php /var/srv/www/cacti/include/top_graph_header.php
--- top_graph_header.php 2006-06-27 14:34:55.012130192 -0700
+++ /var/srv/www/cacti/include/top_graph_header.php 2006-06-27 15:07:22.573055928 -0700
@@ -41,6 +41,8 @@
if (sizeof(db_fetch_assoc("select realm_id from user_auth_realm where realm_id=8 and user_id=" . $_SESSION["sess_user_id"])) == 0) {
$show_console_tab = false;
}
+} else {
+ $current_user = db_fetch_row("select * from user_auth where id='admin'");
}
/* use cached url if available and applicable */
These changes do give full admin access to everything; that is the way we currently run Cacti (everyone is trusted who has access to the server)