Skip to content

Commit

Permalink
SSSDUtils: config file ownership should match service user
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-tikhonov committed Feb 5, 2024
1 parent a7cf9bb commit 1b9f911
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sssd_test_framework/utils/sssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import configparser
from io import StringIO
import re
from typing import TYPE_CHECKING, Literal

from pytest_mh import MultihostHost, MultihostRole, MultihostUtility
Expand Down Expand Up @@ -406,7 +407,12 @@ def config_apply(self, check_config: bool = True, debug_level: str | None = "0xf
:type debug_level: str | None, optional
"""
cfg = self.__set_debug_level(debug_level)
service_user = self.config.get("sssd", "user", fallback="root")
if self.fs.exists("/etc/systemd/system/multi-user.target.wants/sssd.service"):
service_file = self.fs.read("/etc/systemd/system/multi-user.target.wants/sssd.service")
if re.search(r"User= *sssd", service_file):
service_user = "sssd"
else:
service_user = "root"
contents = self.__config_dumps(cfg)
self.fs.write("/etc/sssd/sssd.conf", contents, mode="0600", user=service_user, group=service_user)

Expand Down

0 comments on commit 1b9f911

Please sign in to comment.