8f2528
diff -up openssh-7.4p1/gss-serv-krb5.c.GSSAPIEnablek5users openssh-7.4p1/gss-serv-krb5.c
8f2528
--- openssh-7.4p1/gss-serv-krb5.c.GSSAPIEnablek5users	2017-02-09 10:10:47.403859893 +0100
8f2528
+++ openssh-7.4p1/gss-serv-krb5.c	2017-02-09 10:10:47.414859882 +0100
8f2528
@@ -260,7 +260,6 @@ ssh_gssapi_krb5_cmdok(krb5_principal pri
8f2528
 	FILE *fp;
8f2528
 	char file[MAXPATHLEN];
8f2528
 	char line[BUFSIZ];
8f2528
-	char kuser[65]; /* match krb5_kuserok() */
8f2528
 	struct stat st;
8f2528
 	struct passwd *pw = the_authctxt->pw;
8f2528
 	int found_principal = 0;
8f2528
@@ -269,7 +268,7 @@ ssh_gssapi_krb5_cmdok(krb5_principal pri
8f2528
 
8f2528
 	snprintf(file, sizeof(file), "%s/.k5users", pw->pw_dir);
8f2528
 	/* If both .k5login and .k5users DNE, self-login is ok. */
8f2528
-	if (!k5login_exists && (access(file, F_OK) == -1)) {
8f2528
+	if ( !options.enable_k5users || (!k5login_exists && (access(file, F_OK) == -1))) {
8f2528
                 return ssh_krb5_kuserok(krb_context, principal, luser,
8f2528
                                         k5login_exists);
8f2528
 	}
8f2528
diff -up openssh-7.4p1/servconf.c.GSSAPIEnablek5users openssh-7.4p1/servconf.c
8f2528
--- openssh-7.4p1/servconf.c.GSSAPIEnablek5users	2017-02-09 10:10:47.404859892 +0100
8f2528
+++ openssh-7.4p1/servconf.c	2017-02-09 10:18:45.800385543 +0100
8f2528
@@ -166,6 +166,7 @@ initialize_server_options(ServerOptions
8f2528
 	options->ip_qos_bulk = -1;
8f2528
 	options->version_addendum = NULL;
8f2528
 	options->use_kuserok = -1;
8f2528
+	options->enable_k5users = -1;
8f2528
 	options->fingerprint_hash = -1;
8f2528
 	options->disable_forwarding = -1;
8f2528
 }
8f2528
@@ -337,6 +338,8 @@ fill_default_server_options(ServerOption
8f2528
 		options->show_patchlevel = 0;
8f2528
 	if (options->use_kuserok == -1)
8f2528
 		options->use_kuserok = 1;
8f2528
+	if (options->enable_k5users == -1)
8f2528
+		options->enable_k5users = 0;
8f2528
 	if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1)
8f2528
 		options->fwd_opts.streamlocal_bind_mask = 0177;
8f2528
 	if (options->fwd_opts.streamlocal_bind_unlink == -1)
8f2528
@@ -418,7 +421,7 @@ typedef enum {
8f2528
 	sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes,
8f2528
 	sHostKeyAlgorithms,
8f2528
 	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
8f2528
-	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
8f2528
+	sGssAuthentication, sGssCleanupCreds, sGssEnablek5users, sGssStrictAcceptor,
8f2528
 	sGssKeyEx, sGssStoreRekey, sAcceptEnv, sPermitTunnel,
8f2528
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
8f2528
 	sUsePrivilegeSeparation, sAllowAgentForwarding,
8f2528
@@ -497,12 +500,14 @@ static struct {
8f2528
 	{ "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL },
8f2528
 	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL },
8f2528
 	{ "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL },
8f2528
+	{ "gssapienablek5users", sGssEnablek5users, SSHCFG_ALL },
8f2528
 #else
8f2528
 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
8f2528
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
8f2528
 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
8f2528
 	{ "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL },
8f2528
 	{ "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL },
8f2528
+	{ "gssapienablek5users", sUnsupported, SSHCFG_ALL },
8f2528
 #endif
8f2528
 	{ "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL },
8f2528
 	{ "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL },
8f2528
@@ -1653,6 +1658,10 @@ process_server_config_line(ServerOptions
8f2528
 		intptr = &options->use_kuserok;
8f2528
 		goto parse_flag;
8f2528
 
8f2528
+	case sGssEnablek5users:
8f2528
+		intptr = &options->enable_k5users;
8f2528
+		goto parse_flag;
8f2528
+
8f2528
 	case sPermitOpen:
8f2528
 		arg = strdelim(&cp;;
8f2528
 		if (!arg || *arg == '\0')
8f2528
@@ -2026,6 +2035,7 @@ copy_set_server_options(ServerOptions *d
8f2528
 	M_CP_INTOPT(ip_qos_interactive);
8f2528
 	M_CP_INTOPT(ip_qos_bulk);
8f2528
 	M_CP_INTOPT(use_kuserok);
8f2528
+	M_CP_INTOPT(enable_k5users);
8f2528
 	M_CP_INTOPT(rekey_limit);
8f2528
 	M_CP_INTOPT(rekey_interval);
8f2528
 
8f2528
@@ -2319,6 +2329,7 @@ dump_config(ServerOptions *o)
8f2528
 	dump_cfg_fmtint(sStreamLocalBindUnlink, o->fwd_opts.streamlocal_bind_unlink);
8f2528
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
8f2528
 	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
8f2528
+	dump_cfg_fmtint(sGssEnablek5users, o->enable_k5users);
8f2528
 	dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash);
8f2528
 
8f2528
 	/* string arguments */
8f2528
diff -up openssh-7.4p1/servconf.h.GSSAPIEnablek5users openssh-7.4p1/servconf.h
8f2528
--- openssh-7.4p1/servconf.h.GSSAPIEnablek5users	2017-02-09 10:10:47.404859892 +0100
8f2528
+++ openssh-7.4p1/servconf.h	2017-02-09 10:10:47.415859881 +0100
8f2528
@@ -174,7 +174,8 @@ typedef struct {
8f2528
 
8f2528
 	int	num_permitted_opens;
8f2528
 
8f2528
-	int	use_kuserok;
8f2528
+	int		use_kuserok;
8f2528
+	int		enable_k5users;
8f2528
 	char   *chroot_directory;
8f2528
 	char   *revoked_keys_file;
8f2528
 	char   *trusted_user_ca_keys;
8f2528
diff -up openssh-7.4p1/sshd_config.5.GSSAPIEnablek5users openssh-7.4p1/sshd_config.5
8f2528
--- openssh-7.4p1/sshd_config.5.GSSAPIEnablek5users	2017-02-09 10:10:47.415859881 +0100
8f2528
+++ openssh-7.4p1/sshd_config.5	2017-02-09 10:19:29.420336796 +0100
8f2528
@@ -633,6 +633,12 @@ Specifies whether key exchange based on
8f2528
 doesn't rely on ssh keys to verify host identity.
8f2528
 The default is
8f2528
 .Dq no .
8f2528
+.It Cm GSSAPIEnablek5users
8f2528
+Specifies whether to look at .k5users file for GSSAPI authentication
8f2528
+access control. Further details are described in
8f2528
+.Xr ksu 1 .
8f2528
+The default is
8f2528
+.Cm no .
8f2528
 .It Cm GSSAPIStrictAcceptorCheck
8f2528
 Determines whether to be strict about the identity of the GSSAPI acceptor
8f2528
 a client authenticates against.
8f2528
diff -up openssh-7.4p1/sshd_config.GSSAPIEnablek5users openssh-7.4p1/sshd_config
8f2528
--- openssh-7.4p1/sshd_config.GSSAPIEnablek5users	2017-02-09 10:10:47.404859892 +0100
8f2528
+++ openssh-7.4p1/sshd_config	2017-02-09 10:10:47.415859881 +0100
8f2528
@@ -80,6 +80,7 @@ GSSAPIAuthentication yes
8f2528
 GSSAPICleanupCredentials no
8f2528
 #GSSAPIStrictAcceptorCheck yes
8f2528
 #GSSAPIKeyExchange no
8f2528
+#GSSAPIEnablek5users no
8f2528
 
8f2528
 # Set this to 'yes' to enable PAM authentication, account processing,
8f2528
 # and session processing. If this is enabled, PAM authentication will