From 4484acf9d6df1b3f04451c0149e53e6954fe7fb6 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Sun, 31 Mar 2019 10:25:06 -0700 Subject: [PATCH] Option --assume-execute-permission modified: main.cpp modified: options.h modified: p_unix.cpp https://github.com/upx/upx/issues/256 --- src/main.cpp | 4 ++++ src/options.h | 1 + src/p_unix.cpp | 5 ++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 35bd3f3b..7861283c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -872,6 +872,9 @@ static int do_option(int optc, const char *arg) case 677: opt->o_unix.force_pie = true; break; + case 678: + opt->o_unix.assume_execute_permission = true; + break; case '\0': return -1; @@ -1024,6 +1027,7 @@ static const struct mfx_option longopts[] = {"preserve-build-id", 0, 0, 675}, {"android-shlib", 0, 0, 676}, {"force-pie", 0, 0, 677}, + {"assume-execute-permission", 0, 0, 678}, // watcom/le {"le", 0x10, 0, 620}, // produce LE output // win32/pe diff --git a/src/options.h b/src/options.h index ff516346..fb2cb8d6 100644 --- a/src/options.h +++ b/src/options.h @@ -148,6 +148,7 @@ struct options_t { bool preserve_build_id; // copy the build-id to the compressed binary bool android_shlib; // keep some ElfXX_Shdr for dlopen() bool force_pie; // choose DF_1_PIE instead of is_shlib + bool assume_execute_permission; // do not check .st_mode for S_IXUSR } o_unix; struct { bool le; diff --git a/src/p_unix.cpp b/src/p_unix.cpp index 8816957a..e8db891f 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -63,11 +63,10 @@ bool PackUnix::canPack() if (exetype == 0) return false; -#if defined(__unix__) && !defined(__MSYS2__) // must be executable by owner - if ((fi->st.st_mode & S_IXUSR) == 0) + if (!opt->o_unix.assume_execute_permission // benefits __MSYS2__ + && (fi->st.st_mode & S_IXUSR) == 0) throwCantPack("file not executable; try 'chmod +x'"); -#endif if (file_size < 4096) throwCantPack("file is too small");