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

Clean up workspace dir from inside runner to avoid permission errors. #1648

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smoser
Copy link
Contributor

@smoser smoser commented Nov 14, 2024

When running privileged docker as an unprivileged user, the files that are created in the WorkspaceDir are created as root. Even if the build were run as non-root, they would not necessarily be the same ownership as the user invoking melange.

As a result, WorkspaceDir would not be able to be cleaned up and melange would just leave files there to later be cleaned up with a dangerous 'sudo rm -Rf' by the user.

The change here is to clean up the WorkspaceDir from inside the container, where the uid is the same as the uid that created the files.

I believe this will waste IO and/or time on the qemu runner, where /home/build isn't actually bind'd in. Later we could expose a CleanWorkspace from the runner that was a noop in qemu.

When running privileged docker as an unprivileged user, the files that
are created in the WorkspaceDir are created as root. Even if the build
were run as non-root, they would not necessarily be the same ownership
as the user invoking melange.

As a result, WorkspaceDir would not be able to be cleaned up and
melange would just leave files there to later be cleaned up with
a dangerous 'sudo rm -Rf' by the user.

The change here is to clean up the WorkspaceDir from _inside_ the
container, where the uid is the same as the uid that created the files.

I believe this will waste IO and/or time on the qemu runner,
where /home/build isn't actually bind'd in.  Later we could expose a
CleanWorkspace from the runner that was a noop in qemu.

Signed-off-by: Scott Moser <[email protected]>
@89luca89
Copy link
Contributor

I like this 👍 related to #1647 we could move also the mkdir in the container this way?

This should fix the problem of subpackage building when using docker runner with an unprivileged user

I believe this will waste IO and/or time on the qemu runner, where /home/build isn't actually bind'd in. Later we could expose a CleanWorkspace from the runner that was a noop in qemu.

Also nice yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants