Skip to content

Commit

Permalink
Packaging: Set elasticsearch homedir
Browse files Browse the repository at this point in the history
This commit adds setting the homedir for the elasticsearch user to the
adduser command in the packaging preinstall script. While the
elasticsearch user is a system user, it is sometimes conventient to have
an existing homedir (even if it is not writeable). For example, running
cron as the elasticsearch user will try to change dir to the homedir.

closes elastic#14453
  • Loading branch information
rjernst committed Mar 13, 2018
1 parent 8b6fbe2 commit 0964a52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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-dir /usr/share/elasticsearch \
--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

0 comments on commit 0964a52

Please sign in to comment.