mirror of
https://github.com/vectras-team/termux-x11.git
synced 2024-11-30 10:20:53 +00:00
Fixing MIT-SHM in proot-distro
This commit is contained in:
parent
d0c65ac76d
commit
15e3d60eab
@ -1,27 +0,0 @@
|
||||
LORIE {
|
||||
global:
|
||||
Java_com_termux_x11_CmdEntryPoint_spawnCompositor;
|
||||
Java_com_termux_x11_CmdEntryPoint_outputResize;
|
||||
Java_com_termux_x11_CmdEntryPoint_socketExists;
|
||||
Java_com_termux_x11_CmdEntryPoint_exec;
|
||||
Java_com_termux_x11_CmdEntryPoint_connect;
|
||||
Java_com_termux_x11_CmdEntryPoint_stderr;
|
||||
Java_com_termux_x11_CmdEntryPoint_getuid;
|
||||
|
||||
Java_com_termux_x11_MainActivity_init;
|
||||
Java_com_termux_x11_MainActivity_connect;
|
||||
Java_com_termux_x11_MainActivity_cursorChanged;
|
||||
Java_com_termux_x11_MainActivity_windowChanged;
|
||||
Java_com_termux_x11_MainActivity_onPointerMotion;
|
||||
Java_com_termux_x11_MainActivity_onPointerScroll;
|
||||
Java_com_termux_x11_MainActivity_onPointerButton;
|
||||
Java_com_termux_x11_MainActivity_onKeySym;
|
||||
Java_com_termux_x11_MainActivity_onKey;
|
||||
Java_com_termux_x11_MainActivity_setHorizontalScrollEnabled;
|
||||
Java_com_termux_x11_MainActivity_setClipboardSyncEnabled;
|
||||
Java_com_termux_x11_MainActivity_nativeResume;
|
||||
Java_com_termux_x11_MainActivity_nativePause;
|
||||
Java_com_termux_x11_MainActivity_startLogcat;
|
||||
local:
|
||||
*;
|
||||
};
|
@ -472,8 +472,7 @@ Java_com_termux_x11_MainActivity_sendTextEvent(JNIEnv *env, unused jobject thiz,
|
||||
size_t len = mbrtowc(&wc, p, MB_CUR_MAX, &state);
|
||||
|
||||
if (len == (size_t)-1 || len == (size_t)-2) {
|
||||
fprintf(stderr, "Invalid UTF-8 sequence encountered\n");
|
||||
exit(EXIT_FAILURE);
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Xlorie-client","Invalid UTF-8 sequence encountered");
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,29 +1,3 @@
|
||||
/*
|
||||
* Copyright © 2008 George Sapountzis <gsap7@yahoo.gr>
|
||||
* Copyright © 2008 Red Hat, Inc
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of the
|
||||
* copyright holders not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
@ -56,32 +30,13 @@ static __GLXdrawable * createDrawable(unused ClientPtr client, __GLXscreen * scr
|
||||
}
|
||||
|
||||
static void glXDRIscreenDestroy(__GLXscreen *baseScreen) {
|
||||
__glXScreenDestroy(baseScreen);
|
||||
free(baseScreen->glvnd);
|
||||
free(baseScreen->GLXextensions);
|
||||
free(baseScreen->GLextensions);
|
||||
free(baseScreen->visuals);
|
||||
free(baseScreen);
|
||||
}
|
||||
|
||||
/* According to __glXScreenDestroy's code all configs
|
||||
* are freed with separate `free` call for each config so
|
||||
* this way we are cloning configs.
|
||||
*/
|
||||
static __GLXconfig* generateConfigs(void) {
|
||||
__GLXconfig *first, *current, *last;
|
||||
|
||||
first = malloc(sizeof(__GLXconfig));
|
||||
*first = configs[0];
|
||||
last = first;
|
||||
|
||||
for (int i=1; i< ARRAY_SIZE(configs); i++) {
|
||||
current = malloc(sizeof(__GLXconfig));
|
||||
*current = configs[i];
|
||||
|
||||
last->next = current;
|
||||
last = current;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
static __GLXscreen *glXDRIscreenProbe(ScreenPtr pScreen) {
|
||||
__GLXscreen *screen;
|
||||
|
||||
@ -92,7 +47,7 @@ static __GLXscreen *glXDRIscreenProbe(ScreenPtr pScreen) {
|
||||
screen->destroy = glXDRIscreenDestroy;
|
||||
screen->createDrawable = createDrawable;
|
||||
screen->pScreen = pScreen;
|
||||
screen->fbconfigs = generateConfigs();
|
||||
screen->fbconfigs = configs;
|
||||
screen->glvnd = strdup("mesa");
|
||||
|
||||
__glXInitExtensionEnableBits(screen->glx_enable_bits);
|
||||
|
@ -16,10 +16,13 @@
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#include <paths.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define __u32 uint32_t
|
||||
#ifdef ANDROID
|
||||
#include <linux/ashmem.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include "shm.h"
|
||||
@ -44,19 +47,54 @@ typedef struct {
|
||||
static shmem_t* shmem = NULL;
|
||||
static size_t shmem_amount = 0;
|
||||
|
||||
static uint8_t syscall_supported = 1;
|
||||
static uint8_t syscall_supported = 0;
|
||||
|
||||
__attribute__((constructor))
|
||||
#define ANDROID_LINUX_SHM
|
||||
#undef SYS_ipc
|
||||
static bool isProot(void) {
|
||||
char buf[4096];
|
||||
char path[256];
|
||||
char exe_path[256];
|
||||
int tpid;
|
||||
|
||||
const int status_fd = open("/proc/self/status", O_RDONLY);
|
||||
if (status_fd == -1)
|
||||
return false;
|
||||
|
||||
read(status_fd, buf, sizeof(buf) - 1);
|
||||
close(status_fd);
|
||||
|
||||
const char *tracer_str = strstr(buf, "TracerPid:");
|
||||
|
||||
if (tracer_str || sscanf(tracer_str, "TracerPid: %d", &tpid) != 1 || !tpid)
|
||||
return false;
|
||||
|
||||
snprintf(path, sizeof(path), "/proc/%d/exe", tpid);
|
||||
|
||||
ssize_t len = readlink(path, exe_path, sizeof(exe_path) - 1);
|
||||
if (len == -1)
|
||||
return false;
|
||||
|
||||
exe_path[len] = '\0';
|
||||
return (!strcmp(basename(exe_path), "proot"));
|
||||
}
|
||||
|
||||
__attribute__((unused, constructor))
|
||||
static void check_syscall_support(void) {
|
||||
dprintf(2, "proot: %d\n", isProot());
|
||||
if (!isProot())
|
||||
return;
|
||||
|
||||
errno = 0;
|
||||
#ifdef ANDROID_LINUX_SHM
|
||||
#ifdef SYS_ipc
|
||||
if (syscall(SYS_ipc) != -1 && errno != ENOSYS)
|
||||
syscall(SYS_ipc);
|
||||
#else
|
||||
if (syscall(SYS_shmat) == -1 && errno == ENOSYS)
|
||||
syscall(SYS_shmat);
|
||||
#endif
|
||||
#endif
|
||||
syscall_supported = 0;
|
||||
// printf("syscall supported %d %s\n", syscall_supported, strerror(errno));
|
||||
if (errno != ENOSYS)
|
||||
syscall_supported = 1;
|
||||
}
|
||||
|
||||
// The lower 16 bits of (getpid() + i), where i is a sequence number.
|
||||
|
@ -1,59 +0,0 @@
|
||||
#include <jni.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define unused __attribute__((unused))
|
||||
#define used __attribute__((used))
|
||||
|
||||
JNIEXPORT jint JNICALL used
|
||||
Java_com_eltechs_axs_Mcat_startVtest(unused JNIEnv *env, unused jobject thiz) {
|
||||
int pid = fork();
|
||||
switch (pid) { // NOLINT(hicpp-multiway-paths-covered)
|
||||
case 0: {
|
||||
const char* packages[] = {
|
||||
"com.antutu.ABenchMark",
|
||||
"com.ludashi.benchmark",
|
||||
"com.eltechs.ed",
|
||||
NULL
|
||||
};
|
||||
|
||||
int fd = open("/storage/emulated/0/android-virtioGPU.txt", O_WRONLY | O_CREAT | O_TRUNC, 644);
|
||||
dup2(fd, 1);
|
||||
dup2(fd, 2);
|
||||
|
||||
setenv("TERM", "xterm-256color", 1);
|
||||
setenv("LC_ALL", "zh_CN.utf8", 1);
|
||||
setenv("LANG", "zh_CN.utf8", 1);
|
||||
setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games", 1);
|
||||
setenv("HOME", "/root", 1);
|
||||
|
||||
for (int i=0; packages[i]; i++) {
|
||||
char *root, *tmp, *script;
|
||||
asprintf(&root, "/data/data/%s/files", packages[i]);
|
||||
asprintf(&tmp, "/data/data/%s/files/image/tmp", packages[i]);
|
||||
asprintf(&script, "/data/data/%s/files/image/opt/start.sh", packages[i]);
|
||||
setenv("ROOT", root, 1);
|
||||
setenv("PROOT_TMP_DIR", tmp, 1);
|
||||
|
||||
if (access(script, F_OK) == 0) {
|
||||
printf("Executing %s\n", script);
|
||||
execl("/system/bin/sh", "sh", script, NULL);
|
||||
printf("Error executing %s: %s\n", script, strerror(errno));
|
||||
} else printf("Script %s is not accessible or does not exist\n", script);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL used
|
||||
Java_com_eltechs_axs_Mcat_stopVtest(unused JNIEnv *env, unused jobject thiz, jint pid) {
|
||||
killpg(pid, SIGINT);
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
add_library(mcat SHARED "recipes/mcat.c")
|
||||
target_link_options(mcat PRIVATE "-s")
|
Loading…
Reference in New Issue
Block a user