From e4e3b3052fa6050a796796e22a0c4b52cb7e0835 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 May 2015 10:42:36 +0200 Subject: tests: Apply umask before calling mkstemp() CID: #978660 Signed-off-by: Andreas Schneider --- tests/client/torture_sftp_read.c | 4 +++- tests/unittests/torture_server_x11.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/client/torture_sftp_read.c b/tests/client/torture_sftp_read.c index 6586d49e..eca8a8c6 100644 --- a/tests/client/torture_sftp_read.c +++ b/tests/client/torture_sftp_read.c @@ -45,12 +45,14 @@ static void torture_sftp_read_blocking(void **state) { ssize_t byteswritten; int fd; sftp_file file; - + mode_t mask; file = sftp_open(t->sftp, "/usr/bin/ssh", O_RDONLY, 0); assert_non_null(file); + mask = umask(S_IRWXO | S_IRWXG); fd = mkstemp(libssh_tmp_file); + umask(mask); unlink(libssh_tmp_file); for (;;) { diff --git a/tests/unittests/torture_server_x11.c b/tests/unittests/torture_server_x11.c index 0b86c692..b990b587 100644 --- a/tests/unittests/torture_server_x11.c +++ b/tests/unittests/torture_server_x11.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include "torture.h" @@ -18,13 +20,16 @@ struct hostkey_state { static void setup(void **state) { struct hostkey_state *h; + mode_t mask; h = malloc(sizeof(struct hostkey_state)); assert_non_null(h); h->hostkey_path = strdup("/tmp/libssh_hostkey_XXXXXX"); + mask = umask(S_IRWXO | S_IRWXG); h->fd = mkstemp(h->hostkey_path); + umask(mask); assert_return_code(h->fd, errno); close(h->fd); -- cgit