Blame SOURCES/authconfig-6.2.8-sssd-smartcard-1.patch

ee2f06
diff -Naur old/authinfo.py new/authinfo.py
ee2f06
--- old/authinfo.py	2017-03-28 13:38:56.610467419 +0200
ee2f06
+++ new/authinfo.py	2017-03-28 13:55:43.626505569 +0200
ee2f06
@@ -334,6 +334,10 @@
ee2f06
 	"wait_for_card"
ee2f06
 ]
ee2f06
 
ee2f06
+argv_sssd_missing_name = [
ee2f06
+   "allow_missing_name"
ee2f06
+]
ee2f06
+
ee2f06
 argv_krb5_auth = [
ee2f06
 	"use_first_pass"
ee2f06
 ]
ee2f06
@@ -736,6 +740,8 @@
ee2f06
 pam_modules[SMARTCARD] = [
ee2f06
 	[True,  AUTH,		LOGIC_REQUIRED,
ee2f06
 	 "env",			[]],
ee2f06
+	[False,  AUTH,		LOGIC_SUFFICIENT,
ee2f06
+	 "sss",			argv_sssd_missing_name],
ee2f06
 	[False,  AUTH,		LOGIC_PKCS11,
ee2f06
 	 "pkcs11",		argv_force_pkcs11_auth],
ee2f06
 	[False, AUTH,		LOGIC_OPTIONAL,
ee2f06
@@ -1428,7 +1434,7 @@
ee2f06
 		("kerberosAdminServer", "i"), ("kerberosRealmviaDNS", "b"),
ee2f06
 		("kerberosKDCviaDNS", "b")]),
ee2f06
 	SaveGroup(self.writeSSSD, self.toggleSSSDService, [("ldapServer", "i"), ("ldapBaseDN", "c"), ("enableLDAPS", "b"),
ee2f06
-		("ldapSchema", "c"), ("ldapCacertDir", "c"), ("enableCacheCreds", "b"),
ee2f06
+		("ldapSchema", "c"), ("ldapCacertDir", "c"), ("enableCacheCreds", "b"), ("enableSmartcard", "b"),
ee2f06
 		("kerberosRealm", "c"), ("kerberosKDC", "i"), ("kerberosAdminServer", "i"),
ee2f06
 		("forceSSSDUpdate", "b"), ("enableLDAP", "b"), ("enableKerberos", "b"),
ee2f06
 		("enableLDAPAuth", "b"), ("enableIPAv2", "b")]),
ee2f06
@@ -3281,11 +3287,35 @@
ee2f06
 				domain.remove_provider(subtype)
ee2f06
 			domain.add_provider(newprovider, subtype)
ee2f06
 
ee2f06
+	def writeSSSDPAM(self):
ee2f06
+		if not self.sssdConfig:
ee2f06
+			return True
ee2f06
+
ee2f06
+		pam = self.sssdConfig.get_service('pam')
ee2f06
+
ee2f06
+		if self.enableSmartcard and self.enableSSSDAuth and self.smartcardModule == "sssd" :
ee2f06
+			pam.set_option('pam_cert_auth', 'True')
ee2f06
+		else:
ee2f06
+			try:
ee2f06
+				pam.remove_option('pam_cert_auth')
ee2f06
+			except SSSDConfig.NoOptionError:
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
+
ee2f06
+		return True
ee2f06
+
ee2f06
 	def writeSSSD(self):
ee2f06
 		if not self.sssdConfig:
ee2f06
 			return True
ee2f06
 
ee2f06
 		all_configs[CFG_SSSD].backup(self.backupDir)
ee2f06
+		
ee2f06
+		self.writeSSSDPAM()
ee2f06
 
ee2f06
 		if self.enableIPAv2:
ee2f06
 			# just save the backup
ee2f06
@@ -3855,7 +3885,7 @@
ee2f06
 				args = self.mkhomedirArgs
ee2f06
 			if name == "systemd":
ee2f06
 				args = self.systemdArgs
ee2f06
-			if name == "sss" and stack == "auth" and not self.enableNIS:
ee2f06
+			if name == "sss" and stack == "auth" and not self.enableNIS and not module[ARGV] == argv_sssd_missing_name:
ee2f06
 				args = "forward_pass"
ee2f06
 			if not args and module[ARGV]:
ee2f06
 				args = " ".join(module[ARGV])
ee2f06
@@ -3935,6 +3965,10 @@
ee2f06
 				enableSmartcard = True
ee2f06
 				forceSmartcard = True
ee2f06
 
ee2f06
+			# configure SSSD Smartcard support instead of
ee2f06
+			# pam_pkcs11 if SSSD is used for authentication and no
ee2f06
+			# Smartcard module is set, e.g. if pam_pkcs11 is not installed.
ee2f06
+			use_sssd_smartcard_support = self.enableSSSDAuth and self.smartcardModule == "sssd"
ee2f06
 			prevmodule = []
ee2f06
 			for module in pam_modules[service]:
ee2f06
 				if prevmodule and module[STACK] != prevmodule[STACK]:
ee2f06
@@ -3952,15 +3986,17 @@
ee2f06
 					    ((module[NAME] == "krb5" and module[ARGV] == argv_krb5_sc_auth) or
ee2f06
 					    (module[NAME] == "permit" and module[STACK] == AUTH))) or
ee2f06
 					((self.enableLDAPAuth and not self.implicitSSSDAuth) and module[NAME] == "ldap") or
ee2f06
-					(enableSmartcard and module[STACK] == AUTH and
ee2f06
+					(enableSmartcard and use_sssd_smartcard_support and module[NAME] == "sss" and module[ARGV] == argv_sssd_missing_name) or
ee2f06
+					(enableSmartcard and not use_sssd_smartcard_support and module[STACK] == AUTH and
ee2f06
 						module[NAME] == "succeed_if" and module[LOGIC] == LOGIC_SKIPNEXT) or
ee2f06
-					(enableSmartcard and module[NAME] == "pkcs11") or 
ee2f06
+					(enableSmartcard and not use_sssd_smartcard_support and module[NAME] == "pkcs11") or
ee2f06
+					(enableSmartcard and not use_sssd_smartcard_support and forceSmartcard and module[NAME] == "deny") or
ee2f06
 					(enableSmartcard and forceSmartcard and module[NAME] == "deny") or 
ee2f06
 					(enableFprintd and module[NAME] == "fprintd") or
ee2f06
 					(self.enableOTP and module[NAME] == "otp") or
ee2f06
 					(self.enablePasswdQC and module[NAME] == "passwdqc") or
ee2f06
 					(self.enableWinbindAuth and module[NAME] == "winbind") or
ee2f06
-					((self.enableSSSDAuth or self.implicitSSSDAuth or self.enableIPAv2) and module[NAME] == "sss") or
ee2f06
+					((self.enableSSSDAuth or self.implicitSSSDAuth or self.enableIPAv2) and module[NAME] == "sss" and module[ARGV] != argv_sssd_missing_name) or
ee2f06
 					((self.enableSSSDAuth or self.implicitSSSDAuth or self.enableIPAv2) and
ee2f06
 						(not self.enableNIS) and module[NAME] == "localuser" and module[STACK] == AUTH) or
ee2f06
 					(self.enableLocAuthorize and module[NAME] == "localuser" and module[STACK] == ACCOUNT) or
ee2f06
@@ -4093,6 +4129,8 @@
ee2f06
 				ret = ret and self.writeWinbind()
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.writeNSS()
ee2f06
 			ret = ret and self.writePAM()
ee2f06
 			ret = ret and self.writeSysconfig()
ee2f06
@@ -4250,7 +4288,8 @@
ee2f06
 		print " LDAP server = \"%s\"" % self.ldapServer
ee2f06
 		print " LDAP base DN = \"%s\"" % self.ldapBaseDN
ee2f06
 		print " LDAP schema = \"%s\"" % (self.ldapSchema or "rfc2307")
ee2f06
-		print "pam_pkcs11 is %s" % formatBool(self.enableSmartcard)
ee2f06
+		print "pam_pkcs11 is %s" % formatBool(self.enableSmartcard and not (self.enableSSSDAuth and self.smartcardModule == "sssd"))
ee2f06
+		print "SSSD smartcard support is %s" % formatBool(self.enableSmartcard and (self.enableSSSDAuth and self.smartcardModule == "sssd"))
ee2f06
 		print " use only smartcard for login is %s" % formatBool(self.forceSmartcard)
ee2f06
 		print " smartcard module = \"%s\"" % self.smartcardModule
ee2f06
 		print " smartcard removal action = \"%s\"" % self.smartcardAction