The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: kim27 on January 18, 2016, 09:01:42 AM

Title: Simutrans passwords on server restart
Post by: kim27 on January 18, 2016, 09:01:42 AM
Hi all,

I'm a bit confused about my server. I am trying to stop the server when no one is playing... would rather not have it running at all when no one is playing, also keeps us focused on other stuff so we don't over do it.

At any rate, every time I restart the server all the passwords are gone!

I found that the password hashes are bz2 encoded, and that the file looks good until restart. It looks like the file gets overwritten when the server starts with a blank slate. I think it has something to do with not sending the password hashes over the network.

Then it looks like when a client connects, it attempts to read this "fresh" password file. Which is great and all, but it is too small to read! Yes, the bz2 calls in loadsave_t::rd_open require the compressed file be at least 80 bytes long, and well, my file is 74 bytes long after getting stomped. Not that it really matters because I think the real source of the trouble is stomping the file in the first place.  :o

Any help you can offer would be appreciated. This is version 120-1-1 running on Ubuntu if it matters.

Thanks,

Kim27
Title: Re: Simutrans passwords on server restart
Post by: prissi on January 18, 2016, 11:16:31 PM
First, there is an autopause of the server if nobody is connected (parameter pause_server_no_clients=1 in simuconf.tab).

Second, you should use zipped for networkgames, since the time for bz2 compression is much longer than for a usual data transfer.

Third, that bzip cannot unpack these files is an error of that libary. I never run into any such problems with bz2. Still, the password hashes do not need any compression. I changed them hardcoded to zipped, just as lazy way for corruption tests.
Title: Re: Simutrans passwords on server restart
Post by: DrSuperGood on January 18, 2016, 11:57:26 PM
QuoteSecond, you should use zipped for networkgames, since the time for bz2 compression is much longer than for a usual data transfer.
Depends on the upload bandwidth and processor available. If you have poor upload and a fast CPU (most simutrans servers) then the time trade off might be worth it. That said, it is generally not.

Quote
I think it has something to do with not sending the password hashes over the network.
Clients never receive the password hashes as that would be insecure (they could pull them from the file to log into any company). Instead when you enter a password it gets sent to the server, checked against or saved with the hashes stored on the server, and the result (pass/fail) sent back to the client. As such the password loss must be happening on the server side since the clients never retain the passwords.

Quote
This is version 120-1-1 running on Ubuntu if it matters.
It could very well be a permission problem with the password file. Make sure that the server account has all reasonable file permissions set for the password file. From my experience with Linux systems that is generally one of the most common errors.
Title: Re: Simutrans passwords on server restart
Post by: TurfIt on January 19, 2016, 05:36:04 AM
Quote from: kim27 on January 18, 2016, 09:01:42 AM
At any rate, every time I restart the server all the passwords are gone!
How are you restarting the server? You can't use the -load parameter to load a different savegame, the file must be called server{xxx}-network.sve as created automatically. {xxx} is port number.

If you're trying to use the server_save_game_on_quit=1 function, the resultant server{xxx}-restore.sve must be manually renamed  *-network.sve so the hashes are reloaded.

i.e. The two files must be server{xxx}-network.sve and server{xxx}-pwdhash.sve both in the main simutrans directory (not save/), and loaded by the -server parameter, not -load.
Title: Re: Simutrans passwords on server restart
Post by: kim27 on February 01, 2016, 04:06:15 PM
Thanks for the info. I was having a hard time getting the game to run without load. Finally figured out that I needed -objects pak along with -lang en

Thanks for the help!