don't dereference null pointer
[Samba/gebeck_regimport.git] / source4 / rpc_server / srv_dfs.c
blob14c1cb4088edaea0de6fca414fd718f2e90d1e25
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines for Dfs
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Shirish Kalele 2000,
7 * Copyright (C) Jeremy Allison 2001,
8 * Copyright (C) Anthony Liguori 2003.
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.
25 /* This is the interface to the dfs pipe. */
27 #include "includes.h"
28 #include "nterr.h"
30 #define MAX_MSDFS_JUNCTIONS 256
32 #undef DBGC_CLASS
33 #define DBGC_CLASS DBGC_RPC_SRV
35 /**********************************************************************
36 api_dfs_exist
37 **********************************************************************/
39 static BOOL api_dfs_exist(pipes_struct *p)
41 DFS_Q_DFS_EXIST q_u;
42 DFS_R_DFS_EXIST r_u;
43 prs_struct *data = &p->in_data.data;
44 prs_struct *rdata = &p->out_data.rdata;
46 if(!dfs_io_q_dfs_exist("", &q_u, data, 0))
47 return False;
49 r_u.status = _dfs_exist(p, &q_u, &r_u);
51 if (!dfs_io_r_dfs_exist("", &r_u, rdata, 0))
52 return False;
54 return True;
57 /*****************************************************************
58 api_dfs_add
59 *****************************************************************/
61 static BOOL api_dfs_add(pipes_struct *p)
63 DFS_Q_DFS_ADD q_u;
64 DFS_R_DFS_ADD r_u;
65 prs_struct *data = &p->in_data.data;
66 prs_struct *rdata = &p->out_data.rdata;
68 ZERO_STRUCT(q_u);
69 ZERO_STRUCT(r_u);
71 if(!dfs_io_q_dfs_add("", &q_u, data, 0))
72 return False;
74 r_u.status = _dfs_add(p, &q_u, &r_u);
76 if (!dfs_io_r_dfs_add("", &r_u, rdata, 0))
77 return False;
79 return True;
82 /*****************************************************************
83 api_dfs_remove
84 *****************************************************************/
86 static BOOL api_dfs_remove(pipes_struct *p)
88 DFS_Q_DFS_REMOVE q_u;
89 DFS_R_DFS_REMOVE 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 if(!dfs_io_q_dfs_remove("", &q_u, data, 0))
97 return False;
99 r_u.status = _dfs_remove(p, &q_u, &r_u);
101 if (!dfs_io_r_dfs_remove("", &r_u, rdata, 0))
102 return False;
104 return True;
107 /*******************************************************************
108 api_dfs_get_info
109 *******************************************************************/
111 static BOOL api_dfs_get_info(pipes_struct *p)
113 DFS_Q_DFS_GET_INFO q_u;
114 DFS_R_DFS_GET_INFO r_u;
115 prs_struct *data = &p->in_data.data;
116 prs_struct *rdata = &p->out_data.rdata;
118 ZERO_STRUCT(q_u);
119 ZERO_STRUCT(r_u);
121 if(!dfs_io_q_dfs_get_info("", &q_u, data, 0))
122 return False;
124 r_u.status = _dfs_get_info(p, &q_u, &r_u);
126 if(!dfs_io_r_dfs_get_info("", &r_u, rdata, 0))
127 return False;
129 return True;
132 /*******************************************************************
133 api_dfs_enum
134 *******************************************************************/
136 static BOOL api_dfs_enum(pipes_struct *p)
138 DFS_Q_DFS_ENUM q_u;
139 DFS_R_DFS_ENUM r_u;
140 prs_struct *data = &p->in_data.data;
141 prs_struct *rdata = &p->out_data.rdata;
143 ZERO_STRUCT(q_u);
144 ZERO_STRUCT(r_u);
146 if(!dfs_io_q_dfs_enum("", &q_u, data, 0))
147 return False;
149 r_u.status = _dfs_enum(p, &q_u, &r_u);
151 if(!dfs_io_r_dfs_enum("", &r_u, rdata, 0))
152 return False;
154 return True;
157 /*******************************************************************
158 \pipe\netdfs commands
159 ********************************************************************/
161 #ifdef RPC_DFS_DYNAMIC
162 int init_module(void)
163 #else
164 int rpc_dfs_init(void)
165 #endif
167 struct api_struct api_netdfs_cmds[] =
169 {"DFS_EXIST", DFS_EXIST, api_dfs_exist },
170 {"DFS_ADD", DFS_ADD, api_dfs_add },
171 {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove },
172 {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info },
173 {"DFS_ENUM", DFS_ENUM, api_dfs_enum }
175 return rpc_pipe_register_commands("netdfs", "netdfs", api_netdfs_cmds,
176 sizeof(api_netdfs_cmds) / sizeof(struct api_struct));