Commit 400c6963 authored by Peter Parente's avatar Peter Parente Committed by GitHub

Merge pull request #525 from parente/fix-sudo-path

Append /opt/conda/bin to the sudo secure_path
parents 2c80cf35 a3cfda28
...@@ -48,8 +48,9 @@ if [ $(id -u) == 0 ] ; then ...@@ -48,8 +48,9 @@ if [ $(id -u) == 0 ] ; then
# Enable sudo if requested # Enable sudo if requested
if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then
echo "Granting $NB_USER sudo access" echo "Granting $NB_USER sudo access and appending $CONDA_DIR/bin to sudo PATH"
echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
sed -ri "s#Defaults\s+secure_path=\"([^\"]+)\"#Defaults secure_path=\"\1:$CONDA_DIR/bin\"#" /etc/sudoers
fi fi
# Exec the command as NB_USER with the PATH and the rest of # Exec the command as NB_USER with the PATH and the rest of
......
...@@ -71,6 +71,20 @@ def test_sudo(container): ...@@ -71,6 +71,20 @@ def test_sudo(container):
assert rv == 0 assert rv == 0
assert 'uid=0(root)' in c.logs(stdout=True).decode('utf-8') assert 'uid=0(root)' in c.logs(stdout=True).decode('utf-8')
def test_sudo_path(container):
"""Container should include /opt/conda/bin in the sudo secure_path."""
c = container.run(
tty=True,
user='root',
environment=['GRANT_SUDO=yes'],
command=['start.sh', 'sudo', 'which', 'jupyter']
)
rv = c.wait(timeout=10)
assert rv == 0
assert c.logs(stdout=True).decode('utf-8').rstrip().endswith('/opt/conda/bin/jupyter')
def test_group_add(container, tmpdir): def test_group_add(container, tmpdir):
"""Container should run with the specified uid, gid, and secondary """Container should run with the specified uid, gid, and secondary
group. group.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment