mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Don't use sudo for everything
We are running as root, and will rely on dropping privs via systemd rather than sudo
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
"""
|
||||
Wraps systemctl to install, uninstall, start & stop systemd services.
|
||||
|
||||
We use sudo + subprocess calls for everything. This works when we
|
||||
are running as root & as normal user (with arbitrary sudo privileges).
|
||||
Arbitrary sudo privileges suck, but are better than running the whole
|
||||
process as root.
|
||||
|
||||
If we use a debian package instead, we can get rid of all this code.
|
||||
"""
|
||||
import subprocess
|
||||
@@ -19,7 +14,6 @@ def reload_daemon():
|
||||
Makes systemd discover new units.
|
||||
"""
|
||||
subprocess.run([
|
||||
'sudo',
|
||||
'systemctl',
|
||||
'daemon-reload'
|
||||
], check=True)
|
||||
@@ -30,7 +24,6 @@ def install_unit(name, unit, path='/etc/systemd/system'):
|
||||
Install unit wih given name
|
||||
"""
|
||||
subprocess.run([
|
||||
'sudo',
|
||||
'tee',
|
||||
os.path.join(path, name)
|
||||
], input=unit.encode('utf-8'), check=True)
|
||||
@@ -41,7 +34,6 @@ def uninstall_unit(name, path='/etc/systemd/system'):
|
||||
Uninstall unit with given name
|
||||
"""
|
||||
subprocess.run([
|
||||
'sudo',
|
||||
'rm',
|
||||
os.path.join(path, name)
|
||||
], check=True)
|
||||
@@ -52,7 +44,6 @@ def start_service(name):
|
||||
Start service with given name.
|
||||
"""
|
||||
subprocess.run([
|
||||
'sudo',
|
||||
'systemctl',
|
||||
'start',
|
||||
name
|
||||
|
||||
Reference in New Issue
Block a user