module main import nspkg.engine import nspkg.tests.archivefixtures import nspkg.tests.signaturefixtures import os fn main() { run() or { eprintln(err) exit(1) } } fn run() ! { if os.args.len != 3 || os.readlink('/proc/self/ns/mnt')! == os.args[2] { return error('requires a private mount namespace') } signaturefixtures.command('mount', ['--make-rprivate', '/'])! base := os.args[1] root := os.join_path(base, 'root') parent := os.join_path(root, 'f') child := os.join_path(parent, 'self') entry := os.join_path(base, 'db', 'local', 'app-1-1') os.mkdir_all(child)! os.mkdir_all(entry)! os.write_file(os.join_path(base, 'db', 'local', 'ALPM_DB_VERSION'), '9\n')! os.write_file(os.join_path(entry, 'desc'), '%DESC%\nInstalled\n\n')! os.write_file(os.join_path(entry, 'files'), '%FILES%\nf/\nf/self/\n\n')! archive := os.join_path(base, 'app.pkg.tar') archivefixtures.write(archive, [ archivefixtures.Entry{ name: '.PKGINFO', text: 'pkgname = app\npkgver = 2-1\n' }, archivefixtures.Entry{ name: 'f', text: 'replacement' }, ], false)! signaturefixtures.command('mount', ['--bind', parent, child])! defer { signaturefixtures.command('umount', [child]) or { eprintln(err) } } mut handle := engine.initialize(root, os.join_path(base, 'db'))! defer { handle.release() or { eprintln(err) } } handle.start_transaction(.no_deps | .no_hooks | .no_scriptlet | .nolock)! defer { handle.release_transaction() or { eprintln(err) } } handle.add_package(handle.load_package(archive, true, 0)!)! assert handle.prepare_transaction()!.success result := handle.check_file_conflicts()! assert !result.success assert result.conflicts.len == 1 assert result.conflicts[0].kind == .filesystem assert os.is_dir(parent) assert os.is_dir(entry) println('native file preflight rejects cyclic bind mounts without mutation') }