diff --git a/wcfs/__init__.py b/wcfs/__init__.py index 180471323559691c558ca7603fce37f97d3121f6..2f5f033a3f5f81c2c49328b80bbda70231d1f20e 100644 --- a/wcfs/__init__.py +++ b/wcfs/__init__.py @@ -295,10 +295,20 @@ def _wcfs_exe(): def _mntpt_4zurl(zurl): m = hashlib.sha1() m.update(zurl) + # mkdir /tmp/wcfs with stiky bit. This way multiple users can create subdirectories inside. wcfsroot = "%s/wcfs" % (tempfile.gettempdir()) + wcfsmode = 0777 | stat.S_ISVTX if _mkdir_p(wcfsroot): - os.chmod(wcfsroot, 0777 | stat.S_ISVTX) + os.chmod(wcfsroot, wcfsmode) + else: + # migration workaround for the situation when /tmp/wcfs was created by + # code that did not yet set sticky bit. + _ = os.stat(wcfsroot) + if _.st_uid == os.getuid(): + if _.st_mode != wcfsmode: + os.chmod(wcfsroot, wcfsmode) + mntpt = "%s/%s" % (wcfsroot, m.hexdigest()) _mkdir_p(mntpt) return mntpt