If logrotate is run in debug mode (-d) it leaves temp files in /tmp. This happens in rotateLogSet: mkstemp is used to create the file but it's unlinked only if the debug is not set (see the if statement on line 639).
mkstemp is only called from runScript. runScript has the following snippet near the top: if (debug) { message(MESS_DEBUG, "running script with arg %s: \"%s\"\n", logfn, script); return 0; } Then two lines down: strcpy(filespec, "/tmp/logrotate.XXXXXX"); if ((fd = mkstemp(filespec)) < 0 || fchmod(fd, 0700)) { So mkstemp isn't even called when you are in debug mode. Are you sure about this bug? I don't see how it is possible.
Perhaps we're looking at different logrotate versions (3.5.4), but on logrotate.c:int rotateLogSet if (log->errAddress) { message(MESS_DEBUG, "errors will be mailed to %s\n", log->errAddress); strcpy(errorFileName, "/tmp/logrotate.XXXXXX"); if ((newerr = mkstemp(errorFileName)) < 0) { message(MESS_ERROR, "error creating temporary file %s\n", errorFileName); ... if (log->errAddress && !debug) { ... unlink(errorFileName); ^^^^^^ unlink is called if !debug, perhaps it is intentional ?
Newer versions have dropped this segment of code.