|
| 1 | +/* |
| 2 | + SSSD |
| 3 | +
|
| 4 | + sss_config.c |
| 5 | +
|
| 6 | + Authors: |
| 7 | + Samuel Cabrero <scabrero@suse.com> |
| 8 | +
|
| 9 | + Copyright (C) 2026 SUSE LINUX GmbH, Nuernberg, Germany. |
| 10 | +
|
| 11 | + This program is free software; you can redistribute it and/or modify |
| 12 | + it under the terms of the GNU General Public License as published by |
| 13 | + the Free Software Foundation; either version 3 of the License, or |
| 14 | + (at your option) any later version. |
| 15 | +
|
| 16 | + This program is distributed in the hope that it will be useful, |
| 17 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + GNU General Public License for more details. |
| 20 | +
|
| 21 | + You should have received a copy of the GNU General Public License |
| 22 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | +*/ |
| 24 | + |
| 25 | +#include "util/util.h" |
| 26 | + |
| 27 | +#ifdef USE_VENDORDIR |
| 28 | +#include <sys/stat.h> |
| 29 | +#endif |
| 30 | + |
| 31 | +const char *sss_get_default_config_file(TALLOC_CTX *mem_ctx) { |
| 32 | + char *config_file = NULL; |
| 33 | +#if defined(USE_VENDORDIR) |
| 34 | + struct stat stats = {0}; |
| 35 | +#endif /* USE_VENDORDIR */ |
| 36 | + |
| 37 | + config_file = talloc_strdup(mem_ctx, SSSD_CONFIG_FILE); |
| 38 | + if (config_file == NULL) { |
| 39 | + return NULL; |
| 40 | + } |
| 41 | + |
| 42 | +#if defined(USE_VENDORDIR) |
| 43 | + if (stat(config_file, &stats) < 0 && errno == ENOENT) { |
| 44 | + TALLOC_FREE(config_file); |
| 45 | + config_file = talloc_strdup(mem_ctx, SSSD_VENDOR_CONFIG_FILE); |
| 46 | + if (config_file == NULL) { |
| 47 | + return NULL; |
| 48 | + } |
| 49 | + DEBUG(SSSDBG_CONF_SETTINGS, "Using vendor config file %s\n", config_file); |
| 50 | + } |
| 51 | +#endif /* USE_VENDORDIR */ |
| 52 | + |
| 53 | + return config_file; |
| 54 | +} |
0 commit comments