-- e2-su set_permissions_2_3 <chroot_path>
local args = string.format("set_permissions_2_3 '%s'",
res.build_config.base)
+ e2tool.set_umask(info)
local rc, re = e2lib.e2_su_2_2(args)
+ e2tool.reset_umask(info)
if not rc then
return false, e:cat(re)
end
-- e2-su extract_tar_2_3 <path> <tartype> <file>
local args = string.format("extract_tar_2_3 '%s' '%s' '%s'",
res.build_config.base, tartype, path)
+ e2tool.set_umask(info)
local rc, re = e2lib.e2_su_2_2(args)
+ e2tool.reset_umask(info)
if not rc then
return false, e:cat(re)
end
local cmd = string.format("%s %s chroot_2_3 '%s' %s",
res.build_config.chroot_call_prefix, e2_su,
res.build_config.base, chroot_command)
+ e2tool.set_umask(info)
os.execute(cmd)
+ e2tool.reset_umask(info)
-- return code depends on user commands. Ignore.
return true, nil
end
e2lib.log(3, "fix permissions")
local args = string.format("chroot_2_3 '%s' chown -R root:root '%s'",
res.build_config.base, res.build_config.Tc)
+ e2tool.set_umask(info)
rc, re = e2lib.e2_su_2_2(args)
+ e2tool.reset_umask(info)
if not rc then
return false, e:cat(re)
end
local args = string.format("chroot_2_3 '%s' chmod -R u=rwX,go=rX '%s'",
res.build_config.base, res.build_config.Tc)
+ e2tool.set_umask(info)
rc, re = e2lib.e2_su_2_2(args)
+ e2tool.reset_umask(info)
if not rc then
return false, e:cat(re)
end
out:write(output)
out:flush()
end
+ e2tool.set_umask(info)
local rc = e2lib.callcmd_capture(cmd, logto)
+ e2tool.reset_umask(info)
out:close()
if rc ~= 0 then
-- XXX e2hook.run_hook(c.info, "build-failure", c, "e2-build")
return true, nil
end
local args = string.format("remove_chroot_2_3 '%s'", res.build_config.base)
+ e2tool.set_umask(info)
local rc, re = e2lib.e2_su_2_2(args)
+ e2tool.reset_umask(info)
if not rc then
return e:cat(re)
end
end
return true, nil
end
+
local e = new_error("reading project configuration")
local info = {}
+
+ -- set the umask value to be used in chroot
+ info.chroot_umask = 18 -- 0022 octal
+ e2tool.init_umask(info)
+
info.root, re = e2lib.locate_project_root(path)
if not info.root then
return false, e:append("you are not located in a project directory")
end
return true, nil
end
+
+--- set umask to value used for build processes
+-- @param info
+function e2tool.set_umask(info)
+ e2lib.logf(4, "setting umask to %04o", info.chroot_umask)
+ e2util.umask(info.chroot_umask)
+end
+
+-- set umask back to the value used on the host
+-- @param info
+function e2tool.reset_umask(info)
+ e2lib.logf(4, "setting umask to %04o", info.host_umask)
+ e2util.umask(info.host_umask)
+end
+
+-- initialize the umask set/reset mechanism (i.e. store the host umask)
+-- @param info
+function e2tool.init_umask(info)
+ -- save the umask value we run with
+ info.host_umask = e2util.umask(022);
+ -- restore the previous umask value again
+ e2util.umask(info.host_umask);
+end