Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What's the best way to allow an unprivileged user to control an upstart job?

By controlling an upstart job I mean starting/stopping/reloading/restarting it:

start myservice 

I can imagine one way to go about it is through sudo; what needs to be done to make this possible? Are there other/better ways?

NB: This question, while similarly named, is very different from Running upstart jobs as unprivileged users, as that one deals with the execution of the actual service instead of the controlling of the job.

share|improve this question
    
This can be interesting for you: bradleyayers.blogspot.com/2011/10/… –  user121825 Mar 7 '12 at 14:54

2 Answers 2

In addition to what Tuminoid said, you can actually limit sudo to commands with concrete arguments:

Cmnd_Alias START_MYSQL = /sbin/start mysql
user ALL=(ALL) NOPASSWD: START_MYSQL

With the above two lines in sudoers (you can edit the suoders with visudo command), user account named user will be able to run without password:

$ sudo start mysql

sudo will not be available to the user for anything else, though, with or without password, unless there are other entries in sudoers list that permit it.

share|improve this answer

You certainly can control the jobs with sudo. You don't need anything special, just sudo start myservice etc. It is the preferred way if you have sudo rights.

Beyond that, you need some mapper running as root to convert your user privileged commands into root commands. I've once done this for a special purpose with a FIFO, that is writeable by user, read by an root privileged upstart script which then maps the commands into start, stop and so on. Certainly not a secure way to do it for a multi-user/production systems.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.