Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package silently fails to extract properly #2041

Open
moracca opened this issue May 12, 2022 · 3 comments
Open

Package silently fails to extract properly #2041

moracca opened this issue May 12, 2022 · 3 comments

Comments

@moracca
Copy link

moracca commented May 12, 2022

We host our own pkg repo server and after our most recent port updates I've experienced a failure when running pkg upgrade where the squid port fails to upgrade with the following error:

[89/144] Upgrading squid from 4.15 to 5.4.1...
===> Creating groups.
Using existing group 'squid'.
===> Creating users
Using existing user 'squid'.
===> Creating homedir(s)
===> Pre-installation configuration for squid-5.4.1
[89/144] Extracting squid-5.4.1: 100%
pkg: Fail to rename /usr/local/etc/squid/errors/es-mx/.pkgtemp.ERR_ACCESS_DENIED.Uxm4Qekj4vP8 -> /usr/local/etc/squid/errors/es-mx/ERR_ACCESS_DENIED:No such file or directory

When I manually extract the squid package on the server I see the usr/local/etc/squid/errors/es-mx within it, yet if I go look inside /usr/local/etc/squid/errors/ itself on this system, I do not see the es-mx directory at all.

In both cases, a second attempt to run pkg upgrade completed successfully.

We also had a recent instance on a different system that got this error while installing packages which we chalked up to a fluke at the time because a second attempt worked as expected:

[514/550] Installing py38-ansible-4.7.0...
[514/550] Extracting py38-ansible-4.7.0: .....
pkg: Fail to chmod /usr/local/lib/python3.8/site-packages/ansible_collections/community/network/tests/unit/plugins/modules/network/aireos/.pkgtemp.aireos_module.py.ypORaZODAg81:Bad file descriptor
[514/550] Extracting py38-ansible-4.7.0... done

My question is, what could cause pkg to encounter these issues while extracting packages? Is it possible that the package download was corrupted in some way? I wouldn't expect the same error in the same package on two different systems if that were the case, but is it possible to force pkg to check the md5 of the downloaded packages before proceeding? I didn't see any disk-related errors in any of the other system logs during the ugprades.

Any suggestions on how to track this issue down/prevent it?
Thanks!

@moracca
Copy link
Author

moracca commented Nov 1, 2022

in the case of squid, this turned out to be a problem with the package itself, where a directory was changed from a symlink to a real folder, and the file was initially extracted properly to the symlinked folder, but then the symlink got replaced with the folder, and the .pkgtemp file was no longer around when it tried to rename it to the final filename.

@yadij
Copy link

yadij commented Nov 2, 2022

Sorry my initial thought was incorrect. The bug is in a Squid makefile. I have opened https://bugs.squid-cache.org/show_bug.cgi?id=5246 to track it upstream.

@fichtner
Copy link
Contributor

This case is still easily reproducible by creating a file at the location where pkg expects none and tries to move the temp dir to:

pkg/libpkg/pkg_add.c

Lines 877 to 884 in e686c3f

tll_foreach(*tempdirs, t) {
if (renameat(pkg->rootfd, RELATIVE_PATH(t->item->temp),
pkg->rootfd, RELATIVE_PATH(t->item->name)) != 0) {
pkg_fatal_errno("Fail to rename %s -> %s",
t->item->temp, t->item->name);
}
free(t->item);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants