Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions in README cause root owned files to appear in the local filesystem #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pfrenssen
Copy link
Member

ISAICP-5825

Description

When running tests according to the instructions in the README the user ends up with a bunch of root-owned files that are created during the tests.

Let's update the README with safe instructions so that a potential bug in a test will not accidentally overwrite critical files.

Change log

  • Fixed: README updated with instructions on how to safely run the unit tests

@@ -76,7 +76,7 @@ docker-compose exec web ./vendor/bin/grumphp run
To run the phpunit tests:

```bash
docker-compose exec web ./vendor/bin/phpunit
docker-compose exec --user=$(id -u):$(id -g) web ./vendor/bin/phpunit
Copy link
Contributor

@idimopoulos idimopoulos May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work 100% of the use cases.. What happens with docker is that the mapping of file ownership between the host and the container are based strictly on the User ID and the Group ID of the user that runs the command. That being said, it works in probably most of the cases as most unix systems tend to have the default user to be with GID and UID 1000.
This is what happens in your case as well (and mine too).
If however, you were a secondary user in your machine, with GID 1001 and UID 1001 this is a missdirection as the files would either again fail to create or have the files owned by root as well.
At least i mostly think it does :D

Copy link
Member Author

@pfrenssen pfrenssen May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "a secondary user"? Do you mean using su to switch to a different user?

Note that I am not hardcoding any UID and GID, but getting the correct values dynamically from the user running the command. It seems to work as expected.

I just tried this by creating a second user, and switching to it, and both id -u and id -g give the expected results:

[pieter@thinkarch ~]$ sudo useradd testuser
[pieter@thinkarch ~]$ sudo su testuser -s /bin/bash
[testuser@thinkarch pieter]$ id -u
2002
[testuser@thinkarch pieter]$ id -g
2002

I got this trick from here: docker/compose#1532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants