Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 423139 - =app-admin/logrotate-3.8.1: Error creating new files after rotating
Summary: =app-admin/logrotate-3.8.1: Error creating new files after rotating
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal major (vote)
Assignee: Chema Alonso Josa (RETIRED)
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2012-06-23 13:11 UTC by Michael Morak
Modified: 2012-07-24 21:11 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed patch that creates temporary files in ' (logrotate-3.8.0-atomic-create.patch.patch,528 bytes, patch)
2012-06-23 13:15 UTC, Michael Morak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Morak 2012-06-23 13:11:48 UTC
When rotating any file in /var/log as per the configuration in /etc/logrotate.[conf|d], logrotate tries to create new temporary (see logrotate-3.8.0-atomic-create.patch) in /var/log. For me this results in the following error:

"error: error creating unique temp file: Bad address"

This is because the "open" function throws en error, setting errno of EFAULT, meaning that, according to "man 2 open", the pathname points outside your accessible address space.

I have created a patch for this, that creates the new files in /tmp and then moves them to the correct position.

Reproducible: Always

Steps to Reproduce:
1. Configure a file in /var/log to be rotated
2. Run logrotate -fv /etc/logrotate.conf
3. Cry.
Actual Results:  
Logrotate reports the error:

"error: error creating unique temp file: Bad address"

This is bad, because it has already moved the original files but not created the new ones, potentially breaking logging applications.

Expected Results:  
Correctly move the files, replace them with empty, new files.

I have SELinux running, however it is in permissive mode so it shoudn't cause any problems. But even if this is the culprit, this should be fixed. Creating temporary files in the /tmp folder seems sensible to me anyway.
Comment 1 Michael Morak 2012-06-23 13:15:27 UTC
Created attachment 316057 [details, diff]
Proposed patch that creates temporary files in '
Comment 2 Chema Alonso Josa (RETIRED) gentoo-dev 2012-07-06 12:25:36 UTC
Sorry for the delay. Very busy now. I'll take a closer look in the following days.

Thanks for reporting.
Comment 3 Chema Alonso Josa (RETIRED) gentoo-dev 2012-07-18 10:01:40 UTC
I've been unable to reproduce this problem in a permissive selinux machine. It rotates the logs here with no problem.

¿Can you post the output of logrotate -fv /etc/logrotate.conf to check if the fscreate security context is properly set before the temp file creation?

You should get in your log something like:

fscreate context set to system_u:object_r:unlabeled_t

right before the message "renamig /var/log/file.log to /var/log/file..."

Cheers.
Comment 4 Michael Morak 2012-07-24 00:28:38 UTC
I temporarily fixed the issue with my patch, which worked for my machine at the time. However, in order to give you your log output, I've updated and/or recompiled all the selinux libraries and logrotate from scratch and it now works perfectly. Dunno what caused the error in the first place, but at the time I could reproduce it every time I tried to run logrotate -f /etc/logrotate.conf.

Maybe some selinux functionality or something was not compiled correctly at the time, or broken after an emerge -DNu, but as the current stable version of selinux and logrotate work without a problem now, I'm marking this as RESOLVED-INVALID.

Thanks for your time though and sorry for apparently wasting it.
Comment 5 Chema Alonso Josa (RETIRED) gentoo-dev 2012-07-24 21:11:03 UTC
No problem. Glad it's working fine at your side :-)