diff options
Diffstat (limited to 'src/responder/common/responder_common.c')
-rw-r--r-- | src/responder/common/responder_common.c | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index bb54c5514..37c2ebe3a 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -58,7 +58,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; } @@ -79,7 +79,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; } @@ -118,11 +119,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; } @@ -130,7 +133,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 @@ -249,7 +252,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; } @@ -277,7 +280,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; } @@ -287,7 +291,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; } @@ -301,7 +306,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 @@ -313,17 +319,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); } @@ -386,14 +393,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; } @@ -402,7 +411,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)); @@ -418,7 +428,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; } @@ -427,7 +437,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"); } @@ -542,7 +552,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, @@ -550,7 +560,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; } @@ -561,7 +571,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; } @@ -640,11 +650,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; } @@ -657,7 +669,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; } } @@ -690,11 +702,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; } @@ -707,7 +721,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; } } @@ -758,7 +773,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; @@ -804,7 +819,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; } @@ -822,7 +837,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; } @@ -842,7 +857,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; } } @@ -850,14 +866,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; } |