Skip to content

Add support for openSUSE UsrEtc#8504

Open
scabrero wants to merge 3 commits intoSSSD:masterfrom
scabrero:scabrero-UsrEtc
Open

Add support for openSUSE UsrEtc#8504
scabrero wants to merge 3 commits intoSSSD:masterfrom
scabrero:scabrero-UsrEtc

Conversation

@scabrero
Copy link
Contributor

@scabrero scabrero commented Mar 6, 2026

To support transactional-updates in openSUSE, this PR adds support for UsrEtc.

  • Vendor provided configuration is installed in /usr/etc/sssd/sssd.conf.
  • Users can override the vendor creating /etc/sssd/sssd.conf or dropping config snippets to /etc/sssd/conf.d/

Doc: https://en.opensuse.org/openSUSE:Packaging_UsrEtc

scabrero added 3 commits March 6, 2026 13:59
Signed-off-by: Samuel Cabrero <scabrero@suse.com>
Use same logic as the main daemon.

Signed-off-by: Samuel Cabrero <scabrero@suse.com>
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>
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for openSUSE's UsrEtc layout, allowing SSSD to fall back to a vendor-provided configuration file. The changes are generally well-implemented across the build system and source code. However, I've identified a memory leak in src/monitor/monitor.c due to incorrect handling of talloc allocations when determining the configuration file path. Additionally, there's a minor bug in configure.ac that causes a user-facing notice to display an empty value. I have provided suggestions to address both of these issues.

[], [enable_vendordir=no])
if test "$enable_vendordir" != no; then
AC_DEFINE(USE_VENDORDIR, 1, [Define if distribution provided configuration files should be used.])
AC_MSG_NOTICE([Used vendor dir: $VENDORDIR])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The shell variable for the vendor directory is vendordir, not VENDORDIR. VENDORDIR is the C preprocessor macro. This will result in an empty value being printed in the notice.

  AC_MSG_NOTICE([Used vendor dir: $vendordir])

Comment on lines +1819 to +1827
#ifdef USE_VENDORDIR
struct stat stats = { 0 } ;
#endif /* USE_VENDORDIR */
config_file = talloc_strdup(tmp_ctx, SSSD_CONFIG_FILE);
#ifdef USE_VENDORDIR
if (stat(config_file, &stats) < 0 && errno == ENOENT) {
config_file = talloc_strdup(tmp_ctx, SSSD_VENDOR_CONFIG_FILE);
}
#endif /* USE_VENDORDIR */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This block of code has a memory leak. If stat(config_file, &stats) fails with ENOENT, config_file is re-assigned with a new allocation from talloc_strdup, leaking the memory from the first allocation. It's better to determine the correct config path first, and then allocate memory for it only once to avoid the leak and simplify the code.

        const char *path = SSSD_CONFIG_FILE;
#ifdef USE_VENDORDIR
        struct stat stats;
        if (stat(path, &stats) < 0 && errno == ENOENT) {
            path = SSSD_VENDOR_CONFIG_FILE;
        }
#endif /* USE_VENDORDIR */
        config_file = talloc_strdup(tmp_ctx, path);

@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Mar 6, 2026
Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only added comments to the first instance of each problem.

I'd highly recommend you to create a centralized place to manage this logic. A new file located in src/util/util_config.c would probably be the best location to place this logic. This way we reduce the maintenance burden and the possibility of applying fixes in one place but forgetting about the other

#endif /* USE_VENDORDIR */
config_file = talloc_strdup(tmp_ctx, SSSD_CONFIG_FILE);
#ifdef USE_VENDORDIR
if (stat(config_file, &stats) < 0 && errno == ENOENT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check the return value for config_file before using it for anything

config_file = talloc_strdup(tmp_ctx, SSSD_CONFIG_FILE);
#ifdef USE_VENDORDIR
if (stat(config_file, &stats) < 0 && errno == ENOENT) {
config_file = talloc_strdup(tmp_ctx, SSSD_VENDOR_CONFIG_FILE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are overwriting the content of config_file it would be sensible to free it before. I know talloc already takes care of this, but it would improve the readability

#ifdef USE_VENDORDIR
if (stat(config_file, &stats) < 0 && errno == ENOENT) {
config_file = talloc_strdup(tmp_ctx, SSSD_VENDOR_CONFIG_FILE);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add some debugging to state when the user vendor config is used

AC_SUBST(vendordir)

AC_ARG_ENABLE([vendordir],
[AS_HELP_STRING([--enable-vendordir], [Enable support for distribution provided configuration files])],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you providing two different options? This is quite confusing

@pbrezina pbrezina self-assigned this Mar 19, 2026
@pbrezina pbrezina self-requested a review March 19, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants