xref: /titanic_51/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c (revision 63c17d01856124d99676ad972bf973d4a005a877)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * NetLogon RPC (NETR) interface definition. This module provides
28  * the server side NETR RPC interface and the interface registration
29  * function.
30  */
31 
32 #include <strings.h>
33 
34 #include <smbsrv/libsmb.h>
35 #include <smbsrv/libmlsvc.h>
36 #include <smbsrv/ndl/netlogon.ndl>
37 #include <smbsrv/ntstatus.h>
38 #include <smbsrv/nterror.h>
39 #include <smbsrv/nmpipes.h>
40 #include <smbsrv/netrauth.h>
41 
42 static int netr_s_ServerReqChallenge(void *, ndr_xa_t *);
43 static int netr_s_ServerAuthenticate2(void *, ndr_xa_t *);
44 static int netr_s_ServerPasswordSet(void *, ndr_xa_t *);
45 static int netr_s_SamLogon(void *, ndr_xa_t *);
46 static int netr_s_SamLogoff(void *, ndr_xa_t *);
47 
48 static ndr_stub_table_t netr_stub_table[] = {
49 	{ netr_s_ServerReqChallenge,	NETR_OPNUM_ServerReqChallenge },
50 	{ netr_s_ServerAuthenticate2,	NETR_OPNUM_ServerAuthenticate2 },
51 	{ netr_s_ServerPasswordSet,	NETR_OPNUM_ServerPasswordSet },
52 	{ netr_s_SamLogon,		NETR_OPNUM_SamLogon },
53 	{ netr_s_SamLogoff,		NETR_OPNUM_SamLogoff },
54 	{0}
55 };
56 
57 static ndr_service_t netr_service = {
58 	"NETR",				/* name */
59 	"NetLogon",			/* desc */
60 	"\\netlogon",			/* endpoint */
61 	PIPE_LSASS,			/* sec_addr_port */
62 	"12345678-1234-abcd-ef00-01234567cffb", 1,	/* abstract */
63 	NDR_TRANSFER_SYNTAX_UUID,		2,	/* transfer */
64 	0,				/* no bind_instance_size */
65 	0,				/* no bind_req() */
66 	0,				/* no unbind_and_close() */
67 	0,				/* use generic_call_stub() */
68 	&TYPEINFO(netr_interface),	/* interface ti */
69 	netr_stub_table			/* stub_table */
70 };
71 
72 /*
73  * netr_initialize
74  *
75  * This function registers the NETR RPC interface with the RPC runtime
76  * library. It must be called in order to use either the client side
77  * or the server side functions.
78  */
79 void
80 netr_initialize(void)
81 {
82 	(void) ndr_svc_register(&netr_service);
83 }
84 
85 /*
86  * netr_s_ServerReqChallenge
87  */
88 /*ARGSUSED*/
89 static int
90 netr_s_ServerReqChallenge(void *arg, ndr_xa_t *mxa)
91 {
92 	struct netr_ServerReqChallenge *param = arg;
93 
94 	bzero(param, sizeof (struct netr_ServerReqChallenge));
95 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
96 	return (NDR_DRC_OK);
97 }
98 
99 /*
100  * netr_s_ServerAuthenticate2
101  */
102 /*ARGSUSED*/
103 static int
104 netr_s_ServerAuthenticate2(void *arg, ndr_xa_t *mxa)
105 {
106 	struct netr_ServerAuthenticate2 *param = arg;
107 
108 	bzero(param, sizeof (struct netr_ServerAuthenticate2));
109 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
110 	return (NDR_DRC_OK);
111 }
112 
113 /*
114  * netr_s_ServerPasswordSet
115  */
116 /*ARGSUSED*/
117 static int
118 netr_s_ServerPasswordSet(void *arg, ndr_xa_t *mxa)
119 {
120 	struct netr_PasswordSet *param = arg;
121 
122 	bzero(param, sizeof (struct netr_PasswordSet));
123 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
124 	return (NDR_DRC_OK);
125 }
126 
127 /*
128  * netr_s_SamLogon
129  */
130 /*ARGSUSED*/
131 static int
132 netr_s_SamLogon(void *arg, ndr_xa_t *mxa)
133 {
134 	struct netr_SamLogon *param = arg;
135 
136 	bzero(param, sizeof (struct netr_SamLogon));
137 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
138 	return (NDR_DRC_OK);
139 }
140 
141 /*
142  * netr_s_SamLogoff
143  */
144 /*ARGSUSED*/
145 static int
146 netr_s_SamLogoff(void *arg, ndr_xa_t *mxa)
147 {
148 	struct netr_SamLogoff *param = arg;
149 
150 	bzero(param, sizeof (struct netr_SamLogoff));
151 	param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
152 	return (NDR_DRC_OK);
153 }
154 
155 /*
156  * Declare extern references.
157  */
158 DECL_FIXUP_STRUCT(netr_validation_u);
159 DECL_FIXUP_STRUCT(netr_validation_info);
160 DECL_FIXUP_STRUCT(netr_SamLogon);
161 
162 /*
163  * Patch the netr_SamLogon union.
164  * This function is called from mlsvc_netr_ndr.c
165  */
166 void
167 fixup_netr_SamLogon(struct netr_SamLogon *arg)
168 {
169 	unsigned short size1 = 0;
170 	unsigned short size2 = 0;
171 	unsigned short size3 = 0;
172 	WORD level = (WORD)arg->validation_level;
173 
174 	switch (level) {
175 	case 3:
176 		/*
177 		 * The netr_validation_u union contains a pointer, which
178 		 * is a DWORD in NDR. So we need to set size1 to ensure
179 		 * that we can correctly decode the remaining parameters.
180 		 */
181 		size1 = sizeof (DWORD);
182 		break;
183 
184 	default:
185 		/*
186 		 * If the request is badly formed or the level is invalid,
187 		 * the server returns NT_STATUS_INVALID_INFO_CLASS. Size1
188 		 * must be zero to correctly decode the status.
189 		 */
190 		size1 = 0;
191 		break;
192 	};
193 
194 	size2 = size1 + (2 * sizeof (DWORD));
195 	size3 = size2 + sizeof (ndr_request_hdr_t) + sizeof (DWORD);
196 
197 	FIXUP_PDU_SIZE(netr_validation_u, size1);
198 	FIXUP_PDU_SIZE(netr_validation_info, size2);
199 	FIXUP_PDU_SIZE(netr_SamLogon, size3);
200 }
201