Skip to content
Snippets Groups Projects
Commit b1d29440 authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Read ShellUsers from configs and fix /login-name implementation.

parent b65c290c
No related branches found
No related tags found
1 merge request!1Rewrite devkit service in python.
...@@ -38,6 +38,7 @@ DEVKIT_HOOKS_DIR = "/usr/share/steamos-devkit/hooks" ...@@ -38,6 +38,7 @@ DEVKIT_HOOKS_DIR = "/usr/share/steamos-devkit/hooks"
# root until config is loaded and told otherwise, etc. # root until config is loaded and told otherwise, etc.
entry_point_user = "root" entry_point_user = "root"
device_users = []
properties = {} properties = {}
machine_name = '' machine_name = ''
hook_dirs = [] hook_dirs = []
...@@ -145,6 +146,9 @@ class DevkitHandler(BaseHTTPRequestHandler): ...@@ -145,6 +146,9 @@ class DevkitHandler(BaseHTTPRequestHandler):
class DevkitService: class DevkitService:
def __init__(self): def __init__(self):
global entry_point_user
global device_users
self.port = SERVICE_PORT self.port = SERVICE_PORT
if 'Settings' in global_config: if 'Settings' in global_config:
...@@ -157,6 +161,27 @@ class DevkitService: ...@@ -157,6 +161,27 @@ class DevkitService:
if 'Port' in settings: if 'Port' in settings:
self.port = int(settings["Port"]) self.port = int(settings["Port"])
# Parse users from configs
if os.geteuid() == 0:
# Running as root, maybe warn?
print("Running as root, Probably shouldn't be\n")
if 'Users' in global_config:
users = global_config["Users"]
if 'ShellUsers' in users:
device_users = users["ShellUsers"]
else:
if 'Users' in user_config:
users = user_config["Users"]
if 'ShellUsers' in users:
device_users = users["ShellUsers"]
else:
device_users = [os.getlogin()]
# If only one user, that's the entry point user
# Otherwise entry_point_user needs to be root to be able to switch between users
if len(device_users) == 1:
entry_point_user = device_users[0]
self.httpd = socketserver.TCPServer(("", self.port), DevkitHandler, bind_and_activate=False) self.httpd = socketserver.TCPServer(("", self.port), DevkitHandler, bind_and_activate=False)
print("serving at port: {}".format(self.port)) print("serving at port: {}".format(self.port))
print("machine name: {}".format(machine_name)) print("machine name: {}".format(machine_name))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment