Skip to content

Commit e1a5f27

Browse files
committed
Add server side anonymous authentication
Signed-off-by: Simo Sorce <[email protected]>
1 parent e037e78 commit e1a5f27

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/gss_names.c

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ uint32_t gssntlm_import_name_by_mech(uint32_t *minor_status,
157157
/* TODO: check mech_type == gssntlm_oid */
158158
if (mech_type == GSS_C_NO_OID) {
159159
return GSSERRS(ERR_NOARG, GSS_S_CALL_INACCESSIBLE_READ);
160+
} else if (!gss_oid_equal(mech_type, &gssntlm_oid)) {
161+
return GSSERRS(ERR_BADARG, GSS_S_BAD_MECH);
160162
}
161163

162164
name = calloc(1, sizeof(struct gssntlm_name));

src/gss_ntlmssp.c

+13
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,16 @@ int gssntlm_get_lm_compatibility_level(void)
193193
/* use 3 by default for better compatibility */
194194
return 3;
195195
}
196+
197+
bool gssntlm_is_anonymous_allowed(void)
198+
{
199+
const char *envvar;
200+
201+
envvar = getenv("NTLM_ALLOW_ANONYMOUS");
202+
if (envvar != NULL) {
203+
return (atoi(envvar) > 0);
204+
}
205+
206+
/* Not allowed by default */
207+
return false;
208+
}

src/gss_ntlmssp.h

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ uint32_t gssntlm_context_is_valid(struct gssntlm_ctx *ctx,
178178
time_t *time_now);
179179

180180
int gssntlm_get_lm_compatibility_level(void);
181+
bool gssntlm_is_anonymous_allowed(void);
181182

182183
void gssntlm_int_release_name(struct gssntlm_name *name);
183184
void gssntlm_int_release_cred(struct gssntlm_cred *cred);

src/gss_sec_ctx.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ uint32_t gssntlm_accept_sec_context(uint32_t *minor_status,
651651
}
652652

653653
ctx->neg_flags = NTLMSSP_DEFAULT_SERVER_FLAGS;
654-
/* Fixme: How do we allow anonymous negotition ? */
655654

656655
if (gssntlm_sec_lm_ok(ctx)) {
657656
ctx->neg_flags |= NTLMSSP_REQUEST_NON_NT_SESSION_KEY;
@@ -847,9 +846,17 @@ uint32_t gssntlm_accept_sec_context(uint32_t *minor_status,
847846
(((lm_chal_resp.length == 1) && (lm_chal_resp.data[0] == '\0')) ||
848847
(lm_chal_resp.length == 0))) {
849848
/* Anonymous auth */
850-
/* FIXME: not supported for now */
851-
set_GSSERR(ERR_NOTSUPPORTED);
852-
goto done;
849+
if (!gssntlm_is_anonymous_allowed()) {
850+
set_GSSERRS(ERR_NOUSRCRED, GSS_S_DEFECTIVE_CREDENTIAL);
851+
goto done;
852+
}
853+
854+
retmaj = gssntlm_import_name(&retmin, NULL, GSS_C_NT_ANONYMOUS,
855+
(gss_name_t *)&ctx->source_name);
856+
if (retmaj) goto done;
857+
858+
/* nullSession */
859+
memset(key_exchange_key.data, 0, 16);
853860

854861
} else {
855862

0 commit comments

Comments
 (0)