exec_sandbox 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
data/exec_sandbox.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "exec_sandbox"
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Costan"]
@@ -65,7 +65,18 @@ module Spawn
65
65
  redirected_fds = Set.new redirects.map(&:first)
66
66
  max_fd = LibC.getdtablesize
67
67
  0.upto(max_fd) do |fd|
68
- LibC.close fd unless redirected_fds.include?(fd)
68
+ next if redirected_fds.include?(fd)
69
+
70
+ # TODO(pwnall): this is slow; consider detecting the Ruby version and
71
+ # only running it on buggy MRIs
72
+ begin
73
+ # This fails if rb_reserved_fd_p returns 0.
74
+ # In that case, we shouldn't close the FD, otherwise the VM will crash.
75
+ IO.new(fd)
76
+ rescue ArgumentError, Errno::EBADF
77
+ next
78
+ end
79
+ LibC.close fd
69
80
  end
70
81
  end
71
82
 
@@ -13,8 +13,20 @@ describe ExecSandbox::Spawn do
13
13
  @temp_in.close
14
14
  @temp_out = Tempfile.new 'exec_sandbox_rspec'
15
15
  @temp_out.close
16
+
17
+ # Force-creating a 2nd thread to make MRI 1.9.3 crash without our fix.
18
+ @lock = Mutex.new
19
+ @lock.lock
20
+ Thread.new do
21
+ loop do
22
+ sleep 0.1
23
+ break if @lock.try_lock
24
+ end
25
+ @lock.unlock
26
+ end
16
27
  end
17
28
  after do
29
+ @lock.unlock
18
30
  @temp_in.unlink
19
31
  @temp_out.unlink
20
32
  end
@@ -37,7 +49,8 @@ describe ExecSandbox::Spawn do
37
49
  describe 'with paths' do
38
50
  before do
39
51
  pid = ExecSandbox::Spawn.spawn bin_fixture(:duplicate),
40
- {:in => @temp_in.path, :out => @temp_out.path}
52
+ {:in => @temp_in.path, :out => @temp_out.path,
53
+ :err => @temp_out.path}
41
54
  @status = ExecSandbox::Wait4.wait4 pid
42
55
  end
43
56
 
@@ -11,7 +11,9 @@ File.open(ARGV[0], 'wb') do |f|
11
11
  0.upto(proc_count - 1) do |i|
12
12
  pids[i] = fork do
13
13
  f.write '+'
14
+ f.close
14
15
  sleep 1
16
+ exit
15
17
  end
16
18
  end
17
19
  0.upto(proc_count - 1) { |i| Process.waitpid(pids[i]) }
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,9 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'exec_sandbox'
5
5
 
6
+ # Spawn tests use threads to test against an MRI 1.9.3 crash.
7
+ require 'thread'
8
+
6
9
  # Requires supporting files with custom matchers and macros, etc,
7
10
  # in ./support/ and its subdirectories.
8
11
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exec_sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-09 00:00:00.000000000 Z
12
+ date: 2012-02-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
- requirement: &16244480 !ruby/object:Gem::Requirement
16
+ requirement: &25139320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.11
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16244480
24
+ version_requirements: *25139320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &16243600 !ruby/object:Gem::Requirement
27
+ requirement: &25138680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.10'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *16243600
35
+ version_requirements: *25138680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &16242420 !ruby/object:Gem::Requirement
38
+ requirement: &25138060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *16242420
46
+ version_requirements: *25138060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &16240920 !ruby/object:Gem::Requirement
49
+ requirement: &25137500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.7.5
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *16240920
57
+ version_requirements: *25137500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard-rspec
60
- requirement: &16255360 !ruby/object:Gem::Requirement
60
+ requirement: &25136740 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0.1'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *16255360
68
+ version_requirements: *25136740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &16254280 !ruby/object:Gem::Requirement
71
+ requirement: &25135940 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.21
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *16254280
79
+ version_requirements: *25135940
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &16253700 !ruby/object:Gem::Requirement
82
+ requirement: &25119740 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.8.3
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *16253700
90
+ version_requirements: *25119740
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &16252960 !ruby/object:Gem::Requirement
93
+ requirement: &25119080 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *16252960
101
+ version_requirements: *25119080
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: simplecov
104
- requirement: &16252200 !ruby/object:Gem::Requirement
104
+ requirement: &25117840 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *16252200
112
+ version_requirements: *25117840
113
113
  description: Temporary users and groups, rlimits
114
114
  email: costan@gmail.com
115
115
  executables: []
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  segments:
164
164
  - 0
165
- hash: 3787059974273612193
165
+ hash: -1493873678505410753
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  none: false
168
168
  requirements: