Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log file check #451

Merged
merged 2 commits into from
Mar 8, 2021
Merged
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: 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