autofssrv.c revision ab792150c97bd6eba1f8cd46653f41a0c64fd765
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly Jakub Hrozek <jhrozek@redhat.com>
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly Copyright (C) 2012 Red Hat
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly Autofs responder: the responder server
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly This program is free software; you can redistribute it and/or modify
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly it under the terms of the GNU General Public License as published by
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly the Free Software Foundation; either version 3 of the License, or
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly (at your option) any later version.
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly This program is distributed in the hope that it will be useful,
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly but WITHOUT ANY WARRANTY; without even the implied warranty of
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder GNU General Public License for more details.
56899f6457976a2ee20f6a23f088cb5655b15715Liam O'Reilly You should have received a copy of the GNU General Public License
7d41a06add784ca68e6507ce832e621a1d2abf49Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder#include "responder/autofs/autofs_private.h"
c0833539c8cf577dd3f2497792fbdd818442744cChristian Maederstatic int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data);
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reillystruct mon_cli_iface monitor_autofs_methods = {
caf021dd48c90ff6b26117f13e1d8c0ef1ca618aChristian Maeder ret = confdb_get_int(cdb, CONFDB_AUTOFS_CONF_ENTRY,
ace03c3051e5c5144e43ae78cae73f6a29dde6d5Christian Maederautofs_dp_reconnect_init(struct sbus_connection *conn,
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
4770d29adda064baa5dbfcca03f600d7608806f7Liam O'Reilly /* Did we reconnect successfully? */
4770d29adda064baa5dbfcca03f600d7608806f7Liam O'Reilly DEBUG(SSSDBG_TRACE_FUNC, "Reconnected to the Data Provider.\n");
4770d29adda064baa5dbfcca03f600d7608806f7Liam O'Reilly /* Identify ourselves to the data provider */
4770d29adda064baa5dbfcca03f600d7608806f7Liam O'Reilly /* all fine */
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly handle_requests_after_reconnect(be_conn->rctx);
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* Failed to reconnect */
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly DEBUG(SSSDBG_FATAL_FAILURE, "Could not reconnect to %s provider.\n",
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reillystatic int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data)
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder talloc_get_type(rctx->pvt_ctx, struct autofs_ctx);
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly DEBUG(SSSDBG_OP_FAILURE, "Could not invalidate maps\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
56899f6457976a2ee20f6a23f088cb5655b15715Liam O'Reilly DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder autofs_ctx = talloc_zero(rctx, struct autofs_ctx);
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing autofs_ctx\n");
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder DEBUG(SSSDBG_FATAL_FAILURE, "Cannot read autofs configuration\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* Enable automatic reconnection to the Data Provider */
ace03c3051e5c5144e43ae78cae73f6a29dde6d5Christian Maeder ret = confdb_get_int(autofs_ctx->rctx->cdb,
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly "Failed to set up automatic reconnection\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly for (iter = autofs_ctx->rctx->be_conns; iter; iter = iter->next) {
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maeder sbus_reconnect_init(iter->conn, max_retries,
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* Create the lookup table for setautomntent results */
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly hret = sss_hash_create_ex(autofs_ctx, 10, &autofs_ctx->maps, 0, 0, 0, 0,
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder "Unable to initialize automount maps hash table\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly DEBUG(SSSDBG_TRACE_FUNC, "autofs Initialization complete\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* Set debug level to invalid value so we can decide if -d 0 was used. */
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly pc = poptGetContext(argv[0], argc, argv, long_options, 0);
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly fprintf(stderr, "\nInvalid option %s: %s\n\n",
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* set up things like debug, signals, daemonization, etc... */
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly ret = server_setup("sssd[autofs]", 0, uid, gid,
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* This is not fatal, don't return */
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "Could not set up to exit "
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly "when parent process does\n");
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly /* loop on main */