[Rpm-maint] [rpm-software-management/rpm] Relocatable packages with plain `/` in `%files` can't be installed as regular user (Issue #3173)
Panu Matilainen
notifications at github.com
Wed Jun 19 07:59:21 UTC 2024
> When processing the payload files, we eventually call fsmSetmeta() for the top-level directory / which obviously fails for a regular user. This happens despite us already being (via di.dirfd) in the right top-level directory $PWD/RPMROOTDIR, because fp->fpath is set to / there and when we pass it to fchownat(2), since the path is absolute, di.dirfd is ignored by the function (as per specification).
Oh... what fun. It's basically a gotcha of the *at() APIs I never considered at all. So your suggestion to replace "/" with "." seems like the right thing to do, the code is not really wanting to touch real "/" all, it's just getting thrown off by the "/" basename. As per the API spec.
With the relative path, the removal case is not failing because it tries to remove the real "/" but because of this:
`D: fsmRmdir (8 .) Invalid argument`
Ie "." is not a valid argument to unlinkat() .
https://stackoverflow.com/questions/76844005/how-to-get-unlinkatdir-fd-at-removedir-to-work talks about this: the gotcha is in the rmdir(2) manual:
> EINVAL pathname has . as last component.
This seems pretty annoying. We must never try to create or remove the real "/" - the old code had specific check on creation but at least as of 4.17 actually tried to remove "/" on erasure, which is wrong no matter what the package says. The current code doesn't need the test on creation, but it would need to check against removal. But, in this case we should remove the RPMROOTDIR we created because the package owns it and older rpm versions did remove it. But, because "." is not acceptable it seems we'd need to go one directory upwards. Which might be a bit tricky to to fit there. Maybe it needs a special case in fsmRmdir(), as ugly as that seems.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/3173#issuecomment-2178015760
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/3173/2178015760 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20240619/4446d82e/attachment-0001.html>
More information about the Rpm-maint
mailing list