This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[samba.git] / source / rpc_server / srv_reg.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Marc Jacobsen                                         2000.
8  *  Copyright (C) Jeremy Allison                                        2001.
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.
14  *  
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.
19  *  
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.
23  */
24
25 /* This is the interface for the registry functions. */
26
27 #include "includes.h"
28
29 /*******************************************************************
30  api_reg_close
31  ********************************************************************/
32
33 static BOOL api_reg_close(pipes_struct *p)
34 {
35         REG_Q_CLOSE q_u;
36         REG_R_CLOSE r_u;
37         prs_struct *data = &p->in_data.data;
38         prs_struct *rdata = &p->out_data.rdata;
39
40         ZERO_STRUCT(q_u);
41         ZERO_STRUCT(r_u);
42
43         /* grab the reg unknown 1 */
44         if(!reg_io_q_close("", &q_u, data, 0))
45                 return False;
46
47         r_u.status = _reg_close(p, &q_u, &r_u);
48
49         if(!reg_io_r_close("", &r_u, rdata, 0))
50                 return False;
51
52         return True;
53 }
54
55 /*******************************************************************
56  api_reg_open
57  ********************************************************************/
58
59 static BOOL api_reg_open(pipes_struct *p)
60 {
61         REG_Q_OPEN_HKLM q_u;
62         REG_R_OPEN_HKLM r_u;
63         prs_struct *data = &p->in_data.data;
64         prs_struct *rdata = &p->out_data.rdata;
65
66         ZERO_STRUCT(q_u);
67         ZERO_STRUCT(r_u);
68
69         /* grab the reg open */
70         if(!reg_io_q_open_hklm("", &q_u, data, 0))
71                 return False;
72
73         r_u.status = _reg_open(p, &q_u, &r_u);
74
75         if(!reg_io_r_open_hklm("", &r_u, rdata, 0))
76                 return False;
77
78         return True;
79 }
80
81 /*******************************************************************
82  api_reg_open_entry
83  ********************************************************************/
84
85 static BOOL api_reg_open_entry(pipes_struct *p)
86 {
87         REG_Q_OPEN_ENTRY q_u;
88         REG_R_OPEN_ENTRY r_u;
89         prs_struct *data = &p->in_data.data;
90         prs_struct *rdata = &p->out_data.rdata;
91
92         ZERO_STRUCT(q_u);
93         ZERO_STRUCT(r_u);
94
95         /* grab the reg open entry */
96         if(!reg_io_q_open_entry("", &q_u, data, 0))
97                 return False;
98
99         /* construct reply. */
100         r_u.status = _reg_open_entry(p, &q_u, &r_u);
101
102         if(!reg_io_r_open_entry("", &r_u, rdata, 0))
103                 return False;
104
105         return True;
106 }
107
108 /*******************************************************************
109  api_reg_info
110  ********************************************************************/
111
112 static BOOL api_reg_info(pipes_struct *p)
113 {
114         REG_Q_INFO q_u;
115         REG_R_INFO r_u;
116         prs_struct *data = &p->in_data.data;
117         prs_struct *rdata = &p->out_data.rdata;
118
119         ZERO_STRUCT(q_u);
120         ZERO_STRUCT(r_u);
121
122         /* grab the reg unknown 0x11*/
123         if(!reg_io_q_info("", &q_u, data, 0))
124                 return False;
125
126         r_u.status = _reg_info(p, &q_u, &r_u);
127
128         if(!reg_io_r_info("", &r_u, rdata, 0))
129                 return False;
130
131         return True;
132 }
133
134 /*******************************************************************
135  api_reg_shutdown
136  ********************************************************************/
137
138 static BOOL api_reg_shutdown(pipes_struct *p)
139 {
140         REG_Q_SHUTDOWN q_u;
141         REG_R_SHUTDOWN r_u;
142         prs_struct *data = &p->in_data.data;
143         prs_struct *rdata = &p->out_data.rdata;
144
145         ZERO_STRUCT(q_u);
146         ZERO_STRUCT(r_u);
147
148         /* grab the reg shutdown */
149         if(!reg_io_q_shutdown("", &q_u, data, 0))
150                 return False;
151
152         r_u.status = _reg_shutdown(p, &q_u, &r_u);
153
154         if(!reg_io_r_shutdown("", &r_u, rdata, 0))
155                 return False;
156
157         return True;
158 }
159
160 /*******************************************************************
161  api_reg_abort_shutdown
162  ********************************************************************/
163
164 static BOOL api_reg_abort_shutdown(pipes_struct *p)
165 {
166         REG_Q_ABORT_SHUTDOWN q_u;
167         REG_R_ABORT_SHUTDOWN r_u;
168         prs_struct *data = &p->in_data.data;
169         prs_struct *rdata = &p->out_data.rdata;
170
171         ZERO_STRUCT(q_u);
172         ZERO_STRUCT(r_u);
173
174         /* grab the reg shutdown */
175         if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
176                 return False;
177
178         r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
179
180         if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
181                 return False;
182
183         return True;
184 }
185
186
187 /*******************************************************************
188  array of \PIPE\reg operations
189  ********************************************************************/
190 static struct api_struct api_reg_cmds[] =
191 {
192         { "REG_CLOSE"        , REG_CLOSE        , api_reg_close        },
193         { "REG_OPEN_ENTRY"   , REG_OPEN_ENTRY   , api_reg_open_entry   },
194         { "REG_OPEN"         , REG_OPEN_HKLM    , api_reg_open         },
195         { "REG_INFO"         , REG_INFO         , api_reg_info         },
196         { "REG_SHUTDOWN"     , REG_SHUTDOWN     , api_reg_shutdown     },
197         { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown },
198         { NULL,                0                , NULL                 }
199 };
200
201 /*******************************************************************
202  receives a reg pipe and responds.
203  ********************************************************************/
204
205 BOOL api_reg_rpc(pipes_struct *p)
206 {
207         return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds);
208 }