LiveOverflow/PwnAdventure3

Game server fails to start on Debian

prockallsyms opened this issue · 7 comments

Hi! So last night I gathered the relevant files from the repository, pwn3 website, and docker to use docker-compose to setup the repository. Running the docker-compose binary doesn't fail, however there is a problem with the setup scripts that causes the game server to fail to boot, and exit with code 139:

[sudo] password for pwn3: 
Starting pwnadventure3_init_1 ... done`Starting pwnadventure3_master_1 ... done
Starting pwnadventure3_game_1   ... done
Attaching to pwnadventure3_init_1, pwnadventure3_master_1, pwnadventure3_game_1
master_1  |  * Starting PostgreSQL 9.3 database server
pwnadventure3_init_1 exited with code 0
game_1    | FMallocCrash overhead is 3780608 bytes
game_1    | bash: line 1:     7 Segmentation fault      ./PwnAdventure3Server
pwnadventure3_game_1 exited with code 139
master_1  |    ...done.
master_1  | psql:/opt/pwn3/setup/postgres_init.sql:1: ERROR:  role "pwn3" already exists
master_1  | psql:/opt/pwn3/setup/postgres_init.sql:2: ERROR:  database "master" already exists
master_1  | GRANT
master_1  | rm: cannot remove /opt/pwn3/client/PwnAdventure3_Data/PwnAdventure3/PwnAdventure3/Saved/Logs/*': No such file or irectory
master_1  | No backup data found!
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | DROP TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE TABLE
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | CREATE INDEX
master_1  | INSERT 0 1
master_1  | INSERT 0 1
master_1  | UPDATE 1
master_1  | UPDATE 1
master_1  | Use the following team hash to join the admin team:
master_1  | [local hash not needed for this issue]
master_1  | bash: /opt/pwn3/server/creds: Permission denied

Some more information:

Output of ls:

drwxr-xr-x  9 pwn3 pwn3     4096 May 29 19:23 .
drwxr-xr-x 18 pwn3 pwn3     4096 May 29 16:20 ..
drwxr-xr-x  3 pwn3 pwn3     4096 Mar  2 18:11 client
-rwxr-xr-x  1 pwn3 pwn3 10858808 May 28 21:05 docker-compose
-rw-r--r--  1 pwn3 pwn3     1720 May 28 19:48 docker-compose.yml
-rw-r--r--  1 pwn3 pwn3      250 May 28 19:42 Dockerfile
drwxr-xr-x  8 pwn3 pwn3     4096 May 28 19:42 .git
-rw-r--r--  1 pwn3 pwn3       39 May 28 19:42 .gitignore
-rw-r--r--  1 pwn3 pwn3    35147 May 28 19:42 LICENSE
drwxr-xr-x  2 root root     4096 May 29 01:59 postgres-data
-rw-r--r--  1 pwn3 pwn3     8822 May 28 19:42 README.md
drwxr-xr-x  4 pwn3 pwn3     4096 Mar  3 16:06 server
drwxr-xr-x  2 pwn3 pwn3     4096 May 29 19:25 setup
drwxr-xr-x  2 pwn3 pwn3     4096 May 29 00:31 tmp
drwxr-xr-x  3 pwn3 pwn3     4096 May 28 19:42 tools

Executed from:
host:~/PwnAdventure3/client/PwnAdventure3_Data/PwnAdventure3/PwnAdventure3/Binaries/Linux$

./PwnAdventure3Server: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory

I fixed it. I'll make a resolution pull request. Although I'm not sure if it's going to work for other OSs.

host:~/PwnAdventure3/client/PwnAdventure3_Data/PwnAdventure3/PwnAdventure3/Binaries/Linux$

did you execute the server on your host system?

I guess your permissions are now all screwed up, but at least it's working :D But if you want you could purge the whole docker stuff again and start fresh.

If the issue reappears you could do this troubleshooting:
docker exec -i -t pwnadventure3_game_1 /bin/bash to get a bash shell inside the container, then do:

cd /opt/pwn3/client/PwnAdventure3_Data/PwnAdventure3/PwnAdventure3/Binaries/Linux/
su pwn3
./PwnAdventure3Server

Does this also crash with a segfault? If it crashes can you install strace inside this container and then start the server (as pwn3) with strace ./PwnAdventure3Server

Whatever happens inside your docker container should just work.

You should not execute the client you placed next to the docker-compose.yml on your debian host system since this one is used while running the live game server.
It's better to make a copy instead. Could this be the reason for the permissions issues?

I suggest you download it all again and start from scratch.
Could you please provide the logs of the docker-compose up command?

Yeah. My host machine is down because of a partitioning error I made, but once I figure out how to fix it I'll post the logs.

This happens because pwn3 has no write access to /opt/pwn3/server/creds, there is a step in the master server shell script where it writes the creds in that file. Sending a pull request to fix this.

shw1n commented

Got a shell in the docker container and ran it with strace, the tail end yielded the following:

open(0x7ffc90d84410, O_RDWR|O_CREAT|O_CLOEXEC, 0600) = -1 EACCES (Permission denied)
socket(PF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 65
connect(65, {...}, 110)                 = -1 ENOENT (No such file or directory)
close(65)                               = 0
stat(0x7ffc90d7fa38, 0x7ffc90d7fad0)    = -1 ENOENT (No such file or directory)
mkdir(0x7ffc90d7b938, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d7b8a8, {...})             = 0
mkdir(0x7ffc90d7b938, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d7b8a8, {...})             = 0
mkdir(0x7ffc90d7b938, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d7b8a8, {...})             = 0
mkdir(0x7ffc90d7b938, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d7b8a8, {...})             = 0
mkdir(0x7ffc90d7b938, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d7b8a8, {...})             = 0
mkdir(0x7ffc90d7b938, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d7b8a8, {...})             = 0
stat(0x7ffc90d7b8a8, {...})             = 0
stat(0x7ffc90d7f3b0, 0x7ffc90d7f448)    = -1 ENOENT (No such file or directory)
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
open(0x7ffc90d7f9a0, O_RDWR|O_CREAT|O_CLOEXEC, 0600) = -1 EACCES (Permission denied)
socket(PF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 65
connect(65, {...}, 110)                 = -1 ENOENT (No such file or directory)
close(65)                               = 0
stat(0x7ffc90d7afc8, 0x7ffc90d7b060)    = -1 ENOENT (No such file or directory)
mkdir(0x7ffc90d76ec8, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d76e38, {...})             = 0
mkdir(0x7ffc90d76ec8, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d76e38, {...})             = 0
mkdir(0x7ffc90d76ec8, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d76e38, {...})             = 0
mkdir(0x7ffc90d76ec8, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d76e38, {...})             = 0
mkdir(0x7ffc90d76ec8, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d76e38, {...})             = 0
mkdir(0x7ffc90d76ec8, 0755)             = -1 EEXIST (File exists)
stat(0x7ffc90d76e38, {...})             = 0
stat(0x7ffc90d76e38, {...})             = 0
stat(0x7ffc90d7a940, 0x7ffc90d7a9d8)    = -1 ENOENT (No such file or directory)
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
stat(0x596d8c0, {...})                  = 0
open(0x7ffc90d7af30, O_RDWR|O_CREAT|O_CLOEXEC, 0600) = -1 EACCES (Permission denied)
socket(PF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 65
connect(65, {...}, 110)                 = -1 ENOENT (No such file or directory)
close(65)                               = 0
stat(0x7ffc90d76558, 0x7ffc90d765f0)    = -1 ENOENT (No such file or directory)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x7ffc90d72518} ---
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
+++ killed by SIGSEGV +++
Segmentation fault