Skip to content

Commit 9eb8d00

Browse files
utils: set_service_user skip on read only filesystem
In image mode the sevice file is not editable so we skip tests that are not applicable.
1 parent 875b35b commit 9eb8d00

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sssd_test_framework/utils/sssd.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from io import StringIO
77
from typing import TYPE_CHECKING, Literal
88

9+
import pytest
910
from pytest_mh import MultihostHost, MultihostRole, MultihostUtility
1011
from pytest_mh.conn import Process, ProcessLogLevel, ProcessResult
1112

@@ -358,6 +359,11 @@ def set_service_user(self, user: str) -> None:
358359
return # requested service user matches default, nothing to do
359360

360361
service_file = "/usr/lib/systemd/system/sssd.service"
362+
rw = self.host.conn.run(f"test -w {service_file}", raise_on_error=False)
363+
if rw.rc != 0:
364+
# Can't change service user on read only filesystem
365+
pytest.skip(f"Cannot write {service_file}")
366+
361367
self.fs.backup(service_file)
362368
cmd = f'sed -i "s/^User=.*/User={user}/g" {service_file}\n'
363369
cmd += f'sed -i "s/^Group=.*/Group={user}/g" {service_file}\n'

0 commit comments

Comments
 (0)