Rev1818, Set user-only permissions on directories instead of files
This commit is contained in:
parent
0a3a71f634
commit
8c9457d636
3 changed files with 11 additions and 5 deletions
|
@ -9,7 +9,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.5.1"
|
||||
self.rev = 1817
|
||||
self.rev = 1818
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.config_file = "zeronet.conf"
|
||||
|
|
12
src/main.py
12
src/main.py
|
@ -30,14 +30,22 @@ if not config.arguments: # Config parse failed, show the help screen and exit
|
|||
# Create necessary files and dirs
|
||||
if not os.path.isdir(config.log_dir):
|
||||
os.mkdir(config.log_dir)
|
||||
try:
|
||||
os.chmod(config.log_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
except Exception, err:
|
||||
print "Can't change permission of %s: %s" % (config.log_dir, err)
|
||||
|
||||
if not os.path.isdir(config.data_dir):
|
||||
os.mkdir(config.data_dir)
|
||||
try:
|
||||
os.chmod(config.data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
except Exception, err:
|
||||
print "Can't change permission of %s: %s" % (config.data_dir, err)
|
||||
|
||||
if not os.path.isfile("%s/sites.json" % config.data_dir):
|
||||
open("%s/sites.json" % config.data_dir, "w").write("{}")
|
||||
os.chmod("%s/sites.json" % config.data_dir, stat.S_IRUSR | stat.S_IWUSR)
|
||||
if not os.path.isfile("%s/users.json" % config.data_dir):
|
||||
open("%s/users.json" % config.data_dir, "w").write("{}")
|
||||
os.chmod("%s/users.json" % config.data_dir, stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
# Setup logging
|
||||
if config.action == "main":
|
||||
|
|
|
@ -14,7 +14,6 @@ from Config import config
|
|||
|
||||
def atomicWrite(dest, content, mode="w"):
|
||||
try:
|
||||
permissions = stat.S_IMODE(os.lstat(dest).st_mode)
|
||||
with open(dest + "-tmpnew", mode) as f:
|
||||
f.write(content)
|
||||
f.flush()
|
||||
|
@ -23,7 +22,6 @@ def atomicWrite(dest, content, mode="w"):
|
|||
os.rename(dest + "-tmpold", dest + "-tmpold-%s" % time.time())
|
||||
os.rename(dest, dest + "-tmpold")
|
||||
os.rename(dest + "-tmpnew", dest)
|
||||
os.chmod(dest, permissions)
|
||||
os.unlink(dest + "-tmpold")
|
||||
return True
|
||||
except Exception, err:
|
||||
|
|
Loading…
Reference in a new issue