From 83bf46f4066e3d5e838a32357c201de9bd6ecdfd Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Wed, 12 Feb 2014 10:12:59 -0500 Subject: Update DEBUG* invocations to use new levels Use a script to update DEBUG* macro invocations, which use literal numbers for levels, to use bitmask macros instead: grep -rl --include '*.[hc]' DEBUG . | while read f; do mv "$f"{,.orig} perl -e 'use strict; use File::Slurp; my @map=qw" SSSDBG_FATAL_FAILURE SSSDBG_CRIT_FAILURE SSSDBG_OP_FAILURE SSSDBG_MINOR_FAILURE SSSDBG_CONF_SETTINGS SSSDBG_FUNC_DATA SSSDBG_TRACE_FUNC SSSDBG_TRACE_LIBS SSSDBG_TRACE_INTERNAL SSSDBG_TRACE_ALL "; my $text=read_file(\*STDIN); my $repl; $text=~s/ ^ ( .* \b (DEBUG|DEBUG_PAM_DATA|DEBUG_GR_MEM) \s* \(\s* )( [0-9] )( \s*, ) ( \s* ) ( .* ) $ / $repl = $1.$map[$3].$4.$5.$6, length($repl) <= 80 ? $repl : $1.$map[$3].$4."\n".(" " x length($1)).$6 /xmge; print $text; ' < "$f.orig" > "$f" rm "$f.orig" done Reviewed-by: Jakub Hrozek Reviewed-by: Stephen Gallagher Reviewed-by: Simo Sorce --- src/monitor/monitor.c | 164 +++++++++++++++++++++++++----------------- src/monitor/monitor_netlink.c | 32 +++++---- src/monitor/monitor_sbus.c | 27 +++---- 3 files changed, 130 insertions(+), 93 deletions(-) (limited to 'src/monitor') diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index d4b2f9e36..8a0844bbc 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -268,7 +268,7 @@ static int client_registration(DBusMessage *message, data = sbus_conn_get_private_data(conn); mini = talloc_get_type(data, struct mon_init_conn); if (!mini) { - DEBUG(0, "Connection holds no valid init data\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Connection holds no valid init data\n"); return EINVAL; } @@ -282,14 +282,16 @@ static int client_registration(DBusMessage *message, DBUS_TYPE_UINT16, &svc_ver, DBUS_TYPE_INVALID); if (!dbret) { - DEBUG(1, "Failed to parse message, killing connection\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to parse message, killing connection\n"); if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error); sbus_disconnect(conn); /* FIXME: should we just talloc_zfree(conn) ? */ goto done; } - DEBUG(4, "Received ID registration: (%s,%d)\n", svc_name, svc_ver); + DEBUG(SSSDBG_CONF_SETTINGS, + "Received ID registration: (%s,%d)\n", svc_name, svc_ver); /* search this service in the list */ svc = mini->ctx->svc_list; @@ -301,7 +303,8 @@ static int client_registration(DBusMessage *message, svc = svc->next; } if (!svc) { - DEBUG(0, "Unable to find peer [%s] in list of services," + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to find peer [%s] in list of services," " killing connection!\n", svc_name); sbus_disconnect(conn); /* FIXME: should we just talloc_zfree(conn) ? */ @@ -313,7 +316,7 @@ static int client_registration(DBusMessage *message, ret = mark_service_as_started(svc); if (ret) { - DEBUG(1, "Failed to mark service [%s]!\n", svc_name); + DEBUG(SSSDBG_CRIT_FAILURE, "Failed to mark service [%s]!\n", svc_name); goto done; } @@ -411,7 +414,7 @@ static int mark_service_as_started(struct mt_svc *svc) int ret; int i; - DEBUG(5, "Marking %s as started.\n", svc->name); + DEBUG(SSSDBG_FUNC_DATA, "Marking %s as started.\n", svc->name); svc->svc_started = true; /* we need to attach a spy to the connection structure so that if some code @@ -419,7 +422,7 @@ static int mark_service_as_started(struct mt_svc *svc) * try to access or even free, freed memory. */ ret = add_svc_conn_spy(svc); if (ret) { - DEBUG(0, "Failed to attch spy\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to attch spy\n"); goto done; } @@ -428,7 +431,8 @@ static int mark_service_as_started(struct mt_svc *svc) /* check if all providers are up */ for (iter = ctx->svc_list; iter; iter = iter->next) { if (iter->provider && !iter->svc_started) { - DEBUG(5, "Still waiting on %s provider.\n", iter->name); + DEBUG(SSSDBG_FUNC_DATA, + "Still waiting on %s provider.\n", iter->name); break; } } @@ -440,7 +444,7 @@ static int mark_service_as_started(struct mt_svc *svc) ctx->services_started = true; - DEBUG(4, "Now starting services!\n"); + DEBUG(SSSDBG_CONF_SETTINGS, "Now starting services!\n"); /* then start all services */ for (i = 0; ctx->services[i]; i++) { add_new_service(ctx, ctx->services[i], 0); @@ -486,16 +490,16 @@ static void services_startup_timeout(struct tevent_context *ev, struct mt_ctx *ctx = talloc_get_type(ptr, struct mt_ctx); int i; - DEBUG(6, "Handling timeout\n"); + DEBUG(SSSDBG_TRACE_FUNC, "Handling timeout\n"); if (!ctx->services_started) { - DEBUG(1, "Providers did not start in time, " + DEBUG(SSSDBG_CRIT_FAILURE, "Providers did not start in time, " "forcing services startup!\n"); ctx->services_started = true; - DEBUG(4, "Now starting services!\n"); + DEBUG(SSSDBG_CONF_SETTINGS, "Now starting services!\n"); /* then start all services */ for (i = 0; ctx->services[i]; i++) { add_new_service(ctx, ctx->services[i], 0); @@ -512,7 +516,7 @@ static int add_services_startup_timeout(struct mt_ctx *ctx) tv = tevent_timeval_current_ofs(5, 0); to = tevent_add_timer(ctx->ev, ctx, tv, services_startup_timeout, ctx); if (!to) { - DEBUG(0,"Out of memory?!\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"Out of memory?!\n"); return ENOMEM; } @@ -568,12 +572,14 @@ static void tasks_check_handler(struct tevent_context *ev, break; case ENXIO: - DEBUG(1,"Child (%s) not responding! (yet)\n", svc->name); + DEBUG(SSSDBG_CRIT_FAILURE, + "Child (%s) not responding! (yet)\n", svc->name); break; default: /* TODO: should we tear it down ? */ - DEBUG(1,"Sending a message to service (%s) failed!!\n", svc->name); + DEBUG(SSSDBG_CRIT_FAILURE, + "Sending a message to service (%s) failed!!\n", svc->name); break; } @@ -605,7 +611,8 @@ static void set_tasks_checker(struct mt_svc *svc) tv.tv_usec = 0; te = tevent_add_timer(svc->mt_ctx->ev, svc, tv, tasks_check_handler, svc); if (te == NULL) { - DEBUG(0, "failed to add event, monitor offline for [%s]!\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "failed to add event, monitor offline for [%s]!\n", svc->name); /* FIXME: shutdown ? */ } @@ -688,7 +695,8 @@ static void reload_reply(DBusPendingCall *pending, void *data) * until reply is valid or timeout has occurred. If reply is NULL * here, something is seriously wrong and we should bail out. */ - DEBUG(0, "A reply callback was called but no reply was received" + DEBUG(SSSDBG_FATAL_FAILURE, + "A reply callback was called but no reply was received" " and no timeout occurred\n"); /* Destroy this connection */ sbus_disconnect(svc->conn); @@ -710,7 +718,7 @@ static int monitor_update_resolv(struct config_file_ctx *file_ctx, { int ret; struct mt_svc *cur_svc; - DEBUG(2, "Resolv.conf has been updated. Reloading.\n"); + DEBUG(SSSDBG_OP_FAILURE, "Resolv.conf has been updated. Reloading.\n"); ret = res_init(); if(ret != 0) { @@ -964,7 +972,7 @@ int get_monitor_config(struct mt_ctx *ctx) CONFDB_MONITOR_ACTIVE_SERVICES, &ctx->services); if (ret != EOK) { - DEBUG(0, "No services configured!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "No services configured!\n"); return EINVAL; } @@ -977,7 +985,7 @@ int get_monitor_config(struct mt_ctx *ctx) badsrv = check_services(ctx->services); if (badsrv != NULL) { - DEBUG(0, "Invalid service %s\n", badsrv); + DEBUG(SSSDBG_FATAL_FAILURE, "Invalid service %s\n", badsrv); return EINVAL; } @@ -993,13 +1001,13 @@ int get_monitor_config(struct mt_ctx *ctx) } ret = confdb_get_domains(ctx->cdb, &ctx->domains); if (ret != EOK) { - DEBUG(0, "No domains configured.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "No domains configured.\n"); return ret; } ret = check_local_domain_unique(ctx->domains); if (ret != EOK) { - DEBUG(0, "More than one local domain configured.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "More than one local domain configured.\n"); return ret; } @@ -1097,7 +1105,7 @@ static int get_service_config(struct mt_ctx *ctx, const char *name, CONFDB_SERVICE_COMMAND, NULL, &svc->command); if (ret != EOK) { - DEBUG(0,"Failed to start service '%s'\n", svc->name); + DEBUG(SSSDBG_FATAL_FAILURE,"Failed to start service '%s'\n", svc->name); talloc_free(svc); return ret; } @@ -1184,7 +1192,7 @@ static int add_new_service(struct mt_ctx *ctx, ret = start_service(svc); if (ret != EOK) { - DEBUG(0,"Failed to start service '%s'\n", svc->name); + DEBUG(SSSDBG_FATAL_FAILURE,"Failed to start service '%s'\n", svc->name); talloc_free(svc); } @@ -1232,7 +1240,8 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name, CONFDB_DOMAIN_ID_PROVIDER, NULL, &svc->provider); if (ret != EOK) { - DEBUG(0, "Failed to find ID provider from [%s] configuration\n", name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Failed to find ID provider from [%s] configuration\n", name); talloc_free(svc); return ret; } @@ -1241,7 +1250,8 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name, CONFDB_DOMAIN_COMMAND, NULL, &svc->command); if (ret != EOK) { - DEBUG(0, "Failed to find command from [%s] configuration\n", name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Failed to find command from [%s] configuration\n", name); talloc_free(svc); return ret; } @@ -1329,7 +1339,8 @@ static int add_new_provider(struct mt_ctx *ctx, ret = get_provider_config(ctx, name, &svc); if (ret != EOK) { - DEBUG(0, "Could not get provider configuration for [%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not get provider configuration for [%s]\n", name); return ret; } @@ -1347,7 +1358,7 @@ static int add_new_provider(struct mt_ctx *ctx, ret = start_service(svc); if (ret != EOK) { - DEBUG(0,"Failed to start service '%s'\n", svc->name); + DEBUG(SSSDBG_FATAL_FAILURE,"Failed to start service '%s'\n", svc->name); talloc_free(svc); } @@ -1364,7 +1375,7 @@ static void monitor_hup(struct tevent_context *ev, struct mt_ctx *ctx = talloc_get_type(private_data, struct mt_ctx); struct mt_svc *cur_svc; - DEBUG(1, "Received SIGHUP.\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Received SIGHUP.\n"); /* Send D-Bus message to other services to rotate their logs. * NSS service receives also message to clear memory caches. */ @@ -1417,13 +1428,14 @@ static void monitor_quit(struct mt_ctx *mt_ctx, int ret) } killed = false; - DEBUG(1, "Terminating [%s][%d]\n", svc->name, svc->pid); + DEBUG(SSSDBG_CRIT_FAILURE, + "Terminating [%s][%d]\n", svc->name, svc->pid); do { errno = 0; kret = kill(svc->pid, SIGTERM); if (kret < 0) { error = errno; - DEBUG(1, "Couldn't kill [%s][%d]: [%s]\n", + DEBUG(SSSDBG_CRIT_FAILURE, "Couldn't kill [%s][%d]: [%s]\n", svc->name, svc->pid, strerror(error)); } @@ -1437,7 +1449,8 @@ static void monitor_quit(struct mt_ctx *mt_ctx, int ret) if (error == ECHILD) { killed = true; } else if (error != EINTR) { - DEBUG(0, "[%d][%s] while waiting for [%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "[%d][%s] while waiting for [%s]\n", error, strerror(error), svc->name); /* Forcibly kill this child */ kill(svc->pid, SIGKILL); @@ -1446,11 +1459,14 @@ static void monitor_quit(struct mt_ctx *mt_ctx, int ret) } else if (pid != 0) { error = 0; if (WIFEXITED(status)) { - DEBUG(1, "Child [%s] exited gracefully\n", svc->name); + DEBUG(SSSDBG_CRIT_FAILURE, + "Child [%s] exited gracefully\n", svc->name); } else if (WIFSIGNALED(status)) { - DEBUG(1, "Child [%s] terminated with a signal\n", svc->name); + DEBUG(SSSDBG_CRIT_FAILURE, + "Child [%s] terminated with a signal\n", svc->name); } else { - DEBUG(0, "Child [%s] did not exit cleanly\n", svc->name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Child [%s] did not exit cleanly\n", svc->name); /* Forcibly kill this child */ kill(svc->pid, SIGKILL); } @@ -1596,14 +1612,14 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx, cdb_file = talloc_asprintf(ctx, "%s/%s", DB_PATH, CONFDB_FILE); if (cdb_file == NULL) { - DEBUG(0,"Out of memory, aborting!\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"Out of memory, aborting!\n"); ret = ENOMEM; goto done; } ret = confdb_init(ctx, &ctx->cdb, cdb_file); if (ret != EOK) { - DEBUG(0,"The confdb initialization failed\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"The confdb initialization failed\n"); goto done; } @@ -1620,25 +1636,26 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx, ret = confdb_init(ctx, &ctx->cdb, cdb_file); if (ret != EOK) { - DEBUG(0,"The confdb initialization failed\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"The confdb initialization failed\n"); goto done; } /* Load special entries */ ret = confdb_create_base(ctx->cdb); if (ret != EOK) { - DEBUG(0, "Unable to load special entries into confdb\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to load special entries into confdb\n"); goto done; } } else if (ret != EOK) { - DEBUG(0, "Fatal error initializing confdb\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Fatal error initializing confdb\n"); goto done; } talloc_zfree(cdb_file); ret = confdb_init_db(config_file, ctx->cdb); if (ret != EOK) { - DEBUG(0, "ConfDB initialization has failed [%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, "ConfDB initialization has failed [%s]\n", sss_strerror(ret)); goto done; } @@ -1697,7 +1714,8 @@ static void config_file_changed(struct tevent_context *ev, te = tevent_add_timer(ev, ev, tv, process_config_file, file_ctx); if (!te) { - DEBUG(0, "Unable to queue config file update! Exiting.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to queue config file update! Exiting.\n"); kill(getpid(), SIGTERM); return; } @@ -1726,7 +1744,7 @@ static void process_config_file(struct tevent_context *ev, file_ctx = talloc_get_type(ptr, struct config_file_ctx); - DEBUG(1, "Processing config file changes\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Processing config file changes\n"); tmp_ctx = talloc_new(NULL); if (!tmp_ctx) return; @@ -1773,7 +1791,7 @@ static void process_config_file(struct tevent_context *ev, } } if (!cb) { - DEBUG(0, "Unknown watch descriptor\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Unknown watch descriptor\n"); goto done; } @@ -1788,12 +1806,13 @@ static void process_config_file(struct tevent_context *ev, struct tevent_timer *tev; tv.tv_sec = t.tv_sec+5; tv.tv_usec = t.tv_usec; - DEBUG(5, "Restoring inotify watch.\n"); + DEBUG(SSSDBG_FUNC_DATA, "Restoring inotify watch.\n"); cb->retries = 0; rw_ctx = talloc(file_ctx, struct rewatch_ctx); if(!rw_ctx) { - DEBUG(0, "Could not restore inotify watch. Quitting!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not restore inotify watch. Quitting!\n"); close(file_ctx->mt_ctx->inotify_fd); kill(getpid(), SIGTERM); goto done; @@ -1803,7 +1822,8 @@ static void process_config_file(struct tevent_context *ev, tev = tevent_add_timer(ev, rw_ctx, tv, rewatch_config_file, rw_ctx); if (tev == NULL) { - DEBUG(0, "Could not restore inotify watch. Quitting!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not restore inotify watch. Quitting!\n"); close(file_ctx->mt_ctx->inotify_fd); kill(getpid(), SIGTERM); } @@ -1906,7 +1926,8 @@ static void poll_config_file(struct tevent_context *ev, ret = stat(cb->filename, &file_stat); if (ret < 0) { err = errno; - DEBUG(0, "Could not stat file [%s]. Error [%d:%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not stat file [%s]. Error [%d:%s]\n", cb->filename, err, strerror(err)); /* TODO: If the config file is missing, should we shut down? */ return; @@ -1917,7 +1938,7 @@ static void poll_config_file(struct tevent_context *ev, /* Note: this will fire if the modification time changes into the past * as well as the future. */ - DEBUG(1, "Config file changed\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Config file changed\n"); cb->modified = file_stat.st_mtime; /* Tell the monitor to signal the children */ @@ -1931,7 +1952,8 @@ static void poll_config_file(struct tevent_context *ev, file_ctx->timer = tevent_add_timer(ev, file_ctx->parent_ctx, tv, poll_config_file, file_ctx); if (!file_ctx->timer) { - DEBUG(0, "Error: Config file no longer monitored for changes!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Error: Config file no longer monitored for changes!\n"); } } @@ -1949,7 +1971,8 @@ static int try_inotify(struct config_file_ctx *file_ctx, const char *filename, file_ctx->mt_ctx->inotify_fd = inotify_init(); if (file_ctx->mt_ctx->inotify_fd < 0) { err = errno; - DEBUG(0, "Could not initialize inotify, error [%d:%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not initialize inotify, error [%d:%s]\n", err, strerror(err)); return err; } @@ -1995,7 +2018,8 @@ static int try_inotify(struct config_file_ctx *file_ctx, const char *filename, cb->filename, IN_MODIFY); if (cb->wd < 0) { err = errno; - DEBUG(0, "Could not add inotify watch for file [%s]. Error [%d:%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not add inotify watch for file [%s]. Error [%d:%s]\n", cb->filename, err, strerror(err)); close(file_ctx->mt_ctx->inotify_fd); return err; @@ -2154,7 +2178,7 @@ int monitor_process_init(struct mt_ctx *ctx, ret = setenv("KRB5RCACHEDIR", rcachedir, 1); if (ret < 0) { error = errno; - DEBUG(1, + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set KRB5RCACHEDIR: %s." "Will attempt to use libkrb5 defaults\n", strerror(error)); @@ -2250,7 +2274,8 @@ int monitor_process_init(struct mt_ctx *ctx, ret = setup_netlink(ctx, ctx->ev, network_status_change_cb, ctx, &ctx->nlctx); if (ret != EOK) { - DEBUG(2, "Cannot set up listening for network notifications\n"); + DEBUG(SSSDBG_OP_FAILURE, + "Cannot set up listening for network notifications\n"); return ret; } @@ -2296,7 +2321,7 @@ static void init_timeout(struct tevent_context *ev, { struct mon_init_conn *mini; - DEBUG(2, "Client timed out before Identification!\n"); + DEBUG(SSSDBG_OP_FAILURE, "Client timed out before Identification!\n"); mini = talloc_get_type(ptr, struct mon_init_conn); @@ -2322,7 +2347,7 @@ static int monitor_service_init(struct sbus_connection *conn, void *data) mini = talloc(conn, struct mon_init_conn); if (!mini) { - DEBUG(0,"Out of memory?!\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"Out of memory?!\n"); talloc_zfree(conn); return ENOMEM; } @@ -2334,7 +2359,7 @@ static int monitor_service_init(struct sbus_connection *conn, void *data) mini->timeout = tevent_add_timer(ctx->ev, mini, tv, init_timeout, mini); if (!mini->timeout) { - DEBUG(0,"Out of memory?!\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"Out of memory?!\n"); talloc_zfree(conn); return ENOMEM; } @@ -2356,11 +2381,11 @@ static int service_send_ping(struct mt_svc *svc) int ret; if (!svc->conn) { - DEBUG(8, "Service not yet initialized\n"); + DEBUG(SSSDBG_TRACE_INTERNAL, "Service not yet initialized\n"); return ENXIO; } - DEBUG(4,"Pinging %s\n", svc->name); + DEBUG(SSSDBG_CONF_SETTINGS,"Pinging %s\n", svc->name); /* * Set up identity request @@ -2372,7 +2397,7 @@ static int service_send_ping(struct mt_svc *svc) MONITOR_INTERFACE, MON_CLI_METHOD_PING); if (!msg) { - DEBUG(0,"Out of memory?!\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"Out of memory?!\n"); talloc_zfree(svc->conn); return ENOMEM; } @@ -2407,7 +2432,8 @@ static void ping_check(DBusPendingCall *pending, void *data) * until reply is valid or timeout has occurred. If reply is NULL * here, something is seriously wrong and we should bail out. */ - DEBUG(0, "A reply callback was called but no reply was received" + DEBUG(SSSDBG_FATAL_FAILURE, + "A reply callback was called but no reply was received" " and no timeout occurred\n"); /* Destroy this connection */ @@ -2421,7 +2447,7 @@ static void ping_check(DBusPendingCall *pending, void *data) /* ok peer replied, * make sure we reset the failure counter in the service structure */ - DEBUG(4,"Service %s replied to ping\n", svc->name); + DEBUG(SSSDBG_CONF_SETTINGS,"Service %s replied to ping\n", svc->name); svc->failed_pongs = 0; break; @@ -2475,7 +2501,7 @@ static int start_service(struct mt_svc *svc) struct tevent_timer *te; struct timeval tv; - DEBUG(4,"Queueing service %s for startup\n", svc->name); + DEBUG(SSSDBG_CONF_SETTINGS,"Queueing service %s for startup\n", svc->name); tv = tevent_timeval_current(); @@ -2488,7 +2514,8 @@ static int start_service(struct mt_svc *svc) te = tevent_add_timer(svc->mt_ctx->ev, svc, tv, service_startup_handler, svc); if (te == NULL) { - DEBUG(0, "Unable to queue service %s for startup\n", svc->name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to queue service %s for startup\n", svc->name); return ENOMEM; } return EOK; @@ -2511,7 +2538,8 @@ static void service_startup_handler(struct tevent_context *ev, mt_svc->pid = fork(); if (mt_svc->pid != 0) { if (mt_svc->pid == -1) { - DEBUG(0, "Could not fork child to start service [%s]. " + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not fork child to start service [%s]. " "Continuing.\n", mt_svc->name); return; } @@ -2548,7 +2576,8 @@ static void service_startup_handler(struct tevent_context *ev, /* If we are here, exec() has failed * Print errno and abort quickly */ - DEBUG(0,"Could not exec %s, reason: %s\n", mt_svc->command, strerror(errno)); + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not exec %s, reason: %s\n", mt_svc->command, strerror(errno)); /* We have to call _exit() instead of exit() here * because a bug in D-BUS will cause the server to @@ -2604,7 +2633,8 @@ static void mt_svc_exit_handler(int pid, int wait_status, void *pvt) "Child [%s] terminated with signal [%d]\n", svc->name, WTERMSIG(wait_status)); } else { - DEBUG(0, "Child [%s] did not exit cleanly\n", svc->name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Child [%s] did not exit cleanly\n", svc->name); /* Forcibly kill this child, just in case */ kill(svc->pid, SIGKILL); diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c index 24fbed58d..b4d636191 100644 --- a/src/monitor/monitor_netlink.c +++ b/src/monitor/monitor_netlink.c @@ -155,7 +155,8 @@ static bool has_wireless_extension(const char *ifname) s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) { ret = errno; - DEBUG(2, "Could not open socket: [%d] %s\n", ret, strerror(ret)); + DEBUG(SSSDBG_OP_FAILURE, + "Could not open socket: [%d] %s\n", ret, strerror(ret)); return false; } @@ -320,7 +321,7 @@ static bool nlw_accept_message(struct nlw_handle *nlp, uint32_t local_port; if (snl == NULL) { - DEBUG(3, "Malformed message, skipping\n"); + DEBUG(SSSDBG_MINOR_FAILURE, "Malformed message, skipping\n"); return false; } @@ -338,7 +339,7 @@ static bool nlw_accept_message(struct nlw_handle *nlp, } if (accept_msg == false) { - DEBUG(9, "ignoring netlink message from PID %d", + DEBUG(SSSDBG_TRACE_ALL, "ignoring netlink message from PID %d", hdr->nlmsg_pid); } @@ -394,13 +395,13 @@ static bool nlw_is_link_object(struct nl_object *obj) filter = rtnl_link_alloc(); if (!filter) { - DEBUG(0, "Allocation error!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Allocation error!\n"); is_link_object = false; } /* Ensure it's a link object */ if (!nl_object_match_filter(obj, OBJ_CAST(filter))) { - DEBUG(2, "Not a link object\n"); + DEBUG(SSSDBG_OP_FAILURE, "Not a link object\n"); is_link_object = false; } @@ -438,7 +439,8 @@ static int nlw_group_subscribe(struct nlw_handle *nlp, int group) &group, sizeof(group)); if (ret < 0) { ret = errno; - DEBUG(1, "setsockopt failed (%d): %s\n", ret, strerror(ret)); + DEBUG(SSSDBG_CRIT_FAILURE, + "setsockopt failed (%d): %s\n", ret, strerror(ret)); return ret; } #endif @@ -548,7 +550,7 @@ static int nlw_set_callbacks(struct nlw_handle *nlp, void *data) ret = nl_cb_set(cb, NL_CB_MSG_IN, NL_CB_CUSTOM, event_msg_recv, data); #endif if (ret != 0) { - DEBUG(1, "Unable to set validation callback\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set validation callback\n"); return ret; } @@ -559,7 +561,7 @@ static int nlw_set_callbacks(struct nlw_handle *nlp, void *data) ret = nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, event_msg_ready, data); #endif if (ret != 0) { - DEBUG(1, "Unable to set receive callback\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set receive callback\n"); return ret; } @@ -715,13 +717,14 @@ static void netlink_fd_handler(struct tevent_context *ev, struct tevent_fd *fde, int ret; if (!nlctx || !nlctx->nlp) { - DEBUG(1, "Invalid netlink handle, this is most likely a bug!\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "Invalid netlink handle, this is most likely a bug!\n"); return; } ret = nl_recvmsgs_default(nlctx->nlp); if (ret != EOK) { - DEBUG(1, "Error while reading from netlink fd\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Error while reading from netlink fd\n"); return; } } @@ -760,7 +763,7 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, /* Register our custom message validation filter */ ret = nlw_set_callbacks(nlctx->nlp, nlctx); if (ret != 0) { - DEBUG(1, "Unable to set callbacks\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set callbacks\n"); ret = EIO; goto fail; } @@ -785,7 +788,7 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, /* Subscribe to the LINK group for internal carrier signals */ ret = nlw_groups_subscribe(nlctx->nlp, groups); if (ret != 0) { - DEBUG(1, "Unable to subscribe to netlink monitor\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to subscribe to netlink monitor\n"); ret = EIO; goto fail; } @@ -799,14 +802,15 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, ret = fcntl(nlfd, F_SETFL, flags | O_NONBLOCK); if (ret < 0) { ret = errno; - DEBUG(1, "Cannot set the netlink fd to nonblocking\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "Cannot set the netlink fd to nonblocking\n"); goto fail; } nlctx->tefd = tevent_add_fd(ev, nlctx, nlfd, TEVENT_FD_READ, netlink_fd_handler, nlctx); if (nlctx->tefd == NULL) { - DEBUG(1, "tevent_add_fd() failed\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "tevent_add_fd() failed\n"); ret = EIO; goto fail; } diff --git a/src/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c index d94116ef4..4b0e221e8 100644 --- a/src/monitor/monitor_sbus.c +++ b/src/monitor/monitor_sbus.c @@ -61,7 +61,8 @@ static void id_callback(DBusPendingCall *pending, void *ptr) * until reply is valid or timeout has occurred. If reply is NULL * here, something is seriously wrong and we should bail out. */ - DEBUG(0, "Severe error. A reply callback was called but no" + DEBUG(SSSDBG_FATAL_FAILURE, + "Severe error. A reply callback was called but no" " reply was received and no timeout occurred\n"); /* FIXME: Destroy this connection ? */ @@ -75,18 +76,19 @@ static void id_callback(DBusPendingCall *pending, void *ptr) DBUS_TYPE_UINT16, &mon_ver, DBUS_TYPE_INVALID); if (!ret) { - DEBUG(1, "Failed to parse message\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Failed to parse message\n"); if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error); /* FIXME: Destroy this connection ? */ goto done; } - DEBUG(4, "Got id ack and version (%d) from Monitor\n", mon_ver); + DEBUG(SSSDBG_CONF_SETTINGS, + "Got id ack and version (%d) from Monitor\n", mon_ver); break; case DBUS_MESSAGE_TYPE_ERROR: - DEBUG(0,"The Monitor returned an error [%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE,"The Monitor returned an error [%s]\n", dbus_message_get_error_name(reply)); /* Falling through to default intentionally*/ default: @@ -120,18 +122,18 @@ int monitor_common_send_id(struct sbus_connection *conn, MON_SRV_INTERFACE, MON_SRV_METHOD_REGISTER); if (msg == NULL) { - DEBUG(0, "Out of memory?!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory?!\n"); return ENOMEM; } - DEBUG(4, "Sending ID: (%s,%d)\n", name, version); + DEBUG(SSSDBG_CONF_SETTINGS, "Sending ID: (%s,%d)\n", name, version); ret = dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_UINT16, &version, DBUS_TYPE_INVALID); if (!ret) { - DEBUG(1, "Failed to build message\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Failed to build message\n"); return EIO; } @@ -197,14 +199,15 @@ errno_t monitor_common_rotate_logs(struct confdb_ctx *confdb, old_debug_level, &debug_level); if (ret != EOK) { - DEBUG(0, "Error reading from confdb (%d) [%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) [%s]\n", ret, strerror(ret)); /* Try to proceed with the old value */ debug_level = old_debug_level; } if (debug_level != old_debug_level) { - DEBUG(0, "Debug level changed to %#.4x\n", debug_level); + DEBUG(SSSDBG_FATAL_FAILURE, + "Debug level changed to %#.4x\n", debug_level); debug_level = debug_convert_old_level(debug_level); } @@ -226,7 +229,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx, /* Set up SBUS connection to the monitor */ ret = monitor_get_sbus_address(NULL, &sbus_address); if (ret != EOK) { - DEBUG(0, "Could not locate monitor address.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Could not locate monitor address.\n"); return ret; } @@ -234,7 +237,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx, intf, &conn, NULL, pvt); if (ret != EOK) { - DEBUG(0, "Failed to connect to monitor services.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n"); talloc_free(sbus_address); return ret; } @@ -243,7 +246,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx, /* Identify ourselves to the monitor */ ret = monitor_common_send_id(conn, svc_name, svc_version); if (ret != EOK) { - DEBUG(0, "Failed to identify to the monitor!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to identify to the monitor!\n"); return ret; } -- cgit