Fixing sudo user issue with virtual environments.

Change-Id: I828a17e6675c21a8eab0fc4f2afbd70487a5f83f
This commit is contained in:
John Vrbanac
2013-05-31 11:33:45 -05:00
parent 0eee778f35
commit c640e32a4d

View File

@@ -70,6 +70,8 @@ setup(
#'Programming Language :: Python :: 3.3', #'Programming Language :: Python :: 3.3',
) )
) )
# real_prefix should only be set under a virtualenv
using_virtualenv = hasattr(sys, 'real_prefix')
''' @todo: need to clean this up or do it with puppet/chef ''' ''' @todo: need to clean this up or do it with puppet/chef '''
# Default Config Options # Default Config Options
@@ -108,9 +110,13 @@ else:
# Get uid and gid of the current user to set permissions (Linux/OSX only) # Get uid and gid of the current user to set permissions (Linux/OSX only)
if platform.system().lower() != 'windows': if platform.system().lower() != 'windows':
sudo_user = os.getenv("SUDO_USER") if using_virtualenv:
uid = pwd.getpwnam(sudo_user).pw_uid working_user = os.getenv("USER")
gid = pwd.getpwnam(sudo_user).pw_gid else:
working_user = os.getenv("SUDO_USER")
uid = pwd.getpwnam(working_user).pw_uid
gid = pwd.getpwnam(working_user).pw_gid
config_dirs = os.listdir("configs") config_dirs = os.listdir("configs")
for dir in config_dirs: for dir in config_dirs: