Blame SOURCES/0022-sss_client-create-nss_common.h.patch

9f2ebf
From 22c5575eb442f20230081cc06528d685397c8914 Mon Sep 17 00:00:00 2001
9f2ebf
From: Sumit Bose <sbose@redhat.com>
9f2ebf
Date: Fri, 29 Sep 2017 21:38:54 +0200
9f2ebf
Subject: [PATCH 22/31] sss_client: create nss_common.h
9f2ebf
9f2ebf
This patch makes sss_nss_getpw_readrep() and sss_nss_getgr_readrep()
9f2ebf
calls which parse SSSD's replies for user and group requests available
9f2ebf
to other components.
9f2ebf
9f2ebf
Related to https://pagure.io/SSSD/sssd/issue/2478
9f2ebf
9f2ebf
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
9f2ebf
(cherry picked from commit 7449b236523409cc8766fb957d6cba051fdfb483)
9f2ebf
---
9f2ebf
 Makefile.am                 |  1 +
9f2ebf
 src/sss_client/nss_common.h | 43 +++++++++++++++++++++++++++++++++++++++++++
9f2ebf
 src/sss_client/nss_group.c  | 10 +++-------
9f2ebf
 src/sss_client/nss_passwd.c | 11 +++--------
9f2ebf
 4 files changed, 50 insertions(+), 15 deletions(-)
9f2ebf
 create mode 100644 src/sss_client/nss_common.h
9f2ebf
9f2ebf
diff --git a/Makefile.am b/Makefile.am
9f2ebf
index 5483375167d99568e8313c9a0488900419be6ec3..dc2f4b1857ce5bd376544488348731be29b6b293 100644
9f2ebf
--- a/Makefile.am
9f2ebf
+++ b/Makefile.am
9f2ebf
@@ -3623,6 +3623,7 @@ libnss_sss_la_SOURCES = \
9f2ebf
     src/sss_client/nss_services.c \
9f2ebf
     src/sss_client/sss_cli.h \
9f2ebf
     src/sss_client/nss_compat.h \
9f2ebf
+    src/sss_client/nss_common.h \
9f2ebf
     src/sss_client/nss_mc_common.c \
9f2ebf
     src/util/io.c \
9f2ebf
     src/util/murmurhash3.c \
9f2ebf
diff --git a/src/sss_client/nss_common.h b/src/sss_client/nss_common.h
9f2ebf
new file mode 100644
9f2ebf
index 0000000000000000000000000000000000000000..e83b4f95a3136b5aa711194a4d37389eebfb607a
9f2ebf
--- /dev/null
9f2ebf
+++ b/src/sss_client/nss_common.h
9f2ebf
@@ -0,0 +1,43 @@
9f2ebf
+/*
9f2ebf
+   SSSD
9f2ebf
+
9f2ebf
+   Common routines for classical and enhanced NSS interface
9f2ebf
+
9f2ebf
+   Authors:
9f2ebf
+        Sumit Bose <sbose@redhat.com>
9f2ebf
+
9f2ebf
+   Copyright (C) Red Hat, Inc 2007
9f2ebf
+
9f2ebf
+   This program is free software; you can redistribute it and/or modify
9f2ebf
+   it under the terms of the GNU Lesser General Public License as published by
9f2ebf
+   the Free Software Foundation; either version 3 of the License, or
9f2ebf
+   (at your option) any later version.
9f2ebf
+
9f2ebf
+   This program is distributed in the hope that it will be useful,
9f2ebf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9f2ebf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9f2ebf
+   GNU Lesser General Public License for more details.
9f2ebf
+
9f2ebf
+   You should have received a copy of the GNU Lesser General Public License
9f2ebf
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
9f2ebf
+*/
9f2ebf
+
9f2ebf
+
9f2ebf
+
9f2ebf
+struct sss_nss_pw_rep {
9f2ebf
+    struct passwd *result;
9f2ebf
+    char *buffer;
9f2ebf
+    size_t buflen;
9f2ebf
+};
9f2ebf
+
9f2ebf
+int sss_nss_getpw_readrep(struct sss_nss_pw_rep *pr,
9f2ebf
+                          uint8_t *buf, size_t *len);
9f2ebf
+
9f2ebf
+struct sss_nss_gr_rep {
9f2ebf
+    struct group *result;
9f2ebf
+    char *buffer;
9f2ebf
+    size_t buflen;
9f2ebf
+};
9f2ebf
+
9f2ebf
+int sss_nss_getgr_readrep(struct sss_nss_gr_rep *pr,
9f2ebf
+                          uint8_t *buf, size_t *len);
9f2ebf
diff --git a/src/sss_client/nss_group.c b/src/sss_client/nss_group.c
9f2ebf
index 0e686af43aeb84a5938315e3922e9fcf2fef4e83..42fba6242d23fc1d52cfd7be10cf10383010f091 100644
9f2ebf
--- a/src/sss_client/nss_group.c
9f2ebf
+++ b/src/sss_client/nss_group.c
9f2ebf
@@ -29,6 +29,7 @@
9f2ebf
 #include <stdbool.h>
9f2ebf
 #include "sss_cli.h"
9f2ebf
 #include "nss_mc.h"
9f2ebf
+#include "nss_common.h"
9f2ebf
 
9f2ebf
 static struct sss_nss_getgrent_data {
9f2ebf
     size_t len;
9f2ebf
@@ -190,14 +191,9 @@ done:
9f2ebf
  *
9f2ebf
  *  FIXME: do we need to pad so that each result is 32 bit aligned ?
9f2ebf
  */
9f2ebf
-struct sss_nss_gr_rep {
9f2ebf
-    struct group *result;
9f2ebf
-    char *buffer;
9f2ebf
-    size_t buflen;
9f2ebf
-};
9f2ebf
 
9f2ebf
-static int sss_nss_getgr_readrep(struct sss_nss_gr_rep *pr,
9f2ebf
-                                 uint8_t *buf, size_t *len)
9f2ebf
+int sss_nss_getgr_readrep(struct sss_nss_gr_rep *pr,
9f2ebf
+                          uint8_t *buf, size_t *len)
9f2ebf
 {
9f2ebf
     errno_t ret;
9f2ebf
     size_t i, l, slen, ptmem, pad, dlen, glen;
9f2ebf
diff --git a/src/sss_client/nss_passwd.c b/src/sss_client/nss_passwd.c
9f2ebf
index c43f9bc50f43599b541e97f5a5aa60de036a5cdf..61e2a567e684fbc7664b5d425e81cfa28a98e845 100644
9f2ebf
--- a/src/sss_client/nss_passwd.c
9f2ebf
+++ b/src/sss_client/nss_passwd.c
9f2ebf
@@ -28,6 +28,7 @@
9f2ebf
 #include <string.h>
9f2ebf
 #include "sss_cli.h"
9f2ebf
 #include "nss_mc.h"
9f2ebf
+#include "nss_common.h"
9f2ebf
 
9f2ebf
 static struct sss_nss_getpwent_data {
9f2ebf
     size_t len;
9f2ebf
@@ -63,14 +64,8 @@ static void sss_nss_getpwent_data_clean(void) {
9f2ebf
  *  8-X: sequence of 5, 0 terminated, strings (name, passwd, gecos, dir, shell)
9f2ebf
  */
9f2ebf
 
9f2ebf
-struct sss_nss_pw_rep {
9f2ebf
-    struct passwd *result;
9f2ebf
-    char *buffer;
9f2ebf
-    size_t buflen;
9f2ebf
-};
9f2ebf
-
9f2ebf
-static int sss_nss_getpw_readrep(struct sss_nss_pw_rep *pr,
9f2ebf
-                                 uint8_t *buf, size_t *len)
9f2ebf
+int sss_nss_getpw_readrep(struct sss_nss_pw_rep *pr,
9f2ebf
+                          uint8_t *buf, size_t *len)
9f2ebf
 {
9f2ebf
     errno_t ret;
9f2ebf
     size_t i, slen, dlen;
9f2ebf
-- 
9f2ebf
2.13.6
9f2ebf