Skip to content

Commit

Permalink
Revert "[MRG] Do not try to build the image with root as the primary …
Browse files Browse the repository at this point in the history
…user." (#678)

Revert "[MRG] Do not try to build the image with root as the primary user."
  • Loading branch information
betatim authored May 9, 2019
2 parents 4514ba3 + e66f0af commit fedd58a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
2 changes: 0 additions & 2 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ API changes

Bug fixes
---------
- Prevent building the image as root if --user-id and --user-name are not specified
in :pr:`676` by :user:`Xarthisius`.


Version 0.9.0
Expand Down
14 changes: 0 additions & 14 deletions repo2docker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
python -m repo2docker https://github.com/you/your-repo
"""
import argparse
import errno
import json
import sys
import logging
Expand Down Expand Up @@ -651,19 +650,6 @@ def build(self):
extra=dict(phase='building'))

if not self.dry_run:
if os.geteuid() == 0:
self.log.error(
'Root as the primary user in the image is not permitted.\n'
)
self.log.info(
"The uid and the username of the user invoking repo2docker "
"is used to create a mirror account in the image by default. "
"To override that behavior pass --user-id <numeric_id> and "
" --user-name <string> to repo2docker.\n"
"Please see repo2docker --help for more details.\n"
)
sys.exit(errno.EPERM)

build_args = {
'NB_USER': self.user_name,
'NB_UID': str(self.user_id),
Expand Down
15 changes: 1 addition & 14 deletions tests/unit/test_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import errno
import pytest
from tempfile import TemporaryDirectory
from unittest.mock import patch

Expand Down Expand Up @@ -103,15 +101,4 @@ def test_run_kwargs(repo_with_content):
containers.run.assert_called_once()
args, kwargs = containers.run.call_args
assert 'somekey' in kwargs
assert kwargs['somekey'] == "somevalue"


def test_root_not_allowed():
with TemporaryDirectory() as src, patch('os.geteuid') as geteuid:
geteuid.return_value = 0
app = Repo2Docker()
argv = [src]
app = make_r2d(argv)
with pytest.raises(SystemExit) as exc:
app.build()
assert exc.code == errno.EPERM
assert kwargs['somekey'] == "somevalue"

0 comments on commit fedd58a

Please sign in to comment.