Use the same non-privileged UID inside the container as that of the host user - #20
Use the same non-privileged UID inside the container as that of the host user#20atrosinenko wants to merge 3 commits into
Conversation
|
I plan tuning this patch a bit, so that |
19a28e6 to
1ef542c
Compare
6f21a05 to
e1c2c44
Compare
1ef542c to
8251227
Compare
e1c2c44 to
6d28a75
Compare
|
Updated the PR, now it is ready for review. |
| # without sudo on the host - this is useful to make sure ccache does not | ||
| # silently fall back to non-cached rebuilds in the 'host-build' mode of build.sh. | ||
| local UID | ||
| if [ "x$SUDO_USER" != "x" ]; then |
There was a problem hiding this comment.
So do we need to manually set this environment variable in the config file if we with to achieve the desired effect? If yes, could you please add a corresponding entry + short description to the config file + mention this variable in README?
Or is it some well-known automatically set environment variable? If yes, could you please clarify who is setting it?
There was a problem hiding this comment.
SUDO_USER is normally set by sudo itself:
Set to the login name of the user who invoked sudo.
Added a comment in 03a97e7, thanks.
There was a problem hiding this comment.
So, does this imply that one might want to run build.sh under sudo for some reasons? I'm just not sure if it's a good idea... Maybe I'm missing smth though.
There was a problem hiding this comment.
So, does this imply that one might want to run build.sh under sudo for some reasons?
Yes, locally I usually run docker using sudo - maybe this is against the best practices, but I'm not sure. I could drop the part with SUDO_USER at all, as this seems to be the trickiest part of the PR. On the other hand, I'm not sure which are the best practices for other container engines, such as daemon-less Podman.
Frankly speaking, I'm a bit worried about this PR in general from the security perspective as it deals with going from non-privileged user to privileged one and vice versa. On the other hand, if the current user is able to launch rootful Ubuntu docker container and mount own directories as volumes into it, then exactly the same actions can be performed manually :)
|
Maybe I could provide a much easier replacement for this PR. The most painful consequence of various files and directories being owned by I would expect that the host and containerized builds would not share object files most of the times anyway, so the only issue is that the |
Yeah, this would probably be the simplest fix which would not make a lot of assumptions about sudo-related stuff, user privileges, UID hardcoded, etc. Would cost 1 extra "initial" build (if one wants to use both host and containerized build, they need to run initial build for each variant to have ccache initialized for both), but I guess it's not that huge cost and is acceptable |
This fixes the contents of ./ccache and ./output directories being owned by `root`.
03a97e7 to
7199ad0
Compare
This fixes the contents of ./ccache and ./output directories being owned by
root.