X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fmachine%2Fmachine.c;h=a49cf81906039799b949ed61e76c7a4c455eac42;hb=9a0549093332880df47c4218209ce126b8586835;hp=9a5cc9a63c4eb1f017d0c8a2196c14ec6ce9c833;hpb=de58a50e24a0d55e3bbcc77f8f6170a7322acf52;p=elogind.git diff --git a/src/machine/machine.c b/src/machine/machine.c index 9a5cc9a63..a49cf8190 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -123,17 +123,42 @@ int machine_save(Machine *m) { "NAME=%s\n", m->name); - if (m->unit) - fprintf(f, "SCOPE=%s\n", m->unit); /* We continue to call this "SCOPE=" because it is internal only, and we want to stay compatible with old files */ + if (m->unit) { + _cleanup_free_ char *escaped; + + escaped = cescape(m->unit); + if (!escaped) { + r = -ENOMEM; + goto finish; + } + + fprintf(f, "SCOPE=%s\n", escaped); /* We continue to call this "SCOPE=" because it is internal only, and we want to stay compatible with old files */ + } if (m->scope_job) fprintf(f, "SCOPE_JOB=%s\n", m->scope_job); - if (m->service) - fprintf(f, "SERVICE=%s\n", m->service); + if (m->service) { + _cleanup_free_ char *escaped; - if (m->root_directory) - fprintf(f, "ROOT=%s\n", m->root_directory); + escaped = cescape(m->service); + if (!escaped) { + r = -ENOMEM; + goto finish; + } + fprintf(f, "SERVICE=%s\n", escaped); + } + + if (m->root_directory) { + _cleanup_free_ char *escaped; + + escaped = cescape(m->root_directory); + if (!escaped) { + r = -ENOMEM; + goto finish; + } + fprintf(f, "ROOT=%s\n", escaped); + } if (!sd_id128_equal(m->id, SD_ID128_NULL)) fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id)); @@ -303,7 +328,7 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) { log_struct(LOG_INFO, MESSAGE_ID(SD_MESSAGE_MACHINE_START), "NAME=%s", m->name, - "LEADER=%lu", (unsigned long) m->leader, + "LEADER="PID_FMT, m->leader, "MESSAGE=New machine %s.", m->name, NULL); @@ -350,7 +375,7 @@ int machine_stop(Machine *m) { log_struct(LOG_INFO, MESSAGE_ID(SD_MESSAGE_MACHINE_STOP), "NAME=%s", m->name, - "LEADER=%lu", (unsigned long) m->leader, + "LEADER="PID_FMT, m->leader, "MESSAGE=Machine %s terminated.", m->name, NULL);