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

dnf/dnf/conf/config.py: if TMPDIR is set to a non-existent dir, upgrades will fail #280

Open
wileyhy opened this issue Jun 20, 2023 · 2 comments
Labels
Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take

Comments

@wileyhy
Copy link

wileyhy commented Jun 20, 2023

dnf/dnf/conf/config.py: if TMPDIR is set to a non-existent dir, upgrades will fail.

in addition to testing whether TMPDIR is set, config.py should also check that the directory TMPDIR points to actually exists, in my opinion.

export TMPDIR=/sound
dnf -y install ncdu

Last metadata expiration check: 0:00:57 ago on Tue 20 Jun 2023 12:56:51 PM PDT.
Dependencies resolved.
Package Architecture Version Repository Size
Reinstalling:
ncdu x86_64 1.18-4.fc38 fedora 63 k

Transaction Summary

Total download size: 63 k
Installed size: 111 k
Downloading Packages:
Cannot create temporary file - mkstemp '/sound/librepo-tmp-EZSao0': No such file or directory

dnf -y upgrade

Last metadata expiration check: 0:01:04 ago on Tue 20 Jun 2023 12:56:51 PM PDT.
Dependencies resolved.
Package Architecture Version Repository Size
Installing:
kernel x86_64 6.3.8-200.fc38 updates 132 k
...
xxd x86_64 2:9.0.1627-1.fc38 updates 35 k

Transaction Summary
Install 13 Packages
Upgrade 501 Packages

Total download size: 840 M
Downloading Packages:
Cannot create temporary file - mkstemp '/sound/librepo-tmp-Hzxjb7': No such file or directory

mapfile -t rpm_rpms < <(rpm -qa | grep -e dnf -e yum -e rpm )
: > ~/files
for r in "${rpm_rpms[@]}"; do unset foo; mapfile -t foo < <(rpm -ql "$r"); file -pk "${foo[@]}" >> ~/files; done
mapfile -t gfs < <( awk -F':' ' { print $1 }' ~/files )
grep -- mkstemp "${gfs[@]}" 2> /dev/null

/usr/lib/python3.11/site-packages/dnf/conf/config.py: temp_fd, temp_path = tempfile.mkstemp(prefix='dnf-downloaded-config-')

git clone https://github.com/rpm-software-management/dnf
cd ./dnf; ls
grep -rn mkstemp .

./dnf/conf/config.py:288: temp_fd, temp_path = tempfile.mkstemp(prefix='dnf-downloaded-config-')

find / -type f -path '*/dnf/conf/*' -name '*config.py*' 2> /dev/null

/home/liveuser/OTHERSPROJECTS/dnf/dnf/conf/config.py
/usr/lib/python3.11/site-packages/dnf/conf/config.py

unset TMPDIR r rpms_rpms gfs
cd ..; rm -fr ./dnf

@mcurlej mcurlej added the Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take label Jul 10, 2023
@jan-kolarik
Copy link
Member

Hello, I think the mentioned issue is not coming from the dnf component, but rather from librepo.

There is the TMPDIR constant in dnf, but given message Cannot create temporary file - mkstemp '/sound/librepo-tmp-EZSao0': No such file or directory is coming from librepo when the file is being downloaded into temporary location with the lr_gettmpfile function here. It doesn't use the TMPDIR constant from DNF, but the directory is taken from global environment variable when using GLib call g_get_tmp_dir, see here.

So the handling of the situation is done in GLib, the only thing of improving the situation from the user POV I can think of now is like checking the TMPDIR by ourselves in librepo and reseting it in case of non-existence, but I don't feel it is a good way as the GLib implementation could change...

@jan-kolarik jan-kolarik self-assigned this Jul 14, 2023
@wileyhy
Copy link
Author

wileyhy commented Jul 19, 2023

Hey, Well, I'm still a bit of a newbie with such questions, so... To me it seems like, since '/tmp' is hard-coded a value of last resort, that providing the name of some known-as-existing directory is probably intended, because /tmp is so conventionally ubiquitous (right? ...it seems to be...). However, it is a temporary directory we're talking about here, so it also seems like there should be at least some expectation that the value of TMPDIR might have already bit the bucket by the time g_get_tmp_dir looks for a parameter value. idk

@jan-kolarik jan-kolarik transferred this issue from rpm-software-management/dnf Jul 31, 2023
@jan-kolarik jan-kolarik removed their assignment Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Projects
Status: Backlog
Development

No branches or pull requests

3 participants