Packaging: Set elasticsearch user to have non-existent homedir (#29007)
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 #14453
This commit is contained in:
parent
e697299103
commit
3aec8c7725
|
@ -27,6 +27,7 @@ case "$1" in
|
||||||
adduser --quiet \
|
adduser --quiet \
|
||||||
--system \
|
--system \
|
||||||
--no-create-home \
|
--no-create-home \
|
||||||
|
--home /nonexistent \
|
||||||
--ingroup elasticsearch \
|
--ingroup elasticsearch \
|
||||||
--disabled-password \
|
--disabled-password \
|
||||||
--shell /bin/false \
|
--shell /bin/false \
|
||||||
|
@ -50,8 +51,9 @@ case "$1" in
|
||||||
# Create elasticsearch user if not existing
|
# Create elasticsearch user if not existing
|
||||||
if ! id elasticsearch > /dev/null 2>&1 ; then
|
if ! id elasticsearch > /dev/null 2>&1 ; then
|
||||||
echo -n "Creating elasticsearch user..."
|
echo -n "Creating elasticsearch user..."
|
||||||
useradd -r \
|
useradd --system \
|
||||||
-M \
|
--no-create-home \
|
||||||
|
--home-dir /nonexistent \
|
||||||
--gid elasticsearch \
|
--gid elasticsearch \
|
||||||
--shell /sbin/nologin \
|
--shell /sbin/nologin \
|
||||||
--comment "elasticsearch user" \
|
--comment "elasticsearch user" \
|
||||||
|
|
|
@ -88,6 +88,8 @@ verify_package_installation() {
|
||||||
id elasticsearch
|
id elasticsearch
|
||||||
|
|
||||||
getent group elasticsearch
|
getent group elasticsearch
|
||||||
|
# homedir is set in /etc/passwd but to a non existent directory
|
||||||
|
assert_file_not_exist $(getent passwd elasticsearch | cut -d: -f6)
|
||||||
|
|
||||||
assert_file "$ESHOME" d root root 755
|
assert_file "$ESHOME" d root root 755
|
||||||
assert_file "$ESHOME/bin" d root root 755
|
assert_file "$ESHOME/bin" d root root 755
|
||||||
|
|
Loading…
Reference in New Issue