mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 16:47:14 -04:00
Whitelist bugfixes and polish
Former-commit-id: fa8991e443fb5117d1a69afa4cd0b0017bacda1f [formerly 773f27946e]
Former-commit-id: e417225d361e3fdb1021885336ec7a9f86e0fdaa
This commit is contained in:
+6
-4
@@ -479,7 +479,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
def whitelist_list(): # shows the quick-unlock whitelist status of device ids
|
def whitelist_list(): # shows the quick-unlock whitelist status of device ids
|
||||||
_whitelisted_ids = listdir(path.expanduser('~/.config/sshyp/whitelist'))
|
_whitelisted_ids = listdir(path.expanduser('~/.config/sshyp/whitelist'))
|
||||||
_device_ids = listdir(path.expanduser('~/.config/sshyp/devices'))
|
_device_ids = listdir(path.expanduser('~/.config/sshyp/devices'))
|
||||||
print('\u001b[1mquick-unlock whitelisted device ids:\u001b[0m')
|
print('\n\u001b[1mquick-unlock whitelisted device ids:\u001b[0m')
|
||||||
for _id in _whitelisted_ids:
|
for _id in _whitelisted_ids:
|
||||||
print(_id)
|
print(_id)
|
||||||
print('\n\u001b[1mother registered device ids:\u001b[0m')
|
print('\n\u001b[1mother registered device ids:\u001b[0m')
|
||||||
@@ -492,21 +492,23 @@ def whitelist_list(): # shows the quick-unlock whitelist status of device ids
|
|||||||
def whitelist_manage(): # adds or removes quick-unlock whitelisted device ids
|
def whitelist_manage(): # adds or removes quick-unlock whitelisted device ids
|
||||||
if len(argument_list) == 3:
|
if len(argument_list) == 3:
|
||||||
whitelist_list()
|
whitelist_list()
|
||||||
_device_id = input()
|
_device_id = input('device id: ')
|
||||||
else:
|
else:
|
||||||
_argument_split = argument.split(' ')
|
_argument_split = argument.split(' ')
|
||||||
del _argument_split[:1]
|
del _argument_split[:2]
|
||||||
_device_id = ' '.join(_argument_split)
|
_device_id = ' '.join(_argument_split)
|
||||||
|
|
||||||
if argument_list[2] == 'add':
|
if argument_list[2] == 'add':
|
||||||
if _device_id in listdir(path.expanduser('~/.config/sshyp/devices')):
|
if _device_id in listdir(path.expanduser('~/.config/sshyp/devices')):
|
||||||
open(path.expanduser(f"~/.config/sshyp/whitelist/{_device_id}"), 'w').write('')
|
open(path.expanduser(f"~/.config/sshyp/whitelist/{_device_id}"), 'w').write('')
|
||||||
|
whitelist_list()
|
||||||
else:
|
else:
|
||||||
print(f"\n\u001b[38;5;9merror: device id ({_device_id}) is not registered\u001b[0m\n")
|
print(f"\n\u001b[38;5;9merror: device id ({_device_id}) is not registered\u001b[0m\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
|
|
||||||
elif Path(path.expanduser(f"~/.config/sshyp/whitelist/{_device_id}")).is_file():
|
elif Path(path.expanduser(f"~/.config/sshyp/whitelist/{_device_id}")).is_file():
|
||||||
remove(path.expanduser(f"~/.config/sshyp/whitelist/{_device_id}"))
|
remove(path.expanduser(f"~/.config/sshyp/whitelist/{_device_id}"))
|
||||||
|
whitelist_list()
|
||||||
|
|
||||||
|
|
||||||
def add_entry(): # adds a new entry
|
def add_entry(): # adds a new entry
|
||||||
@@ -765,7 +767,7 @@ if __name__ == "__main__":
|
|||||||
print_info()
|
print_info()
|
||||||
elif argument_list[2] == 'list' or argument_list[2] == '-l':
|
elif argument_list[2] == 'list' or argument_list[2] == '-l':
|
||||||
whitelist_list()
|
whitelist_list()
|
||||||
elif argument_list[2] == 'add' or argument_list[2] == 'delete' or argument_list == 'del':
|
elif argument_list[2] == 'add' or argument_list[2] == 'delete' or argument_list[2] == 'del':
|
||||||
whitelist_manage()
|
whitelist_manage()
|
||||||
elif argument_list[1] == 'add':
|
elif argument_list[1] == 'add':
|
||||||
if len(argument_list) == 2:
|
if len(argument_list) == 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user