mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Don't use Files.copy() when decrypting to stdout
Files.copy() attempts to delete the file if it already exists, which obviously won't work very well for /dev/stdout. Instead copy directly from the decoder to standard output. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=228384575
This commit is contained in:
parent
04a495bc99
commit
9e0b675275
5 changed files with 47 additions and 3 deletions
|
@ -106,6 +106,7 @@ def domain_registry_repositories(
|
|||
omit_com_sun_xml_bind_jaxb_xjc = False,
|
||||
omit_com_thoughtworks_paranamer = False,
|
||||
omit_commons_codec = False,
|
||||
omit_commons_io = False,
|
||||
omit_commons_logging = False,
|
||||
omit_dnsjava = False,
|
||||
omit_io_netty_buffer = False,
|
||||
|
@ -337,6 +338,8 @@ def domain_registry_repositories(
|
|||
com_thoughtworks_paranamer()
|
||||
if not omit_commons_codec:
|
||||
commons_codec()
|
||||
if not omit_commons_io:
|
||||
commons_io()
|
||||
if not omit_commons_logging:
|
||||
commons_logging()
|
||||
if not omit_dnsjava:
|
||||
|
@ -1799,6 +1802,17 @@ def commons_codec():
|
|||
],
|
||||
)
|
||||
|
||||
def commons_io():
|
||||
java_import_external(
|
||||
name = "commons_io",
|
||||
licenses = ["notice"], # Apache License, Version 2.0
|
||||
jar_sha256 = "a10418348d234968600ccb1d988efcbbd08716e1d96936ccc1880e7d22513474",
|
||||
jar_urls = [
|
||||
"http://maven.ibiblio.org/maven2/commons-io/commons-io/2.5/commons-io-2.5.jar",
|
||||
"http://repo1.maven.org/maven2/commons-io/commons-io/2.5/commons-io-2.5.jar",
|
||||
],
|
||||
)
|
||||
|
||||
def commons_logging():
|
||||
java_import_external(
|
||||
name = "commons_logging",
|
||||
|
|
|
@ -65,6 +65,7 @@ java_library(
|
|||
"//java/google/registry/whois",
|
||||
"//java/google/registry/xjc",
|
||||
"//java/google/registry/xml",
|
||||
"//third_party/java/jakarta_commons_io",
|
||||
"//third_party/jaxb",
|
||||
"//third_party/objectify:objectify-v4_1",
|
||||
"@com_beust_jcommander",
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPrivateKey;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
|
@ -101,9 +102,15 @@ final class GhostrydeCommand implements CommandWithRemoteApi {
|
|||
private void runDecrypt() throws IOException, PGPException {
|
||||
try (InputStream in = Files.newInputStream(input);
|
||||
InputStream ghostDecoder = Ghostryde.decoder(in, rdeStagingDecryptionKey.get())) {
|
||||
Path outFile =
|
||||
Files.isDirectory(output) ? output.resolve(input.getFileName() + ".decrypt") : output;
|
||||
Files.copy(ghostDecoder, outFile, REPLACE_EXISTING);
|
||||
System.err.println("output = " + output);
|
||||
if (output.toString().equals("/dev/stdout")) {
|
||||
System.err.println("doing copy");
|
||||
IOUtils.copy(ghostDecoder, System.out);
|
||||
} else {
|
||||
Path outFile =
|
||||
Files.isDirectory(output) ? output.resolve(input.getFileName() + ".decrypt") : output;
|
||||
Files.copy(ghostDecoder, outFile, REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue