Skip to content

Commit

Permalink
systemd configs: add CAP_DAC_OVERRIDE in case certain case
Browse files Browse the repository at this point in the history
If sssd is configured with --with-sssd-user=<user> where <user>!='root'
but is actually run under the root we need CAP_DAC_OVERRIDE to access
files owned by <user>:<user>
If sssd is really run under non-root account that doesn't have this cap
originally then it's addition to CapabilityBoundingSet doesn't matter.

Reviewed-by: Sumit Bose <[email protected]>
  • Loading branch information
alexey-tikhonov authored and pbrezina committed Feb 19, 2021
1 parent ee9dbea commit fd7ce7b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ condconfigexists =
else
condconfigexists = ConditionPathExists=\|/etc/sssd/sssd.conf\nConditionDirectoryNotEmpty=\|/etc/sssd/conf.d/
endif
# If sssd is configured with --with-sssd-user=<user> where <user>!='root'
# but is actually run under the root we need CAP_DAC_OVERRIDE to access
# files owned by <user>:<user>
# If sssd is really run under non-root account that doesn't have this cap
# originally then it's addition to CapabilityBoundingSet doesn't matter.
if SSSD_NON_ROOT_USER
additional_caps = CAP_DAC_OVERRIDE
endif
else
ifp_exec_cmd = $(sssdlibexecdir)/sss_signal
ifp_systemdservice =
Expand Down Expand Up @@ -5123,7 +5131,8 @@ edit_cmd = $(SED) \
-e 's|@pipepath[@]|$(pipepath)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e 's|@SSSD_USER[@]|$(SSSD_USER)|g' \
-e 's|@condconfigexists[@]|$(condconfigexists)|g'
-e 's|@condconfigexists[@]|$(condconfigexists)|g' \
-e 's|@additional_caps[@]|$(additional_caps)|g'

replace_script = \
@rm -f $@ $@.tmp; \
Expand Down
1 change: 1 addition & 0 deletions src/conf_macros.m4
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ AC_DEFUN([WITH_SSSD_USER],
AC_SUBST(SSSD_USER)
AC_DEFINE_UNQUOTED(SSSD_USER, "$SSSD_USER", ["The default user to run SSSD as"])
AM_CONDITIONAL([SSSD_USER], [test x"$with_sssd_user" != x])
AM_CONDITIONAL([SSSD_NON_ROOT_USER], [test x"$SSSD_USER" != xroot])
])

AC_DEFUN([WITH_AD_GPO_DEFAULT],
Expand Down
2 changes: 1 addition & 1 deletion src/sysv/systemd/sssd-kcm.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Also=sssd-kcm.socket
Environment=DEBUG_LOGGER=--logger=files
ExecStartPre=-@sbindir@/sssd --genconf-section=kcm
ExecStart=@libexecdir@/sssd/sssd_kcm --uid 0 --gid 0 ${DEBUG_LOGGER}
CapabilityBoundingSet=CAP_IPC_LOCK CAP_CHOWN CAP_DAC_READ_SEARCH CAP_FOWNER CAP_SETGID CAP_SETUID
CapabilityBoundingSet= @additional_caps@ CAP_IPC_LOCK CAP_CHOWN CAP_DAC_READ_SEARCH CAP_FOWNER CAP_SETGID CAP_SETUID
2 changes: 1 addition & 1 deletion src/sysv/systemd/sssd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ExecStart=@sbindir@/sssd -i ${DEBUG_LOGGER}
Type=notify
NotifyAccess=main
PIDFile=@pidpath@/sssd.pid
CapabilityBoundingSet=CAP_IPC_LOCK CAP_CHOWN CAP_DAC_READ_SEARCH CAP_KILL CAP_NET_ADMIN CAP_SYS_NICE CAP_FOWNER CAP_SETGID CAP_SETUID CAP_SYS_ADMIN CAP_SYS_RESOURCE CAP_BLOCK_SUSPEND
CapabilityBoundingSet= @additional_caps@ CAP_IPC_LOCK CAP_CHOWN CAP_DAC_READ_SEARCH CAP_KILL CAP_NET_ADMIN CAP_SYS_NICE CAP_FOWNER CAP_SETGID CAP_SETUID CAP_SYS_ADMIN CAP_SYS_RESOURCE CAP_BLOCK_SUSPEND
Restart=on-failure

[Install]
Expand Down

0 comments on commit fd7ce7b

Please sign in to comment.