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

Packaging: Set elasticsearch user to have non-existent homedir #29007

Merged
merged 10 commits into from
May 2, 2018
6 changes: 4 additions & 2 deletions distribution/packages/src/common/scripts/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ case "$1" in
adduser --quiet \
--system \
--no-create-home \
--home /usr/share/elasticsearch \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why /usr/share/elasticsearch? Is /var/lib/elasticsearch more appropriate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose /usr/share/elasticsearch because it is ES_HOME, and it is not expected to be written to. I'm open to being persuaded either way.

--ingroup elasticsearch \
--disabled-password \
--shell /bin/false \
Expand All @@ -50,8 +51,9 @@ case "$1" in
# Create elasticsearch user if not existing
if ! id elasticsearch > /dev/null 2>&1 ; then
echo -n "Creating elasticsearch user..."
useradd -r \
-M \
useradd --system \
--no-create-home \
--home-dir /usr/share/elasticsearch \
--gid elasticsearch \
--shell /sbin/nologin \
--comment "elasticsearch user" \
Expand Down
2 changes: 2 additions & 0 deletions qa/vagrant/src/test/resources/packaging/utils/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ verify_package_installation() {
id elasticsearch

getent group elasticsearch
# homedir is set in /etc/passwd
assert_file $(getent passwd elasticsearch | cut -d: -f6) d root root 755

assert_file "$ESHOME" d root root 755
assert_file "$ESHOME/bin" d root root 755
Expand Down