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

[enhancement] Update Java driver fingerprinting for macOS #7865

Closed
angrycub opened this issue May 4, 2020 · 3 comments · Fixed by #9225
Closed

[enhancement] Update Java driver fingerprinting for macOS #7865

angrycub opened this issue May 4, 2020 · 3 comments · Fixed by #9225

Comments

@angrycub
Copy link
Contributor

angrycub commented May 4, 2020

On versions of macOS without Java installed, there is a stub executable that presents a warning to users that there is no longer a default JDK installed on macOS.
Screen Shot 2020-05-04 at 5 09 14 PM

The fingerprinter runs this stub command every 30 seconds while Nomad is running because of

// fingerprintPeriod is the interval at which the driver will send fingerprint responses
fingerprintPeriod = 30 * time.Second

var javaVersionCommand = []string{"java", "-version"}
func javaVersionInfo() (version, runtime, vm string, err error) {
var out bytes.Buffer
cmd := exec.Command(javaVersionCommand[0], javaVersionCommand[1:]...)
cmd.Stdout = &out
cmd.Stderr = &out
err = cmd.Run()
if err != nil {
err = fmt.Errorf("failed to check java version: %v", err)
return
}
version, runtime, vm = parseJavaVersionOutput(out.String())
return
}

It appears that we could fingerprint for an installed JDK (that would be seen by this stub) by looking for one or more symlinks in /Library/Java/JavaVirtualMachines. This would definitely improve the getting started experience on macOS.

@angrycub angrycub changed the title [enhancement] Provide a non-config way to disable Java driver in a -dev agent. [enhancement] Update Java driver fingerprinting for macOS May 4, 2020
@vancluever
Copy link

vancluever commented May 20, 2020

@angrycub and I were discussing workarounds here, so I thought I'd post one here that I just applied: you can remove the /usr/bin/java symlink to make this go away. Not too sure if it comes back eventually though (ie: through patches or with the next version of MacOS).

On modern MacOS you need to disable SIP from recovery mode and remount / read-write (mount -u -w /) before you can operate on the symlink. Of course, you can just delete it from recovery mode too.

@angrycub
Copy link
Contributor Author

I was able to collect enough of the necessary bits to make a null.jdk that can be put in /Library/Java/JavaVirtualMachines that uses symlinks to /usr/bin/false as the target command.
Tested on macOS Catalina 10.15.4.

Unzip and then sudo cp -R null.jdk /Library/Java/JavaVirtualMachines

null.jdk.zip

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants