From 357973d13822ad33048e045523b26a0dc64d7c14 Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzeleny@redhat.com>
Date: Wed, 12 Oct 2011 09:14:57 -0400
Subject: [PATCH 1/5] Renamed some LDAP routines

These were renamed just ot make sure they are not mistook for IPA
netgroup functions.
---
 src/providers/ldap/ldap_common.h          |   10 +++---
 src/providers/ldap/ldap_id.c              |    4 +-
 src/providers/ldap/ldap_id_netgroup.c     |   46 ++++++++++++++--------------
 src/providers/ldap/sdap.h                 |    1 +
 src/providers/ldap/sdap_async_netgroups.c |   14 ++-------
 src/providers/ldap/sdap_async_private.h   |   15 +++++++++
 6 files changed, 49 insertions(+), 41 deletions(-)

diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
index e64b65c24e1c421fe505cb96c4a420412fc7bac8..770ffc8f5ef8ea091e78313105c1c03e2df4d565 100644
--- a/src/providers/ldap/ldap_common.h
+++ b/src/providers/ldap/ldap_common.h
@@ -136,11 +136,11 @@ struct tevent_req *groups_get_send(TALLOC_CTX *memctx,
 int groups_get_recv(struct tevent_req *req, int *dp_error_out);
 
 
-struct tevent_req *netgroup_get_send(TALLOC_CTX *memctx,
-                                                      struct tevent_context *ev,
-                                                      struct sdap_id_ctx *ctx,
-                                                      const char *name);
-int netgroup_get_recv(struct tevent_req *req, int *dp_error_out);
+struct tevent_req *ldap_netgroup_get_send(TALLOC_CTX *memctx,
+                                          struct tevent_context *ev,
+                                          struct sdap_id_ctx *ctx,
+                                          const char *name);
+int ldap_netgroup_get_recv(struct tevent_req *req, int *dp_error_out);
 /* setup child logging */
 int setup_child(struct sdap_id_ctx *ctx);
 
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
index d300184886244e030fb9fdd629d2596f3c54922b..b8e9563bda3053217c223f1352bd3474613cbc2f 100644
--- a/src/providers/ldap/ldap_id.c
+++ b/src/providers/ldap/ldap_id.c
@@ -815,7 +815,7 @@ void sdap_account_info_handler(struct be_req *breq)
             break;
         }
 
-        req = netgroup_get_send(breq, breq->be_ctx->ev, ctx, ar->filter_value);
+        req = ldap_netgroup_get_send(breq, breq->be_ctx->ev, ctx, ar->filter_value);
         if (!req) {
             return sdap_handler_done(breq, DP_ERR_FATAL, ENOMEM, "Out of memory");
         }
@@ -893,7 +893,7 @@ static void sdap_account_info_netgroups_done(struct tevent_req *req)
     struct be_req *breq = tevent_req_callback_data(req, struct be_req);
     int ret, dp_error;
 
-    ret = netgroup_get_recv(req, &dp_error);
+    ret = ldap_netgroup_get_recv(req, &dp_error);
     talloc_zfree(req);
 
     sdap_account_info_complete(breq, dp_error, ret, "Netgroup lookup failed");
diff --git a/src/providers/ldap/ldap_id_netgroup.c b/src/providers/ldap/ldap_id_netgroup.c
index e05aaa752055d119e8c0a1287edd7e7410e445e4..2432f9c4fad24f3e780b2a0524d7d696499534b2 100644
--- a/src/providers/ldap/ldap_id_netgroup.c
+++ b/src/providers/ldap/ldap_id_netgroup.c
@@ -30,7 +30,7 @@
 #include "providers/ldap/sdap_async.h"
 
 
-struct netgroup_get_state {
+struct ldap_netgroup_get_state {
     struct tevent_context *ev;
     struct sdap_id_ctx *ctx;
     struct sdap_id_op *op;
@@ -49,21 +49,21 @@ struct netgroup_get_state {
     int dp_error;
 };
 
-static int netgroup_get_retry(struct tevent_req *req);
-static void netgroup_get_connect_done(struct tevent_req *subreq);
-static void netgroup_get_done(struct tevent_req *subreq);
+static int ldap_netgroup_get_retry(struct tevent_req *req);
+static void ldap_netgroup_get_connect_done(struct tevent_req *subreq);
+static void ldap_netgroup_get_done(struct tevent_req *subreq);
 
-struct tevent_req *netgroup_get_send(TALLOC_CTX *memctx,
+struct tevent_req *ldap_netgroup_get_send(TALLOC_CTX *memctx,
                                      struct tevent_context *ev,
                                      struct sdap_id_ctx *ctx,
                                      const char *name)
 {
     struct tevent_req *req;
-    struct netgroup_get_state *state;
+    struct ldap_netgroup_get_state *state;
     char *clean_name;
     int ret;
 
-    req = tevent_req_create(memctx, &state, struct netgroup_get_state);
+    req = tevent_req_create(memctx, &state, struct ldap_netgroup_get_state);
     if (!req) return NULL;
 
     state->ev = ev;
@@ -102,7 +102,7 @@ struct tevent_req *netgroup_get_send(TALLOC_CTX *memctx,
                                SDAP_OPTS_NETGROUP, &state->attrs);
     if (ret != EOK) goto fail;
 
-    ret = netgroup_get_retry(req);
+    ret = ldap_netgroup_get_retry(req);
     if (ret != EOK) {
         goto fail;
     }
@@ -115,10 +115,10 @@ fail:
     return req;
 }
 
-static int netgroup_get_retry(struct tevent_req *req)
+static int ldap_netgroup_get_retry(struct tevent_req *req)
 {
-    struct netgroup_get_state *state = tevent_req_data(req,
-                                                    struct netgroup_get_state);
+    struct ldap_netgroup_get_state *state = tevent_req_data(req,
+                                                    struct ldap_netgroup_get_state);
     struct tevent_req *subreq;
     int ret = EOK;
 
@@ -127,16 +127,16 @@ static int netgroup_get_retry(struct tevent_req *req)
         return ret;
     }
 
-    tevent_req_set_callback(subreq, netgroup_get_connect_done, req);
+    tevent_req_set_callback(subreq, ldap_netgroup_get_connect_done, req);
     return EOK;
 }
 
-static void netgroup_get_connect_done(struct tevent_req *subreq)
+static void ldap_netgroup_get_connect_done(struct tevent_req *subreq)
 {
     struct tevent_req *req = tevent_req_callback_data(subreq,
                                                       struct tevent_req);
-    struct netgroup_get_state *state = tevent_req_data(req,
-                                                    struct netgroup_get_state);
+    struct ldap_netgroup_get_state *state = tevent_req_data(req,
+                                                    struct ldap_netgroup_get_state);
     int dp_error = DP_ERR_FATAL;
     int ret;
 
@@ -160,17 +160,17 @@ static void netgroup_get_connect_done(struct tevent_req *subreq)
         tevent_req_error(req, ENOMEM);
         return;
     }
-    tevent_req_set_callback(subreq, netgroup_get_done, req);
+    tevent_req_set_callback(subreq, ldap_netgroup_get_done, req);
 
     return;
 }
 
-static void netgroup_get_done(struct tevent_req *subreq)
+static void ldap_netgroup_get_done(struct tevent_req *subreq)
 {
     struct tevent_req *req = tevent_req_callback_data(subreq,
                                                       struct tevent_req);
-    struct netgroup_get_state *state = tevent_req_data(req,
-                                                    struct netgroup_get_state);
+    struct ldap_netgroup_get_state *state = tevent_req_data(req,
+                                                    struct ldap_netgroup_get_state);
     int dp_error = DP_ERR_FATAL;
     int ret;
 
@@ -181,7 +181,7 @@ static void netgroup_get_done(struct tevent_req *subreq)
 
     if (dp_error == DP_ERR_OK && ret != EOK) {
         /* retry */
-        ret = netgroup_get_retry(req);
+        ret = ldap_netgroup_get_retry(req);
         if (ret != EOK) {
             tevent_req_error(req, ret);
             return;
@@ -216,10 +216,10 @@ static void netgroup_get_done(struct tevent_req *subreq)
     return;
 }
 
-int netgroup_get_recv(struct tevent_req *req, int *dp_error_out)
+int ldap_netgroup_get_recv(struct tevent_req *req, int *dp_error_out)
 {
-    struct netgroup_get_state *state = tevent_req_data(req,
-                                                    struct netgroup_get_state);
+    struct ldap_netgroup_get_state *state = tevent_req_data(req,
+                                                    struct ldap_netgroup_get_state);
 
     if (dp_error_out) {
         *dp_error_out = state->dp_error;
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index b32560a8ffef3b55913aa1a4e6e82f27e5b3642e..7ad5da6c636d94fa2ca83322dee44b9b31af5738 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -299,6 +299,7 @@ struct sdap_options {
     struct sdap_attr_map *user_map;
     struct sdap_attr_map *group_map;
     struct sdap_attr_map *netgroup_map;
+    struct sdap_attr_map *host_map;
 
     /* supported schema types */
     enum schema_type {
diff --git a/src/providers/ldap/sdap_async_netgroups.c b/src/providers/ldap/sdap_async_netgroups.c
index 1f0d1dd27c28953135100b414d96c8070c6d615a..ed8a41aaebdc53cc5d76e0440dcbc854212ec2c3 100644
--- a/src/providers/ldap/sdap_async_netgroups.c
+++ b/src/providers/ldap/sdap_async_netgroups.c
@@ -27,7 +27,7 @@
 #include "providers/ldap/sdap_async_private.h"
 #include "providers/ldap/ldap_common.h"
 
-static bool is_dn(const char *str)
+bool is_dn(const char *str)
 {
     int ret;
     LDAPDN dn;
@@ -183,16 +183,8 @@ fail:
     return ret;
 }
 
-struct dn_item {
-    const char *dn;
-    struct sysdb_attrs *netgroup;
-    char *cn;
-    struct dn_item *next;
-    struct dn_item *prev;
-};
-
-static errno_t update_dn_list(struct dn_item *dn_list, const size_t count,
-                              struct ldb_message **res, bool *all_resolved)
+errno_t update_dn_list(struct dn_item *dn_list, const size_t count,
+                       struct ldb_message **res, bool *all_resolved)
 {
     struct dn_item *dn_item;
     size_t c;
diff --git a/src/providers/ldap/sdap_async_private.h b/src/providers/ldap/sdap_async_private.h
index fa7844e720732eb2040dbb708b29ffd4304bc581..4192a225efaa94f00b420836c6276f63529e2718 100644
--- a/src/providers/ldap/sdap_async_private.h
+++ b/src/providers/ldap/sdap_async_private.h
@@ -26,6 +26,21 @@
 #include "util/sss_krb5.h"
 #include "providers/ldap/sdap_async.h"
 
+struct dn_item {
+    const char *dn;
+    /* Parent netgroup containing this record */
+    struct sysdb_attrs *netgroup;
+    char *cn;
+    struct dn_item *next;
+    struct dn_item *prev;
+};
+
+bool is_dn(const char *str);
+errno_t update_dn_list(struct dn_item *dn_list,
+                       const size_t count,
+                       struct ldb_message **res,
+                       bool *all_resolved);
+
 void make_realm_upper_case(const char *upn);
 struct sdap_handle *sdap_handle_create(TALLOC_CTX *memctx);
 
-- 
1.7.6.4

