Use systemd unit files for disabling the remote access#3336
Use systemd unit files for disabling the remote access#3336
Conversation
102aa3e to
7ccedd4
Compare
7ccedd4 to
40d54f9
Compare
|
So long story short, we have "systemd.mask=agama-web-server-remote.service systemd.wants=agama-web-server-local.service" instead of simple "inst.listen_on=local" because someone might want to disable sshd and they would have to use "systemd.mask". |
|
🤷♂️ |
|
I was originally envisioning something like: Consistent with the SSH case and easy to remember. As it is currently in this pull request, I find it to be cumbersome (too detailed, too long and not memorable enough). Moreover, it defeats a bit the purpose of been symmetric to disabling ssh. To be honest, I think I would prefer to use that "hidden magic" at alternative 2 (we can always find a better implementation over time) than to force the user to use a combination of two different boot arguments. On the other hand, I got an honest question - can we simplify the name of the service(s)? |
Problem
inst.listen_onboot option to disable remote access to the server looks inconsistent (for disabling the SSH access you can use thesystemd.mask=sshd.serviceboot option)Solution
agama-web-server-localandagama-web-server-remoteservicessystemd.mask=agama-web-server-remote.service systemd.wants=agama-web-server-local.serviceboot parameters.Testing
The default behavior (no boot option specified): the local service is inactive, the remote service is running.
With the
systemd.mask=agama-web-server-remote.service systemd.wants=agama-web-server-local.serviceboot options the remote service is inactive and the local service is running:Notes
I tried several approaches but either they did not work or were a bit hacky:
BeforeandAfterso the remote service starts first and the conflict should block the local service from running. Disabling the remote service allows running the local service automatically.The problem was that there is probably some race condition and sometimes the local service was actually running instead of the remote by default. I tried several changes but nothing helped.
ExecConditionattribute). But that feels a bit hacky and it is a hidden magic.systemd.maskoption you can also enable a disabled service using thesystemd.wantsparameter. So instead of enabling both services enable only the default remote one. The users then can explicitly disable the remote service and enable the local one using thesystemd.mask=agama-web-server-remote.service systemd.wants=agama-web-server-local.serviceboot options. That's a bit more complicated but does not use any hidden magic.