-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Elasticsearch keystore passphrase for startup scripts #44775
Merged
williamrandolph
merged 122 commits into
elastic:feature-pwd-protected-keystore
from
williamrandolph:elasticsearch-keystore-init-passphrase
Nov 11, 2019
Merged
Changes from 119 commits
Commits
Show all changes
122 commits
Select commit
Hold shift + click to select a range
c58f3aa
Add passphrase support to elasticsearch-keystore
jkakavas c74685f
Address feedback
jkakavas af3d5e9
Allow creating obfuscated keystores without prompting for a passphrase
jkakavas d118da4
Create obfuscated keystores for integTestCluster tasks. This can be p…
jkakavas 041143e
Merge remote-tracking branch 'origin/master' into elasticsearch-keyst…
jkakavas 852533a
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
jkakavas 668c438
address feedback
jkakavas 95e1a78
Handle tests by creating obfuscated keystores by default - At least u…
jkakavas bc5b99d
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
jkakavas f095d90
Merge remote-tracking branch 'origin/feature-pwd-protected-keystore' …
jkakavas 76ea066
fix checkstyl
jkakavas 3bf1830
Address feedback
jkakavas 500c79a
Merge remote-tracking branch 'origin/feature-pwd-protected-keystore' …
jkakavas ba4a9ba
revert unnecessary formatting changes
jkakavas 2b74f64
remove nopass again
jkakavas ecc0ed6
Addresses feedback
jkakavas ac5cf83
Merge remote-tracking branch 'origin/feature-pwd-protected-keystore' …
jkakavas ca55074
address feedback
jkakavas 690df96
Merge remote-tracking branch 'origin/feature-pwd-protected-keystore' …
jkakavas 250c9f2
Read keystore password from stdin on startup
williamrandolph a167d5c
Add thread safety and fix typos
williamrandolph e390afe
Remove command line flag for standard input
williamrandolph 8c99702
Let bin/elasticsearch read passwd from FIFO/file
williamrandolph ef66eaf
Improve bin/elasticsearch portability
williamrandolph 6a2ecc5
Avoid multiple buffered readers of standard input
williamrandolph 85c9160
Avoid forbidden and restricted APIs
williamrandolph 3d11327
Add keystore passphrase support to docker images
williamrandolph 9ab6cdf
Merge branch 'elasticsearch-keystore-cli-passphrase' into elasticsear…
williamrandolph c9c0b42
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph 193ff6e
Send all input via the terminal in tests
williamrandolph 54de1eb
Remove some unused imports
williamrandolph 636ac69
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph e581b55
Back out OSX delay workaround
williamrandolph c0b1fc2
Address PR feedback
williamrandolph e1f50b6
Discard standard input in cluster integration tests
williamrandolph 30ce2a2
Close stdin to elasticsearch process
williamrandolph ef8a6c4
Add a write to stdin for restclusters
williamrandolph eb32c60
Check that keystore command can be executed
williamrandolph 9fb0a52
Remove unused imports
williamrandolph 52305c0
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph a66994a
Adjust bin/elasticsearch for running in docker
williamrandolph a44fc58
RPM Packaging Tests for Keystore
williamrandolph 97ddb4e
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph 1d22a27
Remove extra keystore test
williamrandolph 17aa6d5
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph 94b98e7
Add integration tests for archives
williamrandolph e227ce2
Update new vagrant tests to run on Windows
williamrandolph c1e4008
Simplify code to set keystore password in test
williamrandolph 3bd969a
Merging feature branch into PR branch
williamrandolph 7a7739a
Remove FIFO checks from bin/elasticsearch
williamrandolph 8e5d02e
Assume password on stdin when bootstrapping
williamrandolph 775c35c
Clean up terminal interfaces and tests
williamrandolph 3b0fd80
Checkstyle - remove unused imports
williamrandolph d693a44
Create new has-passwd keystore CLI subcommand
williamrandolph 7d98e3d
Revert unused addition to CommandTestCase
williamrandolph 425c6c5
Add license headers to new files
williamrandolph bef250b
Reorder clauses for clarity
williamrandolph 5896f31
merge feature branch into PR branch
williamrandolph 7de60e9
Restore import dropped during merge
williamrandolph 155464a
Move keystore tests into a single test class
williamrandolph 60a9f0b
Adapt keystore management tests for RPMs
williamrandolph 1e26b2f
Refactor keystore os tests for clarity
williamrandolph dc1f312
Checkstyle: remove unused import
williamrandolph d7ce46e
Add license header to keystore test
williamrandolph c3e6795
Improvements to vagrant tests
williamrandolph f108fa3
Get Windows tests to pass
williamrandolph 0cfa719
Undo changes having to do with string encoding
williamrandolph a613b45
Add TTY-based tests for non-Windows archives
williamrandolph 6b090a6
Rename test for accuracy
williamrandolph 3f79421
Remove unneeded changes to clean up diff
williamrandolph c4868ff
Revert unneeded changes to windows batch scripts
williamrandolph 1e1e459
Remove unneeded whitespace change
williamrandolph 9e6f767
One more whitespace tweak
williamrandolph 5585c61
Use delayed expansion variable for Windows pwd
williamrandolph 2c69dba
Respond to PR feedback
williamrandolph c97749a
Fix BufferedReader usage
williamrandolph e06da98
Improve os tests
williamrandolph 1436534
Escape special characters in password for windows
williamrandolph a1a125b
Remove obsolete comment
williamrandolph d5a04a7
Handle backslashes in bash keystore passwords
williamrandolph cb61eb7
Give elasticsearch-keystore a true silent mode
williamrandolph 4611d54
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph 19442c8
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph c9a6e63
Use shell env vars rather than writing to env file
williamrandolph 6b760b2
Remove redundant non-special-char tests
williamrandolph d47e1fe
Test for specific password failure message
williamrandolph 87ecea4
Avoid intermediate Strings when reading secrets
williamrandolph 34e431f
Merging upstream changes from feature branch
williamrandolph 13c27f3
Specify InputStream encoding in tests
williamrandolph 1501bf3
Remove exit message override
williamrandolph 2273b11
Use Conditional pattern for packages and archives
williamrandolph 0982d04
Use keystore passphrase file only with systemd
williamrandolph 7146b36
Add a information to assertion failure message
williamrandolph 7a65f22
Clear out stray keystore files between tests groups
williamrandolph 67fa0f8
Unset systemd environment variables after use
williamrandolph b0e3a4b
Move entrypoint to an ok location for dpkg
williamrandolph 3883d59
Rename systemd entrypoint script
williamrandolph 0c0a56a
Use null message to suppress error output for CLI
williamrandolph 945aead
Cleanup static import references
williamrandolph 026ee0d
Improve error message
williamrandolph f271e59
Re-work methods for reading from standard input
williamrandolph 43ce860
Remove custom buffer limit for BufferedReader
williamrandolph 16bc6be
Update comment to match code
williamrandolph 1855bce
Use static import for static methods
williamrandolph 43ed544
Rename log files between tests
williamrandolph b7c2d66
Merge changes from master
williamrandolph 2725769
Add some docker support after merge
williamrandolph 44bfb95
Add sleep time to daemonized ES startup in qa test
williamrandolph 457fc59
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph ef850d2
Set file permissions for Windows keystore tests
williamrandolph e548d55
Run chown on autocreated keystore on Windows tests
williamrandolph 7eb26c2
Simplify tests with StringReader
williamrandolph 36d61ae
Clarify purpose of unit test
williamrandolph 6fc4994
Sundry trivial cleanup
williamrandolph 94e6a3f
Refactor big Powershell script string
williamrandolph 1ef3dfb
Get powershell output path via static method
williamrandolph c31c88e
Checkstyle - remove unused import
williamrandolph 6eb3e35
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph b85eed9
Merge branch 'feature-pwd-protected-keystore' into elasticsearch-keys…
williamrandolph 56b83f1
Use expectThrows instead of JUnit rule
williamrandolph f982f91
Bootstrap's readPassphrase delegates to Terminal
williamrandolph 73e35e7
Remove unused imports
williamrandolph 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 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 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 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 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 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
10 changes: 10 additions & 0 deletions
10
distribution/packages/src/common/systemd/systemd-entrypoint
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
# This wrapper script allows SystemD to feed a file containing a passphrase into | ||
# the main Elasticsearch startup script | ||
|
||
if [ -n "$ES_KEYSTORE_PASSPHRASE_FILE" ] ; then | ||
exec /usr/share/elasticsearch/bin/elasticsearch "$@" < "$ES_KEYSTORE_PASSPHRASE_FILE" | ||
else | ||
exec /usr/share/elasticsearch/bin/elasticsearch "$@" | ||
fi |
This file contains 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 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 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
57 changes: 57 additions & 0 deletions
57
...store-cli/src/main/java/org/elasticsearch/common/settings/HasPasswordKeyStoreCommand.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.common.settings; | ||
|
||
import joptsimple.OptionSet; | ||
import org.elasticsearch.cli.KeyStoreAwareCommand; | ||
import org.elasticsearch.cli.Terminal; | ||
import org.elasticsearch.cli.UserException; | ||
import org.elasticsearch.env.Environment; | ||
|
||
import java.nio.file.Path; | ||
|
||
public class HasPasswordKeyStoreCommand extends KeyStoreAwareCommand { | ||
|
||
static final int NO_PASSWORD_EXIT_CODE = 1; | ||
|
||
HasPasswordKeyStoreCommand() { | ||
super("Succeeds if the keystore exists and is password-protected, " + | ||
"fails with exit code " + NO_PASSWORD_EXIT_CODE + " otherwise."); | ||
} | ||
|
||
@Override | ||
protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { | ||
final Path configFile = env.configFile(); | ||
final KeyStoreWrapper keyStore = KeyStoreWrapper.load(configFile); | ||
|
||
// We handle error printing here so we can respect the "--silent" flag | ||
// We have to throw an exception to get a nonzero exit code | ||
if (keyStore == null) { | ||
terminal.errorPrintln(Terminal.Verbosity.NORMAL, "ERROR: Elasticsearch keystore not found"); | ||
throw new UserException(NO_PASSWORD_EXIT_CODE, null); | ||
} | ||
if (keyStore.hasPassword() == false) { | ||
terminal.errorPrintln(Terminal.Verbosity.NORMAL, "ERROR: Keystore is not password-protected"); | ||
throw new UserException(NO_PASSWORD_EXIT_CODE, null); | ||
} | ||
|
||
terminal.println(Terminal.Verbosity.NORMAL, "Keystore is password-protected"); | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.
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.
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.
There is so much hacky overhead to retrieving and piping a password with windows batch commands. Switching to Powershell would make the situation better. But I'm wondering if we'll hit a point where it makes sense to move this processing into Java even for the first effort.