mirror of
https://github.com/systemd/systemd.git
synced 2025-02-25 21:57:32 +03:00
machine: escape fields we store in /run, so that they can be properly unescaped by parse_env_file()
This commit is contained in:
parent
5052e3996d
commit
ca5405bb4f
Notes:
Lennart Poettering
2014-05-22 22:00:53 +09:00
Backport: bugfix
@ -123,17 +123,42 @@ int machine_save(Machine *m) {
|
|||||||
"NAME=%s\n",
|
"NAME=%s\n",
|
||||||
m->name);
|
m->name);
|
||||||
|
|
||||||
if (m->unit)
|
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 */
|
_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)
|
if (m->scope_job)
|
||||||
fprintf(f, "SCOPE_JOB=%s\n", m->scope_job);
|
fprintf(f, "SCOPE_JOB=%s\n", m->scope_job);
|
||||||
|
|
||||||
if (m->service)
|
if (m->service) {
|
||||||
fprintf(f, "SERVICE=%s\n", m->service);
|
_cleanup_free_ char *escaped;
|
||||||
|
|
||||||
if (m->root_directory)
|
escaped = cescape(m->service);
|
||||||
fprintf(f, "ROOT=%s\n", m->root_directory);
|
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))
|
if (!sd_id128_equal(m->id, SD_ID128_NULL))
|
||||||
fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id));
|
fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user