-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use shared selinux context for mounts #6294
Conversation
On systems with SElinux enforcing trying to bind a filesystem path without a context will result in an error. Using shared context by default will make `withFileSystemBind(String hostPath, String containerPath)` method work for all systems. On Windows, Mac OS and Linux systems without SElinux it will have no effect. On systems with SElinux enforcing it will make the path accessible to the container. Signed-off-by: monosoul <Kloz.Klaud@gmail.com>
As an SELinux user, I definitely upvote! Thanks for creating this PR! |
Hi, @monosoul, thanks for the PR! Unfortunately, this is a breaking change due to introducing the change will, by default, bind the filesystem instead of copying the file. This will break for those using a remote Docker. Below, you can see the logic described testcontainers-java/core/src/main/java/org/testcontainers/containers/GenericContainer.java Lines 1268 to 1284 in 6fe954a
However, you still can use the method directly. I understand the PR aim to make this easier. Although, I think we can document this if it is not clear. |
@eddumelendez if shared context will be the default one, I could've just changed the condition there to |
Yes, that's right! 🤦🏽♂️ Sorry about that. I just tested locally and with my remote environment and all good. |
@@ -1274,7 +1274,7 @@ public SELF withClasspathResourceMapping( | |||
) { | |||
final MountableFile mountableFile = MountableFile.forClasspathResource(resourcePath); | |||
|
|||
if (mode == BindMode.READ_ONLY && selinuxContext == SelinuxContext.NONE) { | |||
if (mode == BindMode.READ_ONLY && selinuxContext == SelinuxContext.SHARED) { |
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.
I'm fine updating addFileSystemBind
but with withClasspathResourceMapping
, I'm still thinking about it... This will promote copying resources instead of binding filesystem and current source code with those condition will do so. The only scenario to bind filesystem would be with BindMode.READ_WRITE
. Ping to @kiview and @bsideup in case I'm missing something.
Superseded by #7187 |
On systems with SElinux enforcing trying to bind a path without a context will result in an error. Using shared context by default will make
withFileSystemBind(String hostPath, String containerPath)
method work for all systems. On Windows, Mac OS and Linux systems without SElinux it will have no effect. On systems with SElinux enforcing it will make the path accessible to the container.