Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 454914

Summary: sys-apps/openrc: Feature Request: Open logfile before chuid option
Product: Gentoo Hosted Projects Reporter: Cameron Tacklind <cameron>
Component: OpenRCAssignee: OpenRC Team <openrc>
Status: UNCONFIRMED ---    
Severity: enhancement    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Patch allowing opening of stdout/stderr files before chuid

Description Cameron Tacklind 2013-01-31 23:56:37 UTC
Created attachment 337528 [details]
Patch allowing opening of stdout/stderr files before chuid

When using --user (and --group) options, start-stop-daemon opens the specified --pidfile (and creates it) BEFORE changing to specified user. This means the pidfile is owned by root, which is fine.

However, --stdout and --stderr get opened (and created) AFTER changing to the specified user. This means that extra commands are needed in init.d scripts (or done manually) to create and chown the log files.

Of course some users like this as log files are then owned by the same user as the daemon so we need to continue to support this.

I'm proposing a new start-stop-daemon flag called --rootlog (and associated --userlog which is the default so unnecessary) which opens the log files before the chuid.

I've written a quick patch attempting to kept the changes as minor as possible.

Putting the patch file in /etc/portage/patches/sys-apps/openrc/ works flawlessly.

Needed improvements:
 - Indenting of original section
 - Moving original section to a function so code is not repeated
 - Adding input sanity checks
   - Useless without --user
 - Other issues I forgot