Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a method to set up an upstart script to execute a user-space program without keeping root privileges, but so the user which has directory/permissions-based ownership of the program can stop/start while still having the program start at boot time?

share|improve this question
    
Also, if anyone can point me to examples of upstart scripts that'd be awesome –  Thomas W. Jun 1 '12 at 19:25
add comment

2 Answers 2

Yes, with sudo:

sudo -u lordoftime program

-u + username start the program as that user.

share|improve this answer
1  
Will this also use user-space environment stuff, such as ~/.progfolder/? –  Thomas W. Jun 1 '12 at 19:17
    
@LordofTime: As far as I read in the man page, you can use -H to set the home, and -i to start the loginshell of the user, thereby reading some configuration files. There are multiple blocks in the manpage refering to ENV, I don't like to cite complete. Read it up yourself, try it out and tell us, if you experience further problems. –  user unknown Jun 1 '12 at 20:00
add comment

Problem using su trick with system jobs the user has no control over that job. It is still a system job, despite running as given user.

Proper solution in 12.04 is using user jobs. Those jobs live in each user's $HOME/.init and are fully controllable by that user. They also do not have root powers as user job is always run as that user's credentials. Otherwise they act just as system jobs, so you can define start onstanzas just like system jobs.

By default, Upstart jobs have no environment set except what is defined in the job. You can circumvent that by exec'ing via sh -l (exec /bin/sh -l -c "exec YOUR STUFF HERE").

share|improve this answer
    
Does this work with 11.04, the system which this is going to be in use on? –  Thomas W. Jun 6 '12 at 12:49
    
See Cookbook about enabling user jobs in prior to 12.04: upstart.ubuntu.com/cookbook/#id95 Then it should work (0.9.7 in 11.04 is about the same as 1.3 in upstream). –  Tuminoid Jun 7 '12 at 5:44
add comment

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.