fix: Chromium browsers start on the desktop (#1280)

A process's status read for another process is served read-only, so
Chromium's ReadOnlyFile check no longer kills the browser. Chromium-based
AppImages without chrome-sandbox get --no-sandbox, and Flathub Chromium and
Electron apps skip zypak's spawn portal, which cannot work here.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-21 18:17:07 -04:00
1 parent a0dbdd6b9a
commit 8b40bb5c88
5 files changed
+72 -12

No files matched your search

+28 -10
View File
@@ -22,15 +22,17 @@ static const char *skip_digits(const char *s) {
return end == s ? NULL : end;
}
static int is_status_path(const char *path) {
static long status_pid(const char *path) {
const char *rest;
if (path == NULL || strncmp(path, "/proc/", 6) != 0) return 0;
long pid = 0;
if (path == NULL || strncmp(path, "/proc/", 6) != 0) return -1;
path += 6;
if (strncmp(path, "self/", 5) == 0) rest = path + 4;
else if (strncmp(path, "thread-self/", 12) == 0) rest = path + 11;
else if ((rest = skip_digits(path)) == NULL) return 0;
if (strncmp(rest, "/task/", 6) == 0 && (rest = skip_digits(rest + 6)) == NULL) return 0;
return strcmp(rest, "/status") == 0;
else if ((rest = skip_digits(path)) == NULL) return -1;
else pid = strtol(path, NULL, 10);
if (strncmp(rest, "/task/", 6) == 0 && (rest = skip_digits(rest + 6)) == NULL) return -1;
return strcmp(rest, "/status") == 0 ? pid : -1;
}
static int is_web_helper(const void *caller) {
@@ -56,13 +58,26 @@ static int write_all(int fd, const char *data, size_t len) {
return 0;
}
static int read_only_copy(const char *data, size_t len, int flags) {
char path[] = "/tmp/.droiddeck-status-XXXXXX";
int rw = mkostemp(path, O_CLOEXEC);
if (rw < 0) return -1;
int ro = -1;
if (write_all(rw, data, len) == 0)
ro = (int)syscall(SYS_openat, AT_FDCWD, path, O_RDONLY | (flags & O_CLOEXEC));
unlink(path);
close(rw);
return ro;
}
__attribute__((visibility("hidden"))) int bl_status_without_tracer(const char *path, int flags, const void *caller) {
char text[STATUS_MAX];
size_t len = 0;
int saved = errno;
int out = -1;
if ((flags & O_ACCMODE) != O_RDONLY || !is_status_path(path) || is_web_helper(caller)) return -1;
long pid;
if ((flags & O_ACCMODE) != O_RDONLY || (pid = status_pid(path)) < 0 || is_web_helper(caller)) return -1;
int in = (int)syscall(SYS_openat, AT_FDCWD, path, O_RDONLY | O_CLOEXEC);
if (in < 0) goto done;
for (;;) {
@@ -78,13 +93,16 @@ __attribute__((visibility("hidden"))) int bl_status_without_tracer(const char *p
if (field == NULL) goto done;
char *value = field + strlen(TRACER_FIELD);
char *line_end = strchr(value, '\n');
if (line_end == NULL) goto done;
if (line_end == NULL || line_end == value) goto done;
memmove(value + 1, line_end, len - (size_t)(line_end - text) + 1);
*value = '0';
len = (size_t)(value + 1 - text) + strlen(value + 1);
if (pid != 0 && pid != getpid() && (out = read_only_copy(text, len, flags)) >= 0) goto done;
out = memfd_create("status", (flags & O_CLOEXEC) ? MFD_CLOEXEC : 0);
if (out < 0) goto done;
if (write_all(out, text, (size_t)(value - text)) != 0 || write_all(out, "0", 1) != 0
|| write_all(out, line_end, len - (size_t)(line_end - text)) != 0
|| lseek(out, 0, SEEK_SET) != 0) {
if (write_all(out, text, len) != 0 || lseek(out, 0, SEEK_SET) != 0) {
close(out);
out = -1;
}