shell

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 568b396b41daeb5d8a4d8be06c243f3695c7c16f
parent e65fe41a77cdb9958924a30fbfc7bb0e22d8d7e9
Author: flupe <flupe@sbi.re>
Date:   Thu, 18 Nov 2021 00:11:54 +0100

using filesystem instead of json for creds

Diffstat:
Mshell.py | 13++++++++-----
Dusers.json | 22----------------------
Ausers/calvin/MBP.pub | 1+
Ausers/ismael/MBP.pub | 1+
Ausers/lucas/poule.pub | 2++
Ausers/peio/radon.pub | 1+
6 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/shell.py b/shell.py @@ -6,10 +6,11 @@ import subprocess import shlex import json import cmd +from os.path import basename, splitext, isfile, isdir, join import policy -CREDS = os.path.expanduser('~/users.json') +USERS = os.path.expanduser('~/users') def die(msg, status=1): sys.stderr.write(msg) @@ -71,10 +72,12 @@ def do_git_upload_archive(user, cmd, args): def do_keys(user, cmd, args): sys.stdout.write('You currently allow the following SSH keys:\n') - with open(CREDS) as raw_users: - users = json.load(raw_users) - for key in users[user]: - sys.stdout.write('%s: %s\n' % (key["name"], key["key"])) + for path in os.listdir(os.path.join(USERS, user)): + abs_path = join(USERS, user, path) + if not isfile(abs_path): continue + with open(abs_path) as key: + key_name, _ = splitext(path) + sys.stdout.write('%s: %s\n' % (key_name, key.read())) def do_help(user, cmd, args): sys.stdout.write('Need help?\n') diff --git a/users.json b/users.json @@ -1,22 +0,0 @@ -{ - "lucas": [ - { "name": "poule", - "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN7XQaZEw/l4wpVSr+GYmJpHV/fJf9HSRLRQ8e8DgwCA flupe@poule" - } - ], - "peio": [ - { "name": "radon", - "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHo/Xr6JMf/69E2MN412uIsVHkCTw0mJnKO5870AIQKv radon" - } - ], - "calvin": [ - { "name": "MPB", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgVALGKVRimLHpkRdkRRqk1BSHnjxe0I56E6jFTrqBRfPWFlVCde7J5yL+/ie0X5CbOOKOWQJDGxklxFyRNiP6RgA+0YlWxJD7NjTt1j5EWVtJxK5qJS3VQUZIrlDnmWsSQrLjnR+3/4Oy33ZDQ90qK2Fqf2EJ0EVatI/HSeh4bNvBNxH9s1dcb9re3wPXlMt2f7ePAwcFp9qVvKclwYxeK7cBfvdSzbaY+UmXk5C2JNXq5vWQ3jBNciSb5OCXnMQ1ybOuudGzIEzbFP1e/D8vX+NZ/tSFKvx1mvm/XAPWyrkarckyvSX0AYyGHlCcHAY3MiGtda5n41lWf9boLiB/dXHS7bt5lfYWfU5hSgtS85e822sfJ4M8GVXyl4KZwr1HobRtTolDCLKXZMcNKBHg8a6QgLWcWkSboVTz31VTcJA49t76icBjXC8Ad+Z9cgB0OK5H20fZxZVJ/HmPrpZwaQDoTKZxYzw6LvjZv5laFoQ/jLfZ47IRNSslvHnIoSU= calvin@MBP-de-Calvin" - } - ], - "ismael": [ - { "name": "MBP", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDbZVQHpuVUg8wBAFVzb/n4HrleUX4P7gyCL6wYU1cxSW5CFELDYuEz/3VfrhkjW43ymK8IGB8zibxMYthgTeVtE2BVnIvsNoa8iBlmMBqfnxY7kb5WSE/3KYMkOLJxcPJ6LRZxXP30dE43SGJ6N3FakDmkI+26Yi0tpcAbasmWc4WNg96Pqq84fZyIkYnJ6mRhq+oBHojdLmUwL6fuByaPlWNNAbMp1sSLFw1MBiWHRQ7ieoJyJxhl0c4V6JXzcJO6cdMl3HAwvkWMVbNwWkVJxfXYu6YlfavijW5m0yAEZq14fXWtg4MSPMJxd9LAAuEktoPzy17vVmJSbt4YXFxz plop@MBP-de-Ismael" - } - ] -} diff --git a/users/calvin/MBP.pub b/users/calvin/MBP.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgVALGKVRimLHpkRdkRRqk1BSHnjxe0I56E6jFTrqBRfPWFlVCde7J5yL+/ie0X5CbOOKOWQJDGxklxFyRNiP6RgA+0YlWxJD7NjTt1j5EWVtJxK5qJS3VQUZIrlDnmWsSQrLjnR+3/4Oy33ZDQ90qK2Fqf2EJ0EVatI/HSeh4bNvBNxH9s1dcb9re3wPXlMt2f7ePAwcFp9qVvKclwYxeK7cBfvdSzbaY+UmXk5C2JNXq5vWQ3jBNciSb5OCXnMQ1ybOuudGzIEzbFP1e/D8vX+NZ/tSFKvx1mvm/XAPWyrkarckyvSX0AYyGHlCcHAY3MiGtda5n41lWf9boLiB/dXHS7bt5lfYWfU5hSgtS85e822sfJ4M8GVXyl4KZwr1HobRtTolDCLKXZMcNKBHg8a6QgLWcWkSboVTz31VTcJA49t76icBjXC8Ad+Z9cgB0OK5H20fZxZVJ/HmPrpZwaQDoTKZxYzw6LvjZv5laFoQ/jLfZ47IRNSslvHnIoSU= calvin@MBP-de-Calvin diff --git a/users/ismael/MBP.pub b/users/ismael/MBP.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDbZVQHpuVUg8wBAFVzb/n4HrleUX4P7gyCL6wYU1cxSW5CFELDYuEz/3VfrhkjW43ymK8IGB8zibxMYthgTeVtE2BVnIvsNoa8iBlmMBqfnxY7kb5WSE/3KYMkOLJxcPJ6LRZxXP30dE43SGJ6N3FakDmkI+26Yi0tpcAbasmWc4WNg96Pqq84fZyIkYnJ6mRhq+oBHojdLmUwL6fuByaPlWNNAbMp1sSLFw1MBiWHRQ7ieoJyJxhl0c4V6JXzcJO6cdMl3HAwvkWMVbNwWkVJxfXYu6YlfavijW5m0yAEZq14fXWtg4MSPMJxd9LAAuEktoPzy17vVmJSbt4YXFxz plop@MBP-de-Ismael diff --git a/users/lucas/poule.pub b/users/lucas/poule.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN7XQaZEw/l4wpVSr+GYmJpHV/fJf9HSRLRQ8e8DgwCA flupe@poule +\ No newline at end of file diff --git a/users/peio/radon.pub b/users/peio/radon.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHo/Xr6JMf/69E2MN412uIsVHkCTw0mJnKO5870AIQKv radon