Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      MacOS, Linux
    • Number of attachments :
      0

      Description

      When running with root access rights, temp dirs cannot be deleted.

      require 'tmpdir'

      Dir.mktmpdir do |d|
      p d
      end

      Run fine as simple user, but as root.

      sh-3.2# jruby foo.rb
      "/tmp/d20110331-37927-ntr68q"
      Errno::EACCES: Permission denied - /tmp/d20110331-37927-ntr68q/.
      initialize at org/jruby/RubyFile.java:434
      open at org/jruby/RubyIO.java:1116
      remove_entry_secure at /opt/jruby/lib/ruby/1.8/fileutils.rb:699
      mktmpdir at /opt/jruby/lib/ruby/1.8/tmpdir.rb:131
      (root) at foo.rb:4

      (same with sudo)

        Issue Links

          Activity

          Hide
          Hiroshi Nakamura added a comment -

          I once introduced the upstream change to master but CI tells that some tests from CRuby directly calls Dir.mktmpdir and FileUtils.remove_entry_secure, so tmpdir.rb needs to create tmpdir at non-world-writable directory regardless of stickey bit. Hmm.

          Show
          Hiroshi Nakamura added a comment - I once introduced the upstream change to master but CI tells that some tests from CRuby directly calls Dir.mktmpdir and FileUtils.remove_entry_secure, so tmpdir.rb needs to create tmpdir at non-world-writable directory regardless of stickey bit. Hmm.
          Hide
          Hiroshi Nakamura added a comment -

          Closing this issue because the root problem is gone. Syncing with CRuby's lib is different issue and should be solved when other problem happens.

          Show
          Hiroshi Nakamura added a comment - Closing this issue because the root problem is gone. Syncing with CRuby's lib is different issue and should be solved when other problem happens.
          Hide
          Joseph Palermo added a comment -

          I'm confused, and still getting the error on 1.6.8.

          In order for this to work I need to override the TMPDIR to point to something that is not world writable?

          Show
          Joseph Palermo added a comment - I'm confused, and still getting the error on 1.6.8. In order for this to work I need to override the TMPDIR to point to something that is not world writable?
          Hide
          David Kellum added a comment -

          Hey, I know I'm very late to this party but I am seeing this now for unprivileged user on jruby 1.6.8, but not 1.7.10. That's great that is not an issue on 1.7 but I would like my code to remain compatible with 1.6.8 (--1.9 mode). Is there any known workaround for this on that version?

          Show
          David Kellum added a comment - Hey, I know I'm very late to this party but I am seeing this now for unprivileged user on jruby 1.6.8, but not 1.7.10. That's great that is not an issue on 1.7 but I would like my code to remain compatible with 1.6.8 (--1.9 mode). Is there any known workaround for this on that version?
          Hide
          David Kellum added a comment -

          OK, FWIW, The following appears to be a sufficient workaround for me:

              # Just like Dir.mktmpdir but with an attempt to workaround a jruby
              # 1.6.x bug.
              def mktmpdir( prefix )
                old_env_tmpdir = nil
                if defined?( JRUBY_VERSION ) && JRUBY_VERSION =~ /^1.6/
                  old_env_tmpdir = ENV['TMPDIR']
                  newdir = "/tmp/syncwrap.#{ENV['USER']}"
                  FileUtils.mkdir_p( newdir, :mode => 0700 )
                  ENV['TMPDIR'] = newdir
                end
                Dir.mktmpdir( 'syncwrap' ) do |tmp_dir|
                  yield tmp_dir
                end
              ensure
                ENV['TMPDIR'] = old_env_tmpdir if old_env_tmpdir
              end
          

          <grumble>
          If only this was fixed in a jruby 1.6.9.... release support of comparable quality to MRI.

          Hmm, how long before you pull the plug on jruby 1.7? First release of jruby 9_000?
          </grumble>

          Show
          David Kellum added a comment - OK, FWIW, The following appears to be a sufficient workaround for me: # Just like Dir.mktmpdir but with an attempt to workaround a jruby # 1.6.x bug. def mktmpdir( prefix ) old_env_tmpdir = nil if defined?( JRUBY_VERSION ) && JRUBY_VERSION =~ /^1.6/ old_env_tmpdir = ENV['TMPDIR'] newdir = "/tmp/syncwrap.#{ENV['USER']}" FileUtils.mkdir_p( newdir, :mode => 0700 ) ENV['TMPDIR'] = newdir end Dir.mktmpdir( 'syncwrap' ) do |tmp_dir| yield tmp_dir end ensure ENV['TMPDIR'] = old_env_tmpdir if old_env_tmpdir end <grumble> If only this was fixed in a jruby 1.6.9.... release support of comparable quality to MRI. Hmm, how long before you pull the plug on jruby 1.7? First release of jruby 9_000? </grumble>

            People

            • Assignee:
              Hiroshi Nakamura
              Reporter:
              lucas dicioccio
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: