Lines 169-174
Link Here
|
169 |
bool must_add_empty_ace = false; |
169 |
bool must_add_empty_ace = false; |
170 |
struct zfsacl_config_data *config = NULL; |
170 |
struct zfsacl_config_data *config = NULL; |
171 |
int fd; |
171 |
int fd; |
|
|
172 |
struct sys_proc_fd_path_buf buf; |
172 |
|
173 |
|
173 |
SMB_VFS_HANDLE_GET_DATA(handle, config, |
174 |
SMB_VFS_HANDLE_GET_DATA(handle, config, |
174 |
struct zfsacl_config_data, |
175 |
struct zfsacl_config_data, |
Lines 235-258
Link Here
|
235 |
SMB_ASSERT(i == naces); |
236 |
SMB_ASSERT(i == naces); |
236 |
|
237 |
|
237 |
/* store acl */ |
238 |
/* store acl */ |
238 |
fd = fsp_get_pathref_fd(fsp); |
239 |
|
239 |
if (fd == -1) { |
240 |
if (!fsp->fsp_flags.is_pathref) { |
|
|
241 |
fd = fsp_get_io_fd(fsp); |
242 |
|
243 |
rv = facl(fd, ACE_SETACL, naces, acebuf); |
244 |
if (rv != 0) { |
245 |
DEBUG(8, ("zfs_process_smbacl(%s): Not PATHREF: facl(ACE_SETACL, %d): %s\n", |
246 |
fsp_str_dbg(fsp), naces, |
247 |
strerror(errno))); |
248 |
return false; |
249 |
} |
250 |
DEBUG(10, ("zfs_process_smbacl(%s): Not PATHREF: facl(ACE_SETACL, %d) -> %d\n", |
251 |
fsp_str_dbg(fsp), naces, |
252 |
rv)); |
253 |
|
254 |
} else if (fsp->fsp_flags.have_proc_fds) { |
255 |
fd = fsp_get_pathref_fd(fsp); |
256 |
if (fd == -1) { |
257 |
DEBUG(8, ("zfs_process_smbacl(%s): PATHREF(proc_fd): fsp_get_pathref_fd=-1: %s\n", |
258 |
fsp_str_dbg(fsp), strerror(errno))); |
240 |
errno = EBADF; |
259 |
errno = EBADF; |
241 |
return false; |
260 |
return false; |
242 |
} |
261 |
} |
243 |
rv = facl(fd, ACE_SETACL, naces, acebuf); |
262 |
rv = acl(sys_proc_fd_path(fd, &buf), ACE_SETACL, naces, acebuf); |
244 |
if (rv != 0) { |
263 |
if (rv != 0) { |
245 |
if(errno == ENOSYS) { |
264 |
DEBUG(8, ("zfs_process_smbacl(%s): acl(ACE_SETACL, %d): %s\n", |
246 |
DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not " |
265 |
fsp_str_dbg(fsp), naces, |
247 |
"supported on the filesystem where the file " |
266 |
strerror(errno))); |
248 |
"resides\n", fsp_str_dbg(fsp))); |
|
|
249 |
} else { |
250 |
DEBUG(9, ("acl(ACE_SETACL, %s): %s\n", fsp_str_dbg(fsp), |
251 |
strerror(errno))); |
252 |
} |
253 |
return false; |
267 |
return false; |
|
|
268 |
} |
269 |
DEBUG(10, ("zfs_process_smbacl(%s): PATHREF(proc_fd): acl(ACE_SETACL, %d) -> %d\n", |
270 |
fsp_str_dbg(fsp), naces, |
271 |
rv)); |
272 |
} else { |
273 |
rv = acl(fsp->fsp_name->base_name, ACE_SETACL, naces, acebuf); |
274 |
if (rv != 0) { |
275 |
DEBUG(8, ("zfs_process_smbacl(%s): PATHREF(base_name): acl(ACE_SETACL, %d): %s\n", |
276 |
fsp_str_dbg(fsp), naces, |
277 |
strerror(errno))); |
278 |
return false; |
279 |
} |
280 |
DEBUG(10, ("zfs_process_smbacl(%s): PATHREF(base_name): facl(ACE_SETACL, %d) -> %d\n", |
281 |
fsp_str_dbg(fsp), naces, |
282 |
rv)); |
254 |
} |
283 |
} |
255 |
|
284 |
|
256 |
return True; |
285 |
return True; |
257 |
} |
286 |
} |
258 |
|
287 |
|
Lines 282-306
Link Here
|
282 |
struct files_struct *fsp, |
311 |
struct files_struct *fsp, |
283 |
ace_t **outbuf) |
312 |
ace_t **outbuf) |
284 |
{ |
313 |
{ |
285 |
int naces, rv; |
314 |
int naces, rv = -1, fd = -1; |
286 |
ace_t *acebuf = NULL; |
315 |
ace_t *acebuf = NULL; |
287 |
int fd; |
316 |
struct sys_proc_fd_path_buf buf; |
288 |
|
317 |
|
289 |
fd = fsp_get_pathref_fd(fsp); |
318 |
|
290 |
if (fd == -1) { |
319 |
if (!fsp->fsp_flags.is_pathref) { |
|
|
320 |
fd = fsp_get_io_fd(fsp); |
321 |
if (fd == -1) { |
322 |
DEBUG(8, ("fget_zfsacl(%s): Not PATHREF: fsp_get_io_fd=-1: %s\n", |
323 |
fsp_str_dbg(fsp), strerror(errno))); |
291 |
errno = EBADF; |
324 |
errno = EBADF; |
292 |
return -1; |
325 |
return -1; |
293 |
} |
326 |
} |
294 |
naces = facl(fd, ACE_GETACLCNT, 0, NULL); |
327 |
naces = facl(fd, ACE_GETACLCNT, 0, NULL); |
295 |
if (naces == -1) { |
328 |
if (naces == -1) { |
296 |
int dbg_level = 10; |
329 |
DEBUG(8, ("fget_zfsacl(%s): Not PATHREF: facl(ACE_GETACLCNT): %s\n", |
297 |
|
330 |
fsp_str_dbg(fsp), strerror(errno))); |
298 |
if (errno == ENOSYS) { |
331 |
return -1; |
299 |
dbg_level = 1; |
332 |
} |
300 |
} |
333 |
} else if (fsp->fsp_flags.have_proc_fds) { |
301 |
DEBUG(dbg_level, ("facl(ACE_GETACLCNT, %s): %s\n", |
334 |
fd = fsp_get_pathref_fd(fsp); |
|
|
335 |
if (fd == -1) { |
336 |
DEBUG(8, ("fget_zfsacl(%s): PATHREF(proc_fd): fsp_get_pathref_fd=-1: %s\n", |
337 |
fsp_str_dbg(fsp), strerror(errno))); |
338 |
errno = EBADF; |
339 |
return -1; |
340 |
} |
341 |
naces = acl(sys_proc_fd_path(fd, &buf), ACE_GETACLCNT, 0, NULL); |
342 |
if (naces == -1) { |
343 |
DEBUG(8, ("fget_zfsacl(%s): PATHREF(proc_fd): acl(ACE_GETACLCNT): %s\n", |
302 |
fsp_str_dbg(fsp), strerror(errno))); |
344 |
fsp_str_dbg(fsp), strerror(errno))); |
303 |
return naces; |
345 |
return -1; |
|
|
346 |
} |
347 |
} else { |
348 |
naces = acl(fsp->fsp_name->base_name, ACE_GETACLCNT, 0, NULL); |
349 |
if (naces == -1) { |
350 |
DEBUG(8, ("fget_zfsacl(%s): PATHREF(base_name): acl(ACE_GETACLCNT): %s\n", |
351 |
fsp_str_dbg(fsp), strerror(errno))); |
352 |
return -1; |
353 |
} |
304 |
} |
354 |
} |
305 |
|
355 |
|
306 |
acebuf = talloc_size(mem_ctx, sizeof(ace_t)*naces); |
356 |
acebuf = talloc_size(mem_ctx, sizeof(ace_t)*naces); |
Lines 309-323
Link Here
|
309 |
return -1; |
359 |
return -1; |
310 |
} |
360 |
} |
311 |
|
361 |
|
312 |
rv = facl(fd, ACE_GETACL, naces, acebuf); |
362 |
if (!fsp->fsp_flags.is_pathref) { |
313 |
if (rv == -1) { |
363 |
rv = facl(fd, ACE_GETACL, naces, acebuf); |
314 |
DBG_DEBUG("acl(ACE_GETACL, %s): %s\n", |
364 |
if (rv == -1) { |
315 |
fsp_str_dbg(fsp), strerror(errno)); |
365 |
DEBUG(8, ("fget_zfsacl(%s): Not PATHREF: facl(ACE_GETACL): %s\n", |
|
|
366 |
fsp_str_dbg(fsp), strerror(errno))); |
316 |
return -1; |
367 |
return -1; |
|
|
368 |
} |
369 |
DEBUG(10, ("fget_zfsacl(%s): Not PATHREF: facl(ACE_GETACL) -> %d entries\n", |
370 |
fsp_str_dbg(fsp), rv)); |
371 |
} else if (fsp->fsp_flags.have_proc_fds) { |
372 |
rv = acl(sys_proc_fd_path(fd, &buf), ACE_GETACL, naces, acebuf); |
373 |
if (rv == -1) { |
374 |
DEBUG(8, ("fget_zfsacl(%s): PATHREF(proc_fd): acl(ACE_GETACL): %s\n", |
375 |
fsp_str_dbg(fsp), strerror(errno))); |
376 |
return -1; |
377 |
} |
378 |
DEBUG(10, ("fget_zfsacl(%s): PATHREF(proc_fd): acl(ACE_GETACL) -> %d entries\n", |
379 |
fsp_str_dbg(fsp), rv)); |
380 |
} else { |
381 |
rv = acl(fsp->fsp_name->base_name, ACE_GETACL, naces, acebuf); |
382 |
if (rv == -1) { |
383 |
DEBUG(8, ("fget_zfsacl(%s): PATHREF(base_name): acl(ACE_GETACL): %s\n", |
384 |
fsp_str_dbg(fsp), strerror(errno))); |
385 |
return -1; |
386 |
} |
387 |
DEBUG(10, ("fget_zfsacl(%s): PATHREF(base_name): acl(ACE_GETACL) -> %d entries\n", |
388 |
fsp_str_dbg(fsp), rv)); |
317 |
} |
389 |
} |
318 |
|
390 |
|
319 |
*outbuf = acebuf; |
391 |
*outbuf = acebuf; |
320 |
return naces; |
392 |
return rv; |
321 |
} |
393 |
} |
322 |
|
394 |
|
323 |
static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, |
395 |
static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, |