Blame SOURCES/authconfig-6.2.8-multiple-ldap-uris.patch

ee2f06
diff -up authconfig-6.2.8/authconfig-gtk.py.ldap-uris authconfig-6.2.8/authconfig-gtk.py
ee2f06
--- authconfig-6.2.8/authconfig-gtk.py.ldap-uris	2014-09-29 15:41:20.000000000 +0200
ee2f06
+++ authconfig-6.2.8/authconfig-gtk.py	2014-09-29 15:49:09.277372121 +0200
ee2f06
@@ -526,6 +526,7 @@ class Authconfig:
ee2f06
 		if not ldapserver:
ee2f06
 			return True
ee2f06
 		uritovalidate = ldapserver.get_text()
ee2f06
+		uritovalidate = self.info.ldapHostsToURIs(uritovalidate, False)
ee2f06
 		return self.info.validateLDAPURI(uritovalidate)
ee2f06
 
ee2f06
 	def enable_cacert_download(self, active, xml):
ee2f06
diff -up authconfig-6.2.8/authinfo.py.ldap-uris authconfig-6.2.8/authinfo.py
ee2f06
--- authconfig-6.2.8/authinfo.py.ldap-uris	2014-09-29 15:44:28.000000000 +0200
ee2f06
+++ authconfig-6.2.8/authinfo.py	2014-09-29 15:49:48.156249829 +0200
ee2f06
@@ -1588,20 +1588,24 @@ class AuthInfo:
ee2f06
 
ee2f06
 	def validateLDAPURI(self, s):
ee2f06
 		"""
ee2f06
-		Check LDAP URI provided in the form of literal IPv6 address
ee2f06
-		for correctness.
ee2f06
-
ee2f06
-		Return False if IPv6 valid is invalid or urlparse failed to
ee2f06
-		obtain integer port value, True otherwise.
ee2f06
+		Check whether LDAP URI is valid.
ee2f06
 		"""
ee2f06
-		try:
ee2f06
-			p = urlparse.urlparse(s).port
ee2f06
-			return True
ee2f06
-		except ValueError:
ee2f06
-			return False
ee2f06
+		if ',' in s:
ee2f06
+			uris = s.split(',')
ee2f06
+		else:
ee2f06
+			uris = s.split()
ee2f06
+		for uri in uris:
ee2f06
+			try:
ee2f06
+				p = urlparse.urlparse(uri).port
ee2f06
+			except (ValueError, socket.error):
ee2f06
+				return False
ee2f06
+		return True
ee2f06
 
ee2f06
-	def ldapHostsToURIs(self, s):
ee2f06
-		l = s.split(",")
ee2f06
+	def ldapHostsToURIs(self, s, validate):
ee2f06
+		if ',' in s:
ee2f06
+			l = s.split(',')
ee2f06
+		else:
ee2f06
+			l = s.split()
ee2f06
 		ret = ""
ee2f06
 		for item in l:
ee2f06
 			if item:
ee2f06
@@ -1611,9 +1615,8 @@ class AuthInfo:
ee2f06
 					ret += item
ee2f06
 				else:
ee2f06
 					ret += "ldap://" + item + "/"
ee2f06
-		if not self.validateLDAPURI(ret):
ee2f06
+		if validate and not self.validateLDAPURI(ret):
ee2f06
 			self.messageCB(_("Invalid LDAP URI."))
ee2f06
-			return ""
ee2f06
 		return ret
ee2f06
 
ee2f06
 	# Read LDAP setup from /etc/ldap.conf.
ee2f06
@@ -1669,7 +1672,7 @@ class AuthInfo:
ee2f06
 			# We'll pull MD5/DES crypt ("pam_password") from the config
ee2f06
 			# file, or from the pam_unix PAM config lines.
ee2f06
 
ee2f06
-		self.ldapServer = self.ldapHostsToURIs(cleanList(self.ldapServer))
ee2f06
+		self.ldapServer = self.ldapHostsToURIs(cleanList(self.ldapServer), False)
ee2f06
 		f.close()
ee2f06
 		return True
ee2f06
 
ee2f06
@@ -2456,12 +2459,12 @@ class AuthInfo:
ee2f06
 	# suggestions we "know".  The second case is when the user has just made a
ee2f06
 	# change to one field and we need to update another field to somehow
ee2f06
 	# compensate for the change.
ee2f06
-	def update(self):
ee2f06
+	def update(self, validate=False):
ee2f06
 		self.smbServers = cleanList(self.smbServers)
ee2f06
 		self.ipav2Server = cleanList(self.ipav2Server)
ee2f06
 		self.kerberosKDC = cleanList(self.kerberosKDC)
ee2f06
 		self.kerberosAdminServer = cleanList(self.kerberosAdminServer)
ee2f06
-		self.ldapServer = self.ldapHostsToURIs(self.ldapServer)
ee2f06
+		self.ldapServer = self.ldapHostsToURIs(self.ldapServer, validate)
ee2f06
 		if self.smbSecurity == "ads":
ee2f06
 			# As of this writing, an ADS implementation always
ee2f06
 			# upper-cases the realm name, even if only internally,
ee2f06
@@ -4024,7 +4027,7 @@ class AuthInfo:
ee2f06
 			self.ipaUninstall = True
ee2f06
 
ee2f06
 	def write(self):
ee2f06
-		self.update()
ee2f06
+		self.update(True)
ee2f06
 		self.prewriteUpdate()
ee2f06
 		self.setupBackup(PATH_CONFIG_BACKUPS + "/last")
ee2f06
 		try:
ee2f06
@@ -4064,7 +4067,7 @@ class AuthInfo:
ee2f06
 
ee2f06
 	def writeChanged(self, ref):
ee2f06
 		self.checkPAMLinked()
ee2f06
-		self.update()
ee2f06
+		self.update(True)
ee2f06
 		self.prewriteUpdate()
ee2f06
 		self.setupBackup(PATH_CONFIG_BACKUPS + "/last")
ee2f06
 		ret = True