View | Details | Raw Unified | Return to bug 277878 | Differences between
and this patch

Collapse All | Expand All

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

Return to bug 277878