dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0017-DYNDNS-special-value-for-dyndns_iface-option.patch

6cf099
From 65976fe3f9db1fc9581bb00060be38c48512b672 Mon Sep 17 00:00:00 2001
6cf099
From: Pavel Reichl <preichl@redhat.com>
6cf099
Date: Tue, 14 Jul 2015 04:21:34 -0400
6cf099
Subject: [PATCH 17/19] DYNDNS: special value '*' for dyndns_iface option
6cf099
6cf099
Option dyndns_iface has now special value '*' which implies that IPs
6cf099
from add interfaces should be sent during DDNS update.
6cf099
---
6cf099
 src/man/sssd-ad.5.xml     |  6 ++++--
6cf099
 src/man/sssd-ipa.5.xml    |  9 ++++-----
6cf099
 src/providers/dp_dyndns.c | 20 ++++++++++++++++----
6cf099
 3 files changed, 24 insertions(+), 11 deletions(-)
6cf099
6cf099
diff --git a/src/man/sssd-ad.5.xml b/src/man/sssd-ad.5.xml
6cf099
index ff43ea37066514a87934d07b141e680416dcc05b..3cbc10520098372d984d00425d03832d002d6672 100644
6cf099
--- a/src/man/sssd-ad.5.xml
6cf099
+++ b/src/man/sssd-ad.5.xml
6cf099
@@ -756,10 +756,12 @@ ad_gpo_map_deny = +my_pam_service
6cf099
                             Optional. Applicable only when dyndns_update
6cf099
                             is true. Choose the interface or a list of interfaces
6cf099
                             whose IP addresses should be used for dynamic DNS
6cf099
-                            updates.
6cf099
+                            updates. Special value <quote>*</quote> implies that
6cf099
+                            IPs from all interfaces should be used.
6cf099
                         </para>
6cf099
                         <para>
6cf099
-                            Default: Use the IP address of the AD LDAP connection
6cf099
+                            Default: Use the IP addresses of the interface which
6cf099
+                            is used for AD LDAP connection
6cf099
                         </para>
6cf099
                         <para>
6cf099
                             Example: dyndns_iface = em1, vnet1, vnet2
6cf099
diff --git a/src/man/sssd-ipa.5.xml b/src/man/sssd-ipa.5.xml
6cf099
index d450c2fadbb1713096ff766bf536702195cfd137..2e985991fde10827aff0e7c8e67f29a009683450 100644
6cf099
--- a/src/man/sssd-ipa.5.xml
6cf099
+++ b/src/man/sssd-ipa.5.xml
6cf099
@@ -168,10 +168,8 @@
6cf099
                             Optional. Applicable only when dyndns_update
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 multiple interfaces.
6cf099
+                            updates. Special value <quote>*</quote> implies that
6cf099
+                            IPs from all interfaces should be used.
6cf099
                         </para>
6cf099
                         <para>
6cf099
                             NOTE: While it is still possible to use the old
6cf099
@@ -180,7 +178,8 @@
6cf099
                             in their config file.
6cf099
                         </para>
6cf099
                         <para>
6cf099
-                            Default: Use the IP address of the IPA LDAP connection
6cf099
+                            Default: Use the IP addresses of the interface which
6cf099
+                            is used for IPA LDAP connection
6cf099
                         </para>
6cf099
                         <para>
6cf099
                             Example: dyndns_iface = em1, vnet1, vnet2
6cf099
diff --git a/src/providers/dp_dyndns.c b/src/providers/dp_dyndns.c
6cf099
index 76562840ef1d427629e41617b871caaedab779d4..03389acfba13e566540ca8b0570c0d009173575f 100644
6cf099
--- a/src/providers/dp_dyndns.c
6cf099
+++ b/src/providers/dp_dyndns.c
6cf099
@@ -42,6 +42,9 @@
6cf099
 #define DYNDNS_TIMEOUT 15
6cf099
 #endif /* DYNDNS_TIMEOUT */
6cf099
 
6cf099
+/* MASK represents special value for matching all interfaces */
6cf099
+#define MASK "*"
6cf099
+
6cf099
 struct sss_iface_addr {
6cf099
     struct sss_iface_addr *next;
6cf099
     struct sss_iface_addr *prev;
6cf099
@@ -171,6 +174,16 @@ ok_for_dns(struct sockaddr *sa)
6cf099
     return true;
6cf099
 }
6cf099
 
6cf099
+static bool supported_address_family(sa_family_t sa_family)
6cf099
+{
6cf099
+    return sa_family == AF_INET || sa_family == AF_INET6;
6cf099
+}
6cf099
+
6cf099
+static bool matching_name(const char *ifname, const char *ifname2)
6cf099
+{
6cf099
+    return (strcmp(MASK, ifname) == 0) || (strcasecmp(ifname, ifname2) == 0);
6cf099
+}
6cf099
+
6cf099
 /* Collect IP addresses associated with an interface */
6cf099
 errno_t
6cf099
 sss_iface_addr_list_get(TALLOC_CTX *mem_ctx, const char *ifname,
6cf099
@@ -200,10 +213,9 @@ sss_iface_addr_list_get(TALLOC_CTX *mem_ctx, const char *ifname,
6cf099
         if (!ifa->ifa_addr) continue;
6cf099
 
6cf099
         /* Add IP addresses to the list */
6cf099
-        if ((ifa->ifa_addr->sa_family == AF_INET ||
6cf099
-             ifa->ifa_addr->sa_family == AF_INET6) &&
6cf099
-             strcasecmp(ifa->ifa_name, ifname) == 0 &&
6cf099
-             ok_for_dns(ifa->ifa_addr)) {
6cf099
+        if (supported_address_family(ifa->ifa_addr->sa_family)
6cf099
+                && matching_name(ifname, ifa->ifa_name)
6cf099
+                && ok_for_dns(ifa->ifa_addr)) {
6cf099
 
6cf099
             /* Add this address to the IP address list */
6cf099
             address = talloc_zero(mem_ctx, struct sss_iface_addr);
6cf099
-- 
6cf099
2.4.3
6cf099