From 4bab32c01bce266c68838c9edac9a567f8b1f413 Mon Sep 17 00:00:00 2001
From: Michal Zidek <mzidek@redhat.com>
Date: Wed, 15 Oct 2014 18:01:55 +0200
Subject: [PATCH 35/46] responders: Do not initialize pipe fd if already
present
Allow to skip initialization of pipe file descriptor
if the responder context already has one.
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Simo Sorce <simo@redhat.com>
(cherry picked from commit 8bccd95e275fae760a991da394235e4e70e57bbd)
---
src/responder/autofs/autofssrv.c | 2 +-
src/responder/common/responder.h | 2 ++
src/responder/common/responder_common.c | 20 ++++++++++++++------
src/responder/ifp/ifpsrv.c | 2 +-
src/responder/nss/nsssrv.c | 2 +-
src/responder/pac/pacsrv.c | 2 +-
src/responder/pam/pamsrv.c | 4 ++--
src/responder/ssh/sshsrv.c | 2 +-
src/responder/sudo/sudosrv.c | 2 +-
9 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/responder/autofs/autofssrv.c b/src/responder/autofs/autofssrv.c
index 931cf018bfe15b37bf8e5f93a21c7ab61d238c18..12a7a777e214fa4c3821eb58ff602b3f3efb987a 100644
--- a/src/responder/autofs/autofssrv.c
+++ b/src/responder/autofs/autofssrv.c
@@ -132,7 +132,7 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
autofs_cmds = get_autofs_cmds();
ret = sss_process_init(mem_ctx, ev, cdb,
autofs_cmds,
- SSS_AUTOFS_SOCKET_NAME, NULL,
+ SSS_AUTOFS_SOCKET_NAME, -1, NULL, -1,
CONFDB_AUTOFS_CONF_ENTRY,
SSS_AUTOFS_SBUS_SERVICE_NAME,
SSS_AUTOFS_SBUS_SERVICE_VERSION,
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index d233710782fe7df1bbcc338e3815d1701557519e..8837e11425be36c67da038287de48c069ae335cd 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -159,7 +159,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx *cdb,
struct sss_cmd_table sss_cmds[],
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,
uint16_t svc_version,
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index a262a2c1487c786404b6d0d4c720edd1679279d0..85aa04335b72c38fb7a128f04315e3c4189c5d56 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -689,9 +689,11 @@ static int set_unix_socket(struct resp_ctx *rctx)
if (rctx->sock_name != NULL ) {
/* Set the umask so that permissions are set right on the socket.
* It must be readable and writable by anybody on the system. */
- ret = create_pipe_fd(rctx->sock_name, &rctx->lfd, 0111);
- if (ret != EOK) {
- return ret;
+ if (rctx->lfd == -1) {
+ ret = create_pipe_fd(rctx->sock_name, &rctx->lfd, 0111);
+ if (ret != EOK) {
+ return ret;
+ }
}
accept_ctx = talloc_zero(rctx, struct accept_fd_ctx);
@@ -710,9 +712,11 @@ static int set_unix_socket(struct resp_ctx *rctx)
if (rctx->priv_sock_name != NULL ) {
/* create privileged pipe */
- ret = create_pipe_fd(rctx->priv_sock_name, &rctx->priv_lfd, 0177);
- if (ret != EOK) {
- goto failed;
+ if (rctx->priv_lfd == -1) {
+ ret = create_pipe_fd(rctx->priv_sock_name, &rctx->priv_lfd, 0177);
+ if (ret != EOK) {
+ goto failed;
+ }
}
accept_ctx = talloc_zero(rctx, struct accept_fd_ctx);
@@ -755,7 +759,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx *cdb,
struct sss_cmd_table sss_cmds[],
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,
uint16_t svc_version,
@@ -779,6 +785,8 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
rctx->sss_cmds = sss_cmds;
rctx->sock_name = sss_pipe_name;
rctx->priv_sock_name = sss_priv_pipe_name;
+ rctx->lfd = pipe_fd;
+ rctx->priv_lfd = priv_pipe_fd;
rctx->confdb_service_path = confdb_service_path;
rctx->shutting_down = false;
diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c
index 8d8fe885abb8ef53ee7f49e763ba78c4dda9a983..eddeec9812bdd650bfbfb78ede91bf3704113504 100644
--- a/src/responder/ifp/ifpsrv.c
+++ b/src/responder/ifp/ifpsrv.c
@@ -310,7 +310,7 @@ int ifp_process_init(TALLOC_CTX *mem_ctx,
ifp_cmds = get_ifp_cmds();
ret = sss_process_init(mem_ctx, ev, cdb,
ifp_cmds,
- NULL, NULL,
+ NULL, -1, NULL, -1,
CONFDB_IFP_CONF_ENTRY,
SSS_IFP_SBUS_SERVICE_NAME,
SSS_IFP_SBUS_SERVICE_VERSION,
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index dbbdb4f844410eabe01f184ccdf8d9deb41833f4..cfb146464d224cdb8b517d23a86421da7eaccd1f 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -392,7 +392,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
ret = sss_process_init(mem_ctx, ev, cdb,
nss_cmds,
- SSS_NSS_SOCKET_NAME, NULL,
+ SSS_NSS_SOCKET_NAME, -1, NULL, -1,
CONFDB_NSS_CONF_ENTRY,
NSS_SBUS_SERVICE_NAME,
NSS_SBUS_SERVICE_VERSION,
diff --git a/src/responder/pac/pacsrv.c b/src/responder/pac/pacsrv.c
index b76691de829b4f40937a07ea83825a606950aa1e..e427cd756f4031218a8fb99c30bf709e21680039 100644
--- a/src/responder/pac/pacsrv.c
+++ b/src/responder/pac/pacsrv.c
@@ -119,7 +119,7 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
ret = sss_process_init(mem_ctx, ev, cdb,
pac_cmds,
- SSS_PAC_SOCKET_NAME, NULL,
+ SSS_PAC_SOCKET_NAME, -1, NULL, -1,
CONFDB_PAC_CONF_ENTRY,
PAC_SBUS_SERVICE_NAME,
PAC_SBUS_SERVICE_VERSION,
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
index 91b395080820b27f5d57341e59dd739e674be31a..a3f8662738c26a537bc21d8d419e65e49c4828c9 100644
--- a/src/responder/pam/pamsrv.c
+++ b/src/responder/pam/pamsrv.c
@@ -194,8 +194,8 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
pam_cmds = get_pam_cmds();
ret = sss_process_init(mem_ctx, ev, cdb,
pam_cmds,
- SSS_PAM_SOCKET_NAME,
- SSS_PAM_PRIV_SOCKET_NAME,
+ SSS_PAM_SOCKET_NAME, -1,
+ SSS_PAM_PRIV_SOCKET_NAME, -1,
CONFDB_PAM_CONF_ENTRY,
SSS_PAM_SBUS_SERVICE_NAME,
SSS_PAM_SBUS_SERVICE_VERSION,
diff --git a/src/responder/ssh/sshsrv.c b/src/responder/ssh/sshsrv.c
index 1328d1746b9e2d6474d6c2f8ce2825be463ca3e7..b154ee1baa16de68f642d2e967b8e7c873c8d4e7 100644
--- a/src/responder/ssh/sshsrv.c
+++ b/src/responder/ssh/sshsrv.c
@@ -92,7 +92,7 @@ int ssh_process_init(TALLOC_CTX *mem_ctx,
ssh_cmds = get_ssh_cmds();
ret = sss_process_init(mem_ctx, ev, cdb,
ssh_cmds,
- SSS_SSH_SOCKET_NAME, NULL,
+ SSS_SSH_SOCKET_NAME, -1, NULL, -1,
CONFDB_SSH_CONF_ENTRY,
SSS_SSH_SBUS_SERVICE_NAME,
SSS_SSH_SBUS_SERVICE_VERSION,
diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c
index 30752c9dacdc390b24fe837c0630333b5e171448..038e3fd7da0829ce554a31694725c3dddaf5c038 100644
--- a/src/responder/sudo/sudosrv.c
+++ b/src/responder/sudo/sudosrv.c
@@ -93,7 +93,7 @@ int sudo_process_init(TALLOC_CTX *mem_ctx,
sudo_cmds = get_sudo_cmds();
ret = sss_process_init(mem_ctx, ev, cdb,
sudo_cmds,
- SSS_SUDO_SOCKET_NAME, NULL,
+ SSS_SUDO_SOCKET_NAME, -1, NULL, -1,
CONFDB_SUDO_CONF_ENTRY,
SSS_SUDO_SBUS_SERVICE_NAME,
SSS_SUDO_SBUS_SERVICE_VERSION,
--
1.9.3