allow a sudo_prefix that doesn't include sudo_prompt #609

wants to merge 1 commit into


None yet

2 participants

3point2 commented Apr 5, 2012

I added a NOPASSWD entry in my sudoers file to allow a particular command to be run as root. as per , I had to add shell=False to run the command 'as-is'.

However, with the latest version of Fabric (1.4.0), it's not possible to prevent Fabric from passing the "-p" option to sudo, which makes it ask for a password even if none is needed.

I tried setting env.sudo_prefix, but this doesn't work because _sudo_prefix() in does

prefix = env.sudo_prefix % env.sudo_prompt

In other words, the sudo_prefix string has to contain a '%s' for interpolation.

Using the approach in this pull request will also make it easier to document sudo_prefix and I think making all env vars available to sudo_prefix is cool, especially since you're planning to document it (#564)

@3point2 3point2 making sudo_prompt interpolation with sudo_prefix optional.
this makes it possible to use a sudo prefix that doesn't
include the sudo_prompt text (for example, if a password
prompt isn't needed)

I like this change, it's subtle but shouldn't break anything and does make it a lot more flexible for your sort of edge case. Thanks!

EDIT: Do you have a surname you'd like to specify so I can credit you in the changelog? :) your GH account just says "Vasili".

3point2 commented Apr 6, 2012

Great! I'm fine with just being credited as "Vasili (3point2)".. If you require a surname, there's no need to credit me :)


Nah, not required, but "full name" is the default format and most people who didn't put it in their GH profile are usually OK handing it out. No worries though! :)

@bitprophet bitprophet added a commit that closed this pull request Apr 6, 2012
@bitprophet bitprophet Clean up & document env.sudo_prefix.
Fixes #609, fixes #564
@bitprophet bitprophet closed this in 6bf1d90 Apr 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment