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