2008-09-02 Esteban Sanchez <estebans@artica.es>

* extensions/update_manager.php: Style correction. Removed force
        updating of the settings.

        * extensions/update_manager/load_updatemanager.php: Run the keygen if
        the user is not the free one.

        * extensions/update_manager/main.php: Show information message to free
        users.

        * extensions/update_manager/settings.php: Allow updating keygen and
        binary path settings.

        * extensions/update_manager/lib/*: Updated to latest version of Open
        Update Manager.

        * extensions/update_manager/sql/update_manager.sql: Set keygen path.

        * godmode/extensions.php: Bug solved that was avoiding to show defined
        extensions. Fixed ACL check.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1066 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2008-09-02 11:16:44 +00:00
parent 14b7cd266a
commit 14304892ba
9 changed files with 103 additions and 35 deletions

View File

@ -1,3 +1,25 @@
2008-09-02 Esteban Sanchez <estebans@artica.es>
* extensions/update_manager.php: Style correction. Removed force
updating of the settings.
* extensions/update_manager/load_updatemanager.php: Run the keygen if
the user is not the free one.
* extensions/update_manager/main.php: Show information message to free
users.
* extensions/update_manager/settings.php: Allow updating keygen and
binary path settings.
* extensions/update_manager/lib/*: Updated to latest version of Open
Update Manager.
* extensions/update_manager/sql/update_manager.sql: Set keygen path.
* godmode/extensions.php: Bug solved that was avoiding to show defined
extensions. Fixed ACL check.
2008-09-02 Esteban Sanchez <estebans@artica.es>
* reporting/fgraph.php: Rollback to r1049. It still needs some tests,

View File

@ -49,7 +49,8 @@ function pandora_update_manager_install () {
if ($success === false)
return;
}
$sql = 'INSERT INTO `tconfig` (`token`, `value` ) VALUES ("update_manager_installed", 1)';
$sql = 'INSERT INTO `tconfig` (`token`, `value`)
VALUES ("update_manager_installed", 1)';
process_sql ($sql);
$db =& um_db_connect ('mysql', $config['dbhost'], $config['dbuser'],
@ -87,10 +88,7 @@ function pandora_update_manager_login () {
$config['dbpass'], $config['dbname']);
$settings = um_db_load_settings ();
um_db_update_setting ('update_server_host', 'www.artica.es');
um_db_update_setting ('update_server_path', '/pandoraupdate/server.php');
$user_key = get_user_key ();
$user_key = get_user_key ($settings);
$package = um_client_check_latest_update ($settings, $user_key);

View File

@ -32,15 +32,30 @@ function um_db_load_settings () {
function um_db_update_setting ($key, $value = '') {
global $db;
$values = array ($value, $key);
$sql =& $db->prepare ('UPDATE tupdate_settings SET value = ? WHERE `key` = ?');
$result =& $db->execute ($sql, $values);
$sql =& $db->prepare ('SELECT COUNT(*) e FROM tupdate_settings WHERE `key` = ?');
$result =& $db->execute ($sql, $key);
if (PEAR::isError ($result)) {
echo '<strong>Error</strong>: '.$result->getMessage ().'<br />';
return false;
return NULL;
}
$result->fetchInto ($exists);
$values = array ($value, $key);
if ($exists->e) {
$sql =& $db->prepare ('UPDATE tupdate_settings SET value = ? WHERE `key` = ?');
$result =& $db->execute ($sql, $values);
if (PEAR::isError ($result)) {
echo '<strong>Error</strong>: '.$result->getMessage ().'<br />';
return false;
}
} else {
$sql =& $db->prepare ('INSERT INTO tupdate_settings (value, `key`) VALUES (?, ?)');
$result =& $db->execute ($sql, $values);
if (PEAR::isError ($result)) {
echo '<strong>Error</strong>: '.$result->getMessage ().'<br />';
return false;
}
}
return true;
}
@ -197,11 +212,11 @@ function um_db_get_package_updates ($id_package) {
return $updates;
}
function um_db_create_package_log ($id_package, $client_key, $user_package, $result = 'query', $user_subscription = '') {
function um_db_create_package_log ($id_package, $client_key, $user_package, $result = 'query', $user_subscription = '', $description = '') {
global $db;
$values = array ($id_package, $client_key, $_SERVER['REMOTE_ADDR'], $user_package, $user_subscription, $result);
$sql =& $db->prepare ('INSERT INTO tupdate_package_log (id_update_package, client_key, ip_address, user_package, user_subscription, result) VALUES (?, ?, ?, ?, ?, ?)');
$values = array ($id_package, $client_key, $_SERVER['REMOTE_ADDR'], $user_package, $user_subscription, $result, $description);
$sql =& $db->prepare ('INSERT INTO tupdate_package_log (id_update_package, client_key, ip_address, user_package, user_subscription, result, description) VALUES (?, ?, ?, ?, ?, ?, ?)');
$result =& $db->execute ($sql, $values);
if (PEAR::isError ($result)) {
return false;

View File

@ -144,7 +144,7 @@ function um_client_db_save_update ($update) {
return true;
}
function um_client_apply_update_file ($update, $destiny_filename, $force = false) {
function um_client_apply_update_file (&$update, $destiny_filename, $force = false) {
@mkdir (dirname ($destiny_filename), 0777, true);
if (file_exists ($destiny_filename)) {
@ -169,7 +169,7 @@ function um_client_apply_update_file ($update, $destiny_filename, $force = false
return true;
}
function um_client_apply_update_database ($update, $db) {
function um_client_apply_update_database (&$update, &$db) {
if ($update->type == 'db_data') {
$values = array ($update->db_table,
$update->db_field,
@ -191,7 +191,7 @@ function um_client_apply_update_database ($update, $db) {
return true;
}
function um_client_apply_update ($update, $settings, $db, $force = false) {
function um_client_apply_update (&$update, $settings, $db, $force = false) {
if ($update->type == 'code') {
$filename = realpath ($settings->updating_code_path.'/'.$update->filename);
$success = um_client_apply_update_file ($update, $filename, $force);
@ -209,7 +209,7 @@ function um_client_apply_update ($update, $settings, $db, $force = false) {
return true;
}
function um_client_rollback_update_file ($update, $destiny_filename) {
function um_client_rollback_update_file (&$update, $destiny_filename) {
/* If there's no data rollback, we suppose it's a new file, so it should
not be a problem. In any case, it's better than deleting the file. */
if (! isset ($update->data_rollback))
@ -222,7 +222,7 @@ function um_client_rollback_update_file ($update, $destiny_filename) {
return true;
}
function um_client_rollback_update ($update, $settings, $db) {
function um_client_rollback_update (&$update, $settings, $db) {
if ($update->type == 'code') {
$filename = realpath ($settings->updating_code_path.'/'.$update->filename);
$success = um_client_rollback_update_file ($update, $filename);
@ -313,7 +313,7 @@ function um_client_upgrade_to_latest ($user_key, $force) {
or on auth failure (server return false) */
}
function um_client_db_connect ($settings = NULL) {
function um_client_db_connect (&$settings = NULL) {
if (! $settings)
$settings = um_db_load_settings ();

View File

@ -7,15 +7,43 @@ error_reporting (E_ALL);
/* Database backend, not really tested with other backends, so it's
not functional right now */
define ('DB_BACKEND', 'mysql');
define ('FREE_USER', 'PANDORA-FREE');
if (! extension_loaded ('mysql'))
die ('Your PHP installation appears to be missing the MySQL extension which is required.');
require_once ('lib/libupdate_manager.php');
function get_user_key () {
/* We only want to know this for statistics records.
Feel free to disable if you want. We don't want to hide anything.
function get_user_key ($settings) {
if ($settings->customer_key != FREE_USER) {
if (! file_exists ($settings->keygen_path)) {
echo '<h3 class="err">';
echo __('Keygen file does not exists');
echo '</h3>';
return '';
}
if (! is_executable ($settings->keygen_path)) {
echo '<h3 class="err">';
echo __('Keygen file is not executable');
echo '</h3>';
return '';
}
global $config;
$user_key = exec (escapeshellcmd ($settings->keygen_path.
' '.$settings->customer_key.' '.$config['dbhost'].
' '.$config['dbuser'].' '.$config['dbpass'].
' '.$config['dbname']));
return $user_key;
}
/* Free users.
We only want to know this for statistics records.
Feel free to disable this extension if you want.
*/
$n = (int) get_db_value ('COUNT(`id_agente`)', 'tagente', 'disabled', 0);
$m = (int) get_db_value ('COUNT(`id_agente_modulo`)', 'tagente_modulo',

View File

@ -34,15 +34,17 @@ $settings = um_db_load_settings ();
echo '<h3>'.__('Update manager').'</h3>';
echo '<div class="notify" style="width: 80%" >';
echo '<img src="images/information.png" /> ';
/* Translators: Do not translade Update Manager, it's the name of the program */
echo __('The new <a href="http://updatemanager.sourceforge.net">Update Manager</a> client is shipped with the new Pandora FMS 2.0. It lets systems administrators to do not need to update their PandoraFMS manually since the Update Manager is the one getting new modules, new plugins and new features (even full migrations tools for future versions) automatically');
echo '<p />';
echo __('Update Manager is one of the most advanced features of PandoraFMS 2.0 Enterprise version, for more information visit <a href="http://pandorafms.com">http://pandorafms.com</a>');
echo '</div>';
if ($settings->customer_key == FREE_USER) {
echo '<div class="notify" style="width: 80%" >';
echo '<img src="images/information.png" /> ';
/* Translators: Do not translade Update Manager, it's the name of the program */
echo __('The new <a href="http://updatemanager.sourceforge.net">Update Manager</a> client is shipped with the new Pandora FMS 2.0. It lets systems administrators to do not need to update their PandoraFMS manually since the Update Manager is the one getting new modules, new plugins and new features (even full migrations tools for future versions) automatically');
echo '<p />';
echo __('Update Manager is one of the most advanced features of PandoraFMS 2.0 Enterprise version, for more information visit <a href="http://pandorafms.com">http://pandorafms.com</a>');
echo '</div>';
}
$user_key = get_user_key ();
$user_key = get_user_key ($settings);
$package = um_client_check_latest_update ($settings, $user_key);
if (is_int ($package) && $package == 1) {

View File

@ -58,6 +58,12 @@ $table->data[2][1] = print_input_text ('keys[update_server_path]', $settings->up
$table->data[3][0] = '<strong>'.__('Update server port').'</strong>';
$table->data[3][1] = print_input_text ('keys[update_server_port]', $settings->update_server_port, '', 5, 5, true);
$table->data[4][0] = '<strong>'.__('Binary input path').'</strong>';
$table->data[4][1] = print_input_text ('keys[updating_binary_path]', $settings->updating_binary_path, '', 40, 255, true);
$table->data[5][0] = '<strong>'.__('Keygen path').'</strong>';
$table->data[5][1] = print_input_text ('keys[keygen_path]', $settings->keygen_path, '', 40, 255, true);
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_input_hidden ('update_settings', 1);

View File

@ -1,5 +1,5 @@
CREATE TABLE `tupdate_settings` ( `key` varchar(255) default '', `value` varchar(255) default '', PRIMARY KEY (`key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tupdate_settings` VALUES ('current_update', '0'), ('customer_key', 'PANDORA-FREE'), ('keygen_path', ''), ('update_server_host', 'www.artica.es'), ('update_server_port', '80'), ('update_server_path', '/pandoraupdate/server.php'), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', '');
INSERT INTO `tupdate_settings` VALUES ('current_update', '0'), ('customer_key', 'PANDORA-FREE'), ('keygen_path', '/usr/share/pandora/util/keygen'), ('update_server_host', 'www.artica.es'), ('update_server_port', '80'), ('update_server_path', '/pandoraupdate/server.php'), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', '');
CREATE TABLE `tupdate_package` ( id int(11) unsigned NOT NULL auto_increment, timestamp datetime NOT NULL, description mediumtext NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tupdate` ( id int(11) unsigned NOT NULL auto_increment, type enum('code', 'db_data', 'db_schema', 'binary'), id_update_package int(11) unsigned NOT NULL default 0, filename varchar(250) default '', checksum varchar(250) default '', previous_checksum varchar(250) default '', svn_version int(4) unsigned NOT NULL default 0, data LONGTEXT default '', data_rollback LONGTEXT default '', description TEXT default '', db_table_name varchar(140) default '', db_field_name varchar(140) default '', db_field_value varchar(1024) default '', PRIMARY KEY (`id`), FOREIGN KEY (`id_update_package`) REFERENCES tupdate_package(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tupdate_journal` ( id int(11) unsigned NOT NULL auto_increment, id_update int(11) unsigned NOT NULL default 0, PRIMARY KEY (`id`), FOREIGN KEY (`id_update`) REFERENCES tupdate(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -16,12 +16,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Login check
require ("include/config.php");
check_login ();
if (! give_acl ($config['id_user'], 0, "AR") && ! dame_admin ($config['id_user'])) {
if (! give_acl ($config['id_user'], 0, "PM")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access extensions list");
include ("general/noaccess.php");