Skip to content

Commit 193a17d

Browse files
committed
Adjusting container permissions for OpenShift and other non-sudo environments. Fixes #802
1 parent 34e50f7 commit 193a17d

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

Base/Dockerfile

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,21 @@ RUN chmod +x /opt/bin/check-grid.sh
6666
#======================================
6767
COPY supervisord.conf /etc
6868

69-
#===================================================
70-
# Run the following commands as non-privileged user
71-
#===================================================
72-
USER seluser
73-
7469
#==========
75-
# Selenium
70+
# Selenium & relaxing permissions for OpenShift and other non-sudo environments
7671
#==========
77-
RUN sudo mkdir -p /opt/selenium \
78-
&& sudo chown seluser:seluser /opt/selenium \
72+
RUN mkdir -p /opt/selenium /var/run/supervisor /var/log/supervisor \
73+
&& touch /opt/selenium/config.json \
74+
&& chmod -R 777 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd \
7975
&& wget --no-verbose https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar \
8076
-O /opt/selenium/selenium-server-standalone.jar \
81-
&& sudo chgrp -R 0 /opt/selenium $HOME \
82-
&& sudo chmod -R g=u /opt/selenium $HOME \
83-
&& sudo mkdir -p /var/run/supervisor/ \
84-
&& sudo mkdir -p /var/log/supervisor/ \
85-
&& sudo chown -R seluser:seluser /var/run/supervisor \
86-
&& sudo chown -R seluser:seluser /var/log/supervisor \
87-
&& sudo chgrp -R 0 /var/run/supervisor /var/log/supervisor \
88-
&& sudo chmod -R g=u /var/run/supervisor /var/log/supervisor
77+
&& chgrp -R 0 /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor \
78+
&& chmod -R g=u /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor
79+
80+
#===================================================
81+
# Run the following commands as non-privileged user
82+
#===================================================
83+
USER seluser
8984

9085

9186
CMD ["/opt/bin/entry_point.sh"]

Base/entry_point.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#!/usr/bin/env bash
22

3+
#==============================================
4+
# OpenShift or non-sudo environments support
5+
# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
6+
#==============================================
7+
8+
if ! whoami &> /dev/null; then
9+
if [ -w /etc/passwd ]; then
10+
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
11+
fi
12+
fi
13+
314
/usr/bin/supervisord --configuration /etc/supervisord.conf &
415

516
SUPERVISOR_PID=$!

NodeDebug/Dockerfile.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ USER seluser
2424
# So the service can be started with seluser
2525
#==============================
2626

27-
RUN mkdir -p ~/.vnc \
28-
&& x11vnc -storepasswd secret ~/.vnc/passwd
27+
RUN mkdir -p ${HOME}/.vnc \
28+
&& x11vnc -storepasswd secret ${HOME}/.vnc/passwd
29+
30+
#==========
31+
# Relaxing permissions for OpenShift and other non-sudo environments
32+
#==========
33+
RUN sudo chmod -R 777 ${HOME} \
34+
&& sudo chgrp -R 0 ${HOME} \
35+
&& sudo chmod -R g=u ${HOME}
2936

3037
#==============================
3138
# Scripts to run fluxbox and x11vnc

NodeFirefox/Dockerfile.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ USER seluser
3434

3535
COPY generate_config /opt/bin/generate_config
3636

37-
# Running this command as sudo just to avoid the message:
38-
# To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
39-
# When logging into the container
40-
RUN sudo echo ""
41-
4237
# Generating a default config during build time
4338
RUN /opt/bin/generate_config > /opt/selenium/config.json
39+
40+
#==========
41+
# Relaxing permissions for OpenShift and other non-sudo environments
42+
#==========
43+
RUN sudo chmod -R 777 ${HOME} \
44+
&& sudo chgrp -R 0 ${HOME} \
45+
&& sudo chmod -R g=u ${HOME}
46+

0 commit comments

Comments
 (0)