Skip to content

Commit dd80dd2

Browse files
authored
Merge pull request #389 from SUSE/bsc1250078
bind mount only required subdirectories under /run into chroot
2 parents 9d831d4 + a2ec6cf commit dd80dd2

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

suse_migration_services/units/mount_system.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,20 @@ def mount_system(root_path, fstab):
179179
system_mount.add_entry(
180180
mount_type, mount_point
181181
)
182-
log.info('Bind mount /run inside chroot {0}'.format(root_path))
182+
log.info('Bind mount subdirectories from /run inside chroot {0}'.format(root_path))
183+
os.makedirs(os.sep.join([root_path, 'run', 'NetworkManager']), exist_ok=True)
183184
Command.run(
184-
['mount', '-o', 'bind', '/run', os.sep.join([root_path, 'run'])]
185+
[
186+
'mount', '-o', 'bind', '/run/NetworkManager',
187+
os.sep.join([root_path, 'run', 'NetworkManager'])
188+
]
189+
)
190+
os.makedirs(os.sep.join([root_path, 'run', 'netconfig']), exist_ok=True)
191+
Command.run(
192+
[
193+
'mount', '-o', 'bind', '/run/netconfig',
194+
os.sep.join([root_path, 'run', 'netconfig'])
195+
]
185196
)
186197
except Exception as issue:
187198
log.error(

test/unit/units/mount_system_test.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ def command_calls(command):
105105
@patch('suse_migration_services.units.mount_system.is_mounted')
106106
@patch('os.path.isfile')
107107
@patch('os.path.exists')
108+
@patch('os.makedirs')
108109
def test_main(
109-
self, mock_path_exists, mock_path_isfile, mock_is_mounted, mock_Fstab,
110+
self, mock_makedirs, mock_path_exists, mock_path_isfile, mock_is_mounted, mock_Fstab,
110111
mock_path_wipe, mock_Command_run, mock_update_migration_config_file,
111112
mock_get_migration_config_file,
112113
mock_get_system_migration_custom_config_file, mock_yaml_dump,
@@ -203,7 +204,16 @@ def _is_mounted(path):
203204
['mount', '-t', 'sysfs', 'sysfs', '/system-root/sys']
204205
),
205206
call(
206-
['mount', '-o', 'bind', '/run', '/system-root/run']
207+
[
208+
'mount', '-o', 'bind', '/run/NetworkManager',
209+
'/system-root/run/NetworkManager'
210+
]
211+
),
212+
call(
213+
[
214+
'mount', '-o', 'bind', '/run/netconfig',
215+
'/system-root/run/netconfig'
216+
]
207217
)
208218
]
209219
assert fstab_mock.add_entry.call_args_list == [
@@ -253,6 +263,10 @@ def _is_mounted(path):
253263
'sysfs', '/system-root/sys'
254264
)
255265
]
266+
assert mock_makedirs.call_args_list == [
267+
call('/system-root/run/NetworkManager', exist_ok=True),
268+
call('/system-root/run/netconfig', exist_ok=True)
269+
]
256270
fstab_mock.export.assert_called_once_with(
257271
'/etc/system-root.fstab'
258272
)

0 commit comments

Comments
 (0)