rpm-software-management / librepo

A library providing C and Python (libcURL like) API for downloading packages and linux repository metadata in rpm-md format
http://rpm-software-management.github.io/librepo/
GNU Lesser General Public License v2.1
74 stars 90 forks source link

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

Open wileyhy opened 1 year ago

wileyhy commented 1 year ago

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

jan-kolarik commented 1 year ago

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...

wileyhy commented 1 year ago

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