fixed error check which caused domain logons to fail
[Samba.git] / source / rpc_server / srv_reg.c
blobd9fa93206ac2e979303ca33069c1b662d7139bc3
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) Marc Jacobsen 2000.
9 * Copyright (C) Jeremy Allison 2001.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* This is the interface for the registry functions. */
28 #include "includes.h"
30 /*******************************************************************
31 api_reg_close
32 ********************************************************************/
34 static BOOL api_reg_close(pipes_struct *p)
36 REG_Q_CLOSE q_u;
37 REG_R_CLOSE r_u;
38 prs_struct *data = &p->in_data.data;
39 prs_struct *rdata = &p->out_data.rdata;
41 ZERO_STRUCT(q_u);
42 ZERO_STRUCT(r_u);
44 /* grab the reg unknown 1 */
45 if(!reg_io_q_close("", &q_u, data, 0))
46 return False;
48 r_u.status = _reg_close(p, &q_u, &r_u);
50 if(!reg_io_r_close("", &r_u, rdata, 0))
51 return False;
53 return True;
56 /*******************************************************************
57 api_reg_open
58 ********************************************************************/
60 static BOOL api_reg_open(pipes_struct *p)
62 REG_Q_OPEN_HKLM q_u;
63 REG_R_OPEN_HKLM r_u;
64 prs_struct *data = &p->in_data.data;
65 prs_struct *rdata = &p->out_data.rdata;
67 ZERO_STRUCT(q_u);
68 ZERO_STRUCT(r_u);
70 /* grab the reg open */
71 if(!reg_io_q_open_hklm("", &q_u, data, 0))
72 return False;
74 r_u.status = _reg_open(p, &q_u, &r_u);
76 if(!reg_io_r_open_hklm("", &r_u, rdata, 0))
77 return False;
79 return True;
82 /*******************************************************************
83 api_reg_open_entry
84 ********************************************************************/
86 static BOOL api_reg_open_entry(pipes_struct *p)
88 REG_Q_OPEN_ENTRY q_u;
89 REG_R_OPEN_ENTRY r_u;
90 prs_struct *data = &p->in_data.data;
91 prs_struct *rdata = &p->out_data.rdata;
93 ZERO_STRUCT(q_u);
94 ZERO_STRUCT(r_u);
96 /* grab the reg open entry */
97 if(!reg_io_q_open_entry("", &q_u, data, 0))
98 return False;
100 /* construct reply. */
101 r_u.status = _reg_open_entry(p, &q_u, &r_u);
103 if(!reg_io_r_open_entry("", &r_u, rdata, 0))
104 return False;
106 return True;
109 /*******************************************************************
110 api_reg_info
111 ********************************************************************/
113 static BOOL api_reg_info(pipes_struct *p)
115 REG_Q_INFO q_u;
116 REG_R_INFO r_u;
117 prs_struct *data = &p->in_data.data;
118 prs_struct *rdata = &p->out_data.rdata;
120 ZERO_STRUCT(q_u);
121 ZERO_STRUCT(r_u);
123 /* grab the reg unknown 0x11*/
124 if(!reg_io_q_info("", &q_u, data, 0))
125 return False;
127 r_u.status = _reg_info(p, &q_u, &r_u);
129 if(!reg_io_r_info("", &r_u, rdata, 0))
130 return False;
132 return True;
135 #if 0
136 /*******************************************************************
137 api_reg_shutdown
138 ********************************************************************/
140 static BOOL api_reg_shutdown(pipes_struct *p)
142 REG_Q_SHUTDOWN q_u;
143 REG_R_SHUTDOWN r_u;
144 prs_struct *data = &p->in_data.data;
145 prs_struct *rdata = &p->out_data.rdata;
147 ZERO_STRUCT(q_u);
148 ZERO_STRUCT(r_u);
150 /* grab the reg shutdown */
151 if(!reg_io_q_shutdown("", &q_u, data, 0))
152 return False;
154 r_u.status = _reg_shutdown(p, &q_u, &r_u);
156 if(!reg_io_r_shutdown("", &r_u, rdata, 0))
157 return False;
159 return True;
162 /*******************************************************************
163 api_reg_abort_shutdown
164 ********************************************************************/
166 static BOOL api_reg_abort_shutdown(pipes_struct *p)
168 REG_Q_ABORT_SHUTDOWN q_u;
169 REG_R_ABORT_SHUTDOWN r_u;
170 prs_struct *data = &p->in_data.data;
171 prs_struct *rdata = &p->out_data.rdata;
173 ZERO_STRUCT(q_u);
174 ZERO_STRUCT(r_u);
176 /* grab the reg shutdown */
177 if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
178 return False;
180 r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
182 if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
183 return False;
185 return True;
187 #endif
189 /*******************************************************************
190 array of \PIPE\reg operations
191 ********************************************************************/
192 static struct api_struct api_reg_cmds[] =
194 { "REG_CLOSE" , REG_CLOSE , api_reg_close },
195 { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry },
196 { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open },
197 { "REG_INFO" , REG_INFO , api_reg_info },
198 #if 0
199 { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown },
200 { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown },
201 #endif
202 { NULL, 0 , NULL }
205 /*******************************************************************
206 receives a reg pipe and responds.
207 ********************************************************************/
209 BOOL api_reg_rpc(pipes_struct *p)
211 return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds);