Module: Tebako::Packager::PatchLiterals
- Included in:
- Pass2NonMSysPatch, Pass2Patch
- Defined in:
- lib/tebako/packager/patch_literals.rb
Overview
Ruby patching literals (pass2)
Constant Summary collapse
- TOOL_MKCONFIG_RB_SUBST =
"# -- Start of tebako patch --\n v_head_comp = \" CONFIG[\\\\\"prefix\\\\\"] \\\#{eq} \"\n if v_head_comp == v[0...(v_head_comp.length)]\n v = \"\\\#{v[0...(v_head_comp.length)]}'/__tebako_memfs__'\n\"\n end\n v_head_comp = \" CONFIG[\\\\\"RUBY_EXEC_PREFIX\\\\\"] \\\#{eq} \"\n if v_head_comp == v[0...(v_head_comp.length)]\n v = \"\\\#{v[0...(v_head_comp.length)]}'/__tebako_memfs__'\n\"\n end\n# -- End of tebako patch --\n if fast[name]\n"- TOOL_MKCONFIG_RB_SUBST_MSYS =
"# -- Start of tebako patch --\n v_head_comp = \" CONFIG[\\\\\"prefix\\\\\"] \\\#{eq} \"\n if v_head_comp == v[0...(v_head_comp.length)]\n v = \"\\\#{v[0...(v_head_comp.length)]}CONFIG[\\\\\"RUBY_EXEC_PREFIX\\\\\"] = 'A:/__tebako_memfs__'\n\"\n end\n v_head_comp = \" CONFIG[\\\\\"RUBY_EXEC_PREFIX\\\\\"] \\\#{eq} \"\n if v_head_comp == v[0...(v_head_comp.length)]\n v = \"\\\#{v[0...(v_head_comp.length)]}'A:/__tebako_memfs__'\n\"\n end\n# -- End of tebako patch --\n if fast[name]\n"- LINUX_MUSL_THREAD_PTHREAD_PATCH =
– Patch no. 3 – hack in “ENABLE_PATH_CHECK” disabling to suppress: “warning: Insecure world writable dir” Applied in CMakeLists.txt
{ "#if MAINSTACKADDR_AVAILABLE && !defined(get_main_stack)" => " /* -- Start of tebako patch -- */\n #if defined(__linux__) && !defined(__GLIBC__) && defined(HAVE_GETRLIMIT)\n #ifndef PAGE_SIZE\n #include <unistd.h>\n #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)\n #endif\n static int\n get_main_stack(void **addr, size_t *size)\n {\n size_t start, end, limit, prevend = 0;\n struct rlimit r;\n FILE *f;\n char buf[PATH_MAX+80], s[8];\n int n;\n STACK_GROW_DIR_DETECTION;\n f = fopen(\"/proc/self/maps\", \"re\");\n if (!f)\n return -1;\n n = 0;\n while (fgets(buf, sizeof buf, f)) {\n n = sscanf(buf, \"%zx-%zx %*s %*s %*s %*s %7s\", &start, &end, s);\n if (n >= 2) {\n if (n == 3 && strcmp(s, \"[stack]\") == 0)\n break;\n prevend = end;\n }\n n = 0;\n }\n fclose(f);\n if (n == 0)\n return -1;\n limit = 100 << 20; /* 100MB stack limit */\n if (getrlimit(RLIMIT_STACK, &r)==0 && r.rlim_cur < limit)\n limit = r.rlim_cur & -PAGE_SIZE;\n if (limit > end) limit = end;\n if (prevend < end - limit) prevend = end - limit;\n if (start > prevend) start = prevend;\n *addr = IS_STACK_DIR_UPPER() ? (void *)start : (void *)end;\n *size = end - start;\n return 0;\n }\n #else\n /* -- End of tebako patch -- */\n SUBST\n}.freeze\n"
- DIR_C_BASE_PATCH_ONE =
Compensate ruby incorrect processing of (f)getattrlist returning ENOTSUP Note. We are not patching need_normalization function In this function (f)getattrlist failure with ENOTSUP is processed correctly
"#if defined HAVE_GETATTRLIST && defined ATTR_DIR_ENTRYCOUNT\n /* tebako patch */ if (!within_tebako_memfs(path))\n"- DIR_C_BASE_PATCH_TWO =
"#if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME\n /* tebako patch */ if (!within_tebako_memfs(path)) plain = 1; else magical = 1;\n"- DIR_C_BASE_PATCH =
{ "#if defined HAVE_GETATTRLIST && defined ATTR_DIR_ENTRYCOUNT" => DIR_C_BASE_PATCH_ONE, "#if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME\n plain = 1;" => DIR_C_BASE_PATCH_TWO, "if (is_case_sensitive(dirp, path) == 0)" => "if (is_case_sensitive(dirp, path) == 0 /* tebako patch */ && !within_tebako_memfs(path))", "if ((*cur)->type == ALPHA) {" => "if ((*cur)->type == ALPHA /* tebako patch */ && !within_tebako_memfs(buf)) {", "else if (e == EIO) {" => "else if (e == EIO /* tebako patch */ && !within_tebako_memfs(path)) {" }.freeze
- DLN_C_PRE34_PATCH_PATTERN =
"static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;"- DLN_C_PATCH_PATTERN =
"#define init_funcname(buf, file) build_funcname(FUNCNAME_PREFIX, buf, file)"- DLN_C_MSYS_PATCH_PRE32 =
{ " winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);" => " /* -- Start of tebako patch -- */\n char *f = NULL;\n winfile = NULL;\n if (file && within_tebako_memfs(file)) {\n f = tebako_dlmap2file(file);\n if (f) {\n winfile = rb_w32_mbstr_to_wstr(CP_UTF8, f, -1, NULL);\n free(f);\n }\n else {\n goto failed;\n }\n }\n else {\n winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);\n }\n /* -- End of tebako patch -- */\n SUBST\n}.freeze\n"
- DLN_C_MSYS_PATCH =
{ " WCHAR *winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);" => " /* -- Start of tebako patch -- */\n char *f = NULL;\n WCHAR *winfile = NULL;\n if (file && within_tebako_memfs(file)) {\n f = tebako_dlmap2file(file);\n if (f) {\n winfile = rb_w32_mbstr_to_wstr(CP_UTF8, f, -1, NULL);\n free(f);\n }\n else {\n goto failed;\n }\n }\n else {\n winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);\n }\n /* -- End of tebako patch -- */\n SUBST\n}.freeze\n"
- C_FILE_SUBST =
"/* -- Start of tebako patch -- */\n#include <tebako/tebako-config.h>\n#include <tebako/tebako-defines.h>\n#include <tebako/tebako-io.h>\n/* -- End of tebako patch -- */\n"- C_FILE_SUBST_LESS =
"/* -- Start of tebako patch -- */\n#include <tebako/tebako-config.h>\n#include <tebako/tebako-io.h>\n/* -- End of tebako patch -- */\n"- IO_C_SUBST =
"/* -- Start of tebako patch -- */\n if (is_tebako_file_descriptor(fd)) return;\n /* -- End of tebako patch -- */\n flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */\n"- FILE_C_MSYS_SUBST =
"/* -- Start of tebako patch -- */\n if (is_tebako_file_descriptor((fptr)->fd)) return ENOTSUP;\n /* -- End of tebako patch -- */\n while ((int)rb_thread_io_blocking_region(rb_thread_flock, op, fptr->fd) < 0) {\n"- FILE_C_MSYS_PATCH =
{ "while ((int)rb_thread_io_blocking_region(rb_thread_flock, op, fptr->fd) < 0) {" => FILE_C_MSYS_SUBST }.freeze
- LINUX_PATCHES =
{ "ext/extmk.rb" => { "mf.macro \"EXTLIBS\", $extlibs" => "# mf.macro \"EXTLIBS\", $extlibs tebako patched" } }.freeze
- PRISM_PATTERN_1 =
"pm_string_init_result_t init_result = pm_read_file(&result->input, RSTRING_PTR(filepath));"- PRISM_SUBST_1 =
"/* -- Start of tebako patch -- */\n pm_string_init_result_t init_result;\n if (within_tebako_memfs(RSTRING_PTR(filepath)))\n {\n init_result = tebako_string_file_init(&result->input, RSTRING_PTR(filepath));\n }\n else\n {\n init_result = pm_read_file(&result->input, RSTRING_PTR(filepath));\n }\n /* -- End of tebako patch -- */\n"- PRISM_PATTERN_2 =
"#include \"prism.h\""- PRISM_SUBST_2 =
"\#{PRISM_PATTERN_2}\n\n/* -- Start of tebako patch -- */\n#include <tebako/tebako-config.h>\n#include <tebako/tebako-defines.h>\n#include <tebako/tebako-io.h>\n#include <tebako/tebako-prism.h>\n/* -- End of tebako patch -- */\n\n"- PRISM_PATCHES =
{ PRISM_PATTERN_1 => PRISM_SUBST_1, PRISM_PATTERN_2 => PRISM_SUBST_2 }.freeze