Skip to content

Commit 7e24e21

Browse files
committed
confdb: Add UsrEtc support
Vendor provided configuration is installed in /usr/etc/sssd/sssd.conf. Users can override it creating /etc/sssd/sssd.conf, or override defaults dropping config snippets to /etc/sssd/conf.d/ Doc: https://en.opensuse.org/openSUSE:Packaging_UsrEtc Signed-off-by: Samuel Cabrero <scabrero@suse.com>
1 parent 49cb12b commit 7e24e21

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed

Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ if BUILD_SAMBA
5858
winbindplugindir = @winbindpluginpath@
5959
endif
6060
sssdconfdir = $(sysconfdir)/sssd
61+
sssdvendordir = $(vendordir)/sssd
6162
sssddatadir = $(datadir)/sssd
6263
sssdapiplugindir = $(sssddatadir)/sssd.api.d
6364
sssdtapscriptdir = $(sssddatadir)/systemtap
@@ -558,6 +559,7 @@ AM_CPPFLAGS = \
558559
-DSSSDDATADIR=\"$(sssddatadir)\" \
559560
-DSSSD_LIBEXEC_PATH=\"$(sssdlibexecdir)\" \
560561
-DSSSD_CONF_DIR=\"$(sssdconfdir)\" \
562+
-DSSSD_VENDOR_DIR=\"$(sssdvendordir)\" \
561563
-DSSS_NSS_MCACHE_DIR=\"$(mcpath)\" \
562564
-DSSS_NSS_SOCKET_NAME=\"$(pipepath)/nss\" \
563565
-DSSS_PAM_SOCKET_NAME=\"$(pipepath)/pam\" \
@@ -5296,6 +5298,7 @@ edit_cmd = $(SED) \
52965298
-e 's|@nss_socket_user_group[@]|$(nss_socket_user_group)|g' \
52975299
-e 's|@supplementary_groups[@]|$(supplementary_groups)|g' \
52985300
-e 's|@sssdconfdir[@]|$(sssdconfdir)|g' \
5301+
-e 's|@sssdvendordir[@]|$(sssdvendordir)|g' \
52995302
-e 's|@secdbpath[@]|$(secdbpath)|g' \
53005303
-e 's|@dbpath[@]|$(dbpath)|g' \
53015304
-e 's|@gpocachepath[@]|$(gpocachepath)|g'

configure.ac

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,30 @@ AS_IF([test x$SETCAP == xfalse], [
542542
AC_MSG_WARN([setcap missing, capabilities cannot be set during make install])
543543
])
544544

545+
AC_ARG_WITH([vendordir],
546+
AS_HELP_STRING([--with-vendordir=DIR], [Directory for distribution provided configuration files]),
547+
[
548+
case $with_vendordir in
549+
/*)
550+
;;
551+
*)
552+
AC_MSG_ERROR(You must specify an absolute path to --with-vendordir=DIR)
553+
;;
554+
esac
555+
vendordir="$with_vendordir"
556+
],
557+
[ vendordir="/usr/etc" ])
558+
AC_DEFINE_UNQUOTED(VENDORDIR, ["$vendordir"], [Location of vendor configuration files])
559+
AC_SUBST(vendordir)
560+
561+
AC_ARG_ENABLE([vendordir],
562+
[AS_HELP_STRING([--enable-vendordir], [Enable support for distribution provided configuration files])],
563+
[], [enable_vendordir=no])
564+
if test "$enable_vendordir" != no; then
565+
AC_DEFINE(USE_VENDORDIR, 1, [Define if distribution provided configuration files should be used.])
566+
AC_MSG_NOTICE([Used vendor dir: $VENDORDIR])
567+
fi
568+
545569
AC_PATH_PROG([DOXYGEN], [doxygen], [false])
546570
AM_CONDITIONAL([HAVE_DOXYGEN], [test x$DOXYGEN != xfalse ])
547571

src/confdb/confdb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#define CONFDB_KCM_FILE "config_kcm.ldb"
4444
#define SSSD_CONFIG_FILE_NAME "sssd.conf"
4545
#define SSSD_CONFIG_FILE SSSD_CONF_DIR"/"SSSD_CONFIG_FILE_NAME
46+
#define SSSD_VENDOR_CONFIG_FILE SSSD_VENDOR_DIR"/"SSSD_CONFIG_FILE_NAME
4647
#define CONFDB_DEFAULT_CONFIG_DIR_NAME "conf.d"
4748
#define CONFDB_DEFAULT_CONFIG_DIR SSSD_CONF_DIR"/"CONFDB_DEFAULT_CONFIG_DIR_NAME
4849
#define SSSD_MIN_ID 1

src/monitor/monitor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#include <systemd/sd-daemon.h>
4747
#endif
4848

49+
#ifdef USE_VENDORDIR
50+
#include <sys/stat.h>
51+
#endif
52+
4953
#define MONITOR_VERSION 0x0001
5054

5155
/* TODO: get the restart related values from config */
@@ -1812,7 +1816,15 @@ int main(int argc, const char *argv[])
18121816
if (opt_config_file) {
18131817
config_file = talloc_strdup(tmp_ctx, opt_config_file);
18141818
} else {
1819+
#ifdef USE_VENDORDIR
1820+
struct stat stats = { 0 } ;
1821+
#endif /* USE_VENDORDIR */
18151822
config_file = talloc_strdup(tmp_ctx, SSSD_CONFIG_FILE);
1823+
#ifdef USE_VENDORDIR
1824+
if (stat(config_file, &stats) < 0 && errno == ENOENT) {
1825+
config_file = talloc_strdup(tmp_ctx, SSSD_VENDOR_CONFIG_FILE);
1826+
}
1827+
#endif /* USE_VENDORDIR */
18161828
}
18171829
if (config_file == NULL) {
18181830
ret = 2;

src/responder/kcm/kcm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "util/util.h"
3333
#include "util/sss_krb5.h"
3434

35+
#ifdef USE_VENDORDIR
36+
#include <sys/stat.h>
37+
#endif
38+
3539
#define DEFAULT_KCM_FD_LIMIT 2048
3640
#define DEFAULT_KCM_CLI_IDLE_TIMEOUT 300
3741

@@ -396,7 +400,15 @@ int main(int argc, const char *argv[])
396400
DEBUG_INIT(debug_level, opt_logger);
397401

398402
if (opt_config_file == NULL) {
403+
#ifdef USE_VENDORDIR
404+
struct stat stats = { 0 } ;
405+
#endif /* USE_VENDORDIR */
399406
config_file = SSSD_CONFIG_FILE;
407+
#ifdef USE_VENDORDIR
408+
if (stat(config_file, &stats) < 0 && errno == ENOENT) {
409+
config_file = SSSD_VENDOR_CONFIG_FILE;
410+
}
411+
#endif /* USE_VENDORDIR */
400412
} else {
401413
config_file = opt_config_file;
402414
}

src/tools/sssctl/sssctl_config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ errno_t sssctl_config_check(struct sss_cmdline *cmdline,
7070
}
7171

7272
if (config_path == NULL) {
73+
#ifdef USE_VENDORDIR
74+
struct stat stats = { 0 } ;
75+
#endif /* USE_VENDORDIR */
7376
config_path = SSSD_CONFIG_FILE;
77+
#ifdef USE_VENDORDIR
78+
if (stat(config_path, &stats) < 0 && errno == ENOENT) {
79+
config_path = SSSD_VENDOR_CONFIG_FILE;
80+
}
81+
#endif /* USE_VENDORDIR */
7482
}
7583

7684
if (config_snippet_path == NULL) {

0 commit comments

Comments
 (0)