Commit 80ac0af2 authored by Jim Fulton's avatar Jim Fulton

Remove the old cache file when we roll the cache over. This is

to avoid a security problem arising from the way that Zope
changes the effective user id. The first cache file gets created while
Zope is root, so it can't be reopened as nobody.
parent e11512e0
...@@ -144,7 +144,7 @@ file 0 and file 1. ...@@ -144,7 +144,7 @@ file 0 and file 1.
""" """
__version__ = "$Revision: 1.9 $"[11:-2] __version__ = "$Revision: 1.10 $"[11:-2]
import os, tempfile import os, tempfile
from struct import pack, unpack from struct import pack, unpack
...@@ -323,6 +323,13 @@ class ClientCache: ...@@ -323,6 +323,13 @@ class ClientCache:
self._current=current self._current=current
if self._p[current] is not None: if self._p[current] is not None:
# Persistent cache file: # Persistent cache file:
# Note that due to permission madness, waaa,
# we need to remove the old file before
# we open the new one. Waaaaaaaaaa.
if self._f[current] is not None:
close(self._f[current])
try: os.remove(self._p[current])
except: pass
self._f[current]=open(self._p[current],'w+b') self._f[current]=open(self._p[current],'w+b')
else: else:
# Temporary cache file: # Temporary cache file:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment