mktemp, tempfile & coreutils

Matthew Burgess matthew at
Thu Oct 18 08:09:21 PDT 2007

On Wed, 17 Oct 2007 22:56:39 -0400, Bryan Kadzban <bryan at> wrote:

Thanks for the detailed analysis, Bryan (and also to others who confirmed these findings).

> /usr/bin/updatedb: Prints "tempfile failed" if the mktemp call fails.
> (Yes, it has the wrong program name.  Oh well.)

I'll push the trivial patch for this upstream.  Not worth holding back the change for though.

> /usr/sbin/grub-install: Checks whether /bin/tempfile is executable
> *first*, then /bin/mktemp, and uses names based on the script's PID if
> neither is executable.  (I think we should patch this anyway: if nothing
> else, to look in /usr/bin as well as /bin.  But preferably to look for
> mktemp first, as well.)

Agreed.  Note, though, that grub-0.9x is no longer being maintained, so upstream won't accept whatever patch we come up with.

Taking a quick look at the source[0] for 1.9x to see if it requires a similar patch (and therefore if/when we upgrade we'd avoid having the issue bite us again), it appears there's a couple of issues:

1. log_file is set to the result of whatever command & parameters are specified in "$mklog", but "$mklog" is never set
2. log_file isn't used anyway - in 0.9x it was used to log the output/errors resulting from the attempt to create the device map file.  In 1.9x, the redirection of such messages has been removed.

So, it looks like Grub2 could use a patch to correctly set log_file by first correctly setting mklog to call mktemp and then using log_file when attempting to create the device map file.  Or, the code could simply be cleaned up by removing the unused log_file variable and the comment immediately preceeding it.




More information about the lfs-dev mailing list