Support non-final XXXXXX in mktemp templates
-
Add a private implementation of
mk{s,d}temp
. The glibc version doesn’t support non-finalXXXXXX
. When the glibc functions are called withXXXXXX
not being in the final position, they returnEINVAL
. 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
neithermkstemp
/mkdtemp
glibc functions nor the originalmktemp
implementation by Todd C. Miller supported.mktemp
from coreutils allowsXXXXXX
to be anywhere in the file name as long as there are more than 3 ofX
s. Todd C. Miller’smktemp
we use in GPL-3-free coreutils silently ignores them creating files with literalX
s, while glibc functions returnEINVAL
.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 allowXXXXXX
to be in non-final position as well.An important difference is that this change doesn’t prevent less than 3
X
s to be used.