sudosrv.c revision b95c6b5485eee5f45f62f87df77c9178857d625e
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Pavel Březina <pbrezina@redhat.com>
d5fe06af711a6912ae028ebf873eada4ee8733f8Christian Maeder Copyright (C) 2011 Red Hat
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder This program is free software; you can redistribute it and/or modify
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder it under the terms of the GNU General Public License as published by
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder the Free Software Foundation; either version 3 of the License, or
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder (at your option) any later version.
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski This program is distributed in the hope that it will be useful,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bdeddba30d29f413af1e1ae6b6bab275c017bd98Christian Maeder GNU General Public License for more details.
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder You should have received a copy of the GNU General Public License
ae35311385999d91f812155fe99439724d54063bChristian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maederstruct sbus_method monitor_sudo_methods[] = {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder { MON_CLI_METHOD_PING, monitor_common_pong },
46b1095ba983ce859e17c2a12f48b50583b7150cChristian Maeder { MON_CLI_METHOD_RES_INIT, monitor_common_res_init },
411392046c2ba1752cde81eaa92a95a2c28b672dChristian Maeder { MON_CLI_METHOD_ROTATE, responder_logrotate },
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maederstruct sbus_interface monitor_sudo_interface = {
3986813db69106b9bb1b62faa77532af42512a0cChristian Maederstatic struct sbus_method sudo_dp_methods[] = {
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maederstatic void sudo_dp_reconnect_init(struct sbus_connection *conn,
56440c7ae61e7277a3494452d0165ee52e677b29Christian Maeder struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
56440c7ae61e7277a3494452d0165ee52e677b29Christian Maeder /* Did we reconnect successfully? */
1842453990fed8a1bd7a5ac792d7982c1d2bfcd5Christian Maeder DEBUG(SSSDBG_TRACE_FUNC, ("Reconnected to the Data Provider.\n"));
2dcec0e101ddd4169f5323462911e988337c2deeChristian Maeder /* Identify ourselves to the data provider */
ec25781c1180ea07f66b48c34f93cf5634e9277cChristian Maeder /* all fine */
64c2422e1ba0691556a6639e959820add102315cChristian Maeder handle_requests_after_reconnect(be_conn->rctx);
63da71bfb4226f504944b293fb77177ebcaea7d4Ewaryst Schulz /* Failed to reconnect */
f8cc2399c16fcda7e3bf9d901a0de0cc8a455f86Ewaryst Schulz DEBUG(SSSDBG_FATAL_FAILURE, ("Could not reconnect to %s provider.\n",
0850c3e5fb6285405ebaeb5aa433985203ac892dEwaryst Schulz sudo_ctx = talloc_zero(mem_ctx, struct sudo_ctx);
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing sudo_ctx\n"));
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder /* Enable automatic reconnection to the Data Provider */
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder ("Failed to set up automatic reconnection\n"));
f6b2c6c33c635279973b8f378470da7dbb8ecee8Christian Maeder for (iter = sudo_ctx->rctx->be_conns; iter; iter = iter->next) {
d27d203b3f42f0e0ecea00e3f19f55f66045bd96Christian Maeder sbus_reconnect_init(iter->conn, max_retries,
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder /* Get responder options */
e49fd57c63845c7806860a9736ad09f6d44dbaedChristian Maeder /* Get sudo_timed option */
f6b2c6c33c635279973b8f378470da7dbb8ecee8Christian Maeder DEBUG(SSSDBG_FATAL_FAILURE, ("Error reading from confdb (%d) [%s]\n",
e6ac593966607b1da5b619e0f9492d37820eed74Christian Maeder DEBUG(SSSDBG_TRACE_FUNC, ("SUDO Initialization complete\n"));
e49fd57c63845c7806860a9736ad09f6d44dbaedChristian Maeder /* Set debug level to invalid value so we can deside if -d 0 was used. */
1bc5dccbf0083a620ae1181c717fea75e4af5e5cChristian Maeder pc = poptGetContext(argv[0], argc, argv, long_options, 0);
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder fprintf(stderr, "\nInvalid option %s: %s\n\n",
154be5bfac61cf5b61fd1571e7bfc2572c4b546aMihai Codescu /* set up things like debug, signals, daemonization, etc... */
7fe976d9f9c4af1aa7636c568d9919859523de0aChristian Maeder ret = server_setup("sssd[sudo]", 0, CONFDB_SUDO_CONF_ENTRY, &main_ctx);
7fe976d9f9c4af1aa7636c568d9919859523de0aChristian Maeder /* This is not fatal, don't return */
154be5bfac61cf5b61fd1571e7bfc2572c4b546aMihai Codescu DEBUG(SSSDBG_OP_FAILURE, ("Could not set up to exit "
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder "when parent process does\n"));
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder /* loop on main */