mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-25 11:50:50 +00:00
Merge branch 'prevent-permissions-footgun' into 'master'
Fail loudly when config isn't writable See merge request KartKrew/Kart-Public!279
This commit is contained in:
commit
a95a8d5c9f
1 changed files with 23 additions and 0 deletions
23
src/d_main.c
23
src/d_main.c
|
@ -1126,6 +1126,29 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
configfile[sizeof configfile - 1] = '\0';
|
configfile[sizeof configfile - 1] = '\0';
|
||||||
|
|
||||||
|
// If config isn't writable, tons of behavior will be broken.
|
||||||
|
// Fail loudly before things get confusing!
|
||||||
|
FILE *tmpfile;
|
||||||
|
char testfile[MAX_WADPATH];
|
||||||
|
|
||||||
|
snprintf(testfile, sizeof testfile, "%s" PATHSEP "file.tmp", srb2home);
|
||||||
|
testfile[sizeof testfile - 1] = '\0';
|
||||||
|
|
||||||
|
tmpfile = fopen(testfile, "w");
|
||||||
|
if (tmpfile == NULL)
|
||||||
|
{
|
||||||
|
#if defined (_WIN32)
|
||||||
|
I_Error("Couldn't write game config.\nMake sure the game is installed somewhere it has write permissions.\n\n(Don't use the Downloads folder, Program Files, or your desktop!\nIf unsure, we recommend making a subfolder in your Documents folder.)");
|
||||||
|
#else
|
||||||
|
I_Error("Couldn't write game config.\nMake sure you've installed the game somewhere it has write permissions.");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fclose(tmpfile);
|
||||||
|
remove(testfile);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _arch_dreamcast
|
#ifdef _arch_dreamcast
|
||||||
strcpy(downloaddir, "/ram"); // the dreamcast's TMP
|
strcpy(downloaddir, "/ram"); // the dreamcast's TMP
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue