From 56889fe2babafd5e8afc224af2c7c76c1c5cbeed Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Tue, 29 Sep 2026 15:04:07 -0400 Subject: [PATCH 1/2] fix: let Flatpak create its repo where Android denies hard links --- tools/proot/PATCHES.md | 4 + .../0011-android-hardlink-denial.patch | 82 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tools/proot/patches/0011-android-hardlink-denial.patch diff --git a/tools/proot/PATCHES.md b/tools/proot/PATCHES.md index 6a0d99e0e0..7edd963838 100644 --- a/tools/proot/PATCHES.md +++ b/tools/proot/PATCHES.md @@ -51,3 +51,7 @@ Added for Flatpak: answer `ENOSYS`. They take paths proot never translated, so libglnx's `open_tree(AT_FDCWD, "/")` handed Flatpak a descriptor for the host's root and it tried to create directories there (`mkdirat(root): Operation not permitted`); unsupported, libglnx falls back to `openat`. +- `0011-android-hardlink-denial.patch` - Android's SELinux policy denies apps hard links, so + `linkat` fails with `EACCES` and Flatpak could not create its repo (`Creating repo: linkat: + Permission denied`). `O_TMPFILE` answers `EOPNOTSUPP`, so libglnx writes a named temporary file + and renames it, and a denied link answers `EPERM`, on which ostree's checkout copies instead. diff --git a/tools/proot/patches/0011-android-hardlink-denial.patch b/tools/proot/patches/0011-android-hardlink-denial.patch new file mode 100644 index 0000000000..e2d089fb31 --- /dev/null +++ b/tools/proot/patches/0011-android-hardlink-denial.patch @@ -0,0 +1,82 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: DroidDeck +Date: Tue, 29 Sep 2026 15:00:00 -0400 +Subject: [PATCH] syscall: work around Android's denial of hard links + +SELinux denies apps the file link permission, so linkat fails with +EACCES. libostree names its O_TMPFILE files with linkat and failed to +create the Flathub repo ("Creating repo: linkat: Permission denied"). +O_TMPFILE now answers EOPNOTSUPP, so libglnx falls back to a named +temporary file and a rename, and a denied link answers EPERM, which +ostree's checkout takes as a filesystem without hard links and copies. +--- +diff --git a/src/syscall/enter.c b/src/syscall/enter.c +index 8c3eb2e..4c28e10 100644 +--- a/src/syscall/enter.c ++++ b/src/syscall/enter.c +@@ -400,6 +400,13 @@ int translate_syscall_enter(Tracee *tracee) + + case PR_open: + flags = peek_reg(tracee, CURRENT, SYSARG_2); ++#ifdef __ANDROID__ ++ /* An O_TMPFILE file can only be named by linkat, which Android denies apps. */ ++ if ((flags & __O_TMPFILE) != 0) { ++ status = -EOPNOTSUPP; ++ break; ++ } ++#endif + + if ( ((flags & O_NOFOLLOW) != 0) + || ((flags & O_EXCL) != 0 && (flags & O_CREAT) != 0)) +@@ -518,6 +525,12 @@ int translate_syscall_enter(Tracee *tracee) + case PR_openat: + dirfd = peek_reg(tracee, CURRENT, SYSARG_1); + flags = peek_reg(tracee, CURRENT, SYSARG_3); ++#ifdef __ANDROID__ ++ if ((flags & __O_TMPFILE) != 0) { ++ status = -EOPNOTSUPP; ++ break; ++ } ++#endif + + status = get_sysarg_path(tracee, path, SYSARG_2); + if (status < 0) +diff --git a/src/syscall/exit.c b/src/syscall/exit.c +index df41084..5d981db 100644 +--- a/src/syscall/exit.c ++++ b/src/syscall/exit.c +@@ -544,6 +544,16 @@ void translate_syscall_exit(Tracee *tracee) + status = handle_statx_syscall(tracee, false); + break; + ++#ifdef __ANDROID__ ++ /* Android denies apps hard links with EACCES; EPERM is what callers such as ++ * libostree take as "no hard links here" and copy instead. */ ++ case PR_link: ++ case PR_linkat: ++ if ((int) syscall_result == -EACCES) ++ poke_reg(tracee, SYSARG_RESULT, -EPERM); ++ goto end; ++#endif ++ + case PR_ioctl: + if (peek_reg(tracee, ORIGINAL, SYSARG_2) == _IOW(0x94, 9, int) /* FICLONE */ && + (int) peek_reg(tracee, CURRENT, SYSARG_RESULT) == -EACCES) { +diff --git a/src/syscall/seccomp.c b/src/syscall/seccomp.c +index 6d1ba47..8db9f45 100644 +--- a/src/syscall/seccomp.c ++++ b/src/syscall/seccomp.c +@@ -362,8 +362,13 @@ static FilteredSysnum proot_sysnums[] = { + { PR_lchown, 0 }, + { PR_lchown32, 0 }, + { PR_lgetxattr, 0 }, ++#ifdef __ANDROID__ ++ { PR_link, FILTER_SYSEXIT }, ++ { PR_linkat, FILTER_SYSEXIT }, ++#else + { PR_link, 0 }, + { PR_linkat, 0 }, ++#endif + { PR_listxattr, 0 }, + { PR_llistxattr, 0 }, + { PR_lremovexattr, 0 }, From 29dc88dce12aa2177082caa6a8bd3098d565b2d9 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Tue, 29 Sep 2026 15:23:29 -0400 Subject: [PATCH 2/2] fix: point store commands at the current network's DNS --- .../main/java/com/droiddeck/launcher/runtime/GuestCommand.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 7d3c6ecd32..6bc9a54a52 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -36,6 +36,8 @@ object GuestCommand { val root = LinuxRuntime.rootDir(context) LinuxRuntime.writeAccounts(context) SessionFiles.stage(context, root) + // The resolver otherwise names the DNS of whatever network the last session was on. + LinuxNetworkLinkComponent(context, root).publish() val runtimeDir = File(context.filesDir, ".flatpak-rt").apply { mkdirs() } val cmd = LinuxRuntime.prootPrefix(context, root, "/root", fakeRoot) LinuxRuntime.binds(context, null, runtimeDir, Environment.getExternalStorageDirectory(), null)