summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-05-22 10:35:28 +0900
committerLennart Poettering <lennart@poettering.net>2014-05-22 10:36:16 +0900
commit558c6490b1df7f82a63d0a747fda7412c4d28b0c (patch)
tree3e95a5f95b457cd5fe7f40372b150d745344f9bf
parenteaa3b74dfd6395c8abaa8416d90dac5e0dc00e15 (diff)
logind: also escape external data when saving to /run
Better be safe than sorry...
-rw-r--r--src/login/logind-session.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 9a54101301..fdeacb150a 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -213,7 +213,6 @@ int session_save(Session *s) {
if (s->scope)
fprintf(f, "SCOPE=%s\n", s->scope);
-
if (s->scope_job)
fprintf(f, "SCOPE_JOB=%s\n", s->scope_job);
@@ -229,17 +228,54 @@ int session_save(Session *s) {
if (s->display)
fprintf(f, "DISPLAY=%s\n", s->display);
- if (s->remote_host)
- fprintf(f, "REMOTE_HOST=%s\n", s->remote_host);
+ if (s->remote_host) {
+ _cleanup_free_ char *escaped;
+
+ escaped = cescape(s->remote_host);
+ if (!escaped) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ fprintf(f, "REMOTE_HOST=%s\n", escaped);
+ }
+
+ if (s->remote_user) {
+ _cleanup_free_ char *escaped;
+
+ escaped = cescape(s->remote_user);
+ if (!escaped) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ fprintf(f, "REMOTE_USER=%s\n", escaped);
+ }
+
+ if (s->service) {
+ _cleanup_free_ char *escaped;
- if (s->remote_user)
- fprintf(f, "REMOTE_USER=%s\n", s->remote_user);
+ escaped = cescape(s->service);
+ if (!escaped) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ fprintf(f, "SERVICE=%s\n", escaped);
+ }
- if (s->service)
- fprintf(f, "SERVICE=%s\n", s->service);
+ if (s->desktop) {
+ _cleanup_free_ char *escaped;
- if (s->desktop)
- fprintf(f, "DESKTOP=%s\n", s->desktop);
+
+ escaped = cescape(s->desktop);
+ if (!escaped) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ fprintf(f, "DESKTOP=%s\n", escaped);
+ }
if (s->seat && seat_has_vts(s->seat))
fprintf(f, "VTNR=%u\n", s->vtnr);