Skip to content

Commit 87d40d7

Browse files
authored
Merge pull request #10680 from spesmilo/disable_memory_hardening
config: add option to disable memory hardening
2 parents f29ef6f + 3ae85ee commit 87d40d7

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

electrum/commands.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,10 @@ def add_global_options(parser, suppress=False):
24622462
group.add_argument(
24632463
"--forgetconfig", action="store_true", dest=SimpleConfig.CONFIG_FORGET_CHANGES.key(), default=None,
24642464
help=argparse.SUPPRESS if suppress else "Forget config on exit")
2465+
group.add_argument(
2466+
# Note: default value is False and not None, so that behaviour cannot be modified by editing the config file
2467+
"--nohardening", action="store_true", dest=SimpleConfig.DISABLE_MEMORY_HARDENING_LINUX.key(), default=False,
2468+
help=argparse.SUPPRESS if suppress else "Disable memory hardening (linux)")
24652469

24662470

24672471
def get_simple_parser():

electrum/simple_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ def __setattr__(self, name, value):
794794
RPC_SOCKET_TYPE = ConfigVar('rpcsock', default='auto', type_=str)
795795
RPC_SOCKET_FILEPATH = ConfigVar('rpcsockpath', default=None, type_=str)
796796

797+
DISABLE_MEMORY_HARDENING_LINUX = ConfigVar('nohardening', default=None, type_=bool) # default is False in add_global_options
798+
797799
GUI_NAME = ConfigVar('gui', default='qt', type_=str)
798800
CURRENT_WALLET = ConfigVar('current_wallet', default=None, type_=str)
799801

run_electrum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ def main():
408408
'cmd': 'gui',
409409
SimpleConfig.GUI_NAME.key(): 'qml',
410410
SimpleConfig.WALLET_SHOULD_USE_SINGLE_PASSWORD.key(): True,
411+
SimpleConfig.DISABLE_MEMORY_HARDENING_LINUX.key(): True,
411412
}
412413
SimpleConfig.set_chain_config_opt_based_on_android_packagename(config_options)
413414
else:
@@ -458,7 +459,7 @@ def main():
458459
print_stderr('unknown command:', uri)
459460
sys.exit(1)
460461

461-
if sys.platform == "linux" and not is_android:
462+
if sys.platform == "linux" and not config.DISABLE_MEMORY_HARDENING_LINUX:
462463
import electrum.harden_memory_linux
463464
electrum.harden_memory_linux.set_dumpable_safe(False)
464465

0 commit comments

Comments
 (0)