-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Evergreen #2012
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
Open
rozza
wants to merge
6
commits into
mongodb:main
Choose a base branch
from
rozza:evergreen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+84
−57
Open
Evergreen #2012
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f42b1ae
JAVA-6057: fix verifyCryptLibs gpg path handling on Windows
rozza fab0222
Fix server version checking for nested MQL asString.
rozza a5b7569
Set a default OS in setup-env.bash
rozza 199c6a9
Ignore drop errors in the shutdown hook.
rozza b6407b9
Potential fix for pull request finding
rozza 2145a4d
Merge branch 'main' into evergreen
rozza 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -168,10 +168,45 @@ abstract class VerifyLibmongocryptTask : DefaultTask() { | |
| return | ||
| } | ||
|
|
||
| // The gpg shipped on the Evergreen Windows hosts is a Cygwin build that only understands POSIX paths. | ||
| // Handed a native Windows path ("C:\dir") it treats the backslash path as relative, prepends its working | ||
| // directory, and fails with "no writable keyring found". Translate drive-letter paths to the Cygwin form | ||
| // ("C:\dir" -> "/cygdrive/c/dir") on Windows so every path argument (homedir, key, signatures, tarballs) | ||
| // is parsed correctly; other platforms pass paths through unchanged. | ||
| val isWindows = System.getProperty("os.name").startsWith("Windows", ignoreCase = true) | ||
| fun toGpgPath(path: String): String { | ||
| if (!isWindows) { | ||
| return path | ||
| } | ||
| val driveLetter = Regex("^([A-Za-z]):[\\\\/](.*)$").matchEntire(path) ?: return path.replace('\\', '/') | ||
| val (drive, rest) = driveLetter.destructured | ||
| return "/cygdrive/${drive.lowercase(java.util.Locale.ROOT)}/${rest.replace('\\', '/')}" | ||
| } | ||
|
|
||
| // Run gpg capturing both streams; on non-zero exit throw with the captured output appended so the | ||
| // underlying gpg diagnostic is visible instead of Gradle's opaque "finished with non-zero exit value N". | ||
| fun runGpg(vararg args: String, onFailure: (String) -> String) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 👍 |
||
| val out = ByteArrayOutputStream() | ||
| val err = ByteArrayOutputStream() | ||
| val result = | ||
| execOps.exec { | ||
| commandLine(listOf("gpg") + args) | ||
| standardOutput = out | ||
| errorOutput = err | ||
| isIgnoreExitValue = true | ||
| } | ||
| val combined = (out.toString().trim() + "\n" + err.toString().trim()).trim() | ||
| logger.info("gpg ${args.joinToString(" ")} -> exit ${result.exitValue}\n$combined") | ||
| if (result.exitValue != 0) { | ||
| throw GradleException("${onFailure(combined)}\ngpg command: gpg ${args.joinToString(" ")}") | ||
| } | ||
| } | ||
|
|
||
| val versionOut = ByteArrayOutputStream() | ||
| try { | ||
| execOps.exec { | ||
| commandLine("gpg", "--version") | ||
| standardOutput = ByteArrayOutputStream() | ||
| standardOutput = versionOut | ||
| } | ||
| } catch (e: Exception) { | ||
| throw GradleException( | ||
|
|
@@ -180,6 +215,7 @@ abstract class VerifyLibmongocryptTask : DefaultTask() { | |
| "or pass -PskipCryptVerify=true for offline development builds.", | ||
| e) | ||
| } | ||
| logger.lifecycle("Using gpg:\n${versionOut.toString().trim().lineSequence().firstOrNull() ?: ""}") | ||
|
|
||
| val home = | ||
| gnupgHome.get().asFile.apply { | ||
|
|
@@ -193,41 +229,28 @@ abstract class VerifyLibmongocryptTask : DefaultTask() { | |
| setExecutable(false, false) | ||
| setExecutable(true, true) | ||
| } | ||
| val homedir = toGpgPath(home.path) | ||
| logger.lifecycle( | ||
| "libmongocrypt verify: gnupgHome=${home.path} -> $homedir (exists=${home.exists()}, " + | ||
| "writable=${home.canWrite()}), publicKey=${publicKey.get().asFile.path} " + | ||
| "(exists=${publicKey.get().asFile.exists()})") | ||
|
|
||
| execOps.exec { | ||
| commandLine( | ||
| "gpg", | ||
| "--homedir", | ||
| home.path, | ||
| "--batch", | ||
| "--quiet", | ||
| "--no-autostart", | ||
| "--import", | ||
| publicKey.get().asFile.path) | ||
| standardOutput = ByteArrayOutputStream() | ||
| errorOutput = ByteArrayOutputStream() | ||
| runGpg("--homedir", homedir, "--batch", "--no-autostart", "--import", toGpgPath(publicKey.get().asFile.path)) { | ||
| output -> | ||
| "Failed to import libmongocrypt signing key into scratch keyring at ${home.path}.\n$output" | ||
| } | ||
|
|
||
| try { | ||
| execOps.exec { | ||
| commandLine( | ||
| "gpg", | ||
| "--homedir", | ||
| home.path, | ||
| "--batch", | ||
| "--no-autostart", | ||
| "--with-colons", | ||
| "--fingerprint", | ||
| expectedFingerprint.get()) | ||
| standardOutput = ByteArrayOutputStream() | ||
| errorOutput = ByteArrayOutputStream() | ||
| } | ||
| } catch (e: Exception) { | ||
| throw GradleException( | ||
| runGpg( | ||
| "--homedir", | ||
| homedir, | ||
| "--batch", | ||
| "--no-autostart", | ||
| "--with-colons", | ||
| "--fingerprint", | ||
| expectedFingerprint.get()) { output -> | ||
| "Imported libmongocrypt signing key fingerprint does not match expected value " + | ||
| "${expectedFingerprint.get()}. The downloaded public key may have been rotated.", | ||
| e) | ||
| } | ||
| "${expectedFingerprint.get()}. The downloaded public key may have been rotated.\n$output" | ||
| } | ||
|
|
||
| // Pair tarballs with signatures by basename; ConfigurableFileCollection.files is an | ||
| // unordered Set, so zipping the two collections could mismatch pairs. | ||
|
|
@@ -238,28 +261,18 @@ abstract class VerifyLibmongocryptTask : DefaultTask() { | |
| signaturesByName[signatureName] | ||
| ?: throw GradleException( | ||
| "Missing signature $signatureName for ${tarball.name}; expected it next to the tarball.") | ||
| val verifyErr = ByteArrayOutputStream() | ||
| try { | ||
| execOps.exec { | ||
| commandLine( | ||
| "gpg", | ||
| "--homedir", | ||
| home.path, | ||
| "--batch", | ||
| "--quiet", | ||
| "--no-autostart", | ||
| "--trust-model", | ||
| "always", | ||
| "--verify", | ||
| signature.path, | ||
| tarball.path) | ||
| standardOutput = ByteArrayOutputStream() | ||
| errorOutput = verifyErr | ||
| runGpg( | ||
| "--homedir", | ||
| homedir, | ||
| "--batch", | ||
| "--no-autostart", | ||
| "--trust-model", | ||
| "always", | ||
| "--verify", | ||
| toGpgPath(signature.path), | ||
| toGpgPath(tarball.path)) { output -> | ||
| "GPG signature verification failed for ${tarball.name}:\n$output" | ||
| } | ||
| } catch (e: Exception) { | ||
| throw GradleException( | ||
| "GPG signature verification failed for ${tarball.name}:\n${verifyErr.toString().trim()}", e) | ||
| } | ||
| } | ||
|
|
||
| verificationStamp | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.