Blob Blame History Raw
From 040f67302cea64b294ddfa2c46b7571b202ac16d Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Mon, 12 May 2014 21:26:54 +0200
Subject: [PATCH] core: sysvcompat - $network should be equivalent to
 network-online, rather than network target
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Most likely the  facility needed is actual connectivity, rather than whether or not the
network managment daemon is running.

We also need to explicitly pull in the network-online.target, as it is not active by
default.

This means {systemd-networkd,NetworkManager}-wait-online.service, can be enabled by default
as part of network-online.target, and only delay boot when some service actively pulls it in.

See: <https://bugzilla.gnome.org/show_bug.cgi?id=728965>

Cc: Pavel Šimerda <psimerda@redhat.com>
Cc: Michal Sekletar <msekleta@redhat.com>
(cherry picked from commit 0404c609f399b2092a3de52eef9d75b0dc12e94c)
(cherry picked from commit 81d4159e6eadb34c25a5643ad95730da2f6f2d69)
---
 src/core/service.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/core/service.c b/src/core/service.c
index c8dbbeff1b..3bda9a37d6 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -359,7 +359,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char
         static const char * const table[] = {
                 /* LSB defined facilities */
                 "local_fs",             NULL,
-                "network",              SPECIAL_NETWORK_TARGET,
+                "network",              SPECIAL_NETWORK_ONLINE_TARGET,
                 "named",                SPECIAL_NSS_LOOKUP_TARGET,
                 "portmap",              SPECIAL_RPCBIND_TARGET,
                 "remote_fs",            SPECIAL_REMOTE_FS_TARGET,
@@ -828,7 +828,11 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         if (r == 0)
                                                 continue;
 
-                                        r = unit_add_dependency_by_name(u, startswith_no_case(t, "X-Start-Before:") ? UNIT_BEFORE : UNIT_AFTER, m, NULL, true);
+                                        if (streq(m, SPECIAL_NETWORK_ONLINE_TARGET) && !startswith_no_case(t, "X-Start-Before:"))
+                                                /* the network-online target is special, as it needs to be actively pulled in */
+                                                r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_WANTS, m, NULL, true);
+                                        else
+                                                r = unit_add_dependency_by_name(u, startswith_no_case(t, "X-Start-Before:") ? UNIT_BEFORE : UNIT_AFTER, m, NULL, true);
 
                                         if (r < 0)
                                                 log_error_unit(u->id, "[%s:%u] Failed to add dependency on %s, ignoring: %s",