From 07fc59f78d816c4496623cc37026b82fd6b0bed3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 4 Jun 2012 20:45:34 -0700 Subject: [PATCH] Tests for bug #8972 - Add permission checks to run_simple_posix_open_test(). This requires a share with : create mask = 0777 force create mode = 0 directory mask = 0777 force directory mode = 0 set so we don't mess with requested permissions. Autobuild-User: Jeremy Allison Autobuild-Date: Tue Jun 5 08:20:03 CEST 2012 on sn-devel-104 --- source3/torture/torture.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 1fc80fe6a49..08294e6ab7f 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -5402,6 +5402,13 @@ static bool run_simple_posix_open_test(int dummy) goto out; } + /* Ensure st_mode == 0600 */ + if ((sbuf.st_ex_mode & 07777) != 0600) { + printf("posix_open - bad permissions 0%o != 0600\n", + (unsigned int)(sbuf.st_ex_mode & 07777)); + goto out; + } + /* Test ftruncate - set file size back to zero. */ status = cli_ftruncate(cli1, fnum1, 0); if (!NT_STATUS_IS_OK(status)) { @@ -5632,6 +5639,26 @@ static bool run_simple_posix_open_test(int dummy) goto out; } + /* Check directory opens with a specific permission. */ + status = cli_posix_mkdir(cli1, dname, 0700); + if (!NT_STATUS_IS_OK(status)) { + printf("POSIX mkdir of %s failed (%s)\n", dname, nt_errstr(status)); + goto out; + } + + /* Ensure st_mode == 0700 */ + status = cli_posix_stat(cli1, dname, &sbuf); + if (!NT_STATUS_IS_OK(status)) { + printf("stat failed (%s)\n", nt_errstr(status)); + goto out; + } + + if ((sbuf.st_ex_mode & 07777) != 0700) { + printf("posix_mkdir - bad permissions 0%o != 0700\n", + (unsigned int)(sbuf.st_ex_mode & 07777)); + goto out; + } + printf("Simple POSIX open test passed\n"); correct = true; -- 2.11.4.GIT