Skip to content

Commit dc4ebfc

Browse files
Merge pull request #629 from splunk/bugfix/provide-user-info-via-params
introduced secure-start shell to disable shell access for container p…
2 parents 9665366 + d229186 commit dc4ebfc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

splunk/common-files/entrypoint.sh

+23
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ watch_for_failure(){
6767
echo Ansible playbook complete, will begin streaming ${SPLUNK_TAIL_FILE}
6868
${RUN_AS_SPLUNK} tail -n 0 -f ${SPLUNK_TAIL_FILE} &
6969
fi
70+
if [[ "$DISABLE_ENTIRE_SHELL_ACCESS" == "true" ]]; then
71+
disable_entire_shell_access_for_container
72+
fi
7073
wait
7174
}
7275

@@ -90,6 +93,12 @@ start() {
9093
watch_for_failure
9194
}
9295

96+
secure_start() {
97+
start_and_exit
98+
export DISABLE_ENTIRE_SHELL_ACCESS="true"
99+
watch_for_failure
100+
}
101+
93102
configure_multisite() {
94103
prep_ansible
95104
ansible-playbook $ANSIBLE_EXTRA_FLAGS -i inventory/environ.py -l localhost multisite.yml
@@ -103,6 +112,16 @@ restart(){
103112
watch_for_failure
104113
}
105114

115+
disable_entire_shell_access_for_container() {
116+
if [[ "$DISABLE_ENTIRE_SHELL_ACCESS" == "true" ]]; then
117+
bash -c "sudo usermod -s /sbin/nologin splunk"
118+
bash -c "sudo usermod -s /sbin/nologin ansible"
119+
sudo rm /bin/sh
120+
sudo rm /bin/bash
121+
sudo ln -s /bin/busybox /bin/sh
122+
fi
123+
}
124+
106125
user_permission_change(){
107126
if [[ "$STEPDOWN_ANSIBLE_USER" == "true" ]]; then
108127
bash -c "sudo deluser -q ansible sudo"
@@ -175,6 +194,10 @@ case "$1" in
175194
tail -n 0 -f /etc/hosts &
176195
wait
177196
;;
197+
secure-start|secure-start-service)
198+
shift
199+
secure_start $@
200+
;;
178201
bash|splunk-bash)
179202
/bin/bash --init-file ${SPLUNK_HOME}/bin/setSplunkEnv
180203
;;

0 commit comments

Comments
 (0)