responder_common.c revision 422217c7ea5fbe94b386c93c19e2c1928151faa0
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher Common Responder methods
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher This program is free software; you can redistribute it and/or modify
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher it under the terms of the GNU General Public License as published by
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher the Free Software Foundation; either version 3 of the License, or
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher (at your option) any later version.
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher This program is distributed in the hope that it will be useful,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher but WITHOUT ANY WARRANTY; without even the implied warranty of
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher GNU General Public License for more details.
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher You should have received a copy of the GNU General Public License
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher along with this program. If not, see <http://www.gnu.org/licenses/>.
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#include "responder/common/iface/responder_iface.h"
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Get the current flags for this file descriptor */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Set the close-on-exec flags on this fd */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ferr = fcntl(fd, F_SETFD, v | FD_CLOEXEC);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Unable to set fd close-on-exec: [%d][%s]\n",
fd555d130dc733509347fa096a2cb858b014a196Simo Sorcestatic void client_close_fn(struct tevent_context *ev,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher struct cli_ctx *ctx = talloc_get_type(ptr, struct cli_ctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher if ((ctx->cfd > 0) && close(ctx->cfd) < 0) {
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "Failed to close fd [%d]: [%s]\n",
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "Terminated client [%p][%d]\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic errno_t get_client_cred(struct cli_ctx *cctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->creds = talloc_zero(cctx, struct cli_creds);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher socklen_t client_cred_len = sizeof(struct ucred);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = getsockopt(cctx->cfd, SOL_SOCKET, SO_PEERCRED, &cctx->creds->ucred,
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "getsock failed [%d][%s].\n", ret, strerror(ret));
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher if (client_cred_len != sizeof(struct ucred)) {
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "getsockopt returned unexpected message size.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Client creds: euid[%d] egid[%d] pid[%d].\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->creds->ucred.uid, cctx->creds->ucred.gid,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = SELINUX_getpeercon(cctx->cfd, &secctx);
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "The following failure is expected to happen in case SELinux is disabled:\n"
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "SELINUX_getpeercon failed [%d][%s].\n"
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "Please, consider enabling SELinux in your system.\n", ret, strerror(ret));
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce /* This is not fatal, as SELinux may simply be disabled */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->creds->selinux_ctx = SELINUX_context_new(secctx);
fd555d130dc733509347fa096a2cb858b014a196Simo Sorceerrno_t check_allowed_uids(uid_t uid, size_t allowed_uids_count,
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zidek for (c = 0; c < allowed_uids_count; c++) {
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghererrno_t csv_string_to_uid_array(TALLOC_CTX *mem_ctx, const char *csv_string,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = split_on_separator(mem_ctx, csv_string, ',', true, false,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "split_on_separator failed [%d][%s].\n",
3a59cbd0b7b9c5dd3c62ac1679876070c264d80fMichal Zidek uids = talloc_array(mem_ctx, uint32_t, list_size);
3a59cbd0b7b9c5dd3c62ac1679876070c264d80fMichal Zidek DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "Failed to unset _SSS_LOOPS, getpwnam "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "might not find sssd users.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher for (c = 0; c < list_size; c++) {
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "Empty list item.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher uids[c] = strtouint32(list[c], &endptr, 10);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "List item [%s] is out of range.\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = sss_user_by_name_or_uid(list[c], &uids[c], NULL);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "List item [%s] is neither a valid "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "UID nor a user name which could be "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher sss_log(SSS_LOG_WARNING, "List item [%s] is neither a valid "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "UID nor a user name which could be "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "Failed to set _SSS_LOOPS.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic void client_send(struct cli_ctx *cctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher pctx = talloc_get_type(cctx->protocol_ctx, struct cli_protocol);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = sss_packet_send(pctx->creq->out, cctx->cfd);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* not all data was sent, loop again */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_FATAL_FAILURE, "Failed to send data, aborting client!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* ok all sent */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic int client_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher pctx = talloc_get_type(cctx->protocol_ctx, struct cli_protocol);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher return sss_cmd_execute(cctx, cmd, sss_cmds);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic void client_recv(struct cli_ctx *cctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher pctx = talloc_get_type(cctx->protocol_ctx, struct cli_protocol);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher pctx->creq = talloc_zero(cctx, struct cli_request);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Failed to alloc request, aborting client!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = sss_packet_new(pctx->creq, SSS_PACKET_MAX_RECV_SIZE,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Failed to alloc request, aborting client!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = sss_packet_recv(pctx->creq->in, cctx->cfd);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* do not read anymore */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* execute command */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = client_cmd_execute(cctx, cctx->rctx->sss_cmds);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Failed to execute request, aborting client!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* past this point cctx can be freed at any time by callbacks
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher * in case of error, do not use it */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* need to read still some data, loop again */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Invalid data from client, closing connection!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_FUNC_DATA, "Client disconnected!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_TRACE_FUNC, "Failed to read request, aborting client!\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic errno_t schedule_responder_idle_timer(struct resp_ctx *rctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic void responder_idle_handler(struct tevent_context *ev,
e299638926171e0e92a36122aeff6611cd52418dStephen Gallagher rctx = talloc_get_type(data, struct resp_ctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Time shift detected, re-scheduling the responder timeout\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher if ((now - rctx->last_request_time) > rctx->idle_timeout) {
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* This responder is idle. Terminate it */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Terminating idle responder [%p]\n", rctx);
e299638926171e0e92a36122aeff6611cd52418dStephen Gallagher "Re-scheduling the idle timeout for the responder [%p]\n", rctx);
e299638926171e0e92a36122aeff6611cd52418dStephen Gallagherstatic errno_t schedule_responder_idle_timer(struct resp_ctx *rctx)
3a59cbd0b7b9c5dd3c62ac1679876070c264d80fMichal Zidek tv = tevent_timeval_current_ofs(rctx->idle_timeout / 2, 0);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Failed to allocate time event: responder [%p] shutdown timeout\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Re-scheduling the idle timeout for the responder [%p]\n", rctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic errno_t setup_responder_idle_timer(struct resp_ctx *rctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = schedule_responder_idle_timer(rctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Error scheduling the idle timeout for the responder [%p]: "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Setting up the idle timeout for the responder [%p]\n", rctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic void client_fd_handler(struct tevent_context *ev,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher struct cli_ctx *cctx = talloc_get_type(ptr, struct cli_ctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Always reset the idle timer on any activity */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->rctx->last_request_time = time(NULL);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Always reset the idle timer on any activity */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Could not create idle timer for client. "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "This connection may not auto-terminate\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Non-fatal, continue */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic errno_t setup_client_idle_timer(struct cli_ctx *cctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic int cli_ctx_destructor(struct cli_ctx *cctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SELINUX_context_free(cctx->creds->selinux_ctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic void accept_fd_handler(struct tevent_context *ev,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* accept and attach new event handler */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher talloc_get_type(ptr, struct accept_fd_ctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher int fd = accept_ctx->is_private ? rctx->priv_lfd : rctx->lfd;
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher ret = stat(rctx->priv_sock_name, &stat_buf);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "stat on privileged pipe failed: [%d][%s].\n", errno,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher if ( ! (stat_buf.st_uid == 0 && stat_buf.st_gid == 0 &&
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zidek (stat_buf.st_mode&(S_IFSOCK|S_IRUSR|S_IWUSR)) == stat_buf.st_mode)) {
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "privileged pipe has an illegal status.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* TODO: what is the best response to this condition? Terminate? */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Out of memory trying to setup client context%s!\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher accept_ctx->is_private ? " on privileged pipe": "");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* accept and close to signal the client we have a problem */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher client_fd = accept(fd, (struct sockaddr *)&addr, &len);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher talloc_set_destructor(cctx, cli_ctx_destructor);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->cfd = accept(fd, (struct sockaddr *)&cctx->addr, &len);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_CRIT_FAILURE, "Accept failed [%s]\n", strerror(errno));
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "get_client_cred failed, "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "client cred may not be available.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_CRIT_FAILURE, "allowed_uids configured, " \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "but platform does not support " \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "reading peer credential from the " \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "socket. Access denied.\n");
d3d297c62e0340151da1d4ce1e082dcfcb45b431Jakub Hrozek ret = check_allowed_uids(client_euid(cctx->creds), rctx->allowed_uids_count,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_OP_FAILURE, "check_allowed_uids failed.\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Failed to setup client handler%s\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher accept_ctx->is_private ? " on privileged pipe" : "");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->cfde = tevent_add_fd(ev, cctx, cctx->cfd,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Failed to queue client handler%s\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher accept_ctx->is_private ? " on privileged pipe" : "");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher tevent_fd_set_close_fn(cctx->cfde, client_close_fn);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Record the new time and set up the idle timer */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Could not create idle timer for client. "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "This connection may not auto-terminate\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Non-fatal, continue */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Could not create idle timer for client. "
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "This connection may not auto-terminate\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Non-fatal, continue */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Client connected%s!\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher accept_ctx->is_private ? " to privileged pipe" : "");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic void client_idle_handler(struct tevent_context *ev,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher struct cli_ctx *cctx = talloc_get_type(data, struct cli_ctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Time shift detected, re-scheduling the client timeout\n");
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher if ((now - cctx->last_request_time) > cctx->rctx->client_idle_timeout) {
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* This connection is idle. Terminate it */
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Terminating idle client [%p][%d]\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* The cli_ctx destructor will handle the rest */
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zidekerrno_t reset_client_idle_timer(struct cli_ctx *cctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic errno_t setup_client_idle_timer(struct cli_ctx *cctx)
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher tevent_timeval_current_ofs(cctx->rctx->client_idle_timeout/2, 0);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher cctx->idle = tevent_add_timer(cctx->ev, cctx, tv, client_idle_handler, cctx);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher "Idle timer re-set for client [%p][%d]\n",
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstatic int sss_dp_init(struct resp_ctx *rctx,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher be_conn = talloc_zero(rctx, struct be_conn);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher /* Set up SBUS connection to the monitor */
3a59cbd0b7b9c5dd3c62ac1679876070c264d80fMichal Zidek ret = dp_get_sbus_address(be_conn, &be_conn->sbus_address, domain->name);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher DEBUG(SSSDBG_FATAL_FAILURE, "Could not locate DP address.\n");
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n");
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher ret = sbus_conn_register_iface_map(be_conn->conn, sbus_iface, rctx);
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher DEBUG(SSSDBG_FATAL_FAILURE, "Failed to register D-Bus interface.\n");
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher resp_sbus_iface = responder_get_sbus_interface();
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher ret = sbus_conn_register_iface_map(be_conn->conn,
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce "Cannot register generic responder iface at %s: %d\n",
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce DLIST_ADD_END(rctx->be_conns, be_conn, struct be_conn *);
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher /* Identify ourselves to the DP */
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher ret = rdp_register_client(be_conn, cli_name);
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher DEBUG(SSSDBG_FATAL_FAILURE, "Failed to identify to the DP!\n");
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zidekint create_pipe_fd(const char *sock_name, int *_fd, mode_t umaskval)
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce strncpy(addr.sun_path, sock_name, sizeof(addr.sun_path) - 1);
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce /* make sure we have no old sockets around */
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce "Cannot remove old socket (errno=%d [%s]), bind might fail!\n",
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce /* restore previous umask value */
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce/* create a unix socket and listen to it */
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce/* for future use */
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce default_pipe = talloc_asprintf(rctx, "%s/%s", PIPE_PATH,
return ret;
if (!default_pipe) {
return ENOMEM;
return ret;
return ret;
goto failed;
goto failed;
goto failed;
return EOK;
return EIO;
int ret;
#ifdef HAVE_SYSTEMD
if (ret < 0) {
goto done;
if (ret < 0) {
goto done;
if (ret < 0) {
goto done;
goto done;
done:
return ret;
return ENOMEM;
return EOK;
int tmp_value;
int ret;
goto done;
if (tmp_value < 0) {
goto done;
0, &tmp_value);
goto done;
if (tmp_value < 0) {
goto done;
goto done;
done:
return ret;
const char *sss_pipe_name,
int pipe_fd,
const char *sss_priv_pipe_name,
int priv_pipe_fd,
const char *confdb_service_path,
const char *svc_name,
const char *cli_name,
int ret;
if (!rctx) {
return ENOMEM;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
&tmp);
goto fail;
&tmp);
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
return EOK;
fail:
return ret;
return EOK;
struct sss_domain_info *
if (!ret_dom) {
return ret_dom;
int ret;
return EINVAL;
goto done;
done:
return ret;
int limret;
if (limret == 0) {
if (limret == 0) {
if (limret == 0) {
goto fail;
fail:
return ret;
static errno_t
return ENOMEM;
goto done;
goto done;
goto done;
done:
return ret;
static errno_t
const char *domain,
return ENOMEM;
goto done;
goto done;
goto done;
done:
return ret;
"Using domain_resolution_order from sssd.conf\n");
goto done;
goto done;
&cr_domains);
goto done;
&cr_domains);
goto done;
goto done;
done:
return ret;
const char *orig_name,
char *name_str;
return ENOMEM;
goto done;
goto done;
done:
return ret;
const char *member_name,
char *domname;
return ENOMEM;
goto done;
goto done;
domname, true);
goto done;
done:
return ret;