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 +1 -1
- data/exec_sandbox.gemspec +1 -1
- data/lib/exec_sandbox/spawn.rb +12 -1
- data/spec/exec_sandbox/spawn_spec.rb +14 -1
- data/spec/fixtures/fork.rb +2 -0
- data/spec/spec_helper.rb +3 -0
- metadata +21 -21
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/exec_sandbox.gemspec
CHANGED
data/lib/exec_sandbox/spawn.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/spec/fixtures/fork.rb
CHANGED
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.
|
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.
|
12
|
+
date: 2012-02-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
16
|
-
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: *
|
24
|
+
version_requirements: *25139320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
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: *
|
35
|
+
version_requirements: *25138680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
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: *
|
46
|
+
version_requirements: *25138060
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
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: *
|
57
|
+
version_requirements: *25137500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: yard-rspec
|
60
|
-
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: *
|
68
|
+
version_requirements: *25136740
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
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: *
|
79
|
+
version_requirements: *25135940
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
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: *
|
90
|
+
version_requirements: *25119740
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rcov
|
93
|
-
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: *
|
101
|
+
version_requirements: *25119080
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: simplecov
|
104
|
-
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: *
|
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:
|
165
|
+
hash: -1493873678505410753
|
166
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
167
|
none: false
|
168
168
|
requirements:
|