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/responder/common/negcache.c | 42 ++++++++++------- src/responder/common/responder_cmd.c | 3 +- src/responder/common/responder_common.c | 80 ++++++++++++++++++++------------- src/responder/common/responder_dp.c | 11 ++--- 4 files changed, 83 insertions(+), 53 deletions(-) (limited to 'src/responder/common') diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c index eaf9373ad..88dd18fa5 100644 --- a/src/responder/common/negcache.c +++ b/src/responder/common/negcache.c @@ -82,7 +82,7 @@ static int sss_ncache_check_str(struct sss_nc_ctx *ctx, char *str, int ttl) char *ep; int ret; - DEBUG(8, "Checking negative cache for [%s]\n", str); + DEBUG(SSSDBG_TRACE_INTERNAL, "Checking negative cache for [%s]\n", str); data.dptr = NULL; @@ -157,12 +157,12 @@ static int sss_ncache_set_str(struct sss_nc_ctx *ctx, ret = string_to_tdb_data(timest, &data); if (ret != EOK) goto done; - DEBUG(6, "Adding [%s] to negative cache%s\n", + DEBUG(SSSDBG_TRACE_FUNC, "Adding [%s] to negative cache%s\n", str, permanent?" permanently":""); ret = tdb_store(ctx->tdb, key, data, TDB_REPLACE); if (ret != 0) { - DEBUG(1, "Negative cache failed to set entry: [%s]\n", + DEBUG(SSSDBG_CRIT_FAILURE, "Negative cache failed to set entry: [%s]\n", tdb_errorstr(ctx->tdb)); ret = EFAULT; } @@ -631,13 +631,15 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, filter_list[i], &domainname, &name); if (ret != EOK) { - DEBUG(1, "Invalid name in filterUsers list: [%s] (%d)\n", + DEBUG(SSSDBG_CRIT_FAILURE, + "Invalid name in filterUsers list: [%s] (%d)\n", filter_list[i], ret); continue; } if (domainname && strcmp(domainname, dom->name)) { - DEBUG(1, "Mismatch between domain name (%s) and name " + DEBUG(SSSDBG_CRIT_FAILURE, + "Mismatch between domain name (%s) and name " "set in FQN (%s), skipping user %s\n", dom->name, domainname, name); continue; @@ -645,7 +647,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, ret = sss_ncache_set_user(ncache, true, dom, name); if (ret != EOK) { - DEBUG(1, "Failed to store permanent user filter for [%s]" + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to store permanent user filter for [%s]" " (%d [%s])\n", filter_list[i], ret, strerror(ret)); continue; @@ -677,7 +680,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, rctx->default_domain, filter_list[i], &domainname, &name); if (ret != EOK) { - DEBUG(1, "Invalid name in filterUsers list: [%s] (%d)\n", + DEBUG(SSSDBG_CRIT_FAILURE, + "Invalid name in filterUsers list: [%s] (%d)\n", filter_list[i], ret); continue; } @@ -691,7 +695,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, ret = sss_ncache_set_user(ncache, true, dom, name); if (ret != EOK) { - DEBUG(1, "Failed to store permanent user filter for [%s]" + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to store permanent user filter for [%s]" " (%d [%s])\n", filter_list[i], ret, strerror(ret)); continue; @@ -700,7 +705,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, for (dom = domain_list; dom; dom = get_next_domain(dom, false)) { ret = sss_ncache_set_user(ncache, true, dom, name); if (ret != EOK) { - DEBUG(1, "Failed to store permanent user filter for" + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to store permanent user filter for" " [%s:%s] (%d [%s])\n", dom->name, filter_list[i], ret, strerror(ret)); @@ -729,13 +735,15 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, ret = sss_parse_name(tmpctx, dom->names, filter_list[i], &domainname, &name); if (ret != EOK) { - DEBUG(1, "Invalid name in filterGroups list: [%s] (%d)\n", + DEBUG(SSSDBG_CRIT_FAILURE, + "Invalid name in filterGroups list: [%s] (%d)\n", filter_list[i], ret); continue; } if (domainname && strcmp(domainname, dom->name)) { - DEBUG(1, "Mismatch betwen domain name (%s) and name " + DEBUG(SSSDBG_CRIT_FAILURE, + "Mismatch betwen domain name (%s) and name " "set in FQN (%s), skipping group %s\n", dom->name, domainname, name); continue; @@ -743,7 +751,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, ret = sss_ncache_set_group(ncache, true, dom, name); if (ret != EOK) { - DEBUG(1, "Failed to store permanent group filter for [%s]" + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to store permanent group filter for [%s]" " (%d [%s])\n", filter_list[i], ret, strerror(ret)); continue; @@ -775,7 +784,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, rctx->default_domain, filter_list[i], &domainname, &name); if (ret != EOK) { - DEBUG(1, "Invalid name in filterGroups list: [%s] (%d)\n", + DEBUG(SSSDBG_CRIT_FAILURE, + "Invalid name in filterGroups list: [%s] (%d)\n", filter_list[i], ret); continue; } @@ -789,7 +799,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, ret = sss_ncache_set_group(ncache, true, dom, name); if (ret != EOK) { - DEBUG(1, "Failed to store permanent group filter for" + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to store permanent group filter for" " [%s] (%d [%s])\n", filter_list[i], ret, strerror(ret)); continue; @@ -798,7 +809,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, for (dom = domain_list; dom; dom = get_next_domain(dom, false)) { ret = sss_ncache_set_group(ncache, true, dom, name); if (ret != EOK) { - DEBUG(1, "Failed to store permanent group filter for" + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to store permanent group filter for" " [%s:%s] (%d [%s])\n", dom->name, filter_list[i], ret, strerror(ret)); diff --git a/src/responder/common/responder_cmd.c b/src/responder/common/responder_cmd.c index 1297ab8ce..1ac86fddf 100644 --- a/src/responder/common/responder_cmd.c +++ b/src/responder/common/responder_cmd.c @@ -117,7 +117,8 @@ int sss_cmd_get_version(struct cli_ctx *cctx) sss_packet_get_body(cctx->creq->in, &req_body, &req_blen); if (req_blen == sizeof(uint32_t)) { memcpy(&client_version, req_body, sizeof(uint32_t)); - DEBUG(5, "Received client version [%d].\n", client_version); + DEBUG(SSSDBG_FUNC_DATA, + "Received client version [%d].\n", client_version); i=0; while(cli_protocol_version[i].version>0) { diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 5e6d94d32..298994a96 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -59,7 +59,7 @@ static errno_t set_nonblocking(int fd) ferr = fcntl(fd, F_SETFL, v | O_NONBLOCK); if (ferr < 0) { error = errno; - DEBUG(0, "Unable to set fd non-blocking: [%d][%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, "Unable to set fd non-blocking: [%d][%s]\n", error, strerror(error)); return error; } @@ -80,7 +80,8 @@ static errno_t set_close_on_exec(int fd) ferr = fcntl(fd, F_SETFD, v | FD_CLOEXEC); if (ferr < 0) { error = errno; - DEBUG(0, "Unable to set fd close-on-exec: [%d][%s]\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to set fd close-on-exec: [%d][%s]\n", error, strerror(error)); return error; } @@ -119,11 +120,13 @@ static errno_t get_client_cred(struct cli_ctx *cctx) &client_cred_len); if (ret != EOK) { ret = errno; - DEBUG(1, "getsock failed [%d][%s].\n", ret, strerror(ret)); + DEBUG(SSSDBG_CRIT_FAILURE, + "getsock failed [%d][%s].\n", ret, strerror(ret)); return ret; } if (client_cred_len != sizeof(struct ucred)) { - DEBUG(1, "getsockopt returned unexpected message size.\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "getsockopt returned unexpected message size.\n"); return ENOMSG; } @@ -131,7 +134,7 @@ static errno_t get_client_cred(struct cli_ctx *cctx) cctx->client_egid = client_cred.gid; cctx->client_pid = client_cred.pid; - DEBUG(9, "Client creds: euid[%d] egid[%d] pid[%d].\n", + DEBUG(SSSDBG_TRACE_ALL, "Client creds: euid[%d] egid[%d] pid[%d].\n", cctx->client_euid, cctx->client_egid, cctx->client_pid); #endif @@ -250,7 +253,7 @@ static void client_send(struct cli_ctx *cctx) return; } if (ret != EOK) { - DEBUG(0, "Failed to send data, aborting client!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to send data, aborting client!\n"); talloc_free(cctx); return; } @@ -278,7 +281,8 @@ static void client_recv(struct cli_ctx *cctx) if (!cctx->creq) { cctx->creq = talloc_zero(cctx, struct cli_request); if (!cctx->creq) { - DEBUG(0, "Failed to alloc request, aborting client!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Failed to alloc request, aborting client!\n"); talloc_free(cctx); return; } @@ -288,7 +292,8 @@ static void client_recv(struct cli_ctx *cctx) ret = sss_packet_new(cctx->creq, SSS_PACKET_MAX_RECV_SIZE, 0, &cctx->creq->in); if (ret != EOK) { - DEBUG(0, "Failed to alloc request, aborting client!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Failed to alloc request, aborting client!\n"); talloc_free(cctx); return; } @@ -302,7 +307,8 @@ static void client_recv(struct cli_ctx *cctx) /* execute command */ ret = client_cmd_execute(cctx, cctx->rctx->sss_cmds); if (ret != EOK) { - DEBUG(0, "Failed to execute request, aborting client!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Failed to execute request, aborting client!\n"); talloc_free(cctx); } /* past this point cctx can be freed at any time by callbacks @@ -314,17 +320,18 @@ static void client_recv(struct cli_ctx *cctx) break; case EINVAL: - DEBUG(6, "Invalid data from client, closing connection!\n"); + DEBUG(SSSDBG_TRACE_FUNC, + "Invalid data from client, closing connection!\n"); talloc_free(cctx); break; case ENODATA: - DEBUG(5, "Client disconnected!\n"); + DEBUG(SSSDBG_FUNC_DATA, "Client disconnected!\n"); talloc_free(cctx); break; default: - DEBUG(6, "Failed to read request, aborting client!\n"); + DEBUG(SSSDBG_TRACE_FUNC, "Failed to read request, aborting client!\n"); talloc_free(cctx); } @@ -387,14 +394,16 @@ static void accept_fd_handler(struct tevent_context *ev, if (accept_ctx->is_private) { ret = stat(rctx->priv_sock_name, &stat_buf); if (ret == -1) { - DEBUG(1, "stat on privileged pipe failed: [%d][%s].\n", errno, + DEBUG(SSSDBG_CRIT_FAILURE, + "stat on privileged pipe failed: [%d][%s].\n", errno, strerror(errno)); return; } if ( ! (stat_buf.st_uid == 0 && stat_buf.st_gid == 0 && (stat_buf.st_mode&(S_IFSOCK|S_IRUSR|S_IWUSR)) == stat_buf.st_mode)) { - DEBUG(1, "privileged pipe has an illegal status.\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "privileged pipe has an illegal status.\n"); /* TODO: what is the best response to this condition? Terminate? */ return; } @@ -403,7 +412,8 @@ static void accept_fd_handler(struct tevent_context *ev, cctx = talloc_zero(rctx, struct cli_ctx); if (!cctx) { struct sockaddr_un addr; - DEBUG(0, "Out of memory trying to setup client context%s!\n", + DEBUG(SSSDBG_FATAL_FAILURE, + "Out of memory trying to setup client context%s!\n", accept_ctx->is_private ? " on privileged pipe": ""); /* accept and close to signal the client we have a problem */ memset(&addr, 0, sizeof(addr)); @@ -419,7 +429,7 @@ static void accept_fd_handler(struct tevent_context *ev, len = sizeof(cctx->addr); cctx->cfd = accept(fd, (struct sockaddr *)&cctx->addr, &len); if (cctx->cfd == -1) { - DEBUG(1, "Accept failed [%s]\n", strerror(errno)); + DEBUG(SSSDBG_CRIT_FAILURE, "Accept failed [%s]\n", strerror(errno)); talloc_free(cctx); return; } @@ -428,7 +438,7 @@ static void accept_fd_handler(struct tevent_context *ev, ret = get_client_cred(cctx); if (ret != EOK) { - DEBUG(2, "get_client_cred failed, " + DEBUG(SSSDBG_OP_FAILURE, "get_client_cred failed, " "client cred may not be available.\n"); } @@ -543,7 +553,7 @@ static int sss_dp_init(struct resp_ctx *rctx, /* Set up SBUS connection to the monitor */ ret = dp_get_sbus_address(be_conn, &be_conn->sbus_address, domain->name); if (ret != EOK) { - DEBUG(0, "Could not locate DP address.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Could not locate DP address.\n"); return ret; } ret = sbus_client_init(rctx, rctx->ev, @@ -551,7 +561,7 @@ static int sss_dp_init(struct resp_ctx *rctx, intf, &be_conn->conn, NULL, rctx); if (ret != EOK) { - DEBUG(0, "Failed to connect to monitor services.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n"); return ret; } @@ -562,7 +572,7 @@ static int sss_dp_init(struct resp_ctx *rctx, DATA_PROVIDER_VERSION, cli_name); if (ret != EOK) { - DEBUG(0, "Failed to identify to the DP!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to identify to the DP!\n"); return ret; } @@ -641,11 +651,13 @@ static int set_unix_socket(struct resp_ctx *rctx) unlink(rctx->sock_name); if (bind(rctx->lfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { - DEBUG(0,"Unable to bind on socket '%s'\n", rctx->sock_name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to bind on socket '%s'\n", rctx->sock_name); goto failed; } if (listen(rctx->lfd, 10) != 0) { - DEBUG(0,"Unable to listen on socket '%s'\n", rctx->sock_name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to listen on socket '%s'\n", rctx->sock_name); goto failed; } @@ -658,7 +670,7 @@ static int set_unix_socket(struct resp_ctx *rctx) TEVENT_FD_READ, accept_fd_handler, accept_ctx); if (!rctx->lfde) { - DEBUG(0, "Failed to queue handler on pipe\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to queue handler on pipe\n"); goto failed; } } @@ -691,11 +703,13 @@ static int set_unix_socket(struct resp_ctx *rctx) unlink(rctx->priv_sock_name); if (bind(rctx->priv_lfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { - DEBUG(0,"Unable to bind on socket '%s'\n", rctx->priv_sock_name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to bind on socket '%s'\n", rctx->priv_sock_name); goto failed; } if (listen(rctx->priv_lfd, 10) != 0) { - DEBUG(0,"Unable to listen on socket '%s'\n", rctx->priv_sock_name); + DEBUG(SSSDBG_FATAL_FAILURE, + "Unable to listen on socket '%s'\n", rctx->priv_sock_name); goto failed; } @@ -708,7 +722,8 @@ static int set_unix_socket(struct resp_ctx *rctx) TEVENT_FD_READ, accept_fd_handler, accept_ctx); if (!rctx->priv_lfde) { - DEBUG(0, "Failed to queue handler on privileged pipe\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Failed to queue handler on privileged pipe\n"); goto failed; } } @@ -759,7 +774,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, rctx = talloc_zero(mem_ctx, struct resp_ctx); if (!rctx) { - DEBUG(0, "fatal error initializing resp_ctx\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing resp_ctx\n"); return ENOMEM; } rctx->ev = ev; @@ -805,7 +820,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, ret = confdb_get_domains(rctx->cdb, &rctx->domains); if (ret != EOK) { - DEBUG(0, "fatal error setting up domain map\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "fatal error setting up domain map\n"); goto fail; } @@ -823,7 +838,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, svc_name, svc_version, rctx, &rctx->mon_conn); if (ret != EOK) { - DEBUG(0, "fatal error setting up message bus\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "fatal error setting up message bus\n"); goto fail; } @@ -843,7 +858,8 @@ int sss_process_init(TALLOC_CTX *mem_ctx, ret = sss_dp_init(rctx, dp_intf, cli_name, dom); if (ret != EOK) { - DEBUG(0, "fatal error setting up backend connector\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "fatal error setting up backend connector\n"); goto fail; } } @@ -851,14 +867,14 @@ int sss_process_init(TALLOC_CTX *mem_ctx, ret = sysdb_init(rctx, rctx->domains, false); if (ret != EOK) { SYSDB_VERSION_ERROR_DAEMON(ret); - DEBUG(0, "fatal error initializing resp_ctx\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing resp_ctx\n"); goto fail; } /* after all initializations we are ready to listen on our socket */ ret = set_unix_socket(rctx); if (ret != EOK) { - DEBUG(0, "fatal error initializing socket\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "fatal error initializing socket\n"); goto fail; } diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c index 396c80997..a9b4ae23a 100644 --- a/src/responder/common/responder_dp.c +++ b/src/responder/common/responder_dp.c @@ -142,18 +142,19 @@ void handle_requests_after_reconnect(struct resp_ctx *rctx) struct sss_dp_req *sdp_req; if (!rctx->dp_request_table) { - DEBUG(7, "No requests to handle after reconnect\n"); + DEBUG(SSSDBG_TRACE_LIBS, "No requests to handle after reconnect\n"); return; } ret = hash_values(rctx->dp_request_table, &count, &values); if (ret != HASH_SUCCESS) { - DEBUG(1, "hash_values failed, " + DEBUG(SSSDBG_CRIT_FAILURE, "hash_values failed, " "not all request might be handled after reconnect.\n"); return; } - DEBUG(7, "Will handle %lu requests after reconnect\n", count); + DEBUG(SSSDBG_TRACE_LIBS, + "Will handle %lu requests after reconnect\n", count); for (i=0; i