3 * Unix SMB/Netbios implementation.
5 * RPC Pipe client / server routines
6 * Copyright (C) Andrew Tridgell 1992-1997,
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
8 * Copyright (C) Paul Ashton 1997.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 extern int DEBUGLEVEL;
32 /*******************************************************************
34 ********************************************************************/
35 static void reg_reply_close(REG_Q_CLOSE *q_r,
40 /* set up the REG unknown_1 response */
41 bzero(r_u.pol.data, POL_HND_SIZE);
43 /* close the policy handle */
44 if (close_lsa_policy_hnd(&(q_r->pol)))
50 r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID;
53 DEBUG(5,("reg_unknown_1: %d\n", __LINE__));
55 /* store the response in the SMB stream */
56 reg_io_r_close("", &r_u, rdata, 0);
58 DEBUG(5,("reg_unknown_1: %d\n", __LINE__));
61 /*******************************************************************
63 ********************************************************************/
64 static void api_reg_close( uint16 vuid, prs_struct *data,
69 /* grab the reg unknown 1 */
70 reg_io_q_close("", &q_r, data, 0);
72 /* construct reply. always indicate success */
73 reg_reply_close(&q_r, rdata);
77 /*******************************************************************
79 ********************************************************************/
80 static void reg_reply_open(REG_Q_OPEN_POLICY *q_r,
83 REG_R_OPEN_POLICY r_u;
86 /* get a (unique) handle. open a policy on it. */
87 if (r_u.status == 0x0 && !open_lsa_policy_hnd(&(r_u.pol)))
89 r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND;
92 DEBUG(5,("reg_open: %d\n", __LINE__));
94 /* store the response in the SMB stream */
95 reg_io_r_open_policy("", &r_u, rdata, 0);
97 DEBUG(5,("reg_open: %d\n", __LINE__));
100 /*******************************************************************
102 ********************************************************************/
103 static void api_reg_open( uint16 vuid, prs_struct *data,
106 REG_Q_OPEN_POLICY q_u;
108 /* grab the reg open */
109 reg_io_q_open_policy("", &q_u, data, 0);
111 /* construct reply. always indicate success */
112 reg_reply_open(&q_u, rdata);
116 /*******************************************************************
118 ********************************************************************/
119 static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u,
124 REG_R_OPEN_ENTRY r_u;
127 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
129 if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1)
131 status = 0xC000000 | NT_STATUS_INVALID_HANDLE;
134 if (status == 0x0 && !open_lsa_policy_hnd(&pol))
136 status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
139 fstrcpy(name, unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len));
143 DEBUG(5,("reg_open_entry: %s\n", name));
144 /* lkcl XXXX do a check on the name, here */
147 if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name))
149 status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
152 make_reg_r_open_entry(&r_u, &pol, status);
154 /* store the response in the SMB stream */
155 reg_io_r_open_entry("", &r_u, rdata, 0);
157 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
160 /*******************************************************************
162 ********************************************************************/
163 static void api_reg_open_entry( uint16 vuid, prs_struct *data,
166 REG_Q_OPEN_ENTRY q_u;
168 /* grab the reg open entry */
169 reg_io_q_open_entry("", &q_u, data, 0);
171 /* construct reply. */
172 reg_reply_open_entry(&q_u, rdata);
176 /*******************************************************************
178 ********************************************************************/
179 static void reg_reply_info(REG_Q_INFO *q_u,
186 DEBUG(5,("reg_info: %d\n", __LINE__));
188 if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1)
190 status = 0xC000000 | NT_STATUS_INVALID_HANDLE;
197 make_reg_r_info(&r_u, 1, "LanmanNT", 0x12, 0x12, status);
199 /* store the response in the SMB stream */
200 reg_io_r_info("", &r_u, rdata, 0);
202 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
205 /*******************************************************************
207 ********************************************************************/
208 static void api_reg_info( uint16 vuid, prs_struct *data,
213 /* grab the reg unknown 0x11*/
214 reg_io_q_info("", &q_u, data, 0);
216 /* construct reply. always indicate success */
217 reg_reply_info(&q_u, rdata);
221 /*******************************************************************
222 array of \PIPE\reg operations
223 ********************************************************************/
224 static struct api_struct api_reg_cmds[] =
226 { "REG_CLOSE" , REG_CLOSE , api_reg_close },
227 { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry },
228 { "REG_OPEN" , REG_OPEN_POLICY , api_reg_open },
229 { "REG_INFO" , REG_INFO , api_reg_info },
233 /*******************************************************************
234 receives a reg pipe and responds.
235 ********************************************************************/
236 BOOL api_reg_rpc(pipes_struct *p, prs_struct *data)
238 return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data);