mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 08:37:14 -04:00
Require _quick_unlock_enabled parameter for decrypt()
Former-commit-id: af37809cfeb7c36de355d6cc0e8bc159f7291033 Former-commit-id: 195364d30d36467a4966347b54d66136e36dcdeb
This commit is contained in:
+9
-7
@@ -133,9 +133,9 @@ def encrypt(_entry_dir, _shm_folder, _shm_entry, _gpg_id, _tmp_dir=f"{home}/.con
|
|||||||
|
|
||||||
|
|
||||||
# decrypts an entry to a temporary directory
|
# decrypts an entry to a temporary directory
|
||||||
def decrypt(_entry_dir, _shm_folder, _shm_entry, _tmp_dir=f"{home}/.config/sshyp/tmp/"):
|
def decrypt(_entry_dir, _shm_folder, _shm_entry, _quick_unlock_enabled, _tmp_dir=f"{home}/.config/sshyp/tmp/"):
|
||||||
# check quick-unlock status, fetch passphrase
|
# check quick-unlock status, fetch passphrase
|
||||||
if sshyp_data.get('CLIENT-ONLINE', 'quick_unlock_enabled') == 'true':
|
if _quick_unlock_enabled == 'true':
|
||||||
_quick_pass = whitelist_verify(port, username_ssh, ip, client_device_id)
|
_quick_pass = whitelist_verify(port, username_ssh, ip, client_device_id)
|
||||||
else:
|
else:
|
||||||
_quick_pass = False
|
_quick_pass = False
|
||||||
@@ -360,7 +360,7 @@ this program comes with absolutely no warranty; type 'sshyp license' for details
|
|||||||
def read_shortcut():
|
def read_shortcut():
|
||||||
target_type_check(entry_name, True, True)
|
target_type_check(entry_name, True, True)
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_shm_folder, _shm_entry = shm_gen()
|
||||||
decrypt(directory + entry_name, _shm_folder, _shm_entry)
|
decrypt(directory + entry_name, _shm_folder, _shm_entry, quick_unlock_enabled)
|
||||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||||
rmtree(f"{tmp_dir}{_shm_folder}")
|
rmtree(f"{tmp_dir}{_shm_folder}")
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ def edit():
|
|||||||
target_type_check(entry_name, True, True)
|
target_type_check(entry_name, True, True)
|
||||||
|
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_shm_folder, _shm_entry = shm_gen()
|
||||||
decrypt(directory + entry_name, _shm_folder, _shm_entry)
|
decrypt(directory + entry_name, _shm_folder, _shm_entry, quick_unlock_enabled)
|
||||||
if arguments[2] in ('username', '-u'):
|
if arguments[2] in ('username', '-u'):
|
||||||
_detail, _edit_line = str(input('username: ')), 1
|
_detail, _edit_line = str(input('username: ')), 1
|
||||||
elif arguments[2] in ('password', '-p'):
|
elif arguments[2] in ('password', '-p'):
|
||||||
@@ -525,7 +525,7 @@ def gen():
|
|||||||
if arg_count == 3 and arguments[2] in ('update', '-u'):
|
if arg_count == 3 and arguments[2] in ('update', '-u'):
|
||||||
# ensure the gen update target is an entry
|
# ensure the gen update target is an entry
|
||||||
target_type_check(entry_name, True, True)
|
target_type_check(entry_name, True, True)
|
||||||
decrypt(directory + entry_name, _shm_folder, _shm_entry)
|
decrypt(directory + entry_name, _shm_folder, _shm_entry, quick_unlock_enabled)
|
||||||
_new_lines = optimized_edit(open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'r').readlines(), pass_gen(), 0)
|
_new_lines = optimized_edit(open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'r').readlines(), pass_gen(), 0)
|
||||||
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_new_lines)
|
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_new_lines)
|
||||||
remove(f"{directory}{entry_name}.gpg")
|
remove(f"{directory}{entry_name}.gpg")
|
||||||
@@ -555,7 +555,7 @@ def copy_data():
|
|||||||
# ensure the copy target is an entry
|
# ensure the copy target is an entry
|
||||||
target_type_check(entry_name, True, True)
|
target_type_check(entry_name, True, True)
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_shm_folder, _shm_entry = shm_gen()
|
||||||
decrypt(directory + entry_name, _shm_folder, _shm_entry)
|
decrypt(directory + entry_name, _shm_folder, _shm_entry, quick_unlock_enabled)
|
||||||
_copy_line, _index = [_line.rstrip() for _line in open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'r').readlines()], 0
|
_copy_line, _index = [_line.rstrip() for _line in open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'r').readlines()], 0
|
||||||
if arguments[2] in ('username', '-u'):
|
if arguments[2] in ('username', '-u'):
|
||||||
_index = 1
|
_index = 1
|
||||||
@@ -605,7 +605,7 @@ def copy_data():
|
|||||||
|
|
||||||
# deletes an entry from the server and flags it for local deletion on sync
|
# deletes an entry from the server and flags it for local deletion on sync
|
||||||
def remove_data():
|
def remove_data():
|
||||||
decrypt(f"{home}/.config/sshyp/lock.gpg", None, None)
|
decrypt(f"{home}/.config/sshyp/lock.gpg", None, None, quick_unlock_enabled)
|
||||||
if not ssh_error:
|
if not ssh_error:
|
||||||
run(('ssh', '-i', f"{home}/.ssh/sshyp", '-p', port, f"{username_ssh}@{ip}",
|
run(('ssh', '-i', f"{home}/.ssh/sshyp", '-p', port, f"{username_ssh}@{ip}",
|
||||||
f'cd /usr/lib/sshyp; python3 -c \'from sshync import delete; delete("{entry_name}", "remotely", False)\''))
|
f'cd /usr/lib/sshyp; python3 -c \'from sshync import delete; delete("{entry_name}", "remotely", False)\''))
|
||||||
@@ -672,7 +672,9 @@ if __name__ == "__main__":
|
|||||||
offline_mode_enabled = sshyp_data.get('CLIENT-GENERAL', 'offline_mode_enabled')
|
offline_mode_enabled = sshyp_data.get('CLIENT-GENERAL', 'offline_mode_enabled')
|
||||||
if offline_mode_enabled == 'true':
|
if offline_mode_enabled == 'true':
|
||||||
ssh_error = True
|
ssh_error = True
|
||||||
|
quick_unlock_enabled = 'false'
|
||||||
else:
|
else:
|
||||||
|
quick_unlock_enabled = sshyp_data.get('CLIENT-ONLINE', 'quick_unlock_enabled')
|
||||||
username_ssh = sshyp_data.get('SSHYNC', 'user')
|
username_ssh = sshyp_data.get('SSHYNC', 'user')
|
||||||
ip = sshyp_data.get('SSHYNC', 'ip')
|
ip = sshyp_data.get('SSHYNC', 'ip')
|
||||||
port = sshyp_data.get('SSHYNC', 'port')
|
port = sshyp_data.get('SSHYNC', 'port')
|
||||||
|
|||||||
Reference in New Issue
Block a user