s3: Fix a bad memleak in winbind
[Samba.git] / source4 / auth / ntlm / auth_anonymous.c
blobc8890718784c4b5d3e645268edb79f8f38e7d79a
1 /*
2 Unix SMB/CIFS implementation.
4 Anonymous Authentification
6 Copyright (C) Stefan Metzmacher 2004-2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "auth/auth.h"
24 #include "auth/ntlm/auth_proto.h"
25 #include "param/param.h"
27 /**
28 * Return a anonymous logon for anonymous users (username = "")
30 * Typically used as the first module in the auth chain, this allows
31 * anonymou logons to be dealt with in one place. Non-anonymou logons 'fail'
32 * and pass onto the next module.
33 **/
34 static NTSTATUS anonymous_want_check(struct auth_method_context *ctx,
35 TALLOC_CTX *mem_ctx,
36 const struct auth_usersupplied_info *user_info)
38 if (user_info->client.account_name && *user_info->client.account_name) {
39 return NT_STATUS_NOT_IMPLEMENTED;
42 return NT_STATUS_OK;
45 /**
46 * Return a anonymous logon for anonymous users (username = "")
48 * Typically used as the first module in the auth chain, this allows
49 * anonymou logons to be dealt with in one place. Non-anonymou logons 'fail'
50 * and pass onto the next module.
51 **/
52 static NTSTATUS anonymous_check_password(struct auth_method_context *ctx,
53 TALLOC_CTX *mem_ctx,
54 const struct auth_usersupplied_info *user_info,
55 struct auth_serversupplied_info **_server_info)
57 return auth_anonymous_server_info(mem_ctx, lp_netbios_name(ctx->auth_ctx->lp_ctx), _server_info);
60 static const struct auth_operations anonymous_auth_ops = {
61 .name = "anonymous",
62 .get_challenge = auth_get_challenge_not_implemented,
63 .want_check = anonymous_want_check,
64 .check_password = anonymous_check_password
67 _PUBLIC_ NTSTATUS auth_anonymous_init(void)
69 NTSTATUS ret;
71 ret = auth_register(&anonymous_auth_ops);
72 if (!NT_STATUS_IS_OK(ret)) {
73 DEBUG(0,("Failed to register 'anonymous' auth backend!\n"));
74 return ret;
77 return ret;