Added root warning and settings token toggle
This commit is contained in:
parent
03bb25be06
commit
b19a6fa22a
2 changed files with 27 additions and 0 deletions
|
@ -935,6 +935,8 @@ class Buildozer(object):
|
||||||
|
|
||||||
self._merge_config_profile()
|
self._merge_config_profile()
|
||||||
|
|
||||||
|
self.check_root()
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
self.run_default()
|
self.run_default()
|
||||||
return
|
return
|
||||||
|
@ -956,6 +958,28 @@ class Buildozer(object):
|
||||||
self.set_target(command)
|
self.set_target(command)
|
||||||
self.target.run_commands(args)
|
self.target.run_commands(args)
|
||||||
|
|
||||||
|
def check_root(self):
|
||||||
|
'''If effective user id is 0, display a warning and require
|
||||||
|
user input to continue (or to cancel)'''
|
||||||
|
|
||||||
|
try: # ensure same result in python2 and python3
|
||||||
|
input = raw_input
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
warn_on_root = self.config.getdefault('buildozer', 'warn_on_root', 1)
|
||||||
|
euid = os.geteuid()
|
||||||
|
if warn_on_root and euid == 0:
|
||||||
|
print('\033[91m\033[1mBuildozer is running as root!\033[0m')
|
||||||
|
print('\033[91mThis is \033[1mnot\033[0m \033[91mrecommended, and may lead to problems later.\033[0m')
|
||||||
|
cont = None
|
||||||
|
while cont not in ('y', 'n'):
|
||||||
|
cont = input('Are you sure you want to continue [y/n]? ')
|
||||||
|
|
||||||
|
if cont == 'n':
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def cmd_init(self, *args):
|
def cmd_init(self, *args):
|
||||||
'''Create a initial buildozer.spec in the current directory
|
'''Create a initial buildozer.spec in the current directory
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -145,6 +145,9 @@ fullscreen = 1
|
||||||
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
|
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
|
||||||
log_level = 1
|
log_level = 1
|
||||||
|
|
||||||
|
# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
|
||||||
|
warn_on_root = 1
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# List as sections
|
# List as sections
|
||||||
|
|
Loading…
Add table
Reference in a new issue