Skip to content

Commit 64242fd

Browse files
committed
core/dbus-service: empty assignment to PIDFile= resets the value
Follow-up for a9353a5.
1 parent c79d66f commit 64242fd

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/core/dbus-service.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -320,32 +320,34 @@ static int bus_service_set_transient_property(
320320
if (r < 0)
321321
return r;
322322

323-
n = path_make_absolute(v, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
324-
if (!n)
325-
return -ENOMEM;
323+
if (!isempty(v)) {
324+
n = path_make_absolute(v, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
325+
if (!n)
326+
return -ENOMEM;
326327

327-
path_simplify(n, true);
328+
path_simplify(n, true);
328329

329-
if (!path_is_normalized(n))
330-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n);
330+
if (!path_is_normalized(n))
331+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n);
331332

332-
e = path_startswith(n, "/var/run/");
333-
if (e) {
334-
char *z;
333+
e = path_startswith(n, "/var/run/");
334+
if (e) {
335+
char *z;
335336

336-
z = strjoin("/run/", e);
337-
if (!z)
338-
return log_oom();
337+
z = strjoin("/run/", e);
338+
if (!z)
339+
return log_oom();
339340

340-
if (!UNIT_WRITE_FLAGS_NOOP(flags))
341-
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);
341+
if (!UNIT_WRITE_FLAGS_NOOP(flags))
342+
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);
342343

343-
free_and_replace(n, z);
344+
free_and_replace(n, z);
345+
}
344346
}
345347

346348
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
347349
free_and_replace(s->pid_file, n);
348-
unit_write_settingf(u, flags, name, "%s=%s", name, s->pid_file);
350+
unit_write_settingf(u, flags, name, "%s=%s", name, strempty(s->pid_file));
349351
}
350352

351353
return 1;

0 commit comments

Comments
 (0)