Skip to content

Commit

Permalink
SSSDConfig: chown() sssd.conf to SSSD service user
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-tikhonov committed Feb 26, 2024
1 parent 4e90bb0 commit a4bf7ab
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config/SSSDConfig/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Created on Sep 18, 2009

import os
import re
import shutil
import subprocess
import sys
from contextlib import suppress
from .sssdoptions import SSSDOptions
from .ipachangeconf import SSSDChangeConf

Expand Down Expand Up @@ -1063,6 +1066,14 @@ class SSSDConfig(SSSDChangeConf):
output = self.dump(self.opts)
of.write(output)
os.umask(old_umask)
service_user = ""
ret = subprocess.run(["systemctl", "show", "sssd", "--value", "--property", "User"], capture_output=True, text=True)
if ret.returncode == 0:
service_user = ret.stdout.strip()
if service_user == "":
service_user = "root"
with suppress(PermissionError):
shutil.chown(outputfile, service_user, service_user)

def list_active_services(self):
"""
Expand Down

0 comments on commit a4bf7ab

Please sign in to comment.