Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit 7fd428b

Browse files
committed
Add REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING for #175
1 parent 8520130 commit 7fd428b

File tree

6 files changed

+82
-25
lines changed

6 files changed

+82
-25
lines changed

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,33 @@ Note image ids also change after scm-source.json has being updated which trigger
77
###### To get container versions
88
docker exec grid versions
99

10+
## TBD_DOCKER_TAG
11+
+ **Changes:** https://github.com/elgalu/docker-selenium/compare/3.5.3-p3...3.5.3-p4 (TBD_DATE)
12+
+ Add REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING for #175
13+
+ **Image tag details:**
14+
+ Selenium version: TBD_SELENIUM_3_VERSION (TBD_SELENIUM_3_REVISION)
15+
+ Chrome stable: TBD_CHROME_STABLE
16+
+ Firefox stable: TBD_FIREFOX_FOR_SEL3
17+
+ Geckodriver: TBD_GECKO_DRIVER
18+
+ Chromedriver: TBD_CHROME_DRIVER (TBD_CHROMEDRIVER_COMMIT)
19+
+ Java: TBD_JAVA_VENDOR Java TBD_JAVA_BUILD
20+
+ Timezone: TBD_TIME_ZONE
21+
+ FROM ubuntu:UBUNTU_FLAVOR-UBUNTU_DATE
22+
+ Python: TBD_PYTHON_VERSION
23+
+ Tested on kernel dev host: 4.4.0-93-generic x86_64
24+
+ Tested on kernel CI host: TBD_HOST_UNAME
25+
+ Built at dev host with: Docker version 17.05.0-ce, build 89658be
26+
+ Built at CI host with: Docker version TBD_DOCKER_VERS, build TBD_DOCKER_BUILD
27+
+ Built at dev host with: Docker Compose version 1.14.0, build c7bdf9e
28+
+ Built at CI host with: Docker Compose version TBD_DOCKER_COMPOSE_VERS, build TBD_DOCKER_COMPOSE_BUILD
29+
+ Image size: TBD_IMAGE_SIZE
30+
+ Digest: TBD_DIGEST
31+
+ Image ID: TBD_IMAGE_ID
32+
1033
## 3.5.3-p3
1134
+ **Changes:** https://github.com/elgalu/docker-selenium/compare/3.5.3-p2...3.5.3-p3 (2017-09-22)
1235
+ Upgrade Chrome patch to 61.0.3163.100
13-
+ Fix cannot touch /var/log/cont/docker-selenium-status.log Permission denied
36+
+ Fix cannot touch /var/log/cont/docker-selenium-status.log Permission denied for #175
1437
+ **Image tag details:**
1538
+ Selenium version: 3.5.3 (a88d25fe6b)
1639
+ Chrome stable: 61.0.3163.100

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ ENV FIREFOX_VERSION="${FF_VER}" \
929929
GA_API_VERSION="1" \
930930
DEBIAN_FRONTEND="" \
931931
USE_KUBERNETES="false" \
932+
REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING="false" \
932933
DEBCONF_NONINTERACTIVE_SEEN=""
933934

934935
#================================

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.5.3-p3
1+
3.5.3-p4

bin/entry.sh

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# set -e: exit asap if a command exits with a non-zero status
44
set -e
55

6-
echoerr() { printf "%s\n" "$*" >&3; }
6+
echoerr() { printf "%s\n" "$*" >&2; }
77

88
# print error and exit
99
die () {
@@ -18,13 +18,34 @@ if [ -f /var/run/secrets/kubernetes.io/serviceaccount/token ]; then
1818
export USE_KUBERNETES=true
1919
fi
2020

21+
# Let's stop using sudo in K8s environments
22+
if [ "${REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING}" == "true" ]; then
23+
# This doesn't seem to work unless you logout:
24+
# sudo gpasswd -d seluser sudo
25+
sudo rm $(which sudo)
26+
if sudo pwd >/dev/null 2>&1; then
27+
die "Somehow we still have sudo access despite having removed it. Quitting. $(sudo pwd)"
28+
fi
29+
fi
30+
31+
# Flag to know if we have sudo acess
32+
if sudo pwd >/dev/null 2>&1; then
33+
export WE_HAVE_SUDO_ACCESS="true"
34+
else
35+
export WE_HAVE_SUDO_ACCESS="false"
36+
fi
37+
2138
#==============================================
2239
# Java blocks until kernel have enough entropy
2340
# to generate the /dev/random seed
2441
#==============================================
2542
# See: SeleniumHQ/docker-selenium/issues/14
2643
# Added a non-sudo conditional so this works on non-sudo environments like K8s
27-
(sudo haveged) || haveged
44+
if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
45+
sudo haveged
46+
else
47+
haveged || true
48+
fi
2849

2950
# Workaround that might help to get dbus working in docker
3051
# http://stackoverflow.com/a/38355729/511069
@@ -33,18 +54,21 @@ fi
3354
# - this works generates errors: DBUS_SESSION_BUS_ADDRESS="/dev/null"
3455
# - this gives less erros: DBUS_SESSION_BUS_ADDRESS="unix:abstract=/dev/null"
3556
# Added a non-sudo conditional so this works on non-sudo environments like K8s
36-
(sudo rm -f /var/lib/dbus/machine-id) || (rm -f /var/lib/dbus/machine-id) || true
37-
(sudo mkdir -p /var/run/dbus) || (mkdir -p /var/run/dbus) || true
38-
(sudo service dbus restart >dbus_service.log) || (service dbus restart >dbus_service.log) || true
39-
# Test dbus works
40-
(service dbus status >dbus_service_status.log) || true
41-
export $(dbus-launch) || true
42-
export NSS_USE_SHARED_DB=ENABLED
43-
# echo "-- INFO: DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
44-
#=> e.g. DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-APZO4BE4TJ,guid=6e9c098d053d3038cb0756ae57ecc885
45-
# echo "-- INFO: DBUS_SESSION_BUS_PID=${DBUS_SESSION_BUS_PID}"
46-
#=> e.g. DBUS_SESSION_BUS_PID=44
47-
#
57+
if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
58+
sudo rm -f /var/lib/dbus/machine-id
59+
sudo mkdir -p /var/run/dbus
60+
sudo service dbus restart >dbus_service.log
61+
62+
# Test dbus works
63+
service dbus status >dbus_service_status.log
64+
export $(dbus-launch)
65+
export NSS_USE_SHARED_DB=ENABLED
66+
# echo "-- INFO: DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
67+
#=> e.g. DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-APZO4BE4TJ,guid=6e9c098d053d3038cb0756ae57ecc885
68+
# echo "-- INFO: DBUS_SESSION_BUS_PID=${DBUS_SESSION_BUS_PID}"
69+
#=> e.g. DBUS_SESSION_BUS_PID=44
70+
fi
71+
4872
#-----------------------------------------------
4973
# Perform cleanup to support `docker restart`
5074
stop >/dev/null 2>&1 || true
@@ -194,6 +218,10 @@ elif [ "${PICK_ALL_RANDOM_PORTS}" = "true" ]; then
194218
fi
195219
fi
196220

221+
if [ "${SELENIUM_NODE_CH_PORT}" == "" ]; then
222+
die "SELENIUM_NODE_CH_PORT is empty"
223+
fi
224+
197225
if [ "${SELENIUM_NODE_FF_PORT}" = "0" ]; then
198226
export SELENIUM_NODE_FF_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
199227
elif [ "${PICK_ALL_RANDOM_PORTS}" = "true" ]; then
@@ -203,6 +231,10 @@ elif [ "${PICK_ALL_RANDOM_PORTS}" = "true" ]; then
203231
fi
204232
fi
205233

234+
if [ "${SELENIUM_NODE_FF_PORT}" == "" ]; then
235+
die "SELENIUM_NODE_FF_PORT is empty"
236+
fi
237+
206238
if [ "${SELENIUM_MULTINODE_PORT}" = "0" ]; then
207239
export SELENIUM_MULTINODE_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
208240
elif [ "${PICK_ALL_RANDOM_PORTS}" = "true" ]; then
@@ -287,17 +319,18 @@ fi
287319

288320
# -ge # greater than or equal
289321
if [ "${SELENIUM_NODE_CH_PORT}" -ge "40000" ] && \
290-
[ "${SELENIUM_NODE_CH_PORT}" != "${DEFAULT_SELENIUM_NODE_CH_PORT}" ];then
322+
[ "${SELENIUM_NODE_CH_PORT}" != "${DEFAULT_SELENIUM_NODE_CH_PORT}" ]; then
291323
SELENIUM_FIRST_NODE_PORT=${SELENIUM_NODE_CH_PORT}
292324
fi
293325

294-
if [ "${SELENIUM_NODE_FF_PORT}" -ge "40000" ] && \
295-
[ "${SELENIUM_NODE_FF_PORT}" != "${DEFAULT_SELENIUM_NODE_FF_PORT}" ];then
326+
if [ "${SELENIUM_NODE_FF_PORT}" -ge "40000" ]; then
327+
if [ "${SELENIUM_NODE_FF_PORT}" != "${DEFAULT_SELENIUM_NODE_FF_PORT}" ]; then
296328
export SELENIUM_FIRST_NODE_PORT=${SELENIUM_NODE_FF_PORT}
329+
fi
297330
fi
298331

299332
if [ "${SELENIUM_MULTINODE_PORT}" -ge "40000" ] && \
300-
[ "${SELENIUM_MULTINODE_PORT}" != "${DEFAULT_SELENIUM_MULTINODE_PORT}" ];then
333+
[ "${SELENIUM_MULTINODE_PORT}" != "${DEFAULT_SELENIUM_MULTINODE_PORT}" ]; then
301334
export SELENIUM_FIRST_NODE_PORT=${SELENIUM_MULTINODE_PORT}
302335
fi
303336

@@ -366,21 +399,21 @@ ga_track_start () {
366399

367400
#--------------------------------
368401
# Improve etc/hosts and fix dirs
369-
if [ "${USE_KUBERNETES}" == "false" ]; then
402+
if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
370403
sudo improve_etc_hosts.sh
371404
fi
372405

373406
#-------------------------
374407
# Docker alongside docker
375-
if [ "${USE_KUBERNETES}" == "false" ]; then
408+
if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
376409
docker_alongside_docker.sh
377410
fi
378411

379412
#-------------------------------
380413
# Fix small tiny 64mb shm issue
381414
#-------------------------------
382415
# https://github.com/elgalu/docker-selenium/issues/20
383-
if [ "${SHM_TRY_MOUNT_UNMOUNT}" = "true" ] && [ "${USE_KUBERNETES}" == "false" ]; then
416+
if [ "${SHM_TRY_MOUNT_UNMOUNT}" = "true" ] && [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
384417
sudo umount /dev/shm || true
385418
sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=${SHM_SIZE} \
386419
tmpfs /dev/shm || true

test/script_scenario_node_dies

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ fi
8686

8787
echo "#================================================="
8888
echo "# Scenario 3b [node_dies]: Dies by killing Firefox"
89+
echo "# + REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING=true"
8990
echo "#================================================="
9091

9192
# Ensure clean env
@@ -95,7 +96,7 @@ docker rm -vf grid_mock || true
9596
# Create container for Firefox
9697
docker run --name=mynodes -d \
9798
-v /dev/shm:/dev/shm \
98-
--privileged \
99+
-e REMOVE_SELUSER_FROM_SUDOERS_FOR_TESTING=true \
99100
-e CHROME=false -e CI \
100101
-e SELENIUM_NODE_FF_PORT -p ${SELENIUM_NODE_FF_PORT}:${SELENIUM_NODE_FF_PORT} \
101102
selenium

vnc/bin/start-vnc.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ trap shutdown SIGTERM SIGINT SIGKILL
4444
# Redirecting to >/dev/null until https://github.com/LibVNC/x11vnc/issues/14
4545
export VNC_PID="9999"
4646
function start_vnc() {
47-
# rm -f ${VNC_TRYOUT_OUT_LOG}.${VNC_PORT}.log ${VNC_TRYOUT_ERR_LOG}.${VNC_PORT}.log
4847
# http://stackoverflow.com/a/21028200/511069
4948
x11vnc ${VNC_CLI_OPTS} \
5049
-rfbport ${VNC_PORT} \

0 commit comments

Comments
 (0)