autofssrv.c revision 83a79d93035c2d75a1941f3b54426119174044a0
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek/*
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Authors:
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Copyright (C) 2012 Red Hat
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek Autofs responder: the responder server
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
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
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
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/>.
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek*/
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include <popt.h>
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include "util/util.h"
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include "confdb/confdb.h"
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include "monitor/monitor_interfaces.h"
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include "responder/common/responder.h"
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include "providers/data_provider.h"
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek#include "responder/autofs/autofs_private.h"
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walterstatic int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data);
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek
769347ad4d35d43488eb98f980143495b0db415dStef Walterstruct mon_cli_iface monitor_autofs_methods = {
769347ad4d35d43488eb98f980143495b0db415dStef Walter { &mon_cli_iface_meta, 0 },
769347ad4d35d43488eb98f980143495b0db415dStef Walter .ping = monitor_common_pong,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .resInit = monitor_common_res_init,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .shutDown = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .goOffline = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .resetOffline = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .rotateLogs = responder_logrotate,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .clearMemcache = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .clearEnumCache = autofs_clean_hash_table,
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek .sysbusReconnect = NULL,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek};
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
769347ad4d35d43488eb98f980143495b0db415dStef Walterstatic struct data_provider_iface autofs_dp_methods = {
769347ad4d35d43488eb98f980143495b0db415dStef Walter { &data_provider_iface_meta, 0 },
769347ad4d35d43488eb98f980143495b0db415dStef Walter .RegisterService = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .pamHandler = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .sudoHandler = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .autofsHandler = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .hostHandler = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .getDomains = NULL,
769347ad4d35d43488eb98f980143495b0db415dStef Walter .getAccountInfo = NULL,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek};
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekstatic errno_t
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekautofs_get_config(struct autofs_ctx *actx,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct confdb_ctx *cdb)
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek{
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek errno_t ret;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
3bea01f01d76e1e95a8239c0d3f67073992136a1Jan Zeleny ret = confdb_get_int(cdb, CONFDB_AUTOFS_CONF_ENTRY,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek CONFDB_AUTOFS_MAP_NEG_TIMEOUT, 15,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek &actx->neg_timeout);
c90fdc85cfb552911e29b4d284fd4c40ea1bb4e9Petr Cech return ret;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek}
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekstatic void
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekautofs_dp_reconnect_init(struct sbus_connection *conn,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int status, void *pvt)
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek{
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int ret;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Did we reconnect successfully? */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (status == SBUS_RECONNECT_SUCCESS) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "Reconnected to the Data Provider.\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Identify ourselves to the data provider */
83a79d93035c2d75a1941f3b54426119174044a0Pavel Březina ret = rdp_register_client(be_conn, "autofs");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* all fine */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (ret == EOK) {
65976ea5e9767bfaced81dfb97dc87d59f50b57eSimo Sorce handle_requests_after_reconnect(be_conn->rctx);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek return;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Failed to reconnect */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "Could not reconnect to %s provider.\n",
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov be_conn->domain->name);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek}
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walterstatic int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data)
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek{
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walter struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek struct autofs_ctx *actx =
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek talloc_get_type(rctx->pvt_ctx, struct autofs_ctx);
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek errno_t ret;
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek ret = autofs_orphan_maps(actx);
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek if (ret != EOK) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Could not invalidate maps\n");
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek return ret;
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek }
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek
d9577dbd92555b0755881e37724019ef9c578404Stef Walter return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek}
ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3Jakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekstatic int
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekautofs_process_init(TALLOC_CTX *mem_ctx,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct tevent_context *ev,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct confdb_ctx *cdb)
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek{
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina struct resp_ctx *rctx;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct sss_cmd_table *autofs_cmds;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct autofs_ctx *autofs_ctx;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct be_conn *iter;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int ret;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int hret;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int max_retries;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek autofs_cmds = get_autofs_cmds();
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina ret = sss_process_init(mem_ctx, ev, cdb,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek autofs_cmds,
8bccd95e275fae760a991da394235e4e70e57bbdMichal Zidek SSS_AUTOFS_SOCKET_NAME, -1, NULL, -1,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek CONFDB_AUTOFS_CONF_ENTRY,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek SSS_AUTOFS_SBUS_SERVICE_NAME,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek SSS_AUTOFS_SBUS_SERVICE_VERSION,
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walter &monitor_autofs_methods,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek "autofs",
07e941c1bbdc752142bbd3b838c540bc7ecd0ed7Stef Walter &autofs_dp_methods.vtable,
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina &rctx);
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina if (ret != EOK) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina return ret;
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina }
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina autofs_ctx = talloc_zero(rctx, struct autofs_ctx);
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina if (!autofs_ctx) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing autofs_ctx\n");
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina ret = ENOMEM;
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina goto fail;
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina }
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina ret = autofs_get_config(autofs_ctx, cdb);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (ret != EOK) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "Cannot read autofs configuration\n");
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březina goto fail;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina autofs_ctx->rctx = rctx;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek autofs_ctx->rctx->pvt_ctx = autofs_ctx;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Enable automatic reconnection to the Data Provider */
3bea01f01d76e1e95a8239c0d3f67073992136a1Jan Zeleny ret = confdb_get_int(autofs_ctx->rctx->cdb,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek CONFDB_AUTOFS_CONF_ENTRY,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek CONFDB_SERVICE_RECON_RETRIES,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek 3, &max_retries);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (ret != EOK) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Failed to set up automatic reconnection\n");
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březina goto fail;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek for (iter = autofs_ctx->rctx->be_conns; iter; iter = iter->next) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek sbus_reconnect_init(iter->conn, max_retries,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek autofs_dp_reconnect_init, iter);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
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,
08c72b84d85d482f030a30cf74786695f097e91cJakub Hrozek autofs_map_hash_delete_cb, NULL);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (hret != HASH_SUCCESS) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Unable to initialize automount maps hash table\n");
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březina ret = EIO;
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březina goto fail;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose if (ret != EOK) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose goto fail;
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose }
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "autofs Initialization complete\n");
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek return EOK;
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březina
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březinafail:
7c9fe57ad82747a32721ca0a08c5569282f3e0c4Pavel Březina talloc_free(rctx);
6f8ae17869f4f8a1496e3f171ae6b5c11af1845cPavel Březina return ret;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek}
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozekint main(int argc, const char *argv[])
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek{
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int opt;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek poptContext pc;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct main_context *main_ctx;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek int ret;
ac40d2f2b2b2fc35c95389f5e28febd580bd2b7aJakub Hrozek uid_t uid;
ac40d2f2b2b2fc35c95389f5e28febd580bd2b7aJakub Hrozek gid_t gid;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek struct poptOption long_options[] = {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek POPT_AUTOHELP
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek SSSD_MAIN_OPTS
ac40d2f2b2b2fc35c95389f5e28febd580bd2b7aJakub Hrozek SSSD_SERVER_OPTS(uid, gid)
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek POPT_TABLEEND
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek };
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* Set debug level to invalid value so we can decide if -d 0 was used. */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek debug_level = SSSDBG_INVALID;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
458f5245dd5130d12666cce6faf8ef1ec7f80169Pavel Reichl umask(DFL_RSP_UMASK);
458f5245dd5130d12666cce6faf8ef1ec7f80169Pavel Reichl
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek while((opt = poptGetNextOpt(pc)) != -1) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek switch(opt) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek default:
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek fprintf(stderr, "\nInvalid option %s: %s\n\n",
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek poptBadOption(pc, 0), poptStrerror(opt));
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek poptPrintUsage(pc, stderr, 0);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek return 1;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek poptFreeContext(pc);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e2c64c6d4f5560e27207193efea6536a566865eMichal Zidek DEBUG_INIT(debug_level);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* set up things like debug, signals, daemonization, etc... */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek debug_log_file = "sssd_autofs";
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
287cc55b9086dd3c4e2a5fb84784e09767860142Jakub Hrozek ret = server_setup("sssd[autofs]", 0, uid, gid,
ac40d2f2b2b2fc35c95389f5e28febd580bd2b7aJakub Hrozek CONFDB_AUTOFS_CONF_ENTRY, &main_ctx);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (ret != EOK) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek return 2;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek ret = die_if_parent_died();
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (ret != EOK) {
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 }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek ret = autofs_process_init(main_ctx,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek main_ctx->event_ctx,
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek main_ctx->confdb_ctx);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek if (ret != EOK) {
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek return 3;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek }
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek /* loop on main */
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek server_loop(main_ctx);
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek return 0;
9e80079370ff3b943832adc3c5ef430e64be0a0cJakub Hrozek}