Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a user who is getting this problem:

Sorry, user myuser is not allowed to execute '/bin/cp /tmp/tempfile /applications/tomcat/instance/webapps/' as tomcat on myserver.on.our.network.

When running the following command:

sudo -u tomcat cp /tmp/tempfile /applications/tomcat/instance/webapps/

What change should I make (I assume with visudo) to allow the user to execute /bin/cp as the tomcat user? The user is a member of the tomcat group.

Thanks in advance

Rich

share|improve this question

2 Answers 2

up vote 4 down vote accepted
myuser        ALL = (tomcat) /bin/cp

is about as simple as it gets. you can allow all members of the tomcat group to do it by putting

%tomcat       ALL = (tomcat) /bin/cp

That ALL there refers to the host in question; if you use this sudoers file on more than one host, it would be inappropriate, but if this sudoers file is particular to this host, it's safe enough and avoids issues with what the machine thinks its hostname is.

share|improve this answer

What are the rights and owner in /tmp/tempfile file ? You should have the right to modify a non by me created file (due to /tmp restrictions)

share|improve this answer
    
Forgive me, Dom, but I think you may be misreading the question. Even if sudo was letting him run the command, the file in /tmp/ is the source file of the copy, not the destination; the destination's in /applications/tomcat, and it seems sensible to me that only tomcat can write into that. –  MadHatter Oct 26 '10 at 15:00
    
Right, I re-read the question two times, and my answer is bad. Thanks to point it. –  Dom Oct 27 '10 at 6:47

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.