Termux x11 port

This commit is contained in:
Caten
2024-09-20 21:39:48 +08:00
parent 958d7839ff
commit a117050fde
136 changed files with 19410 additions and 92 deletions

View File

@@ -0,0 +1,127 @@
diff --git a/Xtranssock.c b/Xtranssock.c
index b06579c..bb5238b 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -200,20 +200,28 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
#if defined(X11_t)
-#define UNIX_PATH "/tmp/.X11-unix/X"
-#define UNIX_DIR "/tmp/.X11-unix"
+extern char* xtrans_unix_path_x11;
+extern char* xtrans_unix_dir_x11;
+#define UNIX_PATH xtrans_unix_path_x11
+#define UNIX_DIR xtrans_unix_dir_x11
#endif /* X11_t */
#if defined(XIM_t)
-#define UNIX_PATH "/tmp/.XIM-unix/XIM"
-#define UNIX_DIR "/tmp/.XIM-unix"
+extern char* xtrans_unix_path_xim;
+extern char* xtrans_unix_dir_xim;
+#define UNIX_PATH xtrans_unix_path_xim
+#define UNIX_DIR xtrans_unix_dir_xim
#endif /* XIM_t */
#if defined(FS_t) || defined(FONT_t)
-#define UNIX_PATH "/tmp/.font-unix/fs"
-#define UNIX_DIR "/tmp/.font-unix"
+extern char* xtrans_unix_path_fs;
+extern char* xtrans_unix_dir_fs;
+#define UNIX_PATH xtrans_unix_path_fs
+#define UNIX_DIR xtrans_unix_dir_fs
#endif /* FS_t || FONT_t */
#if defined(ICE_t)
-#define UNIX_PATH "/tmp/.ICE-unix/"
-#define UNIX_DIR "/tmp/.ICE-unix"
+extern char* xtrans_unix_path_ice;
+extern char* xtrans_unix_dir_ice;
+#define UNIX_PATH xtrans_unix_path_ice
+#define UNIX_DIR xtrans_unix_dir_ice
#endif /* ICE_t */
diff --git a/Xtransutil.c b/Xtransutil.c
index 63f0fc3..a9620a6 100644
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -478,27 +478,6 @@
}
/* Dir doesn't exist. Try to create it */
-#if !defined(WIN32) && !defined(__CYGWIN__)
- /*
- * 'sticky' bit requested: assume application makes
- * certain security implications. If effective user ID
- * is != 0: fail as we may not be able to meet them.
- */
- if (geteuid() != 0) {
- if (mode & 01000) {
- prmsg(1, "mkdir: ERROR: euid != 0,"
- "directory %s will not be created.\n",
- path);
-#ifdef FAIL_HARD
- return -1;
-#endif
- } else {
- prmsg(1, "mkdir: Cannot create %s with root ownership\n",
- path);
- }
- }
-#endif
-
#ifndef WIN32
if (mkdir(path, mode) == 0) {
if (chmod(path, mode)) {
@@ -521,14 +500,9 @@
} else {
if (S_ISDIR(buf.st_mode)) {
- int updateOwner = 0;
int updateMode = 0;
- int updatedOwner = 0;
int updatedMode = 0;
int status = 0;
- /* Check if the directory's ownership is OK. */
- if (buf.st_uid != 0)
- updateOwner = 1;
/*
* Check if the directory's mode is OK. An exact match isn't
@@ -566,7 +540,7 @@
* directory's owner and mode. Otherwise it isn't safe to attempt
* to do this.
*/
- if (updateMode || updateOwner) {
+ if (updateMode) {
int fd = -1;
struct stat fbuf;
if ((fd = open(path, O_RDONLY)) != -1) {
@@ -588,8 +562,6 @@
close(fd);
return -1;
}
- if (updateOwner && fchown(fd, 0, 0) == 0)
- updatedOwner = 1;
if (updateMode && fchmod(fd, mode) == 0)
updatedMode = 1;
close(fd);
@@ -597,20 +569,6 @@
}
#endif
- if (updateOwner && !updatedOwner) {
-#ifdef FAIL_HARD
- if (status & FAIL_IF_NOT_ROOT) {
- prmsg(1, "mkdir: ERROR: Owner of %s must be set to root\n",
- path);
- return -1;
- }
-#endif
-#if !defined(__APPLE_CC__) && !defined(__CYGWIN__)
- prmsg(1, "mkdir: Owner of %s should be set to root\n",
- path);
-#endif
- }
-
if (updateMode && !updatedMode) {
#ifdef FAIL_HARD
if (status & FAIL_IF_NOMODE) {