-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Match Container's User and Group to Host #49962
Merged
noahtallen
merged 20 commits into
WordPress:trunk
from
ObliviousHarmony:try/env-container-ownership
Apr 28, 2023
Merged
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b61c0ef
Changed Environment Container User
ObliviousHarmony 027a071
Changelog
ObliviousHarmony cdaf544
Create Group When It Doesn't Exist
ObliviousHarmony 6c02538
Marked Breaking Change
ObliviousHarmony 97c23c5
Moved `getHostUser()` To Dedicated File
ObliviousHarmony 63f1144
Merge branch 'trunk' into try/env-container-ownership
ObliviousHarmony bd9164a
Removed Upload Permission Mod
ObliviousHarmony 3ffa6f4
Added Shared Home Directory
ObliviousHarmony 269b574
Fixed Dangling Containers
ObliviousHarmony 2c2347f
Isolated Docker Service Images
ObliviousHarmony 9b9edda
Removed Some Duplication
ObliviousHarmony 8ddef45
Added Destroy Note To Changelog
ObliviousHarmony d252b8b
Documented getHostUser Windows Handling
ObliviousHarmony 3867a1d
Update packages/env/CHANGELOG.md
ObliviousHarmony 27eaca1
Fixed Debian Stretch Repositories
ObliviousHarmony 9cd128e
Updated Documentation
ObliviousHarmony 3a4146a
Added Debian Stretch Archive List Link
ObliviousHarmony aab3e3d
Merge branch 'trunk' into try/env-container-ownership
ObliviousHarmony 5d9f976
Moved CLI Sleep Into Dockerfile
ObliviousHarmony 3424a05
Update CHANGELOG.md
noahtallen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const os = require( 'os' ); | ||
|
||
/** | ||
* Gets information about the host user. | ||
* | ||
* @return {Object} The host user's name, uid, and gid. | ||
*/ | ||
module.exports = function getHostUser() { | ||
const hostUser = os.userInfo(); | ||
|
||
// On Windows the uid and gid will be -1. Since there isn't a great way to handle this, | ||
// we're just going to say that the host user is root. On Windows you'll likely be | ||
// using WSL to run commands inside the container, which has a uid and gid. If | ||
// you aren't, you'll be mounting directories from Windows, to a Linux | ||
// VM (Docker Desktop uses one), to the guest OS. I assume that | ||
// when dealing with this configuration that file ownership | ||
// has the same kind of magic handling that macOS uses. | ||
const uid = ( hostUser.uid === -1 ? 0 : hostUser.uid ).toString(); | ||
ObliviousHarmony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const gid = ( hostUser.gid === -1 ? 0 : hostUser.gid ).toString(); | ||
|
||
return { | ||
name: hostUser.username, | ||
uid, | ||
gid, | ||
fullUser: uid + ':' + gid, | ||
}; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc section is actually out of date now that we have npx install-path! We could probably change the entire thing to say that you can just
cd $(npx wp-env install-path)
and then see all the generated config files