When emerging a package which used make in pkg_pretend() (to get kernel version), I get a lot of the following errors: distcc[30129] (dcc_open_lockfile) ERROR: failed to creat /tmp/portage/.distcc/lock/cpu_localhost_0: Permission denied distcc[30129] (dcc_lock_one) ERROR: failed to lock /tmp/portage/.distcc/ ├── [drwxrwsr-x root portage ] lock │ └── [-rw-r--r-- root portage ] cpu_localhost_0 └── [drwxrwsr-x root portage ] state Looking at the: * Adjusting permissions for FEATURES=userpriv: '/tmp/portage/.distcc' * Adjusting permissions for FEATURES=userpriv: '/tmp/portage/.distcc/lock' * Adjusting permissions for FEATURES=userpriv: '/tmp/portage/.distcc/state' I guess that portage adjusts the permissions for directories only, assuming there are no files inside yet. As the earlier make call created the cpu_localhost_0 file, it lacks g+w. The simplest solution would be to simply adjust the permissions recursively. An alternative might be to disable distcc during pkg_pretend() but same problem is likely to appear when ebuilds use RESTRICT=userpriv.
Looking at the code, it already uses the apply_recursive_permissions function when you see that "Adjusting permissions" message, which should do files like cpu_localhost_0 as well. The relevant code is in the _prepare_features_dirs function inside /usr/lib/portage/pym/portage/package/ebuild/prepare_build_dirs.py.