[systemd-devel] [RFC][PATCH]user-sessions: order after network.target

Tom Gundersen teg at jklm.no
Sun Oct 14 04:18:05 PDT 2012

It is necessary to terminate remote sessions before shutting down
the network connection. Otherwise, remote sessions might hang.

In particular this is a problem with ssh on Arch [0]. The network
connection might be pulled down before the ssh sessions are terminated.
Moreover, shutting down the sshd daemon does not (and should not)
terminate the corresponding ssh sessions, so ordering ssh itself
After=network.target is not sufficient.

Cc: bisson at archlinux.org

[0]: <https://bugs.archlinux.org/task/31250>

This patch is only an RFC and not meant for inclusion as is. The reason
is that we would like to order the shutdown of user sessions befor the
shutdown of the network. However, also ordering the start of user
sessions after the start of the network is unnecessary, and with
NetworkManager being as slow as it is on startup this will slow down
boot considerably in the common case.

I see two options: split user-sessions into local-user-sessions and
remote-user-sessions and order only the latter After=network.target, or
introduce a new StopBefore= dependency and use that in user-sessions.


 units/systemd-user-sessions.service.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/units/systemd-user-sessions.service.in b/units/systemd-user-sessions.service.in
index 0869e73..54aa660 100644
--- a/units/systemd-user-sessions.service.in
+++ b/units/systemd-user-sessions.service.in
@@ -8,7 +8,7 @@
 Description=Permit User Sessions
+After=remote-fs.target network.target

More information about the systemd-devel mailing list