1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Change how we handle the Ssh_gss_buf type. Previously, we defined it

ourselves, but on Unix then assumed it was compatible with the system's
gss_buffer_desc, which wasn't the case on LP64 systems.  Now, on Unix
we make Ssh_gss_buf into an alias for gss_buffer_desc, though we keep
something similar to the existing behaviour on Windows.  This requires
renaming a couple of the fields in Ssh_gss_buf, and hence fixing all
the references.

Tested on Linux (MIT Kerberos) and Solaris.  Compiled on NetBSD (Heimdal).
Not tested on Windows because neither mingw32 nor winegcc worked out of the
box for me.  I think the Windows changes are all syntactic, though, so
if this compiles it should work no worse than before.

[originally from svn r8326]
This commit is contained in:
Ben Harris
2008-11-24 23:44:55 +00:00
parent a6cbfd974d
commit 81dafd906e
6 changed files with 75 additions and 55 deletions

View File

@ -60,6 +60,15 @@ extern long tickcount_offset;
#define WCHAR wchar_t
#define BYTE unsigned char
#ifndef NO_GSSAPI
/*
* GSS-API stuff
*/
#include <gssapi/gssapi.h>
typedef gss_buffer_desc Ssh_gss_buf;
#define SSH_GSS_EMPTY_BUF GSS_C_EMPTY_BUFFER
#endif
/*
* Unix-specific global flag
*

View File

@ -6,9 +6,9 @@
#ifndef NO_GSSAPI
static gss_OID_desc gss_mech_krb5_desc =
static gss_OID_desc putty_gss_mech_krb5_desc =
{ 9, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
static gss_OID const gss_mech_krb5 = &gss_mech_krb5_desc;
static gss_OID const putty_gss_mech_krb5 = &putty_gss_mech_krb5_desc;
typedef struct uxSsh_gss_ctx {
OM_uint32 maj_stat;
@ -27,8 +27,8 @@ int ssh_gss_init(void)
Ssh_gss_stat ssh_gss_indicate_mech(Ssh_gss_buf *mech)
{
/* Copy constant into mech */
mech->len = gss_mech_krb5->length;
mech->data = gss_mech_krb5->elements;
mech->length = putty_gss_mech_krb5->length;
mech->value = putty_gss_mech_krb5->elements;
return SSH_GSS_OK;
}
@ -79,11 +79,11 @@ Ssh_gss_stat ssh_gss_init_sec_context(Ssh_gss_ctx *ctx,
GSS_C_NO_CREDENTIAL,
&uxctx->ctx,
(gss_name_t) srv_name,
(gss_OID) gss_mech_krb5,
(gss_OID) putty_gss_mech_krb5,
GSS_C_MUTUAL_FLAG |
GSS_C_INTEG_FLAG | to_deleg,
0,
NULL, /* no channel bindings */
GSS_C_NO_CHANNEL_BINDINGS,
(gss_buffer_desc *)recv_tok,
NULL, /* ignore mech type */
(gss_buffer_desc *)send_tok,
@ -108,13 +108,13 @@ Ssh_gss_stat ssh_gss_display_status(Ssh_gss_ctx ctx, Ssh_gss_buf *buf)
/* get first mesg from GSS */
ccc=0;
lmax=gss_display_status(&lmin,uxctx->maj_stat,GSS_C_GSS_CODE,(gss_OID) gss_mech_krb5,&ccc,&msg_maj);
lmax=gss_display_status(&lmin,uxctx->maj_stat,GSS_C_GSS_CODE,(gss_OID) putty_gss_mech_krb5,&ccc,&msg_maj);
if (lmax != GSS_S_COMPLETE) return SSH_GSS_FAILURE;
/* get first mesg from Kerberos */
ccc=0;
lmax=gss_display_status(&lmin,uxctx->min_stat,GSS_C_MECH_CODE,(gss_OID) gss_mech_krb5,&ccc,&msg_min);
lmax=gss_display_status(&lmin,uxctx->min_stat,GSS_C_MECH_CODE,(gss_OID) putty_gss_mech_krb5,&ccc,&msg_min);
if (lmax != GSS_S_COMPLETE) {
gss_release_buffer(&lmin, &msg_maj);
@ -122,14 +122,14 @@ Ssh_gss_stat ssh_gss_display_status(Ssh_gss_ctx ctx, Ssh_gss_buf *buf)
}
/* copy data into buffer */
buf->len = msg_maj.length + msg_min.length + 1;
buf->data = snewn(buf->len + 1, char);
buf->length = msg_maj.length + msg_min.length + 1;
buf->value = snewn(buf->length + 1, char);
/* copy mem */
memcpy(buf->data, msg_maj.value, msg_maj.length);
buf->data[msg_maj.length] = ' ';
memcpy(buf->data + msg_maj.length + 1, msg_min.value, msg_min.length);
buf->data[buf->len] = 0;
memcpy((char *)buf->value, msg_maj.value, msg_maj.length);
((char *)buf->value)[msg_maj.length] = ' ';
memcpy((char *)buf->value + msg_maj.length + 1, msg_min.value, msg_min.length);
((char *)buf->value)[buf->length] = 0;
/* free mem & exit */
gss_release_buffer(&lmin, &msg_maj);
gss_release_buffer(&lmin, &msg_min);