vishalmishra434 / rpms / openssh

Forked from rpms/openssh 3 months ago
Clone
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/auth-krb5.c.kuserok openssh-5.9p0/auth-krb5.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/auth-krb5.c.kuserok	2011-08-30 16:37:32.651150128 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/auth-krb5.c	2011-08-30 16:37:37.549087368 +0200
Jan F. Chadima 69dd72
@@ -54,6 +54,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
 {
Jan F. Chadima 69dd72
@@ -146,7 +160,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
 	}
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/gss-serv-krb5.c.kuserok openssh-5.9p0/gss-serv-krb5.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/gss-serv-krb5.c.kuserok	2011-08-30 16:37:36.988024804 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/gss-serv-krb5.c	2011-08-30 16:37:37.659088030 +0200
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);
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/servconf.c.kuserok openssh-5.9p0/servconf.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/servconf.c.kuserok	2011-08-30 16:37:35.093073603 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/servconf.c	2011-08-30 16:41:13.568087145 +0200
Jan F. Chadima 69dd72
@@ -144,6 +144,7 @@ initialize_server_options(ServerOptions
Jan F. Chadima 69dd72
 	options->authorized_principals_file = NULL;
Jan F. Chadima 69dd72
 	options->ip_qos_interactive = -1;
Jan F. Chadima 69dd72
 	options->ip_qos_bulk = -1;
Jan F. Chadima 69dd72
+	options->use_kuserok = -1;
Jan F. Chadima 69dd72
 }
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 void
Jan F. Chadima 69dd72
@@ -291,6 +292,8 @@ fill_default_server_options(ServerOption
Jan F. Chadima 69dd72
 		options->ip_qos_bulk = IPTOS_THROUGHPUT;
Jan F. Chadima 69dd72
 	if (options->show_patchlevel == -1)
Jan F. Chadima 69dd72
  		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)
Jan F. Chadima 69dd72
@@ -317,7 +320,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,
Jan F. Chadima 69dd72
@@ -388,11 +391,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 },
Jan F. Chadima 69dd72
@@ -1371,6 +1376,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')
Jan F. Chadima 69dd72
@@ -1580,6 +1589,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();
Jan F. Chadima 69dd72
@@ -1816,6 +1826,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);
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/servconf.h.kuserok openssh-5.9p0/servconf.h
Jan F. Chadima 69dd72
--- openssh-5.9p0/servconf.h.kuserok	2011-08-30 16:37:35.201051957 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/servconf.h	2011-08-30 16:37:37.926087431 +0200
Jan F. Chadima 69dd72
@@ -166,6 +166,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;
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/sshd_config.5.kuserok openssh-5.9p0/sshd_config.5
Jan F. Chadima 69dd72
--- openssh-5.9p0/sshd_config.5.kuserok	2011-08-30 16:37:35.979024607 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/sshd_config.5	2011-08-30 16:37:38.040087843 +0200
Jan F. Chadima 69dd72
@@ -603,6 +603,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.
Jan F. Chadima 69dd72
@@ -746,6 +750,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 ,
Jan F. Chadima 69dd72
 .Cm PubkeyAuthentication ,
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/sshd_config.kuserok openssh-5.9p0/sshd_config
Jan F. Chadima 69dd72
--- openssh-5.9p0/sshd_config.kuserok	2011-08-30 16:37:36.808026328 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/sshd_config	2011-08-30 16:37:38.148071520 +0200
Jan F. Chadima 69dd72
@@ -77,6 +77,7 @@ ChallengeResponseAuthentication no
Jan F. Chadima 69dd72
 #KerberosOrLocalPasswd yes
Jan F. Chadima 69dd72
 #KerberosTicketCleanup yes
Jan F. Chadima 69dd72
 #KerberosGetAFSToken no
Jan F. Chadima 69dd72
+#KerberosUseKuserok yes
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 # GSSAPI options
Jan F. Chadima 69dd72
 #GSSAPIAuthentication no