cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek Copyright (C) 2013 Red Hat
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek InfoPipe responder: the responder server
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek This program is free software; you can redistribute it and/or modify
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek it under the terms of the GNU General Public License as published by
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek the Free Software Foundation; either version 3 of the License, or
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek (at your option) any later version.
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek This program is distributed in the hope that it will be useful,
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek GNU General Public License for more details.
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek You should have received a copy of the GNU General Public License
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozekstatic int ifp_sysbus_reconnect(struct sbus_request *dbus_req, void *data);
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozekstatic void ifp_dp_reconnect_init(struct sbus_connection *conn,
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* Did we reconnect successfully? */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "Reconnected to the Data Provider.\n");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* Identify ourselves to the data provider */
83a79d93035c2d75a1941f3b54426119174044a0Pavel Březina ret = rdp_register_client(be_conn, "InfoPipe");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* all fine */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek handle_requests_after_reconnect(be_conn->rctx);
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* Failed to reconnect */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "Could not reconnect to %s provider.\n",
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek system_bus = talloc_zero(mem_ctx, struct sysbus_ctx);
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek /* Connect to the well-known system bus */
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
1f2507e1fd089f2bf3458cfb4faeaa9669d72f98Jakub Hrozek "Failed to connect to D-BUS system bus: [%s]\n",
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek dbus_connection_set_exit_on_disconnect(conn, FALSE);
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek /* We want exclusive access */
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek /* We were unable to register on the system bus */
1f2507e1fd089f2bf3458cfb4faeaa9669d72f98Jakub Hrozek "Unable to request name on the system bus: [%s]\n",
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "Listening on %s\n", dbus_name);
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek /* Integrate with tevent loop */
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek ret = sbus_init_connection(system_bus, ev, conn,
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek "Could not integrate D-BUS into mainloop.\n");
772199031f0ec687fa1fefd939206858c440e5a1Pavel Březina ret = ifp_register_sbus_interface(system_bus->conn, pvt);
772199031f0ec687fa1fefd939206858c440e5a1Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Could not register interfaces\n");
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek "DBus error message: %s\n", dbus_error.message);
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozekstatic int ifp_sysbus_reconnect(struct sbus_request *dbus_req, void *data)
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek struct ifp_ctx *ifp_ctx = (struct ifp_ctx*) rctx->pvt_ctx;
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "Attempting to reconnect to the system bus\n");
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek DEBUG(SSSDBG_TRACE_LIBS, "Already connected to sysbus\n");
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek /* Connect to the D-BUS system bus and set up methods */
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek "The system bus is not available..\n");
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek "Failed to connect to the system message bus\n");
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek DEBUG(SSSDBG_TRACE_LIBS, "Reconnected to the system bus!\n");
b76419cf8830440b46c20a15585562343c7b1924Jakub Hrozek return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing ifp_ctx\n");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek "(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing regex data\n");
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek ret = confdb_get_string(ifp_ctx->rctx->cdb, ifp_ctx->rctx,
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek CONFDB_IFP_CONF_ENTRY, CONFDB_SERVICE_ALLOWED_UIDS,
1f2507e1fd089f2bf3458cfb4faeaa9669d72f98Jakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "Failed to get allowed UIDs.\n");
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek ret = csv_string_to_uid_array(ifp_ctx->rctx, uid_str, true,
1f2507e1fd089f2bf3458cfb4faeaa9669d72f98Jakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "Failed to set allowed UIDs.\n");
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek ret = confdb_get_string(ifp_ctx->rctx->cdb, ifp_ctx->rctx,
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek CONFDB_IFP_CONF_ENTRY, CONFDB_IFP_USER_ATTR_LIST,
7b5a077bd162cb2340d5d4e9f5dcc0dd00709f1aSumit Bose DEBUG(SSSDBG_FATAL_FAILURE, "Failed to get user attribute list.\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_ctx->user_whitelist = ifp_parse_user_attr_list(ifp_ctx, attr_list_str);
1f2507e1fd089f2bf3458cfb4faeaa9669d72f98Jakub Hrozek "Failed to parse the allowed attribute list\n");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* Enable automatic reconnection to the Data Provider */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek "Failed to set up automatic reconnection\n");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek /* A bit convoluted way until we have a confdb_get_uint32 */
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "Failed to retrieve limit for a wildcard search\n");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ifp_ctx->wildcard_limit = strtouint32(wildcard_limit_str, NULL, 10);
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek for (iter = ifp_ctx->rctx->be_conns; iter; iter = iter->next) {
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek /* Connect to the D-BUS system bus and set up methods */
0c1d65998907930678da2d091789446f2c344d5dJakub Hrozek "The system bus is not available..\n");
0c1d65998907930678da2d091789446f2c344d5dJakub Hrozek /* Explicitly ignore, the D-Bus daemon will start us */
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek "Failed to connect to the system message bus\n");
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
8214510f125879c3b1d247f2ce981ee20b5375d1Jakub Hrozek "schedule_get_domains_tasks failed.\n");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "InfoPipe Initialization complete\n");
677a31351c80453d9ce006481364399a96312052René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
677a31351c80453d9ce006481364399a96312052René Genz /* set up things like debug, signals, daemonization, etc. */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* This is not fatal, don't return */
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek "Could not set up to exit when parent process does\n");
cb4d5b588e704114b7090678752d33512baa718eJakub Hrozek /* loop on main */