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;
}
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);
if (curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L) != CURLE_OK)
return -EIO;
- *ret = c;
+ *ret = TAKE_PTR(c);
return 0;
}
assert(ret);
u = strdup(url);
- if (u)
+ if (!u)
return -ENOMEM;
j = new(PullJob, 1);
* 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) {
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
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)
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()
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()