Commit a7138fef authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs: mkdir /tmp/wcfs with sticky bit

So that multiple users can create things inside.
parent 4d162b2c
...@@ -63,7 +63,7 @@ The following environment variables can be used to control wcfs.py client: ...@@ -63,7 +63,7 @@ The following environment variables can be used to control wcfs.py client:
from __future__ import print_function, absolute_import from __future__ import print_function, absolute_import
import os, sys, hashlib, tempfile, subprocess, time import os, sys, hashlib, tempfile, subprocess, time, stat
import logging as log import logging as log
from os.path import dirname from os.path import dirname
from errno import ENOENT, EEXIST from errno import ENOENT, EEXIST
...@@ -295,18 +295,24 @@ def _wcfs_exe(): ...@@ -295,18 +295,24 @@ def _wcfs_exe():
def _mntpt_4zurl(zurl): def _mntpt_4zurl(zurl):
m = hashlib.sha1() m = hashlib.sha1()
m.update(zurl) m.update(zurl)
mntpt = "%s/wcfs/%s" % (tempfile.gettempdir(), m.hexdigest()) # mkdir /tmp/wcfs with stiky bit. This way multiple users can create subdirectories inside.
wcfsroot = "%s/wcfs" % (tempfile.gettempdir())
if _mkdir_p(wcfsroot):
os.chmod(wcfsroot, 0777 | stat.S_ISVTX)
mntpt = "%s/%s" % (wcfsroot, m.hexdigest())
_mkdir_p(mntpt) _mkdir_p(mntpt)
return mntpt return mntpt
# mkdir -p. # mkdir -p.
def _mkdir_p(path): def _mkdir_p(path, mode=0777): # -> created(bool)
try: try:
os.makedirs(path) os.makedirs(path, mode)
except OSError as e: except OSError as e:
if e.errno != EEXIST: if e.errno != EEXIST:
raise raise
return False
return True
# serve starts and runs wcfs server for ZODB @ zurl. # serve starts and runs wcfs server for ZODB @ zurl.
......
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