1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-24 19:37:48 +03:00

tests: Ensure the mode of the created file is ...

what we set in open funtion by the argument mode. The mode of the created file
is (mode & ~umask), So we set umask to typical default value(octal 022).

Signed-off-by: renmingshuai <renmingshuai@huawei.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
renmingshuai
2022-08-05 17:08:30 +08:00
committed by Jakub Jelen
parent aa1e136ea3
commit 1286a70e13

View File

@@ -39,6 +39,9 @@
#define TEMPLATE BINARYDIR "/tests/home/alice/temp_dir_XXXXXX"
#define ALICE_HOME BINARYDIR "/tests/home/alice"
/* store the original umask */
mode_t old;
struct scp_st {
struct torture_state *s;
char *tmp_dir;
@@ -99,6 +102,9 @@ static int session_setup(void **state)
s = ts->s;
/* store the original umask and set a new one */
old = umask(0022);
/* Create temporary directory for alice */
tmp_dir = torture_make_temp_dir(TEMPLATE);
assert_non_null(tmp_dir);
@@ -135,6 +141,9 @@ static int session_teardown(void **state)
assert_non_null(ts->s);
s = ts->s;
/* restore the umask */
umask(old);
ssh_disconnect(s->ssh.session);
ssh_free(s->ssh.session);