forked from github/server
Merge branch 'master' into develop
Conflicts: src/kernel/save.test.c src/kernel/version.h
This commit is contained in:
commit
c1b0395a6c
|
@ -1203,15 +1203,14 @@ static char * getpasswd(int fno) {
|
||||||
static void read_password(gamedata *data, faction *f) {
|
static void read_password(gamedata *data, faction *f) {
|
||||||
char name[128];
|
char name[128];
|
||||||
READ_STR(data->store, name, sizeof(name));
|
READ_STR(data->store, name, sizeof(name));
|
||||||
if (data->version == BADCRYPT_VERSION) {
|
if (name[0]=='$' && data->version == BADCRYPT_VERSION) {
|
||||||
char * pass = getpasswd(f->no);
|
char * pass = getpasswd(f->no);
|
||||||
if (pass) {
|
if (pass) {
|
||||||
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
|
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
|
||||||
free(pass); // TODO: remove this allocation!
|
free(pass); // TODO: remove this allocation!
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
free(f->_password);
|
log_error("data version is BADCRYPT but %s not in password.txt", itoa36(f->no));
|
||||||
f->_password = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -285,20 +285,25 @@ static void test_read_password_external(CuTest *tc) {
|
||||||
CuAssertPtrNotNull(tc, f->_password);
|
CuAssertPtrNotNull(tc, f->_password);
|
||||||
mstream_init(&data.strm);
|
mstream_init(&data.strm);
|
||||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
WRITE_TOK(data.store, (const char *)f->_password);
|
WRITE_TOK(data.store, "newpassword");
|
||||||
WRITE_TOK(data.store, (const char *)f->_password);
|
WRITE_TOK(data.store, "secret");
|
||||||
|
WRITE_TOK(data.store, "$brokenhash");
|
||||||
data.strm.api->rewind(data.strm.handle);
|
data.strm.api->rewind(data.strm.handle);
|
||||||
|
data.version = NOCRYPT_VERSION;
|
||||||
|
_test_read_password(&data, f);
|
||||||
|
CuAssertStrEquals(tc, "newpassword", f->_password);
|
||||||
data.version = BADCRYPT_VERSION;
|
data.version = BADCRYPT_VERSION;
|
||||||
_test_read_password(&data, f);
|
_test_read_password(&data, f);
|
||||||
CuAssertPtrEquals(tc, 0, f->_password);
|
CuAssertStrEquals(tc, "secret", f->_password);
|
||||||
F = fopen(pwfile, "wt");
|
F = fopen(pwfile, "wt");
|
||||||
fprintf(F, "%s:secret\n", itoa36(f->no));
|
fprintf(F, "%s:pwfile\n", itoa36(f->no));
|
||||||
fclose(F);
|
fclose(F);
|
||||||
|
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
||||||
_test_read_password(&data, f);
|
_test_read_password(&data, f);
|
||||||
CuAssertPtrNotNull(tc, f->_password);
|
CuAssertStrEquals(tc, "pwfile", f->_password);
|
||||||
|
CuAssertTrue(tc, checkpasswd(f, "pwfile"));
|
||||||
mstream_done(&data.strm);
|
mstream_done(&data.strm);
|
||||||
gamedata_done(&data);
|
gamedata_done(&data);
|
||||||
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
|
||||||
CuAssertIntEquals(tc, 0, remove(pwfile));
|
CuAssertIntEquals(tc, 0, remove(pwfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,15 @@
|
||||||
#define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */
|
#define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */
|
||||||
#define OWNER_3_VERSION 349 /* regions store last owner, not last alliance */
|
#define OWNER_3_VERSION 349 /* regions store last owner, not last alliance */
|
||||||
#define ATTRIBOWNER_VERSION 351 /* all attrib_type functions know who owns the attribute */
|
#define ATTRIBOWNER_VERSION 351 /* all attrib_type functions know who owns the attribute */
|
||||||
#define BADCRYPT_VERSION 351 /* passwords are encrypted, poorly */
|
#define BADCRYPT_VERSION 351 /* passwords are broken, 969.dat only. */
|
||||||
#define ATHASH_VERSION 352 /* attribute-type hash, not name */
|
#define NOCRYPT_VERSION 352 /* passwords are plaintext again */
|
||||||
#define NOWATCH_VERSION 353 /* plane->watchers is gone */
|
#define ATHASH_VERSION 353 /* attribute-type hash, not name */
|
||||||
#define CRYPT_VERSION 354 /* passwords are encrypted */
|
#define NOWATCH_VERSION 354 /* plane->watchers is gone */
|
||||||
|
/* unfinished: */
|
||||||
|
#define CRYPT_VERSION 400 /* passwords are encrypted */
|
||||||
|
|
||||||
#define RELEASE_VERSION NOWATCH_VERSION /* current datafile */
|
#define RELEASE_VERSION NOWATCH_VERSION /* current datafile */
|
||||||
#define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */
|
#define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */
|
||||||
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
||||||
|
|
||||||
|
#define STREAM_VERSION 2 /* internal encoding of binary files */
|
||||||
|
|
|
@ -5,7 +5,9 @@ CD ..
|
||||||
SET ERESSEA=%CD%
|
SET ERESSEA=%CD%
|
||||||
|
|
||||||
CD %SRCDIR%
|
CD %SRCDIR%
|
||||||
|
IF exist build-vs%VSVERSION% goto HAVEDIR
|
||||||
mkdir build-vs%VSVERSION%
|
mkdir build-vs%VSVERSION%
|
||||||
|
:HAVEDIR
|
||||||
cd build-vs%VSVERSION%
|
cd build-vs%VSVERSION%
|
||||||
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
|
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
|
||||||
PAUSE
|
PAUSE
|
||||||
|
|
Loading…
Reference in New Issue