summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/login')
-rw-r--r--src/login/account.h6
-rw-r--r--src/login/ipban.h6
-rw-r--r--src/login/login.c40
-rw-r--r--src/login/login.h6
-rw-r--r--src/login/loginlog.h6
5 files changed, 35 insertions, 29 deletions
diff --git a/src/login/account.h b/src/login/account.h
index 74a9e9626..234e7c0c1 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#ifndef __ACCOUNT_H_INCLUDED__
-#define __ACCOUNT_H_INCLUDED__
+#ifndef _LOGIN_ACCOUNT_H_
+#define _LOGIN_ACCOUNT_H_
#include "../common/cbasetypes.h"
#include "../common/mmo.h" // ACCOUNT_REG2_NUM
@@ -139,4 +139,4 @@ Sql *account_db_sql_up(AccountDB* self);
void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id);
void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id);
-#endif // __ACCOUNT_H_INCLUDED__
+#endif /* _LOGIN_ACCOUNT_H_ */
diff --git a/src/login/ipban.h b/src/login/ipban.h
index b2a1a7d9e..e6851d8dd 100644
--- a/src/login/ipban.h
+++ b/src/login/ipban.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#ifndef __IPBAN_H_INCLUDED__
-#define __IPBAN_H_INCLUDED__
+#ifndef _LOGIN_IPBAN_H_
+#define _LOGIN_IPBAN_H_
#include "../common/cbasetypes.h"
@@ -22,4 +22,4 @@ void ipban_log(uint32 ip);
bool ipban_config_read(const char* key, const char* value);
-#endif // __IPBAN_H_INCLUDED__
+#endif /* _LOGIN_IPBAN_H_ */
diff --git a/src/login/login.c b/src/login/login.c
index d427641f5..252031bb8 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -1017,27 +1017,29 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
}
if( login_config.client_hash_check && !isServer ) {
- struct client_hash_node *node = login_config.client_hash_nodes;
+ struct client_hash_node *node = NULL;
bool match = false;
- if( !sd->has_client_hash ) {
- ShowNotice("Client doesn't sent client hash (account: %s, pass: %s, ip: %s)\n", sd->userid, sd->passwd, acc.state, ip);
- return 5;
- }
-
- while( node ) {
- if( node->group_id <= acc.group_id && memcmp(node->hash, sd->client_hash, 16) == 0 ) {
+ for( node = login_config.client_hash_nodes; node; node = node->next ) {
+ if( acc.group_id < node->group_id )
+ continue;
+ if( *node->hash == '\0' // Allowed to login without hash
+ || (sd->has_client_hash && memcmp(node->hash, sd->client_hash, 16) == 0 ) // Correct hash
+ ) {
match = true;
break;
}
-
- node = node->next;
}
if( !match ) {
char smd5[33];
int i;
+ if( !sd->has_client_hash ) {
+ ShowNotice("Client didn't send client hash (account: %s, pass: %s, ip: %s)\n", sd->userid, sd->passwd, acc.state, ip);
+ return 5;
+ }
+
for( i = 0; i < 16; i++ )
sprintf(&smd5[i * 2], "%02x", sd->client_hash[i]);
@@ -1647,15 +1649,19 @@ int login_config_read(const char* cfgName)
int i;
CREATE(nnode, struct client_hash_node, 1);
- for (i = 0; i < 32; i += 2) {
- char buf[3];
- unsigned int byte;
+ if (strcmpi(md5, "disabled") == 0) {
+ nnode->hash[0] = '\0';
+ } else {
+ for (i = 0; i < 32; i += 2) {
+ char buf[3];
+ unsigned int byte;
- memcpy(buf, &md5[i], 2);
- buf[2] = 0;
+ memcpy(buf, &md5[i], 2);
+ buf[2] = 0;
- sscanf(buf, "%x", &byte);
- nnode->hash[i / 2] = (uint8)(byte & 0xFF);
+ sscanf(buf, "%x", &byte);
+ nnode->hash[i / 2] = (uint8)(byte & 0xFF);
+ }
}
nnode->group_id = group;
diff --git a/src/login/login.h b/src/login/login.h
index d6a021125..14c361a15 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#ifndef _LOGIN_H_
-#define _LOGIN_H_
+#ifndef _LOGIN_LOGIN_H_
+#define _LOGIN_LOGIN_H_
#include "../common/mmo.h" // NAME_LENGTH,SEX_*
#include "../common/core.h" // CORE_ST_LAST
@@ -100,4 +100,4 @@ extern struct mmo_char_server server[MAX_SERVERS];
extern struct Login_Config login_config;
-#endif /* _LOGIN_H_ */
+#endif /* _LOGIN_LOGIN_H_ */
diff --git a/src/login/loginlog.h b/src/login/loginlog.h
index a1ffaae85..730fb6e62 100644
--- a/src/login/loginlog.h
+++ b/src/login/loginlog.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#ifndef __LOGINLOG_H_INCLUDED__
-#define __LOGINLOG_H_INCLUDED__
+#ifndef _LOGIN_LOGINLOG_H_
+#define _LOGIN_LOGINLOG_H_
unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes);
@@ -12,4 +12,4 @@ bool loginlog_final(void);
bool loginlog_config_read(const char* w1, const char* w2);
-#endif // __LOGINLOG_H_INCLUDED__
+#endif /* _LOGIN_LOGINLOG_H_ */