mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-04 08:07:15 -04:00
Optimized decrypt() function (fixes issue #1)
Former-commit-id: d94cce05e9695f4d0744b5a3f4232ad48b146ed2 [formerly 3ad5acfc99]
Former-commit-id: b7edcf31903826ebb8010f6e694b728e1616a70f
This commit is contained in:
@@ -8,7 +8,7 @@ import random
|
|||||||
from shutil import get_terminal_size, move, rmtree
|
from shutil import get_terminal_size, move, rmtree
|
||||||
import sshync
|
import sshync
|
||||||
import string
|
import string
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
from subprocess import CalledProcessError, Popen, PIPE, run, STDOUT
|
||||||
from sys import argv, exit as s_exit
|
from sys import argv, exit as s_exit
|
||||||
from textwrap import fill
|
from textwrap import fill
|
||||||
|
|
||||||
@@ -155,9 +155,9 @@ def decrypt(_entry_dir, _shm_folder, _shm_entry):
|
|||||||
_command = f"{gpg} -qd --output /dev/null {path.expanduser('~/.config/sshyp/lock.gpg')}"
|
_command = f"{gpg} -qd --output /dev/null {path.expanduser('~/.config/sshyp/lock.gpg')}"
|
||||||
else:
|
else:
|
||||||
_command = f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} {_entry_dir}.gpg"
|
_command = f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} {_entry_dir}.gpg"
|
||||||
_output = Popen(_command, shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
try:
|
||||||
_block = _output.communicate()[0].strip()
|
run(_command, shell=True, stderr=PIPE, check=True, close_fds=True)
|
||||||
if _output.returncode == 2:
|
except CalledProcessError:
|
||||||
print(f"\n\u001b[38;5;9merror: could not decrypt - ensure the correct gpg key is present\u001b[0m\n")
|
print(f"\n\u001b[38;5;9merror: could not decrypt - ensure the correct gpg key is present\u001b[0m\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user