Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
89863d6c
Commit
89863d6c
authored
Apr 02, 2020
by
Łukasz Nowak
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manager: Follow links in devperm
parent
74d4b39e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
+71
-0
slapos/manager/devperm.py
slapos/manager/devperm.py
+8
-0
slapos/tests/test_slapgrid.py
slapos/tests/test_slapgrid.py
+63
-0
No files found.
slapos/manager/devperm.py
View file @
89863d6c
...
...
@@ -73,6 +73,14 @@ class Manager(object):
logger
.
warning
(
"Disk is None: %s "
%
disk_list
,
exc_info
=
True
)
continue
original
=
disk
try
:
while
os
.
path
.
islink
(
disk
):
disk
=
os
.
readlink
(
disk
)
except
OSError
:
logger
.
warning
(
"Problem resolving link: %s "
%
original
,
exc_info
=
True
)
continue
if
not
str
(
disk
).
startswith
(
"/dev/"
):
logger
.
warning
(
"Bad disk definition: %s "
%
disk_list
,
exc_info
=
True
)
continue
...
...
slapos/tests/test_slapgrid.py
View file @
89863d6c
...
...
@@ -3110,6 +3110,20 @@ class TestSlapgridWithDevPerm(MasterMixin, unittest.TestCase):
else:
original(path, uid, gid)
def os_readlink(self, path, original=os.readlink):
if path == 'some_link':
return '/dev/tst'
elif path == 'bad_link':
return '/dev/non'
else:
return original(path)
def os_path_islink(self, path, original=os.path.islink):
if path in ['some_link', 'bad_link']:
return True
else:
return original(path)
def test(self):
with self._mock_requests():
with open(self.disk_device_filename, 'w+') as f:
...
...
@@ -3134,6 +3148,55 @@ class TestSlapgridWithDevPerm(MasterMixin, unittest.TestCase):
]
)
def test_link(self):
with self._mock_requests():
with open(self.disk_device_filename, 'w+') as f:
json.dump([{'disk': 'some_link'}], f)
self.partition.requested_state = 'started'
self.partition.software.setBuildout(WRAPPER_CONTENT)
with
\
patch.object(os.path, 'exists', new=self.os_path_exists),
\
patch.object(os, 'stat', new=self.os_stat),
\
patch.object(os, 'chown', new=self.os_chown),
\
patch.object(os, 'readlink', new=self.os_readlink),
\
patch.object(os.path, 'islink', new=self.os_path_islink):
self.assertEqual(self.grid.processComputerPartitionList(), slapgrid.SLAPGRID_SUCCESS)
gid = grp.getgrnam("
disk
").gr_gid
uid = os.stat(os.environ['HOME']).st_uid
self.assertEqual(
self.os_chown_call_list,
[
['/dev/tst', uid, gid],
['/dev/tst', uid, gid],
]
)
def test_bad_link(self):
with self._mock_requests():
with open(self.disk_device_filename, 'w+') as f:
json.dump([{'disk': 'bad_link'}], f)
self.partition.requested_state = 'started'
self.partition.software.setBuildout(WRAPPER_CONTENT)
with
\
patch.object(os.path, 'exists', new=self.os_path_exists),
\
patch.object(os, 'stat', new=self.os_stat),
\
patch.object(os, 'chown', new=self.os_chown),
\
patch.object(os, 'readlink', new=self.os_readlink),
\
patch.object(os.path, 'islink', new=self.os_path_islink):
self.assertEqual(self.grid.processComputerPartitionList(), slapgrid.SLAPGRID_SUCCESS)
gid = grp.getgrnam("
disk
").gr_gid
uid = os.stat(os.environ['HOME']).st_uid
self.assertEqual(
self.os_chown_call_list,
[]
)
def test_long(self):
with self._mock_requests():
with open(self.disk_device_filename, 'w+') as f:
...
...
Thomas Gambier
🚴🏼
@tomo
mentioned in merge request
!442 (merged)
·
Oct 26, 2022
mentioned in merge request
!442 (merged)
mentioned in merge request !442
Toggle commit list
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