Open edannenberg opened 2 years ago
Thanks! This sounds like ebuilds may have incorrect dependencies (it's an issue when installing from binpkgs too). Just got up though so let me have a think 🤔
Is there an example set of steps I can play with?
cc @Mord3rca
Hey !
I see .. The only way to mitigate the fowners
issue is to wrap the chown / fchown syscall... So, all commands will be affected at once.
I did not try a full test build at work, but we have this kind of wrapper to avoid setting an unknown permission + we hook getpwname to return an internal list of users read from ${ROOT}/etc/passwd so commands like chown won't crash with a user which is not from the host.
I'll see if this can correct the error. If so, maybe we can add the hooked function to libsandbox. I'll keep you informed.
We discussed this a bit in #gentoo-base on IRC and I think we need some logs to properly understand it. Could you file a bug on Gentoo's Bugzilla with that information? (inc. e.g an example ebuild, and some steps to repro).
Needing BROOT to contain things in order to do e.g. fowners is considered normal and something we've been doing for ages. I'm not against a change along the lines @Mord3rca suggests in principle, I think, but would need to see it in more detail?
Everything but point 2. should be handled by dependencies and point 2 seems like it should be handled by baselayout.
@thesamesam Good news ! I've started a full rebuild (not of this, just to be clear) with my modification in eclasses + my hook for getpwnam / getgroupnam etc and it seems to do the trick for fchown
. I'm starting to adapt my work for libsandbox so you can hopefully test it soon.
Thanks for the swift replies!
Is there an example set of steps I can play with?
Any ebuild that creates a user/group and then tries to fowners
with the new user will do, provided the user doesn't exist on the host yet.
We discussed this a bit in #gentoo-base on IRC and I think we need some logs to properly understand it. Could you file a bug on Gentoo's Bugzilla with that information? (inc. e.g an example ebuild, and some steps to repro).
Given the example ebuild above:
Original behavior:
$ ROOT=/foo emerge dev-util/foo
$ cat /etc/group
<snip>
kubler:x:249:
$ cat /etc/passwd
<snip>
kubler:x:999:249:added by portage for foo:/usr/share/foo:/bin/false
$ cat /foo/etc/passwd
cat: /foo/etc/passwd: No such file or directory
The user is created at ROOT
now but as the user doesn't exist on the host fowners
fails the build. Happy to file a bug if you still think that would help.
Needing BROOT to contain things in order to do e.g. fowners is considered normal and something we've been doing for ages.
Not sure I follow, could you elaborate please?
Everything but point 2. should be handled by dependencies and point 2 seems like it should be handled by baselayout.
Not sure what you mean with handled by dependencies
. Point 3 was me being confused by portage's environment
feature, so old binary packages still worked as before (TIL). The behavior is consistent, if you manage to create a new binary package that is. Workarounds:
ROOT
Point 2 is a nice to have and I can work around that fairly easy by making sure the paths enewgroup/enewuser
expect actually exist. Ideally the eclass would skip the check if ROOT
doesn't have a passwd/group file.
Hello,
I'm making progress on the patch for adding shadow capabilities for libsandbox
, however my patch do not work in the sandboxed context. I need to read more carefully the code to understand why. (It works when using LD_PRELOAD
so .. It's something I guess)
FYI, my branch can be found here: https://github.com/Mord3rca/sandbox/commits/libsandox/shadow_hook
@edannenberg regarding your workaround for the fowners
situation, I guess you can do a more elegant solution. A lot of services (postfix, opendkim, ...) have the acct-user / acct-group related to their executing in both RDEPEND
& BDEPEND
, so you install the user in the host & target. This can be done only if you control the ebuild code of course.
Also, for your test build, be sure to install baselayout
before everything else, if not, passwd / group files won't exist.
Sorry, I meant to reply to this sooner. Another option would be to support both behaviours via some ENV, the kubler patches should make this fairly easy to implement I think.
This commit breaks the build for uncached packages that create users/groups.
Problems:
fowners
will still look on the host for the user.ROOT
which is not always true for our use case. Not handled gracefully currently and fails the build.* To make matters worse the behavior is now inconsistent, as binary packages still create any new users/groups on the host.@thesamesam Could this be reverted for now until all the edge cases are fleshed out? Right now it does more harm then good as its much harder to work around then with the old behavior.