2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Process.initgroups" do
|
2019-09-09 07:24:03 -04:00
|
|
|
platform_is_not :windows, :android do
|
2018-01-10 08:30:25 -05:00
|
|
|
as_user do
|
|
|
|
it "initializes the supplemental group access list" do
|
|
|
|
name = `id -un`.strip
|
|
|
|
groups = Process.groups
|
|
|
|
gid = groups.max.to_i + 1
|
|
|
|
augmented_groups = `id -G`.scan(/\d+/).map {|i| i.to_i} << gid
|
|
|
|
if Process.uid == 0
|
|
|
|
Process.groups = []
|
|
|
|
Process.initgroups(name, gid).sort.should == augmented_groups.sort
|
|
|
|
Process.groups.sort.should == augmented_groups.sort
|
|
|
|
Process.groups = groups
|
|
|
|
else
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM)
|
2018-01-10 08:30:25 -05:00
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|