698723
From 3eab0f1b64477792bd01ca52c3eb26ce64c5c7ba Mon Sep 17 00:00:00 2001
698723
From: Lennart Poettering <lennart@poettering.net>
698723
Date: Fri, 3 Aug 2018 20:18:55 +0200
698723
Subject: [PATCH] logind: turn of stdio locking when writing session files too
698723
698723
This just copies what we already do for user and seat files to session
698723
files.
698723
698723
(cherry picked from commit 44176400138e18d9087e0864ca97041416a90d47)
698723
698723
Related: #1642460
698723
---
698723
 src/login/logind-session.c | 6 +++---
698723
 1 file changed, 3 insertions(+), 3 deletions(-)
698723
698723
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
698723
index 0afb065b2b..960a24d1a7 100644
698723
--- a/src/login/logind-session.c
698723
+++ b/src/login/logind-session.c
698723
@@ -5,6 +5,7 @@
698723
 #include <linux/kd.h>
698723
 #include <linux/vt.h>
698723
 #include <signal.h>
698723
+#include <stdio_ext.h>
698723
 #include <string.h>
698723
 #include <sys/ioctl.h>
698723
 #include <unistd.h>
698723
@@ -175,9 +176,8 @@ int session_save(Session *s) {
698723
         if (r < 0)
698723
                 goto fail;
698723
 
698723
-        assert(s->user);
698723
-
698723
-        fchmod(fileno(f), 0644);
698723
+        (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
698723
+        (void) fchmod(fileno(f), 0644);
698723
 
698723
         fprintf(f,
698723
                 "# This is private data. Do not parse.\n"