diff -Naur talloc-2.1.14/lib/replace/wscript talloc-2.1.14-mkstempfix/lib/replace/wscript --- talloc-2.1.14/lib/replace/wscript 2018-07-12 05:51:30.000000000 +0000 +++ talloc-2.1.14-mkstempfix/lib/replace/wscript 2018-07-16 17:53:44.853417533 +0000 @@ -680,16 +680,28 @@ exit(1); } if (fd2 == -1) exit(1); - unlink(tpl); - unlink(tpl2); - if (fstat(fd, &st) != 0) exit(1); - if ((st.st_mode & 0777) != 0600) exit(1); + if (fstat(fd, &st) != 0) { + unlink(tpl); + unlink(tpl2); + exit(1); + } + if ((st.st_mode & 0777) != 0600) { + unlink(tpl); + unlink(tpl2); + exit(1); + } if (strcmp(tpl, "/tmp/test.XXXXXX") == 0) { + unlink(tpl); + unlink(tpl2); exit(1); } if (strcmp(tpl, tpl2) == 0) { + unlink(tpl); + unlink(tpl2); exit(1); } + unlink(tpl); + unlink(tpl2); exit(0); ''', define='HAVE_SECURE_MKSTEMP',