|
The call to "attrib" to make directories read-only on windows in jstests/readonly/libs/read_only_test.js always fails in the read_only, read_only_WT, read_only_sharded, and read_only_sharded_WT tasks on Windows 2008R2 DEBUG.
Here is one example from a recent commit:
https://logkeeper.mongodb.org/build/32685fadce92b4a9aea6e5d3209d1a52/test/580686ffbe07c46acf0581a8#L184
This is because the use of "attrib" on the following lines is incorrect:
This use of "attrib" fails even directly on the command line on Windows 2008R2:
$ mkdir testdir
|
$ ls -oh
|
drwxrwxr-x+ 1 Administrator 0 Oct 18 21:50 testdir
|
$ attrib +r testdir /s
|
File not found - testdir <-------------
|
A minimal fix is to instead do "attrib +r <dir>/*.* /s"
$ mkdir testdir
|
# Create a regular file, subdirectory, and regular file in the subdirectory
|
$ touch testdir/foo
|
$ mkdir testdir/subdir
|
$ touch testdir/subdir/subfoo
|
# Make all *regular* files in the base directory read-only
|
$ attrib +r testdir/*.* /s
|
$ echo "bar" > testdir/foo
|
-bash: testdir/foo: Permission denied
|
$ echo "bar" > testdir/subdir/subfoo
|
-bash: testdir/subdir/subfoo: Permission denied
|
Note that if the directory does not contain any regular files, this "attrib" command will fail:
$ mkdir testdir
|
# No files were added to testdir
|
$ attrib +r testdir/*.* /s
|
File not found - testdir/*.*
|
Also note that new files, new subdirectories, and new files in those new subdirectories can still be created even after making all existing regular files in the directory read-only:
$ mkdir testdir
|
$ touch testdir/foo
|
$ attrib +r testdir/*.* /s
|
# New regular file "foo2" can be created
|
$ touch testdir/foo2
|
$ ls testdir
|
foo foo2
|
# New subdirectory "subdir" can be created
|
$ mkdir testdir/subdir
|
$ ls testdir
|
foo foo2 subdir
|
# New regular file "subfoo" in the new subdirectory can be created
|
$ touch testdir/subdir/subfoo
|
$ ls testdir/subdir
|
subfoo
|
|