diff options
author | Peter Pettersson <boretrk@hotmail.com> | 2022-01-14 23:25:27 +0100 |
---|---|---|
committer | Peter Pettersson <boretrk@hotmail.com> | 2022-01-14 23:29:21 +0100 |
commit | 8d54822269fbfcc85419df6d099ce62a789d187c (patch) | |
tree | 567cafec32bd8f04224c327c2df11a54e64e5cde | |
parent | e2e3f3e4cde7871f86eabacc6a639439b70a8fc7 (diff) | |
download | libgit2-8d54822269fbfcc85419df6d099ce62a789d187c.tar.gz |
tests: verify that futils_mktmp respects umask
-rw-r--r-- | tests/core/futils.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/core/futils.c b/tests/core/futils.c index b87ea183b..3501765f6 100644 --- a/tests/core/futils.c +++ b/tests/core/futils.c @@ -87,3 +87,29 @@ void test_core_futils__recursive_rmdir_keeps_symlink_targets(void) cl_must_pass(p_rmdir("dir-target")); cl_must_pass(p_unlink("file-target")); } + +void test_core_futils__mktmp_umask(void) +{ +#ifdef GIT_WIN32 + cl_skip(); +#else + git_str path = GIT_STR_INIT; + struct stat st; + int fd; + + umask(0); + cl_assert((fd = git_futils_mktmp(&path, "foo", 0777)) >= 0); + cl_must_pass(p_fstat(fd, &st)); + cl_assert_equal_i(st.st_mode & 0777, 0777); + cl_must_pass(p_unlink(path.ptr)); + close(fd); + + umask(077); + cl_assert((fd = git_futils_mktmp(&path, "foo", 0777)) >= 0); + cl_must_pass(p_fstat(fd, &st)); + cl_assert_equal_i(st.st_mode & 0777, 0700); + cl_must_pass(p_unlink(path.ptr)); + close(fd); + git_str_dispose(&path); +#endif +} |