diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-01-05 18:45:36 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-01-05 18:45:36 +0100 |
| commit | af1176274ac7c55a1402fbcab505e3b0bbb72414 (patch) | |
| tree | 8ce907ebca123b60afbdd84e86bc2a445bd10df3 /src | |
| parent | 4c2ef9947ae5c89f4bfb0b217d6653aa73b95ac2 (diff) | |
| download | box64-af1176274ac7c55a1402fbcab505e3b0bbb72414.tar.gz box64-af1176274ac7c55a1402fbcab505e3b0bbb72414.zip | |
Added more command to rcfiles, and a default one when system version is not found (and move some essential detection there)
Diffstat (limited to 'src')
| -rwxr-xr-x | src/include/debug.h | 1 | ||||
| -rwxr-xr-x | src/main.c | 31 | ||||
| -rw-r--r-- | src/tools/rcfile.c | 47 |
3 files changed, 63 insertions, 16 deletions
diff --git a/src/include/debug.h b/src/include/debug.h index 3ff15229..9a8d7ee0 100755 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -42,6 +42,7 @@ extern char* trace_init; extern char* box64_trace; extern uint64_t start_cnt; #endif +extern int box64_nosandbox; extern int box64_dummy_crashhandler; extern int box64_sse_flushto0; extern int allow_missing_libs; diff --git a/src/main.c b/src/main.c index 229b38cc..310018f0 100755 --- a/src/main.c +++ b/src/main.c @@ -55,6 +55,7 @@ int box64_dynarec_safeflags = 1; int box64_dynarec_callret = 0; int box64_dynarec_hotpage = 16; int box64_dynarec_bleeding_edge = 1; +int box64_nosandbox = 0; uintptr_t box64_nodynarec_start = 0; uintptr_t box64_nodynarec_end = 0; #ifdef ARM64 @@ -1115,6 +1116,8 @@ static void load_rcfiles() { if(FileExist("/etc/box64.box64rc", IS_FILE)) LoadRCFile("/etc/box64.box64rc"); + else + LoadRCFile(NULL); // load default rcfile char* p = getenv("HOME"); if(p) { char tmp[4096]; @@ -1322,21 +1325,6 @@ int main(int argc, const char **argv, char **env) { if(box64_wine) { AddPath("libdl.so.2", &ld_preload, 0); } - // special case for steam that somehow seems to alter libudev opaque pointer (udev_monitor) - if(!strcmp(prgname, "steam")) { - printf_log(LOG_INFO, "steam detected...\n"); - box64_steam = 1; - } - // special case for steam-runtime-check-requirements to fake 64bits suport - if(strstr(prgname, "steam-runtime-check-requirements")==prgname) { - printf_log(LOG_INFO, "steam-runtime-check-requirements detected, faking All is good!\n"); - exit(0); // exiting, not testing anything - } - // special case for steamwebhelper - if(strstr(prgname, "steamwebhelper")==prgname) { - printf_log(LOG_INFO, "steamwebhelper, ignoring for now!\n"); - exit(0); // exiting - } // special case for zoom if(strstr(prgname, "zoom")==prgname) { printf_log(LOG_INFO, "Zoom detected, trying to use system libturbojpeg if possible\n"); @@ -1371,6 +1359,19 @@ int main(int argc, const char **argv, char **env) { my_context->argv[i] = box_strdup(argv[i+nextarg]); printf_log(LOG_INFO, "argv[%i]=\"%s\"\n", i, my_context->argv[i]); } + if(box64_nosandbox) + { + // check if sandbox is already there + int there = 0; + for(int i=1; i<my_context->argc && !there; ++i) + if(!strcmp(my_context->argv[i], "--no-sandbox")) + there = 1; + if(!there) { + my_context->argv = (char**)box_realloc(my_context->argv, (my_context->argc+1)*sizeof(char*)); + my_context->argv[my_context->argc] = box_strdup("--no-sandbox"); + my_context->argc++; + } + } // check if file exist if(!my_context->argv[0] || !FileExist(my_context->argv[0], IS_FILE)) { diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c index 26aed61c..3d39102c 100644 --- a/src/tools/rcfile.c +++ b/src/tools/rcfile.c @@ -1,6 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <stddef.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <fcntl.h> #include "debug.h" #include "rcfile.h" @@ -17,6 +20,32 @@ // file are basicaly ini file, with section [XXXX] defining the name of the process // and BOX64_XXXX=YYYY entry like the env. var. variables +// default rcfile +static const char default_rcfile[] = +"[deadcells]\n" +"BOX64_PREFER_EMULATED=1\n" +"\n" +"[dontstarve]\n" +"BOX64_EMULATED_LIBS=libSDL2-2.0.so.0\n" +"\n" +"[dota2]\n" +"BOX64_CRASHHANDLER=1\n" +"BOX64_DYNAREC_STRONGMEM=1\n" +"\n" +"[pressure-vessel-wrap]\n" +"BOX64_NOGTK=1\n" +"\n" +"[streaming_client]\n" +"BOX64_EMULATED_LIBS=libSDL2-2.0.so.0:libSDL2_ttf-2.0.so.0\n" +"\n" +"[steamwebhelper]\n" +"BOX64_NOSANDBOX=1\n" +"BOX64_EXIT=1\n" +"\n" +"[steam-runtime-check-requirements]\n" +"BOX64_EXIT=1\n" +; + // list of all entries #define SUPER1() \ ENTRYINTPOS(BOX64_ROLLING_LOG, new_cycle_log) \ @@ -45,6 +74,8 @@ ENTRYBOOL(BOX64_NOGTK, box64_nogtk) \ ENTRYBOOL(BOX64_NOVULKAN, box64_novulkan) \ ENTRYSTRING_(BOX64_BASH, bash) \ ENTRYINT(BOX64_JITGDB, jit_gdb, 0, 2, 2) \ +ENTRYBOOL(BOX64_NOSANDBOX, box64_nosandbox) \ +ENTRYBOOL(BOX64_EXIT, want_exit) \ #ifdef HAVE_TRACE #define SUPER2() \ @@ -216,7 +247,18 @@ static void trimString(char* s) void LoadRCFile(const char* filename) { - FILE *f = fopen(filename, "r"); + FILE *f = NULL; + if(filename) + f = fopen(filename, "r"); + else { + #define TMP_MEMRCFILE "/box64_rcfile" + int tmp = shm_open(TMP_MEMRCFILE, O_RDWR | O_CREAT, S_IRWXU); + if(tmp<0) return; // error, bye bye + shm_unlink(TMP_MEMRCFILE); // remove the shm file, but it will still exist because it's currently in use + write(tmp, default_rcfile, sizeof(default_rcfile)); + lseek(tmp, 0, SEEK_SET); + f = fdopen(tmp, "r"); + } if(!f) { printf_log(LOG_INFO, "Cannot open RC file %s\n", filename); return; @@ -374,6 +416,7 @@ void ApplyParams(const char* name) my_params_t* param = &kh_value(params, k); #ifdef DYNAREC int olddynarec = box64_dynarec; + int want_exit = 0; #endif printf_log(LOG_INFO, "Apply RC params for %s\n", name); #define ENTRYINT(NAME, name, minval, maxval, bits) if(param->is_##name##_present) {name = param->name; printf_log(LOG_INFO, "Applying %s=%d\n", #NAME, param->name);} @@ -396,6 +439,8 @@ void ApplyParams(const char* name) #undef ENTRYADDR #undef ENTRYULONG // now handle the manuel entry (the one with ending underscore) + if(want_exit) + exit(0); if(new_cycle_log==1) new_cycle_log = 16; if(new_cycle_log!=cycle_log) { |