align[11] = 'left';
}
+ if (check_acl($config['id_user'], 0, 'AR')) {
+ $actions_list = true;
+ $table->head[12] = __('Actions');
+ $table->align[12] = 'left';
+ }
+
$id_type_web_content_string = db_get_value(
'id_tipo',
'ttipo_modulo',
@@ -1589,31 +1595,6 @@ if (!empty($result)) {
if (in_array('data_type', $show_fields) || is_metaconsole()) {
$data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true, ['class' => 'invert_filter']);
$agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']);
- if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) {
- $show_edit_icon = true;
- if (defined('METACONSOLE')) {
- if (!can_user_access_node()) {
- $show_edit_icon = false;
- }
-
- $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']);
- } else {
- $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1';
- }
-
- if ($show_edit_icon) {
- $table->cellclass[][2] = 'action_buttons';
- $data[2] .= '
'.html_print_image(
- 'images/config.png',
- true,
- [
- 'alt' => '0',
- 'border' => '',
- 'title' => __('Edit'),
- ]
- ).'';
- }
- }
}
if (in_array('module_name', $show_fields) || is_metaconsole()) {
@@ -2089,6 +2070,39 @@ if (!empty($result)) {
$data[11] = ui_print_timestamp($row['utimestamp'], true, $option);
}
+ if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) {
+ if (defined('METACONSOLE')) {
+ $url_edit_module = $row['server_url'].'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&';
+ $url_edit_module .= 'loginhash=auto&id_agente='.$row['id_agent'];
+ $url_edit_module .= '&tab=module&id_agent_module='.$row['id_agente_modulo'].'&edit_module=1&';
+ $url_edit_module .= 'loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']);
+
+ $url_delete_module = $row['server_url'].'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente';
+ $url_delete_module .= '&id_agente='.$row['id_agent'].'&delete_module='.$row['id_agente_modulo'];
+
+ $table->cellclass[][2] = 'action_buttons';
+ $data[12] .= '
'.html_print_image(
+ 'images/config.png',
+ true,
+ [
+ 'alt' => '0',
+ 'border' => '',
+ 'title' => __('Edit'),
+ ]
+ ).'';
+ $onclick = 'onclick="javascript: if (!confirm(\''.__('Are you sure to delete?').'\')) return false;';
+ $data[12] .= '
'.html_print_image(
+ 'images/delete.png',
+ true,
+ [
+ 'alt' => '0',
+ 'border' => '',
+ 'title' => __('Delete'),
+ ]
+ ).'';
+ }
+ }
+
array_push($table->data, $data);
}
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index ffe4e5628f..eedf00a7d7 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.769
-%define release 230222
+%define release 230227
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index d5efadbd68..79d0892fdf 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.769
-%define release 230222
+%define release 230227
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index e7bb00a30b..6bb5708571 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.769
-%define release 230222
+%define release 230227
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2
diff --git a/pandora_plugins/google_sheets/pandora_googlesheet.py b/pandora_plugins/google_sheets/pandora_googlesheet.py
index a6e599b429..bfa346aa40 100644
--- a/pandora_plugins/google_sheets/pandora_googlesheet.py
+++ b/pandora_plugins/google_sheets/pandora_googlesheet.py
@@ -1,7 +1,13 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
import gspread
-import argparse
+import argparse,json,sys
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
+from os import remove
+
+import base64
__author__ = "Alejandro Sánchez Carrion"
__copyright__ = "Copyright 2022, PandoraFMS"
@@ -15,33 +21,61 @@ Version = {__version__}
Manual execution
-python3 pandora_googlesheets.py --cred
--row --column
+python3 pandora_googlesheets.py --creds_json/creds_base64 --name --sheet --cell --row --column
"""
parser = argparse.ArgumentParser(description= info, formatter_class=argparse.RawTextHelpFormatter)
-parser.add_argument('--cred', help='')
-parser.add_argument('--name', help='')
-parser.add_argument('--row', help='',type=int)
-parser.add_argument('--column', help='',type=int)
+parser.add_argument('--creds_json', help='To authenticate with a json file.')
+parser.add_argument('--creds_base64', help='To authenticate with a file that includes the credentials for base64 authentication.')
+parser.add_argument('--name', help='Name of the google sheets document.')
+parser.add_argument('--cell', help='To collect the value of a cell.')
+parser.add_argument('--row', help='To collect the value of a row.',type=int)
+parser.add_argument('--column', help='To collect the value of a column.',type=int)
+parser.add_argument('--sheet', help='To indicate the name of the document sheet, put it in quotation marks and count spaces and capital letters.',type=str)
args = parser.parse_args()
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
-creds = ServiceAccountCredentials.from_json_keyfile_name(args.cred, scope)
+
+
+
+
+## authenticate with file json input
+if args.creds_json is not None and args.creds_base64 == None:
+ creds = ServiceAccountCredentials.from_json_keyfile_name(args.creds_json, scope)
+## authenticate with base64 input
+elif args.creds_base64 is not None and args.creds_json== None:
+ ## base64 to json
+ text=base64.b64decode(args.creds_base64).decode('utf-8')
+ with open("cred.json", "w") as outfile:
+ outfile.write(text)
+ creds = ServiceAccountCredentials.from_json_keyfile_name("cred.json", scope)
+ remove("cred.json")
+else:
+ print("You need to use the --creds_json or creds_base 64 parameter to authenticate. You can only select one.")
+ sys.exit()
client = gspread.authorize(creds)
-sheet = client.open(args.name).sheet1 # Open the spreadhseet
+sheet = client.open(args.name) # Open the spreadhseet
+worksheet = sheet.worksheet(args.sheet) # Open worksheet
-data = sheet.get_all_records() # Get a list of all records
+if args.cell is not None and args.row==None and args.column==None :
-if args.row is not None and args.column==None:
- row = sheet.row_values(args.row) # Get a specific row
- print(row)
-elif args.row ==None and args.column is not None:
- col = sheet.col_values(args.column) # Get a specific column
- print(col)
-elif args.row is not None and args.column is not None:
- cell = sheet.cell(args.row,args.column).value # Get the value of a specific cell
- print(cell)
+ val = worksheet.acell(args.cell).value
+
+elif args.row is not None and args.column==None and args.cell == None:
+
+ val = worksheet.row_values(args.row) # Get a specific row
+
+elif args.column is not None and args.row== None and args.cell == None:
+
+ val = worksheet.col_values(args.column) # Get a specific column
+
+else:
+ print("To search for data in a cell use the --cell parameter, for data in a column --column and in a row --row, only one of these parameters can be used at a time.")
+ sys.exit()
+
+
+print(val)
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 81cbc66539..a4c5ada50d 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-server
-Version: 7.0NG.769-230222
+Version: 7.0NG.769-230227
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index c32145973e..d3ca335b86 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.769-230222"
+pandora_version="7.0NG.769-230227"
package_cpan=0
package_pandora=1
diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server
index 957d2d8f42..c6b1fc15bb 100755
--- a/pandora_server/bin/pandora_server
+++ b/pandora_server/bin/pandora_server
@@ -42,9 +42,6 @@ use PandoraFMS::PredictionServer;
use PandoraFMS::WebServer;
use PandoraFMS::InventoryServer;
-# Constants for Win32 services.
-use constant WIN32_SERVICE_STOPPED => 0x01;
-use constant WIN32_SERVICE_RUNNING => 0x04;
# Global vars
my %Config :shared;
@@ -255,7 +252,6 @@ sub pandora_crash () {
print_message (\%Config, " Error description:\n", 0);
print_message (\%Config, $full_error, 0);
- callback_stop() if ($^O eq 'MSWin32' && defined($Config{'win32_service'}));
}
########################################################################################
@@ -510,135 +506,6 @@ sub pandora_server_tasks ($) {
db_disconnect($dbh);
}
-################################################################################
-## Install the Windows service.
-################################################################################
-sub win32_install_service() {
-
- # Load Win32::Daemon.
- eval "use Win32::Daemon";
- die($@) if ($@);
-
- # Configure and install the service.
- my $service_path = $0;
- my $service_params = "-S run \"" . $Config{'pandora_path'} ."\"";
- my %service_hash = (
- machine => '',
- name => 'PANDORAFMSSRV',
- display => 'Pandora FMS Server',
- path => $service_path,
- user => '',
- pwd => '',
- description => 'Pandora FMS Server http://pandorafms.com/',
- parameters => $service_params
- );
-
- if (Win32::Daemon::CreateService(\%service_hash)) {
- print "Successfully added.\n";
- exit 0;
- } else {
- print "Failed to add service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
- exit 1;
- }
-}
-
-################################################################################
-## Install the Windows service.
-################################################################################
-sub win32_uninstall_service() {
-
- # Load Win32::Daemon.
- eval "use Win32::Daemon";
- die($@) if ($@);
-
- # Uninstall the service.
- if (Win32::Daemon::DeleteService('', 'PANDORAFMSSRV')) {
- print "Successfully deleted.\n";
- exit 0;
- } else {
- print "Failed to delete service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
- exit 1;
- }
-}
-
-################################################################################
-## Windows service callback function for the running event.
-################################################################################
-sub callback_running {
- if (Win32::Daemon::State() == WIN32_SERVICE_RUNNING) {
- }
-}
-
-################################################################################
-## Windows service callback function for the start event.
-################################################################################
-sub callback_start {
- no strict;
-
- # Accept_connections ();
- my $thr = threads->create(\&main);
- if (!defined($thr)) {
- Win32::Daemon::State(WIN32_SERVICE_STOPPED);
- Win32::Daemon::StopService();
- return;
- }
- $thr->detach();
-
- Win32::Daemon::State(WIN32_SERVICE_RUNNING);
-}
-
-################################################################################
-## Windows service callback function for the stop event.
-################################################################################
-sub callback_stop {
-
- $RUN = 0;
- Win32::Daemon::State(WIN32_SERVICE_STOPPED);
- Win32::Daemon::StopService();
-}
-
-################################################################################
-# Run as a Windows service.
-################################################################################
-sub win32_service_run() {
-
- # Load Win32::Daemon.
- eval "use Win32::Daemon";
- die($@) if ($@);
-
- # Run the Pandora FMS Server as a Windows service.
- Win32::Daemon::RegisterCallbacks({
- start => \&callback_start,
- running => \&callback_running,
- stop => \&callback_stop,
- });
- Win32::Daemon::StartService();
-}
-
-################################################################################
-## Parse command line options.
-################################################################################
-sub parse_service_options ($) {
- my $config = shift;
-
- # Sanity checks.
- return unless defined($config->{'win32_service'});
- die ("[ERROR] Windows services are only available on Win32.\n\n") if ($^O ne 'MSWin32');
-
- # Win32 service management.
- eval "use Win32::Daemon";
- die($@) if ($@);
-
- if ($config->{'win32_service'} eq 'install') {
- win32_install_service();
- } elsif ($config->{'win32_service'} eq 'uninstall') {
- win32_uninstall_service();
- } elsif ($config->{'win32_service'} eq 'run') {
- } else {
- die("[ERROR] Unknown action: " . $config->{'win32_service'});
- }
-}
-
################################################################
################################################################
## Main.
@@ -967,17 +834,9 @@ $SIG{'ALRM'} = 'IGNORE';
pandora_init(\%Config, pandora_get_initial_product_name() . ' Server');
pandora_load_config (\%Config);
-# Parse command line options.
-parse_service_options(\%Config);
# Run as a regular process.
-if (!defined($Config{'win32_service'})) {
- main();
-}
-# Run as a Windows service.
-else {
- win32_service_run();
-}
+main();
################################################################################
# Kill any scripts started by the Pandora FMS Server that are still running.
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 50401be6ee..d6234bf2b6 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.769";
-my $pandora_build = "230222";
+my $pandora_build = "230227";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash
@@ -64,7 +64,6 @@ sub help_screen {
print " -d : Debug mode activated. Writes extensive information in the logfile \n";
print " -D : Daemon mode (runs in background)\n";
print " -P : Store PID to file.\n";
- print " -S : Manage the win32 service.\n";
print " -h : This screen. Shows a little help screen \n";
print " \n";
exit;
@@ -111,9 +110,6 @@ sub pandora_init {
elsif ($parametro =~ m/-D\z/) {
$pa_config->{"daemon"}=1;
}
- elsif ($parametro =~ m/^-S\z/i) {
- $pa_config->{'win32_service'}= clean_blank($ARGV[$ax+1]);
- }
else {
($pa_config->{"pandora_path"} = $parametro);
}
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index b6f2a8b940..0faecb33d3 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.769";
-my $pandora_build = "230222";
+my $pandora_build = "230227";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 11f52f0cc9..f93bb611ad 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.769
-%define release 230222
+%define release 230227
Summary: Pandora FMS Server
Name: %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index e97a126961..46c861f6bd 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.769
-%define release 230222
+%define release 230227
Summary: Pandora FMS Server
Name: %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index a2864c992f..5420293644 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.769"
-PI_BUILD="230222"
+PI_BUILD="230227"
MODE=$1
if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index cd6b6075aa..05f8f8e7d5 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
-my $version = "7.0NG.769 Build 230222";
+my $version = "7.0NG.769 Build 230227";
# Pandora server configuration
my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 2aa01fdd62..0c9c3aa929 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
-my $version = "7.0NG.769 Build 230222";
+my $version = "7.0NG.769 Build 230227";
# save program name for logging
my $progname = basename($0);