2 * Unix SMB/CIFS implementation.
4 * Copyright (C) 2023 Stefan Metzmacher
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "rpc_worker.h"
22 #include "librpc/gen_ndr/ndr_witness.h"
23 #include "librpc/gen_ndr/ndr_witness_scompat.h"
25 static size_t witness_interfaces(
26 const struct ndr_interface_table
***pifaces
,
29 static const struct ndr_interface_table
*ifaces
[] = {
33 if (!lp_clustering()) {
35 * Without clustering there's no need for witness.
42 return ARRAY_SIZE(ifaces
);
45 static NTSTATUS
witness_servers(
46 struct dcesrv_context
*dce_ctx
,
47 const struct dcesrv_endpoint_server
***_ep_servers
,
48 size_t *_num_ep_servers
,
51 static const struct dcesrv_endpoint_server
*ep_servers
[1] = { NULL
};
52 char *principal
= NULL
;
55 if (!lp_clustering()) {
57 * Without clustering there's no need for witness.
64 principal
= talloc_asprintf(talloc_tos(),
67 if (principal
== NULL
) {
68 return NT_STATUS_NO_MEMORY
;
71 status
= dcesrv_auth_type_principal_register(dce_ctx
,
72 DCERPC_AUTH_TYPE_NTLMSSP
,
74 if (!NT_STATUS_IS_OK(status
)) {
77 status
= dcesrv_auth_type_principal_register(dce_ctx
,
78 DCERPC_AUTH_TYPE_SPNEGO
,
80 if (!NT_STATUS_IS_OK(status
)) {
83 if (lp_security() == SEC_ADS
) {
84 status
= dcesrv_auth_type_principal_register(dce_ctx
,
85 DCERPC_AUTH_TYPE_KRB5
,
87 if (!NT_STATUS_IS_OK(status
)) {
92 TALLOC_FREE(principal
);
95 * We prefer NDR64 for witness,
96 * as it's a very simple protocol and
97 * we support it from the beginning,
98 * which means it's well tested.
100 dce_ctx
->preferred_transfer
= &ndr_transfer_syntax_ndr64
;
102 ep_servers
[0] = witness_get_ep_server();
104 *_ep_servers
= ep_servers
;
105 *_num_ep_servers
= ARRAY_SIZE(ep_servers
);
109 int main(int argc
, const char *argv
[])
111 return rpc_worker_main(