I sent the patch to gentoo-portage-dev@lists.gentoo.org, but it looks like it got stuch somewhere. Reproducible: Always
Created attachment 907319 [details, diff] gpkg: ignore symlinks to files we have no access to
Can you give an example of how this case occurs? Are you not running as root? I'm trying to understand if there is any better way to handle this case.
Hi Zac, I'm generating images as regular user, under fakeroot (because i need to create minimal set of devnodes), basically using ROOT=/wherever emerge $wanted_pkgs, and some symlinks happened to be absolute, eventually pointing to places it had no read rights to in running rootfs.
Another way i can think of that could be better: check if symlinks are pointing outside of ROOT=, and if so, ignore them for size evaluation, before attempting to deref them.
(In reply to Étienne Buira from comment #4) > Another way i can think of that could be better: > check if symlinks are pointing outside of ROOT=, and if so, ignore them for > size evaluation, before attempting to deref them. We can use the portage.abssymlink function to resolve the path here.
Created attachment 907503 [details, diff] gpkg: do not consider symlinks targets for size estimation Hi, I took another look, and it seemed to me probing for the pointed to BLOB was buggy anyway, so what do you think about this (untested) patch?
Yes, ignoring symlinks entirely here seems perfectly reasonable.
I've noticed there's an earlier redundant islink call we can make use of here.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35 commit 5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35 Author: Etienne Buira <etienne.buira@free.fr> AuthorDate: 2024-11-01 23:33:30 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2024-11-01 23:33:30 +0000 gpkg: do not consider symlinks targets for size estimation Symlinks size is already accounted for, so there is no need to account for the pointed to file. Moreover, previous code failed to handle permission error when using ROOT= and having absolute symlinks pointing to running root. Signed-off-by: Etienne Buira <etienne.buira@free.fr> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <zmedico@gentoo.org> NEWS | 2 ++ lib/portage/gpkg.py | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-)
Created attachment 907680 [details, diff] avoid 2 more syscalls Thanks, we can use the same syscall elision in the code around.
Created attachment 907684 [details, diff] Save another 2 syscalls While at it :)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=33e5f70ec3ec7334d646daf1cf18a22fec8faf39 commit 33e5f70ec3ec7334d646daf1cf18a22fec8faf39 Author: Etienne Buira <etienne.buira@free.fr> AuthorDate: 2024-11-02 15:18:34 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2024-11-02 15:47:01 +0000 gpkg: use already queried size instead of syscall Signed-off-by: Etienne Buira <etienne.buira@free.fr> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <zmedico@gentoo.org> lib/portage/gpkg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) https://gitweb.gentoo.org/proj/portage.git/commit/?id=320df528974c09338c7fef12e41ce66c5593c101 commit 320df528974c09338c7fef12e41ce66c5593c101 Author: Etienne Buira <etienne.buira@free.fr> AuthorDate: 2024-11-02 14:33:27 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2024-11-02 15:45:49 +0000 gpkg: avoid os.path.islink where lstat is available Signed-off-by: Etienne Buira <etienne.buira@free.fr> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <zmedico@gentoo.org> lib/portage/gpkg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=ac88048bb1d6a28dbd415223e2e0fc3ec8b16a6c commit ac88048bb1d6a28dbd415223e2e0fc3ec8b16a6c Author: Zac Medico <zmedico@gentoo.org> AuthorDate: 2024-11-02 22:10:44 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2024-11-02 22:11:47 +0000 gpkg: Fix S_ISLNK usage Fixes: 320df528974c ("gpkg: avoid os.path.islink where lstat is available") Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <zmedico@gentoo.org> lib/portage/gpkg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03f41049a0fe0632eabd8cddaaca898e45943201 commit 03f41049a0fe0632eabd8cddaaca898e45943201 Author: Sam James <sam@gentoo.org> AuthorDate: 2025-01-22 00:29:50 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2025-01-22 00:30:02 +0000 sys-apps/portage: add 3.0.67 Closes: https://bugs.gentoo.org/703520 Closes: https://bugs.gentoo.org/707980 Closes: https://bugs.gentoo.org/904702 Closes: https://bugs.gentoo.org/906044 Closes: https://bugs.gentoo.org/923530 Closes: https://bugs.gentoo.org/938164 Closes: https://bugs.gentoo.org/939299 Closes: https://bugs.gentoo.org/940120 Closes: https://bugs.gentoo.org/942512 Closes: https://bugs.gentoo.org/942760 Closes: https://bugs.gentoo.org/945382 Closes: https://bugs.gentoo.org/945861 Closes: https://bugs.gentoo.org/946326 Closes: https://bugs.gentoo.org/947822 Closes: https://bugs.gentoo.org/948067 Closes: https://bugs.gentoo.org/939444 Signed-off-by: Sam James <sam@gentoo.org> sys-apps/portage/Manifest | 1 + sys-apps/portage/portage-3.0.67.ebuild | 231 +++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+)