Add ALLOW_ROOT option (#268)
* Add ALLOW_ROOT option * Document ALLOW_ROOT option * Update controller.py * Update ENVIRONMENT.rst
This commit is contained in:
parent
accbdf6884
commit
0e6b59eb92
@ -64,6 +64,10 @@ Miscellaneous
|
||||
|
||||
These environment variables are optional:
|
||||
|
||||
* **ALLOW_ROOT**
|
||||
|
||||
Set this environment variable to anything non-empty to allow running ElectrumX as root.
|
||||
|
||||
* **NET**
|
||||
|
||||
Must be a *NET* from one of the **Coin** classes in `lib/coins.py`_.
|
||||
|
||||
@ -51,9 +51,12 @@ class Controller(util.LoggedClass):
|
||||
if sys.version_info < (3, 5, 3):
|
||||
raise RuntimeError('Python >= 3.5.3 is required to run ElectrumX')
|
||||
|
||||
if os.geteuid() == 0:
|
||||
raise RuntimeError('DO NOT RUN AS ROOT! Create an unprivileged '
|
||||
'user account and use that')
|
||||
if os.geteuid() == 0 and not env.allow_root:
|
||||
raise RuntimeError('RUNNING AS ROOT IS STRONGLY DISCOURAGED!\n'
|
||||
'You shoud create an unprivileged user account '
|
||||
'and use that.\n'
|
||||
'To continue as root anyway, restart with '
|
||||
'environment variable ALLOW_ROOT non-empty')
|
||||
|
||||
# Set the event loop policy before doing anything asyncio
|
||||
self.logger.info('event loop policy: {}'.format(env.loop_policy))
|
||||
|
||||
@ -29,6 +29,7 @@ class Env(lib_util.LoggedClass):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.obsolete(['UTXO_MB', 'HIST_MB', 'NETWORK'])
|
||||
self.allow_root = self.boolean('ALLOW_ROOT', False)
|
||||
self.db_dir = self.required('DB_DIRECTORY')
|
||||
self.daemon_url = self.required('DAEMON_URL')
|
||||
coin_name = self.required('COIN').strip()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user