Hi,

I've attached a patch to make atop create decompressed raw logs
safely by using mkstemp.

I think that it's still possible, by making /tmp/atop.d a symbolic
link to a directory containing a file named atop.acct, to make atop
remove the file named atop.acct in the linked-to directory.

-- 
Matt Kraai
https://ftbfs.org/kraai
--- atop-1.23~/rawlog.c	2011-04-14 20:52:34.000000000 -0700
+++ atop-1.23/rawlog.c	2011-04-14 20:59:55.000000000 -0700
@@ -477,18 +477,18 @@
 		*/
 		fprintf(stderr, "Decompressing logfile ....\n");
 
-		snprintf(tmpname2, sizeof tmpname2, "/tmp/atopwrk%d", getpid());
-		snprintf(command,  sizeof command, "gunzip -c %s > %s",
-							tmpname1, tmpname2);
-		system (command);
+		snprintf(tmpname2, sizeof tmpname2, "/tmp/atopwrkXXXXXX");
 
-		if ( (rawfd = open(tmpname2, O_RDONLY)) == -1)
+		if ( (rawfd = mkstemp(tmpname2)) == -1)
 		{
 			fprintf(stderr, "%s - ", rawname);
 			perror("open decompressed raw file");
 			cleanstop(7);
 		}
 
+		snprintf(command,  sizeof command, "gunzip -c %s > %s",
+							tmpname1, tmpname2);
+		system (command);
 		unlink(tmpname2);
 	}
 

Reply via email to