Commit 3cd9fb33 by Őry Máté

store: set permissions before writing uploaded files

parent 800ba190
...@@ -247,13 +247,14 @@ def upload(hash_num): ...@@ -247,13 +247,14 @@ def upload(hash_num):
# TODO setuid subcommand # TODO setuid subcommand
# Check if file exist (root can overwrite anything not safe) # Check if file exist (root can overwrite anything not safe)
f = open(up_path , 'wb') f = open(up_path , 'wb')
os.chown(up_path, getpwnam(username).pw_uid, getpwnam(username).pw_gid)
os.chmod(up_path, 0644)
f.close()
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):
f.write(chunk) f.write(chunk)
datalength += len(chunk) datalength += len(chunk)
f.close()
os.chown(up_path, getpwnam(username).pw_uid, getpwnam(username).pw_gid)
os.chmod(up_path, 0644)
return 'Upload finished: '+file_name+' - '+str(datalength)+' Byte' return 'Upload finished: '+file_name+' - '+str(datalength)+' Byte'
......
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