Blame SOURCES/0016-DYNDNS-support-mult.-interfaces-for-dyndns_iface-opt.patch

6cf099
From e1936ccbb810965e90d030c2ed8f420c084b6a22 Mon Sep 17 00:00:00 2001
6cf099
From: Pavel Reichl <preichl@redhat.com>
6cf099
Date: Wed, 8 Jul 2015 09:08:03 -0400
6cf099
Subject: [PATCH 16/19] DYNDNS: support mult. interfaces for dyndns_iface opt
6cf099
6cf099
Resolves:
6cf099
https://fedorahosted.org/sssd/ticket/2549
6cf099
---
6cf099
 src/man/sssd-ad.5.xml            | 11 +++---
6cf099
 src/man/sssd-ipa.5.xml           | 10 ++++--
6cf099
 src/providers/dp_dyndns.c        |  6 ++++
6cf099
 src/providers/dp_dyndns.h        |  4 +++
6cf099
 src/providers/ldap/sdap_dyndns.c | 72 +++++++++++++++++++++++++++++++++++-----
6cf099
 5 files changed, 87 insertions(+), 16 deletions(-)
6cf099
6cf099
diff --git a/src/man/sssd-ad.5.xml b/src/man/sssd-ad.5.xml
6cf099
index 938a443e027b9bf83c75c240a7d6b2a0876b92c8..ff43ea37066514a87934d07b141e680416dcc05b 100644
6cf099
--- a/src/man/sssd-ad.5.xml
6cf099
+++ b/src/man/sssd-ad.5.xml
6cf099
@@ -754,15 +754,16 @@ ad_gpo_map_deny = +my_pam_service
6cf099
                     <listitem>
6cf099
                         <para>
6cf099
                             Optional. Applicable only when dyndns_update
6cf099
-                            is true. Choose the interface whose IP address
6cf099
-                            should be used for dynamic DNS updates.
6cf099
-                        </para>
6cf099
-                        <para>
6cf099
-                            NOTE: This option currently supports only one interface.
6cf099
+                            is true. Choose the interface or a list of interfaces
6cf099
+                            whose IP addresses should be used for dynamic DNS
6cf099
+                            updates.
6cf099
                         </para>
6cf099
                         <para>
6cf099
                             Default: Use the IP address of the AD LDAP connection
6cf099
                         </para>
6cf099
+                        <para>
6cf099
+                            Example: dyndns_iface = em1, vnet1, vnet2
6cf099
+                        </para>
6cf099
                     </listitem>
6cf099
                 </varlistentry>
6cf099
 
6cf099
diff --git a/src/man/sssd-ipa.5.xml b/src/man/sssd-ipa.5.xml
6cf099
index 0716b6235f93965170983856b930799bfded6258..d450c2fadbb1713096ff766bf536702195cfd137 100644
6cf099
--- a/src/man/sssd-ipa.5.xml
6cf099
+++ b/src/man/sssd-ipa.5.xml
6cf099
@@ -166,11 +166,12 @@
6cf099
                     <listitem>
6cf099
                         <para>
6cf099
                             Optional. Applicable only when dyndns_update
6cf099
-                            is true. Choose the interface whose IP address
6cf099
-                            should be used for dynamic DNS updates.
6cf099
+                            is true. Choose the interface or a list of interfaces
6cf099
+                            whose IP addresses should be used for dynamic DNS
6cf099
+                            updates.
6cf099
                         </para>
6cf099
                         <para>
6cf099
-                            NOTE: This option currently supports only one interface.
6cf099
+                            NOTE: This option currently supports multiple interfaces.
6cf099
                         </para>
6cf099
                         <para>
6cf099
                             NOTE: While it is still possible to use the old
6cf099
@@ -181,6 +182,9 @@
6cf099
                         <para>
6cf099
                             Default: Use the IP address of the IPA LDAP connection
6cf099
                         </para>
6cf099
+                        <para>
6cf099
+                            Example: dyndns_iface = em1, vnet1, vnet2
6cf099
+                        </para>
6cf099
                     </listitem>
6cf099
                 </varlistentry>
6cf099
 
6cf099
diff --git a/src/providers/dp_dyndns.c b/src/providers/dp_dyndns.c
6cf099
index 2ac43a108ff6197d9e2662198a6da976ca348e76..76562840ef1d427629e41617b871caaedab779d4 100644
6cf099
--- a/src/providers/dp_dyndns.c
6cf099
+++ b/src/providers/dp_dyndns.c
6cf099
@@ -49,6 +49,12 @@ struct sss_iface_addr {
6cf099
     struct sockaddr_storage *addr;
6cf099
 };
6cf099
 
6cf099
+void sss_iface_addr_concatenate(struct sss_iface_addr **list,
6cf099
+                                struct sss_iface_addr *list2)
6cf099
+{
6cf099
+    DLIST_CONCATENATE((*list), list2, struct sss_iface_addr*);
6cf099
+}
6cf099
+
6cf099
 struct sss_iface_addr *
6cf099
 sss_iface_addr_add(TALLOC_CTX *mem_ctx, struct sss_iface_addr **list,
6cf099
                    struct sockaddr_storage *ss)
6cf099
diff --git a/src/providers/dp_dyndns.h b/src/providers/dp_dyndns.h
6cf099
index 23b833dace58a0ecbb1e2e21963a55186f1d06a8..deba112538ad22cd7f59be07934778ee9d4361e7 100644
6cf099
--- a/src/providers/dp_dyndns.h
6cf099
+++ b/src/providers/dp_dyndns.h
6cf099
@@ -128,4 +128,8 @@ nsupdate_get_addrs_recv(struct tevent_req *req,
6cf099
                         struct sss_iface_addr **_addrlist,
6cf099
                         size_t *_count);
6cf099
 
6cf099
+void
6cf099
+sss_iface_addr_concatenate(struct sss_iface_addr **list,
6cf099
+                           struct sss_iface_addr *list2);
6cf099
+
6cf099
 #endif /* DP_DYNDNS_H_ */
6cf099
diff --git a/src/providers/ldap/sdap_dyndns.c b/src/providers/ldap/sdap_dyndns.c
6cf099
index e99a4f6687035928f6775c38b9df6b2a06d38f38..f5929cff3db6f724efcedeb963e3a12d04f6e1d3 100644
6cf099
--- a/src/providers/ldap/sdap_dyndns.c
6cf099
+++ b/src/providers/ldap/sdap_dyndns.c
6cf099
@@ -482,6 +482,65 @@ static void sdap_dyndns_get_addrs_done(struct tevent_req *subreq);
6cf099
 static errno_t sdap_dyndns_add_ldap_conn(struct sdap_dyndns_get_addrs_state *state,
6cf099
                                          struct sdap_handle *sh);
6cf099
 
6cf099
+static errno_t get_ifaces_addrs(TALLOC_CTX *mem_ctx,
6cf099
+                                const char *iface,
6cf099
+                                struct sss_iface_addr **_result)
6cf099
+{
6cf099
+    struct sss_iface_addr *result_addrs = NULL;
6cf099
+    struct sss_iface_addr *intf_addrs;
6cf099
+    TALLOC_CTX *tmp_ctx;
6cf099
+    char **list_of_intfs;
6cf099
+    int num_of_intfs;
6cf099
+    errno_t ret;
6cf099
+    int i;
6cf099
+
6cf099
+    tmp_ctx = talloc_new(NULL);
6cf099
+    if (tmp_ctx == NULL) {
6cf099
+        ret = ENOMEM;
6cf099
+        goto done;
6cf099
+    }
6cf099
+
6cf099
+    ret = split_on_separator(tmp_ctx, iface, ',', true, true, &list_of_intfs,
6cf099
+                             &num_of_intfs);
6cf099
+    if (ret != EOK) {
6cf099
+        DEBUG(SSSDBG_MINOR_FAILURE,
6cf099
+              "Parsing names of interfaces failed - %d:[%s].\n",
6cf099
+              ret, sss_strerror(ret));
6cf099
+        goto done;
6cf099
+    }
6cf099
+
6cf099
+    for (i = 0; i < num_of_intfs; i++) {
6cf099
+        ret = sss_iface_addr_list_get(tmp_ctx, list_of_intfs[i], &intf_addrs);
6cf099
+        if (ret == EOK) {
6cf099
+            if (result_addrs != NULL) {
6cf099
+                /* If there is already an existing list, head of this existing
6cf099
+                 * list will be considered as parent talloc context for the
6cf099
+                 * new list.
6cf099
+                 */
6cf099
+                talloc_steal(result_addrs, intf_addrs);
6cf099
+            }
6cf099
+            sss_iface_addr_concatenate(&result_addrs, intf_addrs);
6cf099
+        } else if (ret == ENOENT) {
6cf099
+            /* non-critical failure */
6cf099
+            DEBUG(SSSDBG_TRACE_FUNC,
6cf099
+                  "Cannot get interface %s or there are no addresses "
6cf099
+                  "bind to it.\n", list_of_intfs[i]);
6cf099
+        } else {
6cf099
+            DEBUG(SSSDBG_OP_FAILURE,
6cf099
+                  "Cannot get list of addresses from interface %s - %d:[%s]\n",
6cf099
+                  list_of_intfs[i], ret, sss_strerror(ret));
6cf099
+            goto done;
6cf099
+        }
6cf099
+    }
6cf099
+
6cf099
+    ret = EOK;
6cf099
+    *_result = talloc_steal(mem_ctx, result_addrs);
6cf099
+
6cf099
+done:
6cf099
+    talloc_free(tmp_ctx);
6cf099
+    return ret;
6cf099
+}
6cf099
+
6cf099
 static struct tevent_req *
6cf099
 sdap_dyndns_get_addrs_send(TALLOC_CTX *mem_ctx,
6cf099
                            struct tevent_context *ev,
6cf099
@@ -500,14 +559,11 @@ sdap_dyndns_get_addrs_send(TALLOC_CTX *mem_ctx,
6cf099
     }
6cf099
 
6cf099
     if (iface) {
6cf099
-        ret = sss_iface_addr_list_get(state, iface, &state->addresses);
6cf099
-        if (ret != EOK) {
6cf099
-            DEBUG(ret == ENOENT ? SSSDBG_MINOR_FAILURE : SSSDBG_OP_FAILURE,
6cf099
-                  "Cannot get list of addresses from interface %s\n", iface);
6cf099
-            /* non critical failure */
6cf099
-            if (ret == ENOENT) {
6cf099
-                ret = EOK;
6cf099
-            }
6cf099
+        ret = get_ifaces_addrs(state, iface, &state->addresses);
6cf099
+        if (ret != EOK || state->addresses == NULL) {
6cf099
+            DEBUG(SSSDBG_MINOR_FAILURE,
6cf099
+                  "get_ifaces_addrs() failed: %d:[%s]\n",
6cf099
+                  ret, sss_strerror(ret));
6cf099
         }
6cf099
         /* We're done. Just fake an async request completion */
6cf099
         goto done;
6cf099
-- 
6cf099
2.4.3
6cf099