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

Add more defensive mkdir for GEM_HOME #463

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

tianon
Copy link
Member

@tianon tianon commented Jun 25, 2024

This drops the -p argument in mkdir -p "$GEM_HOME" to ensure that this validates our assumption that our GEM_HOME did not exist before this line and is indeed created (as a new, empty directory) by this line.

cc @whalelines (whose idea validating better this was)

Copy link

@whalelines whalelines left a comment

Choose a reason for hiding this comment

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

Question about $GEM_HOME parent directories.

# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 1777 "$GEM_HOME"
RUN set -eux; \
mkdir "$GEM_HOME"; \

Choose a reason for hiding this comment

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

Do we expect all parent directories of $GEM_HOME to exist? Removing the -p causes mkdir to fail if the directory already exists, which is desireable, but it also means parent directories are not automatically created, which would be bad if all of $GEM_HOME's parent directory do not exist in the image layers prior to this RUN command.

Choose a reason for hiding this comment

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

It looks like all the Dockerfiles have a mkdir -p /usr/local/etc in a previous RUN statement, so this should be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, and Ruby itself ends up in /usr/local via make install

Copy link

@whalelines whalelines left a comment

Choose a reason for hiding this comment

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

Should work because of the earlier mkdir -p /usr/local/etc

@yosifkit yosifkit merged commit c069afc into docker-library:master Jun 27, 2024
26 checks passed
@yosifkit yosifkit deleted the mkdir-gem-home branch June 27, 2024 23:51
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jun 28, 2024
Changes:

- docker-library/ruby@c069afc: Merge pull request docker-library/ruby#463 from infosiftr/mkdir-gem-home
- docker-library/ruby@f69cac9: Add more defensive `mkdir` for `GEM_HOME`
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jul 9, 2024
Changes:

- docker-library/ruby@2e432fc: Update 3.3 to 3.3.4
- docker-library/ruby@c069afc: Merge pull request docker-library/ruby#463 from infosiftr/mkdir-gem-home
- docker-library/ruby@f69cac9: Add more defensive `mkdir` for `GEM_HOME`
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.

4 participants