-
-
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
Conversation
…luser, not needed anymore
…hey already exist in the seluser env. Also adopting new paths.
… up the build and reduces duplicated config.
Base/Dockerfile
Outdated
#========== | ||
RUN mkdir -p /home/seluser/selenium \ | ||
&& wget --no-verbose https://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar \ | ||
-O /home/seluser/selenium/selenium-server-standalone.jar |
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.
The Selenium related files are placed in a seluser
home subfolder, called /home/seluser/selenium/
, so the seluser
is owner by default.
@@ -1,3 +1,5 @@ | |||
USER seluser | |||
|
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.
@@ -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 comment
The 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.
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 comment
The 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.
Exporting them with seluser
, so they are present by default in the entry points.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This was a workaround to export the ENV vars present in the root
user and not present in the seluser
. Since all ENV vars are now exported with the seluser
, this is not needed anymore.
#!/bin/bash | ||
# | ||
# IMPORTANT: Change this file only in directory NodeDebug! | ||
|
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.
File added to handle the entry_point.sh
in the same way it is done for the StandaloneDebug images. Things get changed here and the file is copied to the appropriate folders.
@@ -27,31 +27,11 @@ RUN wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geck | |||
&& chmod 755 /opt/geckodriver-$GECKODRIVER_VERSION \ | |||
&& ln -fs /opt/geckodriver-$GECKODRIVER_VERSION /usr/bin/geckodriver | |||
|
|||
#======================== |
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.
All these ENV vars are now exported in the NodeBase image.
@@ -1,55 +0,0 @@ | |||
FROM selenium/node-firefox:3.4.0-chromium |
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.
This file was in the repo, but not used anywhere. The Dockerfile
comes from the NodeDebug folder.
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)" \ | ||
DISPLAY=$DISPLAY \ |
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.
This was a workaround to export the ENV vars present in the root
user and not present in the seluser
. Since all ENV vars are now exported with the seluser
, this is not needed anymore.
@@ -29,19 +29,17 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this TODO since the browserSideLog
(which the URL refers to), should not be used anymore according to the Selenium Grid code
👍 on my side, I run a couple of tests in my OSX host and also in my Linux host, using chrome and firefox standalone images built from Diego's fork. |
i'd like to merge this in at the same time as i get the new testing in place. working on it as we speak, so hopefully soon we'll get this in :) |
the only thing that concerns me with these changes, are programs that have their own arbitrary user for security purposes, e.g.: OpenShift. We can fix these on an adhoc basis, but we can probably expect to see some issues being created regarding this. |
While checking #474, I found that in some images the processes are run by
seluser
and in other ones they are run withseluser
androot
(specially in the debug ones). E.g.:I went through all the
Dockerfiles
andentry_point.sh
and improved them so all the processes run now withseluser
.I executed the tests and they passed, I also tested it so the fix done in #459 and #469 don't get lost.
@ddavison
I will add some comments next to the commits to make this PR easier to review.
@elgalu, can you please also help to review this PR?
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement