mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
tests: Add umask() around mkstemp()
CID 1391450 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define LIBSSH_STATIC
|
#define LIBSSH_STATIC
|
||||||
#include <libssh/priv.h>
|
#include <libssh/priv.h>
|
||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
@ -20,13 +22,16 @@ static int setup_knownhosts_file(void **state)
|
|||||||
char *tmp_file = NULL;
|
char *tmp_file = NULL;
|
||||||
size_t nwritten;
|
size_t nwritten;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
mode_t mask;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
tmp_file = strdup(TMP_FILE_NAME);
|
tmp_file = strdup(TMP_FILE_NAME);
|
||||||
assert_non_null(tmp_file);
|
assert_non_null(tmp_file);
|
||||||
*state = tmp_file;
|
*state = tmp_file;
|
||||||
|
|
||||||
|
mask = umask(S_IRWXO | S_IRWXG);
|
||||||
fd = mkstemp(tmp_file);
|
fd = mkstemp(tmp_file);
|
||||||
|
umask(mask);
|
||||||
assert_return_code(fd, errno);
|
assert_return_code(fd, errno);
|
||||||
|
|
||||||
fp = fdopen(fd, "w");
|
fp = fdopen(fd, "w");
|
||||||
|
Reference in New Issue
Block a user