Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
fa437e14
Commit
fa437e14
authored
10 years ago
by
Steve Holme
Browse files
Options
Downloads
Patches
Plain Diff
sasl_gssapi: Added body to Curl_sasl_create_gssapi_user_message()
parent
61e71a8b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/curl_sasl_gssapi.c
+87
-7
87 additions, 7 deletions
lib/curl_sasl_gssapi.c
with
87 additions
and
7 deletions
lib/curl_sasl_gssapi.c
+
87
−
7
View file @
fa437e14
...
...
@@ -26,10 +26,18 @@
#if defined(HAVE_GSSAPI) && defined(USE_KERBEROS5)
#ifdef HAVE_OLD_GSSMIT
#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#define NCOMPAT 1
#endif
#include
<curl/curl.h>
#include
"curl_sasl.h"
#include
"urldata.h"
#include
"curl_base64.h"
#include
"curl_gssapi.h"
#include
"curl_memory.h"
#define _MPRINTF_REPLACE
/* use our functions only */
#include
<curl/mprintf.h>
...
...
@@ -87,17 +95,89 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data,
struct
kerberos5data
*
krb5
,
char
**
outptr
,
size_t
*
outlen
)
{
(
void
)
data
;
CURLcode
result
=
CURLE_OK
;
size_t
chlglen
=
0
;
unsigned
char
*
chlg
=
NULL
;
OM_uint32
gss_status
;
OM_uint32
gss_major_status
;
OM_uint32
gss_minor_status
;
gss_buffer_desc
spn_token
=
GSS_C_EMPTY_BUFFER
;
gss_buffer_desc
input_token
=
GSS_C_EMPTY_BUFFER
;
gss_buffer_desc
output_token
=
GSS_C_EMPTY_BUFFER
;
(
void
)
userp
;
(
void
)
passwdp
;
(
void
)
service
;
(
void
)
mutual_auth
;
(
void
)
chlg64
;
(
void
)
krb5
;
(
void
)
outptr
;
(
void
)
outlen
;
return
CURLE_NOT_BUILT_IN
;
if
(
krb5
->
context
==
GSS_C_NO_CONTEXT
)
{
/* Generate our SPN */
char
*
spn
=
Curl_sasl_build_gssapi_spn
(
service
,
data
->
easy_conn
->
host
.
name
);
if
(
!
spn
)
return
CURLE_OUT_OF_MEMORY
;
/* Populate the SPN structure */
spn_token
.
value
=
spn
;
spn_token
.
length
=
strlen
(
spn
);
/* Import the SPN */
gss_major_status
=
gss_import_name
(
&
gss_minor_status
,
&
spn_token
,
gss_nt_service_name
,
&
krb5
->
spn
);
if
(
GSS_ERROR
(
gss_major_status
))
{
Curl_gss_log_error
(
data
,
gss_minor_status
,
"gss_import_name() failed: "
);
return
CURLE_OUT_OF_MEMORY
;
}
}
else
{
/* Decode the base-64 encoded challenge message */
if
(
strlen
(
chlg64
)
&&
*
chlg64
!=
'='
)
{
result
=
Curl_base64_decode
(
chlg64
,
&
chlg
,
&
chlglen
);
if
(
result
)
return
result
;
}
/* Ensure we have a valid challenge message */
if
(
!
chlg
)
return
CURLE_BAD_CONTENT_ENCODING
;
/* Setup the challenge "input" security buffer */
input_token
.
value
=
chlg
;
input_token
.
length
=
chlglen
;
}
gss_major_status
=
Curl_gss_init_sec_context
(
data
,
&
gss_minor_status
,
&
krb5
->
context
,
krb5
->
spn
,
&
Curl_krb5_mech_oid
,
GSS_C_NO_CHANNEL_BINDINGS
,
&
input_token
,
&
output_token
,
NULL
);
Curl_safefree
(
input_token
.
value
);
if
(
GSS_ERROR
(
gss_major_status
))
{
if
(
output_token
.
value
)
gss_release_buffer
(
&
gss_status
,
&
output_token
);
Curl_gss_log_error
(
data
,
gss_minor_status
,
"gss_init_sec_context() failed: "
);
return
CURLE_RECV_ERROR
;
}
if
(
output_token
.
value
&&
output_token
.
length
)
{
/* Base64 encode the response */
result
=
Curl_base64_encode
(
data
,
(
char
*
)
output_token
.
value
,
output_token
.
length
,
outptr
,
outlen
);
gss_release_buffer
(
&
gss_status
,
&
output_token
);
}
return
result
;
}
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment