[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] Changing user with sudo and running commands as new user
From: |
Herman Schistad |
Subject: |
Re: [Fab-user] Changing user with sudo and running commands as new user |
Date: |
Mon, 29 Oct 2012 10:38:11 +0100 |
Hi guys, sorry for getting back to you so late.
I first ended up doing creating a method for doing su'ing:
def su(command, user):
sudo("su %s -s /bin/bash -c %s", command, user)
But, figured I could just use the sudo(command, user=USER_ID), which
in my opinion is the simplest (and correct) aproach in this situation.
Where USER_ID is the system user running apache or whatever (e.g.
www-data).
Final code ended up like this (this is without tunnelling, which we
are dropping until fabric 1.5):
https://gist.github.com/3972599
So far running great.
Thanks for your time and feedback, Jeff and Rahul.
Sincerly, Herman Schistad