mirror of
https://github.com/frappe/bench.git
synced 2025-01-24 15:38:25 +00:00
fix cmd_requires_root logic
This commit is contained in:
parent
9cc3c4492b
commit
6a100e22ba
11
bench/cli.py
11
bench/cli.py
@ -34,13 +34,20 @@ def cli():
|
|||||||
return frappe()
|
return frappe()
|
||||||
return bench()
|
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():
|
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'
|
print 'superuser privileges required for this command'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def change_uid():
|
def change_uid():
|
||||||
if is_root():
|
if is_root() and not cmd_requires_root():
|
||||||
frappe_user = get_config().get('frappe_user')
|
frappe_user = get_config().get('frappe_user')
|
||||||
if frappe_user:
|
if frappe_user:
|
||||||
os.setuid(pwd.getpwnam(frappe_user).pw_uid)
|
os.setuid(pwd.getpwnam(frappe_user).pw_uid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user