From: Lennart Poettering Date: Mon, 19 May 2025 09:07:53 +0000 (+0200) Subject: machine: use the correct escaping calls for machine metadata X-Git-Tag: v258-rc1~481^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b9c91843155045e9933fe93d36b2fdd207891f2;p=thirdparty%2Fsystemd.git machine: use the correct escaping calls for machine metadata --- diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index efe40c70f5b..f49713597a8 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -10,7 +10,6 @@ #include "cgroup-util.h" #include "dirent-util.h" #include "env-file.h" -#include "escape.h" #include "extract-word.h" #include "fd-util.h" #include "format-util.h" @@ -837,20 +836,7 @@ _public_ int sd_session_get_class(const char *session, char **class) { } _public_ int sd_session_get_desktop(const char *session, char **desktop) { - _cleanup_free_ char *escaped = NULL; - int r; - ssize_t l; - - assert_return(desktop, -EINVAL); - - r = session_get_string(session, "DESKTOP", &escaped); - if (r < 0) - return r; - - l = cunescape(escaped, 0, desktop); - if (l < 0) - return l; - return 0; + return session_get_string(session, "DESKTOP", desktop); } _public_ int sd_session_get_display(const char *session, char **display) { diff --git a/src/machine/machine.c b/src/machine/machine.c index fb397362b15..0d5818439d1 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -180,36 +180,12 @@ int machine_save(Machine *m) { "NAME=%s\n", m->name); - if (m->unit) { - _cleanup_free_ char *escaped = NULL; - - escaped = cescape(m->unit); - if (!escaped) - return log_oom(); - - 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) { - _cleanup_free_ char *escaped = NULL; + /* We continue to call this "SCOPE=" because it is internal only, and we want to stay compatible with old files */ + env_file_fputs_assignment(f, "SCOPE=", m->unit); + env_file_fputs_assignment(f, "SCOPE_JOB=", m->scope_job); - escaped = cescape(m->service); - if (!escaped) - return log_oom(); - fprintf(f, "SERVICE=%s\n", escaped); - } - - if (m->root_directory) { - _cleanup_free_ char *escaped = NULL; - - escaped = cescape(m->root_directory); - if (!escaped) - return log_oom(); - fprintf(f, "ROOT=%s\n", escaped); - } + env_file_fputs_assignment(f, "SERVICE=", m->service); + env_file_fputs_assignment(f, "ROOT=", m->root_directory); if (!sd_id128_is_null(m->id)) fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id));