One less Get_Pwnam_Modify call!
[kai/samba.git] / source3 / rpc_server / srv_reg.c
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.
10  *
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.
15  *  
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.
20  *  
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.
24  */
25
26 /* This is the interface for the registry functions. */
27
28 #include "includes.h"
29
30 /*******************************************************************
31  api_reg_close
32  ********************************************************************/
33
34 static BOOL api_reg_close(pipes_struct *p)
35 {
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;
40
41         ZERO_STRUCT(q_u);
42         ZERO_STRUCT(r_u);
43
44         /* grab the reg unknown 1 */
45         if(!reg_io_q_close("", &q_u, data, 0))
46                 return False;
47
48         r_u.status = _reg_close(p, &q_u, &r_u);
49
50         if(!reg_io_r_close("", &r_u, rdata, 0))
51                 return False;
52
53         return True;
54 }
55
56 /*******************************************************************
57  api_reg_open
58  ********************************************************************/
59
60 static BOOL api_reg_open(pipes_struct *p)
61 {
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;
66
67         ZERO_STRUCT(q_u);
68         ZERO_STRUCT(r_u);
69
70         /* grab the reg open */
71         if(!reg_io_q_open_hklm("", &q_u, data, 0))
72                 return False;
73
74         r_u.status = _reg_open(p, &q_u, &r_u);
75
76         if(!reg_io_r_open_hklm("", &r_u, rdata, 0))
77                 return False;
78
79         return True;
80 }
81
82 /*******************************************************************
83  api_reg_open_entry
84  ********************************************************************/
85
86 static BOOL api_reg_open_entry(pipes_struct *p)
87 {
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;
92
93         ZERO_STRUCT(q_u);
94         ZERO_STRUCT(r_u);
95
96         /* grab the reg open entry */
97         if(!reg_io_q_open_entry("", &q_u, data, 0))
98                 return False;
99
100         /* construct reply. */
101         r_u.status = _reg_open_entry(p, &q_u, &r_u);
102
103         if(!reg_io_r_open_entry("", &r_u, rdata, 0))
104                 return False;
105
106         return True;
107 }
108
109 /*******************************************************************
110  api_reg_info
111  ********************************************************************/
112
113 static BOOL api_reg_info(pipes_struct *p)
114 {
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;
119
120         ZERO_STRUCT(q_u);
121         ZERO_STRUCT(r_u);
122
123         /* grab the reg unknown 0x11*/
124         if(!reg_io_q_info("", &q_u, data, 0))
125                 return False;
126
127         r_u.status = _reg_info(p, &q_u, &r_u);
128
129         if(!reg_io_r_info("", &r_u, rdata, 0))
130                 return False;
131
132         return True;
133 }
134
135 /*******************************************************************
136  api_reg_shutdown
137  ********************************************************************/
138
139 static BOOL api_reg_shutdown(pipes_struct *p)
140 {
141         REG_Q_SHUTDOWN q_u;
142         REG_R_SHUTDOWN r_u;
143         prs_struct *data = &p->in_data.data;
144         prs_struct *rdata = &p->out_data.rdata;
145
146         ZERO_STRUCT(q_u);
147         ZERO_STRUCT(r_u);
148
149         /* grab the reg shutdown */
150         if(!reg_io_q_shutdown("", &q_u, data, 0))
151                 return False;
152
153         r_u.status = _reg_shutdown(p, &q_u, &r_u);
154
155         if(!reg_io_r_shutdown("", &r_u, rdata, 0))
156                 return False;
157
158         return True;
159 }
160
161 /*******************************************************************
162  api_reg_abort_shutdown
163  ********************************************************************/
164
165 static BOOL api_reg_abort_shutdown(pipes_struct *p)
166 {
167         REG_Q_ABORT_SHUTDOWN q_u;
168         REG_R_ABORT_SHUTDOWN r_u;
169         prs_struct *data = &p->in_data.data;
170         prs_struct *rdata = &p->out_data.rdata;
171
172         ZERO_STRUCT(q_u);
173         ZERO_STRUCT(r_u);
174
175         /* grab the reg shutdown */
176         if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
177                 return False;
178
179         r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
180
181         if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
182                 return False;
183
184         return True;
185 }
186
187
188 /*******************************************************************
189  array of \PIPE\reg operations
190  ********************************************************************/
191 static struct api_struct api_reg_cmds[] =
192 {
193         { "REG_CLOSE"        , REG_CLOSE        , api_reg_close        },
194         { "REG_OPEN_ENTRY"   , REG_OPEN_ENTRY   , api_reg_open_entry   },
195         { "REG_OPEN"         , REG_OPEN_HKLM    , api_reg_open         },
196         { "REG_INFO"         , REG_INFO         , api_reg_info         },
197         { "REG_SHUTDOWN"     , REG_SHUTDOWN     , api_reg_shutdown     },
198         { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown },
199         { NULL,                0                , NULL                 }
200 };
201
202 /*******************************************************************
203  receives a reg pipe and responds.
204  ********************************************************************/
205
206 BOOL api_reg_rpc(pipes_struct *p)
207 {
208         return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds);
209 }