File: | xlators/nfs/server/src/acl3.c |
Location: | line 240, column 44 |
Description: | Dereference of null pointer |
1 | /* | |||
2 | * Copyright (c) 2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | * This file is part of GlusterFS. | |||
4 | * | |||
5 | * This file is licensed to you under your choice of the GNU Lesser | |||
6 | * General Public License, version 3 or any later version (LGPLv3 or | |||
7 | * later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | * cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | #ifndef _CONFIG_H | |||
12 | #define _CONFIG_H | |||
13 | #include "config.h" | |||
14 | #endif | |||
15 | ||||
16 | #include "defaults.h" | |||
17 | #include "rpcsvc.h" | |||
18 | #include "dict.h" | |||
19 | #include "xlator.h" | |||
20 | #include "nfs.h" | |||
21 | #include "mem-pool.h" | |||
22 | #include "logging.h" | |||
23 | #include "nfs-fops.h" | |||
24 | #include "inode.h" | |||
25 | #include "nfs3.h" | |||
26 | #include "nfs-mem-types.h" | |||
27 | #include "nfs3-helpers.h" | |||
28 | #include "nfs3-fh.h" | |||
29 | #include "nfs-generics.h" | |||
30 | #include "acl3.h" | |||
31 | ||||
32 | ||||
33 | typedef ssize_t (*acl3_serializer) (struct iovec outmsg, void *args); | |||
34 | ||||
35 | extern void nfs3_call_state_wipe (nfs3_call_state_t *cs); | |||
36 | ||||
37 | extern nfs3_call_state_t * | |||
38 | nfs3_call_state_init (struct nfs3_state *s, rpcsvc_request_t *req, xlator_t *v); | |||
39 | ||||
40 | extern int | |||
41 | nfs3_fh_validate (struct nfs3_fh *fh); | |||
42 | ||||
43 | extern fattr3 | |||
44 | nfs3_stat_to_fattr3 (struct iatt *buf); | |||
45 | ||||
46 | #define acl3_validate_nfs3_state(request, state, status, label, retval)do { state = (((rpcsvc_program_t *)((request)->prog))-> private); if (!state) { do { do { if (0) printf ("NFSv3 state " "missing from RPC request"); } while (0); _gf_log ("nfs""-ACL" , "acl3.c", __FUNCTION__, 46, GF_LOG_ERROR, "NFSv3 state " "missing from RPC request" ); } while (0); (req)->rpc_err = SYSTEM_ERR; status = NFS3ERR_SERVERFAULT ; goto label; } } while (0); \ | |||
47 | do { \ | |||
48 | state = rpcsvc_request_program_private (request)(((rpcsvc_program_t *)((request)->prog))->private); \ | |||
49 | if (!state) { \ | |||
50 | gf_log (GF_ACL, GF_LOG_ERROR, "NFSv3 state " \do { do { if (0) printf ("NFSv3 state " "missing from RPC request" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 51, GF_LOG_ERROR, "NFSv3 state " "missing from RPC request") ; } while (0) | |||
51 | "missing from RPC request")do { do { if (0) printf ("NFSv3 state " "missing from RPC request" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 51, GF_LOG_ERROR, "NFSv3 state " "missing from RPC request") ; } while (0); \ | |||
52 | rpcsvc_request_seterr (req, SYSTEM_ERR)(req)->rpc_err = SYSTEM_ERR; \ | |||
53 | status = NFS3ERR_SERVERFAULT; \ | |||
54 | goto label; \ | |||
55 | } \ | |||
56 | } while (0); \ | |||
57 | ||||
58 | #define acl3_validate_gluster_fh(handle, status, errlabel)do { if (!nfs3_fh_validate (handle)) { status = NFS3ERR_SERVERFAULT ; goto errlabel; } } while (0) \ | |||
59 | do { \ | |||
60 | if (!nfs3_fh_validate (handle)) { \ | |||
61 | status = NFS3ERR_SERVERFAULT; \ | |||
62 | goto errlabel; \ | |||
63 | } \ | |||
64 | } while (0) \ | |||
65 | ||||
66 | ||||
67 | extern xlator_t * | |||
68 | nfs3_fh_to_xlator (struct nfs3_state *nfs3, struct nfs3_fh *fh); | |||
69 | ||||
70 | #define acl3_map_fh_to_volume(nfs3state, handle, req, volume, status, label)do { char exportid[256], gfid[256]; rpc_transport_t *trans = ( (void*)0); volume = nfs3_fh_to_xlator ((nfs3state), handle); if (!volume) { uuid_unparse (handle->exportid, exportid); uuid_unparse (handle->gfid, gfid); trans = ((req)->trans); do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 70, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 70, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); status = NFS3ERR_STALE; goto label; } else { do { do { if (0) printf ("FH to Volume: %s" , volume->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 70, GF_LOG_TRACE, "FH to Volume: %s" ,volume-> name); } while (0); (req)->private = (void *)(volume); } } while (0); \ | |||
71 | do { \ | |||
72 | char exportid[256], gfid[256]; \ | |||
73 | rpc_transport_t *trans = NULL((void*)0); \ | |||
74 | volume = nfs3_fh_to_xlator ((nfs3state), handle); \ | |||
75 | if (!volume) { \ | |||
76 | uuid_unparse (handle->exportid, exportid); \ | |||
77 | uuid_unparse (handle->gfid, gfid); \ | |||
78 | trans = rpcsvc_request_transport (req)((req)->trans); \ | |||
79 | gf_log (GF_ACL, GF_LOG_ERROR, "Failed to map " \do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 82, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) | |||
80 | "FH to vol: client=%s, exportid=%s, gfid=%s",\do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 82, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) | |||
81 | trans->peerinfo.identifier, exportid, \do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 82, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) | |||
82 | gfid)do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 82, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0); \ | |||
83 | gf_log (GF_ACL, GF_LOG_ERROR, \do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 86, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0) | |||
84 | "Stale nfs client %s must be trying to "\do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 86, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0) | |||
85 | "connect to a deleted volume, please " \do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 86, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0) | |||
86 | "unmount it.", trans->peerinfo.identifier)do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 86, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0);\ | |||
87 | status = NFS3ERR_STALE; \ | |||
88 | goto label; \ | |||
89 | } else { \ | |||
90 | gf_log (GF_ACL, GF_LOG_TRACE, "FH to Volume: %s"\do { do { if (0) printf ("FH to Volume: %s" ,volume->name) ; } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 91 , GF_LOG_TRACE, "FH to Volume: %s" ,volume->name); } while (0) | |||
91 | ,volume->name)do { do { if (0) printf ("FH to Volume: %s" ,volume->name) ; } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 91 , GF_LOG_TRACE, "FH to Volume: %s" ,volume->name); } while (0); \ | |||
92 | rpcsvc_request_set_private (req, volume)(req)->private = (void *)(volume); \ | |||
93 | } \ | |||
94 | } while (0); \ | |||
95 | ||||
96 | #define acl3_volume_started_check(nfs3state, vlm, rtval, erlbl)do { if ((!nfs_subvolume_started ((nfs3state->nfsx)->private , vlm))){ do { do { if (0) printf ("Volume is disabled: %s", vlm ->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__ , 96, GF_LOG_ERROR, "Volume is disabled: %s", vlm->name); } while (0); rtval = (-2); goto erlbl; } } while (0) \ | |||
97 | do { \ | |||
98 | if ((!nfs_subvolume_started (nfs_state (nfs3state->nfsx)(nfs3state->nfsx)->private, vlm))){\ | |||
99 | gf_log (GF_ACL, GF_LOG_ERROR, "Volume is disabled: %s",\do { do { if (0) printf ("Volume is disabled: %s", vlm->name ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 100, GF_LOG_ERROR, "Volume is disabled: %s", vlm->name); } while (0) | |||
100 | vlm->name)do { do { if (0) printf ("Volume is disabled: %s", vlm->name ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 100, GF_LOG_ERROR, "Volume is disabled: %s", vlm->name); } while (0); \ | |||
101 | rtval = RPCSVC_ACTOR_IGNORE(-2); \ | |||
102 | goto erlbl; \ | |||
103 | } \ | |||
104 | } while (0) \ | |||
105 | ||||
106 | #define acl3_check_fh_resolve_status(cst, nfstat, erlabl)do { xlator_t *xlatorp = ((void*)0); char buf[256], gfid[256] ; rpc_transport_t *trans = ((void*)0); if ((cst)->resolve_ret < 0) { trans = ((cst->req)->trans); xlatorp = nfs3_fh_to_xlator (cst->nfs3state, &cst->resolvefh); uuid_unparse (cst ->resolvefh.gfid, gfid); sprintf (buf, "(%s) %s : %s", trans ->peerinfo.identifier, xlatorp ? xlatorp->name : "ERR", gfid); do { do { if (0) printf ("Unable to resolve FH" ": %s" , buf); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__ , 106, GF_LOG_ERROR, "Unable to resolve FH" ": %s", buf); } while (0); nfstat = nfs3_errno_to_nfsstat3 (cst->resolve_errno) ; goto erlabl; } } while (0) \ | |||
107 | do { \ | |||
108 | xlator_t *xlatorp = NULL((void*)0); \ | |||
109 | char buf[256], gfid[256]; \ | |||
110 | rpc_transport_t *trans = NULL((void*)0); \ | |||
111 | if ((cst)->resolve_ret < 0) { \ | |||
112 | trans = rpcsvc_request_transport (cst->req)((cst->req)->trans); \ | |||
113 | xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ | |||
114 | &cst->resolvefh); \ | |||
115 | uuid_unparse (cst->resolvefh.gfid, gfid); \ | |||
116 | sprintf (buf, "(%s) %s : %s", trans->peerinfo.identifier,\ | |||
117 | xlatorp ? xlatorp->name : "ERR", gfid); \ | |||
118 | gf_log (GF_ACL, GF_LOG_ERROR, "Unable to resolve FH"\do { do { if (0) printf ("Unable to resolve FH" ": %s", buf); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 119 , GF_LOG_ERROR, "Unable to resolve FH" ": %s", buf); } while ( 0) | |||
119 | ": %s", buf)do { do { if (0) printf ("Unable to resolve FH" ": %s", buf); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 119 , GF_LOG_ERROR, "Unable to resolve FH" ": %s", buf); } while ( 0); \ | |||
120 | nfstat = nfs3_errno_to_nfsstat3 (cst->resolve_errno);\ | |||
121 | goto erlabl; \ | |||
122 | } \ | |||
123 | } while (0) \ | |||
124 | ||||
125 | #define acl3_handle_call_state_init(nfs3state, calls, rq, v, opstat, errlabel)do { calls = nfs3_call_state_init ((nfs3state), (rq), v); if ( !calls) { do { do { if (0) printf ("Failed to " "init call state" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 125, GF_LOG_ERROR, "Failed to " "init call state"); } while ( 0); opstat = NFS3ERR_SERVERFAULT; (req)->rpc_err = SYSTEM_ERR ; goto errlabel; } } while (0)\ | |||
126 | do { \ | |||
127 | calls = nfs3_call_state_init ((nfs3state), (rq), v); \ | |||
128 | if (!calls) { \ | |||
129 | gf_log (GF_ACL, GF_LOG_ERROR, "Failed to " \do { do { if (0) printf ("Failed to " "init call state"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 130, GF_LOG_ERROR , "Failed to " "init call state"); } while (0) | |||
130 | "init call state")do { do { if (0) printf ("Failed to " "init call state"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 130, GF_LOG_ERROR , "Failed to " "init call state"); } while (0); \ | |||
131 | opstat = NFS3ERR_SERVERFAULT; \ | |||
132 | rpcsvc_request_seterr (req, SYSTEM_ERR)(req)->rpc_err = SYSTEM_ERR; \ | |||
133 | goto errlabel; \ | |||
134 | } \ | |||
135 | } while (0) \ | |||
136 | ||||
137 | ||||
138 | int | |||
139 | acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc) | |||
140 | { | |||
141 | struct iovec outmsg = {0, }; | |||
142 | struct iobuf *iob = NULL((void*)0); | |||
143 | struct nfs3_state *nfs3 = NULL((void*)0); | |||
144 | int ret = -1; | |||
145 | struct iobref *iobref = NULL((void*)0); | |||
146 | ||||
147 | if (!req) | |||
148 | return -1; | |||
149 | ||||
150 | nfs3 = (struct nfs3_state *)rpcsvc_request_program_private (req)(((rpcsvc_program_t *)((req)->prog))->private); | |||
151 | if (!nfs3) { | |||
152 | gf_log (GF_ACL, GF_LOG_ERROR, "mount state not found")do { do { if (0) printf ("mount state not found"); } while (0 ); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 152, GF_LOG_ERROR , "mount state not found"); } while (0); | |||
153 | goto ret; | |||
154 | } | |||
155 | ||||
156 | /* First, get the io buffer into which the reply in arg will | |||
157 | * be serialized. | |||
158 | */ | |||
159 | iob = iobuf_get (nfs3->iobpool); | |||
160 | if (!iob) { | |||
161 | gf_log (GF_ACL, GF_LOG_ERROR, "Failed to get iobuf")do { do { if (0) printf ("Failed to get iobuf"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 161, GF_LOG_ERROR , "Failed to get iobuf"); } while (0); | |||
162 | goto ret; | |||
163 | } | |||
164 | ||||
165 | iobuf_to_iovec (iob, &outmsg); | |||
166 | /* Use the given serializer to translate the give C structure in arg | |||
167 | * to XDR format which will be written into the buffer in outmsg. | |||
168 | */ | |||
169 | outmsg.iov_len = sfunc (outmsg, arg); | |||
170 | ||||
171 | iobref = iobref_new (); | |||
172 | if (iobref == NULL((void*)0)) { | |||
173 | gf_log (GF_ACL, GF_LOG_ERROR, "Failed to get iobref")do { do { if (0) printf ("Failed to get iobref"); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 173, GF_LOG_ERROR , "Failed to get iobref"); } while (0); | |||
174 | goto ret; | |||
175 | } | |||
176 | ||||
177 | iobref_add (iobref, iob); | |||
178 | ||||
179 | /* Then, submit the message for transmission. */ | |||
180 | ret = rpcsvc_submit_message (req, &outmsg, 1, NULL((void*)0), 0, iobref); | |||
181 | if (ret == -1) { | |||
182 | gf_log (GF_ACL, GF_LOG_ERROR, "Reply submission failed")do { do { if (0) printf ("Reply submission failed"); } while ( 0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 182, GF_LOG_ERROR , "Reply submission failed"); } while (0); | |||
183 | goto ret; | |||
184 | } | |||
185 | ||||
186 | ret = 0; | |||
187 | ret: | |||
188 | if (iob) | |||
189 | iobuf_unref (iob); | |||
190 | if (iobref) | |||
191 | iobref_unref (iobref); | |||
192 | ||||
193 | return ret; | |||
194 | } | |||
195 | ||||
196 | ||||
197 | int | |||
198 | acl3svc_null (rpcsvc_request_t *req) | |||
199 | { | |||
200 | struct iovec dummyvec = {0, }; | |||
201 | ||||
202 | if (!req) { | |||
203 | gf_log (GF_ACL, GF_LOG_ERROR, "Got NULL request!")do { do { if (0) printf ("Got NULL request!"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 203, GF_LOG_ERROR, "Got NULL request!" ); } while (0); | |||
204 | return 0; | |||
205 | } | |||
206 | rpcsvc_submit_generic (req, &dummyvec, 1, NULL((void*)0), 0, NULL((void*)0)); | |||
207 | return 0; | |||
208 | } | |||
209 | ||||
210 | int | |||
211 | acl3_getacl_reply (nfs3_call_state_t *cs, getaclreply *reply) | |||
212 | { | |||
213 | acl3svc_submit_reply (cs->req, (void *)reply, | |||
214 | (acl3_serializer)xdr_serialize_getaclreply); | |||
215 | return 0; | |||
216 | } | |||
217 | ||||
218 | ||||
219 | int | |||
220 | acl3_getacl_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
221 | int32_t op_ret, int32_t op_errno, dict_t *dict, | |||
222 | dict_t *xdata) | |||
223 | { | |||
224 | nfsstat3 stat = NFS3ERR_SERVERFAULT; | |||
225 | nfs3_call_state_t *cs = NULL((void*)0); | |||
226 | data_t *data = NULL((void*)0); | |||
227 | int *p = NULL((void*)0); | |||
228 | int i = 0; | |||
229 | getaclreply *getaclreply = NULL((void*)0); | |||
| ||||
230 | ||||
231 | cs = frame->local; | |||
232 | if (cs) | |||
233 | getaclreply = &cs->args.getaclreply; | |||
234 | ||||
235 | if (op_ret == -1) { | |||
236 | stat = nfs3_errno_to_nfsstat3 (op_errno); | |||
237 | goto err; | |||
238 | } | |||
239 | ||||
240 | getaclreply->aclentry.aclentry_val = cs->aclentry; | |||
| ||||
241 | getaclreply->daclentry.daclentry_val = cs->daclentry; | |||
242 | ||||
243 | /* FIXME: use posix_acl_from_xattr() */ | |||
244 | data = dict_get (dict, "system.posix_acl_access"); | |||
245 | if (data && (p = data_to_bin (data))) { | |||
246 | /* POSIX_ACL_XATTR_VERSION */ | |||
247 | p++; | |||
248 | while ((char *)p < (data->data + data->len)) { | |||
249 | getaclreply->aclentry.aclentry_val[i].type = *(*(short **)&p)++; | |||
250 | getaclreply->aclentry.aclentry_val[i].perm = *(*(short **)&p)++; | |||
251 | getaclreply->aclentry.aclentry_val[i].uid = *(*(int **)&p)++; | |||
252 | i++; | |||
253 | } | |||
254 | getaclreply->aclcount = getaclreply->aclentry.aclentry_len = i; | |||
255 | } | |||
256 | i = 0; | |||
257 | ||||
258 | data = dict_get (dict, "system.posix_acl_default"); | |||
259 | if (data && (p = data_to_bin (data))) { | |||
260 | /* POSIX_ACL_XATTR_VERSION */ | |||
261 | p++; | |||
262 | while ((char *)p < (data->data + data->len)) { | |||
263 | getaclreply->daclentry.daclentry_val[i].type = *(*(short **)&p)++; | |||
264 | getaclreply->daclentry.daclentry_val[i].perm = *(*(short **)&p)++; | |||
265 | getaclreply->daclentry.daclentry_val[i].uid = *(*(int **)&p)++; | |||
266 | i++; | |||
267 | } | |||
268 | getaclreply->daclcount = getaclreply->daclentry.daclentry_len = i; | |||
269 | } | |||
270 | ||||
271 | acl3_getacl_reply (cs, getaclreply); | |||
272 | nfs3_call_state_wipe (cs); | |||
273 | return 0; | |||
274 | ||||
275 | err: | |||
276 | if (getaclreply) | |||
277 | getaclreply->status = stat; | |||
278 | acl3_getacl_reply (cs, getaclreply); | |||
279 | nfs3_call_state_wipe (cs); | |||
280 | return 0; | |||
281 | } | |||
282 | ||||
283 | int | |||
284 | acl3_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
285 | int32_t op_ret, int32_t op_errno, struct iatt *buf, | |||
286 | dict_t *xdata) | |||
287 | { | |||
288 | nfsstat3 stat = NFS3ERR_SERVERFAULT; | |||
289 | nfs3_call_state_t *cs = NULL((void*)0); | |||
290 | getaclreply *getaclreply = NULL((void*)0); | |||
291 | int ret = -1; | |||
292 | nfs_user_t nfu = {0, }; | |||
293 | ||||
294 | cs = frame->local; | |||
295 | if (cs) | |||
296 | getaclreply = &cs->args.getaclreply; | |||
297 | ||||
298 | if (op_ret == -1) { | |||
299 | stat = nfs3_errno_to_nfsstat3 (op_errno); | |||
300 | goto err; | |||
301 | } | |||
302 | ||||
303 | getaclreply->attr_follows = 1; | |||
304 | getaclreply->attr = nfs3_stat_to_fattr3 (buf); | |||
305 | getaclreply->mask = 0xf; | |||
306 | nfs_request_user_init (&nfu, cs->req); | |||
307 | ret = nfs_getxattr (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, NULL((void*)0), NULL((void*)0), | |||
308 | acl3_getacl_cbk, cs); | |||
309 | if (ret == -1) { | |||
310 | stat = nfs3_errno_to_nfsstat3 (op_errno); | |||
311 | goto err; | |||
312 | } | |||
313 | return 0; | |||
314 | err: | |||
315 | getaclreply->status = stat; | |||
316 | acl3_getacl_reply (cs, getaclreply); | |||
317 | nfs3_call_state_wipe (cs); | |||
318 | return 0; | |||
319 | } | |||
320 | ||||
321 | ||||
322 | int | |||
323 | acl3_getacl_resume (void *carg) | |||
324 | { | |||
325 | int ret = -1; | |||
326 | nfs3_call_state_t *cs = NULL((void*)0); | |||
327 | nfsstat3 stat = NFS3ERR_SERVERFAULT; | |||
328 | nfs_user_t nfu = {0, }; | |||
329 | ||||
330 | if (!carg) | |||
331 | return ret; | |||
332 | ||||
333 | cs = (nfs3_call_state_t *)carg; | |||
334 | acl3_check_fh_resolve_status (cs, stat, acl3err)do { xlator_t *xlatorp = ((void*)0); char buf[256], gfid[256] ; rpc_transport_t *trans = ((void*)0); if ((cs)->resolve_ret < 0) { trans = ((cs->req)->trans); xlatorp = nfs3_fh_to_xlator (cs->nfs3state, &cs->resolvefh); uuid_unparse (cs-> resolvefh.gfid, gfid); sprintf (buf, "(%s) %s : %s", trans-> peerinfo.identifier, xlatorp ? xlatorp->name : "ERR", gfid ); do { do { if (0) printf ("Unable to resolve FH" ": %s", buf ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 334, GF_LOG_ERROR, "Unable to resolve FH" ": %s", buf); } while (0); stat = nfs3_errno_to_nfsstat3 (cs->resolve_errno); goto acl3err; } } while (0); | |||
335 | nfs_request_user_init (&nfu, cs->req); | |||
336 | ||||
337 | ret = nfs_stat (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, | |||
338 | acl3_stat_cbk, cs); | |||
339 | stat = -ret; | |||
340 | acl3err: | |||
341 | if (ret < 0) { | |||
342 | gf_log (GF_ACL, GF_LOG_ERROR, "unable to open_and_resume")do { do { if (0) printf ("unable to open_and_resume"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 342, GF_LOG_ERROR , "unable to open_and_resume"); } while (0); | |||
343 | cs->args.getaclreply.status = nfs3_errno_to_nfsstat3 (stat); | |||
344 | acl3_getacl_reply (cs, &cs->args.getaclreply); | |||
345 | nfs3_call_state_wipe (cs); | |||
346 | } | |||
347 | ||||
348 | return ret; | |||
349 | } | |||
350 | ||||
351 | ||||
352 | int | |||
353 | acl3svc_getacl (rpcsvc_request_t *req) | |||
354 | { | |||
355 | xlator_t *vol = NULL((void*)0); | |||
356 | struct nfs_state *nfs = NULL((void*)0); | |||
357 | nfs3_state_t *nfs3 = NULL((void*)0); | |||
358 | nfs3_call_state_t *cs = NULL((void*)0); | |||
359 | int ret = RPCSVC_ACTOR_ERROR(-1); | |||
360 | nfsstat3 stat = NFS3ERR_SERVERFAULT; | |||
361 | struct nfs3_fh fh, *fhp = NULL((void*)0); | |||
362 | getaclargs getaclargs; | |||
363 | ||||
364 | if (!req) | |||
365 | return ret; | |||
366 | ||||
367 | acl3_validate_nfs3_state (req, nfs3, stat, rpcerr, ret)do { nfs3 = (((rpcsvc_program_t *)((req)->prog))->private ); if (!nfs3) { do { do { if (0) printf ("NFSv3 state " "missing from RPC request" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 367, GF_LOG_ERROR, "NFSv3 state " "missing from RPC request" ); } while (0); (req)->rpc_err = SYSTEM_ERR; stat = NFS3ERR_SERVERFAULT ; goto rpcerr; } } while (0);; | |||
368 | nfs = nfs_state (nfs3->nfsx)(nfs3->nfsx)->private; | |||
369 | memset (&getaclargs, 0, sizeof (getaclargs)); | |||
370 | getaclargs.fh.n_bytes = (char *)&fh; | |||
371 | if (xdr_to_getaclargs(req->msg[0], &getaclargs) <= 0) { | |||
372 | gf_log (GF_ACL, GF_LOG_ERROR, "Error decoding args")do { do { if (0) printf ("Error decoding args"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 372, GF_LOG_ERROR , "Error decoding args"); } while (0); | |||
373 | rpcsvc_request_seterr (req, GARBAGE_ARGS)(req)->rpc_err = GARBAGE_ARGS; | |||
374 | goto rpcerr; | |||
375 | } | |||
376 | fhp = &fh; | |||
377 | acl3_validate_gluster_fh (&fh, stat, acl3err)do { if (!nfs3_fh_validate (&fh)) { stat = NFS3ERR_SERVERFAULT ; goto acl3err; } } while (0); | |||
378 | acl3_map_fh_to_volume (nfs->nfs3state, fhp, req,do { char exportid[256], gfid[256]; rpc_transport_t *trans = ( (void*)0); vol = nfs3_fh_to_xlator ((nfs->nfs3state), fhp) ; if (!vol) { uuid_unparse (fhp->exportid, exportid); uuid_unparse (fhp->gfid, gfid); trans = ((req)->trans); do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 379, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 379, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); stat = NFS3ERR_STALE; goto acl3err; } else { do { do { if (0) printf ("FH to Volume: %s" ,vol->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 379, GF_LOG_TRACE, "FH to Volume: %s" ,vol-> name); } while (0); (req)->private = (void *)(vol); } } while (0); | |||
379 | vol, stat, acl3err)do { char exportid[256], gfid[256]; rpc_transport_t *trans = ( (void*)0); vol = nfs3_fh_to_xlator ((nfs->nfs3state), fhp) ; if (!vol) { uuid_unparse (fhp->exportid, exportid); uuid_unparse (fhp->gfid, gfid); trans = ((req)->trans); do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 379, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 379, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); stat = NFS3ERR_STALE; goto acl3err; } else { do { do { if (0) printf ("FH to Volume: %s" ,vol->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 379, GF_LOG_TRACE, "FH to Volume: %s" ,vol-> name); } while (0); (req)->private = (void *)(vol); } } while (0);; | |||
380 | acl3_handle_call_state_init (nfs->nfs3state, cs, req,do { cs = nfs3_call_state_init ((nfs->nfs3state), (req), vol ); if (!cs) { do { do { if (0) printf ("Failed to " "init call state" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 381, GF_LOG_ERROR, "Failed to " "init call state"); } while ( 0); stat = NFS3ERR_SERVERFAULT; (req)->rpc_err = SYSTEM_ERR ; goto rpcerr; } } while (0) | |||
381 | vol, stat, rpcerr)do { cs = nfs3_call_state_init ((nfs->nfs3state), (req), vol ); if (!cs) { do { do { if (0) printf ("Failed to " "init call state" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 381, GF_LOG_ERROR, "Failed to " "init call state"); } while ( 0); stat = NFS3ERR_SERVERFAULT; (req)->rpc_err = SYSTEM_ERR ; goto rpcerr; } } while (0); | |||
382 | ||||
383 | cs->vol = vol; | |||
384 | acl3_volume_started_check (nfs3, vol, ret, acl3err)do { if ((!nfs_subvolume_started ((nfs3->nfsx)->private , vol))){ do { do { if (0) printf ("Volume is disabled: %s", vol ->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__ , 384, GF_LOG_ERROR, "Volume is disabled: %s", vol->name); } while (0); ret = (-2); goto acl3err; } } while (0); | |||
385 | ||||
386 | ret = nfs3_fh_resolve_and_resume (cs, fhp, | |||
387 | NULL((void*)0), acl3_getacl_resume); | |||
388 | ||||
389 | acl3err: | |||
390 | if (ret < 0) { | |||
391 | gf_log (GF_ACL, GF_LOG_ERROR, "unable to resolve and resume")do { do { if (0) printf ("unable to resolve and resume"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 391, GF_LOG_ERROR , "unable to resolve and resume"); } while (0); | |||
392 | if (cs) { | |||
393 | cs->args.getaclreply.status = stat; | |||
394 | acl3_getacl_reply (cs, &cs->args.getaclreply); | |||
395 | nfs3_call_state_wipe (cs); | |||
396 | } | |||
397 | return 0; | |||
398 | } | |||
399 | ||||
400 | rpcerr: | |||
401 | return ret; | |||
402 | } | |||
403 | ||||
404 | int | |||
405 | acl3_setacl_cbk (call_frame_t *frame, void *cookie, | |||
406 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||
407 | dict_t *xdata) | |||
408 | { | |||
409 | nfs3_call_state_t *cs = NULL((void*)0); | |||
410 | cs = frame->local; | |||
411 | if (op_ret < 0) { | |||
412 | cs->args.setaclreply.status = nfs3_errno_to_nfsstat3 (op_errno); | |||
413 | } | |||
414 | ||||
415 | acl3svc_submit_reply (cs->req, (void *)&cs->args.setaclreply, | |||
416 | (acl3_serializer)xdr_serialize_setaclreply); | |||
417 | return 0; | |||
418 | } | |||
419 | ||||
420 | int | |||
421 | acl3_setacl_resume (void *carg) | |||
422 | { | |||
423 | int ret = -1; | |||
424 | nfs3_call_state_t *cs = NULL((void*)0); | |||
425 | nfsstat3 stat = NFS3ERR_SERVERFAULT; | |||
426 | nfs_user_t nfu = {0, }; | |||
427 | dict_t *xattr = NULL((void*)0); | |||
428 | ||||
429 | if (!carg) | |||
430 | return ret; | |||
431 | ||||
432 | cs = (nfs3_call_state_t *)carg; | |||
433 | acl3_check_fh_resolve_status (cs, stat, acl3err)do { xlator_t *xlatorp = ((void*)0); char buf[256], gfid[256] ; rpc_transport_t *trans = ((void*)0); if ((cs)->resolve_ret < 0) { trans = ((cs->req)->trans); xlatorp = nfs3_fh_to_xlator (cs->nfs3state, &cs->resolvefh); uuid_unparse (cs-> resolvefh.gfid, gfid); sprintf (buf, "(%s) %s : %s", trans-> peerinfo.identifier, xlatorp ? xlatorp->name : "ERR", gfid ); do { do { if (0) printf ("Unable to resolve FH" ": %s", buf ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 433, GF_LOG_ERROR, "Unable to resolve FH" ": %s", buf); } while (0); stat = nfs3_errno_to_nfsstat3 (cs->resolve_errno); goto acl3err; } } while (0); | |||
434 | nfs_request_user_init (&nfu, cs->req); | |||
435 | xattr = dict_new(); | |||
436 | if (cs->aclcount) | |||
437 | ret = dict_set_static_bin (xattr, "system.posix_acl_access", cs->aclxattr, | |||
438 | cs->aclcount * 8 + 4); | |||
439 | if (cs->daclcount) | |||
440 | ret = dict_set_static_bin (xattr, "system.posix_acl_default", cs->daclxattr, | |||
441 | cs->daclcount * 8 + 4); | |||
442 | ||||
443 | ret = nfs_setxattr (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, xattr, | |||
444 | 0, NULL((void*)0), acl3_setacl_cbk, cs); | |||
445 | dict_unref (xattr); | |||
446 | ||||
447 | acl3err: | |||
448 | if (ret < 0) { | |||
449 | stat = -ret; | |||
450 | gf_log (GF_ACL, GF_LOG_ERROR, "unable to open_and_resume")do { do { if (0) printf ("unable to open_and_resume"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 450, GF_LOG_ERROR , "unable to open_and_resume"); } while (0); | |||
451 | cs->args.setaclreply.status = nfs3_errno_to_nfsstat3 (stat); | |||
452 | acl3svc_submit_reply (cs->req, (void *)&cs->args.setaclreply, | |||
453 | (acl3_serializer)xdr_serialize_setaclreply); | |||
454 | nfs3_call_state_wipe (cs); | |||
455 | } | |||
456 | ||||
457 | return ret; | |||
458 | } | |||
459 | ||||
460 | ||||
461 | int | |||
462 | acl3svc_setacl (rpcsvc_request_t *req) | |||
463 | { | |||
464 | xlator_t *vol = NULL((void*)0); | |||
465 | struct nfs_state *nfs = NULL((void*)0); | |||
466 | nfs3_state_t *nfs3 = NULL((void*)0); | |||
467 | nfs3_call_state_t *cs = NULL((void*)0); | |||
468 | int ret = RPCSVC_ACTOR_ERROR(-1); | |||
469 | nfsstat3 stat = NFS3ERR_SERVERFAULT; | |||
470 | struct nfs3_fh fh; | |||
471 | struct nfs3_fh *fhp = NULL((void*)0); | |||
472 | setaclargs setaclargs; | |||
473 | aclentry aclentry[NFS_ACL_MAX_ENTRIES1024]; | |||
474 | struct aclentry daclentry[NFS_ACL_MAX_ENTRIES1024]; | |||
475 | int *p = NULL((void*)0), i = 0; | |||
476 | ||||
477 | if (!req) | |||
478 | return ret; | |||
479 | ||||
480 | acl3_validate_nfs3_state (req, nfs3, stat, rpcerr, ret)do { nfs3 = (((rpcsvc_program_t *)((req)->prog))->private ); if (!nfs3) { do { do { if (0) printf ("NFSv3 state " "missing from RPC request" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 480, GF_LOG_ERROR, "NFSv3 state " "missing from RPC request" ); } while (0); (req)->rpc_err = SYSTEM_ERR; stat = NFS3ERR_SERVERFAULT ; goto rpcerr; } } while (0);; | |||
481 | nfs = nfs_state (nfs3->nfsx)(nfs3->nfsx)->private; | |||
482 | memset (&setaclargs, 0, sizeof (setaclargs)); | |||
483 | memset (&fh, 0, sizeof (fh)); | |||
484 | setaclargs.fh.n_bytes = (char *)&fh; | |||
485 | setaclargs.aclentry.aclentry_val = aclentry; | |||
486 | setaclargs.daclentry.daclentry_val = daclentry; | |||
487 | if (xdr_to_setaclargs(req->msg[0], &setaclargs) <= 0) { | |||
488 | gf_log (GF_ACL, GF_LOG_ERROR, "Error decoding args")do { do { if (0) printf ("Error decoding args"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 488, GF_LOG_ERROR , "Error decoding args"); } while (0); | |||
489 | rpcsvc_request_seterr (req, GARBAGE_ARGS)(req)->rpc_err = GARBAGE_ARGS; | |||
490 | goto rpcerr; | |||
491 | } | |||
492 | fhp = &fh; | |||
493 | acl3_validate_gluster_fh (fhp, stat, acl3err)do { if (!nfs3_fh_validate (fhp)) { stat = NFS3ERR_SERVERFAULT ; goto acl3err; } } while (0); | |||
494 | acl3_map_fh_to_volume (nfs->nfs3state, fhp, req,do { char exportid[256], gfid[256]; rpc_transport_t *trans = ( (void*)0); vol = nfs3_fh_to_xlator ((nfs->nfs3state), fhp) ; if (!vol) { uuid_unparse (fhp->exportid, exportid); uuid_unparse (fhp->gfid, gfid); trans = ((req)->trans); do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 495, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 495, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); stat = NFS3ERR_STALE; goto acl3err; } else { do { do { if (0) printf ("FH to Volume: %s" ,vol->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 495, GF_LOG_TRACE, "FH to Volume: %s" ,vol-> name); } while (0); (req)->private = (void *)(vol); } } while (0); | |||
495 | vol, stat, acl3err)do { char exportid[256], gfid[256]; rpc_transport_t *trans = ( (void*)0); vol = nfs3_fh_to_xlator ((nfs->nfs3state), fhp) ; if (!vol) { uuid_unparse (fhp->exportid, exportid); uuid_unparse (fhp->gfid, gfid); trans = ((req)->trans); do { do { if (0) printf ("Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 495, GF_LOG_ERROR , "Failed to map " "FH to vol: client=%s, exportid=%s, gfid=%s" , trans->peerinfo.identifier, exportid, gfid); } while (0) ; do { do { if (0) printf ("Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); _gf_log ("nfs""-ACL", "acl3.c" , __FUNCTION__, 495, GF_LOG_ERROR, "Stale nfs client %s must be trying to " "connect to a deleted volume, please " "unmount it.", trans-> peerinfo.identifier); } while (0); stat = NFS3ERR_STALE; goto acl3err; } else { do { do { if (0) printf ("FH to Volume: %s" ,vol->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 495, GF_LOG_TRACE, "FH to Volume: %s" ,vol-> name); } while (0); (req)->private = (void *)(vol); } } while (0);; | |||
496 | acl3_handle_call_state_init (nfs->nfs3state, cs, req,do { cs = nfs3_call_state_init ((nfs->nfs3state), (req), vol ); if (!cs) { do { do { if (0) printf ("Failed to " "init call state" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 497, GF_LOG_ERROR, "Failed to " "init call state"); } while ( 0); stat = NFS3ERR_SERVERFAULT; (req)->rpc_err = SYSTEM_ERR ; goto rpcerr; } } while (0) | |||
497 | vol, stat, rpcerr)do { cs = nfs3_call_state_init ((nfs->nfs3state), (req), vol ); if (!cs) { do { do { if (0) printf ("Failed to " "init call state" ); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 497, GF_LOG_ERROR, "Failed to " "init call state"); } while ( 0); stat = NFS3ERR_SERVERFAULT; (req)->rpc_err = SYSTEM_ERR ; goto rpcerr; } } while (0); | |||
498 | ||||
499 | cs->vol = vol; | |||
500 | acl3_volume_started_check (nfs3, vol, ret, rpcerr)do { if ((!nfs_subvolume_started ((nfs3->nfsx)->private , vol))){ do { do { if (0) printf ("Volume is disabled: %s", vol ->name); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__ , 500, GF_LOG_ERROR, "Volume is disabled: %s", vol->name); } while (0); ret = (-2); goto rpcerr; } } while (0); | |||
501 | ||||
502 | cs->aclcount = setaclargs.aclcount; | |||
503 | cs->daclcount = setaclargs.daclcount; | |||
504 | ||||
505 | if ((cs->aclcount > NFS_ACL_MAX_ENTRIES1024) || | |||
506 | (cs->daclcount > NFS_ACL_MAX_ENTRIES1024)) | |||
507 | goto acl3err; | |||
508 | /* FIXME: use posix_acl_to_xattr() */ | |||
509 | p = (int *)cs->aclxattr; | |||
510 | *(*(int **)&p)++ = POSIX_ACL_XATTR_VERSION0x0002; | |||
511 | for (i = 0; i < cs->aclcount; i++) { | |||
512 | *(*(short **)&p)++ = aclentry[i].type; | |||
513 | *(*(short **)&p)++ = aclentry[i].perm; | |||
514 | *(*(int **)&p)++ = aclentry[i].uid; | |||
515 | } | |||
516 | p = (int *)cs->daclxattr; | |||
517 | *(*(int **)&p)++ = POSIX_ACL_XATTR_VERSION0x0002; | |||
518 | for (i = 0; i < cs->daclcount; i++) { | |||
519 | *(*(short **)&p)++ = daclentry[i].type; | |||
520 | *(*(short **)&p)++ = daclentry[i].perm; | |||
521 | *(*(int **)&p)++ = daclentry[i].uid; | |||
522 | } | |||
523 | ||||
524 | ||||
525 | ret = nfs3_fh_resolve_and_resume (cs, fhp, | |||
526 | NULL((void*)0), acl3_setacl_resume); | |||
527 | ||||
528 | acl3err: | |||
529 | if (ret < 0) { | |||
530 | gf_log (GF_ACL, GF_LOG_ERROR, "unable to resolve and resume")do { do { if (0) printf ("unable to resolve and resume"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 530, GF_LOG_ERROR , "unable to resolve and resume"); } while (0); | |||
531 | cs->args.setaclreply.status = stat; | |||
532 | acl3svc_submit_reply (cs->req, (void *)&cs->args.setaclreply, | |||
533 | (acl3_serializer)xdr_serialize_setaclreply); | |||
534 | nfs3_call_state_wipe (cs); | |||
535 | return 0; | |||
536 | } | |||
537 | ||||
538 | rpcerr: | |||
539 | if (ret < 0) | |||
540 | nfs3_call_state_wipe (cs); | |||
541 | ||||
542 | return ret; | |||
543 | } | |||
544 | ||||
545 | ||||
546 | ||||
547 | ||||
548 | rpcsvc_actor_t acl3svc_actors[ACL3_PROC_COUNT3] = { | |||
549 | {"NULL", ACL3_NULL0, acl3svc_null, NULL((void*)0), 0}, | |||
550 | {"GETACL", ACL3_GETACL1, acl3svc_getacl, NULL((void*)0), 0}, | |||
551 | {"SETACL", ACL3_SETACL2, acl3svc_setacl, NULL((void*)0), 0}, | |||
552 | }; | |||
553 | ||||
554 | rpcsvc_program_t acl3prog = { | |||
555 | .progname = "ACL3", | |||
556 | .prognum = ACL_PROGRAM100227, | |||
557 | .progver = ACL_V33, | |||
558 | .progport = GF_NFS3_PORT2049, | |||
559 | .actors = acl3svc_actors, | |||
560 | .numactors = ACL3_PROC_COUNT3, | |||
561 | .min_auth = AUTH_NULL0, | |||
562 | }; | |||
563 | ||||
564 | rpcsvc_program_t * | |||
565 | acl3svc_init(xlator_t *nfsx) | |||
566 | { | |||
567 | struct nfs3_state *ns = NULL((void*)0); | |||
568 | struct nfs_state *nfs = NULL((void*)0); | |||
569 | dict_t *options = NULL((void*)0); | |||
570 | int ret = -1; | |||
571 | char *portstr = NULL((void*)0); | |||
572 | ||||
573 | nfs = (struct nfs_state*)nfsx->private; | |||
574 | ||||
575 | ns = nfs->nfs3state; | |||
576 | if (!ns) { | |||
577 | gf_log (GF_ACL, GF_LOG_ERROR, "ACL3 init failed")do { do { if (0) printf ("ACL3 init failed"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 577, GF_LOG_ERROR, "ACL3 init failed" ); } while (0); | |||
578 | goto err; | |||
579 | } | |||
580 | acl3prog.private = ns; | |||
581 | ||||
582 | options = dict_new (); | |||
583 | ||||
584 | ret = gf_asprintf (&portstr, "%d", GF_ACL3_PORT38469); | |||
585 | if (ret == -1) | |||
586 | goto err; | |||
587 | ||||
588 | ret = dict_set_dynstr (options, "transport.socket.listen-port", | |||
589 | portstr); | |||
590 | if (ret == -1) | |||
591 | goto err; | |||
592 | ret = dict_set_str (options, "transport-type", "socket"); | |||
593 | if (ret == -1) { | |||
594 | gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error")do { do { if (0) printf ("dict_set_str error"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 594, GF_LOG_ERROR, "dict_set_str error" ); } while (0); | |||
595 | goto err; | |||
596 | } | |||
597 | ||||
598 | if (nfs->allow_insecure) { | |||
599 | ret = dict_set_str (options, "rpc-auth-allow-insecure", "on"); | |||
600 | if (ret == -1) { | |||
601 | gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error")do { do { if (0) printf ("dict_set_str error"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 601, GF_LOG_ERROR, "dict_set_str error" ); } while (0); | |||
602 | goto err; | |||
603 | } | |||
604 | ret = dict_set_str (options, "rpc-auth.ports.insecure", "on"); | |||
605 | if (ret == -1) { | |||
606 | gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error")do { do { if (0) printf ("dict_set_str error"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 606, GF_LOG_ERROR, "dict_set_str error" ); } while (0); | |||
607 | goto err; | |||
608 | } | |||
609 | } | |||
610 | ||||
611 | ret = dict_set_str (options, "transport.address-family", "inet"); | |||
612 | if (ret == -1) { | |||
613 | gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error")do { do { if (0) printf ("dict_set_str error"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 613, GF_LOG_ERROR, "dict_set_str error" ); } while (0); | |||
614 | goto err; | |||
615 | } | |||
616 | ||||
617 | rpcsvc_create_listeners (nfs->rpcsvc, options, "ACL"); | |||
618 | if (ret == -1) { | |||
619 | gf_log (GF_ACL, GF_LOG_ERROR, "Unable to create listeners")do { do { if (0) printf ("Unable to create listeners"); } while (0); _gf_log ("nfs""-ACL", "acl3.c", __FUNCTION__, 619, GF_LOG_ERROR , "Unable to create listeners"); } while (0); | |||
620 | dict_unref (options); | |||
621 | goto err; | |||
622 | } | |||
623 | ||||
624 | return &acl3prog; | |||
625 | err: | |||
626 | return NULL((void*)0); | |||
627 | } |