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