| 41 |
{ |
{ |
| 42 |
char username[BBS_username_max_len + 1]; |
char username[BBS_username_max_len + 1]; |
| 43 |
char password[BBS_password_max_len + 1]; |
char password[BBS_password_max_len + 1]; |
| 44 |
int i = 0; |
int i; |
|
int ok = 0; |
|
| 45 |
int ret; |
int ret; |
| 46 |
|
|
| 47 |
for (; !SYS_server_exit && !ok && i < BBS_login_retry_times; i++) |
for (i = 0; !SYS_server_exit && i < BBS_login_retry_times; i++) |
| 48 |
{ |
{ |
| 49 |
prints("\033[1;33m请输入帐号\033[m(试用请输入`\033[1;36mguest\033[m', " |
prints("\033[1;33m请输入帐号\033[m(试用请输入`\033[1;36mguest\033[m', " |
| 50 |
"注册请输入`\033[1;31mnew\033[m'): "); |
"注册请输入`\033[1;31mnew\033[m'): "); |
| 58 |
if (strcmp(username, "guest") == 0) |
if (strcmp(username, "guest") == 0) |
| 59 |
{ |
{ |
| 60 |
load_guest_info(); |
load_guest_info(); |
| 61 |
|
log_common("User [%s] authenticated successfully", username); |
| 62 |
return 0; |
return 0; |
| 63 |
} |
} |
| 64 |
|
|
| 65 |
if (strcmp(username, "new") == 0) |
if (strcmp(username, "new") == 0) |
| 66 |
{ |
{ |
| 67 |
display_file(DATA_REGISTER, 1); |
display_file(DATA_REGISTER, 1); |
|
|
|
| 68 |
return -1; |
return -1; |
| 69 |
} |
} |
| 70 |
|
|
| 85 |
ret = 0; |
ret = 0; |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
ok = (ret == 0); |
if (ret == 0) |
| 89 |
|
{ |
| 90 |
|
log_common("User [%s] authenticated successfully", username); |
| 91 |
|
return 0; |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
log_common("User [%s] authentication failed (%d/%d)", username, |
| 95 |
|
i + 1, BBS_login_retry_times); |
| 96 |
iflush(); |
iflush(); |
| 97 |
} |
} |
| 98 |
} |
} |
| 99 |
|
|
| 100 |
if (!ok) |
display_file(DATA_LOGIN_ERROR, 1); |
| 101 |
{ |
return -1; |
|
display_file(DATA_LOGIN_ERROR, 1); |
|
|
return -1; |
|
|
} |
|
|
|
|
|
return 0; |
|
| 102 |
} |
} |
| 103 |
|
|
| 104 |
int check_user(const char *username, const char *password) |
int check_user(const char *username, const char *password) |
| 324 |
goto cleanup; |
goto cleanup; |
| 325 |
} |
} |
| 326 |
|
|
|
if (!SSH_v2 && checklevel2(&BBS_priv, P_MAN_S)) |
|
|
{ |
|
|
prints("\033[1;31m非普通账户必须使用SSH方式登录\033[m\r\n"); |
|
|
ret = 1; |
|
|
goto cleanup; |
|
|
} |
|
|
|
|
| 327 |
ret = load_user_info(db, BBS_uid); |
ret = load_user_info(db, BBS_uid); |
| 328 |
|
|
| 329 |
switch (ret) |
switch (ret) |
| 330 |
{ |
{ |
| 331 |
case 0: // Login successfully |
case 0: // Login successfully |
| 332 |
|
if (!SSH_v2 && checklevel2(&BBS_priv, P_MAN_S)) |
| 333 |
|
{ |
| 334 |
|
prints("\033[1;31m非普通账户必须使用SSH方式登录\033[m\r\n"); |
| 335 |
|
ret = 1; |
| 336 |
|
goto cleanup; |
| 337 |
|
} |
| 338 |
break; |
break; |
| 339 |
case -1: // Load data error |
case -1: // Load data error |
| 340 |
prints("\033[1;31m读取用户数据错误...\033[m\r\n"); |
prints("\033[1;31m读取用户数据错误...\033[m\r\n"); |
| 341 |
ret = -1; |
ret = -1; |
| 342 |
goto cleanup; |
goto cleanup; |
| 343 |
case -2: // Enforce update user agreement |
case -2: // Enforce update user agreement |
| 344 |
|
if (!SSH_v2 && checklevel2(&BBS_priv, P_MAN_S)) |
| 345 |
|
{ |
| 346 |
|
prints("\033[1;31m非普通账户必须使用SSH方式登录\033[m\r\n"); |
| 347 |
|
ret = 1; |
| 348 |
|
goto cleanup; |
| 349 |
|
} |
| 350 |
ret = 2; |
ret = 2; |
| 351 |
goto cleanup; |
goto cleanup; |
| 352 |
case -3: // Dead |
case -3: // Dead |