How to start a server with authentication?

You can get help here if Freeciv doesn't start on your computer, or if you keep getting fatal errors while playing etc.
User avatar
Corbeau
Elite
Posts: 1052
Joined: Mon Jan 13, 2014 11:13 pm

How to start a server with authentication?

Postby Corbeau » Wed May 29, 2019 12:35 pm

I'm trying to start a multiplayer server with authentication support. Also, what I need is to have a script that does an autosave every hour (or so). So there are two sets of problems.

1. If I start the bare server, it would probably be easy to setup a database and password stuff would resolve itself automatically. I may need a ilttle bit of help with that, but it seems straightforward. however, that leaves the autosave-per-hour thing unresolved.

2. I could also use the Longturn.org/net files that have the autosave-per-hour thing pretty solved, but they seem to require a server/site-side support (password database) which I don't have at this server. I struggled with several layers of problems on this path, but I finally ended here:

Code: Select all

This is the server for Freeciv version 2.5.11+ (f554d58727)
This freeciv-server program has player authentication support, but it's currently not in use.


Code: Select all

2: Connection request from Corbeau from iskon988.duo.carnet.hr
2: c1 has client version 2.5.7
2: AUTHPROG not set
2: Client rejected: Corbeau from iskon988.duo.carnet.hr (connection incomplete).
2: Corbeau was rejected: Only preregistered users allowed, or illegal username.
2: Lost connection: Corbeau from iskon988.duo.carnet.hr (rejected).


Basically, I could cut out the part where the server connects to the LT on-site password database, but I tried and failed.

Any help with solving either of these problems would be gladly received.

cazfi
Elite
Posts: 1721
Joined: Tue Jan 29, 2013 6:54 pm

Re: How to start a server with authentication?

Postby cazfi » Wed May 29, 2019 3:12 pm

You need this for 2.5? Freeciv-2.6 supports timer based autosaves.

Code: Select all

> explain autosaves
Option: autosaves  -  Which savegames are generated automatically
...
  - "Timer" (TIMER): Save every 'savefrequency' minutes.
...
> explain savefrequency
Option: savefrequency  -  Minutes per auto-save
...

User avatar
Corbeau
Elite
Posts: 1052
Joined: Mon Jan 13, 2014 11:13 pm

Re: How to start a server with authentication?

Postby Corbeau » Wed May 29, 2019 3:15 pm

Yes, 2.5. I have a ruleset that is ready now and it will take a while to translate it to 2.6.

User avatar
Corbeau
Elite
Posts: 1052
Joined: Mon Jan 13, 2014 11:13 pm

Re: How to start a server with authentication?

Postby Corbeau » Sat Jun 01, 2019 12:20 am

Next problem.

I found the short manual that is telling me exactly what I need to know... except it doesn't work. I did everything up to this point:

Code: Select all

Now start the server with
  freeciv-server --Database fc_auth.conf --auth --Newusers

The first time you do this, you need to create the database file and its
tables with the following server command:
  /fcdb lua sqlite_createdb()


After that, the server starting ends up with:

Code: Select all

1: [sqlite:connect]: LuaSQL: unable to open database file

which indeed makes perfect sense. Unable to open database file because the database file doesn't exist yet. I'm supposed to start the server in order to create the DB file, however, I can't start the server because the DB file needs to be created first.

I tried starting the server without those command lines and then creating the database, but I got, obviously:

Code: Select all

Freeciv database script not activated at server start. See the Freeciv server's --auth command line option.

cazfi
Elite
Posts: 1721
Joined: Tue Jan 29, 2013 6:54 pm

Re: How to start a server with authentication?

Postby cazfi » Sat Jun 01, 2019 12:50 am

It worked last time I needed it... (can't test just now). Simply starting the server program should not require existing database, but you should be able to enter that 'fcdb' -command before it's needed.

What your fc_auth.conf looks like? Do you have write permissions to the directory where the database is about to get created?

cazfi
Elite
Posts: 1721
Joined: Tue Jan 29, 2013 6:54 pm

Re: How to start a server with authentication?

Postby cazfi » Sat Jun 01, 2019 12:59 am

It actually creates an empty database file when server is started, the 'fcdb' -command can/must then be used to populate it.

cazfi
Elite
Posts: 1721
Joined: Tue Jan 29, 2013 6:54 pm

Re: How to start a server with authentication?

Postby cazfi » Sat Jun 01, 2019 1:29 pm

cazfi wrote:Do you have write permissions to the directory where the database is about to get created?

I got the same error message as you when I specified unwritable location for the database file.

User avatar
Corbeau
Elite
Posts: 1052
Joined: Mon Jan 13, 2014 11:13 pm

Re: How to start a server with authentication?

Postby Corbeau » Sat Jun 01, 2019 4:51 pm

Just checking, drwxr-xr-x (755) is fine? Doesn't have to be 777 or something? Because it's 755 everywhere I checked.

User avatar
Corbeau
Elite
Posts: 1052
Joined: Mon Jan 13, 2014 11:13 pm

Re: How to start a server with authentication?

Postby Corbeau » Sat Jun 01, 2019 6:30 pm

So let's review my steps.

Game is installed in ~/games/GT0 directory. (Ignore the GT0 part, it's another mystery I'm trying to solve. Long story.)

File freeciv-server is in .../GT0/bin directory

File: GT0_auth.conf (755) in the same directory. Content:

Code: Select all

[fcdb]
backend="sqlite"
database="$HOME/games/GT0/game.sqlite"


Command line:

freeciv-server --Database GT0_auth.conf --auth --Newusers

Result as described above:
1: [sqlite:connect]: LuaSQL: unable to open database file

ALL relevant files and folders I checked are (d)rwxr-xr-x.

cazfi
Elite
Posts: 1721
Joined: Tue Jan 29, 2013 6:54 pm

Re: How to start a server with authentication?

Postby cazfi » Sat Jun 01, 2019 6:44 pm

Corbeau wrote:File: GT0_auth.conf (755) in the same directory. Content:

Code: Select all

[fcdb]
backend="sqlite"
database="$HOME/games/GT0/game.sqlite"

It's not a shell script! Freeciv does not know that by "$HOME" you mean value of the environment variable HOME.