bugFreeciv - Bugs: bug #13643, [Metaticket] Use lua for...

 
 
Show feedback again

bug #13643: [Metaticket] Use lua for customizable database access

Submitted by:  Madeline Book <mbook>
Submitted on:  Sun 07 Jun 2009 04:44:31 AM UTC  
 
Category: generalSeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Assigned to: Matthias Pfafferodt <syntron>Open/Closed: Closed
Release: Operating System: None
Planned Release: 2.4.0

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sat 25 Jun 2011 04:22:53 PM UTC, comment #14:

>> I'm inclined to move the MD5 generation into the Freeciv core
>> code, where the MD5 verification already is.
> I propose to do it in freeciv (or lua). Thus, there is no
> dependency on the database backend to have this function. I
> will check this.

I've moved all MD5'ing into the core code as part of bug #18170.

Jacob Nevins <jtn>
Project Administrator
Wed 22 Jun 2011 07:07:22 PM UTC, comment #13:

I hope to have internet ready at the end of this week - after the backlog is finished I can also start doing something for freeciv again ...

> Unless I've missed something, the area of authentication and
> databases in Freeciv is short on documentation. It would be nice
> if there were some sort of README.auth or README.fcdb explaining
> how a server operator would set up authentication -- I'm finding
> that I have to reverse engineer it from the code. (This was true
> already, but the instructions will presumably be different after
> this work.)


I will do such an README file

> Is the database.lua checked in to trunk intended to work with
> backends other than MySQL? I ask because it references
> luasql._MYSQLVERSION. Is a server operator who wants to use
> (say) SQLite expected to rewrite database.lua?


At the moment it is mainly the old backend (mysql). For other backends such a lua file has to be written. THe main difference would be to replace all references to the mysql lua module to another luasql module.

> Talking of dependencies on MySQL, we've discovered in bug
> #18170 that database.lua:user_save() depends on the SQL
> function "md5()" (as did the C code that pre-dated it). Is
> this supported by backends other than MySQL (SQLite,
> Postgres)? It smells like a proprietary extension; I can't
> find mention of it in the SQLite docs.
> I'm inclined to move the MD5 generation into the Freeciv core
> code, where the MD5 verification already is. Alternatively,
> verification could be moved out of the core code into Lua, I
> suppose.


I propose to do it in freeciv (or lua). Thus, there is no dependency on the database backend to have this function. I will check this.

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Tue 21 Jun 2011 10:46:18 PM UTC, comment #12:

Some random questions:

Unless I've missed something, the area of authentication and databases in Freeciv is short on documentation. It would be nice if there were some sort of README.auth or README.fcdb explaining how a server operator would set up authentication -- I'm finding that I have to reverse engineer it from the code. (This was true already, but the instructions will presumably be different after this work.)

Is the database.lua checked in to trunk intended to work with backends other than MySQL? I ask because it references luasql._MYSQLVERSION. Is a server operator who wants to use (say) SQLite expected to rewrite database.lua?

Talking of dependencies on MySQL, we've discovered in bug #18170 that database.lua:user_save() depends on the SQL function "md5()" (as did the C code that pre-dated it). Is this supported by backends other than MySQL (SQLite, Postgres)? It smells like a proprietary extension; I can't find mention of it in the SQLite docs.
I'm inclined to move the MD5 generation into the Freeciv core code, where the MD5 verification already is. Alternatively, verification could be moved out of the core code into Lua, I suppose.

Jacob Nevins <jtn>
Project Administrator
Mon 10 Jan 2011 10:28:30 AM UTC, comment #11:

updated all patches of this meta ticket (see dependencies)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Thu 28 Oct 2010 05:29:22 PM UTC, comment #10:

the following patches belong to this metaticket:

[01/04] patch #2114: [fcdb] add luasql files
[02/04] patch #2115: [fcdb] redo lua script
[03/04] patch #2116: [fcdb] freeciv database lua script (fcdb)
[04/04] patch #2117: [fcdb] use fcdb for authentication

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Wed 27 Oct 2010 09:45:11 PM UTC, comment #9:

and here is the missing patch file

(file #10957)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Wed 27 Oct 2010 09:44:35 PM UTC, comment #8:

WIP patch to implement the database connection via luasql:

  • split auth.c into auth.c (autentication) and fcdb.c (freeciv database)
  • add luasql files (only mysql working; postgres prepared)
  • add database.lua file with the needed functions
  • changed options for the server:

-D (--Database <file>)
-a (--auth)

  • new command: fcdb (at the moment only reload)
  • cleanup definition of database config
  • split common lua script functions into a new file (luascript.c)
  • rename script.c/api.pkg to script_game.c/tolua_game.pkg
  • add script_fcdb.c/tolua_fcdb.pkg as entry point for luasql
  • add api for logging (api_log.c)
  • check arguments to script functions against the defined values

The patch will be splitted into smaller part before submission. At the moment I would like some comments (that should be changed; are the lua function correct, that directory layout should be used for ./server/scripting/, ...).

Using this patch as well as the newcommer patches freeciv 2.4.x should be ready to be used by the longturn community ...

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Mon 25 Oct 2010 08:28:57 PM UTC, comment #7:

> I can affirm to you it works well. All warservers run it for
> more than 2 years with it for the authentication and for the
> ranking system.


The code is in warserver but it was never used. Warserver still relys on hardcoded mysql access. But the code is a good starting point. I will post more after it is working.

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Thu 08 Apr 2010 11:37:14 PM UTC, comment #6:

> Question is, does book's code work? Is it complete or missing
> something?


I can affirm to you it works well. All warservers run it for more than 2 years with it for the authentication and for the ranking system.

pepeto <pepeto>
Project Member
Thu 08 Apr 2010 10:31:55 PM UTC, comment #5:

After a brief look at database.[ch] (I don't know if I have the latest version) I see that it uses some form of Lua integration. The Lua state for the database should be independent of the game/server Lua state that we use for ruleset scripts.

Question is, does book's code work? Is it complete or missing something?

Engla <englabenny>
Project Member
Thu 08 Apr 2010 09:40:19 PM UTC, comment #4:

> Such code has been already done in warclient by Book. See trunk/server/database.[ch].


I through more about doing this in lua. As said in comment #0 this could/should support mysql as well as postgres or any other database which lua supports.

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Thu 08 Apr 2010 08:38:15 PM UTC, comment #3:

Such code has been already done in warclient by Book. See trunk/server/database.[ch].

pepeto <pepeto>
Project Member
Thu 08 Apr 2010 08:34:27 PM UTC, comment #2:

@Ulrik Sverdrup: would it be possible to support user authentication (database) via a lua script? It would need mysql (mainline freeciv) and postgres (longturn) connectors

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Sat 28 Nov 2009 11:09:14 PM UTC, comment #1:

Yes, please. anything that would make interaction between Freeciv and a database more extensible would be welcome. (:

Theodore Munk <boozerbear>
Sun 07 Jun 2009 04:44:31 AM UTC, original submission:

I propose that the current auth code and all
future database interfacing code be written
in lua scripts.

This would have the following advantages:
- No need to recompile to change the way the
database is used (e.g. table field names,
sql statment format, etc.).
- Support for databases other than mysql.
- Easily extended beyond just auth.

For example longturn currently uses postgresql
instead of mysql, and warclient servers use
password salt.

The lua database bindings are provided by LuaSQL
(http://www.keplerproject.org/luasql/). It would
be added to the 'dependencies' directory, with
specific driver libraries only being compiled
and linked to the main server executable if the
corresponding database is detected by configure.

As a first step the lua integration would
proceed by combining much of the functionality
of the functions

authenticate_user
process_authentication_status
handle_authentication_reply

into a single script entry point (i.e. a function
that is expected to exist in the database script).
A stand-alone lua state is created for this script
in auth_init().

The lua function will need to return a status
value indicating how the connection should be
handled (e.g. 'accept', 'wait', 'reject').

The script would need to be able to manipulate
'user' objects, which correspond to 'struct
connection'. Methods should be provided which
allow access to at least 'id', 'name' and
'password' information. An alternative would
be to pass the required information to the
script function each time it is invoked.

Possibly all "auth" string occurences in the code
and in filenames should be changed to "database",
in preparation for future generalization.

I'll clarify and revise the details as I test out
a tentative implementation (though this will not
be very high priority for a while).

----------------------------------------------------------------
誰かが月を一口食いちぎたようだ。

Madeline Book <mbook>
Project Member

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #10957:  database.diff.bz2 added by syntron (58kB - application/x-bzip2)

 

Digest:
   patch dependencies.

Digest:
   patch dependencies.

 

Carbon-Copy List
  • -unavailable- added by jtn (Posted a comment)
  • -unavailable- added by englabenny (Posted a comment)
  • -unavailable- added by pepeto (Posted a comment)
  • -unavailable- added by syntron (Posted a comment)
  • -unavailable- added by englabenny (I'll share what I know about LUa)
  • -unavailable- added by boozerbear (Posted a comment)
  • -unavailable- added by mbook (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 19 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 17 Jan 2011 03:13:31 PM UTCsyntronStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Mon 10 Jan 2011 10:25:48 AM UTCsyntronDependencies-=>Depends on patch #2294
      Dependencies-=>Depends on patch #2293
    Thu 23 Dec 2010 12:44:19 PM UTCsyntronDependenciesRemoved dependancy to patch #2121=>-
    Fri 29 Oct 2010 08:15:58 PM UTCsyntronDependencies-=>Depends on patch #2121
      Dependencies-=>Depends on patch #2120
    Thu 28 Oct 2010 05:29:38 PM UTCsyntronDependencies-=>Depends on patch #2117
      Dependencies-=>Depends on patch #2116
      Dependencies-=>Depends on patch #2115
      Dependencies-=>Depends on patch #2114
    Thu 28 Oct 2010 05:29:22 PM UTCsyntronStatusIn Progress=>Ready For Test
      Summary[RFC] Use lua for customizable database access=>[Metaticket] Use lua for customizable database access
    Wed 27 Oct 2010 09:45:11 PM UTCsyntronAttached File-=>Added database.diff.bz2, #10957
    Wed 27 Oct 2010 09:44:35 PM UTCsyntronPriority3 - Low=>5 - Normal
      StatusNone=>In Progress
      Assigned toNone=>syntron
      Planned Release=>2.4.0
    Sat 27 Mar 2010 02:30:59 PM UTCenglabennyCarbon-Copy-=>Added englabenny
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup