2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

fix cmd_requires_root logic

This commit is contained in:
Pratik Vyas 2014-11-10 14:56:09 +05:30
parent 9cc3c4492b
commit 6a100e22ba

View File

@ -34,13 +34,20 @@ def cli():
return frappe()
return bench()
def cmd_requires_root():
print sys.argv
if len(sys.argv) > 3 and sys.argv[2] in ('production', 'sudoers'):
return True
if len(sys.argv) > 2 and sys.argv[1] in ('patch',):
return True
def check_uid():
if len(sys.argv) > 3 and sys.argv[2] in ('production', 'sudoers') and not is_root():
if cmd_requires_root() and not is_root():
print 'superuser privileges required for this command'
sys.exit(1)
def change_uid():
if is_root():
if is_root() and not cmd_requires_root():
frappe_user = get_config().get('frappe_user')
if frappe_user:
os.setuid(pwd.getpwnam(frappe_user).pw_uid)