forked from github/server
hack to read passwords from an external file
This commit is contained in:
parent
fc86de85f1
commit
8054a145cc
2 changed files with 24 additions and 3 deletions
|
@ -1156,6 +1156,23 @@ void write_spellbook(const struct spellbook *book, struct storage *store)
|
||||||
WRITE_TOK(store, "end");
|
WRITE_TOK(store, "end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * getpasswd(int fno) {
|
||||||
|
const char *prefix = itoa36(fno);
|
||||||
|
size_t len = strlen(prefix);
|
||||||
|
FILE * F = fopen("passwords.txt", "r");
|
||||||
|
char line[80];
|
||||||
|
if (F) {
|
||||||
|
while (!feof(F)) {
|
||||||
|
fgets(line, sizeof(line), F);
|
||||||
|
if (line[len+1]==':' && strncmp(prefix, line, len)==0) {
|
||||||
|
fclose(F);
|
||||||
|
return _strdup(line+len+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(F);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
/** Reads a faction from a file.
|
/** Reads a faction from a file.
|
||||||
* This function requires no context, can be called in any state. The
|
* This function requires no context, can be called in any state. The
|
||||||
* faction may not already exist, however.
|
* faction may not already exist, however.
|
||||||
|
@ -1223,7 +1240,11 @@ faction *readfaction(struct gamedata * data)
|
||||||
}
|
}
|
||||||
|
|
||||||
READ_STR(data->store, name, sizeof(name));
|
READ_STR(data->store, name, sizeof(name));
|
||||||
f->passw = _strdup(name);
|
if (data->version < CRYPT_VERSION) {
|
||||||
|
f->passw = _strdup(name);
|
||||||
|
} else {
|
||||||
|
f->passw = getpasswd(f->no);
|
||||||
|
}
|
||||||
if (data->version < NOOVERRIDE_VERSION) {
|
if (data->version < NOOVERRIDE_VERSION) {
|
||||||
READ_STR(data->store, 0, 0);
|
READ_STR(data->store, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
#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 350 /* all attrib_type functions know who owns the attribute */
|
#define ATTRIBOWNER_VERSION 350 /* all attrib_type functions know who owns the attribute */
|
||||||
|
#define CRYPT_VERSION 351 /* passwords are encrypted */
|
||||||
#define RELEASE_VERSION ATTRIBOWNER_VERSION /* current datafile */
|
#define RELEASE_VERSION ATTRIBOWNER_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 CRYPT_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 */
|
#define STREAM_VERSION 2 /* internal encoding of binary files */
|
||||||
|
|
Loading…
Reference in a new issue