Line data Source code
1 : /*
2 : * Fake ACLs VFS module. Implements passthrough operation of all VFS
3 : * calls to disk functions, except for file ownership and ACLs, which
4 : * are stored in xattrs.
5 : *
6 : * Copyright (C) Tim Potter, 1999-2000
7 : * Copyright (C) Alexander Bokovoy, 2002
8 : * Copyright (C) Andrew Bartlett, 2002,2012
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 3 of the License, or
13 : * (at your option) any later version.
14 : *
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.
19 : *
20 : * You should have received a copy of the GNU General Public License
21 : * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 : */
23 :
24 : #include "includes.h"
25 : #include "smbd/smbd.h"
26 : #include "system/filesys.h"
27 : #include "auth.h"
28 : #include "librpc/gen_ndr/ndr_smb_acl.h"
29 :
30 : #undef DBGC_CLASS
31 : #define DBGC_CLASS DBGC_VFS
32 :
33 : #define FAKE_UID "system.fake_uid"
34 : #define FAKE_GID "system.fake_gid"
35 : #define FAKE_ACL_ACCESS_XATTR "system.fake_access_acl"
36 : #define FAKE_ACL_DEFAULT_XATTR "system.fake_default_acl"
37 :
38 : struct in_pathref_data {
39 : bool calling_pathref_fsp;
40 : };
41 :
42 221369 : static int fake_acls_fuid(vfs_handle_struct *handle,
43 : files_struct *fsp,
44 : uid_t *uid)
45 : {
46 : ssize_t size;
47 : uint8_t uid_buf[4];
48 :
49 221369 : size = SMB_VFS_NEXT_FGETXATTR(handle, fsp, FAKE_UID, uid_buf, sizeof(uid_buf));
50 221369 : if (size == -1 && errno == ENOATTR) {
51 163130 : return 0;
52 : }
53 58239 : if (size != 4) {
54 0 : return -1;
55 : }
56 58239 : *uid = IVAL(uid_buf, 0);
57 58239 : return 0;
58 : }
59 :
60 221369 : static int fake_acls_fgid(vfs_handle_struct *handle,
61 : files_struct *fsp,
62 : uid_t *gid)
63 : {
64 : ssize_t size;
65 : uint8_t gid_buf[4];
66 :
67 221369 : size = SMB_VFS_NEXT_FGETXATTR(handle, fsp, FAKE_GID, gid_buf, sizeof(gid_buf));
68 221369 : if (size == -1 && errno == ENOATTR) {
69 163130 : return 0;
70 : }
71 58239 : if (size != 4) {
72 0 : return -1;
73 : }
74 58239 : *gid = IVAL(gid_buf, 0);
75 58239 : return 0;
76 : }
77 :
78 141560 : static int fake_acls_stat(vfs_handle_struct *handle,
79 : struct smb_filename *smb_fname)
80 : {
81 141560 : int ret = -1;
82 141560 : struct in_pathref_data *prd = NULL;
83 141560 : struct smb_filename *smb_fname_cp = NULL;
84 141560 : struct files_struct *fsp = NULL;
85 :
86 141560 : SMB_VFS_HANDLE_GET_DATA(handle,
87 : prd,
88 : struct in_pathref_data,
89 : return -1);
90 :
91 141560 : ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
92 141560 : if (ret != 0) {
93 205 : return ret;
94 : }
95 :
96 141355 : if (smb_fname->fsp != NULL) {
97 0 : fsp = metadata_fsp(smb_fname->fsp);
98 : } else {
99 : NTSTATUS status;
100 :
101 : /*
102 : * Ensure openat_pathref_fsp()
103 : * can't recurse into fake_acls_stat().
104 : * openat_pathref_fsp() doesn't care
105 : * about the uid/gid values, it only
106 : * wants a valid/invalid stat answer
107 : * and we know smb_fname exists as
108 : * the SMB_VFS_NEXT_STAT() returned
109 : * zero above.
110 : */
111 141355 : if (prd->calling_pathref_fsp) {
112 128858 : return 0;
113 : }
114 :
115 : /*
116 : * openat_pathref_fsp() expects a talloc'ed
117 : * smb_filename. stat can be passed a struct
118 : * from the stack. Make a talloc'ed copy
119 : * so openat_pathref_fsp() can add its
120 : * destructor.
121 : */
122 75584 : smb_fname_cp = cp_smb_filename(talloc_tos(),
123 : smb_fname);
124 75584 : if (smb_fname_cp == NULL) {
125 0 : errno = ENOMEM;
126 0 : return -1;
127 : }
128 :
129 : /* Recursion guard. */
130 75584 : prd->calling_pathref_fsp = true;
131 75584 : status = openat_pathref_fsp(handle->conn->cwd_fsp,
132 : smb_fname_cp);
133 : /* End recursion guard. */
134 75584 : prd->calling_pathref_fsp = false;
135 :
136 75584 : if (!NT_STATUS_IS_OK(status)) {
137 : /*
138 : * Ignore errors here. We know
139 : * the path exists (the SMB_VFS_NEXT_STAT()
140 : * above succeeded. So being unable to
141 : * open a pathref fsp can be due to a
142 : * range of errors (startup path beginning
143 : * with '/' for example, path = ".." when
144 : * enumerating a directory. Just treat this
145 : * the same way as the path not having the
146 : * FAKE_UID or FAKE_GID EA's present. For the
147 : * test purposes of this module (fake NT ACLs
148 : * from windows clients) this is close enough.
149 : * Just report for debugging purposes.
150 : */
151 10123 : DBG_DEBUG("Unable to get pathref fsp on %s. "
152 : "Error %s\n",
153 : smb_fname_str_dbg(smb_fname_cp),
154 : nt_errstr(status));
155 10123 : TALLOC_FREE(smb_fname_cp);
156 10123 : return 0;
157 : }
158 65461 : fsp = smb_fname_cp->fsp;
159 : }
160 :
161 65461 : ret = fake_acls_fuid(handle,
162 : fsp,
163 : &smb_fname->st.st_ex_uid);
164 65461 : if (ret != 0) {
165 0 : TALLOC_FREE(smb_fname_cp);
166 0 : return ret;
167 : }
168 65461 : ret = fake_acls_fgid(handle,
169 : fsp,
170 65461 : &smb_fname->st.st_ex_gid);
171 65461 : if (ret != 0) {
172 0 : TALLOC_FREE(smb_fname_cp);
173 0 : return ret;
174 : }
175 65461 : TALLOC_FREE(smb_fname_cp);
176 65461 : return ret;
177 : }
178 :
179 1896 : static int fake_acls_lstat(vfs_handle_struct *handle,
180 : struct smb_filename *smb_fname)
181 : {
182 1896 : int ret = -1;
183 1896 : struct in_pathref_data *prd = NULL;
184 :
185 1896 : SMB_VFS_HANDLE_GET_DATA(handle,
186 : prd,
187 : struct in_pathref_data,
188 : return -1);
189 :
190 1896 : ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
191 1896 : if (ret == 0) {
192 1896 : struct smb_filename *smb_fname_base = NULL;
193 1896 : SMB_STRUCT_STAT sbuf = { 0 };
194 : NTSTATUS status;
195 :
196 : /*
197 : * Ensure synthetic_pathref()
198 : * can't recurse into fake_acls_lstat().
199 : * synthetic_pathref() doesn't care
200 : * about the uid/gid values, it only
201 : * wants a valid/invalid stat answer
202 : * and we know smb_fname exists as
203 : * the SMB_VFS_NEXT_LSTAT() returned
204 : * zero above.
205 : */
206 1896 : if (prd->calling_pathref_fsp) {
207 0 : return 0;
208 : }
209 :
210 : /* Recursion guard. */
211 1896 : prd->calling_pathref_fsp = true;
212 3692 : status = synthetic_pathref(talloc_tos(),
213 1896 : handle->conn->cwd_fsp,
214 1896 : smb_fname->base_name,
215 : NULL,
216 : &sbuf,
217 : smb_fname->twrp,
218 : 0, /* we want stat, not lstat. */
219 : &smb_fname_base);
220 : /* End recursion guard. */
221 1896 : prd->calling_pathref_fsp = false;
222 1896 : if (NT_STATUS_IS_OK(status)) {
223 : /*
224 : * This isn't quite right (calling fgetxattr not
225 : * lgetxattr), but for the test purposes of this
226 : * module (fake NT ACLs from windows clients), it is
227 : * close enough. We removed the l*xattr functions
228 : * because linux doesn't support using them, but we
229 : * could fake them in xattr_tdb if we really wanted
230 : * to. We ignore errors because the link might not
231 : * point anywhere */
232 3692 : fake_acls_fuid(handle,
233 1896 : smb_fname_base->fsp,
234 : &smb_fname->st.st_ex_uid);
235 1896 : fake_acls_fgid(handle,
236 1896 : smb_fname_base->fsp,
237 1896 : &smb_fname->st.st_ex_gid);
238 : }
239 1896 : TALLOC_FREE(smb_fname_base);
240 : }
241 :
242 1896 : return ret;
243 : }
244 :
245 154012 : static int fake_acls_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
246 : {
247 154012 : int ret = -1;
248 :
249 154012 : ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
250 154012 : if (ret == 0) {
251 154012 : ret = fake_acls_fuid(handle, fsp, &sbuf->st_ex_uid);
252 154012 : if (ret != 0) {
253 0 : return ret;
254 : }
255 154012 : ret = fake_acls_fgid(handle, fsp, &sbuf->st_ex_gid);
256 154012 : if (ret != 0) {
257 0 : return ret;
258 : }
259 : }
260 154012 : return ret;
261 : }
262 :
263 10778 : static SMB_ACL_T fake_acls_blob2acl(DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
264 : {
265 : enum ndr_err_code ndr_err;
266 10778 : struct smb_acl_t *acl = talloc(mem_ctx, struct smb_acl_t);
267 10778 : if (!acl) {
268 0 : errno = ENOMEM;
269 0 : return NULL;
270 : }
271 :
272 10778 : ndr_err = ndr_pull_struct_blob(blob, acl, acl,
273 : (ndr_pull_flags_fn_t)ndr_pull_smb_acl_t);
274 :
275 10778 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
276 0 : DEBUG(0, ("ndr_pull_acl_t failed: %s\n",
277 : ndr_errstr(ndr_err)));
278 0 : TALLOC_FREE(acl);
279 0 : return NULL;
280 : }
281 10778 : return acl;
282 : }
283 :
284 1718 : static DATA_BLOB fake_acls_acl2blob(TALLOC_CTX *mem_ctx, SMB_ACL_T acl)
285 : {
286 : enum ndr_err_code ndr_err;
287 : DATA_BLOB blob;
288 1718 : ndr_err = ndr_push_struct_blob(&blob, mem_ctx, acl,
289 : (ndr_push_flags_fn_t)ndr_push_smb_acl_t);
290 :
291 1718 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
292 0 : DEBUG(0, ("ndr_push_acl_t failed: %s\n",
293 : ndr_errstr(ndr_err)));
294 0 : return data_blob_null;
295 : }
296 1718 : return blob;
297 : }
298 :
299 26006 : static SMB_ACL_T fake_acls_sys_acl_get_fd(struct vfs_handle_struct *handle,
300 : files_struct *fsp,
301 : SMB_ACL_TYPE_T type,
302 : TALLOC_CTX *mem_ctx)
303 : {
304 26006 : DATA_BLOB blob = data_blob_null;
305 : ssize_t length;
306 26006 : const char *name = NULL;
307 26006 : struct smb_acl_t *acl = NULL;
308 26006 : TALLOC_CTX *frame = talloc_stackframe();
309 :
310 26006 : switch (type) {
311 15270 : case SMB_ACL_TYPE_ACCESS:
312 15270 : name = FAKE_ACL_ACCESS_XATTR;
313 15270 : break;
314 10736 : case SMB_ACL_TYPE_DEFAULT:
315 10736 : name = FAKE_ACL_DEFAULT_XATTR;
316 10736 : break;
317 0 : default:
318 0 : DBG_ERR("Illegal ACL type %d\n", (int)type);
319 0 : break;
320 : }
321 :
322 26006 : if (name == NULL) {
323 0 : TALLOC_FREE(frame);
324 0 : return NULL;
325 : }
326 :
327 : do {
328 26006 : blob.length += 1000;
329 26006 : blob.data = talloc_realloc(frame, blob.data, uint8_t, blob.length);
330 26006 : if (!blob.data) {
331 0 : errno = ENOMEM;
332 0 : TALLOC_FREE(frame);
333 0 : return NULL;
334 : }
335 26006 : length = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, blob.data, blob.length);
336 26006 : blob.length = length;
337 26006 : } while (length == -1 && errno == ERANGE);
338 26006 : if (length == -1 && errno == ENOATTR) {
339 15228 : TALLOC_FREE(frame);
340 15228 : return NULL;
341 : }
342 10778 : if (length != -1) {
343 10778 : acl = fake_acls_blob2acl(&blob, mem_ctx);
344 : }
345 10778 : TALLOC_FREE(frame);
346 10778 : return acl;
347 : }
348 :
349 1718 : static int fake_acls_sys_acl_set_fd(vfs_handle_struct *handle,
350 : struct files_struct *fsp,
351 : SMB_ACL_TYPE_T type,
352 : SMB_ACL_T theacl)
353 : {
354 : int ret;
355 1718 : const char *name = NULL;
356 1718 : TALLOC_CTX *frame = talloc_stackframe();
357 1718 : DATA_BLOB blob = fake_acls_acl2blob(frame, theacl);
358 1718 : if (!blob.data) {
359 0 : DEBUG(0, ("Failed to convert ACL to linear blob for xattr storage\n"));
360 0 : TALLOC_FREE(frame);
361 0 : errno = EINVAL;
362 0 : return -1;
363 : }
364 :
365 1718 : switch (type) {
366 1045 : case SMB_ACL_TYPE_ACCESS:
367 1045 : name = FAKE_ACL_ACCESS_XATTR;
368 1045 : break;
369 673 : case SMB_ACL_TYPE_DEFAULT:
370 673 : name = FAKE_ACL_DEFAULT_XATTR;
371 673 : break;
372 0 : default:
373 0 : errno = EINVAL;
374 0 : return -1;
375 : }
376 :
377 1718 : ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, blob.data, blob.length, 0);
378 1718 : TALLOC_FREE(frame);
379 1718 : return ret;
380 : }
381 :
382 5 : static int fake_acls_sys_acl_delete_def_fd(vfs_handle_struct *handle,
383 : struct files_struct *fsp)
384 : {
385 : int ret;
386 5 : const char *name = FAKE_ACL_DEFAULT_XATTR;
387 :
388 5 : if (!fsp->fsp_flags.is_directory) {
389 0 : errno = EINVAL;
390 0 : return -1;
391 : }
392 :
393 5 : ret = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
394 5 : if (ret == -1 && errno == ENOATTR) {
395 1 : ret = 0;
396 1 : errno = 0;
397 : }
398 :
399 5 : return ret;
400 : }
401 :
402 0 : static int fake_acls_lchown(vfs_handle_struct *handle,
403 : const struct smb_filename *smb_fname,
404 : uid_t uid,
405 : gid_t gid)
406 : {
407 : int ret;
408 : uint8_t id_buf[4];
409 0 : if (uid != -1) {
410 0 : uid_t current_uid = get_current_uid(handle->conn);
411 :
412 0 : if (current_uid != 0 && current_uid != uid) {
413 0 : return EACCES;
414 : }
415 :
416 : /* This isn't quite right (calling setxattr not
417 : * lsetxattr), but for the test purposes of this
418 : * module (fake NT ACLs from windows clients), it is
419 : * close enough. We removed the l*xattr functions
420 : * because linux doesn't support using them, but we
421 : * could fake them in xattr_tdb if we really wanted
422 : * to.
423 : */
424 0 : SIVAL(id_buf, 0, uid);
425 0 : ret = SMB_VFS_NEXT_FSETXATTR(handle,
426 : smb_fname->fsp,
427 : FAKE_UID,
428 : id_buf,
429 : sizeof(id_buf),
430 : 0);
431 0 : if (ret != 0) {
432 0 : return ret;
433 : }
434 : }
435 0 : if (gid != -1) {
436 0 : SIVAL(id_buf, 0, gid);
437 0 : ret = SMB_VFS_NEXT_FSETXATTR(handle,
438 : smb_fname->fsp,
439 : FAKE_GID,
440 : id_buf,
441 : sizeof(id_buf),
442 : 0);
443 0 : if (ret != 0) {
444 0 : return ret;
445 : }
446 : }
447 0 : return 0;
448 : }
449 :
450 2729 : static int fake_acls_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)
451 : {
452 : int ret;
453 : uint8_t id_buf[4];
454 2729 : if (uid != -1) {
455 2725 : uid_t current_uid = get_current_uid(handle->conn);
456 :
457 2725 : if (current_uid != 0 && current_uid != uid) {
458 352 : return EACCES;
459 : }
460 :
461 2373 : SIVAL(id_buf, 0, uid);
462 2373 : ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, FAKE_UID, id_buf, sizeof(id_buf), 0);
463 2373 : if (ret != 0) {
464 0 : return ret;
465 : }
466 : }
467 2377 : if (gid != -1) {
468 2377 : SIVAL(id_buf, 0, gid);
469 2377 : ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, FAKE_GID, id_buf, sizeof(id_buf), 0);
470 2377 : if (ret != 0) {
471 0 : return ret;
472 : }
473 : }
474 2377 : return 0;
475 : }
476 :
477 : /*
478 : * Implement the chmod uid/mask/other mode changes on a fake ACL.
479 : */
480 :
481 0 : static int fake_acl_process_chmod(SMB_ACL_T *pp_the_acl,
482 : uid_t owner,
483 : mode_t mode)
484 : {
485 0 : bool got_mask = false;
486 0 : int entry_id = SMB_ACL_FIRST_ENTRY;
487 0 : mode_t umode = 0;
488 0 : mode_t mmode = 0;
489 0 : mode_t omode = 0;
490 0 : int ret = -1;
491 0 : SMB_ACL_T the_acl = *pp_the_acl;
492 :
493 : /* Split the mode into u/mask/other masks. */
494 0 : umode = unix_perms_to_acl_perms(mode, S_IRUSR, S_IWUSR, S_IXUSR);
495 0 : mmode = unix_perms_to_acl_perms(mode, S_IRGRP, S_IWGRP, S_IXGRP);
496 0 : omode = unix_perms_to_acl_perms(mode, S_IROTH, S_IWOTH, S_IXOTH);
497 :
498 0 : while (1) {
499 : SMB_ACL_ENTRY_T entry;
500 : SMB_ACL_TAG_T tagtype;
501 : SMB_ACL_PERMSET_T permset;
502 0 : uid_t *puid = NULL;
503 :
504 0 : ret = sys_acl_get_entry(the_acl,
505 : entry_id,
506 : &entry);
507 0 : if (ret == 0) {
508 : /* End of ACL */
509 0 : break;
510 : }
511 0 : if (ret == -1) {
512 0 : return -1;
513 : }
514 :
515 0 : ret = sys_acl_get_tag_type(entry, &tagtype);
516 0 : if (ret == -1) {
517 0 : return -1;
518 : }
519 0 : ret = sys_acl_get_permset(entry, &permset);
520 0 : if (ret == -1) {
521 0 : return -1;
522 : }
523 0 : switch (tagtype) {
524 0 : case SMB_ACL_USER_OBJ:
525 0 : ret = map_acl_perms_to_permset(umode, &permset);
526 0 : if (ret == -1) {
527 0 : return -1;
528 : }
529 0 : break;
530 0 : case SMB_ACL_USER:
531 0 : puid = (uid_t *)sys_acl_get_qualifier(entry);
532 0 : if (puid == NULL) {
533 0 : return -1;
534 : }
535 0 : if (owner != *puid) {
536 0 : break;
537 : }
538 0 : ret = map_acl_perms_to_permset(umode, &permset);
539 0 : if (ret == -1) {
540 0 : return -1;
541 : }
542 0 : break;
543 0 : case SMB_ACL_GROUP_OBJ:
544 : case SMB_ACL_GROUP:
545 : /* Ignore all group entries. */
546 0 : break;
547 0 : case SMB_ACL_MASK:
548 0 : ret = map_acl_perms_to_permset(mmode, &permset);
549 0 : if (ret == -1) {
550 0 : return -1;
551 : }
552 0 : got_mask = true;
553 0 : break;
554 0 : case SMB_ACL_OTHER:
555 0 : ret = map_acl_perms_to_permset(omode, &permset);
556 0 : if (ret == -1) {
557 0 : return -1;
558 : }
559 0 : break;
560 0 : default:
561 0 : errno = EINVAL;
562 0 : return -1;
563 : }
564 0 : ret = sys_acl_set_permset(entry, permset);
565 0 : if (ret == -1) {
566 0 : return -1;
567 : }
568 : /* Move to next entry. */
569 0 : entry_id = SMB_ACL_NEXT_ENTRY;
570 : }
571 :
572 : /*
573 : * If we didn't see a mask entry, add one.
574 : */
575 :
576 0 : if (!got_mask) {
577 : SMB_ACL_ENTRY_T mask_entry;
578 : SMB_ACL_PERMSET_T mask_permset;
579 0 : ret = sys_acl_create_entry(&the_acl, &mask_entry);
580 0 : if (ret == -1) {
581 0 : return -1;
582 : }
583 0 : ret = map_acl_perms_to_permset(mmode, &mask_permset);
584 0 : if (ret == -1) {
585 0 : return -1;
586 : }
587 0 : ret = sys_acl_set_permset(mask_entry, mask_permset);
588 0 : if (ret == -1) {
589 0 : return -1;
590 : }
591 0 : ret = sys_acl_set_tag_type(mask_entry, SMB_ACL_MASK);
592 0 : if (ret == -1) {
593 0 : return -1;
594 : }
595 : /* In case we were realloced and moved. */
596 0 : *pp_the_acl = the_acl;
597 : }
598 :
599 0 : return 0;
600 : }
601 :
602 0 : static int fake_acls_fchmod(vfs_handle_struct *handle,
603 : files_struct *fsp,
604 : mode_t mode)
605 : {
606 0 : TALLOC_CTX *frame = talloc_stackframe();
607 0 : int ret = -1;
608 0 : SMB_ACL_T the_acl = NULL;
609 :
610 : /*
611 : * Passthrough first to preserve the
612 : * S_ISUID | S_ISGID | S_ISVTX
613 : * bits.
614 : */
615 :
616 0 : ret = SMB_VFS_NEXT_FCHMOD(handle,
617 : fsp,
618 : mode);
619 0 : if (ret == -1) {
620 0 : TALLOC_FREE(frame);
621 0 : return -1;
622 : }
623 :
624 0 : the_acl = fake_acls_sys_acl_get_fd(handle,
625 : fsp,
626 : SMB_ACL_TYPE_ACCESS,
627 : talloc_tos());
628 0 : if (the_acl == NULL) {
629 0 : TALLOC_FREE(frame);
630 0 : if (errno == ENOATTR) {
631 : /* No ACL on this file. Just passthrough. */
632 0 : return 0;
633 : }
634 0 : return -1;
635 : }
636 0 : ret = fake_acl_process_chmod(&the_acl,
637 0 : fsp->fsp_name->st.st_ex_uid,
638 : mode);
639 0 : if (ret == -1) {
640 0 : TALLOC_FREE(frame);
641 0 : return -1;
642 : }
643 0 : ret = fake_acls_sys_acl_set_fd(handle,
644 : fsp,
645 : SMB_ACL_TYPE_ACCESS,
646 : the_acl);
647 0 : TALLOC_FREE(frame);
648 0 : return ret;
649 : }
650 :
651 7952 : static int fake_acls_connect(struct vfs_handle_struct *handle,
652 : const char *service,
653 : const char *user)
654 : {
655 7952 : struct in_pathref_data *prd = NULL;
656 : int ret;
657 :
658 7952 : ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
659 7952 : if (ret < 0) {
660 0 : return ret;
661 : }
662 : /*
663 : * Create a struct can tell us if we're recursing
664 : * into openat_pathref_fsp() in this module. This will
665 : * go away once we have SMB_VFS_STATX() and we will
666 : * have a way for a caller to as for specific stat
667 : * fields in a granular way. Then we will know exactly
668 : * what fields the caller wants, so we won't have to
669 : * fill in everything.
670 : */
671 7952 : prd = talloc_zero(handle->conn, struct in_pathref_data);
672 7952 : if (prd == NULL) {
673 0 : return -1;
674 : }
675 7952 : SMB_VFS_HANDLE_SET_DATA(handle,
676 : prd,
677 : NULL,
678 : struct in_pathref_data,
679 : return -1);
680 7952 : return 0;
681 : }
682 :
683 : static struct vfs_fn_pointers vfs_fake_acls_fns = {
684 : .connect_fn = fake_acls_connect,
685 : .stat_fn = fake_acls_stat,
686 : .lstat_fn = fake_acls_lstat,
687 : .fstat_fn = fake_acls_fstat,
688 : .fchmod_fn = fake_acls_fchmod,
689 : .sys_acl_get_fd_fn = fake_acls_sys_acl_get_fd,
690 : .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
691 : .sys_acl_set_fd_fn = fake_acls_sys_acl_set_fd,
692 : .sys_acl_delete_def_fd_fn = fake_acls_sys_acl_delete_def_fd,
693 : .lchown_fn = fake_acls_lchown,
694 : .fchown_fn = fake_acls_fchown,
695 :
696 : };
697 :
698 : static_decl_vfs;
699 4865 : NTSTATUS vfs_fake_acls_init(TALLOC_CTX *ctx)
700 : {
701 4865 : return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "fake_acls",
702 : &vfs_fake_acls_fns);
703 : }
|