Cleaned up macOS/Darwin OSSP Bundle Launcher

This commit is contained in:
2026-03-19 11:15:16 +10:00
parent d00cf292f1
commit cdad7be12e
4 changed files with 21 additions and 23 deletions
@@ -5,9 +5,6 @@
* Darwin XNU / macOS OSSP Bundle Launcher * Darwin XNU / macOS OSSP Bundle Launcher
*/ */
// Yes I know this is some of the worst written code, like ever
// I will clean this up later, it just has to work
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <sstream> #include <sstream>
@@ -40,7 +37,7 @@ int main(int argc, char** argv) {
removePath(bundle_path); removePath(bundle_path);
removePath(bundle_path); removePath(bundle_path);
removePath(bundle_path); removePath(bundle_path);
printf("Bundle Path: %s\n", bundle_path.c_str()); printf("[OSSPL] Bundle Path: %s\n", bundle_path.c_str());
// Create DYLD_LIBRARY_PATH - 'Bundle/sysroot/lib' // Create DYLD_LIBRARY_PATH - 'Bundle/sysroot/lib'
std::string dyld_library_path = bundle_path; std::string dyld_library_path = bundle_path;
@@ -65,16 +62,17 @@ int main(int argc, char** argv) {
std::string pwd_env = home_env_orig + "/.config/ossp"; std::string pwd_env = home_env_orig + "/.config/ossp";
pwd_env = "PWD=" + pwd_env; pwd_env = "PWD=" + pwd_env;
char* c_pwd_env = strdup(pwd_env.c_str()); char* c_pwd_env = strdup(pwd_env.c_str());
printf("New PWD: %s\n", c_pwd_env);
char test[256]; // Make new environment
strcpy(test, c_dyld_library_path); char envp0[PATH_MAX];
char test2[256]; char envp1[PATH_MAX];
strcpy(test2, c_lv2_path); char envp2[PATH_MAX];
char test3[256]; char envp3[PATH_MAX];
strcpy(test3, c_home_env_b);
char test4[256]; strncpy(envp0, c_dyld_library_path, PATH_MAX);
strcpy(test4, c_pwd_env); strncpy(envp1, c_lv2_path, PATH_MAX);
strncpy(envp2, c_home_env_b, PATH_MAX);
strncpy(envp3, c_pwd_env, PATH_MAX);
free(c_dyld_library_path); free(c_dyld_library_path);
free(c_lv2_path); free(c_lv2_path);
free(c_home_env_b); free(c_home_env_b);
@@ -83,19 +81,19 @@ int main(int argc, char** argv) {
// NOTE: I have to package the environment variables this way because if they are set through **environ, // NOTE: I have to package the environment variables this way because if they are set through **environ,
// macOS sanitizes it and OSSP doesn't get it // macOS sanitizes it and OSSP doesn't get it
char* envp[] = { char* envp[] = {
test3, envp0,
test, envp1,
test2, envp2,
test4, envp3,
NULL NULL
}; };
printf("--------------------------------\n"); // Print new environment to console
printf("%s\n", envp[0]); printf("[OSSPL] New environment:\n");
printf("%s\n", envp[1]); printf("envp0: %s\n", envp[0]);
printf("%s\n", envp[2]); printf("envp1: %s\n", envp[1]);
printf("%s\n", envp[3]); printf("envp2: %s\n", envp[2]);
printf("--------------------------------\n"); printf("envp3: %s\n", envp[3]);
// Create OSSP path and run // Create OSSP path and run
std::string ossp_path = macho_path; std::string ossp_path = macho_path;