-
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
Password-protected Keystore Feature Branch PR #51123
Changes from 14 commits
b0be180
fab3d56
d64ab04
35b4f52
6695e53
1284ecc
1c656f2
3d7cf1f
93ca7e6
663fc0b
91cb2c9
6238d85
75bdbdd
0b2d5d1
81458e7
3775061
bf27d31
ba7434f
bd9465d
e6156ef
f88837b
f61d756
9508733
936ba91
8ede626
8389ea0
2f82284
6757785
f93ab59
a8103a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,19 @@ if [ -z "$ES_TMPDIR" ]; then | |
ES_TMPDIR=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.TempDirectory` | ||
fi | ||
|
||
# get keystore password before setting java options to avoid | ||
# conflicting GC configurations for the keystore tools | ||
unset KEYSTORE_PASSWORD | ||
KEYSTORE_PASSWORD= | ||
if ! echo $* | grep -E -q '(^-h |-h$| -h |--help$|--help |^-V |-V$| -V |--version$|--version )' \ | ||
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. This feels a bit fragile to me. What about something like: CHECK_KEYSTORE=false
for option in "$@"; do
case "$option" in
-h|--help|-V|--version)
CHECK_KEYSTORE=true
;;
esac
done
if [[ $CHECK_KEYSTORE == true ]] \
&& "`dirname "$0"`"/elasticsearch-keystore has-passwd --silent
# etc 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. I copied a pattern checking for daemonization below. I'd like to put this off for a follow-up PR so it can be discussed with some other team members in isolation. That being said I don't have any objection to doing a loop over options and it seems to work just fine in my quick local tests. |
||
&& "`dirname "$0"`"/elasticsearch-keystore has-passwd --silent | ||
then | ||
if ! read -s -r -p "Elasticsearch keystore password: " KEYSTORE_PASSWORD ; then | ||
echo "Failed to read keystore password on console" 1>&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options | ||
ES_JAVA_OPTS=`export ES_TMPDIR; "$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_JVM_OPTIONS"` | ||
|
||
|
@@ -35,7 +48,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; | |
-Des.bundled_jdk="$ES_BUNDLED_JDK" \ | ||
-cp "$ES_CLASSPATH" \ | ||
org.elasticsearch.bootstrap.Elasticsearch \ | ||
"$@" | ||
"$@" <<<"$KEYSTORE_PASSWORD" | ||
else | ||
exec \ | ||
"$JAVA" \ | ||
|
@@ -48,7 +61,7 @@ else | |
-cp "$ES_CLASSPATH" \ | ||
org.elasticsearch.bootstrap.Elasticsearch \ | ||
"$@" \ | ||
<&- & | ||
<<<"$KEYSTORE_PASSWORD" & | ||
retval=$? | ||
pid=$! | ||
[ $retval -eq 0 ] || exit $retval | ||
|
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.
Tiny nit / observation - is it worth putting the command in quotes?