]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #11655 from yuwata/fix-11652
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Feb 2019 14:01:31 +0000 (15:01 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Feb 2019 14:01:31 +0000 (15:01 +0100)
sd-device: fix device_copy_properties()

src/core/dbus-service.c
src/core/load-fragment.c
src/import/curl-util.c
src/import/pull-job.c
src/libsystemd/sd-daemon/sd-daemon.c
test/test-execute/exec-privatenetwork-yes.service
test/test-network/systemd-networkd-tests.py

index ec61ea2772f8651ef7389fc9409b3ed6f17c2a63..0904cc09c020e8ec536d2d9c30568d365234601f 100644 (file)
@@ -320,29 +320,35 @@ static int bus_service_set_transient_property(
                 if (r < 0)
                         return r;
 
-                n = path_make_absolute(v, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
-                if (!n)
-                        return -ENOMEM;
+                if (!isempty(v)) {
+                        n = path_make_absolute(v, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
+                        if (!n)
+                                return -ENOMEM;
 
-                path_simplify(n, true);
+                        path_simplify(n, true);
 
-                if (!path_is_normalized(n))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n);
+                        if (!path_is_normalized(n))
+                                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n);
 
-                e = path_startswith(n, "/var/run/");
-                if (e) {
-                        char *z;
+                        e = path_startswith(n, "/var/run/");
+                        if (e) {
+                                char *z;
 
-                        z = strjoin("/run/", e);
-                        if (!z)
-                                return log_oom();
+                                z = strjoin("/run/", e);
+                                if (!z)
+                                        return log_oom();
 
-                        if (!UNIT_WRITE_FLAGS_NOOP(flags))
-                                log_unit_notice(u, "Transient unit's PIDFile= property references path below legacy directory /var/run, updating %s → %s; please update client accordingly.", n, z);
+                                if (!UNIT_WRITE_FLAGS_NOOP(flags))
+                                        log_unit_notice(u, "Transient unit's PIDFile= property references path below legacy directory /var/run, updating %s → %s; please update client accordingly.", n, z);
 
-                        free_and_replace(s->pid_file, z);
-                } else
+                                free_and_replace(n, z);
+                        }
+                }
+
+                if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
                         free_and_replace(s->pid_file, n);
+                        unit_write_settingf(u, flags, name, "%s=%s", name, strempty(s->pid_file));
+                }
 
                 return 1;
         }
index 159e8d5050857f58288245b5c3cf837e7a9ed171..44f00a30460b10ae166969c7448fa9157be42248 100644 (file)
@@ -4254,6 +4254,12 @@ int config_parse_pid_file(
         assert(rvalue);
         assert(u);
 
+        if (isempty(rvalue)) {
+                /* An empty assignment removes already set value. */
+                *s = mfree(*s);
+                return 0;
+        }
+
         r = unit_full_printf(u, rvalue, &k);
         if (r < 0) {
                 log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue);
index 360628fe440a753fbd59f61b1ae873f5e9976bbd..7db03b291916524cd30ec9456cf154f18e54b2ca 100644 (file)
@@ -291,7 +291,7 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) {
         if (curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L) != CURLE_OK)
                 return -EIO;
 
-        *ret = c;
+        *ret = TAKE_PTR(c);
         return 0;
 }
 
index a44e0a7eda9e305b4f6290cee36a4d89950ccd68..6881bd627f30453af52357621ddb07fefced6c7b 100644 (file)
@@ -537,7 +537,7 @@ int pull_job_new(PullJob **ret, const char *url, CurlGlue *glue, void *userdata)
         assert(ret);
 
         u = strdup(url);
-        if (u)
+        if (!u)
                 return -ENOMEM;
 
         j = new(PullJob, 1);
index 218210f234b49932f344d64fb49db27bf948e9b6..9e8f0a73f57c2825c084bf54163e5f39a844fa98 100644 (file)
@@ -604,7 +604,13 @@ _public_ int sd_booted(void) {
          * created. This takes place in mount-setup.c, so is
          * guaranteed to happen very early during boot. */
 
-        return laccess("/run/systemd/system/", F_OK) >= 0;
+        if (laccess("/run/systemd/system/", F_OK) >= 0)
+                return true;
+
+        if (errno == ENOENT)
+                return false;
+
+        return -errno;
 }
 
 _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {
index ded8d5512636cbe4ac3cc0c919c9a862c8bb7a26..8f5cbadf0408aa7d37541289a4091c6693c44895 100644 (file)
@@ -2,6 +2,6 @@
 Description=Test for PrivateNetwork
 
 [Service]
-ExecStart=/bin/sh -x -c '! ip link | grep ": " | grep -Ev ": (lo|(sit0|ip6tnl0|ip6gre0)@.*):"'
+ExecStart=/bin/sh -x -c '! ip link | grep -E "^[0-9]+: " | grep -Ev ": (lo|(erspan|gre|gretap|ip_vti|ip6_vti|ip6gre|ip6tnl|sit|tunl)0@.*):"'
 Type=oneshot
 PrivateNetwork=yes
index 6e3bcf5df128d6aed83da3428383fc12b47e9808..29bd08906cccb81df8724c21cd043bc8a65b5a8d 100755 (executable)
@@ -47,6 +47,28 @@ def expectedFailureIfERSPANModuleIsNotAvailable():
 
     return f
 
+def expectedFailureIfRoutingPolicyPortRangeIsNotAvailable():
+    def f(func):
+        rc = subprocess.call(['ip', 'rule', 'add', 'from', '192.168.100.19', 'sport', '1123-1150', 'dport', '3224-3290', 'table', '7'])
+        if rc == 0:
+            subprocess.call(['ip', 'rule', 'del', 'from', '192.168.100.19', 'sport', '1123-1150', 'dport', '3224-3290', 'table', '7'])
+            return func
+        else:
+            return unittest.expectedFailure(func)
+
+    return f
+
+def expectedFailureIfRoutingPolicyIPProtoIsNotAvailable():
+    def f(func):
+        rc = subprocess.call(['ip', 'rule', 'add', 'not', 'from', '192.168.100.19', 'ipproto', 'tcp', 'table', '7'])
+        if rc == 0:
+            subprocess.call(['ip', 'rule', 'del', 'not', 'from', '192.168.100.19', 'ipproto', 'tcp', 'table', '7'])
+            return func
+        else:
+            return unittest.expectedFailure(func)
+
+    return f
+
 def setUpModule():
 
     os.makedirs(network_unit_file_path, exist_ok=True)
@@ -653,6 +675,7 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities):
 
         subprocess.call(['ip', 'rule', 'del', 'table', '7'])
 
+    @expectedFailureIfRoutingPolicyPortRangeIsNotAvailable()
     def test_routing_policy_rule_port_range(self):
         self.copy_unit_to_networkd_unit_path('25-fibrule-port-range.network', '11-dummy.netdev')
         self.start_networkd()
@@ -670,6 +693,7 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities):
 
         subprocess.call(['ip', 'rule', 'del', 'table', '7'])
 
+    @expectedFailureIfRoutingPolicyIPProtoIsNotAvailable()
     def test_routing_policy_rule_invert(self):
         self.copy_unit_to_networkd_unit_path('25-fibrule-invert.network', '11-dummy.netdev')
         self.start_networkd()