Blame SOURCES/authconfig-6.2.8-ipav2join.patch

977b74
diff -up authconfig-6.2.8/authconfig-gtk.py.ipav2join authconfig-6.2.8/authconfig-gtk.py
977b74
--- authconfig-6.2.8/authconfig-gtk.py.ipav2join	2014-09-29 15:18:58.252487444 +0200
977b74
+++ authconfig-6.2.8/authconfig-gtk.py	2014-09-29 15:19:15.077867285 +0200
977b74
@@ -2,12 +2,13 @@
977b74
 # -*- coding: UTF-8 -*-
977b74
 #
977b74
 # Authconfig - client authentication configuration program
977b74
-# Copyright (c) 1999-2008 Red Hat, Inc.
977b74
+# Copyright (c) 1999-2014 Red Hat, Inc.
977b74
 #
977b74
 # Authors: Preston Brown <pbrown@redhat.com>
977b74
 #          Nalin Dahyabhai <nalin@redhat.com>
977b74
 #          Matt Wilson <msw@redhat.com>
977b74
 #          Tomas Mraz <tmraz@redhat.com>
977b74
+#          Jan Lieskovsky <jlieskov@redhat.com>
977b74
 #
977b74
 # This is free software; you can redistribute it and/or modify it
977b74
 # under the terms of the GNU General Public License as published by
977b74
@@ -236,6 +237,7 @@ class Authconfig:
977b74
 		self.oldrealm = ""
977b74
 		self.oldkdc = ""
977b74
 		self.oldadminserver = ""
977b74
+		self.messageParent = None
977b74
 
977b74
 	def destroy_widget(self, button, widget):
977b74
 		widget.destroy()
977b74
@@ -272,7 +274,9 @@ class Authconfig:
977b74
 		response = self.run_on_button(None, "joinwbdomain",
977b74
 					      "winbindjoin_map", parent)
977b74
 		if (response == gtk.RESPONSE_OK):
977b74
-			self.info.joinDomain(True)
977b74
+			self.messageParent = parent
977b74
+			self.info.joinDomain(False)
977b74
+			self.messageParent = None
977b74
 		self.info.joinUser = None
977b74
 		self.info.joinPassword = None
977b74
 
977b74
@@ -287,7 +291,9 @@ class Authconfig:
977b74
 		response = self.run_on_button(None, "joinipadomain",
977b74
 					      "ipav2join_map", parent)
977b74
 		if (response == gtk.RESPONSE_OK):
977b74
-			self.info.joinIPADomain(True)
977b74
+			self.messageParent = parent
977b74
+			self.info.joinIPADomain(False)
977b74
+			self.messageParent = None
977b74
 
977b74
 	def info_apply(self, map, xml):
977b74
 		for entry in map.keys():
977b74
@@ -796,10 +802,12 @@ class Authconfig:
977b74
 		response = self.run_on_button(None, "ldapcacertdownload",
977b74
 					      "ldapcacert_map", parent)
977b74
 		if (response == gtk.RESPONSE_OK):
977b74
+			self.messageParent = parent
977b74
 			self.info.downloadLDAPCACert()
977b74
+			self.messageParent = None
977b74
 
977b74
 	def message_callback(self, text):
977b74
-		msg = gtk.MessageDialog(None, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, text)
977b74
+		msg = gtk.MessageDialog(self.messageParent, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, text)
977b74
 		msg.set_title(_("Authentication Configuration"))
977b74
 		msg.run()
977b74
 		msg.destroy()
977b74
diff -up authconfig-6.2.8/authinfo.py.ipav2join authconfig-6.2.8/authinfo.py
977b74
--- authconfig-6.2.8/authinfo.py.ipav2join	2014-09-29 15:14:59.000000000 +0200
977b74
+++ authconfig-6.2.8/authinfo.py	2014-09-29 15:15:55.776367966 +0200
977b74
@@ -1,7 +1,7 @@
977b74
 # -*- coding: UTF-8 -*-
977b74
 #
977b74
 # Authconfig - client authentication configuration program
977b74
-# Copyright (c) 1999-2011 Red Hat, Inc.
977b74
+# Copyright (c) 1999-2014 Red Hat, Inc.
977b74
 #
977b74
 # Authors: Preston Brown <pbrown@redhat.com>
977b74
 #          Nalin Dahyabhai <nalin@redhat.com>
977b74
@@ -10,6 +10,7 @@
977b74
 #          Ray Strode <rstrode@redhat.com>
977b74
 #          Paolo Bonzini <pbonzini@redhat.com>
977b74
 #          Miloslav Trmac <mitr@redhat.com>
977b74
+#          Jan Lieskovsky <jlieskov@redhat.com>
977b74
 #
977b74
 # This is free software; you can redistribute it and/or modify it
977b74
 # under the terms of the GNU General Public License as published by
977b74
@@ -879,9 +880,17 @@ def feedFork(command, echo, query, respo
977b74
 		return 255
977b74
 	if not pid:
977b74
 		# child
977b74
-		status = os.system(command)
977b74
+		if query:
977b74
+			child = Popen([command], shell=True)
977b74
+		else:
977b74
+			child = Popen([command], stdin=PIPE, shell=True)
977b74
+			child.communicate(input=(response or '')+'\n')
977b74
+
977b74
+		# wait for the child to terminate & set the returncode
977b74
+		child.wait()
977b74
+		status = child.returncode
977b74
 		os._exit(status)
977b74
-	output = ""
977b74
+	(output, error) = ("","")
977b74
 	try:
977b74
 		i = fcntl.fcntl(master, fcntl.F_GETFL)
977b74
 		fcntl.fcntl(master, fcntl.F_SETFL, i & ~os.O_NONBLOCK)
977b74
@@ -918,13 +927,24 @@ def feedFork(command, echo, query, respo
977b74
 		if c:
977b74
 			try:
977b74
 				output += c
977b74
+				error += c
977b74
 				if echo:
977b74
 					sys.stderr.write(c)
977b74
-				if query in output:
977b74
-					os.write(master, response)
977b74
+				if query and query in output:
977b74
+					# Search for password prompt start
977b74
+					index = error.rfind("\r\n")
977b74
+					os.write(master, response or '')
977b74
 					os.write(master, "\r\n")
977b74
+					if index != -1:
977b74
+						# Drop password prompt substring from error
977b74
+						error = "\n" + error[:index]
977b74
+					else:
977b74
+						# Drop whole error content, password prompt
977b74
+						# was the first line
977b74
+						error = ""
977b74
 					output = ""
977b74
-					sys.stderr.write("<...>\n")
977b74
+					if echo:
977b74
+						sys.stderr.write("<...>\n")
977b74
 			except OSError, (err, text):
977b74
 				sys.stderr.write("write: " + text + "\n")
977b74
 				os.close(master)
977b74
@@ -941,7 +961,7 @@ def feedFork(command, echo, query, respo
977b74
 		(child, status) = os.waitpid(pid, 0)
977b74
 	except OSError, (err, text):
977b74
 		sys.stderr.write("waitpid: " + text + "\n")
977b74
-	return status
977b74
+	return (status, error)
977b74
 
977b74
 def isEmptyDir(path):
977b74
 	try:
977b74
@@ -4227,17 +4247,26 @@ class AuthInfo:
977b74
 				# Not needed -- "joining" is meaningless for other
977b74
 				# models.
977b74
 				return
977b74
-			cmd = "/usr/bin/net join %s%s %s%s -U %s" % (
977b74
+			cmd = PATH_WINBIND_NET + " join %s%s %s%s -U %s" % (
977b74
 				domain and "-w " or "", domain,
977b74
 				server and "-S " or "", server,
977b74
 				self.joinUser)
977b74
 			
977b74
 			if echo:
977b74
 				sys.stderr.write("[%s]\n" % cmd)
977b74
-			if self.joinPassword:
977b74
-				status = feedFork(cmd, echo, "sword:", self.joinPassword)
977b74
+				child = Popen([cmd], shell=True)
977b74
+				child.communicate()
977b74
+				status = child.returncode
977b74
+			else:
977b74
+				status, error = feedFork(cmd, echo, "sword:", self.joinPassword)
977b74
+			if echo:
977b74
+				if status != 0:
977b74
+					self.messageCB(_("Winbind domain join was not successful."))
977b74
 			else:
977b74
-				status = os.system(cmd)
977b74
+				if status != 0:
977b74
+					errmsg = _("Winbind domain join was not successful. The net join command failed with the following error:")
977b74
+					errmsg += "\n" + error
977b74
+					self.messageCB(errmsg)
977b74
 		return status == 0
977b74
 
977b74
 	def joinIPADomain(self, echo):
977b74
@@ -4258,22 +4287,30 @@ class AuthInfo:
977b74
 				realm and "--realm=" or "", realm,
977b74
 				principal and "--principal=" or "", principal,
977b74
 				nontp,
977b74
-				password and "-W" or "")
977b74
-			
977b74
+				not echo and "--unattended" or "-W")
977b74
+
977b74
 			if echo:
977b74
 				sys.stderr.write("[%s]\n" % cmd)
977b74
-			if self.joinPassword:
977b74
-				status = feedFork(cmd, echo, "sword:", self.joinPassword)
977b74
+				child = Popen([cmd], shell=True)
977b74
+				child.communicate()
977b74
+				status = child.returncode
977b74
 			else:
977b74
-				status = os.system(cmd)
977b74
+				status, error = feedFork(cmd, echo, '', password)
977b74
+
977b74
 			if status == 0:
977b74
 				self.ipaDomainJoined = True
977b74
+			if echo:
977b74
+				if status != 0:
977b74
+					self.messageCB(_("IPAv2 domain join was not successful."))
977b74
 			else:
977b74
-				self.messageCB(_("IPAv2 domain join was not succesful. The ipa-client-install command failed."))
977b74
+				if status != 0:
977b74
+					errmsg = _("IPAv2 domain join was not successful. The ipa-client-install command failed with the following error:")
977b74
+					errmsg += "\n" + error
977b74
+					self.messageCB(errmsg)
977b74
 		return status == 0
977b74
 
977b74
 	def uninstallIPA(self):
977b74
-		cmd = PATH_IPA_CLIENT_INSTALL + " --uninstall --noac"
977b74
+		cmd = PATH_IPA_CLIENT_INSTALL + " --uninstall --noac --unattended"
977b74
 		os.system(cmd)
977b74
 
977b74
 	def toggleCachingService(self, nostart):