@@ -28,6 +28,18 @@ if [ "${REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING}" == "true" ]; then
2828 fi
2929fi
3030
31+ CURRENT_UID=" $( id -u) "
32+ CURRENT_GID=" $( id -g) "
33+
34+ # Ensure that assigned uid has entry in /etc/passwd.
35+ if [ ${CURRENT_UID} -ne 1000 ]; then
36+ echo " ${USER} :x:${CURRENT_UID} :${CURRENT_GID} :,,,:/home/seluser:/bin/bash" >> /tmp/passwd
37+ # cat /etc/passwd | sed -e "s/^${USER}:/builder:/" > /tmp/passwd
38+ cat /etc/passwd | sed -e " s/^${USER} :/seluser:/" > /tmp/passwd
39+ cat /tmp/passwd > /etc/passwd
40+ rm /tmp/passwd
41+ fi
42+
3143# Flag to know if we have sudo acess
3244if sudo pwd > /dev/null 2>&1 ; then
3345 export WE_HAVE_SUDO_ACCESS=" true"
3648 warn " We don't have sudo"
3749fi
3850
51+ # if [ ${CURRENT_UID} -ne 1000 ]; then
52+ # if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
53+ # warn 1
54+ # sudo groupadd --gid ${CURRENT_GID} selgroup
55+ # warn 2
56+ # sudo gpasswd -a ${USER} seluser
57+ # warn 3
58+ # sudo gpasswd -a ${USER} selgroup
59+ # fi
60+ # fi
61+
3962# ==============================================
4063# Java blocks until kernel have enough entropy
4164# to generate the /dev/random seed
4265# ==============================================
4366# See: SeleniumHQ/docker-selenium/issues/14
4467# Added a non-sudo conditional so this works on non-sudo environments like K8s
4568if [ " ${WE_HAVE_SUDO_ACCESS} " == " true" ]; then
69+ # We found that, for better entropy, running haveged
70+ # with --privileged and sudo here works more reliable
4671 sudo -E haveged
4772else
4873 haveged || true
5479# - still unclear if this helps: `-v /var/run/dbus:/var/run/dbus`
5580# - this works generates errors: DBUS_SESSION_BUS_ADDRESS="/dev/null"
5681# - this gives less erros: DBUS_SESSION_BUS_ADDRESS="unix:abstract=/dev/null"
57- # Added a non-sudo conditional so this works on non-sudo environments like K8s
58- if [ " ${WE_HAVE_SUDO_ACCESS} " == " true" ]; then
59- sudo rm -f /var/lib/dbus/machine-id
60- sudo mkdir -p /var/run/dbus
61- sudo service dbus restart > dbus_service.log
62-
63- # Test dbus works
64- service dbus status > dbus_service_status.log
65- export $( dbus-launch)
66- export NSS_USE_SHARED_DB=ENABLED
67- # echo "-- INFO: DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
68- # => e.g. DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-APZO4BE4TJ,guid=6e9c098d053d3038cb0756ae57ecc885
69- # echo "-- INFO: DBUS_SESSION_BUS_PID=${DBUS_SESSION_BUS_PID}"
70- # => e.g. DBUS_SESSION_BUS_PID=44
71- fi
82+ rm -f /var/lib/dbus/machine-id
83+ mkdir -p /var/run/dbus
84+ service dbus restart > dbus_service.log
85+
86+ # Test dbus works
87+ service dbus status > dbus_service_status.log
88+ export $( dbus-launch)
89+ export NSS_USE_SHARED_DB=ENABLED
90+ # echo "-- INFO: DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
91+ # => e.g. DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-APZO4BE4TJ,guid=6e9c098d053d3038cb0756ae57ecc885
92+ # echo "-- INFO: DBUS_SESSION_BUS_PID=${DBUS_SESSION_BUS_PID}"
93+ # => e.g. DBUS_SESSION_BUS_PID=44
7294
7395# -----------------------------------------------
7496# Perform cleanup to support `docker restart`
0 commit comments