httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <>
Subject symlinks and logfiles
Date Sun, 05 Jan 1997 07:45:57 GMT
I think the following should be a safe way of opening logfiles.  Since
we have no way to do a check and open atomically, we need to make sure
that no one else can play with the file between the check and open.
This can be accomplished by creating a mode 600 directory and
temporarily moving the logfile into there.

In mixed-pseudocode:
	if (mkdir("logs/foo")) whine;
	chmod logs/foo 600
	-f logs/logfile && mv logs/logfile logs/foo/logfile
	# check logs/foo/logfile to see if it is a link, etc.
	fd = open("logs/foo/logfile", ...)
	mv logs/foo/logfile logs/logfile

Now the only race condition (I think) is if someone tries reading the
logfile before it is moved back, it will fail but that shouldn't be a
huge deal.  

It is ugly though and I'm not sure it is worth implementing.

View raw message