glacier-ng 4.0.0

This commit is contained in:
lw-everestlinux committed 2026-10-29 09:15:34 -04:00
commit 0cf4829fa5
159 files changed
+33717

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
-- test_exdev.lua
--
-- Verifies gl_commit_transaction detects and rejects a cross-filesystem
-- commit instead of failing partway through the rename sequence. Rather
-- than trust that the check is "probably fine", this actually mounts a
-- tmpfs over /glacier/usr/<uid>/stage so the filesystem mismatch is real, not
-- simulated.
--
-- Requires CAP_SYS_ADMIN (root) to call mount()/umount2() — expected to
-- be running as root inside the test container.
local glacier = require("glacier_ffi")
local h = require("test_helpers")
h.reset_glacier_root()
local uid = 1002
io.write("== test_exdev (uid " .. uid .. ") ==\n")
if tonumber(glacier.C.geteuid()) ~= 0 then
io.write(" SKIP - not running as root, can't mount(); " ..
"run this test as root inside the container\n")
os.exit(0)
end
glacier.lib.gl_init_user(uid, false)
local stage = "/glacier/usr/" .. uid .. "/stage"
h.sh("mkdir -p " .. stage)
local mnt_rc = glacier.C.mount("tmpfs", stage, "tmpfs", 0, "size=16m")
if tonumber(mnt_rc) ~= 0 then
local why = glacier.strerror()
io.write(" SKIP - mount() failed: " .. why .. "\n")
io.write(" This is very likely the container's seccomp profile blocking " ..
"the mount syscall, not a bug under test.\n" ..
" Re-run the container with --cap-add=SYS_ADMIN (or --privileged) " ..
"to actually exercise this test.\n")
os.exit(0)
end
h.check(true, "tmpfs mounted on " .. stage)
local ctx = glacier.new_context()
local st = glacier.lib.gl_init_stage_context(ctx, glacier.SCOPE_USR, uid)
-- Two places can catch it, both correct: stage seeding hardlinks live
-- into the stage and link() fails EXDEV (init returns GL_TXN_ERR_XDEV),
-- or — if live had nothing to seed — commit's own same-fs check does.
-- What must never happen is a different error, or a partial commit.
if tonumber(st) == 0 then
local commit = glacier.lib.gl_commit_transaction(ctx)
h.check(tonumber(commit) == 8, -- GL_TXN_ERR_XDEV
"commit across filesystems is rejected with GL_TXN_ERR_XDEV: got " ..
glacier.txn_name(commit))
glacier.lib.gl_abort_transaction(ctx)
else
h.check(tonumber(st) == 8, -- GL_TXN_ERR_XDEV
"stage on a different fs is rejected at init with GL_TXN_ERR_XDEV: got " ..
glacier.txn_name(st))
end
h.check(not h.exists("/glacier/usr/" .. uid .. "/store/core"),
"live store was NOT mutated by the rejected transaction")
h.check(h.exists("/glacier/usr/" .. uid .. "/index/current"),
"live index still intact")
glacier.C.umount2(stage, 0)
h.summary()