[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] sudo with user=...: can't read MY bash profile or change
From: |
Shenton, Chris (HQ-LM020)[InDyne, Inc] |
Subject: |
Re: [Fab-user] sudo with user=...: can't read MY bash profile or change to MY dir |
Date: |
Thu, 12 Aug 2010 21:07:48 -0500 |
On Aug 12, 2010, at 8:47 PM, Jeff Forcier wrote:
>
> You can modify env.shell to remove the -l flag to address that
> specific issue; see http://docs.fabfile.org/0.9.1/usage/env.html#shell
> for details.
Ah, didn't think of that. Seems a good idea.
>
> (BTW, you can see exactly what is being passed down the line for all
> your commands by specifying --show=debug or setting output.debug=True.
> This will show the bash wrapper if it's enabled, as well as any
> escaping being done.
Nice.
>
>
> This is simply how SSH works; commands invoked directly assume a
> starting working directory of the connecting user's homedir. I'm not
> aware of any way to change this offhand.
Yeah, guess it has to -- to find your authorized keys, etc.
>>
> To keep state you need to perform tricks such as prefixing each
> command with "cd <somewhere> && <actual command>". Fabric has some of
> these build in, such as "with cd():", which I see you've already found
> -- there's a more generic "with prefix():" coming in the next release
> or two, too.
Been doing a bunch of this, works fine.
>> sudo -H -u username pwd
>>
> An interesting idea. I'm not sure I'd want that to be the default, for
> a handful of reasons, but one of the nice things about Fabric being
> pure Python is that you can easily define your own higher level
> wrapper functions, like those in fabric.contrib.
>
> So you could write your own sudo function (either shadowing the
> builtin or with a tweaked name) and use that pretty easily (especially
> once we add more dependency injection, e.g. allowing you to pass in
> the "runner" to use for high level stuff like contrib.files.append()).
I'll take a whack at that. It's nice that fabric is so easy to work with,
being python.
Thanks for all your help!