Search code examples
pythonpython-3.xfabric

Can I make fabric use `dzdo su -` instead of sudo?


We have some older systems that don't actually have sudo installed, they have dzdo, which is a Centrify thing. It looks like we're pretty limited in what we can do, basically dzdo su - is it. So we ssh in, run dzdo su - to gain root, and then do our stuff.

Is there a way to make fabric do this?

I've tried

from fabric.api import settings

def as_root():
    with settings(sudo_prefix='dzdo su -'):
        sudo('whoami')

and dzdo and dzdo su and... none of these approaches work.

Is there a way that I can use Fabric for this?


Solution

  • I know this is an old question, but this is what worked for me:

    def as_root():
        env.sudo_prefix = "/usr/bin/dzdo -s"
        sudo('whoami')
    

    Or, with your approach:

    def as_root():
        with settings(sudo_prefix='/usr/bin/dzdo -s'):
            sudo('whoami')