Tomas Mraz 4a3f2c
diff -up authconfig-6.2.8/authinfo.py.norestart authconfig-6.2.8/authinfo.py
Tomas Mraz 4a3f2c
--- authconfig-6.2.8/authinfo.py.norestart	2014-01-17 15:35:09.000000000 +0100
Tomas Mraz 4a3f2c
+++ authconfig-6.2.8/authinfo.py	2014-01-17 15:37:45.085207188 +0100
Tomas Mraz 4a3f2c
@@ -80,11 +80,6 @@ PATH_PWCONV = "/usr/sbin/pwconv"
Tomas Mraz 4a3f2c
 PATH_RPCBIND = "/sbin/rpcbind"
Tomas Mraz 4a3f2c
 PATH_NSCD = "/usr/sbin/nscd"
Tomas Mraz 4a3f2c
 PATH_NSLCD = "/usr/sbin/nslcd"
Tomas Mraz 4a3f2c
-PATH_DBBIND = "/usr/sbin/dbbind"
Tomas Mraz 4a3f2c
-PATH_DBIBIND = "/usr/sbin/dbibind"
Tomas Mraz 4a3f2c
-PATH_HESIODBIND = "/usr/sbin/hesiodbind"
Tomas Mraz 4a3f2c
-PATH_LDAPBIND = "/usr/sbin/ldapbind"
Tomas Mraz 4a3f2c
-PATH_ODBCBIND = "/usr/sbin/odbcbind"
Tomas Mraz 4a3f2c
 PATH_WINBIND = "/usr/sbin/winbindd"
Tomas Mraz 4a3f2c
 PATH_SSSD = "/usr/sbin/sssd"
Tomas Mraz 4a3f2c
 PATH_YPBIND = "/usr/sbin/ypbind"
Tomas Mraz 4a3f2c
@@ -848,77 +843,13 @@ try:
Tomas Mraz 4a3f2c
 except OSError:
Tomas Mraz 4a3f2c
 	Service = SysVInitService()
Tomas Mraz 4a3f2c
 
Tomas Mraz 4a3f2c
-def toggleCachingService(enableCaching, nostart, onlystart):
Tomas Mraz 4a3f2c
-	if not nostart:
Tomas Mraz 4a3f2c
-		if enableCaching:
Tomas Mraz 4a3f2c
-			if not onlystart:
Tomas Mraz 4a3f2c
-				Service.stop("nscd")
Tomas Mraz 4a3f2c
-			Service.start("nscd")
Tomas Mraz 4a3f2c
-		else:
Tomas Mraz 4a3f2c
-			try:
Tomas Mraz 4a3f2c
-				Service.stop("nscd")
Tomas Mraz 4a3f2c
-			except OSError:
Tomas Mraz 4a3f2c
-				pass
Tomas Mraz 4a3f2c
-	return True
Tomas Mraz 4a3f2c
-
Tomas Mraz 4a3f2c
-def toggleNisService(enableNis, nisDomain, nostart, onlystart):
Tomas Mraz 4a3f2c
-	if enableNis and nisDomain:
Tomas Mraz 4a3f2c
-		if not nostart:
Tomas Mraz 4a3f2c
-			os.system("/bin/domainname " + nisDomain)
Tomas Mraz 4a3f2c
-		try:
Tomas Mraz 4a3f2c
-			os.system("[[ $(getsebool allow_ypbind) == *off* ]] && setsebool -P allow_ypbind 1")
Tomas Mraz 4a3f2c
-			os.stat(PATH_RPCBIND)
Tomas Mraz 4a3f2c
-			Service.enable("rpcbind")
Tomas Mraz 4a3f2c
-			if not nostart:
Tomas Mraz 4a3f2c
-				Service.start("rpcbind")
Tomas Mraz 4a3f2c
-		except OSError:
Tomas Mraz 4a3f2c
-			pass
Tomas Mraz 4a3f2c
-		try:
Tomas Mraz 4a3f2c
-			os.stat(PATH_YPBIND)
Tomas Mraz 4a3f2c
-			Service.enable("ypbind")
Tomas Mraz 4a3f2c
-			if not nostart:
Tomas Mraz 4a3f2c
-				if not onlystart:
Tomas Mraz 4a3f2c
-					Service.stop("ypbind")
Tomas Mraz 4a3f2c
-				Service.start("ypbind")
Tomas Mraz 4a3f2c
-		except OSError:
Tomas Mraz 4a3f2c
-			pass
Tomas Mraz 4a3f2c
-	else:
Tomas Mraz 4a3f2c
-		if not nostart:
Tomas Mraz 4a3f2c
-			os.system("/bin/domainname \"(none)\"")
Tomas Mraz 4a3f2c
-		try:
Tomas Mraz 4a3f2c
-			os.system("[[ $(getsebool allow_ypbind) == *on* ]] && setsebool -P allow_ypbind 0")
Tomas Mraz 4a3f2c
-			os.stat(PATH_YPBIND)
Tomas Mraz 4a3f2c
-			if not nostart:
Tomas Mraz 4a3f2c
-				try:
Tomas Mraz 4a3f2c
-					Service.stop("ypbind")
Tomas Mraz 4a3f2c
-				except OSError:
Tomas Mraz 4a3f2c
-					pass
Tomas Mraz 4a3f2c
-			Service.disable("ypbind")
Tomas Mraz 4a3f2c
-		except OSError:
Tomas Mraz 4a3f2c
-			pass
Tomas Mraz 4a3f2c
-	return True
Tomas Mraz 4a3f2c
-
Tomas Mraz 4a3f2c
-def toggleLDAPService(enableLDAP):
Tomas Mraz 4a3f2c
-	if enableLDAP:
Tomas Mraz 4a3f2c
-		try:
Tomas Mraz 4a3f2c
-			os.system("[[ $(getsebool authlogin_nsswitch_use_ldap) == *off* ]] && setsebool -P authlogin_nsswitch_use_ldap 1")
Tomas Mraz 4a3f2c
-		except OSError:
Tomas Mraz 4a3f2c
-			pass
Tomas Mraz 4a3f2c
-	else:
Tomas Mraz 4a3f2c
-		try:
Tomas Mraz 4a3f2c
-			os.system("[[ $(getsebool authlogin_nsswitch_use_ldap) == *on* ]] && setsebool -P authlogin_nsswitch_use_ldap 0")
Tomas Mraz 4a3f2c
-		except OSError:
Tomas Mraz 4a3f2c
-			pass
Tomas Mraz 4a3f2c
-	return True
Tomas Mraz 4a3f2c
-
Tomas Mraz 4a3f2c
-def toggleSplatbindService(enable, path, name, nostart, onlystart):
Tomas Mraz 4a3f2c
+def toggleSplatbindService(enable, path, name, nostart):
Tomas Mraz 4a3f2c
 	if enable:
Tomas Mraz 4a3f2c
 		try:
Tomas Mraz 4a3f2c
 			os.stat(path)
Tomas Mraz 4a3f2c
 			Service.enable(name)
Tomas Mraz 4a3f2c
 			if not nostart:
Tomas Mraz 4a3f2c
-				if not onlystart:
Tomas Mraz 4a3f2c
-					Service.stop(name)
Tomas Mraz 4a3f2c
+				Service.stop(name)
Tomas Mraz 4a3f2c
 				Service.start(name)
Tomas Mraz 4a3f2c
 		except OSError:
Tomas Mraz 4a3f2c
 			pass
Tomas Mraz 4a3f2c
@@ -1055,8 +986,9 @@ def read(msgcb):
Tomas Mraz 4a3f2c
 	return info
Tomas Mraz 4a3f2c
 
Tomas Mraz 4a3f2c
 class SaveGroup:
Tomas Mraz 4a3f2c
-	def __init__(self, savefunc, attrlist):
Tomas Mraz 4a3f2c
+	def __init__(self, savefunc, togglefunc, attrlist):
Tomas Mraz 4a3f2c
 		self.saveFunction = savefunc
Tomas Mraz 4a3f2c
+		self.toggleFunction = togglefunc
Tomas Mraz 4a3f2c
 		self.attrlist = attrlist
Tomas Mraz 4a3f2c
 
Tomas Mraz 4a3f2c
 	def attrsDiffer(self, a, b):
Tomas Mraz 4a3f2c
@@ -1429,49 +1361,49 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		self.sssdConfig = None
Tomas Mraz 4a3f2c
 		self.sssdDomain = None
Tomas Mraz 4a3f2c
 		self.forceSSSDUpdate = None
Tomas Mraz 4a3f2c
-		self.confChanged = False
Tomas Mraz 4a3f2c
 		if SSSDConfig:
Tomas Mraz 4a3f2c
 			try:
Tomas Mraz 4a3f2c
 				self.sssdConfig = SSSDConfig.SSSDConfig()
Tomas Mraz 4a3f2c
 				self.sssdConfig.new_config()
Tomas Mraz 4a3f2c
 			except IOError:
Tomas Mraz 4a3f2c
 				pass
Tomas Mraz 4a3f2c
+		self.toggleFunctions = set()
Tomas Mraz 4a3f2c
 		self.save_groups = [
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeCache, [("enableCache", "b"), ("implicitSSSD", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeHesiod, [("hesiodLHS", "i"), ("hesiodRHS", "i")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeNIS, [("nisDomain", "c"), ("nisLocalDomain", "c"), ("nisServer", "c")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeLDAP, [("ldapServer", "i"), ("ldapBaseDN", "c"), ("enableLDAPS", "b"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeCache, self.toggleCachingService, [("enableCache", "b"), ("implicitSSSD", "b")]),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeHesiod, None, [("hesiodLHS", "i"), ("hesiodRHS", "i")]),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeNIS, self.toggleNisService, [("nisDomain", "c"), ("nisLocalDomain", "c"), ("nisServer", "c")]),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeLDAP, None, [("ldapServer", "i"), ("ldapBaseDN", "c"), ("enableLDAPS", "b"),
Tomas Mraz 4a3f2c
 		("ldapSchema", "c"), ("ldapCacertDir", "c"), ("passwordAlgorithm", "i")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeLibuser, [("passwordAlgorithm", "i")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeLogindefs, [("passwordAlgorithm", "i")]), # for now we do not rewrite uidMin
Tomas Mraz 4a3f2c
-        SaveGroup(self.writePWQuality, [("passMinLen", "c"), ("passMinClass", "c"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeLibuser, None, [("passwordAlgorithm", "i")]),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeLogindefs, None, [("passwordAlgorithm", "i")]), # for now we do not rewrite uidMin
Tomas Mraz 4a3f2c
+        SaveGroup(self.writePWQuality, None,  [("passMinLen", "c"), ("passMinClass", "c"),
Tomas Mraz 4a3f2c
                 ("passMaxRepeat", "c"), ("passMaxClassRepeat", "c"), ("passReqLower", "b"),
Tomas Mraz 4a3f2c
                 ("passReqUpper", "b"), ("passReqDigit", "b"), ("passReqOther", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeKerberos, [("kerberosRealm", "c"), ("kerberosKDC", "i"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeKerberos, None, [("kerberosRealm", "c"), ("kerberosKDC", "i"),
Tomas Mraz 4a3f2c
 		("smbSecurity", "i"), ("smbRealm", "c"), ("smbServers", "i"),
Tomas Mraz 4a3f2c
 		("kerberosAdminServer", "i"), ("kerberosRealmviaDNS", "b"),
Tomas Mraz 4a3f2c
 		("kerberosKDCviaDNS", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeSSSD, [("ldapServer", "i"), ("ldapBaseDN", "c"), ("enableLDAPS", "b"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeSSSD, self.toggleSSSDService, [("ldapServer", "i"), ("ldapBaseDN", "c"), ("enableLDAPS", "b"),
Tomas Mraz 4a3f2c
 		("ldapSchema", "c"), ("ldapCacertDir", "c"), ("enableCacheCreds", "b"),
Tomas Mraz 4a3f2c
 		("kerberosRealm", "c"), ("kerberosKDC", "i"), ("kerberosAdminServer", "i"),
Tomas Mraz 4a3f2c
 		("forceSSSDUpdate", "b"), ("enableLDAP", "b"), ("enableKerberos", "b"),
Tomas Mraz 4a3f2c
 		("enableLDAPAuth", "b"), ("enableIPAv2", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeSmartcard, [("smartcardAction", "i"), ("smartcardModule", "c")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeDConf, [("smartcardAction", "i"), ("smartcardModule", "c"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeSmartcard, None, [("smartcardAction", "i"), ("smartcardModule", "c")]),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeDConf, None, [("smartcardAction", "i"), ("smartcardModule", "c"),
Tomas Mraz 4a3f2c
 		("enableFprintd", "b"), ("enableSmartcard", "b"), ("forceSmartcard", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeWinbind, [("smbWorkgroup", "i"), ("smbServers", "i"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeWinbind, self.toggleWinbindService, [("smbWorkgroup", "i"), ("smbServers", "i"),
Tomas Mraz 4a3f2c
 		("smbRealm", "c"), ("smbSecurity", "i"), ("smbIdmapRange", "i"),
Tomas Mraz 4a3f2c
 		("winbindSeparator", "c"), ("winbindTemplateHomedir", "c"),
Tomas Mraz 4a3f2c
 		("winbindTemplatePrimaryGroup", "c"), ("winbindTemplateShell", "c"),
Tomas Mraz 4a3f2c
 		("winbindUseDefaultDomain", "b"), ("winbindOffline", "b"), ("winbindKrb5", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeNSS, [("enableDB", "b"), ("enableDirectories", "b"), ("enableWinbind", "b"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeNSS, None, [("enableDB", "b"), ("enableDirectories", "b"), ("enableWinbind", "b"),
Tomas Mraz 4a3f2c
 		("enableOdbcbind", "b"), ("enableNIS3", "b"), ("enableNIS", "b"),
Tomas Mraz 4a3f2c
 		("enableLDAPbind", "b"), ("enableLDAP", "b"), ("enableHesiodbind", "b"),
Tomas Mraz 4a3f2c
 		("enableHesiod", "b"), ("enableDBIbind", "b"), ("enableDBbind", "b"),
Tomas Mraz 4a3f2c
 		("enableCompat", "b"), ("enableWINS", "b"), ("enableMDNS", "b"),
Tomas Mraz 4a3f2c
 		("enableNIS3", "b"), ("enableNIS", "b"), ("enableIPAv2", "b"),
Tomas Mraz 4a3f2c
 		("enableSSSD", "b"), ("preferDNSinHosts", "b"), ("implicitSSSD", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writePAM, [("pwqualityArgs", "c"), ("passwdqcArgs", "c"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writePAM, None, [("pwqualityArgs", "c"), ("passwdqcArgs", "c"),
Tomas Mraz 4a3f2c
 		("localuserArgs", "c"), ("pamAccessArgs", "c"), ("enablePAMAccess", "b"),
Tomas Mraz 4a3f2c
 		("mkhomedirArgs", "c"), ("enableMkHomeDir", "b"), ("algoRounds", "c"),
Tomas Mraz 4a3f2c
 		("passwordAlgorithm", "i"), ("enableShadow", "b"), ("enableNIS", "b"),
Tomas Mraz 4a3f2c
@@ -1484,7 +1416,7 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		("winbindOffline", "b"), ("winbindKrb5", "b"),
Tomas Mraz 4a3f2c
 		("enableSSSDAuth", "b"), ("enableFprintd", "b"), ("pamLinked", "b"),
Tomas Mraz 4a3f2c
 		("implicitSSSDAuth", "b"), ("systemdArgs", "c"), ("uidMin", "i"), ("enableIPAv2", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeSysconfig, [("passwordAlgorithm", "i"), ("enableShadow", "b"), ("enableNIS", "b"),
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeSysconfig, None, [("passwordAlgorithm", "i"), ("enableShadow", "b"), ("enableNIS", "b"),
Tomas Mraz 4a3f2c
 		("enableLDAP", "b"), ("enableLDAPAuth", "b"), ("enableKerberos", "b"),
Tomas Mraz 4a3f2c
 		("enableEcryptfs", "b"), ("enableSmartcard", "b"), ("forceSmartcard", "b"),
Tomas Mraz 4a3f2c
 		("enableWinbindAuth", "b"), ("enableWinbind", "b"), ("winbindKrb5", "b"), ("enableDB", "b"),
Tomas Mraz 4a3f2c
@@ -1494,8 +1426,14 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		("enableSSSD", "b"), ("enableSSSDAuth", "b"), ("enableForceLegacy", "b"),
Tomas Mraz 4a3f2c
 		("ipav2Server", "i"), ("ipav2Domain", "i"), ("ipav2Realm", "c"),
Tomas Mraz 4a3f2c
 		("enableIPAv2", "b"), ("ipaDomainJoined", "b"), ("ipav2NoNTP", "b")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.writeNetwork, [("nisDomain", "c")]),
Tomas Mraz 4a3f2c
-	SaveGroup(self.toggleShadow, [("enableShadow", "b")])]
Tomas Mraz 4a3f2c
+	SaveGroup(self.writeNetwork, None, [("nisDomain", "c")]),
Tomas Mraz 4a3f2c
+	SaveGroup(self.toggleShadow, None, [("enableShadow", "b")]),
Tomas Mraz 4a3f2c
+	SaveGroup(None, self.toggleNisService, [("enableNIS", "b")]),
Tomas Mraz 4a3f2c
+	SaveGroup(None, self.toggleOddjobService, [("enableMkHomeDir", "b")]),
Tomas Mraz 4a3f2c
+	SaveGroup(None, self.toggleLDAPService, [("enableLDAP", "b"), ("enableLDAPAuth", "b")]),
Tomas Mraz 4a3f2c
+	SaveGroup(None, self.toggleSSSDService, [("implicitSSSD", "b"), ("implicitSSSDAuth", "b"),
Tomas Mraz 4a3f2c
+		("enableIPAv2", "b"), ("enableSSSD", "b"), ("enableSSSDAuth", "b")]),
Tomas Mraz 4a3f2c
+	SaveGroup(None, self.toggleWinbindService, [("enableWinbind", "b"), ("enableWinbindAuth", "b")])]
Tomas Mraz 4a3f2c
 
Tomas Mraz 4a3f2c
 	def setParam(self, attr, value, ref):
Tomas Mraz 4a3f2c
 		oldval = getattr(self, attr)
Tomas Mraz 4a3f2c
@@ -4049,7 +3987,6 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		self.update()
Tomas Mraz 4a3f2c
 		self.prewriteUpdate()
Tomas Mraz 4a3f2c
 		self.setupBackup(PATH_CONFIG_BACKUPS + "/last")
Tomas Mraz 4a3f2c
-		self.confChanged = True
Tomas Mraz 4a3f2c
 		try:
Tomas Mraz 4a3f2c
 			ret = self.writeLibuser()
Tomas Mraz 4a3f2c
 			ret = ret and self.writeLogindefs()
Tomas Mraz 4a3f2c
@@ -4080,6 +4017,9 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		except (OSError, IOError):
Tomas Mraz 4a3f2c
 			sys.stderr.write(str(sys.exc_info()[1]) + "\n")
Tomas Mraz 4a3f2c
 			return False
Tomas Mraz 4a3f2c
+		for group in self.save_groups:
Tomas Mraz 4a3f2c
+			if group.toggleFunction:
Tomas Mraz 4a3f2c
+				self.toggleFunctions.add(group.toggleFunction)
Tomas Mraz 4a3f2c
 		return ret
Tomas Mraz 4a3f2c
 
Tomas Mraz 4a3f2c
 	def writeChanged(self, ref):
Tomas Mraz 4a3f2c
@@ -4091,8 +4031,10 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		try:
Tomas Mraz 4a3f2c
 			for group in self.save_groups:
Tomas Mraz 4a3f2c
 				if group.attrsDiffer(self, ref):
Tomas Mraz 4a3f2c
-					self.confChanged = True
Tomas Mraz 4a3f2c
-					ret = ret and group.saveFunction()
Tomas Mraz 4a3f2c
+					if group.saveFunction:
Tomas Mraz 4a3f2c
+						ret = ret and group.saveFunction()
Tomas Mraz 4a3f2c
+					if group.toggleFunction:
Tomas Mraz 4a3f2c
+						self.toggleFunctions.add(group.toggleFunction)
Tomas Mraz 4a3f2c
 		except (OSError, IOError):
Tomas Mraz 4a3f2c
 			sys.stderr.write(str(sys.exc_info()[1]) + "\n")
Tomas Mraz 4a3f2c
 			return False
Tomas Mraz 4a3f2c
@@ -4326,44 +4268,93 @@ class AuthInfo:
Tomas Mraz 4a3f2c
 		cmd = PATH_IPA_CLIENT_INSTALL + " --uninstall --noac"
Tomas Mraz 4a3f2c
 		os.system(cmd)
Tomas Mraz 4a3f2c
 
Tomas Mraz 4a3f2c
-	def post(self, nostart):
Tomas Mraz 4a3f2c
-		onlystart = not self.confChanged
Tomas Mraz 4a3f2c
-		toggleNisService(self.enableNIS, self.nisDomain, nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleLDAPService(self.enableLDAP or self.enableLDAPAuth)
Tomas Mraz 4a3f2c
+	def toggleCachingService(self, nostart):
Tomas Mraz 4a3f2c
+		if not nostart:
Tomas Mraz 4a3f2c
+			if self.enableCache:
Tomas Mraz 4a3f2c
+				Service.stop("nscd")
Tomas Mraz 4a3f2c
+				Service.start("nscd")
Tomas Mraz 4a3f2c
+			else:
Tomas Mraz 4a3f2c
+				try:
Tomas Mraz 4a3f2c
+					Service.stop("nscd")
Tomas Mraz 4a3f2c
+				except OSError:
Tomas Mraz 4a3f2c
+					pass
Tomas Mraz 4a3f2c
+		return True
Tomas Mraz 4a3f2c
+	def toggleNisService(self, nostart):
Tomas Mraz ecf3b5
+		if self.enableNIS and self.nisDomain:
Tomas Mraz 4a3f2c
+			if not nostart:
Tomas Mraz 4a3f2c
+				os.system("/bin/domainname " + self.nisDomain)
Tomas Mraz 4a3f2c
+			try:
Tomas Mraz 4a3f2c
+				os.system("[[ $(getsebool allow_ypbind) == *off* ]] && setsebool -P allow_ypbind 1")
Tomas Mraz 4a3f2c
+				os.stat(PATH_RPCBIND)
Tomas Mraz 4a3f2c
+				Service.enable("rpcbind")
Tomas Mraz 4a3f2c
+				if not nostart:
Tomas Mraz 4a3f2c
+					Service.start("rpcbind")
Tomas Mraz 4a3f2c
+			except OSError:
Tomas Mraz 4a3f2c
+				pass
Tomas Mraz 4a3f2c
+			try:
Tomas Mraz 4a3f2c
+				os.stat(PATH_YPBIND)
Tomas Mraz 4a3f2c
+				Service.enable("ypbind")
Tomas Mraz 4a3f2c
+				if not nostart:
Tomas Mraz 4a3f2c
+					Service.stop("ypbind")
Tomas Mraz 4a3f2c
+					Service.start("ypbind")
Tomas Mraz 4a3f2c
+			except OSError:
Tomas Mraz 4a3f2c
+				pass
Tomas Mraz 4a3f2c
+		else:
Tomas Mraz 4a3f2c
+			if not nostart:
Tomas Mraz 4a3f2c
+				os.system("/bin/domainname \"(none)\"")
Tomas Mraz 4a3f2c
+			try:
Tomas Mraz 4a3f2c
+				os.system("[[ $(getsebool allow_ypbind) == *on* ]] && setsebool -P allow_ypbind 0")
Tomas Mraz 4a3f2c
+				os.stat(PATH_YPBIND)
Tomas Mraz 4a3f2c
+				if not nostart:
Tomas Mraz 4a3f2c
+					try:
Tomas Mraz 4a3f2c
+						Service.stop("ypbind")
Tomas Mraz 4a3f2c
+					except OSError:
Tomas Mraz 4a3f2c
+						pass
Tomas Mraz 4a3f2c
+				Service.disable("ypbind")
Tomas Mraz 4a3f2c
+			except OSError:
Tomas Mraz 4a3f2c
+				pass
Tomas Mraz 4a3f2c
+		return True
Tomas Mraz 4a3f2c
+
Tomas Mraz 4a3f2c
+	def toggleLDAPService(self, nostart):
Tomas Mraz 4a3f2c
+		toggleSplatbindService((self.enableLDAP or self.enableLDAPAuth) and
Tomas Mraz 4a3f2c
+			not self.implicitSSSD,
Tomas Mraz 4a3f2c
+			PATH_NSLCD,
Tomas Mraz 4a3f2c
+			"nslcd", nostart)
Tomas Mraz 4a3f2c
+		if self.enableLDAP:
Tomas Mraz 4a3f2c
+			try:
Tomas Mraz 4a3f2c
+				os.system("[[ $(getsebool authlogin_nsswitch_use_ldap) == *off* ]] && setsebool -P authlogin_nsswitch_use_ldap 1")
Tomas Mraz 4a3f2c
+			except OSError:
Tomas Mraz 4a3f2c
+				pass
Tomas Mraz 4a3f2c
+		else:
Tomas Mraz 4a3f2c
+			try:
Tomas Mraz 4a3f2c
+				os.system("[[ $(getsebool authlogin_nsswitch_use_ldap) == *on* ]] && setsebool -P authlogin_nsswitch_use_ldap 0")
Tomas Mraz 4a3f2c
+			except OSError:
Tomas Mraz 4a3f2c
+				pass
Tomas Mraz 4a3f2c
+		return True
Tomas Mraz 4a3f2c
+
Tomas Mraz 4a3f2c
+	def toggleWinbindService(self, nostart):
Tomas Mraz 4a3f2c
 		toggleSplatbindService(self.enableWinbind or self.enableWinbindAuth,
Tomas Mraz 4a3f2c
 			PATH_WINBIND,
Tomas Mraz 4a3f2c
-			"winbind", nostart, onlystart)
Tomas Mraz 4a3f2c
+			"winbind", nostart)
Tomas Mraz 4a3f2c
+
Tomas Mraz 4a3f2c
+	def toggleSSSDService(self, nostart):
Tomas Mraz 4a3f2c
 		toggleSplatbindService(self.implicitSSSD or self.implicitSSSDAuth or
Tomas Mraz 4a3f2c
 			self.enableIPAv2 or self.enableSSSD or self.enableSSSDAuth,
Tomas Mraz 4a3f2c
 			PATH_SSSD,
Tomas Mraz 4a3f2c
 			"sssd", nostart or not (self.implicitSSSD or self.implicitSSSDAuth
Tomas Mraz 4a3f2c
-			or self.enableIPAv2), onlystart)
Tomas Mraz 4a3f2c
-		toggleSplatbindService((self.enableLDAP or self.enableLDAPAuth) and
Tomas Mraz 4a3f2c
-			not self.implicitSSSD,
Tomas Mraz 4a3f2c
-			PATH_NSLCD,
Tomas Mraz 4a3f2c
-			"nslcd", nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleSplatbindService(self.enableDBbind,
Tomas Mraz 4a3f2c
-			PATH_DBBIND,
Tomas Mraz 4a3f2c
-			"dbbind", nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleSplatbindService(self.enableDBIbind,
Tomas Mraz 4a3f2c
-			PATH_DBIBIND,
Tomas Mraz 4a3f2c
-			"dbibind", nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleSplatbindService(self.enableHesiodbind,
Tomas Mraz 4a3f2c
-			PATH_HESIODBIND,
Tomas Mraz 4a3f2c
-			"hesiodbind", nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleSplatbindService(self.enableLDAPbind,
Tomas Mraz 4a3f2c
-			PATH_LDAPBIND,
Tomas Mraz 4a3f2c
-			"ldapbind", nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleSplatbindService(self.enableOdbcbind,
Tomas Mraz 4a3f2c
-			PATH_ODBCBIND,
Tomas Mraz 4a3f2c
-			"odbcbind", nostart, onlystart)
Tomas Mraz 4a3f2c
+			or self.enableIPAv2))
Tomas Mraz 4a3f2c
+
Tomas Mraz 4a3f2c
+	def toggleOddjobService(self, nostart):
Tomas Mraz 4a3f2c
 		if self.enableMkHomeDir and os.access("%s/pam_%s.so"
Tomas Mraz 4a3f2c
 				% (AUTH_MODULE_DIR, "oddjob_mkhomedir"), os.X_OK):
Tomas Mraz 4a3f2c
 			# only switch on and only if pam_oddjob_mkhomedir exists
Tomas Mraz 4a3f2c
 			toggleSplatbindService(True,
Tomas Mraz 4a3f2c
 				PATH_ODDJOBD,
Tomas Mraz 4a3f2c
-				"oddjobd", nostart, onlystart)
Tomas Mraz 4a3f2c
-		toggleCachingService(self.enableCache, nostart, onlystart)
Tomas Mraz 4a3f2c
+				"oddjobd", nostart)
Tomas Mraz 4a3f2c
+
Tomas Mraz 4a3f2c
+	def post(self, nostart):
Tomas Mraz 4a3f2c
+		for togglefunc in self.toggleFunctions:
Tomas Mraz 4a3f2c
+			togglefunc(nostart)
Tomas Mraz 4a3f2c
 		if self.ipaUninstall:
Tomas Mraz 4a3f2c
 			self.uninstallIPA()
Tomas Mraz 4a3f2c