6995654
diff -up openssh-7.4p1/gss-serv-krb5.c.GSSAPIEnablek5users openssh-7.4p1/gss-serv-krb5.c
6995654
--- openssh-7.4p1/gss-serv-krb5.c.GSSAPIEnablek5users	2016-12-23 15:18:40.615216100 +0100
6995654
+++ openssh-7.4p1/gss-serv-krb5.c	2016-12-23 15:18:40.628216102 +0100
6995654
@@ -279,7 +279,6 @@ ssh_gssapi_krb5_cmdok(krb5_principal pri
300c081
 	FILE *fp;
300c081
 	char file[MAXPATHLEN];
5923b7b
 	char *line = NULL;
300c081
-	char kuser[65]; /* match krb5_kuserok() */
300c081
 	struct stat st;
300c081
 	struct passwd *pw = the_authctxt->pw;
300c081
 	int found_principal = 0;
6995654
@@ -288,7 +287,7 @@ ssh_gssapi_krb5_cmdok(krb5_principal pri
300c081
 
300c081
 	snprintf(file, sizeof(file), "%s/.k5users", pw->pw_dir);
300c081
 	/* If both .k5login and .k5users DNE, self-login is ok. */
300c081
-	if (!k5login_exists && (access(file, F_OK) == -1)) {
300c081
+	if ( !options.enable_k5users || (!k5login_exists && (access(file, F_OK) == -1))) {
300c081
                 return ssh_krb5_kuserok(krb_context, principal, luser,
300c081
                                         k5login_exists);
300c081
 	}
6995654
diff -up openssh-7.4p1/servconf.c.GSSAPIEnablek5users openssh-7.4p1/servconf.c
6995654
--- openssh-7.4p1/servconf.c.GSSAPIEnablek5users	2016-12-23 15:18:40.615216100 +0100
6995654
+++ openssh-7.4p1/servconf.c	2016-12-23 15:35:36.354401156 +0100
6995654
@@ -168,6 +168,7 @@ initialize_server_options(ServerOptions
c7d42e7
 	options->gss_store_rekey = -1;
aa3c245
 	options->gss_kex_algorithms = NULL;
300c081
 	options->use_kuserok = -1;
300c081
+	options->enable_k5users = -1;
c7d42e7
 	options->password_authentication = -1;
c7d42e7
 	options->kbd_interactive_authentication = -1;
5686259
	options->permit_empty_passwd = -1;
6995654
@@ -345,6 +346,8 @@ fill_default_server_options(ServerOption
aa3c245
 #endif
b636005
 	if (options->use_kuserok == -1)
b636005
 		options->use_kuserok = 1;
6995654
+	if (options->enable_k5users == -1)
6995654
+		options->enable_k5users = 0;
c7d42e7
 	if (options->password_authentication == -1)
c7d42e7
 		options->password_authentication = 1;
c7d42e7
 	if (options->kbd_interactive_authentication == -1)
6995654
@@ -418,7 +421,7 @@ typedef enum {
d482358
 	sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedAlgorithms,
d482358
 	sHostKeyAlgorithms, sPerSourceMaxStartups, sPerSourceNetBlockSize,
04aef64
 	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
300c081
-	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
300c081
+	sGssAuthentication, sGssCleanupCreds, sGssEnablek5users, sGssStrictAcceptor,
aa3c245
 	sGssKeyEx, sGssKexAlgorithms, sGssStoreRekey,
aa3c245
 	sAcceptEnv, sSetEnv, sPermitTunnel,
5923b7b
 	sMatch, sPermitOpen, sPermitListen, sForceCommand, sChrootDirectory,
aa3c245
@@ -497,14 +500,16 @@ static struct {
300c081
 	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL },
300c081
 	{ "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL },
aa3c245
 	{ "gssapikexalgorithms", sGssKexAlgorithms, SSHCFG_GLOBAL },
300c081
+	{ "gssapienablek5users", sGssEnablek5users, SSHCFG_ALL },
300c081
 #else
300c081
 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
300c081
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
aa3c245
 	{ "gssapicleanupcreds", sUnsupported, SSHCFG_GLOBAL },
300c081
 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
300c081
 	{ "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL },
300c081
 	{ "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL },
aa3c245
 	{ "gssapikexalgorithms", sUnsupported, SSHCFG_GLOBAL },
300c081
+	{ "gssapienablek5users", sUnsupported, SSHCFG_ALL },
300c081
 #endif
300c081
 	{ "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL },
300c081
 	{ "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL },
6995654
@@ -1653,6 +1658,10 @@ process_server_config_line(ServerOptions
300c081
 		intptr = &options->use_kuserok;
300c081
 		goto parse_flag;
300c081
 
300c081
+	case sGssEnablek5users:
300c081
+		intptr = &options->enable_k5users;
300c081
+		goto parse_flag;
300c081
+
5686259
	case sMatch:
5686259
		if (cmdline)
5686259
			fatal("Match directive not supported as a command-line "
6995654
@@ -2026,6 +2035,7 @@ copy_set_server_options(ServerOptions *d
300c081
 	M_CP_INTOPT(ip_qos_interactive);
300c081
 	M_CP_INTOPT(ip_qos_bulk);
300c081
 	M_CP_INTOPT(use_kuserok);
300c081
+	M_CP_INTOPT(enable_k5users);
300c081
 	M_CP_INTOPT(rekey_limit);
300c081
 	M_CP_INTOPT(rekey_interval);
c7d42e7
 	M_CP_INTOPT(log_level);
6995654
@@ -2320,6 +2330,7 @@ dump_config(ServerOptions *o)
c7d42e7
 # endif
afffcad
 	dump_cfg_fmtint(sKerberosUniqueCCache, o->kerberos_unique_ccache);
300c081
 	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
300c081
+	dump_cfg_fmtint(sGssEnablek5users, o->enable_k5users);
c7d42e7
 #endif
c7d42e7
 #ifdef GSSAPI
c7d42e7
 	dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
6995654
diff -up openssh-7.4p1/servconf.h.GSSAPIEnablek5users openssh-7.4p1/servconf.h
6995654
--- openssh-7.4p1/servconf.h.GSSAPIEnablek5users	2016-12-23 15:18:40.616216100 +0100
6995654
+++ openssh-7.4p1/servconf.h	2016-12-23 15:18:40.629216102 +0100
c7d42e7
@@ -174,6 +174,7 @@ typedef struct {
afffcad
	int     kerberos_unique_ccache;		/* If true, the acquired ticket will
db96e2a
						 * be stored in per-session ccache */
c7d42e7
 	int	use_kuserok;
300c081
+	int		enable_k5users;
c7d42e7
 	int     gss_authentication;	/* If true, permit GSSAPI authentication */
c7d42e7
 	int     gss_keyex;		/* If true, permit GSSAPI key exchange */
c7d42e7
 	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
6995654
diff -up openssh-7.4p1/sshd_config.5.GSSAPIEnablek5users openssh-7.4p1/sshd_config.5
6995654
--- openssh-7.4p1/sshd_config.5.GSSAPIEnablek5users	2016-12-23 15:18:40.630216103 +0100
6995654
+++ openssh-7.4p1/sshd_config.5	2016-12-23 15:36:21.607408435 +0100
6995654
@@ -628,6 +628,12 @@ Specifies whether to automatically destr
845bd87
 on logout.
300c081
 The default is
6995654
 .Cm yes .
300c081
+.It Cm GSSAPIEnablek5users
300c081
+Specifies whether to look at .k5users file for GSSAPI authentication
300c081
+access control. Further details are described in
300c081
+.Xr ksu 1 .
300c081
+The default is
6995654
+.Cm no .
6995654
 .It Cm GSSAPIKeyExchange
6995654
 Specifies whether key exchange based on GSSAPI is allowed. GSSAPI key exchange
6995654
 doesn't rely on ssh keys to verify host identity.
6995654
diff -up openssh-7.4p1/sshd_config.GSSAPIEnablek5users openssh-7.4p1/sshd_config
6995654
--- openssh-7.4p1/sshd_config.GSSAPIEnablek5users	2016-12-23 15:18:40.616216100 +0100
6995654
+++ openssh-7.4p1/sshd_config	2016-12-23 15:18:40.631216103 +0100
6995654
@@ -80,6 +80,7 @@ GSSAPIAuthentication yes
9549c46
 #GSSAPICleanupCredentials yes
00e17c1
 #GSSAPIStrictAcceptorCheck yes
00e17c1
 #GSSAPIKeyExchange no
00e17c1
+#GSSAPIEnablek5users no
00e17c1
 
00e17c1
 # Set this to 'yes' to enable PAM authentication, account processing,
00e17c1
 # and session processing. If this is enabled, PAM authentication will