kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
f09e2e
diff -up openssh-6.3p1/auth-krb5.c.kuserok openssh-6.3p1/auth-krb5.c
f09e2e
--- openssh-6.3p1/auth-krb5.c.kuserok	2013-10-11 21:41:42.889087613 +0200
f09e2e
+++ openssh-6.3p1/auth-krb5.c	2013-10-11 21:41:42.905087537 +0200
f09e2e
@@ -55,6 +55,20 @@
f09e2e
 
f09e2e
 extern ServerOptions	 options;
f09e2e
 
f09e2e
+int
f09e2e
+ssh_krb5_kuserok(krb5_context krb5_ctx, krb5_principal krb5_user, const char *client)
f09e2e
+{
f09e2e
+	if (options.use_kuserok)
f09e2e
+		return krb5_kuserok(krb5_ctx, krb5_user, client);
f09e2e
+	else {
f09e2e
+		char kuser[65];
f09e2e
+
f09e2e
+		if (krb5_aname_to_localname(krb5_ctx, krb5_user, sizeof(kuser), kuser))
f09e2e
+			return 0;
f09e2e
+		return strcmp(kuser, client) == 0;
f09e2e
+	}
f09e2e
+}
f09e2e
+
f09e2e
 static int
f09e2e
 krb5_init(void *context)
f09e2e
 {
f09e2e
@@ -159,7 +173,7 @@ auth_krb5_password(Authctxt *authctxt, c
f09e2e
 	if (problem)
f09e2e
 		goto out;
f09e2e
 
f09e2e
-	if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
f09e2e
+	if (!ssh_krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
f09e2e
 		problem = -1;
f09e2e
 		goto out;
f09e2e
 	}
f09e2e
diff -up openssh-6.3p1/gss-serv-krb5.c.kuserok openssh-6.3p1/gss-serv-krb5.c
f09e2e
--- openssh-6.3p1/gss-serv-krb5.c.kuserok	2013-10-11 21:41:42.901087556 +0200
f09e2e
+++ openssh-6.3p1/gss-serv-krb5.c	2013-10-11 21:46:42.898673597 +0200
f09e2e
@@ -67,6 +67,7 @@ static int ssh_gssapi_krb5_cmdok(krb5_pr
f09e2e
     int);
f09e2e
 
f09e2e
 static krb5_context krb_context = NULL;
f09e2e
+extern int ssh_krb5_kuserok(krb5_context, krb5_principal, const char *);
f09e2e
 
f09e2e
 /* Initialise the krb5 library, for the stuff that GSSAPI won't do */
f09e2e
 
f09e2e
@@ -116,7 +117,7 @@ ssh_gssapi_krb5_userok(ssh_gssapi_client
f09e2e
 	/* NOTE: .k5login and .k5users must opened as root, not the user,
f09e2e
 	 * because if they are on a krb5-protected filesystem, user credentials
f09e2e
 	 * to access these files aren't available yet. */
f09e2e
-	if (krb5_kuserok(krb_context, princ, name) && k5login_exists) {
f09e2e
+	if (ssh_krb5_kuserok(krb_context, princ, name) && k5login_exists) {
f09e2e
 		retval = 1;
f09e2e
 		logit("Authorized to %s, krb5 principal %s (krb5_kuserok)",
f09e2e
 		    name, (char *)client->displayname.value);
f09e2e
diff -up openssh-6.3p1/servconf.c.kuserok openssh-6.3p1/servconf.c
f09e2e
--- openssh-6.3p1/servconf.c.kuserok	2013-10-11 21:41:42.896087580 +0200
f09e2e
+++ openssh-6.3p1/servconf.c	2013-10-11 21:48:24.664194016 +0200
f09e2e
@@ -157,6 +157,7 @@ initialize_server_options(ServerOptions
f09e2e
 	options->ip_qos_interactive = -1;
f09e2e
 	options->ip_qos_bulk = -1;
f09e2e
 	options->version_addendum = NULL;
f09e2e
+	options->use_kuserok = -1;
f09e2e
 }
f09e2e
 
f09e2e
 void
f09e2e
@@ -310,6 +311,8 @@ fill_default_server_options(ServerOption
f09e2e
 		options->version_addendum = xstrdup("");
f09e2e
 	if (options->show_patchlevel == -1)
f09e2e
 		options->show_patchlevel = 0;
f09e2e
+	if (options->use_kuserok == -1)
f09e2e
+		options->use_kuserok = 1;
f09e2e
 
f09e2e
 	/* Turn privilege separation on by default */
f09e2e
 	if (use_privsep == -1)
f09e2e
@@ -336,7 +339,7 @@ typedef enum {
f09e2e
 	sPermitRootLogin, sLogFacility, sLogLevel,
f09e2e
 	sRhostsRSAAuthentication, sRSAAuthentication,
f09e2e
 	sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
f09e2e
-	sKerberosGetAFSToken,
f09e2e
+	sKerberosGetAFSToken, sKerberosUseKuserok,
f09e2e
 	sKerberosTgtPassing, sChallengeResponseAuthentication,
f09e2e
 	sPasswordAuthentication, sKbdInteractiveAuthentication,
f09e2e
 	sListenAddress, sAddressFamily,
f09e2e
@@ -409,11 +412,13 @@ static struct {
f09e2e
 #else
f09e2e
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
f09e2e
 #endif
f09e2e
+	{ "kerberosusekuserok", sKerberosUseKuserok, SSHCFG_ALL },
f09e2e
 #else
f09e2e
 	{ "kerberosauthentication", sUnsupported, SSHCFG_ALL },
f09e2e
 	{ "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
f09e2e
 	{ "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
f09e2e
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
f09e2e
+	{ "kerberosusekuserok", sUnsupported, SSHCFG_ALL },
f09e2e
 #endif
f09e2e
 	{ "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
f09e2e
 	{ "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
f09e2e
@@ -1515,6 +1520,10 @@ process_server_config_line(ServerOptions
f09e2e
 		*activep = value;
f09e2e
 		break;
f09e2e
 
f09e2e
+	case sKerberosUseKuserok:
f09e2e
+		intptr = &options->use_kuserok;
f09e2e
+		goto parse_flag;
f09e2e
+
f09e2e
 	case sPermitOpen:
f09e2e
 		arg = strdelim(&cp;;
f09e2e
 		if (!arg || *arg == '\0')
f09e2e
@@ -1815,6 +1824,7 @@ copy_set_server_options(ServerOptions *d
f09e2e
 	M_CP_INTOPT(max_authtries);
f09e2e
 	M_CP_INTOPT(ip_qos_interactive);
f09e2e
 	M_CP_INTOPT(ip_qos_bulk);
f09e2e
+	M_CP_INTOPT(use_kuserok);
f09e2e
 	M_CP_INTOPT(rekey_limit);
f09e2e
 	M_CP_INTOPT(rekey_interval);
f09e2e
 
f09e2e
@@ -2055,6 +2065,7 @@ dump_config(ServerOptions *o)
f09e2e
 	dump_cfg_fmtint(sUseDNS, o->use_dns);
f09e2e
 	dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
f09e2e
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
f09e2e
+	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
f09e2e
 
f09e2e
 	/* string arguments */
f09e2e
 	dump_cfg_string(sPidFile, o->pid_file);
f09e2e
diff -up openssh-6.3p1/servconf.h.kuserok openssh-6.3p1/servconf.h
f09e2e
--- openssh-6.3p1/servconf.h.kuserok	2013-10-11 21:41:42.896087580 +0200
f09e2e
+++ openssh-6.3p1/servconf.h	2013-10-11 21:41:42.907087528 +0200
f09e2e
@@ -174,6 +174,7 @@ typedef struct {
f09e2e
 
f09e2e
 	int	num_permitted_opens;
f09e2e
 
f09e2e
+	int	use_kuserok;
f09e2e
 	char   *chroot_directory;
f09e2e
 	char   *revoked_keys_file;
f09e2e
 	char   *trusted_user_ca_keys;
f09e2e
diff -up openssh-6.3p1/sshd_config.5.kuserok openssh-6.3p1/sshd_config.5
f09e2e
--- openssh-6.3p1/sshd_config.5.kuserok	2013-10-11 21:41:42.898087571 +0200
f09e2e
+++ openssh-6.3p1/sshd_config.5	2013-10-11 21:41:42.907087528 +0200
f09e2e
@@ -675,6 +675,10 @@ Specifies whether to automatically destr
f09e2e
 file on logout.
f09e2e
 The default is
f09e2e
 .Dq yes .
f09e2e
+.It Cm KerberosUseKuserok
f09e2e
+Specifies whether to look at .k5login file for user's aliases.
f09e2e
+The default is
f09e2e
+.Dq yes .
f09e2e
 .It Cm KexAlgorithms
f09e2e
 Specifies the available KEX (Key Exchange) algorithms.
f09e2e
 Multiple algorithms must be comma-separated.
f09e2e
@@ -833,6 +837,7 @@ Available keywords are
f09e2e
 .Cm HostbasedUsesNameFromPacketOnly ,
f09e2e
 .Cm KbdInteractiveAuthentication ,
f09e2e
 .Cm KerberosAuthentication ,
f09e2e
+.Cm KerberosUseKuserok ,
f09e2e
 .Cm MaxAuthTries ,
f09e2e
 .Cm MaxSessions ,
f09e2e
 .Cm PasswordAuthentication ,
f09e2e
diff -up openssh-6.3p1/sshd_config.kuserok openssh-6.3p1/sshd_config
f09e2e
--- openssh-6.3p1/sshd_config.kuserok	2013-10-11 21:41:42.898087571 +0200
f09e2e
+++ openssh-6.3p1/sshd_config	2013-10-11 21:41:42.907087528 +0200
f09e2e
@@ -86,6 +86,7 @@ ChallengeResponseAuthentication no
f09e2e
 #KerberosOrLocalPasswd yes
f09e2e
 #KerberosTicketCleanup yes
f09e2e
 #KerberosGetAFSToken no
f09e2e
+#KerberosUseKuserok yes
f09e2e
 
f09e2e
 # GSSAPI options
f09e2e
 #GSSAPIAuthentication no