xref: /onnv-gate/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c (revision 5331:3047ad28a67b)
1*5331Samw /*
2*5331Samw  * CDDL HEADER START
3*5331Samw  *
4*5331Samw  * The contents of this file are subject to the terms of the
5*5331Samw  * Common Development and Distribution License (the "License").
6*5331Samw  * You may not use this file except in compliance with the License.
7*5331Samw  *
8*5331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5331Samw  * or http://www.opensolaris.org/os/licensing.
10*5331Samw  * See the License for the specific language governing permissions
11*5331Samw  * and limitations under the License.
12*5331Samw  *
13*5331Samw  * When distributing Covered Code, include this CDDL HEADER in each
14*5331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5331Samw  * If applicable, add the following below this CDDL HEADER, with the
16*5331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
17*5331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
18*5331Samw  *
19*5331Samw  * CDDL HEADER END
20*5331Samw  */
21*5331Samw /*
22*5331Samw  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*5331Samw  * Use is subject to license terms.
24*5331Samw  */
25*5331Samw 
26*5331Samw #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*5331Samw 
28*5331Samw /*
29*5331Samw  * NetLogon RPC (NETR) interface definition. This module provides
30*5331Samw  * the server side NETR RPC interface and the interface registration
31*5331Samw  * function.
32*5331Samw  */
33*5331Samw 
34*5331Samw #include <strings.h>
35*5331Samw 
36*5331Samw #include <smbsrv/libsmb.h>
37*5331Samw #include <smbsrv/mlsvc_util.h>
38*5331Samw #include <smbsrv/ndl/netlogon.ndl>
39*5331Samw #include <smbsrv/ntstatus.h>
40*5331Samw #include <smbsrv/nterror.h>
41*5331Samw #include <smbsrv/nmpipes.h>
42*5331Samw #include <smbsrv/netrauth.h>
43*5331Samw 
44*5331Samw static int netr_s_ServerReqChallenge(void *, struct mlrpc_xaction *);
45*5331Samw static int netr_s_ServerAuthenticate2(void *, struct mlrpc_xaction *);
46*5331Samw static int netr_s_ServerPasswordSet(void *, struct mlrpc_xaction *);
47*5331Samw static int netr_s_SamLogon(void *, struct mlrpc_xaction *);
48*5331Samw static int netr_s_SamLogoff(void *, struct mlrpc_xaction *);
49*5331Samw 
50*5331Samw static mlrpc_stub_table_t netr_stub_table[] = {
51*5331Samw 	{ netr_s_ServerReqChallenge,	NETR_OPNUM_ServerReqChallenge },
52*5331Samw 	{ netr_s_ServerAuthenticate2,	NETR_OPNUM_ServerAuthenticate2 },
53*5331Samw 	{ netr_s_ServerPasswordSet,	NETR_OPNUM_ServerPasswordSet },
54*5331Samw 	{ netr_s_SamLogon,		NETR_OPNUM_SamLogon },
55*5331Samw 	{ netr_s_SamLogoff,		NETR_OPNUM_SamLogoff },
56*5331Samw 	{0}
57*5331Samw };
58*5331Samw 
59*5331Samw static mlrpc_service_t netr_service = {
60*5331Samw 	"NETR",				/* name */
61*5331Samw 	"NetLogon",			/* desc */
62*5331Samw 	"\\netlogon",			/* endpoint */
63*5331Samw 	PIPE_LSASS,			/* sec_addr_port */
64*5331Samw 	"12345678-1234-abcd-ef0001234567cffb", 1,	/* abstract */
65*5331Samw 	"8a885d04-1ceb-11c9-9fe808002b104860", 2,	/* transfer */
66*5331Samw 	0,				/* no bind_instance_size */
67*5331Samw 	0,				/* no bind_req() */
68*5331Samw 	0,				/* no unbind_and_close() */
69*5331Samw 	0,				/* use generic_call_stub() */
70*5331Samw 	&TYPEINFO(netr_interface),	/* interface ti */
71*5331Samw 	netr_stub_table			/* stub_table */
72*5331Samw };
73*5331Samw 
74*5331Samw /*
75*5331Samw  * netr_initialize
76*5331Samw  *
77*5331Samw  * This function registers the NETR RPC interface with the RPC runtime
78*5331Samw  * library. It must be called in order to use either the client side
79*5331Samw  * or the server side functions.
80*5331Samw  */
81*5331Samw void
82*5331Samw netr_initialize(void)
83*5331Samw {
84*5331Samw 	(void) mlrpc_register_service(&netr_service);
85*5331Samw }
86*5331Samw 
87*5331Samw /*
88*5331Samw  * netr_s_ServerReqChallenge
89*5331Samw  */
90*5331Samw /*ARGSUSED*/
91*5331Samw static int
92*5331Samw netr_s_ServerReqChallenge(void *arg, struct mlrpc_xaction *mxa)
93*5331Samw {
94*5331Samw 	struct netr_ServerReqChallenge *param = arg;
95*5331Samw 
96*5331Samw 	bzero(param, sizeof (struct netr_ServerReqChallenge));
97*5331Samw 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
98*5331Samw 	return (MLRPC_DRC_OK);
99*5331Samw }
100*5331Samw 
101*5331Samw /*
102*5331Samw  * netr_s_ServerAuthenticate2
103*5331Samw  */
104*5331Samw /*ARGSUSED*/
105*5331Samw static int
106*5331Samw netr_s_ServerAuthenticate2(void *arg, struct mlrpc_xaction *mxa)
107*5331Samw {
108*5331Samw 	struct netr_ServerAuthenticate2 *param = arg;
109*5331Samw 
110*5331Samw 	bzero(param, sizeof (struct netr_ServerAuthenticate2));
111*5331Samw 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
112*5331Samw 	return (MLRPC_DRC_OK);
113*5331Samw }
114*5331Samw 
115*5331Samw /*
116*5331Samw  * netr_s_ServerPasswordSet
117*5331Samw  */
118*5331Samw /*ARGSUSED*/
119*5331Samw static int
120*5331Samw netr_s_ServerPasswordSet(void *arg, struct mlrpc_xaction *mxa)
121*5331Samw {
122*5331Samw 	struct netr_PasswordSet *param = arg;
123*5331Samw 
124*5331Samw 	bzero(param, sizeof (struct netr_PasswordSet));
125*5331Samw 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
126*5331Samw 	return (MLRPC_DRC_OK);
127*5331Samw }
128*5331Samw 
129*5331Samw /*
130*5331Samw  * netr_s_SamLogon
131*5331Samw  */
132*5331Samw /*ARGSUSED*/
133*5331Samw static int
134*5331Samw netr_s_SamLogon(void *arg, struct mlrpc_xaction *mxa)
135*5331Samw {
136*5331Samw 	struct netr_SamLogon *param = arg;
137*5331Samw 
138*5331Samw 	bzero(param, sizeof (struct netr_SamLogon));
139*5331Samw 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
140*5331Samw 	return (MLRPC_DRC_OK);
141*5331Samw }
142*5331Samw 
143*5331Samw /*
144*5331Samw  * netr_s_SamLogoff
145*5331Samw  */
146*5331Samw /*ARGSUSED*/
147*5331Samw static int
148*5331Samw netr_s_SamLogoff(void *arg, struct mlrpc_xaction *mxa)
149*5331Samw {
150*5331Samw 	struct netr_SamLogoff *param = arg;
151*5331Samw 
152*5331Samw 	bzero(param, sizeof (struct netr_SamLogoff));
153*5331Samw 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
154*5331Samw 	return (MLRPC_DRC_OK);
155*5331Samw }
156*5331Samw 
157*5331Samw /*
158*5331Samw  * Declare extern references.
159*5331Samw  */
160*5331Samw DECL_FIXUP_STRUCT(netr_validation_u);
161*5331Samw DECL_FIXUP_STRUCT(netr_validation_info);
162*5331Samw DECL_FIXUP_STRUCT(netr_SamLogon);
163*5331Samw 
164*5331Samw /*
165*5331Samw  * Patch the netr_SamLogon union.
166*5331Samw  * This function is called from mlsvc_netr_ndr.c
167*5331Samw  */
168*5331Samw void
169*5331Samw fixup_netr_SamLogon(struct netr_SamLogon *arg)
170*5331Samw {
171*5331Samw 	unsigned short size1 = 0;
172*5331Samw 	unsigned short size2 = 0;
173*5331Samw 	unsigned short size3 = 0;
174*5331Samw 	WORD level = (WORD)arg->validation_level;
175*5331Samw 
176*5331Samw 	switch (level) {
177*5331Samw 	case 3:
178*5331Samw 		/*
179*5331Samw 		 * The netr_validation_u union contains a pointer, which
180*5331Samw 		 * is a DWORD in NDR. So we need to set size1 to ensure
181*5331Samw 		 * that we can correctly decode the remaining parameters.
182*5331Samw 		 */
183*5331Samw 		size1 = sizeof (DWORD);
184*5331Samw 		break;
185*5331Samw 
186*5331Samw 	default:
187*5331Samw 		/*
188*5331Samw 		 * If the request is badly formed or the level is invalid,
189*5331Samw 		 * the server returns NT_STATUS_INVALID_INFO_CLASS. Size1
190*5331Samw 		 * must be zero to correctly decode the status.
191*5331Samw 		 */
192*5331Samw 		size1 = 0;
193*5331Samw 		break;
194*5331Samw 	};
195*5331Samw 
196*5331Samw 	size2 = size1 + (2 * sizeof (DWORD));
197*5331Samw 	size3 = size2 + sizeof (mlrpcconn_request_hdr_t) + sizeof (DWORD);
198*5331Samw 
199*5331Samw 	FIXUP_PDU_SIZE(netr_validation_u, size1);
200*5331Samw 	FIXUP_PDU_SIZE(netr_validation_info, size2);
201*5331Samw 	FIXUP_PDU_SIZE(netr_SamLogon, size3);
202*5331Samw }
203