mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 04:46:34 -04:00
Added gpg support for Haiku
This commit is contained in:
@@ -97,7 +97,7 @@ def pass_gen():
|
||||
|
||||
|
||||
def encrypt(_shm_folder, _shm_entry, _location):
|
||||
system(f"gpg -qr {str(gpg_id)} -e '{tmp_dir}{_shm_folder}/{_shm_entry}'")
|
||||
system(f"{gpg} -qr {str(gpg_id)} -e '{tmp_dir}{_shm_folder}/{_shm_entry}'")
|
||||
move(f"{tmp_dir}{_shm_folder}/{_shm_entry}.gpg", f"{directory}{_location}.gpg")
|
||||
rmtree(f"{tmp_dir}{_shm_folder}")
|
||||
|
||||
@@ -142,13 +142,13 @@ def tweak(): # runs configuration wizard
|
||||
'willing to use? (y/N)')
|
||||
if _gpg_id.lower() != 'y':
|
||||
print('\nA unique gpg key has been generated for you.')
|
||||
system('gpg --full-generate-key')
|
||||
system(f"{gpg} --full-generate-key")
|
||||
_gpg_id = str(input('\nPlease input the ID of your gpg key: '))
|
||||
open(path.expanduser('~/.config/sshyp/sshyp-gpg'), 'w').write(_gpg_id + '\n')
|
||||
|
||||
# lock file generation
|
||||
open(path.expanduser('~/.config/sshyp/lock'), 'w')
|
||||
system(f"gpg -qr {str(_gpg_id)} -e {path.expanduser('~/.config/sshyp/lock')}")
|
||||
system(f"{gpg} -qr {str(_gpg_id)} -e {path.expanduser('~/.config/sshyp/lock')}")
|
||||
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
||||
|
||||
# ssh key configuration
|
||||
@@ -274,12 +274,12 @@ def no_arg(): # displays a list of entries and gives an option to select one fo
|
||||
print("\nFor a list of usable commands, run 'sshyp help'.")
|
||||
entry_list_gen()
|
||||
_read_entry = str(input('Entry to read: '))
|
||||
system(f"gpg -qd '{directory}{_read_entry.replace('/', '', 1)}.gpg'")
|
||||
system(f"{gpg} -qd '{directory}{_read_entry.replace('/', '', 1)}.gpg'")
|
||||
print()
|
||||
|
||||
|
||||
def read_shortcut(): # shortcut to quickly read an entry
|
||||
system(f"gpg -qd '{directory}{argument.replace('/', '', 1)}.gpg'")
|
||||
system(f"{gpg} -qd '{directory}{argument.replace('/', '', 1)}.gpg'")
|
||||
|
||||
|
||||
def sync(): # calls sshync to sync changes to the user's server
|
||||
@@ -422,21 +422,21 @@ def edit(): # edits the contents of an entry
|
||||
if argument.startswith('edit username') or argument.startswith('edit -u'):
|
||||
_detail = str(input('New Username: '))
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"gpg -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 0, _detail + '\n')
|
||||
elif argument.startswith('edit password') or argument.startswith('edit -p'):
|
||||
_detail = str(input('New Password: '))
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"gpg -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 1, _detail + '\n')
|
||||
elif argument.startswith('edit url') or argument.startswith('edit -l'):
|
||||
_detail = str(input('New URL: '))
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"gpg -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 2, _detail + '\n')
|
||||
elif argument.startswith('edit note') or argument.startswith('edit -n'):
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"gpg -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
edit_note(_shm_folder, _shm_entry)
|
||||
remove(f"{directory}{_entry_name}.gpg")
|
||||
print('\n\u001b[38;5;0;48;5;15mEntry preview:\u001b[0m\n\n' + open(f"{tmp_dir}{_shm_folder}/{_shm_entry}",
|
||||
@@ -485,7 +485,7 @@ def gen(): # generates a password for a new or an existing entry
|
||||
encrypt(_shm_folder, _shm_entry, _entry_name)
|
||||
else:
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"gpg -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 1, _password + '\n')
|
||||
remove(f"{directory}{_entry_name}.gpg")
|
||||
print('\n\u001b[38;5;0;48;5;15mEntry preview:\u001b[0m\n\n' + open(f"{tmp_dir}{_shm_folder}/{_shm_entry}",
|
||||
@@ -506,7 +506,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard
|
||||
print("\nThe file does not exist!\n")
|
||||
s_exit(1)
|
||||
_shm_folder, _shm_entry = shm_gen()
|
||||
system(f"gpg -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_read_entry}.gpg'")
|
||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_read_entry}.gpg'")
|
||||
_copy_line = open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'r').readlines()
|
||||
if uname()[0] == 'Haiku': # clipboard method detection
|
||||
if argument.startswith('copy username') or argument.startswith('copy -u'):
|
||||
@@ -558,7 +558,7 @@ def remove_data(): # deletes an entry from the server and flags it for local de
|
||||
if _entry_name.startswith('/'):
|
||||
_entry_name = _entry_name.replace('/', '', 1)
|
||||
try:
|
||||
system(f"gpg -qd --output {tmp_dir}sshyp.lock {path.expanduser('~/.config/sshyp/lock.gpg')}")
|
||||
system(f"{gpg} -qd --output {tmp_dir}sshyp.lock {path.expanduser('~/.config/sshyp/lock.gpg')}")
|
||||
_unlock = open(f"{tmp_dir}sshyp.lock", 'r').readlines()
|
||||
remove(f"{tmp_dir}sshyp.lock")
|
||||
except FileNotFoundError:
|
||||
@@ -592,6 +592,10 @@ if __name__ == "__main__":
|
||||
directory = str(ssh_info[3].replace('\n', ''))
|
||||
directory_ssh = '/home/' + username_ssh + '/.password-pasture/'
|
||||
client_device_name = listdir(path.expanduser('~/.config/sshyp/devices'))[0]
|
||||
if uname()[0] == 'Haiku':
|
||||
gpg = 'gpg --pinentry-mode loopback'
|
||||
else:
|
||||
gpg = 'gpg'
|
||||
except FileNotFoundError:
|
||||
if device_type.lower() != 's':
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
|
||||
Reference in New Issue
Block a user