Skip to content

Commit

Permalink
Switched to Ruby 1.9 hash syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnall committed Feb 5, 2014
1 parent 7b0cdec commit 8fe1711
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/exec_sandbox/sandbox.rb
Expand Up @@ -26,7 +26,7 @@ def initialize(admin)
@destroyed = false

# principal argument for Spawn.spawn()
@principal = { :uid => @user_uid, :gid => @user_gid, :dir => @path }
@principal = { uid: @user_uid, gid: @user_gid, dir: @path }
end

# Copies a file or directory to the sandbox.
Expand Down
2 changes: 1 addition & 1 deletion lib/exec_sandbox/wait4.rb
Expand Up @@ -13,7 +13,7 @@ def self.wait4(pid)
rusage = ExecSandbox::Wait4::Rusage.new
returned_pid = LibC.wait4(pid, status_ptr, 0, rusage.pointer)
raise SystemCallError, FFI.errno if returned_pid < 0
status = { :bits => status_ptr.read_int }
status = { bits: status_ptr.read_int }
status_ptr.free

signal_code = status[:bits] & 0x7f
Expand Down
14 changes: 7 additions & 7 deletions spec/exec_sandbox/sandbox_spec.rb
Expand Up @@ -17,8 +17,8 @@
describe 'duplicate.rb' do
before do
ExecSandbox.use do |s|
@result = s.run bin_fixture(:duplicate), :in => @temp_in.path,
:out => @temp_out.path
@result = s.run bin_fixture(:duplicate), in: @temp_in.path,
out: @temp_out.path
end
end

Expand All @@ -34,8 +34,8 @@
describe 'count.rb' do
before do
ExecSandbox.use do |s|
@result = s.run [bin_fixture(:count), '9'], :in => @temp_in.path,
:out => @temp_out.path, :err => :out
@result = s.run [bin_fixture(:count), '9'], in: @temp_in.path,
out: @temp_out.path, err: :out
end
end

Expand All @@ -53,7 +53,7 @@
describe 'duplicate.rb' do
before do
ExecSandbox.use do |s|
@result = s.run bin_fixture(:duplicate), :in_data => "Pipe test\n"
@result = s.run bin_fixture(:duplicate), in_data: "Pipe test\n"
end
end

Expand Down Expand Up @@ -86,7 +86,7 @@
describe 'count.rb' do
before do
ExecSandbox.use do |s|
@result = s.run [bin_fixture(:count), '9'], :err => :out
@result = s.run [bin_fixture(:count), '9'], err: :out
end
end

Expand Down Expand Up @@ -136,7 +136,7 @@
before do
ExecSandbox.use do |s|
@result = s.run [bin_fixture(:churn), 'stdout', 3.to_s],
:limits => {:cpu => 1}
limits: {cpu: 1}
s.pull 'stdout', @temp_out.path
end
end
Expand Down
44 changes: 22 additions & 22 deletions spec/exec_sandbox/spawn_spec.rb
Expand Up @@ -49,8 +49,8 @@
describe 'with paths' do
before do
pid = ExecSandbox::Spawn.spawn bin_fixture(:duplicate),
{:in => @temp_in.path, :out => @temp_out.path,
:err => @temp_out.path}
{in: @temp_in.path, out: @temp_out.path,
err: @temp_out.path}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -62,7 +62,7 @@
File.open(@temp_in.path, 'r') do |in_io|
File.open(@temp_out.path, 'w') do |out_io|
pid = ExecSandbox::Spawn.spawn bin_fixture(:duplicate),
{:in => in_io, :out => out_io, :err => STDERR}
{in: in_io, out: out_io, err: STDERR}
@status = ExecSandbox::Wait4.wait4 pid
end
end
Expand All @@ -74,7 +74,7 @@
describe 'without stdout' do
before do
pid = ExecSandbox::Spawn.spawn bin_fixture(:duplicate),
{:in => @temp_in.path}
{in: @temp_in.path}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand Down Expand Up @@ -103,7 +103,7 @@
File.open(@temp_in.path, 'r') do |in_io|
File.open(@temp_out.path, 'w') do |out_io|
pid = ExecSandbox::Spawn.spawn [bin_fixture(:count), '9'],
{:in => in_io, :out => out_io, :err => STDOUT}
{in: in_io, out: out_io, err: STDOUT}
@status = ExecSandbox::Wait4.wait4 pid
end
end
Expand All @@ -126,8 +126,8 @@
describe 'with root credentials' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:write_arg),
@temp_path, "Spawn uid test\n"], {:err => STDERR},
{:uid => 0, :gid => 0}
@temp_path, "Spawn uid test\n"], {err: STDERR},
{uid: 0, gid: 0}
@status = ExecSandbox::Wait4.wait4 pid
@fstat = File.stat(@temp_path)
end
Expand All @@ -152,8 +152,8 @@
before do
@temp.unlink
pid = ExecSandbox::Spawn.spawn [bin_fixture(:write_arg),
@temp_path, "Spawn uid test\n"], {:err => STDERR},
{:uid => test_uid, :gid => test_gid}
@temp_path, "Spawn uid test\n"], {err: STDERR},
{uid: test_uid, gid: test_gid}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -178,7 +178,7 @@
File.chmod 0700, @temp_path
pid = ExecSandbox::Spawn.spawn [bin_fixture(:write_arg),
@temp_path, "Spawn uid test\n"], {},
{:uid => test_uid, :gid => test_gid}
{uid: test_uid, gid: test_gid}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -196,7 +196,7 @@
File.chmod 070, @temp_path
pid = ExecSandbox::Spawn.spawn [bin_fixture(:write_arg), @temp_path,
"Spawn uid test\n"], {},
{:uid => test_uid, :gid => test_gid}
{uid: test_uid, gid: test_gid}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -213,7 +213,7 @@
before do
@temp_dir = Dir.mktmpdir 'exec_sandbox_rspec'
pid = ExecSandbox::Spawn.spawn [bin_fixture(:pwd), @temp_path],
{}, {:dir => @temp_dir}
{}, {dir: @temp_dir}
@status = ExecSandbox::Wait4.wait4 pid
end
after do
Expand Down Expand Up @@ -244,7 +244,7 @@
describe 'without limitations' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:buffer), @temp_path,
(512 * 1024 * 1024).to_s], {:err => STDERR}, {}, {}
(512 * 1024 * 1024).to_s], {err: STDERR}, {}, {}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -260,7 +260,7 @@
describe 'with 256mb memory limitation' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:buffer), @temp_path,
(512 * 1024 * 1024).to_s], {}, {}, {:data => 256 * 1024 * 1024}
(512 * 1024 * 1024).to_s], {}, {}, {data: 256 * 1024 * 1024}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -277,7 +277,7 @@
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:buffer), @temp_path,
(512 * 1024 * 1024).to_s], {}, {},
{:file_size => 64 * 1024 * 1024}
{file_size: 64 * 1024 * 1024}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand Down Expand Up @@ -305,7 +305,7 @@
describe 'without limitations' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:buffer), @temp_path,
(128 * 1024 * 1024).to_s], {:err => STDERR}, {}, {}
(128 * 1024 * 1024).to_s], {err: STDERR}, {}, {}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -315,7 +315,7 @@
describe 'with 256mb memory limitation' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:buffer), @temp_path,
(128 * 1024 * 1024).to_s], {}, {}, {:data => 256 * 1024 * 1024}
(128 * 1024 * 1024).to_s], {}, {}, {data: 256 * 1024 * 1024}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -326,7 +326,7 @@
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:buffer), @temp_path,
(128 * 1024 * 1024).to_s], {}, {},
{:file_size => 256 * 1024 * 1024}
{file_size: 256 * 1024 * 1024}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -339,7 +339,7 @@
describe 'without limitations' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:fork), @temp_path,
10.to_s], {:err => STDERR}, {}, {}
10.to_s], {err: STDERR}, {}, {}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -355,7 +355,7 @@
describe 'with sub-process limitation' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:fork), @temp_path,
10.to_s], {}, {}, {:processes => 4}
10.to_s], {}, {}, {processes: 4}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -373,7 +373,7 @@
describe 'without limitations' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:churn), @temp_path,
3.to_s], {:err => STDERR}, {}, {}
3.to_s], {err: STDERR}, {}, {}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand All @@ -393,7 +393,7 @@
describe 'with CPU time limitation' do
before do
pid = ExecSandbox::Spawn.spawn [bin_fixture(:churn), @temp_path,
10.to_s], {}, {}, {:cpu => 1}
10.to_s], {}, {}, {cpu: 1}
@status = ExecSandbox::Wait4.wait4 pid
end

Expand Down

0 comments on commit 8fe1711

Please sign in to comment.