Commit 47c0dcd0 by Guba Sándor

store-server: Added New Folder command proper permissions

parent 39621075
...@@ -165,7 +165,7 @@ def cmd_rename(request, neptun, home_path): ...@@ -165,7 +165,7 @@ def cmd_rename(request, neptun, home_path):
COMMANDS['RENAME'] = cmd_rename COMMANDS['RENAME'] = cmd_rename
# NEW FOLDER # NEW FOLDER
def cmd_new_folder(request, neptun, home_path): def cmd_new_folder(request, username, home_path):
dir_path = home_path+'/'+request.json['PATH'] dir_path = home_path+'/'+request.json['PATH']
dir_path = os.path.realpath(dir_path) dir_path = os.path.realpath(dir_path)
if not dir_path.startswith(home_path): if not dir_path.startswith(home_path):
...@@ -174,6 +174,7 @@ def cmd_new_folder(request, neptun, home_path): ...@@ -174,6 +174,7 @@ def cmd_new_folder(request, neptun, home_path):
abort(400, "Directory already exist!") abort(400, "Directory already exist!")
else: else:
os.mkdir(dir_path, 0755) os.mkdir(dir_path, 0755)
os.chown(dir_path, getpwnam(username).pw_uid, getpwnam(username).pw_gid)
COMMANDS['NEW_FOLDER'] = cmd_new_folder COMMANDS['NEW_FOLDER'] = cmd_new_folder
# REMOVE # REMOVE
...@@ -295,13 +296,13 @@ def upload(hash_num): ...@@ -295,13 +296,13 @@ def upload(hash_num):
# Check if file exist (root can overwrite anything not safe) # Check if file exist (root can overwrite anything not safe)
with open(up_path , 'wb') as f: with open(up_path , 'wb') as f:
datalength = 0 datalength = 0
for chunk in fbuffer(file_data.file): for chunk in fbuffer(file_data.file, chunk_size=1048576):
f.write(chunk) f.write(chunk)
datalength += len(chunk) datalength += len(chunk)
os.chown(up_path, getpwnam(username).pw_uid, getpwnam(username).pw_gid)
os.chmod(up_path, 0644)
try: try:
redirect_address = request.headers.get('Referer') redirect_address = request.headers.get('Referer')
os.chown(up_path, getpwnam(username).pw_uid, getpwnam(username).pw_gid)
os.chmod(up_path, 0644)
except: except:
redirect_address = REDIRECT_URL redirect_address = REDIRECT_URL
response.set_header('Access-Control-Allow-Origin', '*') response.set_header('Access-Control-Allow-Origin', '*')
......
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 sign in to comment