Skip to content

Commit

Permalink
Merge pull request #451 from ArnoStiefvater/fix-logging
Browse files Browse the repository at this point in the history
Fix log file check
  • Loading branch information
bjoernricks authored Mar 8, 2021
2 parents a0ebd75 + 0b9e27f commit d60bfe3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Continuously send dead hosts to ospd-openvas to enable a smooth progress bar if only ICMP is chosen as alive test. [#389](https://github.com/greenbone/gvm-libs/pull/389)
- Retry if response via tls1.3 is still not received. [#394](https://github.com/greenbone/gvm-libs/pull/394)
- Replace current implementation of alive test arp ping with version using libnet. [#423](https://github.com/greenbone/gvm-libs/pull/423)
- Let setup_log_handlers return an error if it does not have write access to some log file or log dir instead of aborting immediately. [#447](https://github.com/greenbone/gvm-libs/pull/447)
- Let setup_log_handlers return an error if it does not have write access to some log file or log dir instead of aborting immediately.
[#447](https://github.com/greenbone/gvm-libs/pull/447)
[#451](https://github.com/greenbone/gvm-libs/pull/451)

### Removed
- Remove handling of severity class from auth [#402](https://github.com/greenbone/gvm-libs/pull/402)
Expand Down
15 changes: 12 additions & 3 deletions base/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,8 @@ log_func_for_gnutls (int level, const char *message)
/**
* @brief Check permissions of log file and log file directory.
*
* Do not check permissions if log file is syslog or empty string.
*
* @param log_domain_entry Log domain entry.
*
* @return 0 on success, -1 on error.
Expand All @@ -758,11 +760,18 @@ check_log_file (gvm_logging_t *log_domain_entry)
if (log_domain_entry->log_file)
log_file = log_domain_entry->log_file;

// No log file was specified or log file is empty in the openvas_log.conf.
// stderr will be used as default later on. See gvm_log_func.
if (!log_file)
return -1;
else
channel = g_io_channel_new_file (log_file, "a", &error);
return 0;
if (!g_strcmp0 (log_file, ""))
return 0;

// If syslog is used we do not need to check the log file permissions.
if (g_ascii_strcasecmp (log_file, "syslog") == 0)
return 0;

channel = g_io_channel_new_file (log_file, "a", &error);
if (!channel)
{
gchar *log = g_strdup (log_file);
Expand Down

0 comments on commit d60bfe3

Please sign in to comment.