/[LeafOK_CVS]/lbbs/src/login.c
ViewVC logotype

Diff of /lbbs/src/login.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.60 by sysadm, Sat Oct 18 14:35:04 2025 UTC Revision 1.65 by sysadm, Tue Nov 4 13:49:51 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    login.c  -  description  /*
3                                                           -------------------   * login
4          Copyright            : (C) 2004-2025 by Leaflet   *   - user authentication and online status manager
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "bbs.h"  #include "bbs.h"
10  #include "common.h"  #include "common.h"
# Line 32  Line 24 
24  #include <mysql/mysql.h>  #include <mysql/mysql.h>
25  #include <sys/param.h>  #include <sys/param.h>
26    
27    static const int BBS_username_min_len = 3; // common len = 5, special len = 3
28    static const int BBS_password_min_len = 5; // legacy len = 5, current len = 6
29    
30  int bbs_login(void)  int bbs_login(void)
31  {  {
32          char username[BBS_username_max_len + 1];          char username[BBS_username_max_len + 1];
# Line 114  int check_user(const char *username, con Line 109  int check_user(const char *username, con
109          // Verify format          // Verify format
110          for (i = 0; ok && username[i] != '\0'; i++)          for (i = 0; ok && username[i] != '\0'; i++)
111          {          {
112                  if (!(isalpha(username[i]) || (i > 0 && isdigit(username[i]))))                  if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_'))))
113                  {                  {
114                          ok = 0;                          ok = 0;
115                  }                  }
116          }          }
117          if (ok && (i < 3 || i > 12))          if (ok && (i < BBS_username_min_len || i > BBS_username_max_len))
118          {          {
119                  ok = 0;                  ok = 0;
120          }          }
# Line 130  int check_user(const char *username, con Line 125  int check_user(const char *username, con
125                          ok = 0;                          ok = 0;
126                  }                  }
127          }          }
128          if (ok && (i < 5 || i > 12))          if (ok && (i < BBS_password_min_len || i > BBS_password_max_len))
129          {          {
130                  ok = 0;                  ok = 0;
131          }          }
# Line 503  int user_online_add(MYSQL *db) Line 498  int user_online_add(MYSQL *db)
498          }          }
499    
500          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
501                           "INSERT INTO user_online(SID, UID, ip, login_tm, last_tm) "                           "INSERT INTO user_online(SID, UID, ip, current_action, login_tm, last_tm) "
502                           "VALUES('Telnet_Process_%d', %d, '%s', NOW(), NOW())",                           "VALUES('Telnet_Process_%d', %d, '%s', 'LOGIN', NOW(), NOW())",
503                           getpid(), BBS_priv.uid, hostaddr_client);                           getpid(), BBS_priv.uid, hostaddr_client);
504          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
505          {          {
# Line 579  int user_online_update(const char *actio Line 574  int user_online_update(const char *actio
574          }          }
575    
576          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
577                           "UPDATE user_online SET current_action = '%s', last_tm=NOW() "                           "UPDATE user_online SET current_action = '%s', last_tm = NOW() "
578                           "WHERE SID = 'Telnet_Process_%d'",                           "WHERE SID = 'Telnet_Process_%d'",
579                           BBS_current_action, getpid());                           BBS_current_action, getpid());
580          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1