mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
networkd-test: set right access modes for /run/systemd/netif
Otherwise networkd isn't happy. Let's also make addition of the "systemd-network" non-fatal. The user exists on many machines anyway, hence it shouldn't fail if it already exists.
This commit is contained in:
parent
83da42c3bf
commit
ff7507295d
|
@ -53,6 +53,7 @@ def setUpModule():
|
||||||
if (subprocess.call(['systemctl', 'is-active', '--quiet', 'systemd-networkd.service']) == 0 and
|
if (subprocess.call(['systemctl', 'is-active', '--quiet', 'systemd-networkd.service']) == 0 and
|
||||||
subprocess.call(['systemd-detect-virt', '--quiet']) != 0):
|
subprocess.call(['systemd-detect-virt', '--quiet']) != 0):
|
||||||
raise unittest.SkipTest('not virtualized and networkd is already active')
|
raise unittest.SkipTest('not virtualized and networkd is already active')
|
||||||
|
|
||||||
# Ensure we don't mess with an existing networkd config
|
# Ensure we don't mess with an existing networkd config
|
||||||
for u in ['systemd-networkd.socket', 'systemd-networkd', 'systemd-resolved']:
|
for u in ['systemd-networkd.socket', 'systemd-networkd', 'systemd-resolved']:
|
||||||
if subprocess.call(['systemctl', 'is-active', '--quiet', u]) == 0:
|
if subprocess.call(['systemctl', 'is-active', '--quiet', u]) == 0:
|
||||||
|
@ -60,6 +61,12 @@ def setUpModule():
|
||||||
running_units.append(u)
|
running_units.append(u)
|
||||||
else:
|
else:
|
||||||
stopped_units.append(u)
|
stopped_units.append(u)
|
||||||
|
|
||||||
|
# create static systemd-network user for networkd-test-router.service (it
|
||||||
|
# needs to do some stuff as root and can't start as user; but networkd
|
||||||
|
# still insists on the user)
|
||||||
|
subprocess.call(['adduser', '--system', '--no-create-home', 'systemd-network'])
|
||||||
|
|
||||||
for d in ['/etc/systemd/network', '/run/systemd/network',
|
for d in ['/etc/systemd/network', '/run/systemd/network',
|
||||||
'/run/systemd/netif', '/run/systemd/resolve']:
|
'/run/systemd/netif', '/run/systemd/resolve']:
|
||||||
if os.path.isdir(d):
|
if os.path.isdir(d):
|
||||||
|
@ -68,6 +75,9 @@ def setUpModule():
|
||||||
if os.path.isdir('/run/systemd/resolve'):
|
if os.path.isdir('/run/systemd/resolve'):
|
||||||
os.chmod('/run/systemd/resolve', 0o755)
|
os.chmod('/run/systemd/resolve', 0o755)
|
||||||
shutil.chown('/run/systemd/resolve', 'systemd-resolve', 'systemd-resolve')
|
shutil.chown('/run/systemd/resolve', 'systemd-resolve', 'systemd-resolve')
|
||||||
|
if os.path.isdir('/run/systemd/netif'):
|
||||||
|
os.chmod('/run/systemd/netif', 0o755)
|
||||||
|
shutil.chown('/run/systemd/netif', 'systemd-network', 'systemd-network')
|
||||||
|
|
||||||
# Avoid "Failed to open /dev/tty" errors in containers.
|
# Avoid "Failed to open /dev/tty" errors in containers.
|
||||||
os.environ['SYSTEMD_LOG_TARGET'] = 'journal'
|
os.environ['SYSTEMD_LOG_TARGET'] = 'journal'
|
||||||
|
@ -75,11 +85,6 @@ def setUpModule():
|
||||||
# Ensure the unit directory exists so tests can dump files into it.
|
# Ensure the unit directory exists so tests can dump files into it.
|
||||||
os.makedirs(NETWORK_UNITDIR, exist_ok=True)
|
os.makedirs(NETWORK_UNITDIR, exist_ok=True)
|
||||||
|
|
||||||
# create static systemd-network user for networkd-test-router.service (it
|
|
||||||
# needs to do some stuff as root and can't start as user; but networkd
|
|
||||||
# still insists on the user)
|
|
||||||
subprocess.check_call(['adduser', '--system', '--no-create-home', 'systemd-network'])
|
|
||||||
|
|
||||||
|
|
||||||
def tearDownModule():
|
def tearDownModule():
|
||||||
global tmpmounts
|
global tmpmounts
|
||||||
|
|
Loading…
Reference in a new issue