From c7b87b0d51dd1d1a8629832daecd060b5d316123 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 27 Mar 2019 08:36:25 -0700 Subject: [PATCH] fs: add test for copyfile() respecting permissions Add test to test-fs-copyfile.c to check that uv_fs_copyfile() respects destination file permissions. Previously, in macOS, it did not. PR-URL: https://github.com/libuv/libuv/pull/2233 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: Sakthipriyan Vairamani --- test/test-fs-copyfile.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test-fs-copyfile.c b/test/test-fs-copyfile.c index 7b6511c9..cd8a2ea7 100644 --- a/test/test-fs-copyfile.c +++ b/test/test-fs-copyfile.c @@ -185,6 +185,17 @@ TEST_IMPL(fs_copyfile) { if (r == 0) handle_result(&req); +#ifndef _WIN32 + /* Copying respects permissions/mode. */ + unlink(dst); + touch_file(dst, 0); + chmod(dst, S_IRUSR|S_IRGRP|S_IROTH); /* Sets file mode to 444 (read-only). */ + r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); + ASSERT(req.result == UV_EACCES); + ASSERT(r == UV_EACCES); + uv_fs_req_cleanup(&req); +#endif + unlink(dst); /* Cleanup */ return 0; }