mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09: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:
committed by
Jakub Jelen
parent
aa1e136ea3
commit
1286a70e13
@@ -39,6 +39,9 @@
|
|||||||
#define TEMPLATE BINARYDIR "/tests/home/alice/temp_dir_XXXXXX"
|
#define TEMPLATE BINARYDIR "/tests/home/alice/temp_dir_XXXXXX"
|
||||||
#define ALICE_HOME BINARYDIR "/tests/home/alice"
|
#define ALICE_HOME BINARYDIR "/tests/home/alice"
|
||||||
|
|
||||||
|
/* store the original umask */
|
||||||
|
mode_t old;
|
||||||
|
|
||||||
struct scp_st {
|
struct scp_st {
|
||||||
struct torture_state *s;
|
struct torture_state *s;
|
||||||
char *tmp_dir;
|
char *tmp_dir;
|
||||||
@@ -99,6 +102,9 @@ static int session_setup(void **state)
|
|||||||
|
|
||||||
s = ts->s;
|
s = ts->s;
|
||||||
|
|
||||||
|
/* store the original umask and set a new one */
|
||||||
|
old = umask(0022);
|
||||||
|
|
||||||
/* Create temporary directory for alice */
|
/* Create temporary directory for alice */
|
||||||
tmp_dir = torture_make_temp_dir(TEMPLATE);
|
tmp_dir = torture_make_temp_dir(TEMPLATE);
|
||||||
assert_non_null(tmp_dir);
|
assert_non_null(tmp_dir);
|
||||||
@@ -135,6 +141,9 @@ static int session_teardown(void **state)
|
|||||||
assert_non_null(ts->s);
|
assert_non_null(ts->s);
|
||||||
s = ts->s;
|
s = ts->s;
|
||||||
|
|
||||||
|
/* restore the umask */
|
||||||
|
umask(old);
|
||||||
|
|
||||||
ssh_disconnect(s->ssh.session);
|
ssh_disconnect(s->ssh.session);
|
||||||
ssh_free(s->ssh.session);
|
ssh_free(s->ssh.session);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user