diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/etoolkit/__main__.py | 14 | ||||
| -rw-r--r-- | src/etoolkit/etoolkit.py | 19 |
2 files changed, 23 insertions, 10 deletions
diff --git a/src/etoolkit/__main__.py b/src/etoolkit/__main__.py index fba9dc7..8b5bd55 100644 --- a/src/etoolkit/__main__.py +++ b/src/etoolkit/__main__.py | |||
| @@ -319,7 +319,13 @@ def main(inargs=None): | |||
| 319 | sys.exit(0) | 319 | sys.exit(0) |
| 320 | 320 | ||
| 321 | inst = etoolkit.EtoolkitInstance(args.instance, config_dict) | 321 | inst = etoolkit.EtoolkitInstance(args.instance, config_dict) |
| 322 | inst.prompt_func = etoolkit.EtoolkitInstance.confirm_password_prompt | 322 | if ( |
| 323 | args.master_password_prompt | ||
| 324 | or os.environ.get('ETOOLKIT_MASTER_PASSWORD') is None | ||
| 325 | ): | ||
| 326 | inst.prompt_func = ( | ||
| 327 | etoolkit.EtoolkitInstance.confirm_password_prompt | ||
| 328 | ) | ||
| 323 | env = inst.get_environ() | 329 | env = inst.get_environ() |
| 324 | 330 | ||
| 325 | if args.dump_output: | 331 | if args.dump_output: |
| @@ -328,9 +334,11 @@ def main(inargs=None): | |||
| 328 | os.environ.update(env) | 334 | os.environ.update(env) |
| 329 | 335 | ||
| 330 | if args.spawn: | 336 | if args.spawn: |
| 331 | subprocess.run(args.spawn.split(), check=True) | 337 | subprocess.run(args.spawn.split(), check=False) |
| 332 | else: | 338 | else: |
| 333 | subprocess.run(os.environ.get('SHELL', 'bash').split(), check=True) | 339 | subprocess.run( |
| 340 | os.environ.get('SHELL', 'bash').split(), check=False | ||
| 341 | ) | ||
| 334 | except KeyboardInterrupt: | 342 | except KeyboardInterrupt: |
| 335 | logger.debug('KeyboardInterrupt') | 343 | logger.debug('KeyboardInterrupt') |
| 336 | print(os.linesep) | 344 | print(os.linesep) |
diff --git a/src/etoolkit/etoolkit.py b/src/etoolkit/etoolkit.py index 870a4be..a2e0d7a 100644 --- a/src/etoolkit/etoolkit.py +++ b/src/etoolkit/etoolkit.py | |||
| @@ -385,7 +385,7 @@ class EtoolkitInstance: | |||
| 385 | if self._parent is not None | 385 | if self._parent is not None |
| 386 | else '' | 386 | else '' |
| 387 | ) | 387 | ) |
| 388 | if isinstance(value, str) and value.startswith('enc-val$1$'): | 388 | if isinstance(value, str) and value.startswith('enc-val$'): |
| 389 | value = self._decrypt_value(value) | 389 | value = self._decrypt_value(value) |
| 390 | if isinstance(value, str) and value.endswith(':'): | 390 | if isinstance(value, str) and value.endswith(':'): |
| 391 | # if 'value' ends with ':', append the existing value of | 391 | # if 'value' ends with ':', append the existing value of |
| @@ -440,11 +440,16 @@ class EtoolkitInstance: | |||
| 440 | """ | 440 | """ |
| 441 | if self._master_password is None: | 441 | if self._master_password is None: |
| 442 | if self._prompt_func is None: | 442 | if self._prompt_func is None: |
| 443 | raise EtoolkitInstanceError( | 443 | if ( |
| 444 | 'Neither password or prompt function set' | 444 | mp_from_env := os.environ.get('ETOOLKIT_MASTER_PASSWORD') |
| 445 | ) is None: | ||
| 446 | raise EtoolkitInstanceError( | ||
| 447 | 'Neither password or prompt function set' | ||
| 448 | ) | ||
| 449 | self.master_password = mp_from_env | ||
| 450 | else: | ||
| 451 | # use master_password setter in order to propagate to parent | ||
| 452 | self.master_password = self._prompt_func( | ||
| 453 | self._master_password_hash, confirm=False | ||
| 445 | ) | 454 | ) |
| 446 | # use master_password setter in order to propagate to parent | ||
| 447 | self.master_password = self._prompt_func( | ||
| 448 | self._master_password_hash, confirm=False | ||
| 449 | ) | ||
| 450 | return EtoolkitInstance.decrypt(self._master_password, evalue) | 455 | return EtoolkitInstance.decrypt(self._master_password, evalue) |
