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

Outchannel parsing is not working #5047

Open
yishai1999 opened this issue Dec 22, 2022 · 8 comments · May be fixed by #5056
Open

Outchannel parsing is not working #5047

yishai1999 opened this issue Dec 22, 2022 · 8 comments · May be fixed by #5056

Comments

@yishai1999
Copy link

Hi!
I'm trying to configure log rotation but facing some problems.

My rsyslog.conf file looks like this:

$outchannel logrotation,/var/log/syslog,1048576,/etc/rotate_logs.sh
*.* :omfile:$logrotation

Then I run rsyslog in debug mode and I expect the debug logs to be something like this:

Outchannel: Name='logrotation'
File Template: '/var/log/syslog'
Max Size.....: 1048576
OnSizeLimtCmd: '/etc/rotate_logs.sh

But what I see is:

Outchannel: Name='logrotation'
File Template: '/var/log/syslog'
Max Size.....: 0
OnSizeLimtCmd: '1048576,/etc/rotate_logs.sh

When trying to add more debug prints in the source code around the parsing of the configuration file, somehow the problem is solved, and then when I remove them the problem comes back.
I tried changing the conf file by adding spaces between commas, changing the max size, changing the command - nothing helped

I found someone who wrote about the same issue 12 years ago but no one gave him an answer: https://rsyslog.adiscon.narkive.com/2Vu9McFr/outchannel-is-not-working#post1

My environment:

  • rsyslog version: 8.2206.0
  • platform: Custom Yocto distribution (kirkstone)
  • gcc 11
  • armv7
@davidelang
Copy link
Contributor

davidelang commented Dec 23, 2022 via email

@yishai1999
Copy link
Author

yishai1999 commented Dec 26, 2022

Hey @davidelang ,
The official documentation does it this way...
https://www.rsyslog.com/doc/master/tutorials/log_rotation_fix_size.html

@TomerBG2
Copy link

This problem happened to me to! Any updates?

@SchorppDA
Copy link

Hi,
I too have run into this problem.
Also with me it occurred with the upgrade to yocto release kirkstone.
Since the code in outchannel.c were not touched for a while, I had current the suspicion that possibly the behavior in the interaction with a standard function has changed (isspace in skip_Comma maybe).
That debug outputs change the behavior is quite strange.
@yishai1999 can you provide the diff of your debug code changes? Or have you already got further?

@yishai1999
Copy link
Author

Hi,

Here's the diff:

--- 
  outchannel.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/outchannel.c b/outchannel.c
index 2f456b5..e785dd7
--- a/outchannel.c
+++ b/outchannel.c
@@ -74,6 +74,7 @@ static void skip_Comma(char **pp)
    assert(pp != NULL);
    assert(*pp != NULL);

+   dbgprintf("this fixes everything\n");
    p = *pp
    while(isspace((int)*p))
        ++p;

Since the print fixes the problem I assume the problem has something to do with time/synchronization.
Sadly, I haven't understood anything more than that though.

@SchorppDA
Copy link

@yishai1999 a time/synchronization problem would be very weird.
Since we both have the Problem and the similarity is the yocto in the kirkstone release, I rather suspect some kind of compiler effect.
I can also confirm your observation with the debug print in skip_Comma.
As far as I can tell, the skip_Comma function is not applied (for whatever reason).
While analyzing, I noticed that only for the skip_Comma a type cast from uchar to char is done. I have test times then removed the type cast and then the code works again.
See in branch in my fork
Based on this knowledge I would now suspect an effect in the context of the compiler and char, but have found nothing to that effect so far.

Since this change should be free of influence, it would be possible to make this as a pull request for this issue.

@yishai1999
Copy link
Author

yishai1999 commented Jan 3, 2023

@SchorppDA Very very strange stuff. Your change looks good to me. Go ahead an open a pull request! If you rather I open it let me know.

@rgerhards
Copy link
Member

FYI: new style alternative coming up: #5063

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants