monitor.c revision 31d97bce8f113276bf73c7d4349f720cd5edbcb8
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen Service monitor
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen Copyright (C) Simo Sorce 2008
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen This program is free software; you can redistribute it and/or modify
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it under the terms of the GNU General Public License as published by
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen the Free Software Foundation; either version 3 of the License, or
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen (at your option) any later version.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen This program is distributed in the hope that it will be useful,
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen GNU General Public License for more details.
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen You should have received a copy of the GNU General Public License
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
d482b35af87f5fd872bad007da0475813a401a49Timo Sirainen/* Needed for res_init() */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* ping time cannot be less then once every few seconds or the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen * monitor will get crazy hammering children with messages */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* terminate the child after this interval by default if it
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen * doesn't shutdown on receiving SIGTERM */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* name of the monitor server instance */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define SSSD_PIDFILE_PATH PID_PATH"/"MONITOR_NAME".pid"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Special value to leave the Kerberos Replay Cache set to use
7394389230750c45b105cdefb5850c81cae8cdc0Timo Sirainen * the libkrb5 defaults
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen#define KRB5_RCACHE_DIR_DISABLE "__LIBKRB5_DEFAULTS__"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen TALLOC_CTX *domain_ctx; /* Memory context for domain list */
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen TALLOC_CTX *service_ctx; /* Memory context for services */
ace3c14e47a5a865df8aeea2fabc993b609dd163Timo Sirainenstatic int start_service(struct mt_svc *mt_svc);
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainenstatic int monitor_service_init(struct sbus_connection *conn, void *data);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainenstatic int service_send_ping(struct mt_svc *svc);
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainenstatic int service_signal_reset_offline(struct mt_svc *svc);
ace3c14e47a5a865df8aeea2fabc993b609dd163Timo Sirainenstatic void ping_check(DBusPendingCall *pending, void *data);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainenstatic void set_tasks_checker(struct mt_svc *srv);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic int monitor_kill_service (struct mt_svc *svc);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic int get_service_config(struct mt_ctx *ctx, const char *name,
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic int get_provider_config(struct mt_ctx *ctx, const char *name,
dd8de60250511cc729b67249e61dfc6b4debff11Timo Sirainenstatic int add_new_provider(struct mt_ctx *ctx,
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic int mark_service_as_started(struct mt_svc *svc);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic int monitor_cleanup(void);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainenstatic void network_status_change_cb(void *cb_data)
7394389230750c45b105cdefb5850c81cae8cdc0Timo Sirainen struct mt_ctx *ctx = (struct mt_ctx *) cb_data;
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen DEBUG(SSSDBG_TRACE_INTERNAL, ("A networking status change detected "
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen "signaling providers to reset offline status\n"));
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (iter = ctx->svc_list; iter; iter = iter->next) {
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen /* Don't signal services, only providers */
659fe5d24825b160cae512538088020d97a60239Timo Sirainen/* dbus_get_monitor_version
659fe5d24825b160cae512538088020d97a60239Timo Sirainen * Return the monitor version over D-BUS */
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainenstatic int get_monitor_version(DBusMessage *message,
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen reply = dbus_message_new_method_return(message);
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainen /* send reply back */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic int add_svc_conn_spy(struct mt_svc *svc);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen/* registers a new client.
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen * if operation is successful also sends back the Monitor version */
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainenstatic int client_registration(DBusMessage *message,
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen mini = talloc_get_type(data, struct mon_init_conn);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen DEBUG(0, ("Connection holds no valid init data\n"));
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen /* First thing, cancel the timeout */
567e57b09a49bbb2a146b13f8617698eb56237feTimo Sirainen dbret = dbus_message_get_args(message, &dbus_error,
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainen DEBUG(1, ("Failed to parse message, killing connection\n"));
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
7394389230750c45b105cdefb5850c81cae8cdc0Timo Sirainen /* FIXME: should we just talloc_zfree(conn) ? */
f3a258b0930595dedaa4057d4104d99d4409a10eTimo Sirainen DEBUG(4, ("Received ID registration: (%s,%d)\n", svc_name, svc_ver));
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen /* search this service in the list */
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen DEBUG(0, ("Unable to find peer [%s] in list of services,"
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen /* FIXME: should we just talloc_zfree(conn) ? */
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen /* Fill in svc structure with connection data */
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen DEBUG(1, ("Failed to mark service [%s]!\n", svc_name));
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* reply that all is ok */
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen reply = dbus_message_new_method_return(message);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* send reply back */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* init complete, get rid of temp init context */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen struct mt_svc *svc = talloc_get_type(mem, struct mt_svc);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* try to delist service */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* Cancel any pending pings */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* svc is beeing freed, neutralize the spy */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen talloc_set_destructor((TALLOC_CTX *)svc->conn_spy, NULL);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen if (svc->type == MT_SVC_SERVICE && svc->svc_started
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen && svc->mt_ctx != NULL && svc->mt_ctx->started_services > 0) {
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen struct svc_spy *spy = talloc_get_type(mem, struct svc_spy);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* svc->conn has been freed, NULL the pointer in svc */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainenstatic int add_svc_conn_spy(struct mt_svc *svc)
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen talloc_set_destructor((TALLOC_CTX *)spy, svc_spy_destructor);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainenstatic int mark_service_as_started(struct mt_svc *svc)
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen DEBUG(5, ("Marking %s as started.\n", svc->name));
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* we need to attach a spy to the connection structure so that if some code
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen * frees it we can zero it out in the service structure. Otherwise we may
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen * try to access or even free, freed memory. */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* check if all providers are up */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen for (iter = ctx->svc_list; iter; iter = iter->next) {
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen DEBUG(5, ("Still waiting on %s provider.\n", iter->name));
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* there are still unstarted providers */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* then start all services */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* create the pid file if all services are alive */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen if (!ctx->pid_file_created && ctx->started_services == ctx->num_services) {
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen DEBUG(SSSDBG_TRACE_FUNC, ("All services have successfully started, "
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen "creating pid file\n"));
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen ("Error creating pidfile: %s/%s.pid! (%d [%s])\n",
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainenstatic void services_startup_timeout(struct tevent_context *ev,
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen struct mt_ctx *ctx = talloc_get_type(ptr, struct mt_ctx);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen "forcing services startup!\n"));
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* then start all services */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainenstatic int add_services_startup_timeout(struct mt_ctx *ctx)
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* 5 seconds should be plenty */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen to = tevent_add_timer(ctx->ev, ctx, tv, services_startup_timeout, ctx);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen { MON_SRV_METHOD_VERSION, get_monitor_version },
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen { MON_SRV_METHOD_REGISTER, client_registration },
d143077bd518de129b8d446fb58e003903e50867Timo Sirainenstruct sbus_interface monitor_server_interface = {
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen/* monitor_dbus_init
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen * Set up the monitor service as a D-BUS Server */
d143077bd518de129b8d446fb58e003903e50867Timo Sirainenstatic int monitor_dbus_init(struct mt_ctx *ctx)
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ret = monitor_get_sbus_address(ctx, &monitor_address);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen false, &ctx->sbus_srv, monitor_service_init, ctx);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic void tasks_check_handler(struct tevent_context *ev,
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen struct mt_svc *svc = talloc_get_type(ptr, struct mt_svc);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* all fine */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen DEBUG(1,("Child (%s) not responding! (yet)\n", svc->name));
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* TODO: should we tear it down ? */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen DEBUG(1,("Sending a message to service (%s) failed!!\n", svc->name));
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen /* too long since we last heard of this process */
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen ("Killing service [%s], not responding to pings!\n",
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* Kill the service. The SIGCHLD handler will restart it */
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* all fine, set up the task checker again */
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic void set_tasks_checker(struct mt_svc *svc)
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen te = tevent_add_timer(svc->mt_ctx->ev, svc, tv, tasks_check_handler, svc);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen DEBUG(0, ("failed to add event, monitor offline for [%s]!\n",
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen /* FIXME: shutdown ? */
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainenstatic void mt_svc_sigkill(struct tevent_context *ev,
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainenstatic int monitor_kill_service (struct mt_svc *svc)
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ("Sending signal to child (%s:%d) failed! "
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen "Ignore and pretend child is dead.\n",
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* Set up a timer to send SIGKILL if this process
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen * doesn't exit within sixty seconds
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen tv = tevent_timeval_current_ofs(svc->kill_time, 0);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen svc->sigkill_ev = tevent_add_timer(svc->mt_ctx->ev, svc, tv,
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstatic void mt_svc_sigkill(struct tevent_context *ev,
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen struct mt_svc *svc = talloc_get_type(ptr, struct mt_svc);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen ("[%s][%d] is not responding to SIGTERM. Sending SIGKILL.\n",
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen ("Sending signal to child (%s:%d) failed! "
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen "Ignore and pretend child is dead.\n",
d143077bd518de129b8d446fb58e003903e50867Timo Sirainenstatic void reload_reply(DBusPendingCall *pending, void *data)
7394389230750c45b105cdefb5850c81cae8cdc0Timo Sirainen struct mt_svc *svc = talloc_get_type(data, struct mt_svc);
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen reply = dbus_pending_call_steal_reply(pending);
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen /* reply should never be null. This function shouldn't be called
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen * until reply is valid or timeout has occurred. If reply is NULL
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen * here, something is seriously wrong and we should bail out.
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen DEBUG(0, ("A reply callback was called but no reply was received"
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen " and no timeout occurred\n"));
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen /* Destroy this connection */
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen /* TODO: Handle cases where the call has timed out or returned
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen * with an error.
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainenstatic int service_signal_dns_reload(struct mt_svc *svc);
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainenstatic int monitor_update_resolv(struct config_file_ctx *file_ctx,
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen DEBUG(2, ("Resolv.conf has been updated. Reloading.\n"));
b2105c78f0fd58281317e6d777ded860f33153a3Timo Sirainen /* Signal all services to reload their DNS configuration */
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainen for(cur_svc = file_ctx->mt_ctx->svc_list; cur_svc; cur_svc = cur_svc->next) {
690af4a90eaf8611c2573d34126bb7a852c50a44Timo Sirainenstatic int service_signal(struct mt_svc *svc, const char *svc_signal)
b2105c78f0fd58281317e6d777ded860f33153a3Timo Sirainen if (svc->provider && strcasecmp(svc->provider, "local") == 0) {
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainen /* The local provider requires no signaling */
ea546eaab672d441e180b7619d4750be813c08d8Timo Sirainen /* Avoid a race condition where we are trying to
ea546eaab672d441e180b7619d4750be813c08d8Timo Sirainen * order a service to reload that hasn't started
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen DEBUG(1,("Could not signal service [%s].\n", svc->name));
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenstatic int service_signal_dns_reload(struct mt_svc *svc)
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen return service_signal(svc, MON_CLI_METHOD_RES_INIT);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenstatic int service_signal_offline(struct mt_svc *svc)
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen return service_signal(svc, MON_CLI_METHOD_OFFLINE);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenstatic int service_signal_reset_offline(struct mt_svc *svc)
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen return service_signal(svc, MON_CLI_METHOD_RESET_OFFLINE);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenstatic int service_signal_rotate(struct mt_svc *svc)
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen return service_signal(svc, MON_CLI_METHOD_ROTATE);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenstatic int service_signal_clear_memcache(struct mt_svc *svc)
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen return service_signal(svc, MON_CLI_METHOD_CLEAR_MEMCACHE);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenstatic int check_domain_ranges(struct sss_domain_info *domains)
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen struct sss_domain_info *dom = domains, *other = NULL;
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen if (dom->id_max && dom->id_min > dom->id_max) {
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen ("Domain '%s' does not have a valid ID range\n", dom->name));
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen id_max = MIN((dom->id_max ? dom->id_max : UINT32_MAX),
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen (other->id_max ? other->id_max : UINT32_MAX));
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ("Domains '%s' and '%s' overlap in range %u - %u\n",
d143077bd518de129b8d446fb58e003903e50867Timo Sirainenstatic int check_local_domain_unique(struct sss_domain_info *domains)
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen if (strcasecmp(dom->provider, "local") == 0) {
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen const char *known_services[] = { "nss", "pam", "sudo", "autofs", "ssh",
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen /* Check if services we are about to start are in the list if known */
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen for (i = 0; services[i]; i++) {
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen if (strcasecmp(services[i], known_services[ii]) == 0) {
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ctx->service_id_timeout = timeout_seconds * 1000; /* service_id_timeout is in ms */
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ret = confdb_get_string_as_list(ctx->cdb, ctx->service_ctx,
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ret = confdb_get_domains(ctx->cdb, &ctx->domains);
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ret = check_local_domain_unique(ctx->domains);
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen DEBUG(0, ("More than one local domain configured.\n"));
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen /* Check UID/GID overlaps */
d143077bd518de129b8d446fb58e003903e50867Timo Sirainenstatic errno_t get_ping_config(struct mt_ctx *ctx, const char *path,
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen ("Failed to get ping timeout for '%s'\n", svc->name));
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainen /* 'timeout = 0' should be translated to the default */
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen ("Failed to get kill timeout for %s\n", svc->name));
7394389230750c45b105cdefb5850c81cae8cdc0Timo Sirainen /* 'force_timeout = 0' should be translated to the default */
ea546eaab672d441e180b7619d4750be813c08d8Timo Sirainenstatic int get_service_config(struct mt_ctx *ctx, const char *name,
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen talloc_set_destructor((TALLOC_CTX *)svc, svc_destructor);
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainen path = talloc_asprintf(svc, CONFDB_SERVICE_PATH_TMPL, svc->name);
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainen DEBUG(0,("Failed to start service '%s'\n", svc->name));
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainen svc, "%s/sssd_%s", SSSD_LIBEXEC_PATH, svc->name
7e94cf9d70ce9fdeccb7a85ff400b899e6386f36Timo Sirainen if (cmdline_debug_level != SSSDBG_UNRESOLVED) {
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen svc->command, " -d %#.4x", cmdline_debug_level
90a6478adca64af3b909498711bb034a5ddb79a9Timo Sirainen if (cmdline_debug_timestamps != SSSDBG_TIMESTAMP_UNRESOLVED) {
90a6478adca64af3b909498711bb034a5ddb79a9Timo Sirainen svc->command, " --debug-timestamps=%d", cmdline_debug_timestamps
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen if (cmdline_debug_microseconds != SSSDBG_MICROSECONDS_UNRESOLVED) {
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen ("Failed to get ping timeouts for %s\n", svc->name));
f172291ed740e6af3ce3e7c9c2ef0fe1d3ad7963Timo Sirainen DEBUG(0,("Failed to start service '%s'\n", svc->name));
int ret;
char *path;
if (!svc) {
return ENOMEM;
return ENOMEM;
return ENOMEM;
if (!path) {
return ENOMEM;
return ret;
return ret;
return ret;
return EIO;
return ENOMEM;
return ENOMEM;
return ENOMEM;
return ENOMEM;
if (debug_to_file) {
return ENOMEM;
return EOK;
const char *name,
int restarts)
int ret;
name));
return ret;
return ENOENT;
return ret;
int signum,
int count,
void *siginfo,
void *private_data)
static int monitor_cleanup(void)
int ret;
errno = 0;
return ret;
return EOK;
int signum,
int count,
void *siginfo,
void *private_data)
int status;
int kret;
bool killed;
killed = false;
errno = 0;
if (kret < 0) {
error = 0;
errno = 0;
} else if (pid != 0) {
error = 0;
killed = true;
if (!killed) {
} while (!killed);
#if HAVE_GETPGRP
error = 0;
errno = 0;
exit(0);
int ret;
if (ret == 0) {
int signum,
int count,
void *siginfo,
void *private_data)
int signum,
int count,
void *siginfo,
void *private_data)
const char *config_file,
if(!ctx) {
return ENOMEM;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
#ifdef HAVE_SYS_INOTIFY_H
if (!te) {
struct rewatch_ctx {
char *buf;
char *name;
if (!tmp_ctx) return;
if (!buf) {
goto done;
errno = 0;
goto done;
if (!name) {
goto done;
errno = 0;
goto done;
if (!cb) {
goto done;
if(!rw_ctx) {
goto done;
goto done;
done:
const char *file,
bool ignore_missing);
int err;
if (ret < 0) {
#ifdef HAVE_SYS_INOTIFY_H
return err;
if (fd_args < 0) {
return EINVAL;
if (ret < 0) {
return EINVAL;
file_ctx);
if (!tfd) {
return EIO;
if(!cb) {
return EIO;
return ENOMEM;
return err;
return EOK;
return EINVAL;
const char *file,
bool ignore_missing)
bool use_inotify;
if (ret < 0) {
return EOK;
return err;
true, &use_inotify);
return ret;
if (use_inotify) {
use_inotify = false;
if (!use_inotify) {
return ret;
const char *file,
bool ignore_missing)
if (ret < 0) {
return EOK;
return err;
if (!cb) {
return ENOMEM;
return ENOMEM;
return EIO;
return EOK;
const char *config_file)
char *rcachedir;
int num_providers;
int ret;
int error;
&rcachedir);
return ret;
errno = 0;
if (ret < 0) {
return EIO;
return EIO;
return EIO;
return EIO;
return EIO;
return ret;
/* Watch for changes to the DNS resolv.conf */
monitor_update_resolv,true);
return ret;
if (!tmp_ctx) {
return ENOMEM;
return ret;
return ret;
return ret;
num_providers = 0;
return ret;
if (num_providers > 0) {
return ret;
return EOK;
if (!mini) {
return ENOMEM;
return ENOMEM;
return EOK;
int ret;
return ENXIO;
if (!msg) {
return ENOMEM;
return ret;
const char *dbus_error_name;
int type;
if (!svc) {
if (!reply) {
goto done;
switch (type) {
case DBUS_MESSAGE_TYPE_ERROR:
if (!dbus_error_name) {
done:
return ENOMEM;
return EOK;
char **args;
int opt;
int opt_daemon = 0;
int opt_interactive = 0;
int opt_version = 0;
int flags = 0;
int ret;
switch(opt) {
if (opt_version) {
return EXIT_SUCCESS;
if (uid != 0) {
if (!tmp_ctx) {
if (opt_config_file) {
if (!config_file) {
if (debug_to_file) {
if (ret) {
#ifdef USE_KEYRING