hvisage / metalog

metalog is a syslog replacement that allows regular expresion matching
GNU General Public License v2.0
36 stars 11 forks source link

consolelog broken #19

Closed Massimo-B closed 1 year ago

Massimo-B commented 1 year ago

Something is broken since I enabled consolelog. I found some / subdirs now with weird namings

drwx------   1 root root   34 13. Feb 08:41 ''$'\360''!'$'\220''1'$'\324\177'/
drwx------   1 root root   34 13. Feb 13:28 ''$'\300''!'$'\220''1'$'\324\177'/
drwx------   1 root root   34  8. Feb 10:14 ''$'\300\361''#3M'$'\177'/
drwx------   1 root root   34 10. Feb 07:38 ''$'\360''!~5'$'\264\177'/
drwx------   1 root root   34 10. Feb 08:13 ''$'\300''!~5'$'\264\177'/

containing files .timestamp and current with the log entries in current.

Enabled in /etc/metalog.conf as most early block:

console logging :

     facility  = "*"
     command   = "/sbin/consolelog.sh"
# grep -v "^#" /etc/conf.d/metalog 
METALOG_OPTS="-s"
CONSOLE="/dev/tty11"
FORMAT='$1 [$2] $3'
# cat /etc/gentoo-release 
Gentoo Base System release 2.9
# eix metalog -Ic
[I] app-admin/metalog (20220214@25.04.2022): A highly configurable replacement for syslogd/klogd
LoneFox78 commented 1 year ago

I had same issue when I tried to update pcre2 to 10.41 or 10.42, reverting it back to 10.40 solved the problem.

Massimo-B commented 1 year ago

Thanks, I masked 10.42 and downgraded to 10.40. I'm not sure how to reproduce the issue, watching if it happens again in the next days. I would like to file the issue on https://github.com/PCRE2Project/pcre2/issues but I can't actually describe the bug against the library. Is this bug already known and filed there?

LoneFox78 commented 1 year ago

I think I've found the problem. Metalog is not initializing the directory name pointer for consolelog entries. I guess malloc() is giving it memory that was used by pcre earlier in the program and by change always contained zeroes with the old versions of the library, but not anymore in 10.41.

Here is the fix:

diff -bur metalog-metalog-20220214-orig/src/metalog.c metalog-metalog-20220214/src/metalog.c
--- metalog-metalog-20220214-orig/src/metalog.c 2022-02-13 17:03:27.000000000 +0200
+++ metalog-metalog-20220214/src/metalog.c      2023-03-09 13:27:17.000000000 +0200
@@ -212,8 +212,10 @@
             }
             if (strcasecmp(value, "NONE") != 0)
                 new_output->directory = logdir;
-            else
+            else {
                 free(logdir);
+                new_output->directory = NULL;
+            }
             new_output->fp = NULL;
             new_output->perms = (*cur_block)->perms;
             new_output->size = (off_t) 0;
m-kress commented 1 year ago

@LoneFox78: Thank you for finding and fixing this!

Massimo-B commented 1 year ago

How can I see which release does include this bugfix?

auouymous commented 1 year ago

@Massimo-B It is fixed in the last two releases: 20230707 and 20230719.