panel icon indicating copy to clipboard operation
panel copied to clipboard

Server startup command is executed with non-existent user

Open argetlam-coder opened this issue 2 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues before opening this issue.

Current Behavior

When wings is installed, it creates a user named pterodactyl. This user apparently gets the first free UID, which is less than 1000. The UID of the created user is used as user inside the server container e.g. to execute the startup command. However, in almost all cases there is no user with this UID in the containers. Some servers seem to have a problem with the user not having a username and therefore do not start (e.g. DayZ).

Expected Behavior

In every pterodactyl image that I have seen so far, a user named container is created. This user always seems to have the UID 1000. Shouldn't the containers or the start commands be executed with this user? Is the container run with a user that does not exist in the containers for security reasons?

I changed the UID of the user pterodactyl on the host system to 1000 for testing and also adjusted it in the wings configuration. After this change the server starts without any problems. However, I am not sure now if this makes my setup more insecure.

Steps to Reproduce

This behavior occurs with every server. However, it seems to be a problem only on a few servers (e.g. DayZ).

I can also provide my DayZ egg for testing if needed.

Panel Version

1.6.6

Wings Version

1.5.3

Error Logs

No response

argetlam-coder avatar Dec 26 '21 13:12 argetlam-coder

I can confirm this. When User and Group pterodactyl is 1000, the dayz egg work now. i test it with other, but it would be great, when this can be changed

gOOvER avatar Dec 27 '21 09:12 gOOvER

User management with containers is a mess, TL;DR is that only the UID and GIDs on the host matter. I still need to look into if we actually need to create the user within the container as it seems when we pass the UID and GID when running the container, there is no need for the container to create and switch to it's own user.

Other than that, this is not really a bug.

Related to https://github.com/pterodactyl/wings/pull/106

matthewpi avatar Jan 16 '22 20:01 matthewpi

There is no need to create a new user in the containers. In each container exists the user container, which has the UID 1000 and GUID 1000, because it is the first and only user. Probably it would be enough to pass 1000 as UID and GID when running the container but the corresponding options in config.yml get overwritten every time wings is started.

argetlam-coder avatar Jan 28 '22 21:01 argetlam-coder

@matthewpi it helps keep the file permissions outside of the container correct, which is why it was done that way if I remember correctly.

DaneEveritt avatar Jan 28 '22 22:01 DaneEveritt

I've run into this once before and was able to fix it by exporting USER=pterodactyl. No idea if that will work in this particular case, but the symptoms were similar where it would work if the UID was 1000, but if it was under 1000 it only worked when the user variable was set.

iamkubi avatar Feb 01 '22 19:02 iamkubi

Here is the answer from the DayZ Linux Server Dev:

I think I can further narrow down the cause of this problem. Basically, the server works in a Docker container. However, when starting the Docker container, it is possible to set the UID and GID under which the commands are executed within the container. If you use a UID and GID for which there is no user in the container, then the commands are executed under a user that has no user name. Instead of the user name, only "I have no name" is displayed. For most commands and programs this does not seem to be a problem but the DayZ server crashes when executed by a user who does not have a username.

https://feedback.bistudio.com/T162311

gOOvER avatar Feb 01 '22 20:02 gOOvER

So as we have a default user we have in the wings config I do think it's worhwhile to just set the uid in the container to match it.

So we would need to update the useradd to specify uid 988

As seen here - https://github.com/pterodactyl/wings/blob/2b2b5200eb5f208e44f6c5303ace37529d208986/config/config.go

parkervcp avatar Feb 01 '22 21:02 parkervcp

@gOOvER This is not an answer from the developers. I have added this comment to this issue so that the developers can search more specifically for the problem.

@parkervcp The UID is not always 998, it can be different on each system. The default pterodactyl user gets the first free ID under 1000, so which ID he gets depends on how many users already exist on the system when pterodactyl is installed.

argetlam-coder avatar Feb 02 '22 06:02 argetlam-coder

Discord_v8Mi32DRWA

More info's from Dev; they don't care about in their server

gOOvER avatar Apr 16 '22 18:04 gOOvER