Skip to content

Support non-final XXXXXX in mktemp templates

Andrej Shadura requested to merge non-final-xxxxxx into apertis/v2021dev3
  • Add a private implementation of mk{s,d}temp. The glibc version doesn’t support non-final XXXXXX. When the glibc functions are called with XXXXXX not being in the final position, they return EINVAL. Since we cannot easily amend the behaviour of the glibc functions, we need to bring back the Todd C. Miller’s reimplementation of them.

  • Make sure non-final XXXXXX are also replaced with random symbols. Our tests rely on the behaviour of mktemp neither mkstemp/mkdtemp glibc functions nor the original mktemp implementation by Todd C. Miller supported. mktemp from coreutils allows XXXXXX to be anywhere in the file name as long as there are more than 3 of Xs. Todd C. Miller’s mktemp we use in GPL-3-free coreutils silently ignores them creating files with literal Xs, while glibc functions return EINVAL.

    To prevent file name collisions due to mktemp not using any random symbols at all, we need to replicate the behaviour of coreutils mktemp and allow XXXXXX to be in non-final position as well.

    An important difference is that this change doesn’t prevent less than 3 Xs to be used.

    Fixes Apertis bugs: T7262, T7263.

Edited by Andrej Shadura

Merge request reports