Don't warn about missing 'type' if the locking fails

and stop warning about corrupted mandatory files

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
This commit is contained in:
Matej Habrnal 2015-08-14 09:48:40 +02:00
parent 80acf9fdce
commit 042ef11f33
3 changed files with 131 additions and 1 deletions

View File

@ -0,0 +1,82 @@
From 63a7dba681c148603c9606e9f841fdecc4e5b549 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 4 Aug 2015 19:18:38 +0200
Subject: [PATCH] dd: stop warning about corrupted mandatory files
These messages are printed by abrtd to syslog when it finds a dump
directory with such files. Unfortunately, abrtd prints out these
messages too often and users do not know how to get rid of them because
they make sense only to us (ABRT devels). Moreover, these messages are
not necessary because abrtd follows them with
"$PATH is not a valid problem directory" message. So admins are notified
about strange problem directories and they can remove them.
The messages were accidentally turned on by me in these commits:
8f9fa454bd8c653758cddf07597f0a5a17ff5793
b9e7fb2ac2ea3064dc73dab26f80beab100af65f
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/lib/dump_dir.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index 66e2569..aed7a15 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -218,7 +218,7 @@ static int read_number_from_file_at(int dir_fd, const char *filename, const char
const int fd = secure_openat_read(dir_fd, filename);
if (fd < 0)
{
- log_warning("Can't open '%s'", filename);
+ log_info("Can't open '%s'", filename);
return fd;
}
@@ -235,14 +235,14 @@ static int read_number_from_file_at(int dir_fd, const char *filename, const char
if (value_buf == NULL)
{
- log_warning("Can't read from '%s'", filename);
+ log_info("Can't read from '%s'", filename);
ret = -EBADFD;
goto finito;
}
if (total_read >= max_size)
{
- log_warning("File '%s' is too long to be valid %s "
+ log_info("File '%s' is too long to be valid %s "
"(max size %u)", filename, typename, (int)sizeof(value_buf));
ret = -EMSGSIZE;
goto finito;
@@ -265,7 +265,7 @@ static int read_number_from_file_at(int dir_fd, const char *filename, const char
|| (*endptr != '\0')
|| endptr == value_buf
) {
- log_warning("File '%s' doesn't contain valid %s"
+ log_info("File '%s' doesn't contain valid %s"
"('%s')", filename, typename, value_buf);
ret = -EINVAL;
goto finito;
@@ -276,7 +276,7 @@ static int read_number_from_file_at(int dir_fd, const char *filename, const char
*/
if (res <= min || res >= max)
{
- log_warning("File '%s' contains a number out-of-range of %s"
+ log_info("File '%s' contains a number out-of-range of %s"
"('%s')", filename, typename, value_buf);
ret = -ERANGE;
goto finito;
@@ -441,7 +441,7 @@ static int dd_lock(struct dump_dir *dd, unsigned sleep_usec, int flags)
if (dd->owns_lock)
xunlinkat(dd->dd_fd, ".lock", /*only files*/0);
- log_warning("Unlocked '%s' (no or corrupted '%s' file)", dd->dd_dirname, missing_file);
+ log_notice("Unlocked '%s' (no or corrupted '%s' file)", dd->dd_dirname, missing_file);
if (--count == 0 || flags & DD_DONT_WAIT_FOR_LOCK)
{
errno = EISDIR; /* "this is an ordinary dir, not dump dir" */
--
2.4.3

View File

@ -0,0 +1,42 @@
From eb38c73cc3aa81884e74718c6d7f412ea7a94f6f Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 4 Aug 2015 19:35:48 +0200
Subject: [PATCH] dd: don't warn about missing 'type' if the locking fails
The warning is printed out at least 10 times and makes only a little
sense to system administrators. abrtd follows those warnings with
"$path is not a valid problem directory" message which is a sufficient
way to tell the administrators to remove that directory.
Related: rhbz#1243280
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/lib/dump_dir.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index aed7a15..2399ca1 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -384,7 +384,16 @@ static const char *dd_check(struct dump_dir *dd)
return FILENAME_TIME;
}
- dd->dd_type = load_text_file_at(dd->dd_fd, FILENAME_TYPE, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
+ /* Do not warn about missing 'type' file in non-verbose modes.
+ *
+ * Handling of FILENAME_TYPE should be consistent with handling of
+ * FILENAME_TIME in the function parse_time_file_at() where the missing
+ * file message is printed by log_info() (in a verbose mode).
+ */
+ int load_flags = DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE;
+ if (g_verbose < 2) load_flags |= DD_FAIL_QUIETLY_ENOENT;
+
+ dd->dd_type = load_text_file_at(dd->dd_fd, FILENAME_TYPE, load_flags);
if (!dd->dd_type || (strlen(dd->dd_type) == 0))
{
log_debug("Missing or empty file: "FILENAME_TYPE);
--
2.4.3

View File

@ -7,7 +7,7 @@
Summary: Generic library for reporting various problems Summary: Generic library for reporting various problems
Name: libreport Name: libreport
Version: 2.6.2 Version: 2.6.2
Release: 2%{?dist} Release: 3%{?dist}
License: GPLv2+ License: GPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
URL: https://abrt.readthedocs.org/ URL: https://abrt.readthedocs.org/
@ -17,6 +17,8 @@ Source1: autogen.sh
# git format-patch %%{Version} -N -M --topo-order # git format-patch %%{Version} -N -M --topo-order
# i=0; for p in `ls 0*.patch`; do printf "Patch%04d: %s\n" $i $p; ((i++)); done # i=0; for p in `ls 0*.patch`; do printf "Patch%04d: %s\n" $i $p; ((i++)); done
Patch0001: 0001-Use-a-dgettext-function-returning-strings-instead-of.patch Patch0001: 0001-Use-a-dgettext-function-returning-strings-instead-of.patch
Patch0002: 0002-dd-stop-warning-about-corrupted-mandatory-files.patch
Patch0003: 0003-dd-don-t-warn-about-missing-type-if-the-locking-fail.patch
# git is need for '%%autosetup -S git' which automatically applies all the # git is need for '%%autosetup -S git' which automatically applies all the
# patches above. Please, be aware that the patches must be generated # patches above. Please, be aware that the patches must be generated
@ -733,6 +735,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog %changelog
* Fri Aug 14 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-3
- don't warn about missing 'type' if the locking fails
- stop warning about corrupted mandatory files
* Wed Jul 22 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-2 * Wed Jul 22 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-2
- Use a dgettext function returning strings instead of bytes - Use a dgettext function returning strings instead of bytes