Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
67c189a2
authored
Feb 05, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store-server: Removed f.open
parent
e33cc619
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
miscellaneous/store-server/CloudStore.py
+4
-6
No files found.
miscellaneous/store-server/CloudStore.py
View file @
67c189a2
...
@@ -283,6 +283,7 @@ def upload(hash_num):
...
@@ -283,6 +283,7 @@ def upload(hash_num):
# Check if upload path valid
# Check if upload path valid
if
not
up_path
.
startswith
(
'/home'
):
if
not
up_path
.
startswith
(
'/home'
):
abort
(
400
,
'Invalid path.'
)
abort
(
400
,
'Invalid path.'
)
os
.
remove
(
ROOT_WWW_FOLDER
+
'/'
+
hash_num
)
os
.
remove
(
ROOT_WWW_FOLDER
+
'/'
+
hash_num
)
# Get the real upload path
# Get the real upload path
# Delete the hash link
# Delete the hash link
...
@@ -292,10 +293,6 @@ def upload(hash_num):
...
@@ -292,10 +293,6 @@ def upload(hash_num):
# os.seteuid(getpwnam(username).pw_uid)
# os.seteuid(getpwnam(username).pw_uid)
# 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'
)
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
:
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
):
...
@@ -303,6 +300,8 @@ def upload(hash_num):
...
@@ -303,6 +300,8 @@ def upload(hash_num):
datalength
+=
len
(
chunk
)
datalength
+=
len
(
chunk
)
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'
,
'*'
)
...
@@ -329,10 +328,9 @@ def updateSSHAuthorizedKeys(username, key_list):
...
@@ -329,10 +328,9 @@ def updateSSHAuthorizedKeys(username, key_list):
os
.
mkdir
(
user_home_ssh
,
0700
)
os
.
mkdir
(
user_home_ssh
,
0700
)
os
.
chown
(
user_home_ssh
,
user_uid
,
user_gid
)
os
.
chown
(
user_home_ssh
,
user_uid
,
user_gid
)
auth_file_name
=
user_home_ssh
+
'/authorized_keys'
auth_file_name
=
user_home_ssh
+
'/authorized_keys'
auth_file
=
open
(
auth_file_name
,
'w'
)
with
open
(
auth_file_name
,
'w'
)
as
auth_file
:
for
key
in
key_list
:
for
key
in
key_list
:
auth_file
.
write
(
key
+
'
\n
'
)
auth_file
.
write
(
key
+
'
\n
'
)
auth_file
.
close
()
os
.
chmod
(
auth_file_name
,
0600
)
os
.
chmod
(
auth_file_name
,
0600
)
os
.
chown
(
auth_file_name
,
user_uid
,
user_gid
)
os
.
chown
(
auth_file_name
,
user_uid
,
user_gid
)
return
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment