Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] Re: (PR#10074) auth database issues
Home

[Freeciv-Dev] Re: (PR#10074) auth database issues

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#10074) auth database issues
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 12 Sep 2004 13:28:07 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10074 >

new patch which defines MAX_LEN_PASSWORD to 512 and uses it. Also adds a
comment on returning an int.

-mike

Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.194
diff -u -r1.194 civclient.c
--- client/civclient.c  6 Sep 2004 17:13:06 -0000       1.194
+++ client/civclient.c  12 Sep 2004 20:27:01 -0000
@@ -75,7 +75,7 @@
 char sound_set_name[512] = "\0";
 char server_host[512] = "\0";
 char user_name[512] = "\0";
-char password[MAX_LEN_NAME] = "\0";
+char password[MAX_LEN_PASSWORD] = "\0";
 char metaserver[512] = "\0";
 int  server_port = -1;
 bool auto_connect = FALSE; /* TRUE = skip "Connect to Freeciv Server" dialog */
Index: client/civclient.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.h,v
retrieving revision 1.33
diff -u -r1.33 civclient.h
--- client/civclient.h  10 Apr 2004 03:47:48 -0000      1.33
+++ client/civclient.h  12 Sep 2004 20:27:01 -0000
@@ -45,7 +45,7 @@
 extern char sound_set_name[512];
 extern char server_host[512];
 extern char user_name[512];
-extern char password[MAX_LEN_NAME];
+extern char password[MAX_LEN_PASSWORD];
 extern char metaserver[512];
 extern int  server_port;
 extern bool auto_connect;
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.185
diff -u -r1.185 capstr.c
--- common/capstr.c     12 Sep 2004 01:35:59 -0000      1.185
+++ common/capstr.c     12 Sep 2004 20:27:01 -0000
@@ -73,7 +73,7 @@
  * are not directly related to the capability strings discussed here.)
  */
 
-#define CAPABILITY "+Freeciv.Devel.2004.Sep.9"
+#define CAPABILITY "+Freeciv.Devel.2004.Sep.12"
 
 void init_our_capability(void)
 {
Index: common/connection.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/connection.h,v
retrieving revision 1.36
diff -u -r1.36 connection.h
--- common/connection.h 9 Sep 2004 17:23:41 -0000       1.36
+++ common/connection.h 12 Sep 2004 20:27:01 -0000
@@ -40,6 +40,7 @@
 
 #define MAX_LEN_BUFFER   (MAX_LEN_PACKET * 128)
 #define MAX_LEN_CAPSTR    512
+#define MAX_LEN_PASSWORD  512 /* do not change this under any circumstances */
 
 /**************************************************************************
   Command access levels for client-side use; at present, they are only
@@ -191,7 +192,7 @@
 
     /* used to follow where the connection is in the authentication process */
     enum auth_status status;
-    char password[MAX_LEN_NAME];
+    char password[MAX_LEN_PASSWORD];
   } server;
 
   /*
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.49
diff -u -r1.49 packets.def
--- common/packets.def  12 Sep 2004 01:35:59 -0000      1.49
+++ common/packets.def  12 Sep 2004 20:27:01 -0000
@@ -262,7 +262,7 @@
 end
 
 PACKET_AUTHENTICATION_REPLY=7;cs,no-handle
-  STRING password[MAX_LEN_NAME];
+  STRING password[MAX_LEN_PASSWORD];
 end
 
 
Index: server/connecthand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/connecthand.c,v
retrieving revision 1.25
diff -u -r1.25 connecthand.c
--- server/connecthand.c        10 Sep 2004 21:20:53 -0000      1.25
+++ server/connecthand.c        12 Sep 2004 20:27:03 -0000
@@ -415,7 +415,7 @@
 
     establish_new_connection(pconn);
   } else if (pconn->server.status == AS_REQUESTING_OLD_PASS) { 
-    if (strncmp(pconn->server.password, password, MAX_LEN_NAME) == 0) {
+    if (userdb_check_password(pconn, password, strlen(password)) == 1) {
       pconn->server.status = AS_ESTABLISHED;
       establish_new_connection(pconn);
     } else {
Index: server/userdb/user_db.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/userdb/user_db.c,v
retrieving revision 1.3
diff -u -r1.3 user_db.c
--- server/userdb/user_db.c     28 Nov 2003 17:37:23 -0000      1.3
+++ server/userdb/user_db.c     12 Sep 2004 20:27:03 -0000
@@ -60,6 +60,18 @@
 }
 
 /**************************************************************************
+  Check if the password with length len matches that given in 
+  pconn->server.password.
+  If so, return 1, else return 0. We return an int instead of boolean here
+  because external databases might not know what bool is.
+***************************************************************************/
+int userdb_check_password(struct connection *pconn, 
+                         const char *password, int len)
+{
+  return (strncmp(pconn->server.password, password, len) == 0) ? 1 : 0;
+}
+
+/**************************************************************************
  Loads a user from the database.
 **************************************************************************/
 enum userdb_status user_db_load(struct connection *pconn)
Index: server/userdb/user_db.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/userdb/user_db.h,v
retrieving revision 1.2
diff -u -r1.2 user_db.h
--- server/userdb/user_db.h     12 Sep 2003 02:31:40 -0000      1.2
+++ server/userdb/user_db.h     12 Sep 2004 20:27:03 -0000
@@ -29,6 +29,8 @@
   USER_DB_NOT_FOUND
 };
 
+int userdb_check_password(struct connection *pconn,
+                         const char *password, int len);
 enum userdb_status user_db_load(struct connection *pconn);
 enum userdb_status user_db_save(struct connection *pconn);
 

[Prev in Thread] Current Thread [Next in Thread]