Jan F 5b4ccb
diff -up openssh-5.8p2/auth-krb5.c.kuserok openssh-5.8p2/auth-krb5.c
Jan F 5b4ccb
--- openssh-5.8p2/auth-krb5.c.kuserok	2011-05-19 16:55:57.176106243 +0200
Jan F 5b4ccb
+++ openssh-5.8p2/auth-krb5.c	2011-05-19 16:56:02.009109884 +0200
Jan F 82036a
@@ -54,6 +54,20 @@
Jan F 82036a
 
Jan F 82036a
 extern ServerOptions	 options;
Jan F 82036a
 
Jan F 82036a
+int
Jan F 82036a
+ssh_krb5_kuserok(krb5_context krb5_ctx, krb5_principal krb5_user, const char *client)
Jan F 82036a
+{
Jan F 82036a
+	if (options.use_kuserok)
Jan F 82036a
+		return krb5_kuserok(krb5_ctx, krb5_user, client);
Jan F 82036a
+	else {
Jan F 82036a
+		char kuser[65];
Jan F 82036a
+
Jan F 82036a
+		if (krb5_aname_to_localname(krb5_ctx, krb5_user, sizeof(kuser), kuser))
Jan F 82036a
+			return 0;
Jan F 82036a
+		return strcmp(kuser, client) == 0;
Jan F 82036a
+	}
Jan F 82036a
+}
Jan F 82036a
+
Jan F 82036a
 static int
Jan F 82036a
 krb5_init(void *context)
Jan F 82036a
 {
Jan F 82036a
@@ -146,7 +160,7 @@ auth_krb5_password(Authctxt *authctxt, c
59d42d
 	if (problem)
59d42d
 		goto out;
59d42d
 
59d42d
-	if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
Jan F 82036a
+	if (!ssh_krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
Jan F 82036a
 		problem = -1;
Jan F 82036a
 		goto out;
59d42d
 	}
Jan F 5b4ccb
diff -up openssh-5.8p2/gss-serv-krb5.c.kuserok openssh-5.8p2/gss-serv-krb5.c
Jan F 5b4ccb
--- openssh-5.8p2/gss-serv-krb5.c.kuserok	2011-05-19 16:56:01.000000000 +0200
Jan F 5b4ccb
+++ openssh-5.8p2/gss-serv-krb5.c	2011-05-20 05:48:50.681167894 +0200
Jan F 5b4ccb
@@ -68,6 +68,7 @@ static int ssh_gssapi_krb5_cmdok(krb5_pr
Jan F 5b4ccb
     int);
Jan F 82036a
 
Jan F 82036a
 static krb5_context krb_context = NULL;
Jan F 82036a
+extern int ssh_krb5_kuserok(krb5_context, krb5_principal, const char *);
Jan F 82036a
 
Jan F 82036a
 /* Initialise the krb5 library, for the stuff that GSSAPI won't do */
Jan F 82036a
 
Jan F 5b4ccb
@@ -115,7 +116,7 @@ ssh_gssapi_krb5_userok(ssh_gssapi_client
Jan F 5b4ccb
 	/* NOTE: .k5login and .k5users must opened as root, not the user,
Jan F 5b4ccb
 	 * because if they are on a krb5-protected filesystem, user credentials
Jan F 5b4ccb
 	 * to access these files aren't available yet. */
Jan F 5b4ccb
-	if (krb5_kuserok(krb_context, princ, luser) && k5login_exists) {
Jan F 5b4ccb
+	if (ssh_krb5_kuserok(krb_context, princ, luser) && k5login_exists) {
Jan F 82036a
 		retval = 1;
Jan F 82036a
 		logit("Authorized to %s, krb5 principal %s (krb5_kuserok)",
Jan F 5b4ccb
 		    luser, (char *)client->displayname.value);
Jan F 5b4ccb
diff -up openssh-5.8p2/servconf.c.kuserok openssh-5.8p2/servconf.c
Jan F 5b4ccb
--- openssh-5.8p2/servconf.c.kuserok	2011-05-19 16:55:59.549112264 +0200
Jan F 5b4ccb
+++ openssh-5.8p2/servconf.c	2011-05-19 16:56:02.332106613 +0200
Jan F 5b4ccb
@@ -145,6 +145,7 @@ initialize_server_options(ServerOptions
Jan F. Chadima 1b8a26
 	options->authorized_principals_file = NULL;
Jan F 003cb0
 	options->ip_qos_interactive = -1;
Jan F 003cb0
 	options->ip_qos_bulk = -1;
59d42d
+	options->use_kuserok = -1;
59d42d
 }
59d42d
 
59d42d
 void
Jan F 5b4ccb
@@ -300,6 +301,8 @@ fill_default_server_options(ServerOption
59d42d
 	if (use_privsep == -1)
59d42d
 		use_privsep = 1;
59d42d
 
59d42d
+	if (options->use_kuserok == -1)
59d42d
+		options->use_kuserok = 1;
59d42d
 #ifndef HAVE_MMAP
59d42d
 	if (use_privsep && options->compression == 1) {
59d42d
 		error("This platform does not support both privilege "
Jan F 5b4ccb
@@ -321,7 +324,7 @@ typedef enum {
59d42d
 	sPermitRootLogin, sLogFacility, sLogLevel,
59d42d
 	sRhostsRSAAuthentication, sRSAAuthentication,
59d42d
 	sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
59d42d
-	sKerberosGetAFSToken,
59d42d
+	sKerberosGetAFSToken, sKerberosUseKuserok,
59d42d
 	sKerberosTgtPassing, sChallengeResponseAuthentication,
59d42d
 	sPasswordAuthentication, sKbdInteractiveAuthentication,
59d42d
 	sListenAddress, sAddressFamily,
Jan F 5b4ccb
@@ -392,11 +395,13 @@ static struct {
59d42d
 #else
59d42d
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
59d42d
 #endif
59d42d
+	{ "kerberosusekuserok", sKerberosUseKuserok, SSHCFG_ALL },
59d42d
 #else
59d42d
 	{ "kerberosauthentication", sUnsupported, SSHCFG_ALL },
59d42d
 	{ "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
59d42d
 	{ "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
59d42d
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
59d42d
+	{ "kerberosusekuserok", sUnsupported, SSHCFG_ALL },
59d42d
 #endif
59d42d
 	{ "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
59d42d
 	{ "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
Jan F 5b4ccb
@@ -1374,6 +1379,10 @@ process_server_config_line(ServerOptions
59d42d
 		*activep = value;
59d42d
 		break;
59d42d
 
59d42d
+	case sKerberosUseKuserok:
59d42d
+		intptr = &options->use_kuserok;
59d42d
+		goto parse_flag;
59d42d
+
59d42d
 	case sPermitOpen:
59d42d
 		arg = strdelim(&cp;;
59d42d
 		if (!arg || *arg == '\0')
Jan F 5b4ccb
@@ -1577,6 +1586,7 @@ copy_set_server_options(ServerOptions *d
59d42d
 	M_CP_INTOPT(max_authtries);
Jan F 003cb0
 	M_CP_INTOPT(ip_qos_interactive);
Jan F 003cb0
 	M_CP_INTOPT(ip_qos_bulk);
59d42d
+	M_CP_INTOPT(use_kuserok);
59d42d
 
59d42d
 	M_CP_STROPT(banner);
59d42d
 	if (preauth)
Jan F 5b4ccb
@@ -1800,6 +1810,7 @@ dump_config(ServerOptions *o)
59d42d
 	dump_cfg_fmtint(sUseDNS, o->use_dns);
59d42d
 	dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
59d42d
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
59d42d
+	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
59d42d
 
59d42d
 	/* string arguments */
59d42d
 	dump_cfg_string(sPidFile, o->pid_file);
Jan F 5b4ccb
diff -up openssh-5.8p2/servconf.h.kuserok openssh-5.8p2/servconf.h
Jan F 5b4ccb
--- openssh-5.8p2/servconf.h.kuserok	2011-05-19 16:55:59.676167388 +0200
Jan F 5b4ccb
+++ openssh-5.8p2/servconf.h	2011-05-19 16:56:02.449168732 +0200
Jan F 5b4ccb
@@ -160,6 +160,7 @@ typedef struct {
59d42d
 
59d42d
 	int	num_permitted_opens;
59d42d
 
59d42d
+	int	use_kuserok;
59d42d
 	char   *chroot_directory;
59d42d
 	char   *revoked_keys_file;
59d42d
 	char   *trusted_user_ca_keys;
Jan F 5b4ccb
diff -up openssh-5.8p2/sshd_config.5.kuserok openssh-5.8p2/sshd_config.5
Jan F 5b4ccb
--- openssh-5.8p2/sshd_config.5.kuserok	2011-05-19 16:56:00.265169181 +0200
Jan F 5b4ccb
+++ openssh-5.8p2/sshd_config.5	2011-05-19 16:56:02.588114955 +0200
Jan F 5b4ccb
@@ -602,6 +602,10 @@ Specifies whether to automatically destr
59d42d
 file on logout.
59d42d
 The default is
59d42d
 .Dq yes .
59d42d
+.It Cm KerberosUseKuserok
59d42d
+Specifies whether to look at .k5login file for user's aliases.
59d42d
+The default is
59d42d
+.Dq yes .
Jan F 003cb0
 .It Cm KexAlgorithms
Jan F 003cb0
 Specifies the available KEX (Key Exchange) algorithms.
Jan F 003cb0
 Multiple algorithms must be comma-separated.
Jan F 5b4ccb
@@ -743,6 +747,7 @@ Available keywords are
Jan F. Chadima 1b8a26
 .Cm HostbasedUsesNameFromPacketOnly ,
59d42d
 .Cm KbdInteractiveAuthentication ,
59d42d
 .Cm KerberosAuthentication ,
59d42d
+.Cm KerberosUseKuserok ,
59d42d
 .Cm MaxAuthTries ,
59d42d
 .Cm MaxSessions ,
7818e5
 .Cm PubkeyAuthentication ,
Jan F 5b4ccb
diff -up openssh-5.8p2/sshd_config.kuserok openssh-5.8p2/sshd_config
Jan F 5b4ccb
--- openssh-5.8p2/sshd_config.kuserok	2011-05-19 16:56:00.886106293 +0200
Jan F 5b4ccb
+++ openssh-5.8p2/sshd_config	2011-05-19 16:56:02.716105342 +0200
Jan F 003cb0
@@ -73,6 +73,7 @@ ChallengeResponseAuthentication no
59d42d
 #KerberosOrLocalPasswd yes
59d42d
 #KerberosTicketCleanup yes
59d42d
 #KerberosGetAFSToken no
59d42d
+#KerberosUseKuserok yes
59d42d
 
59d42d
 # GSSAPI options
59d42d
 #GSSAPIAuthentication no