Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Sudo cd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
HailandKill
n00b
n00b


Joined: 25 Nov 2006
Posts: 8

PostPosted: Sun Oct 07, 2007 11:56 am    Post subject: Sudo cd Reply with quote

None of my sudo users, including root itself, can # sudo cd [path]

so.. use cd.

I'm not a brilliant linux administrator, so I'm not too sure what the problem is or how to rectify it!
Back to top
View user's profile Send private message
tobr
Guru
Guru


Joined: 29 May 2006
Posts: 330

PostPosted: Sun Oct 07, 2007 12:03 pm    Post subject: Reply with quote

That's because cd is not an executable (try which cd) but a shell built-in. It also only sets the current dir for the running shell so it makes no sense to cd with sudo as that change would be lost after sudo executation. What do you want to do?
_________________
Please add [SOLVED] to your message title if your problem is solved.

Death to all blobs!
Back to top
View user's profile Send private message
HailandKill
n00b
n00b


Joined: 25 Nov 2006
Posts: 8

PostPosted: Sun Oct 07, 2007 12:31 pm    Post subject: Reply with quote

I'm setting up a system by which users other than root can deploy ruby on rails apps to my web server using capistrano. Getting sudo cd to work was perhaps me going off on a tangent.

On the local machine I run # cap cold:deploy which does everything well untill

Code:

Sorry, user yumc is not allowed to execute '/bin/sh -c cd /var/www/localhost/htdocs/yumc/current && nohup script/spin' as yumc on goldx.
    command finished
command "sudo -u yumc sh -c 'cd /var/www/localhost/htdocs/yumc/current && nohup script/spin'" failed on www.yumc.co.uk


At the moment though, just tot try and get this working the sudoers file reads:

yumc ALL=ALL

So I'm a bit confused.

Here is my sudoers file http://rafb.net/p/J12JBI43.html
Back to top
View user's profile Send private message
tobr
Guru
Guru


Joined: 29 May 2006
Posts: 330

PostPosted: Sun Oct 07, 2007 12:46 pm    Post subject: Reply with quote

The command sudo -u yumc sh -c 'cd /var/www/localhost/htdocs/yumc/current && nohup script/spin' looks suspicious: What you probably wanted to do was execute sh -c 'cd /var/www/localhost/htdocs/yumc/current && nohup script/spin' as yumc. But -c is an option to both sh and sudo so it is possible that sudo gets confused. What I would do (if this is possible) is to cd before sudo. Or try to change the line to sudo -u yumc "sh -c 'cd /var/www/localhost/htdocs/yumc/current && nohup script/spin'".

Another possibility: Have you tried to replace yumc ALL=ALL with yumc ALL=NOPASSWD:ALL? It could be that if sudo is called from a script that you never see the password prompt and it fails because it demanded password authentication.

Note: if you give yumc the right to do everything with sudo, it doesn't make much sense to do it as yumc instead of root in the first place (at least security-wise). Why don't you try to change the permissions of the directories you want the users to put their Rails stuff into? (I don't know anything about Rails and haven't the slightest idea what "capistrano" is, so I can't help you with the specifics)
_________________
Please add [SOLVED] to your message title if your problem is solved.

Death to all blobs!
Back to top
View user's profile Send private message
HailandKill
n00b
n00b


Joined: 25 Nov 2006
Posts: 8

PostPosted: Sun Oct 07, 2007 12:58 pm    Post subject: Reply with quote

The only reason I've got ALL at the moment is just to try and get the damn thing working in the first place. :)

I will try your other suggestions though, thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum