Blame SOURCES/authconfig-6.2.8-sssd-do-not-write-PAM-if-no-sssd-conf.patch

ee2f06
diff -Naur old/authinfo.py new/authinfo.py
ee2f06
--- old/authinfo.py	2017-04-28 12:04:32.204470232 +0200
ee2f06
+++ new/authinfo.py	2017-04-28 12:10:10.534170041 +0200
ee2f06
@@ -1432,6 +1432,7 @@
ee2f06
 		self.sssdConfig = None
ee2f06
 		self.sssdDomain = None
ee2f06
 		self.forceSSSDUpdate = None
ee2f06
+		self.sssdConfigPresent = False
ee2f06
 		if SSSDConfig:
ee2f06
 			try:
ee2f06
 				self.sssdConfig = SSSDConfig.SSSDConfig()
ee2f06
@@ -1915,6 +1916,7 @@
ee2f06
 		self.sssdConfig = SSSDConfig.SSSDConfig()
ee2f06
 		try:
ee2f06
 			self.sssdConfig.import_config(all_configs[CFG_SSSD].origPath)
ee2f06
+			self.sssdConfigPresent = True
ee2f06
 		except (IOError, SSSDConfig.ParsingError):
ee2f06
 			self.sssdConfig = SSSDConfig.SSSDConfig()
ee2f06
 			self.sssdConfig.new_config()
ee2f06
@@ -3321,9 +3323,14 @@
ee2f06
 				domain.remove_provider(subtype)
ee2f06
 			domain.add_provider(newprovider, subtype)
ee2f06
 
ee2f06
-	def writeSSSDPAM(self):
ee2f06
+	def writeSSSDPAM(self, write_config):
ee2f06
 		if not self.sssdConfig:
ee2f06
 			return True
ee2f06
+		
ee2f06
+		if not self.sssdConfigPresent and not self.implicitSSSD:
ee2f06
+			# do not write to sssd.conf since the file does not exist yet and
ee2f06
+			# we are not creating the domain ourselves
ee2f06
+			return True
ee2f06
 
ee2f06
 		try:
ee2f06
 			pam = self.sssdConfig.get_service('pam')
ee2f06
@@ -3339,10 +3346,11 @@
ee2f06
 				pass
ee2f06
 
ee2f06
 		self.sssdConfig.save_service(pam)
ee2f06
-		try:
ee2f06
-			self.sssdConfig.write(all_configs[CFG_SSSD].origPath)
ee2f06
-		except IOError:
ee2f06
-			pass
ee2f06
+		if write_config:
ee2f06
+			try:
ee2f06
+				self.sssdConfig.write(all_configs[CFG_SSSD].origPath)
ee2f06
+			except IOError:
ee2f06
+				pass
ee2f06
 
ee2f06
 		return True
ee2f06
 
ee2f06
@@ -3352,7 +3360,8 @@
ee2f06
 
ee2f06
 		all_configs[CFG_SSSD].backup(self.backupDir)
ee2f06
 		
ee2f06
-		self.writeSSSDPAM()
ee2f06
+		# do not write to the file yet since we will write all changes at ones
ee2f06
+		self.writeSSSDPAM(False)
ee2f06
 
ee2f06
 		if self.enableIPAv2:
ee2f06
 			# just save the backup
ee2f06
@@ -4172,7 +4181,7 @@
ee2f06
 			if self.implicitSSSD or self.implicitSSSDAuth:
ee2f06
 				ret = ret and self.writeSSSD()
ee2f06
 			elif self.enableSSSDAuth:
ee2f06
-				ret = ret and self.writeSSSDPAM()
ee2f06
+				ret = ret and self.writeSSSDPAM(True)
ee2f06
 			ret = ret and self.writeNSS()
ee2f06
 			ret = ret and self.writePAM()
ee2f06
 			ret = ret and self.writeSysconfig()