[SERVER-26691] read_only and read_only_sharded suites do not make directories read-only on windows Created: 18/Oct/16  Updated: 19/Nov/16  Resolved: 19/Oct/16

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 3.4.0-rc0
Fix Version/s: 3.4.0-rc1

Type: Bug Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: Esha Maharishi (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Look for lines like

[js_test:aggregate] 2016-10-18T20:33:08.046+0000 2016-10-18T20:33:08.046+0000 I -        [main] shell: started program (sh3484):  attrib.exe +r \data\db\job0\mongorunner/mongod-20010 /s
[js_test:aggregate] 2016-10-18T20:33:08.049+0000 sh3484| File not found - \data\db\job0\mongorunner/mongod-20010

in any run of the read_only or read_only_sharded suites on a Windows variant.

Sprint: Sharding 2016-10-31
Participants:

 Description   

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



 Comments   
Comment by Githook User [ 19/Oct/16 ]

Author:

{u'username': u'EshaMaharishi', u'name': u'Esha Maharishi', u'email': u'esha.maharishi@mongodb.com'}

Message: SERVER-26691 read_only and read_only_sharded suites do not make directories read-only on windows
Branch: master
https://github.com/mongodb/mongo/commit/f4d1637a254075c82f6b2a390c31d290819376db

Generated at Thu Feb 08 04:12:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.