gss_ctx_id_t ctx,
gss_buffer_t token)
{
- /* XXX we also need to serialise the current server name */
- return duplicateBuffer(minor, &ctx->acceptorCtx.state, token);
+ OM_uint32 major, tmpMinor;
+ size_t length, serverLen = 0;
+ unsigned char *p;
+ char serverBuf[MAXHOSTNAMELEN];
+
+ if (ctx->acceptorCtx.radConn != NULL &&
+ rs_conn_get_current_server(ctx->acceptorCtx.radConn,
+ serverBuf, sizeof(serverBuf)) == 0)
+ serverLen = strlen(serverBuf);
+
+ length = 4 + serverLen + 4 + ctx->acceptorCtx.state.length;
+
+ token->value = GSSEAP_MALLOC(length);
+ if (token->value == NULL) {
+ *minor = ENOMEM;
+ major = GSS_S_FAILURE;
+ goto cleanup;
+ }
+ token->length = length;
+
+ p = (unsigned char *)token->value;
+
+ store_uint32_be(serverLen, p);
+ p += 4;
+ if (serverLen != 0) {
+ memcpy(p, serverBuf, serverLen);
+ p += serverLen;
+ }
+
+ store_uint32_be(ctx->acceptorCtx.state.length, p);
+ p += 4;
+ if (ctx->acceptorCtx.state.length != 0) {
+ memcpy(p, ctx->acceptorCtx.state.value,
+ ctx->acceptorCtx.state.length);
+ p += ctx->acceptorCtx.state.length;
+ }
+
+ assert(p == (unsigned char *)token->value + token->length);
+
+cleanup:
+ if (GSS_ERROR(major))
+ gss_release_buffer(&tmpMinor, token);
+
+ return major;
}
static OM_uint32
goto cleanup;
}
- length = 16; /* version, state, flags, etc */
+ length = 16; /* version, state, flags, */
length += 4 + ctx->mechanismUsed->length; /* mechanismUsed */
length += 12 + key.length; /* rfc3961Key.value */
length += 4 + initiatorName.length; /* initiatorName.value */
interprocess_token->length = 0;
interprocess_token->value = NULL;
- if (ctx == GSS_C_NO_CONTEXT)
+ if (ctx == GSS_C_NO_CONTEXT) {
+ *minor = EINVAL;
return GSS_S_NO_CONTEXT;
+ }
+
+ *minor = 0;
GSSEAP_MUTEX_LOCK(&ctx->mutex);