-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Pass user ID and group ID to docker native image build in Linux #1810
Conversation
it works locally, but I'm not sure about us using @dmlloyd ? |
@Sanne It doesn't work well with JDK11 (well anything after JDK9) due to modules, am looking for a different solution. I need to determine the numerical user ID, passing in the current user name does not work, due to this docker issue: https://success.docker.com/article/KB000447 |
And I don't think command substitution works in process builder either e.g.
will not work |
How about |
The only other way I have thought about so far is to have a |
Alternatively we could develop a "stubs" module for the JDK security things. This would allow the |
You could try using JAAS to create a login context that authenticates using the UNIX login module. That would yield a principal with the real UID/GID. I'm not 100% sure it's possible to do that without actually referencing a |
@dmlloyd when I tried passing those command into ProcessBuilder, they were not resolved, and docker tried to execute with the literals "$(id -ur):$(id -gr)" |
No I meant create new ProcessBuilders to get each value. At any rate - you could simply call |
@dmlloyd ah, that would work
ok, I'll take a look at those suggestions |
e078cef
to
fd84b2f
Compare
@dmlloyd please could you review? thanks |
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 didn't notice this at first but @gsmet pointed out that the process streams are never closed. These should use try-with-resources.
core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
Outdated
Show resolved
Hide resolved
core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
Outdated
Show resolved
Hide resolved
core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
Outdated
Show resolved
Hide resolved
core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
Outdated
Show resolved
Hide resolved
core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
Outdated
Show resolved
Hide resolved
@dmlloyd rather than tying th CI up again. I have read through your comments, I think this addresses all the issues you raised
|
Yeah I think that should do the job, except it's missing a try {
StringBuilder responseBuilder = new StringBuilder();
String line;
ProcessBuilder idPB = new ProcessBuilder().command("id", option);
idPB.redirectError(new File("/dev/null"));
idPB.redirectOutput(new File("/dev/null"));
process = idPB.start();
try(InputStream inputStream = process.getInputStream()) {
try( BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))){
while ((line = reader.readLine()) != null) {
responseBuilder.append(line);
}
return responseBuilder.toString();
}
} catch (Throwable t) {
safeWaitFor(process);
throw t;
}
safeWaitFor(process);
} catch (IOException e) { //from process.start()
//swallow and return null id
return null;
} where static void safeWaitFor(Process process) {
boolean intr = false;
try {
for (;;) try {
process.waitFor();
return;
} catch (InterruptedException ex) {
intr = true;
}
} finally {
if (intr) Thread.currentThread.interrupt();
}
} |
…efault docker container will run as root
…efault docker container will run as root