Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-transfer-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-transfer-service
Commits
c60d6ee5
Commit
c60d6ee5
authored
2 years ago
by
Cristiano Urban
Browse files
Options
Downloads
Patches
Plain Diff
Get user UID and GID from transfer node user folder.
Signed-off-by:
Cristiano Urban
<
cristiano.urban@inaf.it
>
parent
c1c35b2d
No related branches found
No related tags found
No related merge requests found
Pipeline
#13683
passed
2 years ago
Stage: dockerize
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
transfer_service/data_rpc_server.py
+4
-4
4 additions, 4 deletions
transfer_service/data_rpc_server.py
transfer_service/system_utils.py
+13
-7
13 additions, 7 deletions
transfer_service/system_utils.py
with
17 additions
and
11 deletions
transfer_service/data_rpc_server.py
+
4
−
4
View file @
c60d6ee5
...
...
@@ -169,10 +169,10 @@ class DataRPCServer(RedisRPCServer):
"
errorCode
"
:
2
,
"
errorMsg
"
:
errorMsg
}
return
response
uid
=
os
.
stat
(
folderPath
).
st_uid
gid
=
os
.
stat
(
folderPath
).
st_gid
#
Check if uid and gid match and a
void privilege escalation
if
uid
==
userInfo
[
1
]
and
gid
==
userInfo
[
2
]
and
uid
>=
1000
and
gid
>=
100
:
uid
=
userInfo
[
1
]
gid
=
userInfo
[
2
]
#
A
void privilege escalation
if
uid
>=
1000
and
gid
>=
100
:
# If write permissions are set and the 'store' folder is not empty,
# it means that data is ready to be copied, otherwise, nothing can
# be done until the write permissions are restored or new data is
...
...
This diff is collapsed.
Click to expand it.
transfer_service/system_utils.py
+
13
−
7
View file @
c60d6ee5
...
...
@@ -6,11 +6,12 @@
#
import
os
import
pwd
import
re
import
shutil
import
sys
from
config
import
Config
class
SystemUtils
(
object
):
...
...
@@ -24,19 +25,24 @@ class SystemUtils(object):
}
def
__init__
(
self
):
pass
config
=
Config
(
"
/etc/vos_ts/vos_ts.conf
"
)
params
=
config
.
loadSection
(
"
transfer_node
"
)
self
.
vospaceUserBasePath
=
params
[
"
base_path
"
]
def
userInfo
(
self
,
username
):
"""
Retur
ns username, UID and GID associated to a given user
,
using the Python password database module (pwd)
.
Obtai
ns username, UID and GID associated to a given user
from the user directory (name.surname) on the transfer node
.
"""
try
:
info
=
pwd
.
getpwnam
(
username
)
except
KeyError
:
vospaceUserFolderPath
=
self
.
vospaceUserBasePath
.
replace
(
"
{username}
"
,
username
)
uid
=
os
.
stat
(
vospaceUserFolderPath
).
st_uid
gid
=
os
.
stat
(
vospaceUserFolderPath
).
st_gid
except
OSError
:
return
False
else
:
return
[
info
[
0
],
info
[
2
],
info
[
3
]
]
return
[
username
,
uid
,
gid
]
def
findIllegalCharacters
(
self
,
name
):
"""
Checks for file/dir names containing illegal characters.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment