summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-06-04 20:45:34 -0700
committerJeremy Allison <jra@samba.org>2012-06-05 08:20:03 +0200
commit07fc59f78d816c4496623cc37026b82fd6b0bed3 (patch)
tree4badaac0ef629c59c83f84c5672a7dca6931de40
parent27bb01691ca71854ba146fb62b1114e6b612f562 (diff)
downloadsamba-07fc59f78d816c4496623cc37026b82fd6b0bed3.tar.gz
samba-07fc59f78d816c4496623cc37026b82fd6b0bed3.tar.bz2
samba-07fc59f78d816c4496623cc37026b82fd6b0bed3.zip
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 <jra@samba.org> Autobuild-Date: Tue Jun 5 08:20:03 CEST 2012 on sn-devel-104
-rw-r--r--source3/torture/torture.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 1fc80fe6a4..08294e6ab7 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;