autofssrv.c revision 83a79d93035c2d75a1941f3b54426119174044a0
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Copyright (C) 2012 Red Hat
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Autofs responder: the responder server
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek This program is free software; you can redistribute it and/or modify
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek it under the terms of the GNU General Public License as published by
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek the Free Software Foundation; either version 3 of the License, or
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek (at your option) any later version.
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek This program is distributed in the hope that it will be useful,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek GNU General Public License for more details.
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek You should have received a copy of the GNU General Public License
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walterstatic int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data);
769347ad4d35d43488eb98f980143495b0db415dStef Walterstatic struct data_provider_iface autofs_dp_methods = {
3bea01f01d76e1e95a8239c0d3f67073992136a1Jan Zeleny ret = confdb_get_int(cdb, CONFDB_AUTOFS_CONF_ENTRY,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekautofs_dp_reconnect_init(struct sbus_connection *conn,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Did we reconnect successfully? */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "Reconnected to the Data Provider.\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Identify ourselves to the data provider */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* all fine */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Failed to reconnect */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "Could not reconnect to %s provider.\n",
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walterstatic int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data)
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walter struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek talloc_get_type(rctx->pvt_ctx, struct autofs_ctx);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Could not invalidate maps\n");
d9577dbd92555b0755881e37724019ef9c578404Stef Walter return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina autofs_ctx = talloc_zero(rctx, struct autofs_ctx);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing autofs_ctx\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "Cannot read autofs configuration\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Enable automatic reconnection to the Data Provider */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Failed to set up automatic reconnection\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek for (iter = autofs_ctx->rctx->be_conns; iter; iter = iter->next) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Create the lookup table for setautomntent results */
08c72b84d85d482f030a30cf74786695f097e91cJakub Hrozek hret = sss_hash_create_ex(autofs_ctx, 10, &autofs_ctx->maps, 0, 0, 0, 0,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Unable to initialize automount maps hash table\n");
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "autofs Initialization complete\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Set debug level to invalid value so we can decide if -d 0 was used. */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* set up things like debug, signals, daemonization, etc... */
287cc55b9086dd3c4e2a5fb84784e09767860142Jakub Hrozek ret = server_setup("sssd[autofs]", 0, uid, gid,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* This is not fatal, don't return */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Could not set up to exit "
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "when parent process does\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* loop on main */