dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0035-responders-Do-not-initialize-pipe-fd-if-already-pres.patch

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