vishalmishra434 / rpms / openssh

Forked from rpms/openssh 3 months ago
Clone
Petr Lautrbach 140e5c
diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c
Petr Lautrbach 140e5c
index 0a4930e..a7c0c5f 100644
Petr Lautrbach 140e5c
--- a/gss-serv-krb5.c
Petr Lautrbach 140e5c
+++ b/gss-serv-krb5.c
Petr Lautrbach 140e5c
@@ -260,7 +260,6 @@ ssh_gssapi_krb5_cmdok(krb5_principal principal, const char *name,
Petr Lautrbach 140e5c
 	FILE *fp;
Petr Lautrbach 140e5c
 	char file[MAXPATHLEN];
Petr Lautrbach 140e5c
 	char line[BUFSIZ];
Petr Lautrbach 140e5c
-	char kuser[65]; /* match krb5_kuserok() */
Petr Lautrbach 140e5c
 	struct stat st;
Petr Lautrbach 140e5c
 	struct passwd *pw = the_authctxt->pw;
Petr Lautrbach 140e5c
 	int found_principal = 0;
Petr Lautrbach 140e5c
@@ -269,7 +268,7 @@ ssh_gssapi_krb5_cmdok(krb5_principal principal, const char *name,
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
 	snprintf(file, sizeof(file), "%s/.k5users", pw->pw_dir);
Petr Lautrbach 140e5c
 	/* If both .k5login and .k5users DNE, self-login is ok. */
Petr Lautrbach 140e5c
-	if (!k5login_exists && (access(file, F_OK) == -1)) {
Petr Lautrbach 140e5c
+	if ( !options.enable_k5users || (!k5login_exists && (access(file, F_OK) == -1))) {
Petr Lautrbach 140e5c
                 return ssh_krb5_kuserok(krb_context, principal, luser,
Petr Lautrbach 140e5c
                                         k5login_exists);
Petr Lautrbach 140e5c
 	}
Petr Lautrbach 140e5c
diff --git a/servconf.c b/servconf.c
Petr Lautrbach 140e5c
index d482e79..ad5869b 100644
Petr Lautrbach 140e5c
--- a/servconf.c
Petr Lautrbach 140e5c
+++ b/servconf.c
Petr Lautrbach 140e5c
@@ -158,6 +158,7 @@ initialize_server_options(ServerOptions *options)
Petr Lautrbach 140e5c
 	options->ip_qos_bulk = -1;
Petr Lautrbach 140e5c
 	options->version_addendum = NULL;
Petr Lautrbach 140e5c
 	options->use_kuserok = -1;
Petr Lautrbach 140e5c
+	options->enable_k5users = -1;
Petr Lautrbach 140e5c
 }
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
 void
Petr Lautrbach 140e5c
@@ -315,6 +316,8 @@ fill_default_server_options(ServerOptions *options)
Petr Lautrbach 140e5c
 		options->show_patchlevel = 0;
Petr Lautrbach 140e5c
 	if (options->use_kuserok == -1)
Petr Lautrbach 140e5c
 		options->use_kuserok = 1;
Petr Lautrbach 140e5c
+	if (options->enable_k5users == -1)
Petr Lautrbach 140e5c
+		options->enable_k5users = 0;
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
 	/* Turn privilege separation on by default */
Petr Lautrbach 140e5c
 	if (use_privsep == -1)
Petr Lautrbach 140e5c
@@ -356,7 +359,7 @@ typedef enum {
Petr Lautrbach 140e5c
 	sBanner, sShowPatchLevel, sUseDNS, sHostbasedAuthentication,
Petr Lautrbach 140e5c
 	sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
Petr Lautrbach 140e5c
 	sClientAliveCountMax, sAuthorizedKeysFile,
Petr Lautrbach 140e5c
-	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
Petr Lautrbach 140e5c
+	sGssAuthentication, sGssCleanupCreds, sGssEnablek5users, sGssStrictAcceptor,
Petr Lautrbach 140e5c
 	sGssKeyEx, sGssStoreRekey, sAcceptEnv, sPermitTunnel,
Petr Lautrbach 140e5c
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
Petr Lautrbach 140e5c
 	sUsePrivilegeSeparation, sAllowAgentForwarding,
Petr Lautrbach 140e5c
@@ -430,6 +433,7 @@ static struct {
Petr Lautrbach 140e5c
 	{ "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
 	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
 	{ "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
+	{ "gssapienablek5users", sGssEnablek5users, SSHCFG_ALL },
Petr Lautrbach 140e5c
 #else
Petr Lautrbach 140e5c
 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
Petr Lautrbach 140e5c
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
@@ -437,6 +441,7 @@ static struct {
Petr Lautrbach 140e5c
 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
 	{ "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
 	{ "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
+	{ "gssapienablek5users", sUnsupported, SSHCFG_ALL },
Petr Lautrbach 140e5c
 #endif
Petr Lautrbach 140e5c
 	{ "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
 	{ "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 140e5c
@@ -1536,6 +1541,10 @@ process_server_config_line(ServerOptions *options, char *line,
Petr Lautrbach 140e5c
 		intptr = &options->use_kuserok;
Petr Lautrbach 140e5c
 		goto parse_flag;
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
+	case sGssEnablek5users:
Petr Lautrbach 140e5c
+		intptr = &options->enable_k5users;
Petr Lautrbach 140e5c
+		goto parse_flag;
Petr Lautrbach 140e5c
+
Petr Lautrbach 140e5c
 	case sPermitOpen:
Petr Lautrbach 140e5c
 		arg = strdelim(&cp;;
Petr Lautrbach 140e5c
 		if (!arg || *arg == '\0')
Petr Lautrbach 140e5c
@@ -1824,6 +1833,7 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
Petr Lautrbach 140e5c
 	M_CP_INTOPT(ip_qos_interactive);
Petr Lautrbach 140e5c
 	M_CP_INTOPT(ip_qos_bulk);
Petr Lautrbach 140e5c
 	M_CP_INTOPT(use_kuserok);
Petr Lautrbach 140e5c
+	M_CP_INTOPT(enable_k5users);
Petr Lautrbach 140e5c
 	M_CP_INTOPT(rekey_limit);
Petr Lautrbach 140e5c
 	M_CP_INTOPT(rekey_interval);
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
@@ -2076,6 +2086,7 @@ dump_config(ServerOptions *o)
Petr Lautrbach 140e5c
 	dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
Petr Lautrbach 140e5c
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
Petr Lautrbach 140e5c
 	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
Petr Lautrbach 140e5c
+	dump_cfg_fmtint(sGssEnablek5users, o->enable_k5users);
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
 	/* string arguments */
Petr Lautrbach 140e5c
 	dump_cfg_string(sPidFile, o->pid_file);
Petr Lautrbach 140e5c
diff --git a/servconf.h b/servconf.h
Petr Lautrbach 140e5c
index 5117dfa..d63cb71 100644
Petr Lautrbach 140e5c
--- a/servconf.h
Petr Lautrbach 140e5c
+++ b/servconf.h
Petr Lautrbach 140e5c
@@ -173,7 +173,8 @@ typedef struct {
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
 	int	num_permitted_opens;
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
-	int	use_kuserok;
Petr Lautrbach 140e5c
+	int		use_kuserok;
Petr Lautrbach 140e5c
+	int		enable_k5users;
Petr Lautrbach 140e5c
 	char   *chroot_directory;
Petr Lautrbach 140e5c
 	char   *revoked_keys_file;
Petr Lautrbach 140e5c
 	char   *trusted_user_ca_keys;
Petr Lautrbach 140e5c
diff --git a/sshd_config b/sshd_config
Petr Lautrbach 140e5c
index 43671f6..6ab00ed 100644
Petr Lautrbach 140e5c
--- a/sshd_config
Petr Lautrbach 140e5c
+++ b/sshd_config
Petr Lautrbach 140e5c
@@ -94,6 +94,7 @@ GSSAPIAuthentication yes
Petr Lautrbach 140e5c
 GSSAPICleanupCredentials no
Petr Lautrbach 140e5c
 #GSSAPIStrictAcceptorCheck yes
Petr Lautrbach 140e5c
 #GSSAPIKeyExchange no
Petr Lautrbach 140e5c
+#GSSAPIEnablek5users no
Petr Lautrbach 140e5c
 
Petr Lautrbach 140e5c
 # Set this to 'yes' to enable PAM authentication, account processing,
Petr Lautrbach 140e5c
 # and session processing. If this is enabled, PAM authentication will
Petr Lautrbach 140e5c
diff --git a/sshd_config.5 b/sshd_config.5
Petr Lautrbach 140e5c
index e0e5fff..aa9525d 100644
Petr Lautrbach 140e5c
--- a/sshd_config.5
Petr Lautrbach 140e5c
+++ b/sshd_config.5
Petr Lautrbach 140e5c
@@ -505,6 +505,12 @@ on logout.
Petr Lautrbach 140e5c
 The default is
Petr Lautrbach 140e5c
 .Dq yes .
Petr Lautrbach 140e5c
 Note that this option applies to protocol version 2 only.
Petr Lautrbach 140e5c
+.It Cm GSSAPIEnablek5users
Petr Lautrbach 140e5c
+Specifies whether to look at .k5users file for GSSAPI authentication
Petr Lautrbach 140e5c
+access control. Further details are described in
Petr Lautrbach 140e5c
+.Xr ksu 1 .
Petr Lautrbach 140e5c
+The default is
Petr Lautrbach 140e5c
+.Dq no .
Petr Lautrbach 140e5c
 .It Cm GSSAPIStrictAcceptorCheck
Petr Lautrbach 140e5c
 Determines whether to be strict about the identity of the GSSAPI acceptor 
Petr Lautrbach 140e5c
 a client authenticates against. If