From 429ff7fa074df49cd8e8d91a78ea539e038ccb3e Mon Sep 17 00:00:00 2001 From: MMGen Date: Wed, 22 May 2019 09:52:30 +0000 Subject: [PATCH] [msys2]: warn/exit on buggy, unsupported features --- data_files/mmgen.cfg | 3 +++ mmgen/common.py | 13 +++++++++++++ mmgen/globalvars.py | 6 +++++- mmgen/main_autosign.py | 2 ++ mmgen/seed.py | 2 ++ mmgen/tool.py | 2 ++ mmgen/util.py | 4 ++++ 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/data_files/mmgen.cfg b/data_files/mmgen.cfg index e248bad8..085faba6 100644 --- a/data_files/mmgen.cfg +++ b/data_files/mmgen.cfg @@ -77,6 +77,9 @@ # Set the Ethereum testnet name # eth_testnet_chain_name kovan +# Uncomment to suppress non-ASCII character password warning for MSWin / MSYS2 +# mswin_pw_warning false + ##################################################################### # The following options are probably of interest only to developers # ##################################################################### diff --git a/mmgen/common.py b/mmgen/common.py index 8215f847..c0f40bfd 100755 --- a/mmgen/common.py +++ b/mmgen/common.py @@ -146,3 +146,16 @@ default wallet. pnu=g.proto.name.capitalize(), pnl=g.proj_name.lower()) }[k] + ('-α' if g.debug_utf8 else '') + +def exit_if_mswin(feature): + if g.platform == 'win': + m = capfirst(feature) + ' not supported on the MSWin / MSYS2 platform' + ydie(1,m) + +def mswin_pw_warning(): + if g.platform == 'win' and not opt.echo_passphrase and g.mswin_pw_warning: + m = 'due to a bug in the MSYS2 Python implementation, if your passphrase\n' + m += 'contains non-ASCII characters, you must turn on passphrase echoing with the\n' + m += '--echo-passphrase option or use a password file. Otherwise, the non-ASCII\n' + m += 'characters in your passphrase will be silently ignored!' + msg(red('WARNING: ') + yellow(m)) diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index cdd4c05b..2c4a81be 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -105,6 +105,9 @@ class g(object): test_suite = False test_suite_popen_spawn = False + # warnings + mswin_pw_warning = True + for k in ('linux','win','msys'): if sys.platform[:len(k)] == k: platform = { 'linux':'linux', 'win':'win', 'msys':'win' }[k] @@ -159,7 +162,7 @@ class g(object): 'daemon_data_dir','force_256_color','regtest','subseeds', 'btc_max_tx_fee','ltc_max_tx_fee','bch_max_tx_fee','eth_max_tx_fee', 'eth_mainnet_chain_name','eth_testnet_chain_name', - 'max_tx_file_size','max_input_size' + 'max_tx_file_size','max_input_size','mswin_pw_warning' ) # Supported environmental vars # The corresponding vars (lowercase, minus 'mmgen_') must be initialized in g @@ -189,6 +192,7 @@ class g(object): 'MMGEN_USE_STANDALONE_SCRYPT_MODULE', 'MMGEN_DISABLE_COLOR', + 'MMGEN_DISABLE_MSWIN_PW_WARNING', ) min_screen_width = 80 diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index 1b1399f6..2675b572 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -106,6 +106,8 @@ This command is currently available only on Linux-based platforms. cmd_args = opts.init(opts_data,add_opts=['mmgen_keys_from_file','in_fmt']) +exit_if_mswin('autosigning') + import mmgen.tx import mmgen.altcoins.eth.tx from mmgen.txsign import txsign diff --git a/mmgen/seed.py b/mmgen/seed.py index 2e7a8785..d199e22d 100755 --- a/mmgen/seed.py +++ b/mmgen/seed.py @@ -457,6 +457,7 @@ an empty passphrase, just hit ENTER twice. elif opt.echo_passphrase: pw = ' '.join(get_words_from_user('Enter {}: '.format(desc))) else: + mswin_pw_warning() for i in range(g.passwd_max_tries): pw = ' '.join(get_words_from_user('Enter {}: '.format(desc))) pw2 = ' '.join(get_words_from_user('Repeat passphrase: ')) @@ -481,6 +482,7 @@ an empty passphrase, just hit ENTER twice. w = pwfile_reuse_warning() ret = ' '.join(get_words_from_file(opt.passwd_file,desc,quiet=w)) else: + mswin_pw_warning() ret = ' '.join(get_words_from_user('Enter {}: '.format(desc))) self.ssdata.passwd = ret diff --git a/mmgen/tool.py b/mmgen/tool.py index c105499f..00cf2e7d 100755 --- a/mmgen/tool.py +++ b/mmgen/tool.py @@ -830,6 +830,8 @@ class MMGenToolCmdMonero(MMGenToolCmdBase): def monero_wallet_ops(self,infile:str,op:str,blockheight=0,addrs=''): + exit_if_mswin('Monero wallet operations') + def run_cmd(cmd): import subprocess as sp p = sp.Popen(cmd,stdin=sp.PIPE,stdout=sp.PIPE,stderr=sp.PIPE) diff --git a/mmgen/util.py b/mmgen/util.py index a3b07aa5..2846afc3 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -546,6 +546,8 @@ def get_new_passphrase(desc,passchg=False): elif opt.echo_passphrase: pw = ' '.join(get_words_from_user('Enter {}: '.format(w))) else: + from mmgen.common import mswin_pw_warning + mswin_pw_warning() for i in range(g.passwd_max_tries): pw = ' '.join(get_words_from_user('Enter {}: '.format(w))) pw2 = ' '.join(get_words_from_user('Repeat passphrase: ')) @@ -741,6 +743,8 @@ def get_mmgen_passphrase(desc,passchg=False): pwfile_reuse_warning() return ' '.join(get_words_from_file(opt.passwd_file,'passphrase')) else: + from mmgen.common import mswin_pw_warning + mswin_pw_warning() return ' '.join(get_words_from_user(prompt)) def my_raw_input(prompt,echo=True,insert_txt='',use_readline=True):