Refuse to autoupdate the engine when the binary looks like it has a revision number in its file name.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5943 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-07-03 01:47:10 +00:00
parent 14dddfd63c
commit 4d4a2943fb
2 changed files with 43 additions and 9 deletions

View file

@ -2956,6 +2956,10 @@ qboolean Sys_SetUpdatedBinary(const char *newbinary)
wchar_t enginebinarybackup[MAX_OSPATH+4];
size_t len;
static qboolean alreadymoved = false;
//update blocked via commandline. to be doubly sure its checked.
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
return false;
//windows is annoying. we can't delete a file that's in use (no orphaning)
//we can normally rename it to something else before writing a new file with the original name.
@ -3001,10 +3005,26 @@ qboolean Sys_SetUpdatedBinary(const char *newbinary)
}
qboolean Sys_EngineMayUpdate(void)
{
wchar_t enginebinaryw[MAX_OSPATH];
if (!COM_CheckParm("-allowupdate"))
{
char enginebinary[MAX_OSPATH*4];
char *s;
if (revision_number(true) <= 0)
return false;
GetModuleFileNameW(NULL, enginebinaryw, countof(enginebinaryw)-1);
narrowen(enginebinary, sizeof(enginebinary), enginebinaryw);
//if there's 3 consecutive digits or digit.digit then assume the user is doing their own versioning, and disallow engine updates (unless they use the -allowupdate arg).
//(that or they ran one of our older builds directly)
s = COM_SkipPath(enginebinary);
while (*s)
{
if ( s[0] >= '0' && s[0] <= '9')
if ((s[1] >= '0' && s[1] <= '9') || s[1] == '.' || s[1] == '_' || s[1] == '-')
if ( s[2] >= '0' && s[2] <= '9')
return false;
}
}
//update blocked via commandline

View file

@ -540,9 +540,9 @@ qboolean Sys_SetUpdatedBinary(const char *newbinary)
int i;
struct stat src, dst;
//windows is annoying. we can't delete a file that's in use (no orphaning)
//we can normally rename it to something else before writing a new file with the original name.
//then delete the old file later (sadly only on reboot)
//update blocked via commandline. just in case.
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
return false;
//get the binary name
i = readlink("/proc/self/exe", enginebinary, sizeof(enginebinary)-1);
@ -585,20 +585,34 @@ qboolean Sys_EngineMayUpdate(void)
char enginebinary[MAX_OSPATH];
int len;
//if we can't get a revision number from our cflags then don't allow updates (unless forced on).
if (!COM_CheckParm("-allowupdate"))
if (revision_number(true)<=0)
return false;
//update blocked via commandline
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
return false;
//check that we can actually do it.
len = readlink("/proc/self/exe", enginebinary, sizeof(enginebinary)-1);
if (len <= 0)
return false;
//if we can't get a revision number from our cflags then don't allow updates (unless forced on).
if (!COM_CheckParm("-allowupdate"))
{
char *s;
if (revision_number(true)<=0)
return false;
//if there's 3 consecutive digits or digit.digit then assume the user is doing their own versioning, and disallow engine updates (unless they use the -allowupdate arg).
//(that or they ran one of our older builds directly)
s = COM_SkipPath(enginebinary);
while (*s)
{
if ( s[0] >= '0' && s[0] <= '9')
if ((s[1] >= '0' && s[1] <= '9') || s[1] == '.' || s[1] == '_' || s[1] == '-')
if ( s[2] >= '0' && s[2] <= '9')
return false;
}
}
enginebinary[len] = 0;
if (access(enginebinary, R_OK|W_OK|X_OK) < 0)
return false; //can't write it. don't try downloading updates.