34 lines
1.3 KiB
Plaintext
34 lines
1.3 KiB
Plaintext
Patch to encourage third-parties to compile own packages instead
|
|
of using hosted by Termux.
|
|
|
|
diff -uNr dash-0.5.11.2/src/main.c dash-0.5.11.2.mod/src/main.c
|
|
--- dash-0.5.11.2/src/main.c 2020-08-28 06:05:12.000000000 +0300
|
|
+++ dash-0.5.11.2.mod/src/main.c 2020-09-27 23:40:41.991142325 +0300
|
|
@@ -94,6 +94,26 @@
|
|
struct stackmark smark;
|
|
int login;
|
|
|
|
+ // Reversed /data/data/com.termux/files/usr. Prevents patching with 'sed'
|
|
+ // by using equal-size prefixes.
|
|
+ const char termux_prefix_obfs[] = "rsu/selif/xumret.moc/atad/atad/";
|
|
+ char termux_prefix[sizeof(termux_prefix_obfs)/sizeof(char)] = {0};
|
|
+ int termux_prefix_len = sizeof(termux_prefix_obfs)/sizeof(char) - 1;
|
|
+
|
|
+ // Decode.
|
|
+ for (int i=0; i<termux_prefix_len; i++) {
|
|
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
|
|
+ }
|
|
+
|
|
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
|
|
+ // If checks failed, then we probably running in incompatible environment.
|
|
+ // In this case warn user and exit with status 1.
|
|
+ if (access(termux_prefix, R_OK) != 0) {
|
|
+ fprintf(stderr, "Warning: aborting execution because %s is not accessible.\n", termux_prefix);
|
|
+ fprintf(stderr, "Please make sure that program is compiled with correct prefix.\n");
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
#ifdef __GLIBC__
|
|
dash_errno = __errno_location();
|
|
#endif
|