Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / samba / source / rpc_server / srv_reg.c
blobf2083fa22f52923387e93452f69065e3748a6fe4
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Hewlett-Packard Company 1999.
9 *
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.
26 #include "includes.h"
27 #include "nterr.h"
29 extern int DEBUGLEVEL;
32 /*******************************************************************
33 reg_reply_unknown_1
34 ********************************************************************/
35 static void reg_reply_close(REG_Q_CLOSE *q_r,
36 prs_struct *rdata)
38 REG_R_CLOSE r_u;
40 /* set up the REG unknown_1 response */
41 memset((char *)r_u.pol.data, '\0', POL_HND_SIZE);
43 /* close the policy handle */
44 if (close_lsa_policy_hnd(&(q_r->pol)))
46 r_u.status = 0;
48 else
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 /*******************************************************************
62 api_reg_close
63 ********************************************************************/
64 static BOOL api_reg_close( uint16 vuid, prs_struct *data,
65 prs_struct *rdata )
67 REG_Q_CLOSE q_r;
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);
75 return True;
79 /*******************************************************************
80 reg_reply_open
81 ********************************************************************/
82 static void reg_reply_open(REG_Q_OPEN_HKLM *q_r,
83 prs_struct *rdata)
85 REG_R_OPEN_HKLM r_u;
87 r_u.status = 0x0;
88 /* get a (unique) handle. open a policy on it. */
89 if (r_u.status == 0x0 && !open_lsa_policy_hnd(&(r_u.pol)))
91 r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND;
94 DEBUG(5,("reg_open: %d\n", __LINE__));
96 /* store the response in the SMB stream */
97 reg_io_r_open_hklm("", &r_u, rdata, 0);
99 DEBUG(5,("reg_open: %d\n", __LINE__));
102 /*******************************************************************
103 api_reg_open
104 ********************************************************************/
105 static BOOL api_reg_open( uint16 vuid, prs_struct *data,
106 prs_struct *rdata )
108 REG_Q_OPEN_HKLM q_u;
110 /* grab the reg open */
111 reg_io_q_open_hklm("", &q_u, data, 0);
113 /* construct reply. always indicate success */
114 reg_reply_open(&q_u, rdata);
116 return True;
120 /*******************************************************************
121 reg_reply_open_entry
122 ********************************************************************/
123 static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u,
124 prs_struct *rdata)
126 uint32 status = 0;
127 POLICY_HND pol;
128 REG_R_OPEN_ENTRY r_u;
129 fstring name;
131 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
133 if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1)
135 status = 0xC000000 | NT_STATUS_INVALID_HANDLE;
138 if (status == 0x0 && !open_lsa_policy_hnd(&pol))
140 status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
143 fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len));
145 if (status == 0x0)
147 DEBUG(5,("reg_open_entry: %s\n", name));
148 /* lkcl XXXX do a check on the name, here */
149 if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions"))
151 status = 0xC000000 | NT_STATUS_ACCESS_DENIED;
155 if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name))
157 status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
160 init_reg_r_open_entry(&r_u, &pol, status);
162 /* store the response in the SMB stream */
163 reg_io_r_open_entry("", &r_u, rdata, 0);
165 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
168 /*******************************************************************
169 api_reg_open_entry
170 ********************************************************************/
171 static BOOL api_reg_open_entry( uint16 vuid, prs_struct *data,
172 prs_struct *rdata )
174 REG_Q_OPEN_ENTRY q_u;
176 /* grab the reg open entry */
177 reg_io_q_open_entry("", &q_u, data, 0);
179 /* construct reply. */
180 reg_reply_open_entry(&q_u, rdata);
182 return True;
186 /*******************************************************************
187 reg_reply_info
188 ********************************************************************/
189 static void reg_reply_info(REG_Q_INFO *q_u,
190 prs_struct *rdata)
192 uint32 status = 0;
194 REG_R_INFO r_u;
196 DEBUG(5,("reg_info: %d\n", __LINE__));
198 if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1)
200 status = 0xC000000 | NT_STATUS_INVALID_HANDLE;
203 if (status == 0)
207 /* This makes the server look like a member server to clients */
208 /* which tells clients that we have our own local user and */
209 /* group databases and helps with ACL support. */
210 init_reg_r_info(&r_u, 1, "ServerNT", 0x12, 0x12, status);
212 /* store the response in the SMB stream */
213 reg_io_r_info("", &r_u, rdata, 0);
215 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
218 /*******************************************************************
219 api_reg_info
220 ********************************************************************/
221 static BOOL api_reg_info( uint16 vuid, prs_struct *data,
222 prs_struct *rdata )
224 REG_Q_INFO q_u;
226 /* grab the reg unknown 0x11*/
227 reg_io_q_info("", &q_u, data, 0);
229 /* construct reply. always indicate success */
230 reg_reply_info(&q_u, rdata);
232 return True;
236 /*******************************************************************
237 array of \PIPE\reg operations
238 ********************************************************************/
239 static struct api_struct api_reg_cmds[] =
241 { "REG_CLOSE" , REG_CLOSE , api_reg_close },
242 { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry },
243 { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open },
244 { "REG_INFO" , REG_INFO , api_reg_info },
245 { NULL, 0 , NULL }
248 /*******************************************************************
249 receives a reg pipe and responds.
250 ********************************************************************/
251 BOOL api_reg_rpc(pipes_struct *p, prs_struct *data)
253 return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data);