Hi,
Sharing $HOME/.cache/ccache with the unshare currently requires making
that directory world-writable on the host, which is icky.
I'm not familiar with unshare too much I but solved a similar problem
with podman. Both unshare and podman use UID namespaces, so maybe my
solution would work there, too.
What I did there was: in addition to the subgids (100000:65536), also
map the user's main GUID to the unshare. So that host:1000 can be
unshare:1000, and everything else is per 100000+ mapping.
Then, in the unshare, chown the mount point for CCACHE_DIR to group
1000, and add the subuid of the unshare-user to that group. That user
should now be able to write to that directory, ie on the host.
podman has its own logic to do set up such a map, and I documented it
here [1]. But podman tries to cover a multitude of use cases. In this
case, we'd only need to cover just one special group. podman also just
uses /etc/sub{u,g}id and new{u,g}idmap AFAIK, so there some be some
way to do it.
Just theoretical food for thought now, in case anyone is curious enough
to give it a try.
Best,
Christian
[1]: https://salsa.debian.org/rocm-team/community/team-project/-/blob/master/doc/rocm-autopkgtests-in-containers.md?ref_type=heads#mapping-container-groups-to-host-groups