c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek files_init.c - Initialization of the files provider
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek Copyright (C) 2016 Red Hat
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek This program is free software; you can redistribute it and/or modify
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek it under the terms of the GNU General Public License as published by
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek the Free Software Foundation; either version 3 of the License, or
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek (at your option) any later version.
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek This program is distributed in the hope that it will be useful,
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek GNU General Public License for more details.
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek You should have received a copy of the GNU General Public License
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephensonstatic errno_t files_init_file_sources(TALLOC_CTX *mem_ctx,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson dfl_passwd_files = getenv("SSS_FILES_PASSWD");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Defaulting to %s for the passwd file, "
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "this should only be used for testing!\n",
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Using default passwd file: [%s].\n", dfl_passwd_files);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson env_group_files = getenv("SSS_FILES_GROUP");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Defaulting to %s for the group file, "
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "this should only be used for testing!\n",
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Using default group file: [%s].\n", DEFAULT_GROUP_FILE);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson ret = confdb_get_string(be_ctx->cdb, tmp_ctx, be_ctx->conf_path,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson DEBUG(SSSDBG_CRIT_FAILURE, "Failed to retrieve confdb passwd files!\n");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson ret = confdb_get_string(be_ctx->cdb, tmp_ctx, be_ctx->conf_path,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson DEBUG(SSSDBG_CRIT_FAILURE, "Failed to retrieve confdb group files!\n");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson ret = split_on_separator(tmp_ctx, conf_passwd_files, ',', true, true,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Failed to parse passwd list!\n");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson passwd_files = talloc_zero_array(tmp_ctx, const char *,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero_array() failed\n");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson for (i = 0; i < num_passwd_files; i++) {
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Using passwd file: [%s].\n", passwd_list[i]);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson passwd_files[i] = talloc_strdup(passwd_files, passwd_list[i]);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson /* Retrieve list of group files */
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson ret = split_on_separator(tmp_ctx, conf_group_files, ',', true, true,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Failed to parse group files!\n");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson group_files = talloc_zero_array(tmp_ctx, const char *,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero_array() failed\n");
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson for (i = 0; i < num_group_files; i++) {
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson "Using group file: [%s].\n", group_list[i]);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson group_files[i] = talloc_strdup(group_files, group_list[i]);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson *_passwd_files = talloc_steal(mem_ctx, passwd_files);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson *_group_files = talloc_steal(mem_ctx, group_files);
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek ctx = talloc_zero(mem_ctx, struct files_id_ctx);
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson ret = files_init_file_sources(ctx, be_ctx,
0d6d493f68bb83a046d351cb3035b08ef5456b50Justin Stephenson DEBUG(SSSDBG_CRIT_FAILURE, "Cannot initialize the passwd/group source files\n");
c71e0a6710418991d759a329b8dcb77c7ad3e16eJakub Hrozek ctx = talloc_get_type(module_data, struct files_id_ctx);
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek dp_set_method(dp_methods, DPM_ACCT_DOMAIN_HANDLER,