Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-604

PermissionsTests fail if built on noexec mounted file system (e.g. tmpfs)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Description

      If Commons VFS is compiled on a file system mounted with the noexec flag, e.g. on /tmp with tmpfs, then the PermissionsTests.testExecutable fails:

      Tests run: 90, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.259
      sec <<< FAILURE! - in
      org.apache.commons.vfs2.provider.local.test.LocalProviderTestCase
      testExecutable(org.apache.commons.vfs2.test.PermissionsTests)  Time
      elapsed: 0.011 sec  <<< FAILURE!
      java.lang.AssertionError
          at org.junit.Assert.fail(Assert.java:86)
          at org.junit.Assert.assertTrue(Assert.java:41)
          at org.junit.Assert.assertTrue(Assert.java:52)
          at org.apache.commons.vfs2.test.PermissionsTests.testExecutable(PermissionsTests.java:70)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.commons.vfs2.test.AbstractProviderTestCase.runTest(AbstractProviderTestCase.java:218)
          at junit.framework.TestCase.runBare(TestCase.java:141)
          at junit.framework.TestResult$1.protect(TestResult.java:122)
          at junit.framework.TestResult.runProtected(TestResult.java:142)
          at junit.framework.TestResult.run(TestResult.java:125)
          at junit.framework.TestCase.run(TestCase.java:129)
          at junit.framework.TestSuite.runTest(TestSuite.java:252)
          at junit.framework.TestSuite.run(TestSuite.java:247)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:23)
          at org.apache.commons.vfs2.test.AbstractTestSuite$1.protect(AbstractTestSuite.java:149)
          at junit.framework.TestResult.runProtected(TestResult.java:142)
          at org.apache.commons.vfs2.test.AbstractTestSuite.run(AbstractTestSuite.java:154)
      

      See http://mail-archives.apache.org/mod_mbox/commons-dev/201605.mbox/%3CCAMBJEmVkgqCbnz4BUJ7KpBn_cyTgxgJJiy%3D16dJQxNcyTT_c4w%40mail.gmail.com%3E

      I must admit this is a bit weird - because you ARE allowed to set exec permissions - they just don't work when trying to run.

      stain@biggie:/var/tmp$ echo '#!/bin/cat' > hello
      stain@biggie:/var/tmp$ chmod 755 hello 
      stain@biggie:/var/tmp$ ./hello 
      #!/bin/cat
      
      stain@biggie:/var/tmp$ cd /tmp
      stain@biggie:/tmp$ echo '#!/bin/cat' > hello
      stain@biggie:/tmp$ chmod 755 hello 
      
      stain@biggie:/tmp$ ./hello 
      -bash: ./hello: Permission denied
      
      stain@biggie:/tmp$ ls -al hello 
      -rwxr-xr-x 1 stain stain 11 May  5 10:16 hello
      

      So I don't think Commons VFS is doing something wrong - file.isExecutable() is still false even though setExecutable() (presumably) succeeds - but the test could be improved to check the return values. Unless the signature for isExecutable should read what the file permission is SET as (e.g. replicate ls -al), rather than what the EFFECTIVE permission is (can I execute it?).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              stain Stian Soiland-Reyes
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: