components/krb5/patches/024-smb-compat.patch
changeset 5986 bab15c34f645
parent 5969 96bac9fbcfbd
child 6085 eb3c11e27709
equal deleted inserted replaced
5985:6b195cad32d4 5986:bab15c34f645
     2 # This patch allows for better interop with MS Windows clients accessing Solaris
     2 # This patch allows for better interop with MS Windows clients accessing Solaris
     3 # SMB services.  It fixes a few memory leaks and double frees found during SMB
     3 # SMB services.  It fixes a few memory leaks and double frees found during SMB
     4 # stress testing.  The CRs in order:
     4 # stress testing.  The CRs in order:
     5 #
     5 #
     6 # 15580724 SUNBT6868908 Solaris acceptors should have returned KRB5KRB_AP_...
     6 # 15580724 SUNBT6868908 Solaris acceptors should have returned KRB5KRB_AP_...
       
     7 # 15648322 SUNBT6959251 coredump in gss_release_name+0x36
     7 # 20416772 spnego_gss_accept_sec_context issue with incorrect KRB OID
     8 # 20416772 spnego_gss_accept_sec_context issue with incorrect KRB OID
     8 # 16005842 Should retry SMB authentication upgrade to account for network...
     9 # 16005842 Should retry SMB authentication upgrade to account for network...
     9 # 15579598 SUNBT6867208 Windows client cannot recover from KRB5KRB_AP_ERR_SKEW..
    10 # 15579598 SUNBT6867208 Windows client cannot recover from KRB5KRB_AP_ERR_SKEW..
    10 #
    11 #
    11 # Note: MIT tickets will subsequently be filed, but the solution may differ from
    12 # Note: MIT tickets will subsequently be filed, but the solution may differ from
    65 +        }
    66 +        }
    66 +
    67 +
    67          code -= ERROR_TABLE_BASE_krb5;
    68          code -= ERROR_TABLE_BASE_krb5;
    68          if (code < 0 || code > KRB_ERR_MAX)
    69          if (code < 0 || code > KRB_ERR_MAX)
    69              code = 60 /* KRB_ERR_GENERIC */;
    70              code = 60 /* KRB_ERR_GENERIC */;
    70 
    71 diff -ur krb5-1.13.3.023-mem-rcache.patch/src/lib/gssapi/spnego/spnego_mech.c krb5-1.13.3/src/lib/gssapi/spnego/spnego_mech.c
    71 diff -pur new/src/lib/gssapi/spnego/spnego_mech.c patched/src/lib/gssapi/spnego/spnego_mech.c
    72 --- krb5-1.13.3.023-mem-rcache.patch/src/lib/gssapi/spnego/spnego_mech.c
    72 --- new/src/lib/gssapi/spnego/spnego_mech.c	2016-02-29 11:50:13.000000000 -0800
    73 +++ krb5-1.13.3/src/lib/gssapi/spnego/spnego_mech.c
    73 +++ patched/src/lib/gssapi/spnego/spnego_mech.c	2016-03-18 21:55:31.131280297 -0700
    74 @@ -190,6 +190,13 @@
    74 @@ -191,7 +190,14 @@ static const gss_OID_set_desc spnego_oid
       
    75  };
    75  };
    76  const gss_OID_set_desc * const gss_mech_set_spnego = spnego_oidsets+0;
    76  const gss_OID_set_desc * const gss_mech_set_spnego = spnego_oidsets+0;
    77  
    77  
    78  static int make_NegHints(OM_uint32 *, gss_buffer_t *);
       
    79 +/* encoded OID octet string for NTLMSSP security mechanism */
    78 +/* encoded OID octet string for NTLMSSP security mechanism */
    80 +#define GSS_MECH_NTLMSSP_OID_LENGTH 10
    79 +#define GSS_MECH_NTLMSSP_OID_LENGTH 10
    81 +#define GSS_MECH_NTLMSSP_OID "\053\006\001\004\001\202\067\002\002\012"
    80 +#define GSS_MECH_NTLMSSP_OID "\053\006\001\004\001\202\067\002\002\012"
    82 +static gss_OID_desc ntlmssp_oid = {
    81 +static gss_OID_desc ntlmssp_oid = {
    83 +	GSS_MECH_NTLMSSP_OID_LENGTH, GSS_MECH_NTLMSSP_OID
    82 +	GSS_MECH_NTLMSSP_OID_LENGTH, GSS_MECH_NTLMSSP_OID
    84 +};
    83 +};
    85 +
    84 +
       
    85  static int make_NegHints(OM_uint32 *, spnego_gss_cred_id_t, gss_buffer_t *);
    86  static int put_neg_hints(unsigned char **, gss_buffer_t, unsigned int);
    86  static int put_neg_hints(unsigned char **, gss_buffer_t, unsigned int);
    87  static OM_uint32
    87  static OM_uint32
    88  acc_ctx_hints(OM_uint32 *, gss_ctx_id_t *, spnego_gss_cred_id_t,
    88 @@ -1237,7 +1244,7 @@
    89 @@ -1325,6 +1387,7 @@ acc_ctx_new(OM_uint32 *minor_status,
    89  					&hintNameBuf,
       
    90  					&hintNameType);
       
    91  	if (major_status != GSS_S_COMPLETE) {
       
    92 -		gss_release_name(&minor, &hintName);
       
    93 +		gss_release_name(&minor, &hintKerberosName);
       
    94  		return (major_status);
       
    95  	}
       
    96  	gss_release_name(&minor, &hintKerberosName);
       
    97 @@ -1380,6 +1387,7 @@
    90  	gss_buffer_desc der_mechTypes;
    98  	gss_buffer_desc der_mechTypes;
    91  	gss_OID mech_wanted;
    99  	gss_OID mech_wanted;
    92  	spnego_gss_ctx_id_t sc = NULL;
   100  	spnego_gss_ctx_id_t sc = NULL;
    93 +	unsigned int i;
   101 +	unsigned int i;
    94  
   102  
    95  	ret = GSS_S_DEFECTIVE_TOKEN;
   103  	ret = GSS_S_DEFECTIVE_TOKEN;
    96  	der_mechTypes.length = 0;
   104  	der_mechTypes.length = 0;
    97 @@ -1348,6 +1411,24 @@ acc_ctx_new(OM_uint32 *minor_status,
   105 @@ -1403,6 +1411,24 @@
    98  		goto cleanup;
   106  		goto cleanup;
    99  	}
   107  	}
   100  	/*
   108  	/*
   101 +	 * We add KRB5_WRONG here so that old MS clients can negotiate this
   109 +	 * We add KRB5_WRONG here so that old MS clients can negotiate this
   102 +	 * mechanism, which allows extensions in Kerberos (clock skew
   110 +	 * mechanism, which allows extensions in Kerberos (clock skew
   117 +        }
   125 +        }
   118 +	/*
   126 +	/*
   119  	 * Select the best match between the list of mechs
   127  	 * Select the best match between the list of mechs
   120  	 * that the initiator requested and the list that
   128  	 * that the initiator requested and the list that
   121  	 * the acceptor will support.
   129  	 * the acceptor will support.
   122 @@ -3072,6 +3163,7 @@ static OM_uint32
   130 @@ -3136,6 +3162,7 @@
       
   131  	int		found = 0;
       
   132  	OM_uint32 major_status = GSS_S_COMPLETE, tmpmin;
   123  	gss_OID_set mechs, goodmechs;
   133  	gss_OID_set mechs, goodmechs;
   124 	gss_OID_set_desc except_attrs;
       
   125 	gss_OID_desc attr_oids[2];
       
   126 +	char *msinterop = getenv("MS_INTEROP");
   134 +	char *msinterop = getenv("MS_INTEROP");
   127  
   135  
   128 	attr_oids[0] = *GSS_C_MA_DEPRECATED;
   136  	major_status = gss_indicate_mechs(minor_status, &mechs);
   129 	attr_oids[1] = *GSS_C_MA_NOT_DFLT_MECH;
   137  
   130 @@ -3108,6 +3177,15 @@ get_available_mechs(OM_uint32 *minor_sta
   138 @@ -3150,6 +3177,15 @@
   131  		return (major_status);
   139  		return (major_status);
   132  	}
   140  	}
   133  
   141  
   134 +	/*
   142 +	/*
   135 +	 * If the required keytab entries for Kerberized SMB service are
   143 +	 * If the required keytab entries for Kerberized SMB service are
   141 +		goto ntlmssp;
   149 +		goto ntlmssp;
   142 +
   150 +
   143  	for (i = 0; i < mechs->count && major_status == GSS_S_COMPLETE; i++) {
   151  	for (i = 0; i < mechs->count && major_status == GSS_S_COMPLETE; i++) {
   144  		if ((mechs->elements[i].length
   152  		if ((mechs->elements[i].length
   145  		    != spnego_mechanism.mech_type.length) ||
   153  		    != spnego_mechanism.mech_type.length) ||
   146 @@ -3123,6 +3201,25 @@ get_available_mechs(OM_uint32 *minor_sta
   154 @@ -3165,6 +3201,25 @@
   147  		}
   155  		}
   148  	}
   156  	}
   149  
   157  
   150 +ntlmssp:
   158 +ntlmssp:
   151 +	/*
   159 +	/*
   167 +	}
   175 +	}
   168 +
   176 +
   169  	/*
   177  	/*
   170  	 * If the caller wanted a list of creds returned,
   178  	 * If the caller wanted a list of creds returned,
   171  	 * trim the list of mechanisms down to only those
   179  	 * trim the list of mechanisms down to only those
   172 @@ -3698,9 +3795,17 @@ negotiate_mech(gss_OID_set supported, gs
   180 @@ -3740,9 +3795,17 @@
   173  	for (i = 0; i < received->count; i++) {
   181  	for (i = 0; i < received->count; i++) {
   174  		gss_OID mech_oid = &received->elements[i];
   182  		gss_OID mech_oid = &received->elements[i];
   175  
   183  
   176 +		/*
   184 +		/*
   177 +		 * MIT compares against MS' wrong OID, but we actually want to
   185 +		 * MIT compares against MS' wrong OID, but we actually want to