mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 15:26:04 +00:00
Move the Linux runtime to Ubuntu 26.04 LTS with a separate Kubuntu desktop (#1733)
This commit is contained in:
1 parent
5de690ef39
commit
29c83976d0
305 files changed
+9383
-462
No files matched your search
@@ -146,6 +146,49 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
"""
|
||||
|
||||
WRAPPER = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/filter.h>
|
||||
#include <linux/seccomp.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef SYS_openat2
|
||||
#define SYS_openat2 437
|
||||
#endif
|
||||
|
||||
struct how { uint64_t flags, mode, resolve; };
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct sock_filter filter[] = {
|
||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)),
|
||||
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SYS_openat2, 0, 1),
|
||||
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ERRNO | ENOSYS),
|
||||
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
|
||||
};
|
||||
struct sock_fprog prog = {sizeof(filter) / sizeof(filter[0]), filter};
|
||||
if (argc < 3 || prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) || prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) return 3;
|
||||
int (*call)(int, const char *, struct how *, size_t) = (int (*)(int, const char *, struct how *, size_t))dlsym(RTLD_DEFAULT, "openat2");
|
||||
if (!call) return 4;
|
||||
int dir = open(argv[1], O_PATH | O_DIRECTORY | O_CLOEXEC);
|
||||
struct how h = {O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0644, 0x08};
|
||||
int fd = call(dir, argv[2], &h, sizeof(h));
|
||||
if (fd < 0) {
|
||||
printf("ERR %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
printf("OK\n");
|
||||
return close(fd);
|
||||
}
|
||||
"""
|
||||
|
||||
RAW_LOOKUP = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
@@ -326,6 +369,12 @@ class Openat2PreloadTest(unittest.TestCase):
|
||||
LD_PRELOAD="%s:%s" % (cls.lib, cls.tmp / "real/libblfastpath.so")))
|
||||
except subprocess.TimeoutExpired:
|
||||
cls.fex = None
|
||||
wrapper = cls.tmp / "wrapper.c"
|
||||
wrapper.write_text(WRAPPER)
|
||||
subprocess.run(["cc", "-O2", "-Wall", "-Werror", "-o", str(cls.tmp / "wrapper"), str(wrapper), "-ldl"], check=True)
|
||||
(cls.tmp / "extract").mkdir()
|
||||
cls.wrapper = subprocess.run([str(cls.tmp / "wrapper"), str(cls.tmp / "extract"), "file"], capture_output=True,
|
||||
text=True, timeout=20, env=dict(os.environ, LD_PRELOAD=str(cls.lib)))
|
||||
(cls.tmp / "fex-lookup").mkdir()
|
||||
shutil.copy(cls.tmp / "raw_lookup", cls.tmp / "fex-lookup/FEX")
|
||||
try:
|
||||
@@ -373,6 +422,10 @@ class Openat2PreloadTest(unittest.TestCase):
|
||||
self.assertEqual(self.fex.returncode, 0, self.fex.stderr)
|
||||
self.assertEqual(self.fex.stdout, "inside\n")
|
||||
|
||||
def test_the_libc_openat2_wrapper_creates_files_without_openat2(self):
|
||||
self.assertEqual(self.wrapper.returncode, 0, self.wrapper.stdout + self.wrapper.stderr)
|
||||
self.assertTrue((self.tmp / "extract/file").exists())
|
||||
|
||||
def test_the_kernel_agrees(self):
|
||||
if self.kernel is None:
|
||||
self.skipTest("this kernel or sandbox has no openat2")
|
||||
|
||||
Reference in new issue
Block a user