fhs-userenv: Make it work on kernel < 3.19 cc @abbradar

It may not be very secure, but I think it's better to make it work
with older kernel since 3.19 is not the default on nixos.
This commit is contained in:
Luca Bruno 2015-03-10 18:11:25 +01:00
parent 7711446298
commit b1adfeb23d

@ -79,7 +79,11 @@ if $cpid == 0
$unshare.call CLONE_NEWNS | CLONE_NEWUSER
# Map users and groups to the parent namespace
write_file '/proc/self/setgroups', 'deny'
begin
# setgroups is only available since Linux 3.19
write_file '/proc/self/setgroups', 'deny'
rescue
end
write_file '/proc/self/uid_map', "#{uid} #{uid} 1"
write_file '/proc/self/gid_map', "#{gid} #{gid} 1"