forked from github/server
log a warning when passwords would fail for being case-sensitive.
add a test to enforce the status quo, for now.
This commit is contained in:
parent
b0b63747c4
commit
19390dd8e2
|
@ -313,7 +313,13 @@ unit *addplayer(region * r, faction * f)
|
|||
|
||||
bool checkpasswd(const faction * f, const char *passwd)
|
||||
{
|
||||
return (passwd && unicode_utf8_strcasecmp(f->passw, passwd) == 0);
|
||||
if (!passwd) return false;
|
||||
if (strcmp(f->passw, passwd)==0) return true;
|
||||
if (unicode_utf8_strcasecmp(f->passw, passwd) == 0) {
|
||||
log_warning("case-sensitive password check failed: %s", factionname(f));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
variant read_faction_reference(struct storage * store)
|
||||
|
|
|
@ -119,6 +119,16 @@ static void test_addfaction(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_check_passwd(CuTest *tc) {
|
||||
faction *f;
|
||||
|
||||
f = test_create_faction(0);
|
||||
faction_setpassword(f, "password");
|
||||
CuAssertIntEquals(tc, true, checkpasswd(f, "password"));
|
||||
CuAssertIntEquals(tc, true, checkpasswd(f, "PASSWORD"));
|
||||
CuAssertIntEquals(tc, false, checkpasswd(f, "assword"));
|
||||
}
|
||||
|
||||
static void test_get_monsters(CuTest *tc) {
|
||||
faction *f;
|
||||
|
||||
|
@ -185,5 +195,6 @@ CuSuite *get_faction_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_get_monsters);
|
||||
SUITE_ADD_TEST(suite, test_set_origin);
|
||||
SUITE_ADD_TEST(suite, test_set_origin_bug);
|
||||
SUITE_ADD_TEST(suite, test_check_passwd);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue