-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Run all processes with seluser instead of root #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ca4da7a
553df4e
c8064de
4369255
e39dcc7
17e0cc1
ec6c705
b6ada51
0304487
303e571
02c909e
225fb30
f61783b
b0a1991
0f12883
cff3315
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ standalone_firefox: generate_standalone_firefox firefox | |
cd ./StandaloneFirefox && docker build $(BUILD_ARGS) -t $(NAME)/standalone-firefox:$(VERSION) . | ||
|
||
generate_standalone_firefox_debug: | ||
cd ./StandaloneDebug && ./generate.sh StandaloneFirefoxDebug standalone-firefox Firefox $(VERSION) $(NAMESPACE) $(AUTHORS) | ||
cd ./StandaloneDebug && ./generate.sh StandaloneFirefoxDebug node-firefox-debug Firefox $(VERSION) $(NAMESPACE) $(AUTHORS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building the StandaloneDebug images based on the NodeDebug images, makes the build faster. |
||
|
||
standalone_firefox_debug: generate_standalone_firefox_debug standalone_firefox | ||
cd ./StandaloneFirefoxDebug && docker build $(BUILD_ARGS) -t $(NAME)/standalone-firefox-debug:$(VERSION) . | ||
|
@@ -73,7 +73,7 @@ standalone_chrome: generate_standalone_chrome chrome | |
cd ./StandaloneChrome && docker build $(BUILD_ARGS) -t $(NAME)/standalone-chrome:$(VERSION) . | ||
|
||
generate_standalone_chrome_debug: | ||
cd ./StandaloneDebug && ./generate.sh StandaloneChromeDebug standalone-chrome Chrome $(VERSION) $(NAMESPACE) $(AUTHORS) | ||
cd ./StandaloneDebug && ./generate.sh StandaloneChromeDebug node-chrome-debug Chrome $(VERSION) $(NAMESPACE) $(AUTHORS) | ||
|
||
standalone_chrome_debug: generate_standalone_chrome_debug standalone_chrome | ||
cd ./StandaloneChromeDebug && docker build $(BUILD_ARGS) -t $(NAME)/standalone-chrome-debug:$(VERSION) . | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN true | ||
USER root | ||
|
||
#============== | ||
# VNC and Xvfb | ||
|
@@ -10,14 +9,18 @@ RUN apt-get update -qqy \ | |
xvfb \ | ||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* | ||
|
||
#=================================================== | ||
# Run the following commands as non-privileged user | ||
#=================================================== | ||
|
||
USER seluser | ||
|
||
#============================== | ||
# Scripts to run Selenium Node | ||
#============================== | ||
COPY \ | ||
entry_point.sh \ | ||
COPY entry_point.sh \ | ||
functions.sh \ | ||
/opt/bin/ | ||
RUN chmod +x /opt/bin/entry_point.sh | ||
|
||
#============================ | ||
# Some configuration options | ||
|
@@ -27,6 +30,27 @@ ENV SCREEN_HEIGHT 1020 | |
ENV SCREEN_DEPTH 24 | ||
ENV DISPLAY :99.0 | ||
|
||
USER seluser | ||
#======================== | ||
# Selenium Configuration | ||
#======================== | ||
# As integer, maps to "maxInstances" | ||
ENV NODE_MAX_INSTANCES 1 | ||
# As integer, maps to "maxSession" | ||
ENV NODE_MAX_SESSION 1 | ||
# As integer, maps to "port" | ||
ENV NODE_PORT 5555 | ||
# In milliseconds, maps to "registerCycle" | ||
ENV NODE_REGISTER_CYCLE 5000 | ||
# In milliseconds, maps to "nodePolling" | ||
ENV NODE_POLLING 5000 | ||
# In milliseconds, maps to "unregisterIfStillDownAfter" | ||
ENV NODE_UNREGISTER_IF_STILL_DOWN_AFTER 60000 | ||
# As integer, maps to "downPollingLimit" | ||
ENV NODE_DOWN_POLLING_LIMIT 2 | ||
# As string, maps to "applicationName" | ||
ENV NODE_APPLICATION_NAME "" | ||
|
||
# Following line fixes https://github.com/SeleniumHQ/docker-selenium/issues/87 | ||
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving these ENV vars in the NodeBase image, they were duplicated in other docker files. |
||
|
||
CMD ["/opt/bin/entry_point.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
|
||
source /opt/bin/functions.sh | ||
/opt/selenium/generate_config > /opt/selenium/config.json | ||
/opt/bin/generate_config > /opt/selenium/config.json | ||
|
||
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" | ||
|
||
|
@@ -29,8 +29,6 @@ if [ ! -z "$SE_OPTS" ]; then | |
echo "appending selenium options: ${SE_OPTS}" | ||
fi | ||
|
||
# TODO: Look into http://www.seleniumhq.org/docs/05_selenium_rc.jsp#browser-side-logs | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this TODO since the |
||
SERVERNUM=$(get_server_num) | ||
|
||
rm -f /tmp/.X*lock | ||
|
@@ -44,4 +42,4 @@ xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" | |
NODE_PID=$! | ||
|
||
trap shutdown SIGTERM SIGINT | ||
wait $NODE_PID | ||
wait $NODE_PID |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#!/bin/bash | ||
# | ||
# IMPORTANT: Change this file only in directory NodeDebug! | ||
|
||
source /opt/bin/functions.sh | ||
/opt/selenium/generate_config > /opt/selenium/config.json | ||
/opt/bin/generate_config > /opt/selenium/config.json | ||
|
||
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" | ||
|
||
|
@@ -29,17 +31,11 @@ if [ ! -z "$SE_OPTS" ]; then | |
echo "appending selenium options: ${SE_OPTS}" | ||
fi | ||
|
||
# TODO: Look into http://www.seleniumhq.org/docs/05_selenium_rc.jsp#browser-side-logs | ||
|
||
SERVERNUM=$(get_server_num) | ||
|
||
rm -f /tmp/.X*lock | ||
|
||
env | cut -f 1 -d "=" | sort > asroot | ||
sudo -E -u seluser -i env | cut -f 1 -d "=" | sort > asseluser | ||
sudo -E -i -u seluser \ | ||
"$(for E in $(grep -vxFf asseluser asroot); do echo $E=$(eval echo \$$E); done)" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a workaround to export the ENV vars present in the |
||
DISPLAY=$DISPLAY \ | ||
DISPLAY=$DISPLAY \ | ||
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \ | ||
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \ | ||
-role node \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# | ||
# IMPORTANT: Change this file only in directory NodeDebug! | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File added to handle the |
||
source /opt/bin/functions.sh | ||
/opt/bin/generate_config > /opt/selenium/config.json | ||
|
||
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" | ||
|
||
if [ ! -e /opt/selenium/config.json ]; then | ||
echo No Selenium Node configuration file, the node-base image is not intended to be run directly. 1>&2 | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$HUB_PORT_4444_TCP_ADDR" ]; then | ||
echo Not linked with a running Hub container 1>&2 | ||
exit 1 | ||
fi | ||
|
||
function shutdown { | ||
kill -s SIGTERM $NODE_PID | ||
wait $NODE_PID | ||
} | ||
|
||
if [ ! -z "$REMOTE_HOST" ]; then | ||
>&2 echo "REMOTE_HOST variable is *DEPRECATED* in these docker containers. Please use SE_OPTS=\"-host <host> -port <port>\" instead!" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -z "$SE_OPTS" ]; then | ||
echo "appending selenium options: ${SE_OPTS}" | ||
fi | ||
|
||
SERVERNUM=$(get_server_num) | ||
|
||
rm -f /tmp/.X*lock | ||
|
||
DISPLAY=$DISPLAY \ | ||
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \ | ||
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \ | ||
-role node \ | ||
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \ | ||
-nodeConfig /opt/selenium/config.json \ | ||
${SE_OPTS} & | ||
NODE_PID=$! | ||
|
||
trap shutdown SIGTERM SIGINT | ||
for i in $(seq 1 10) | ||
do | ||
xdpyinfo -display $DISPLAY >/dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
break | ||
fi | ||
echo Waiting xvfb... | ||
sleep 0.5 | ||
done | ||
|
||
fluxbox -display $DISPLAY & | ||
|
||
x11vnc -forever -usepw -shared -rfbport 5900 -display $DISPLAY & | ||
|
||
wait $NODE_PID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running all commands as
seluser
, so the ENV vars a present for this user always.