Skip to content
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

init-docker-image: remove ubuntu user if it exists #49

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bldr/bldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def build(self, package_dir: Path) -> DockerImage:
@classmethod
def selftest(cls) -> None:
client = create_docker_client()
for ubuntu_release in ['focal', 'jammy']:
for ubuntu_release in ['focal', 'jammy', 'noble']:
image = DockerImage(client=client, image='ubuntu:{}'.format(ubuntu_release))
assert image is not None, "DockerImage should be initialized without Exception"

Expand All @@ -214,7 +214,7 @@ def selftest(cls) -> None:

assert container.exec(command=['false']) == 1, "return code should be returned"

cmd = 'useradd -u 1000 user && su user -c whoami' # checking for possible SELinux issues
cmd = 'useradd -u 1001 user && su user -c whoami' # checking for possible SELinux issues
assert container.exec_run(command=['bash', '-c', cmd]) == 'user\n', "'su user' should succeed"

cmd = 'echo "deb http://archive.ubuntu.com/ubuntu {} main universe" > /etc/apt/sources.list'.format(ubuntu_release)
Expand Down
5 changes: 5 additions & 0 deletions bldr/data/files/usr/local/bin/init-docker-image
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
set -e
echo "Preparing BLDR deb builder docker image"

if getent passwd ubuntu; then
echo "Deleting ubuntu user"
userdel -r ubuntu
fi

echo "Adding non-privileged user ${NONPRIV_USER_NAME} with uid ${NONPRIV_USER_UID}"
useradd -u ${NONPRIV_USER_UID} ${NONPRIV_USER_NAME} -m

Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
from pathlib import Path

DEFAULT_DOCKER_IMAGES = ["ubuntu:focal", "ubuntu:jammy"]
DEFAULT_DOCKER_IMAGES = ["ubuntu:focal", "ubuntu:jammy", "ubuntu:noble"]


def pytest_addoption(parser):
Expand Down
Loading