RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2019993 - bad error message when user rpm script removes $TMPDIR
Summary: bad error message when user rpm script removes $TMPDIR
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: librepo
Version: 8.3
Hardware: Unspecified
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Jan Kolarik
QA Contact: Eva Mrakova
URL:
Whiteboard:
Depends On:
Blocks: 2121663
TreeView+ depends on / blocked
 
Reported: 2021-11-03 19:26 UTC by John Reiser
Modified: 2023-05-16 11:09 UTC (History)
5 users (show)

Fixed In Version: librepo-1.14.2-4.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 2121663 (view as bug list)
Environment:
Last Closed: 2023-05-16 09:07:04 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-103474 0 None None None 2021-11-21 17:57:31 UTC
Red Hat Product Errata RHBA-2023:2981 0 None None None 2023-05-16 09:07:08 UTC

Description John Reiser 2021-11-03 19:26:41 UTC
Description of problem: In dnf-4.2.23-4.el8.noarch when installing an .rpm, if the rpm script removes $TMPDIR but dnf tries to use that directory later, then dnf fails with a message "Cannot create temporary file - mkstemp: No such file or directory".  This message is bad because it omits the actual attempted pathname, and because the word "mkstemp" is confusing to the end user.

Because the pathname is missing, then the end user gets very little clue about what might be wrong.  Instead: it is much more helpful to specify the actual troublesome path, and its association with the shell environment variable TMPDIR.  Because the word "mkstemp" is used, then the user easily can be misled about a missing /usr/bin/mkstemp which cannot be found because it does not exist.  "mkstemp" is the name of a subroutine that dnf uses internally, and is a detail that should be hidden from the user.

To be most helpful, then the message should be something like: "Cannot create temporary file using TMPDIR: <<actual_pathname>>"

Version-Release number of selected component (if applicable):
dnf-4.2.23-4.el8.noarch

How reproducible: every time


Steps to Reproduce:
1.  export TMPDIR=$(mktemp -d /tmp/foo.XXXXX)
2.  dnf install an .rpm whose install script contains "rm -rf $TMPDIR".
3.

Actual results: dnf exits with failure and message:
"Cannot create temporary file - mkstemp: No such file or directory"


Expected results: dnf exits with failure and message
"Cannot create temporary file using TMPDIR: /tmp/foo.A1B2C/temp.VWXYZ" where "A1B2C" is the actual substituted value for "XXXXX" at step 1, and "VWXYZ" is the actual value that was substituted for "XXXXX" in a call to subroutine mkstemp().


Additional info: The manual page documentation does not mention that dnf uses environment variable TMPDIR.

Comment 1 Jaroslav Mracek 2021-11-24 11:53:21 UTC
I believe that DNF is not formatting a scriplet's error. May be RPM team will know little bit more.

Comment 2 Panu Matilainen 2021-11-24 12:24:08 UTC
Is that the literal error message? I dunno about dnf and it's libraries, but there's no such message in rpm:

> [pmatilai🎩︎localhost rpm]$ find -name "*.c"|xargs grep "Cannot create"
> [pmatilai🎩︎localhost rpm]$

Comment 3 John Reiser 2021-11-24 15:05:09 UTC
(In reply to Panu Matilainen from comment #2)
> Is that the literal error message?

Yes, the literal error message in its entirety is:
    Cannot create temporary file - mkstemp: No such file or directory
as given in the Actual results section in the original report above.

>  I dunno about dnf and it's libraries, but
> there's no such message in rpm:

Perhaps the message is from Python?
    $ grep 'Cannot create'  $(rpm -ql $(rpm -qa | grep py)) 2>/dev/null  # no matches

    $ grep 'temporary file' $(rpm -ql $(rpm -qa | grep py)) 2>/dev/null  # interesting, including:
/usr/lib64/python3.9/tempfile.py:creating temporary files and directories.  All of the interfaces
/usr/lib64/python3.9/tempfile.py:             another candidate location to store temporary files.
/usr/lib64/python3.9/tempfile.py:    """Calculate the default directory to use for temporary files.
/usr/lib64/python3.9/tempfile.py:                          "No usable temporary file name found")
/usr/lib64/python3.9/tempfile.py:    """User-callable function to return a unique temporary file name.  The
/usr/lib64/python3.9/tempfile.py:                          "No usable temporary filename found")
/usr/lib64/python3.9/tempfile.py:    """A separate object allowing proper closing of a temporary file's
/usr/lib64/python3.9/tempfile.py:    temporary file."""
/usr/lib64/python3.9/tempfile.py:        Close the temporary file, possibly deleting it.
/usr/lib64/python3.9/tempfile.py:    """Create and return a temporary file.
/usr/lib64/python3.9/tempfile.py:        """Create and return a temporary file.

Comment 4 Panu Matilainen 2021-11-25 09:55:28 UTC
> Yes, the literal error message in its entirety is:
>    Cannot create temporary file - mkstemp: No such file or directory
> as given in the Actual results section in the original report above.

Ack, thanks for confirming. I thought the message was indeed literal because it was repeated twice as such, but had to make sure due to the nature of this bug (it's not rare for people to describe stuff from memory, with inevitable differences to actual messages). We can't fix in rpm what doesn't come from rpm.

Comment 5 Jaroslav Mracek 2021-11-26 08:52:31 UTC
My apologies for redirection the issue to RPM. I overlooked that the message is generated librepo util.c


```
int
lr_gettmpfile(void)
{
    int fd;
    _cleanup_free_ char *template = NULL;
    template = g_build_filename(g_get_tmp_dir(), "librepo-tmp-XXXXXX", NULL);
    fd = mkstemp(template);
    if (fd < 0) {
        perror("Cannot create temporary file - mkstemp");
        exit(1);
    }
    unlink(template);
    return fd;
}
```
It looks like that the variable TMPDIR is used by g_lib. I propose to modify message to include the path from template "Cannot create temporary file - mkstemp '/tmy/...'"

Then the final message will be something like "Cannot create temporary file - mkstemp '<path>': No such file or directory".

Anyway the issue has low priority, therefore community can help - link to repository and the file - https://github.com/rpm-software-management/librepo/blob/3b9a8d17188ba602d139f79b6e61305030f21109/librepo/util.c#L158

Comment 7 Jaroslav Mracek 2022-07-19 10:56:20 UTC
We consider the bug as a valid but because the issue has limited impact (low priority) we postpone the issue in favor of other issues.

Comment 8 Jan Kolarik 2022-08-22 06:30:22 UTC
Showing more detailed error message was implemented.

Following PRs were queued related to this fix:

fix:   https://github.com/rpm-software-management/librepo/pull/262
tests: https://github.com/rpm-software-management/ci-dnf-stack/pull/1148

Comment 9 Jan Kolarik 2022-08-26 07:07:05 UTC
Cloned into RHEL 9 ticket https://bugzilla.redhat.com/show_bug.cgi?id=2121663.

Comment 15 errata-xmlrpc 2023-05-16 09:07:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (librepo bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2981


Note You need to log in before you can comment on or make changes to this bug.