Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gorgone/gorgone/class/script.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ sub init {
$self->{logger}->file_mode($self->{log_file});
}
$self->{logger}->flush_output(enabled => $self->{flushoutput});
if ($self->{severity} =~ /debug/i && $ENV{ALLOW_PASSWORD_IN_LOG} ){
# debug logs should not show password, you can enable "trace" level with all logs by adding the env variable ALLOW_PASSWORD_IN_LOG=1
$self->{severity} = 8;
}
$self->{logger}->severity($self->{severity});
$self->{logger}->force_default_severity();

Expand Down
6 changes: 6 additions & 0 deletions gorgone/packaging/scripts/centreon-gorgone-postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ startGorgoned() {
systemctl restart gorgoned.service ||:
}

# Change the gorgone default log file to be 640, it was 644 before.
# New gorgone version create it as 640 but do not change existing log file.
if [[ -e /var/log/centreon-gorgone/gorgoned.log ]] ; then
chmod 640 /var/log/centreon-gorgone/gorgoned.log
fi

action="$1"
if [ "$1" = "configure" ] && [ -z "$2" ]; then
# Alpine linux does not pass args, and deb passes $1=configure
Expand Down
13 changes: 12 additions & 1 deletion perl-libs/lib/centreon/common/logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ my %human_severities = (
4 => 'WARNING',
5 => 'NOTICE',
6 => 'INFO',
7 => 'DEBUG'
7 => 'DEBUG',
8 => 'TRACE'
);

sub new {
Expand Down Expand Up @@ -103,12 +104,16 @@ sub file_mode($$) {
if (defined($self->{filehandler})) {
$self->{filehandler}->close();
}
# Use umask to set the file permissions to 0640 and reset it right after to avoid changing other code area.
my $old_umask = umask(0027);
if (open($self->{filehandler}, ">>", $file)){
umask($old_umask);
$self->{log_mode} = 1;
$self->{filehandler}->autoflush(1);
$self->{file_name} = $file;
return 1;
}
umask($old_umask);
$self->{filehandler} = undef;
print STDERR "Cannot open file $file: $!\n";
return 0;
Expand Down Expand Up @@ -192,6 +197,8 @@ sub severity {
$self->{severity} = 6;
} elsif ($input_severity eq "debug") {
$self->{severity} = 7;
}elsif ($input_severity eq "trace") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}elsif ($input_severity eq "trace") {
} elsif ($input_severity eq "trace") {

$self->{severity} = 8;
} else {
$self->writeLogError("Wrong severity value set.");
return -1;
Expand Down Expand Up @@ -254,6 +261,10 @@ sub writeLog($$$%) {
}
}

sub writeLogTrace {
shift->writeLog(8, @_);
}

sub writeLogDebug {
shift->writeLog(7, @_);
}
Expand Down
Loading