vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Jan F 003cb0
diff -up openssh-5.8p1/auth-krb5.c.kuserok openssh-5.8p1/auth-krb5.c
Jan F 003cb0
--- openssh-5.8p1/auth-krb5.c.kuserok	2009-12-21 00:49:22.000000000 +0100
Jan F 003cb0
+++ openssh-5.8p1/auth-krb5.c	2011-02-14 09:15:12.000000000 +0100
Jan F 82036a
@@ -54,6 +54,20 @@
Jan F 82036a
 
Jan F 82036a
 extern ServerOptions	 options;
Jan F 82036a
 
Jan F 82036a
+int
Jan F 82036a
+ssh_krb5_kuserok(krb5_context krb5_ctx, krb5_principal krb5_user, const char *client)
Jan F 82036a
+{
Jan F 82036a
+	if (options.use_kuserok)
Jan F 82036a
+		return krb5_kuserok(krb5_ctx, krb5_user, client);
Jan F 82036a
+	else {
Jan F 82036a
+		char kuser[65];
Jan F 82036a
+
Jan F 82036a
+		if (krb5_aname_to_localname(krb5_ctx, krb5_user, sizeof(kuser), kuser))
Jan F 82036a
+			return 0;
Jan F 82036a
+		return strcmp(kuser, client) == 0;
Jan F 82036a
+	}
Jan F 82036a
+}
Jan F 82036a
+
Jan F 82036a
 static int
Jan F 82036a
 krb5_init(void *context)
Jan F 82036a
 {
Jan F 82036a
@@ -146,7 +160,7 @@ auth_krb5_password(Authctxt *authctxt, c
Jan F. Chadima 59d42d
 	if (problem)
Jan F. Chadima 59d42d
 		goto out;
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
-	if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
Jan F 82036a
+	if (!ssh_krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) {
Jan F 82036a
 		problem = -1;
Jan F 82036a
 		goto out;
Jan F. Chadima 59d42d
 	}
Jan F 003cb0
diff -up openssh-5.8p1/gss-serv-krb5.c.kuserok openssh-5.8p1/gss-serv-krb5.c
Jan F 003cb0
--- openssh-5.8p1/gss-serv-krb5.c.kuserok	2006-09-01 07:38:36.000000000 +0200
Jan F 003cb0
+++ openssh-5.8p1/gss-serv-krb5.c	2011-02-14 09:15:12.000000000 +0100
Jan F 82036a
@@ -57,6 +57,7 @@ extern ServerOptions options;
Jan F 82036a
 #endif
Jan F 82036a
 
Jan F 82036a
 static krb5_context krb_context = NULL;
Jan F 82036a
+extern int ssh_krb5_kuserok(krb5_context, krb5_principal, const char *);
Jan F 82036a
 
Jan F 82036a
 /* Initialise the krb5 library, for the stuff that GSSAPI won't do */
Jan F 82036a
 
Jan F 82036a
@@ -97,7 +98,7 @@ ssh_gssapi_krb5_userok(ssh_gssapi_client
Jan F 46c77f
 		    krb5_get_err_text(krb_context, retval));
Jan F 46c77f
 		return 0;
Jan F 46c77f
 	}
Jan F 46c77f
-	if (krb5_kuserok(krb_context, princ, name)) {
Jan F 82036a
+	if (ssh_krb5_kuserok(krb_context, princ, name)) {
Jan F 82036a
 		retval = 1;
Jan F 82036a
 		logit("Authorized to %s, krb5 principal %s (krb5_kuserok)",
Jan F 82036a
 		    name, (char *)client->displayname.value);
Jan F 003cb0
diff -up openssh-5.8p1/servconf.c.kuserok openssh-5.8p1/servconf.c
Jan F 003cb0
--- openssh-5.8p1/servconf.c.kuserok	2011-02-14 09:15:12.000000000 +0100
Jan F 003cb0
+++ openssh-5.8p1/servconf.c	2011-02-14 09:20:22.000000000 +0100
Jan F 003cb0
@@ -142,6 +142,7 @@ initialize_server_options(ServerOptions 
Jan F. Chadima 1b8a26
 	options->authorized_principals_file = NULL;
Jan F 003cb0
 	options->ip_qos_interactive = -1;
Jan F 003cb0
 	options->ip_qos_bulk = -1;
Jan F. Chadima 59d42d
+	options->use_kuserok = -1;
Jan F. Chadima 59d42d
 }
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
 void
Jan F 003cb0
@@ -291,6 +292,8 @@ fill_default_server_options(ServerOption
Jan F. Chadima 59d42d
 	if (use_privsep == -1)
Jan F. Chadima 59d42d
 		use_privsep = 1;
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
+	if (options->use_kuserok == -1)
Jan F. Chadima 59d42d
+		options->use_kuserok = 1;
Jan F. Chadima 59d42d
 #ifndef HAVE_MMAP
Jan F. Chadima 59d42d
 	if (use_privsep && options->compression == 1) {
Jan F. Chadima 59d42d
 		error("This platform does not support both privilege "
Jan F 003cb0
@@ -312,7 +315,7 @@ typedef enum {
Jan F. Chadima 59d42d
 	sPermitRootLogin, sLogFacility, sLogLevel,
Jan F. Chadima 59d42d
 	sRhostsRSAAuthentication, sRSAAuthentication,
Jan F. Chadima 59d42d
 	sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
Jan F. Chadima 59d42d
-	sKerberosGetAFSToken,
Jan F. Chadima 59d42d
+	sKerberosGetAFSToken, sKerberosUseKuserok,
Jan F. Chadima 59d42d
 	sKerberosTgtPassing, sChallengeResponseAuthentication,
Jan F. Chadima 59d42d
 	sPasswordAuthentication, sKbdInteractiveAuthentication,
Jan F. Chadima 59d42d
 	sListenAddress, sAddressFamily,
Jan F 003cb0
@@ -381,11 +384,13 @@ static struct {
Jan F. Chadima 59d42d
 #else
Jan F. Chadima 59d42d
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 59d42d
 #endif
Jan F. Chadima 59d42d
+	{ "kerberosusekuserok", sKerberosUseKuserok, SSHCFG_ALL },
Jan F. Chadima 59d42d
 #else
Jan F. Chadima 59d42d
 	{ "kerberosauthentication", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 59d42d
 	{ "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 59d42d
 	{ "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 59d42d
 	{ "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 59d42d
+	{ "kerberosusekuserok", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 59d42d
 #endif
Jan F. Chadima 59d42d
 	{ "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 59d42d
 	{ "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
Jan F. Chadima 1b8a26
@@ -1341,6 +1346,10 @@ process_server_config_line(ServerOptions
Jan F. Chadima 59d42d
 		*activep = value;
Jan F. Chadima 59d42d
 		break;
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
+	case sKerberosUseKuserok:
Jan F. Chadima 59d42d
+		intptr = &options->use_kuserok;
Jan F. Chadima 59d42d
+		goto parse_flag;
Jan F. Chadima 59d42d
+
Jan F. Chadima 59d42d
 	case sPermitOpen:
Jan F. Chadima 59d42d
 		arg = strdelim(&cp;;
Jan F. Chadima 59d42d
 		if (!arg || *arg == '\0')
Jan F 003cb0
@@ -1544,6 +1553,7 @@ copy_set_server_options(ServerOptions *d
Jan F. Chadima 59d42d
 	M_CP_INTOPT(max_authtries);
Jan F 003cb0
 	M_CP_INTOPT(ip_qos_interactive);
Jan F 003cb0
 	M_CP_INTOPT(ip_qos_bulk);
Jan F. Chadima 59d42d
+	M_CP_INTOPT(use_kuserok);
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
 	M_CP_STROPT(banner);
Jan F. Chadima 59d42d
 	if (preauth)
Jan F 003cb0
@@ -1764,6 +1774,7 @@ dump_config(ServerOptions *o)
Jan F. Chadima 59d42d
 	dump_cfg_fmtint(sUseDNS, o->use_dns);
Jan F. Chadima 59d42d
 	dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
Jan F. Chadima 59d42d
 	dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
Jan F. Chadima 59d42d
+	dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok);
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
 	/* string arguments */
Jan F. Chadima 59d42d
 	dump_cfg_string(sPidFile, o->pid_file);
Jan F 003cb0
diff -up openssh-5.8p1/servconf.h.kuserok openssh-5.8p1/servconf.h
Jan F 003cb0
--- openssh-5.8p1/servconf.h.kuserok	2011-02-14 09:15:12.000000000 +0100
Jan F 003cb0
+++ openssh-5.8p1/servconf.h	2011-02-14 09:15:12.000000000 +0100
Jan F. Chadima 59d42d
@@ -157,6 +157,7 @@ typedef struct {
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
 	int	num_permitted_opens;
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
+	int	use_kuserok;
Jan F. Chadima 59d42d
 	char   *chroot_directory;
Jan F. Chadima 59d42d
 	char   *revoked_keys_file;
Jan F. Chadima 59d42d
 	char   *trusted_user_ca_keys;
Jan F 003cb0
diff -up openssh-5.8p1/sshd_config.5.kuserok openssh-5.8p1/sshd_config.5
Jan F 003cb0
--- openssh-5.8p1/sshd_config.5.kuserok	2011-02-14 09:15:12.000000000 +0100
Jan F 003cb0
+++ openssh-5.8p1/sshd_config.5	2011-02-14 09:17:11.000000000 +0100
Jan F 003cb0
@@ -574,6 +574,10 @@ Specifies whether to automatically destr
Jan F. Chadima 59d42d
 file on logout.
Jan F. Chadima 59d42d
 The default is
Jan F. Chadima 59d42d
 .Dq yes .
Jan F. Chadima 59d42d
+.It Cm KerberosUseKuserok
Jan F. Chadima 59d42d
+Specifies whether to look at .k5login file for user's aliases.
Jan F. Chadima 59d42d
+The default is
Jan F. Chadima 59d42d
+.Dq yes .
Jan F 003cb0
 .It Cm KexAlgorithms
Jan F 003cb0
 Specifies the available KEX (Key Exchange) algorithms.
Jan F 003cb0
 Multiple algorithms must be comma-separated.
Jan F 003cb0
@@ -715,6 +719,7 @@ Available keywords are
Jan F. Chadima 1b8a26
 .Cm HostbasedUsesNameFromPacketOnly ,
Jan F. Chadima 59d42d
 .Cm KbdInteractiveAuthentication ,
Jan F. Chadima 59d42d
 .Cm KerberosAuthentication ,
Jan F. Chadima 59d42d
+.Cm KerberosUseKuserok ,
Jan F. Chadima 59d42d
 .Cm MaxAuthTries ,
Jan F. Chadima 59d42d
 .Cm MaxSessions ,
Jan F. Chadima 7818e5
 .Cm PubkeyAuthentication ,
Jan F 003cb0
diff -up openssh-5.8p1/sshd_config.kuserok openssh-5.8p1/sshd_config
Jan F 003cb0
--- openssh-5.8p1/sshd_config.kuserok	2011-02-14 09:15:12.000000000 +0100
Jan F 003cb0
+++ openssh-5.8p1/sshd_config	2011-02-14 09:15:12.000000000 +0100
Jan F 003cb0
@@ -73,6 +73,7 @@ ChallengeResponseAuthentication no
Jan F. Chadima 59d42d
 #KerberosOrLocalPasswd yes
Jan F. Chadima 59d42d
 #KerberosTicketCleanup yes
Jan F. Chadima 59d42d
 #KerberosGetAFSToken no
Jan F. Chadima 59d42d
+#KerberosUseKuserok yes
Jan F. Chadima 59d42d
 
Jan F. Chadima 59d42d
 # GSSAPI options
Jan F. Chadima 59d42d
 #GSSAPIAuthentication no