mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-02 07:07:18 -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):
|
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")
|
move(f"{tmp_dir}{_shm_folder}/{_shm_entry}.gpg", f"{directory}{_location}.gpg")
|
||||||
rmtree(f"{tmp_dir}{_shm_folder}")
|
rmtree(f"{tmp_dir}{_shm_folder}")
|
||||||
|
|
||||||
@@ -142,13 +142,13 @@ def tweak(): # runs configuration wizard
|
|||||||
'willing to use? (y/N)')
|
'willing to use? (y/N)')
|
||||||
if _gpg_id.lower() != 'y':
|
if _gpg_id.lower() != 'y':
|
||||||
print('\nA unique gpg key has been generated for you.')
|
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: '))
|
_gpg_id = str(input('\nPlease input the ID of your gpg key: '))
|
||||||
open(path.expanduser('~/.config/sshyp/sshyp-gpg'), 'w').write(_gpg_id + '\n')
|
open(path.expanduser('~/.config/sshyp/sshyp-gpg'), 'w').write(_gpg_id + '\n')
|
||||||
|
|
||||||
# lock file generation
|
# lock file generation
|
||||||
open(path.expanduser('~/.config/sshyp/lock'), 'w')
|
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")
|
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
||||||
|
|
||||||
# ssh key configuration
|
# 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'.")
|
print("\nFor a list of usable commands, run 'sshyp help'.")
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
_read_entry = str(input('Entry to read: '))
|
_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()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def read_shortcut(): # shortcut to quickly read an entry
|
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
|
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'):
|
if argument.startswith('edit username') or argument.startswith('edit -u'):
|
||||||
_detail = str(input('New Username: '))
|
_detail = str(input('New Username: '))
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_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')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 0, _detail + '\n')
|
||||||
elif argument.startswith('edit password') or argument.startswith('edit -p'):
|
elif argument.startswith('edit password') or argument.startswith('edit -p'):
|
||||||
_detail = str(input('New Password: '))
|
_detail = str(input('New Password: '))
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_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')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 1, _detail + '\n')
|
||||||
elif argument.startswith('edit url') or argument.startswith('edit -l'):
|
elif argument.startswith('edit url') or argument.startswith('edit -l'):
|
||||||
_detail = str(input('New URL: '))
|
_detail = str(input('New URL: '))
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_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')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 2, _detail + '\n')
|
||||||
elif argument.startswith('edit note') or argument.startswith('edit -n'):
|
elif argument.startswith('edit note') or argument.startswith('edit -n'):
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_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)
|
edit_note(_shm_folder, _shm_entry)
|
||||||
remove(f"{directory}{_entry_name}.gpg")
|
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}",
|
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)
|
encrypt(_shm_folder, _shm_entry, _entry_name)
|
||||||
else:
|
else:
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_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')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 1, _password + '\n')
|
||||||
remove(f"{directory}{_entry_name}.gpg")
|
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}",
|
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")
|
print("\nThe file does not exist!\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_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()
|
_copy_line = open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'r').readlines()
|
||||||
if uname()[0] == 'Haiku': # clipboard method detection
|
if uname()[0] == 'Haiku': # clipboard method detection
|
||||||
if argument.startswith('copy username') or argument.startswith('copy -u'):
|
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('/'):
|
if _entry_name.startswith('/'):
|
||||||
_entry_name = _entry_name.replace('/', '', 1)
|
_entry_name = _entry_name.replace('/', '', 1)
|
||||||
try:
|
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()
|
_unlock = open(f"{tmp_dir}sshyp.lock", 'r').readlines()
|
||||||
remove(f"{tmp_dir}sshyp.lock")
|
remove(f"{tmp_dir}sshyp.lock")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@@ -592,6 +592,10 @@ if __name__ == "__main__":
|
|||||||
directory = str(ssh_info[3].replace('\n', ''))
|
directory = str(ssh_info[3].replace('\n', ''))
|
||||||
directory_ssh = '/home/' + username_ssh + '/.password-pasture/'
|
directory_ssh = '/home/' + username_ssh + '/.password-pasture/'
|
||||||
client_device_name = listdir(path.expanduser('~/.config/sshyp/devices'))[0]
|
client_device_name = listdir(path.expanduser('~/.config/sshyp/devices'))[0]
|
||||||
|
if uname()[0] == 'Haiku':
|
||||||
|
gpg = 'gpg --pinentry-mode loopback'
|
||||||
|
else:
|
||||||
|
gpg = 'gpg'
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
if device_type.lower() != 's':
|
if device_type.lower() != 's':
|
||||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||||
|
|||||||
Reference in New Issue
Block a user