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

Bug 310511

Summary: sys-apps/preload: init.d script is not POSIX shell compliant
Product: Gentoo Linux Reporter: Michał Górny <mgorny>
Component: New packagesAssignee: Pacho Ramos <pacho>
Status: RESOLVED FIXED    
Severity: normal CC: binki, esigra, qiaomuf
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 299140    
Bug Blocks:    
Attachments: patch for preload-0.64.init.in
New init.d script
Diff against the original script

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-21 10:31:01 UTC
The init.d script installed by sys-apps/preload is not compliant with POSIX shell and thus fails to run with OpenRC and non-bash default system shell.

This is because of using $(<...) to read files which (probably) has to be replaced by standard 'cat' call.

Moreover, the script lacks proper handling of exit codes. The start() function should save $? after calling ssd, and return it afterwards instead of returning ionice result, and the dump() one should either check exit codes of both 'kill' calls or neither.
Comment 1 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-03-28 04:08:45 UTC
I no longer use this application and have dropped maintainer-ship.
Comment 2 Mu Qiao (RETIRED) gentoo-dev 2010-08-25 10:49:28 UTC
Created attachment 244507 [details, diff]
patch for preload-0.64.init.in

I guess this could solve the problem. But for kill function, someone suggest use kill -[0-9] or -[A-Z] instead of the signal name. I'm not sure if this is true.
Comment 3 Pacho Ramos gentoo-dev 2010-09-06 15:29:55 UTC
Will look at it as soon as I have time to, thanks :-)

As a side note, if you have any idea about how to solve bug #299140 I will really appreciate it (if you don't know, no problem of course ;-))

Thanks a lot
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-06 15:56:38 UTC
(In reply to comment #3)
> As a side note, if you have any idea about how to solve bug #299140 I will
> really appreciate it (if you don't know, no problem of course ;-))

I'll try to prepare a combined patch in a while.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-06 16:41:11 UTC
Created attachment 246276 [details]
New init.d script

The script has been made POSIX compliant. The race condition related to ionice use has been fixed. Additional error handling has been added. Script and command definitions for OpenRC have been added.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-06 16:41:56 UTC
Created attachment 246277 [details, diff]
Diff against the original script
Comment 7 William Hubbs gentoo-dev 2010-09-06 20:42:59 UTC
Packages with non-posix init scripts need to be fixed; however, this is not a blocker for openrc stabilization.
Comment 8 Pacho Ramos gentoo-dev 2010-09-07 12:11:27 UTC
+*preload-0.6.4-r2 (07 Sep 2010)
+
+  07 Sep 2010; Pacho Ramos <pacho@gentoo.org> +preload-0.6.4-r2.ebuild,
+  +files/preload-0.6.4.init.in-r1:
+  Revision bump to fix race condition (bug #299140 by Ambroz Bizjak) and
+  make it POSIX compliant (bug #310511 by Michał Górny), thanks a lot to
+  Michał for providing the new init.d script.