diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2016-04-19 11:58:35 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2016-05-11 11:34:14 +0200 |
commit | 59744cff6edb106ae799b2321cb8731edadf409a (patch) | |
tree | be17c08de80495f9e9e3043552979cea9803dd1c /src | |
parent | 98dbaea0a00c60972b991755a44c51964dfb7877 (diff) | |
download | sssd-59744cff6edb106ae799b2321cb8731edadf409a.tar.gz sssd-59744cff6edb106ae799b2321cb8731edadf409a.tar.xz sssd-59744cff6edb106ae799b2321cb8731edadf409a.zip |
CONFIG: Use default config when none provided
This patch makes SSSD possibly useful "out of the box" by allowing
packagers to provide a default config file located in $LIBDIR/sssd/conf
that will be copied by the monitor to /etc/sssd if no file already
exists in that location. This will make it possible to have SSSD set up
to have distribution-specific default configuration, such as enabling
the proxy provider to cache /etc/passwd (such as in the provided
example in this patch).
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/confdb/confdb.h | 1 | ||||
-rw-r--r-- | src/confdb/confdb_setup.c | 40 | ||||
-rw-r--r-- | src/examples/sssd-shadowutils | 6 | ||||
-rw-r--r-- | src/examples/sssd.conf | 17 |
4 files changed, 60 insertions, 4 deletions
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h index b90ced2bb..a9b1c4362 100644 --- a/src/confdb/confdb.h +++ b/src/confdb/confdb.h @@ -40,6 +40,7 @@ #define CONFDB_DEFAULT_CFG_FILE_VER 2 #define CONFDB_FILE "config.ldb" +#define SSSD_DEFAULT_CONFIG_FILE SSSD_DEFAULT_CONF_DIR"/sssd.conf" #define SSSD_CONFIG_FILE SSSD_CONF_DIR"/sssd.conf" #define SSSD_MIN_ID 1 #define SSSD_LOCAL_MINID 1000 diff --git a/src/confdb/confdb_setup.c b/src/confdb/confdb_setup.c index 694a7f016..dfdcae566 100644 --- a/src/confdb/confdb_setup.c +++ b/src/confdb/confdb_setup.c @@ -21,12 +21,14 @@ #include "config.h" #include <sys/stat.h> +#include <unistd.h> #include "util/util.h" #include "db/sysdb.h" #include "confdb.h" #include "confdb_private.h" #include "confdb_setup.h" #include "util/sss_ini.h" +#include "tools/tools_util.h" int confdb_test(struct confdb_ctx *cdb) @@ -159,11 +161,41 @@ int confdb_init_db(const char *config_file, struct confdb_ctx *cdb) DEBUG(SSSDBG_TRACE_FUNC, "sss_ini_config_file_open failed: %s [%d]\n", strerror(ret), ret); - if (ret == ENOENT) { - /* sss specific error denoting missing configuration file */ - ret = ERR_MISSING_CONF; + if (ret != ENOENT) { + /* Anything other than ENOENT is unrecoverable */ + goto done; + } else { + /* Copy the default configuration file to the standard location + * and then retry + */ + ret = copy_file_secure(SSSD_DEFAULT_CONFIG_FILE, + SSSD_CONFIG_FILE, + 0600, + getuid(), + getgid(), + false); + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not copy default configuration: %s", + sss_strerror(ret)); + /* sss specific error denoting missing configuration file */ + ret = ERR_MISSING_CONF; + goto done; + } + + /* Try again */ + ret = sss_ini_config_file_open(init_data, config_file); + if (ret != EOK) { + DEBUG(SSSDBG_TRACE_FUNC, + "sss_ini_config_file_open(default) failed: %s [%d]\n", + strerror(ret), ret); + if (ret == ENOENT) { + /* sss specific error denoting missing configuration file */ + ret = ERR_MISSING_CONF; + } + goto done; + } } - goto done; } ret = sss_ini_config_access_check(init_data); diff --git a/src/examples/sssd-shadowutils b/src/examples/sssd-shadowutils new file mode 100644 index 000000000..626c7d075 --- /dev/null +++ b/src/examples/sssd-shadowutils @@ -0,0 +1,6 @@ +#%PAM-1.0 +auth [success=done ignore=ignore default=die] pam_unix.so nullok try_first_pass +auth required pam_deny.so + +account required pam_unix.so +account required pam_permit.so diff --git a/src/examples/sssd.conf b/src/examples/sssd.conf new file mode 100644 index 000000000..a851dbb7e --- /dev/null +++ b/src/examples/sssd.conf @@ -0,0 +1,17 @@ +[sssd] +config_file_version = 2 +services = nss, pam +domains = shadowutils + +[nss] + +[pam] + +[domain/shadowutils] +id_provider = proxy +proxy_lib_name = files + +auth_provider = proxy +proxy_pam_target = sssd-shadowutils + +proxy_fast_alias = True |