44d58a
From 1a39666a0dc41d76524001461cd47a19600deaba Mon Sep 17 00:00:00 2001
305396
From: "Alan T. DeKok" <aland@freeradius.org>
305396
Date: Mon, 8 May 2017 16:00:01 -0400
44d58a
Subject: [PATCH] set S_IWUSER when creating the file, not later
305396
305396
(cherry picked from commit 8f53382c64114936a0433d68101a24570783e13a)
305396
---
44d58a
 src/main/tls.c | 4 +---
44d58a
 1 file changed, 1 insertion(+), 3 deletions(-)
305396
305396
diff --git a/src/main/tls.c b/src/main/tls.c
44d58a
index e992062dc..1008e8a51 100644
305396
--- a/src/main/tls.c
305396
+++ b/src/main/tls.c
44d58a
@@ -1382,7 +1382,7 @@ static int cbtls_new_session(SSL *ssl, SSL_SESSION *sess)
305396
 		/* open output file */
305396
 		snprintf(filename, sizeof(filename), "%s%c%s.asn1",
305396
 			 conf->session_cache_path, FR_DIR_SEP, buffer);
305396
-		fd = open(filename, O_RDWR|O_CREAT|O_EXCL, 0600);
305396
+		fd = open(filename, O_RDWR|O_CREAT|O_EXCL, S_IWUSR);
305396
 		if (fd < 0) {
44d58a
 			if (request) RERROR("Session serialisation failed, failed opening session file %s: %s",
44d58a
 					    filename, fr_syserror(errno));
44d58a
@@ -1400,8 +1400,6 @@ static int cbtls_new_session(SSL *ssl, SSL_SESSION *sess)
44d58a
 				fr_pair_value_strcpy(vp, filename);
44d58a
 				fr_pair_add(&request->state, vp);
44d58a
 			}
44d58a
-
44d58a
-			(void) fchmod(fd, S_IWUSR);
44d58a
 		}
44d58a
 
44d58a
 		todo = blob_len;
305396
-- 
305396
2.11.0
305396