vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Petr Lautrbach 8a29de
diff -up openssh-6.2p1/auth-krb5.c.kuserok openssh-6.2p1/auth-krb5.c
Petr Lautrbach 8a29de
--- openssh-6.2p1/auth-krb5.c.kuserok	2013-03-25 20:06:51.295558062 +0100
Petr Lautrbach 8a29de
+++ openssh-6.2p1/auth-krb5.c	2013-03-25 20:06:51.318558207 +0100
Petr Lautrbach 9fe1af
@@ -55,6 +55,20 @@
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 extern ServerOptions	 options;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+int
Jan F. Chadima 69dd72
+ssh_krb5_kuserok(krb5_context krb5_ctx, krb5_principal krb5_user, const char *client)
Jan F. Chadima 69dd72
+{
Jan F. Chadima 69dd72
+	if (options.use_kuserok)
Jan F. Chadima 69dd72
+		return krb5_kuserok(krb5_ctx, krb5_user, client);
Jan F. Chadima 69dd72
+	else {
Jan F. Chadima 69dd72
+		char kuser[65];
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+		if (krb5_aname_to_localname(krb5_ctx, krb5_user, sizeof(kuser), kuser))
Jan F. Chadima 69dd72
+			return 0;
Jan F. Chadima 69dd72
+		return strcmp(kuser, client) == 0;
Jan F. Chadima 69dd72
+	}
Jan F. Chadima 69dd72
+}
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 static int
Jan F. Chadima 69dd72
 krb5_init(void *context)
Jan F. Chadima 69dd72
 {
Petr Lautrbach 9fe1af
@@ -147,7 +161,7 @@ auth_krb5_password(Authctxt *authctxt, c
Jan F. Chadima 69dd72
 	if (problem)
Jan F. Chadima 69dd72
 		goto out;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
-	if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
Jan F. Chadima 69dd72
+	if (!ssh_krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
Jan F. Chadima 69dd72
 		problem = -1;
Jan F. Chadima 69dd72
 		goto out;
Jan F. Chadima 69dd72
 	}
Petr Lautrbach 8a29de
diff -up openssh-6.2p1/gss-serv-krb5.c.kuserok openssh-6.2p1/gss-serv-krb5.c
Petr Lautrbach 8a29de
--- openssh-6.2p1/gss-serv-krb5.c.kuserok	2013-03-25 20:06:51.311558163 +0100
Petr Lautrbach 8a29de
+++ openssh-6.2p1/gss-serv-krb5.c	2013-03-25 20:06:51.319558214 +0100
Jan F. Chadima 69dd72
@@ -68,6 +68,7 @@ static int ssh_gssapi_krb5_cmdok(krb5_pr
Jan F. Chadima 69dd72
     int);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 static krb5_context krb_context = NULL;
Jan F. Chadima 69dd72
+extern int ssh_krb5_kuserok(krb5_context, krb5_principal, const char *);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 /* Initialise the krb5 library, for the stuff that GSSAPI won't do */
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
@@ -115,7 +116,7 @@ ssh_gssapi_krb5_userok(ssh_gssapi_client
Jan F. Chadima 69dd72
 	/* NOTE: .k5login and .k5users must opened as root, not the user,
Jan F. Chadima 69dd72
 	 * because if they are on a krb5-protected filesystem, user credentials
Jan F. Chadima 69dd72
 	 * to access these files aren't available yet. */
Jan F. Chadima 69dd72
-	if (krb5_kuserok(krb_context, princ, luser) && k5login_exists) {
Jan F. Chadima 69dd72
+	if (ssh_krb5_kuserok(krb_context, princ, luser) && k5login_exists) {
Jan F. Chadima 69dd72
 		retval = 1;
Jan F. Chadima 69dd72
 		logit("Authorized to %s, krb5 principal %s (krb5_kuserok)",
Jan F. Chadima 69dd72
 		    luser, (char *)client->displayname.value);
Petr Lautrbach 8a29de
diff -up openssh-6.2p1/servconf.c.kuserok openssh-6.2p1/servconf.c
Petr Lautrbach 8a29de
--- openssh-6.2p1/servconf.c.kuserok	2013-03-25 20:06:51.305558125 +0100
Petr Lautrbach 8a29de
+++ openssh-6.2p1/servconf.c	2013-03-25 20:06:51.319558214 +0100
Petr Lautrbach 8a29de
@@ -150,6 +150,7 @@ initialize_server_options(ServerOptions
Jan F. Chadima 69dd72
 	options->ip_qos_interactive = -1;
Jan F. Chadima 69dd72
 	options->ip_qos_bulk = -1;
Petr Lautrbach 9fe1af
 	options->version_addendum = NULL;
Jan F. Chadima 69dd72
+	options->use_kuserok = -1;
Jan F. Chadima 69dd72
 }
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 void
Petr Lautrbach 8a29de
@@ -299,6 +300,8 @@ fill_default_server_options(ServerOption
Petr Lautrbach 9fe1af
 		options->version_addendum = xstrdup("");
Jan F. Chadima 69dd72
 	if (options->show_patchlevel == -1)
Petr Lautrbach 9fe1af
 		options->show_patchlevel = 0;
Jan F. Chadima 69dd72
+	if (options->use_kuserok == -1)
Jan F. Chadima 69dd72
+		options->use_kuserok = 1;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 	/* Turn privilege separation on by default */
Jan F. Chadima 69dd72
 	if (use_privsep == -1)
Petr Lautrbach 8a29de
@@ -325,7 +328,7 @@ typedef enum {
Jan F. Chadima 69dd72
 	sPermitRootLogin, sLogFacility, sLogLevel,
Jan F. Chadima 69dd72
 	sRhostsRSAAuthentication, sRSAAuthentication,
Jan F. Chadima 69dd72
 	sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
Jan F. Chadima 69dd72
-	sKerberosGetAFSToken,
Jan F. Chadima 69dd72
+	sKerberosGetAFSToken, sKerberosUseKuserok,
Jan F. Chadima 69dd72
 	sKerberosTgtPassing, sChallengeResponseAuthentication,
Jan F. Chadima 69dd72
 	sPasswordAuthentication, sKbdInteractiveAuthentication,
Jan F. Chadima 69dd72
 	sListenAddress, sAddressFamily,
Petr Lautrbach 8a29de
@@ -397,11 +400,13 @@ static struct {
Jan F. Chadima 69dd72
 #else
Jan F. Chadima 69dd72
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
+	{ "kerberosusekuserok", sKerberosUseKuserok, SSHCFG_ALL },
Jan F. Chadima 69dd72
 #else
Jan F. Chadima 69dd72
 	{ "kerberosauthentication", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 69dd72
 	{ "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
 	{ "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
+	{ "kerberosusekuserok", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
 	{ "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
 	{ "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
Petr Lautrbach 8a29de
@@ -1460,6 +1465,10 @@ process_server_config_line(ServerOptions
Jan F. Chadima 69dd72
 		*activep = value;
Jan F. Chadima 69dd72
 		break;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+	case sKerberosUseKuserok:
Jan F. Chadima 69dd72
+		intptr = &options->use_kuserok;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 	case sPermitOpen:
Jan F. Chadima 69dd72
 		arg = strdelim(&cp;;
Jan F. Chadima 69dd72
 		if (!arg || *arg == '\0')
Petr Lautrbach 8a29de
@@ -1761,6 +1770,7 @@ copy_set_server_options(ServerOptions *d
Jan F. Chadima 69dd72
 	M_CP_INTOPT(max_authtries);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(ip_qos_interactive);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(ip_qos_bulk);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(use_kuserok);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 	/* See comment in servconf.h */
Jan F. Chadima 69dd72
 	COPY_MATCH_STRING_OPTS();
Petr Lautrbach 8a29de
@@ -1999,6 +2009,7 @@ dump_config(ServerOptions *o)
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sUseDNS, o->use_dns);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
Jan F. Chadima 69dd72
+	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 	/* string arguments */
Jan F. Chadima 69dd72
 	dump_cfg_string(sPidFile, o->pid_file);
Petr Lautrbach 8a29de
diff -up openssh-6.2p1/servconf.h.kuserok openssh-6.2p1/servconf.h
Petr Lautrbach 8a29de
--- openssh-6.2p1/servconf.h.kuserok	2013-03-25 20:06:51.305558125 +0100
Petr Lautrbach 8a29de
+++ openssh-6.2p1/servconf.h	2013-03-25 20:06:51.320558220 +0100
Petr Lautrbach 8a29de
@@ -173,6 +173,7 @@ typedef struct {
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 	int	num_permitted_opens;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+	int	use_kuserok;
Jan F. Chadima 69dd72
 	char   *chroot_directory;
Jan F. Chadima 69dd72
 	char   *revoked_keys_file;
Jan F. Chadima 69dd72
 	char   *trusted_user_ca_keys;
Petr Lautrbach 8a29de
diff -up openssh-6.2p1/sshd_config.kuserok openssh-6.2p1/sshd_config
Petr Lautrbach 8a29de
--- openssh-6.2p1/sshd_config.kuserok	2013-03-25 20:06:51.308558144 +0100
Petr Lautrbach 8a29de
+++ openssh-6.2p1/sshd_config	2013-03-25 20:06:51.320558220 +0100
Petr Lautrbach 8a29de
@@ -83,6 +83,7 @@ ChallengeResponseAuthentication no
Petr Lautrbach 9fe1af
 #KerberosOrLocalPasswd yes
Petr Lautrbach 9fe1af
 #KerberosTicketCleanup yes
Petr Lautrbach 9fe1af
 #KerberosGetAFSToken no
Petr Lautrbach 9fe1af
+#KerberosUseKuserok yes
Petr Lautrbach 9fe1af
 
Petr Lautrbach 9fe1af
 # GSSAPI options
Petr Lautrbach 9fe1af
 #GSSAPIAuthentication no
Petr Lautrbach 8a29de
diff -up openssh-6.2p1/sshd_config.5.kuserok openssh-6.2p1/sshd_config.5
Petr Lautrbach 8a29de
--- openssh-6.2p1/sshd_config.5.kuserok	2013-03-25 20:06:51.308558144 +0100
Petr Lautrbach 8a29de
+++ openssh-6.2p1/sshd_config.5	2013-03-25 20:08:34.249207272 +0100
Petr Lautrbach 8a29de
@@ -660,6 +660,10 @@ Specifies whether to automatically destr
Jan F. Chadima 69dd72
 file on logout.
Jan F. Chadima 69dd72
 The default is
Jan F. Chadima 69dd72
 .Dq yes .
Jan F. Chadima 69dd72
+.It Cm KerberosUseKuserok
Jan F. Chadima 69dd72
+Specifies whether to look at .k5login file for user's aliases.
Jan F. Chadima 69dd72
+The default is
Jan F. Chadima 69dd72
+.Dq yes .
Jan F. Chadima 69dd72
 .It Cm KexAlgorithms
Jan F. Chadima 69dd72
 Specifies the available KEX (Key Exchange) algorithms.
Jan F. Chadima 69dd72
 Multiple algorithms must be comma-separated.
Petr Lautrbach 8a29de
@@ -819,6 +823,7 @@ Available keywords are
Jan F. Chadima 69dd72
 .Cm HostbasedUsesNameFromPacketOnly ,
Jan F. Chadima 69dd72
 .Cm KbdInteractiveAuthentication ,
Jan F. Chadima 69dd72
 .Cm KerberosAuthentication ,
Jan F. Chadima 69dd72
+.Cm KerberosUseKuserok ,
Jan F. Chadima 69dd72
 .Cm MaxAuthTries ,
Jan F. Chadima 69dd72
 .Cm MaxSessions ,
Petr Lautrbach 8a29de
 .Cm PasswordAuthentication ,