1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

Merge pull request #11663 from yuwata/follow-up-10712

core: make PIDFile= accept empty assignment
This commit is contained in:
Lennart Poettering 2019-02-07 14:46:35 +01:00 committed by GitHub
commit a4a1d59f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 16 deletions

View 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;
}

View 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);