termux-packages/packages/shc/src-shc.c.patch
2020-05-07 15:03:23 +03:00

56 lines
2.1 KiB
Diff

diff -uNr shc-4.0.3/src/shc.c shc-4.0.3.mod/src/shc.c
--- shc-4.0.3/src/shc.c 2019-07-01 19:37:08.000000000 +0300
+++ shc-4.0.3.mod/src/shc.c 2020-05-07 15:01:57.944329115 +0300
@@ -153,7 +153,7 @@
"\" * Copyright 2019 - Intika <intika@librefox.org>\",",
"\" * Replace ******** with secret read from fd 21\",",
"\" * Also change arguments location of sub commands (sh script commands)\",",
-"\" * gcc -Wall -fpic -shared -o shc_secret.so shc_secret.c -ldl\",",
+"\" * clang -Wall -fpic -shared -o shc_secret.so shc_secret.c -ldl\",",
"\" */\",",
"\"\",",
"\"#define _GNU_SOURCE /* needed to get RTLD_NEXT defined in dlfcn.h */\",",
@@ -365,7 +365,7 @@
" FILE *fp;",
" int line = 0;",
"",
-" if ((fp = fopen(\"/tmp/shc_x.c\", \"w\")) == NULL ) {exit(1); exit(1);}",
+" if ((fp = fopen(\"@TERMUX_PREFIX@/tmp/shc_x.c\", \"w\")) == NULL ) {exit(1); exit(1);}",
" for (line = 0; shc_x[line]; line++) fprintf(fp, \"%s\\n\", shc_x[line]);",
" fflush(fp);fclose(fp);",
"}",
@@ -375,11 +375,11 @@
" char cmd[4096];",
"",
" cc = getenv(\"CC\");",
-" if (!cc) cc = \"cc\";",
+" if (!cc) cc = \"clang\";",
"",
-" sprintf(cmd, \"%s %s -o %s %s\", cc, \"-Wall -fpic -shared\", \"/tmp/shc_x.so\", \"/tmp/shc_x.c -ldl\");",
-" if (system(cmd)) {remove(\"/tmp/shc_x.c\"); return -1;}",
-" remove(\"/tmp/shc_x.c\"); return 0;",
+" sprintf(cmd, \"%s %s -o %s %s\", cc, \"-Wall -fpic -shared\", \"@TERMUX_PREFIX@/tmp/shc_x.so\", \"@TERMUX_PREFIX@/tmp/shc_x.c -ldl\");",
+" if (system(cmd)) {remove(\"@TERMUX_PREFIX@/tmp/shc_x.c\"); return -1;}",
+" remove(\"@TERMUX_PREFIX@/tmp/shc_x.c\"); return 0;",
"}",
"",
"void arc4_hardrun(void * str, int len) {",
@@ -396,7 +396,7 @@
" shc_x_file();",
" if (make()) {exit(1);}",
"",
-" setenv(\"LD_PRELOAD\",\"/tmp/shc_x.so\",1);",
+" setenv(\"LD_PRELOAD\",\"@TERMUX_PREFIX@/tmp/shc_x.so\",1);",
"",
" if(pid==0) {",
"",
@@ -429,7 +429,7 @@
" memcpy(tmp2, str, lentmp);",
"",
" //Clean temp",
-" remove(\"/tmp/shc_x.so\");",
+" remove(\"@TERMUX_PREFIX@/tmp/shc_x.so\");",
"",
" //Sinal to detach ptrace",
" ptrace(PTRACE_DETACH, 0, 0, 0);",