|
From: | RS |
Subject: | Re: [Fab-user] Using su on boxes without sudo |
Date: | Fri, 7 Dec 2012 11:23:46 -0800 |
Thanks for the reply,
I've tried using both with prefix(su...) and writing a wrapper implemented as the following:
def _su(pwd, user, cmd):
with settings(password= "%s" % pwd, sudo_prefix="su %s -c " % user, sudo_prompt=" Password:"):
sudo(cmd)
The problem with using with prefix(su...) is it gives me an interactive prompt. Using the wrapper (shamelessly stolen from a stackoverflow answer on the subject), it fails to successfully login, giving me:
out: Password:
out: su: Sorry
Pwd is getting passed in from an execute(_su, pwd, cmd), all of which appears to work properly. My guess from reading through the fabric sudo code and its comments is that it still tries to use sudo, which doesn't exist on these boxes, but I may be misunderstanding how it's written.
I have also attempted to use fexpect, which another person running into this kind of problem created, but that appears to break fabric functionality.
As a last ditch I've thought about writing a pexpect wrapper for this, but that's all sorts of ugly.
Do you have any thoughts? I've read through the fabric operations module and state to try to trace how I could make something work, but haven't gotten a working solution yet (something that allows me to switch to root, executes the command automatically as root, and does not switch to an interactive prompt but instead continues automatic execution).
I've read through every stackoverflow and other resource I could think of, thus the emails.
Thanks for your help,
Robert
Robert,I think we have addressed this before.You can do this in two ways.
use the prefix for the su and then run the commands as you require them or write a method for su and execute commands thru that.RahulOn Fri, Dec 7, 2012 at 2:27 AM, RS <address@hidden> wrote:Hello there,
Is there any way to switch user without getting an interactive prompt or using sudo?
I have run into an issue described as follows:
Installing software on old solaris boxes without sudo installed.
Root logins disabled.
Ssh keys unused.I tried using a with('su -') kind of approach, or using run, but everything I've tried thus far then pops me to a new, interactive prompt, rather than continuing the automated task.
I can exit that prompt to continue execution, but the tasks that need to be run as root never complete.
I should mention that, on boxes that allow root login or use sudo, it's all gravy. The problem is just logging in with a non privileged user and then switching to root.
Any suggestions?
Thanks,
Robert
_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user
--
- Rahul
[Prev in Thread] | Current Thread | [Next in Thread] |