a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce Secrets Responder
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce Copyright (C) Simo Sorce <ssorce@redhat.com> 2016
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce This program is free software; you can redistribute it and/or modify
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce it under the terms of the GNU General Public License as published by
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce the Free Software Foundation; either version 3 of the License, or
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce (at your option) any later version.
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce This program is distributed in the hope that it will be useful,
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce but WITHOUT ANY WARRANTY; without even the implied warranty of
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce GNU General Public License for more details.
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce You should have received a copy of the GNU General Public License
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce along with this program. If not, see <http://www.gnu.org/licenses/>.
197da163943868216f704fb34031e7d5576e8aeeJakub Hrozek/* The number of secrets in the /kcm hive should be quite small,
197da163943868216f704fb34031e7d5576e8aeeJakub Hrozek * but the secret size must be large because one secret in the /kcm
197da163943868216f704fb34031e7d5576e8aeeJakub Hrozek * hive holds the whole ccache which consists of several credentials
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Failed to get container nesting level for %s\n",
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Failed to get maximum number of entries for %s\n",
6b3bab516355fdf4cc81e6da9d87ec3818ab190fJakub Hrozek "Failed to get maximum number of per-UID entries for %s\n",
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Failed to get payload's maximum size for an entry in %s\n",
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozekstatic int sec_get_hive_config(struct sec_ctx *sctx,
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek hive_config->confdb_section = talloc_asprintf(sctx,
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Cannot read quota settings for %s [%d]: %s\n",
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek && hive_config->quota.max_payload_size > sctx->max_payload_size)) {
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek /* If the quota is unlimited or it's larger than what
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek * we already have, save the total limit so we know how much to
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek * accept from clients
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek sctx->max_payload_size = hive_config->quota.max_payload_size;
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Failed to get file descriptors limit\n");
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek /* Set the global max_payload to ridiculously small value so that either 0 (unlimited)
109ed7ca1a82420798efdc6a9b019675a5bd0f4fJakub Hrozek * or any sensible value overwrite it
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek /* Read the global quota first -- this should be removed in a future release */
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek /* Note that this sets the defaults for the sec_config quota to be used
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek * in sec_get_hive_config()
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Failed to get legacy global quotas\n");
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek /* Read the per-hive configuration */
4db56d8c90a6467a216590e5ba3bdcd2a2bf1ae9Jakub Hrozek "Failed to get configuration of the secrets hive\n");
197da163943868216f704fb34031e7d5576e8aeeJakub Hrozek "Failed to get configuration of the secrets hive\n");
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce ret = confdb_get_int(sctx->rctx->cdb, sctx->rctx->confdb_service_path,
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce "Cannot get the client idle timeout [%d]: %s\n",
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce /* Ensure that the client timeout is at least ten seconds */
4358d76475f0292461a2a479d2149472db103c1dFabiano Fidêncio ret = responder_setup_idle_timeout_config(sctx->rctx);
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorcestatic int sec_responder_ctx_destructor(void *ptr)
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce struct resp_ctx *rctx = talloc_get_type(ptr, struct resp_ctx);
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce /* mark that we are shutting down the responder, so it is propagated
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce * into underlying contexts that are freed right before rctx */
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce DEBUG(SSSDBG_TRACE_FUNC, "Responder is being shut down\n");
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing resp_ctx\n");
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce rctx->confdb_service_path = CONFDB_SEC_CONF_ENTRY;
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce talloc_set_destructor((TALLOC_CTX*)rctx, sec_responder_ctx_destructor);
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing sec_ctx\n");
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce DEBUG(SSSDBG_FATAL_FAILURE, "fatal error getting secrets config\n");
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce /* Set up file descriptor limits */
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce ret = activate_unix_sockets(rctx, sec_connection_setup);
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce DEBUG(SSSDBG_TRACE_FUNC, "Secrets Initialization complete\n");
677a31351c80453d9ce006481364399a96312052René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce pc = poptGetContext(argv[0], argc, argv, long_options, 0);
677a31351c80453d9ce006481364399a96312052René Genz /* set up things like debug, signals, daemonization, etc. */
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce ret = server_setup("sssd[secrets]", 0, uid, gid, CONFDB_SEC_CONF_ENTRY,
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce /* This is not fatal, don't return */
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce "Could not set up to exit when parent process does\n");
a8d1a344e580f29699aed9b88d87fc3c6f5d113bSimo Sorce /* loop on main */