Blame SOURCES/authconfig-6.2.8-restorecon.patch

ee2f06
diff -up authconfig-6.2.8/authinfo.py.restorecon authconfig-6.2.8/authinfo.py
ee2f06
--- authconfig-6.2.8/authinfo.py.restorecon	2014-01-29 15:21:07.000000000 +0100
ee2f06
+++ authconfig-6.2.8/authinfo.py	2014-01-29 15:21:32.024225923 +0100
ee2f06
@@ -1009,10 +1009,12 @@ class SaveGroup:
ee2f06
 class SafeFile:
ee2f06
 	def __init__(self, filename, default_mode):
ee2f06
 		(base, name) = os.path.split(filename)
ee2f06
+		self.missing = False
ee2f06
 		self.file = tempfile.NamedTemporaryFile(dir=base, prefix=name, delete=True)
ee2f06
 		# overwrite the inode attributes and contents
ee2f06
 		if call(["/bin/cp", "-af", filename, self.file.name],
ee2f06
 			stderr=os.open('/dev/null', os.O_WRONLY)) == 1:
ee2f06
+			self.missing = True
ee2f06
 			# the mode was not copied, use the default
ee2f06
 			os.fchmod(self.file.fileno(), default_mode)
ee2f06
 		self.filename = filename
ee2f06
@@ -1021,6 +1023,9 @@ class SafeFile:
ee2f06
 		self.file.flush()
ee2f06
 		os.fsync(self.file.fileno())
ee2f06
 		os.rename(self.file.name, self.filename)
ee2f06
+		if self.missing:
ee2f06
+			call(["/usr/sbin/restorecon", self.filename],
ee2f06
+				stderr=os.open('/dev/null', os.O_WRONLY))
ee2f06
 
ee2f06
 	def close(self):
ee2f06
 		# we may have renamed the temp file, need to catch OSError
ee2f06
@@ -1111,7 +1116,9 @@ class FileBackup:
ee2f06
 			rv = self.safeCopy(backuppath, self.origPath)
ee2f06
 
ee2f06
 		try:
ee2f06
-			os.system("restorecon '"+self.origPath+"'")
ee2f06
+			if rv:
ee2f06
+				call(["/usr/sbin/restorecon", self.origPath],
ee2f06
+					stderr=os.open('/dev/null', os.O_WRONLY))
ee2f06
 		except (IOError, OSError):
ee2f06
 			pass
ee2f06