140e5ca
diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c
1900351
index 961c564..0fcfd7b 100644
140e5ca
--- a/gss-serv-krb5.c
140e5ca
+++ b/gss-serv-krb5.c
140e5ca
@@ -260,7 +260,6 @@ ssh_gssapi_krb5_cmdok(krb5_principal principal, const char *name,
140e5ca
 	FILE *fp;
140e5ca
 	char file[MAXPATHLEN];
580f986
 	char line[BUFSIZ] = "";
140e5ca
-	char kuser[65]; /* match krb5_kuserok() */
140e5ca
 	struct stat st;
140e5ca
 	struct passwd *pw = the_authctxt->pw;
140e5ca
 	int found_principal = 0;
140e5ca
@@ -269,7 +268,7 @@ ssh_gssapi_krb5_cmdok(krb5_principal principal, const char *name,
140e5ca
 
140e5ca
 	snprintf(file, sizeof(file), "%s/.k5users", pw->pw_dir);
140e5ca
 	/* If both .k5login and .k5users DNE, self-login is ok. */
140e5ca
-	if (!k5login_exists && (access(file, F_OK) == -1)) {
140e5ca
+	if ( !options.enable_k5users || (!k5login_exists && (access(file, F_OK) == -1))) {
140e5ca
                 return ssh_krb5_kuserok(krb_context, principal, luser,
140e5ca
                                         k5login_exists);
140e5ca
 	}
140e5ca
diff --git a/servconf.c b/servconf.c
1900351
index e4164b1..87a311b 100644
140e5ca
--- a/servconf.c
140e5ca
+++ b/servconf.c
1900351
@@ -164,6 +164,7 @@ initialize_server_options(ServerOptions *options)
140e5ca
 	options->version_addendum = NULL;
1900351
 	options->fingerprint_hash = -1;
140e5ca
 	options->use_kuserok = -1;
140e5ca
+	options->enable_k5users = -1;
140e5ca
 }
140e5ca
 
140e5ca
 void
1900351
@@ -331,6 +332,8 @@ fill_default_server_options(ServerOptions *options)
1900351
 		options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
140e5ca
 	if (options->use_kuserok == -1)
140e5ca
 		options->use_kuserok = 1;
140e5ca
+	if (options->enable_k5users == -1)
140e5ca
+		options->enable_k5users = 0;
140e5ca
 	/* Turn privilege separation on by default */
140e5ca
 	if (use_privsep == -1)
1900351
 		use_privsep = PRIVSEP_NOSANDBOX;
1900351
@@ -371,7 +374,7 @@ typedef enum {
140e5ca
 	sBanner, sShowPatchLevel, sUseDNS, sHostbasedAuthentication,
140e5ca
 	sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
140e5ca
 	sClientAliveCountMax, sAuthorizedKeysFile,
140e5ca
-	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
140e5ca
+	sGssAuthentication, sGssCleanupCreds, sGssEnablek5users, sGssStrictAcceptor,
140e5ca
 	sGssKeyEx, sGssStoreRekey, sAcceptEnv, sPermitTunnel,
140e5ca
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
140e5ca
 	sUsePrivilegeSeparation, sAllowAgentForwarding,
1900351
@@ -447,6 +450,7 @@ static struct {
140e5ca
 	{ "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL },
140e5ca
 	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL },
140e5ca
 	{ "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL },
140e5ca
+	{ "gssapienablek5users", sGssEnablek5users, SSHCFG_ALL },
140e5ca
 #else
140e5ca
 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
140e5ca
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
1900351
@@ -454,6 +458,7 @@ static struct {
140e5ca
 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
140e5ca
 	{ "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL },
140e5ca
 	{ "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL },
140e5ca
+	{ "gssapienablek5users", sUnsupported, SSHCFG_ALL },
140e5ca
 #endif
140e5ca
 	{ "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL },
140e5ca
 	{ "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL },
1900351
@@ -1566,6 +1571,10 @@ process_server_config_line(ServerOptions *options, char *line,
140e5ca
 		intptr = &options->use_kuserok;
140e5ca
 		goto parse_flag;
140e5ca
 
140e5ca
+	case sGssEnablek5users:
140e5ca
+		intptr = &options->enable_k5users;
140e5ca
+		goto parse_flag;
140e5ca
+
140e5ca
 	case sPermitOpen:
140e5ca
 		arg = strdelim(&cp;;
140e5ca
 		if (!arg || *arg == '\0')
1900351
@@ -1884,6 +1893,7 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
140e5ca
 	M_CP_INTOPT(ip_qos_interactive);
140e5ca
 	M_CP_INTOPT(ip_qos_bulk);
140e5ca
 	M_CP_INTOPT(use_kuserok);
140e5ca
+	M_CP_INTOPT(enable_k5users);
140e5ca
 	M_CP_INTOPT(rekey_limit);
140e5ca
 	M_CP_INTOPT(rekey_interval);
140e5ca
 
1900351
@@ -2143,6 +2153,7 @@ dump_config(ServerOptions *o)
140e5ca
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
1900351
 	dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash);
140e5ca
 	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
140e5ca
+	dump_cfg_fmtint(sGssEnablek5users, o->enable_k5users);
140e5ca
 
140e5ca
 	/* string arguments */
140e5ca
 	dump_cfg_string(sPidFile, o->pid_file);
140e5ca
diff --git a/servconf.h b/servconf.h
1900351
index cf2a505..070a8ed 100644
140e5ca
--- a/servconf.h
140e5ca
+++ b/servconf.h
1900351
@@ -175,7 +175,8 @@ typedef struct {
140e5ca
 
140e5ca
 	int	num_permitted_opens;
140e5ca
 
140e5ca
-	int	use_kuserok;
140e5ca
+	int		use_kuserok;
140e5ca
+	int		enable_k5users;
140e5ca
 	char   *chroot_directory;
140e5ca
 	char   *revoked_keys_file;
140e5ca
 	char   *trusted_user_ca_keys;
140e5ca
diff --git a/sshd_config b/sshd_config
1900351
index 0d9454d..e731de1 100644
140e5ca
--- a/sshd_config
140e5ca
+++ b/sshd_config
140e5ca
@@ -94,6 +94,7 @@ GSSAPIAuthentication yes
140e5ca
 GSSAPICleanupCredentials no
140e5ca
 #GSSAPIStrictAcceptorCheck yes
140e5ca
 #GSSAPIKeyExchange no
140e5ca
+#GSSAPIEnablek5users no
140e5ca
 
140e5ca
 # Set this to 'yes' to enable PAM authentication, account processing,
140e5ca
 # and session processing. If this is enabled, PAM authentication will
140e5ca
diff --git a/sshd_config.5 b/sshd_config.5
1900351
index eb4dd9e..ce1229b 100644
140e5ca
--- a/sshd_config.5
140e5ca
+++ b/sshd_config.5
1900351
@@ -548,6 +548,12 @@ on logout.
140e5ca
 The default is
140e5ca
 .Dq yes .
140e5ca
 Note that this option applies to protocol version 2 only.
140e5ca
+.It Cm GSSAPIEnablek5users
140e5ca
+Specifies whether to look at .k5users file for GSSAPI authentication
140e5ca
+access control. Further details are described in
140e5ca
+.Xr ksu 1 .
140e5ca
+The default is
140e5ca
+.Dq no .
140e5ca
 .It Cm GSSAPIStrictAcceptorCheck
140e5ca
 Determines whether to be strict about the identity of the GSSAPI acceptor 
140e5ca
 a client authenticates against. If