ctdb-protocol: Fix marshaling of seqnum
[obnox/samba/samba-obnox.git] / auth / gensec / external.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    SASL/EXTERNAL authentication.
5
6    Copyright (C) Howard Chu <hyc@symas.com> 2013
7
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.
12
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.
17
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/>.
20 */
21
22 #include "includes.h"
23 #include "auth/credentials/credentials.h"
24 #include "auth/gensec/gensec.h"
25 #include "auth/gensec/gensec_internal.h"
26 #include "auth/gensec/gensec_proto.h"
27 #include "auth/gensec/gensec_toplevel_proto.h"
28
29 /* SASL/EXTERNAL is essentially a no-op; it is only usable when the transport
30  * layer is already mutually authenticated.
31  */
32
33 NTSTATUS gensec_external_init(void);
34
35 static NTSTATUS gensec_external_start(struct gensec_security *gensec_security)
36 {
37         if (gensec_security->want_features & GENSEC_FEATURE_SIGN)
38                 return NT_STATUS_INVALID_PARAMETER;
39         if (gensec_security->want_features & GENSEC_FEATURE_SEAL)
40                 return NT_STATUS_INVALID_PARAMETER;
41
42         return NT_STATUS_OK;
43 }
44
45 static NTSTATUS gensec_external_update(struct gensec_security *gensec_security,
46                                    TALLOC_CTX *out_mem_ctx,
47                                    struct tevent_context *ev,
48                                    const DATA_BLOB in, DATA_BLOB *out)
49 {
50         *out = data_blob_talloc(out_mem_ctx, "", 0);
51         return NT_STATUS_OK;
52 }
53
54 /* We have no features */
55 static bool gensec_external_have_feature(struct gensec_security *gensec_security,
56                                      uint32_t feature)
57 {
58         return false;
59 }
60
61 static const struct gensec_security_ops gensec_external_ops = {
62         .name             = "sasl-EXTERNAL",
63         .sasl_name        = "EXTERNAL",
64         .client_start     = gensec_external_start,
65         .update           = gensec_external_update,
66         .have_feature     = gensec_external_have_feature,
67         .enabled          = true,
68         .priority         = GENSEC_EXTERNAL
69 };
70
71
72 NTSTATUS gensec_external_init(void)
73 {
74         NTSTATUS ret;
75
76         ret = gensec_register(&gensec_external_ops);
77         if (!NT_STATUS_IS_OK(ret)) {
78                 DEBUG(0,("Failed to register '%s' gensec backend!\n",
79                          gensec_external_ops.name));
80         }
81         return ret;
82 }