Received: by taz.hyperreal.com (8.8.3/V2.0) id XAA06335; Sat, 4 Jan 1997 23:46:09 -0800 (PST) Received: from scanner.worldgate.com by taz.hyperreal.com (8.8.3/V2.0) with ESMTP id XAA06331; Sat, 4 Jan 1997 23:46:05 -0800 (PST) Received: from znep.com (uucp@localhost) by scanner.worldgate.com (8.7.5/8.7.3) with UUCP id AAA29815 for new-httpd@hyperreal.com; Sun, 5 Jan 1997 00:46:02 -0700 (MST) Received: from localhost (marcs@localhost) by alive.ampr.ab.ca (8.7.5/8.7.3) with SMTP id AAA23227 for ; Sun, 5 Jan 1997 00:45:58 -0700 (MST) Date: Sun, 5 Jan 1997 00:45:57 -0700 (MST) From: Marc Slemko X-Sender: marcs@alive.ampr.ab.ca To: new-httpd@hyperreal.com Subject: symlinks and logfiles Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com 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 rmdir("logs/foo"); 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.