setuid, pre-start and stop

Steve Langasek steve.langasek at canonical.com
Sat Feb 1 21:17:20 UTC 2014


Hi Stuart,

On Fri, Jan 31, 2014 at 05:38:42PM -0800, Stuart Knightley wrote:

> I have an upstart script with setuid, and a pre-start script that I wish
> to call `stop` in.  However the user I've changed to does not have
> permission to call stop.  I realise that I can exit with a non-zero status
> but the previous thread on this mailing list indicates this is not best
> practice.

> Does anyone have any suggestions? 

In general, anything you can do in a {pre,post}-{start,stop} script, you can
also do in a separate job with a 'start on {start,stopp}{ed,ing}' rule.  And
in a case such as this where you are running the main job under some sort of
access controls, this is what you need to do.

Something like the following should work:

start on starting main_job
script
    if $condition; then
        stop main_job
    fi
end script

Hope that helps,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/upstart-devel/attachments/20140201/c6b416d9/attachment.pgp>


More information about the upstart-devel mailing list