Dont exec a symlink in the codesign placeholders

Instead use the full path to the actual binary in the outermost bundle
This commit is contained in:
Kovid Goyal 2019-12-07 15:30:29 +05:30
parent 935e7573ab
commit f1ce7c0cf9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 2 deletions

View File

@ -646,6 +646,7 @@ class Freeze(object):
base_dir = base_dir or self.contents_dir
cc_dir = join(base_dir, name, 'Contents')
exe_dir = join(cc_dir, 'MacOS')
rel_path = os.path.relpath(join(self.contents_dir, 'MacOS'), exe_dir)
os.makedirs(exe_dir)
for x in os.listdir(self.contents_dir):
if x.endswith('.app'):
@ -662,7 +663,10 @@ class Freeze(object):
plist['CFBundleExecutable'] = exe + '-placeholder-for-codesigning'
nexe = join(exe_dir, plist['CFBundleExecutable'])
base = os.path.dirname(abspath(__file__))
cmd = [gcc, '-Wall', '-Werror', '-DEXE_NAME="%s"' % exe, join(base, 'placeholder.c'), '-o', nexe, '-headerpad_max_install_names']
cmd = [
gcc, '-Wall', '-Werror', '-DEXE_NAME="%s"' % exe, '-DREL_PATH="%s"' % rel_path,
join(base, 'placeholder.c'), '-o', nexe, '-headerpad_max_install_names'
]
subprocess.check_call(cmd)
with open(join(cc_dir, x), 'wb') as p:
plistlib.dump(plist, p)

View File

@ -36,6 +36,6 @@ main(int argc, char * const *argv, const char **envp) {
return 1;
}
*(t + 1) = 0;
snprintf(t + 1, sizeof(realpath_buf) - strlen(path), "%s", EXE_NAME);
snprintf(t + 1, sizeof(realpath_buf) - strlen(path), "%s/%s", REL_PATH, EXE_NAME);
execv(path, argv);
}