Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-26691

read_only and read_only_sharded suites do not make directories read-only on windows

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.0-rc1
    • Affects Version/s: 3.4.0-rc0
    • Component/s: Storage
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Hide

      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.

      Show
      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.
    • Sharding 2016-10-31

      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
      

            Assignee:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Reporter:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: