From f3c47078bba4b89cfce3e35b7a4b0655e6a41262 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Fri, 12 Apr 2024 13:08:59 +0200 Subject: [PATCH] dist: set capabilities during make install Resolves: https://github.com/SSSD/sssd/issues/7284 --- Makefile.am | 12 +++++++++--- configure.ac | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index f797da54354..11949fc2187 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,6 +26,7 @@ SUBDIRS += . src/tests/cwrap src/tests/intg src/tests/test_CA \ # Some old versions of automake don't define builddir builddir ?= . +SETCAP = @SETCAP@ DOXYGEN = @DOXYGEN@ DISTSETUPOPTS = @@ -5566,17 +5567,22 @@ else $(MKDIR_P) $(DESTDIR)$(initdir) endif +CHILD_CAPABILITIES="cap_chown,cap_dac_override,cap_setuid,cap_setgid=ep" if SSSD_USER -chgrp $(SSSD_USER) $(DESTDIR)$(sssdlibexecdir)/ldap_child - chmod 4750 $(DESTDIR)$(sssdlibexecdir)/ldap_child + chmod 750 $(DESTDIR)$(sssdlibexecdir)/ldap_child + -$(SETCAP) $(CHILD_CAPABILITIES) $(DESTDIR)$(sssdlibexecdir)/ldap_child -chgrp $(SSSD_USER) $(DESTDIR)$(sssdlibexecdir)/krb5_child - chmod 4750 $(DESTDIR)$(sssdlibexecdir)/krb5_child + chmod 750 $(DESTDIR)$(sssdlibexecdir)/krb5_child + -$(SETCAP) $(CHILD_CAPABILITIES) $(DESTDIR)$(sssdlibexecdir)/krb5_child if BUILD_SELINUX -chgrp $(SSSD_USER) $(DESTDIR)$(sssdlibexecdir)/selinux_child - chmod 4750 $(DESTDIR)$(sssdlibexecdir)/selinux_child + chmod 750 $(DESTDIR)$(sssdlibexecdir)/selinux_child + -$(SETCAP) $(CHILD_CAPABILITIES) $(DESTDIR)$(sssdlibexecdir)/selinux_child endif endif + install-data-hook: rm $(DESTDIR)/$(nsslibdir)/libnss_sss.so.2 \ $(DESTDIR)/$(nsslibdir)/libnss_sss.so diff --git a/configure.ac b/configure.ac index ed7a12d6afc..ee176e7e261 100644 --- a/configure.ac +++ b/configure.ac @@ -522,6 +522,10 @@ AS_IF([test x$have_libcap = x], [ ], [ AC_CHECK_HEADERS([sys/capability.h],,AC_MSG_ERROR([Could not find sys/capability.h headers])) ]) +AC_PATH_PROG([SETCAP], [setcap], [false]) +AS_IF([test x$SETCAP == xfalse], [ + AC_MSG_WARN([setcap missing, capabilities cannot be set during make install]) +]) AC_PATH_PROG([DOXYGEN], [doxygen], [false]) AM_CONDITIONAL([HAVE_DOXYGEN], [test x$DOXYGEN != xfalse ])