Blame SOURCES/authconfig-6.2.8-restorecon.patch

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