2 * CAP VFS module for Samba 3.x Version 0.3
4 * Copyright (C) Tim Potter, 1999-2000
5 * Copyright (C) Alexander Bokovoy, 2002-2003
6 * Copyright (C) Stefan (metze) Metzmacher, 2003
7 * Copyright (C) TAKAHASHI Motonobu (monyo), 2003
8 * Copyright (C) Jeremy Allison, 2007
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.
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, see <http://www.gnu.org/licenses/>.
26 #include "smbd/smbd.h"
29 static char *capencode(TALLOC_CTX
*ctx
, const char *from
);
30 static char *capdecode(TALLOC_CTX
*ctx
, const char *from
);
32 static uint64_t cap_disk_free(vfs_handle_struct
*handle
,
33 const struct smb_filename
*smb_fname
,
38 char *capname
= capencode(talloc_tos(), smb_fname
->base_name
);
39 struct smb_filename
*cap_smb_fname
= NULL
;
45 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
50 if (cap_smb_fname
== NULL
) {
55 return SMB_VFS_NEXT_DISK_FREE(handle
, cap_smb_fname
,
59 static int cap_get_quota(vfs_handle_struct
*handle
,
60 const struct smb_filename
*smb_fname
,
61 enum SMB_QUOTA_TYPE qtype
,
65 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
66 struct smb_filename
*cap_smb_fname
= NULL
;
72 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
77 if (cap_smb_fname
== NULL
) {
82 return SMB_VFS_NEXT_GET_QUOTA(handle
, cap_smb_fname
, qtype
, id
, dq
);
85 static DIR *cap_opendir(vfs_handle_struct
*handle
,
86 const struct smb_filename
*smb_fname
,
90 char *capname
= capencode(talloc_tos(), smb_fname
->base_name
);
91 struct smb_filename
*cap_smb_fname
= NULL
;
97 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
102 if (cap_smb_fname
== NULL
) {
103 TALLOC_FREE(capname
);
107 return SMB_VFS_NEXT_OPENDIR(handle
, cap_smb_fname
, mask
, attr
);
110 static struct dirent
*cap_readdir(vfs_handle_struct
*handle
,
112 SMB_STRUCT_STAT
*sbuf
)
114 struct dirent
*result
;
115 struct dirent
*newdirent
;
118 DEBUG(3,("cap: cap_readdir\n"));
120 result
= SMB_VFS_NEXT_READDIR(handle
, dirp
, NULL
);
125 newname
= capdecode(talloc_tos(), result
->d_name
);
129 DEBUG(3,("cap: cap_readdir: %s\n", newname
));
130 newnamelen
= strlen(newname
)+1;
131 newdirent
= talloc_size(
132 talloc_tos(), sizeof(struct dirent
) + newnamelen
);
136 talloc_set_name_const(newdirent
, "struct dirent");
137 memcpy(newdirent
, result
, sizeof(struct dirent
));
138 memcpy(&newdirent
->d_name
, newname
, newnamelen
);
142 static int cap_mkdir(vfs_handle_struct
*handle
,
143 const struct smb_filename
*smb_fname
,
146 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
147 struct smb_filename
*cap_smb_fname
= NULL
;
154 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
159 if (cap_smb_fname
== NULL
) {
160 TALLOC_FREE(cappath
);
165 return SMB_VFS_NEXT_MKDIR(handle
, cap_smb_fname
, mode
);
168 static int cap_rmdir(vfs_handle_struct
*handle
,
169 const struct smb_filename
*smb_fname
)
171 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
172 struct smb_filename
*cap_smb_fname
= NULL
;
179 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
184 if (cap_smb_fname
== NULL
) {
185 TALLOC_FREE(cappath
);
190 return SMB_VFS_NEXT_RMDIR(handle
, cap_smb_fname
);
193 static int cap_open(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
,
194 files_struct
*fsp
, int flags
, mode_t mode
)
197 char *tmp_base_name
= NULL
;
200 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
207 tmp_base_name
= smb_fname
->base_name
;
208 smb_fname
->base_name
= cappath
;
210 DEBUG(3,("cap: cap_open for %s\n", smb_fname_str_dbg(smb_fname
)));
211 ret
= SMB_VFS_NEXT_OPEN(handle
, smb_fname
, fsp
, flags
, mode
);
213 smb_fname
->base_name
= tmp_base_name
;
214 TALLOC_FREE(cappath
);
219 static int cap_rename(vfs_handle_struct
*handle
,
220 const struct smb_filename
*smb_fname_src
,
221 const struct smb_filename
*smb_fname_dst
)
225 struct smb_filename
*smb_fname_src_tmp
= NULL
;
226 struct smb_filename
*smb_fname_dst_tmp
= NULL
;
229 capold
= capencode(talloc_tos(), smb_fname_src
->base_name
);
230 capnew
= capencode(talloc_tos(), smb_fname_dst
->base_name
);
231 if (!capold
|| !capnew
) {
236 /* Setup temporary smb_filename structs. */
237 smb_fname_src_tmp
= cp_smb_filename(talloc_tos(), smb_fname_src
);
238 if (smb_fname_src_tmp
== NULL
) {
242 smb_fname_dst_tmp
= cp_smb_filename(talloc_tos(), smb_fname_dst
);
243 if (smb_fname_dst_tmp
== NULL
) {
248 smb_fname_src_tmp
->base_name
= capold
;
249 smb_fname_dst_tmp
->base_name
= capnew
;
251 ret
= SMB_VFS_NEXT_RENAME(handle
, smb_fname_src_tmp
,
256 TALLOC_FREE(smb_fname_src_tmp
);
257 TALLOC_FREE(smb_fname_dst_tmp
);
262 static int cap_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
265 char *tmp_base_name
= NULL
;
268 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
275 tmp_base_name
= smb_fname
->base_name
;
276 smb_fname
->base_name
= cappath
;
278 ret
= SMB_VFS_NEXT_STAT(handle
, smb_fname
);
280 smb_fname
->base_name
= tmp_base_name
;
281 TALLOC_FREE(cappath
);
286 static int cap_lstat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
289 char *tmp_base_name
= NULL
;
292 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
299 tmp_base_name
= smb_fname
->base_name
;
300 smb_fname
->base_name
= cappath
;
302 ret
= SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
304 smb_fname
->base_name
= tmp_base_name
;
305 TALLOC_FREE(cappath
);
310 static int cap_unlink(vfs_handle_struct
*handle
,
311 const struct smb_filename
*smb_fname
)
313 struct smb_filename
*smb_fname_tmp
= NULL
;
314 char *cappath
= NULL
;
317 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
323 /* Setup temporary smb_filename structs. */
324 smb_fname_tmp
= cp_smb_filename(talloc_tos(), smb_fname
);
325 if (smb_fname_tmp
== NULL
) {
330 smb_fname_tmp
->base_name
= cappath
;
332 ret
= SMB_VFS_NEXT_UNLINK(handle
, smb_fname_tmp
);
334 TALLOC_FREE(smb_fname_tmp
);
338 static int cap_chmod(vfs_handle_struct
*handle
,
339 const struct smb_filename
*smb_fname
,
342 struct smb_filename
*cap_smb_fname
= NULL
;
343 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
352 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
357 if (cap_smb_fname
== NULL
) {
358 TALLOC_FREE(cappath
);
363 ret
= SMB_VFS_NEXT_CHMOD(handle
, cap_smb_fname
, mode
);
365 TALLOC_FREE(cappath
);
366 TALLOC_FREE(cap_smb_fname
);
371 static int cap_chown(vfs_handle_struct
*handle
,
372 const struct smb_filename
*smb_fname
,
376 struct smb_filename
*cap_smb_fname
= NULL
;
377 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
386 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
391 if (cap_smb_fname
== NULL
) {
392 TALLOC_FREE(cappath
);
397 ret
= SMB_VFS_NEXT_CHOWN(handle
, cap_smb_fname
, uid
, gid
);
399 TALLOC_FREE(cappath
);
400 TALLOC_FREE(cap_smb_fname
);
405 static int cap_lchown(vfs_handle_struct
*handle
,
406 const struct smb_filename
*smb_fname
,
410 struct smb_filename
*cap_smb_fname
= NULL
;
411 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
420 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
425 if (cap_smb_fname
== NULL
) {
426 TALLOC_FREE(cappath
);
431 ret
= SMB_VFS_NEXT_LCHOWN(handle
, cap_smb_fname
, uid
, gid
);
433 TALLOC_FREE(cappath
);
434 TALLOC_FREE(cap_smb_fname
);
439 static int cap_chdir(vfs_handle_struct
*handle
,
440 const struct smb_filename
*smb_fname
)
442 struct smb_filename
*cap_smb_fname
= NULL
;
443 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
451 DEBUG(3,("cap: cap_chdir for %s\n", smb_fname
->base_name
));
453 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
458 if (cap_smb_fname
== NULL
) {
459 TALLOC_FREE(cappath
);
463 ret
= SMB_VFS_NEXT_CHDIR(handle
, cap_smb_fname
);
467 TALLOC_FREE(cappath
);
468 TALLOC_FREE(cap_smb_fname
);
469 if (saved_errno
!= 0) {
475 static int cap_ntimes(vfs_handle_struct
*handle
,
476 const struct smb_filename
*smb_fname
,
477 struct smb_file_time
*ft
)
479 struct smb_filename
*smb_fname_tmp
= NULL
;
480 char *cappath
= NULL
;
483 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
490 /* Setup temporary smb_filename structs. */
491 smb_fname_tmp
= cp_smb_filename(talloc_tos(), smb_fname
);
492 if (smb_fname_tmp
== NULL
) {
497 smb_fname_tmp
->base_name
= cappath
;
499 ret
= SMB_VFS_NEXT_NTIMES(handle
, smb_fname_tmp
, ft
);
501 TALLOC_FREE(smb_fname_tmp
);
506 static int cap_symlink(vfs_handle_struct
*handle
,
507 const char *link_contents
,
508 const struct smb_filename
*new_smb_fname
)
510 char *capold
= capencode(talloc_tos(), link_contents
);
511 char *capnew
= capencode(talloc_tos(), new_smb_fname
->base_name
);
512 struct smb_filename
*new_cap_smb_fname
= NULL
;
516 if (!capold
|| !capnew
) {
520 new_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
524 new_smb_fname
->flags
);
525 if (new_cap_smb_fname
== NULL
) {
531 ret
= SMB_VFS_NEXT_SYMLINK(handle
,
539 TALLOC_FREE(new_cap_smb_fname
);
540 if (saved_errno
!= 0) {
546 static int cap_readlink(vfs_handle_struct
*handle
,
547 const struct smb_filename
*smb_fname
,
551 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
552 struct smb_filename
*cap_smb_fname
= NULL
;
560 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
565 if (cap_smb_fname
== NULL
) {
566 TALLOC_FREE(cappath
);
570 ret
= SMB_VFS_NEXT_READLINK(handle
, cap_smb_fname
, buf
, bufsiz
);
574 TALLOC_FREE(cappath
);
575 TALLOC_FREE(cap_smb_fname
);
576 if (saved_errno
!= 0) {
582 static int cap_link(vfs_handle_struct
*handle
,
583 const struct smb_filename
*old_smb_fname
,
584 const struct smb_filename
*new_smb_fname
)
586 char *capold
= capencode(talloc_tos(), old_smb_fname
->base_name
);
587 char *capnew
= capencode(talloc_tos(), new_smb_fname
->base_name
);
588 struct smb_filename
*old_cap_smb_fname
= NULL
;
589 struct smb_filename
*new_cap_smb_fname
= NULL
;
593 if (!capold
|| !capnew
) {
597 old_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
601 old_smb_fname
->flags
);
602 if (old_cap_smb_fname
== NULL
) {
608 new_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
612 new_smb_fname
->flags
);
613 if (new_cap_smb_fname
== NULL
) {
616 TALLOC_FREE(old_cap_smb_fname
);
620 ret
= SMB_VFS_NEXT_LINK(handle
, old_cap_smb_fname
, new_cap_smb_fname
);
626 TALLOC_FREE(old_cap_smb_fname
);
627 TALLOC_FREE(new_cap_smb_fname
);
628 if (saved_errno
!= 0) {
634 static int cap_mknod(vfs_handle_struct
*handle
,
635 const struct smb_filename
*smb_fname
,
639 struct smb_filename
*cap_smb_fname
= NULL
;
640 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
648 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
653 if (cap_smb_fname
== NULL
) {
654 TALLOC_FREE(cappath
);
658 ret
= SMB_VFS_NEXT_MKNOD(handle
, cap_smb_fname
, mode
, dev
);
662 TALLOC_FREE(cappath
);
663 TALLOC_FREE(cap_smb_fname
);
664 if (saved_errno
!= 0) {
670 static struct smb_filename
*cap_realpath(vfs_handle_struct
*handle
,
672 const struct smb_filename
*smb_fname
)
674 /* monyo need capencode'ed and capdecode'ed? */
675 struct smb_filename
*cap_smb_fname
= NULL
;
676 struct smb_filename
*return_fname
= NULL
;
677 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
684 cap_smb_fname
= synthetic_smb_fname(ctx
,
689 if (cap_smb_fname
== NULL
) {
690 TALLOC_FREE(cappath
);
694 return_fname
= SMB_VFS_NEXT_REALPATH(handle
, ctx
, cap_smb_fname
);
695 if (return_fname
== NULL
) {
698 TALLOC_FREE(cappath
);
699 TALLOC_FREE(cap_smb_fname
);
700 if (saved_errno
!= 0) {
706 static int cap_chmod_acl(vfs_handle_struct
*handle
,
707 const struct smb_filename
*smb_fname
,
710 struct smb_filename
*cap_smb_fname
= NULL
;
711 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
715 /* If the underlying VFS doesn't have ACL support... */
720 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
725 if (cap_smb_fname
== NULL
) {
726 TALLOC_FREE(cappath
);
731 ret
= SMB_VFS_NEXT_CHMOD_ACL(handle
, cap_smb_fname
, mode
);
733 TALLOC_FREE(cappath
);
734 TALLOC_FREE(cap_smb_fname
);
739 static SMB_ACL_T
cap_sys_acl_get_file(vfs_handle_struct
*handle
,
740 const struct smb_filename
*smb_fname
,
744 struct smb_filename
*cap_smb_fname
= NULL
;
745 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
751 return (SMB_ACL_T
)NULL
;
753 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
758 if (cap_smb_fname
== NULL
) {
759 TALLOC_FREE(cappath
);
761 return (SMB_ACL_T
)NULL
;
763 ret
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, cap_smb_fname
,
768 TALLOC_FREE(cappath
);
769 TALLOC_FREE(cap_smb_fname
);
770 if (saved_errno
!= 0) {
776 static int cap_sys_acl_set_file(vfs_handle_struct
*handle
,
777 const struct smb_filename
*smb_fname
,
778 SMB_ACL_TYPE_T acltype
,
781 struct smb_filename
*cap_smb_fname
= NULL
;
782 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
790 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
795 if (cap_smb_fname
== NULL
) {
796 TALLOC_FREE(cappath
);
800 ret
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, cap_smb_fname
,
805 TALLOC_FREE(cappath
);
806 TALLOC_FREE(cap_smb_fname
);
807 if (saved_errno
!= 0) {
813 static int cap_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
814 const struct smb_filename
*smb_fname
)
816 struct smb_filename
*cap_smb_fname
= NULL
;
817 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
825 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
830 if (cap_smb_fname
== NULL
) {
831 TALLOC_FREE(cappath
);
835 ret
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, cap_smb_fname
);
839 TALLOC_FREE(cappath
);
840 TALLOC_FREE(cap_smb_fname
);
847 static ssize_t
cap_getxattr(vfs_handle_struct
*handle
,
848 const struct smb_filename
*smb_fname
,
853 struct smb_filename
*cap_smb_fname
= NULL
;
854 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
855 char *capname
= capencode(talloc_tos(), name
);
859 if (!cappath
|| !capname
) {
863 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
868 if (cap_smb_fname
== NULL
) {
869 TALLOC_FREE(cappath
);
870 TALLOC_FREE(capname
);
874 ret
= SMB_VFS_NEXT_GETXATTR(handle
, cap_smb_fname
,
875 capname
, value
, size
);
879 TALLOC_FREE(cappath
);
880 TALLOC_FREE(capname
);
881 TALLOC_FREE(cap_smb_fname
);
888 static ssize_t
cap_fgetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
, void *value
, size_t size
)
890 char *cappath
= capencode(talloc_tos(), path
);
896 return SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, cappath
, value
, size
);
899 static ssize_t
cap_listxattr(vfs_handle_struct
*handle
,
900 const struct smb_filename
*smb_fname
,
904 struct smb_filename
*cap_smb_fname
= NULL
;
905 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
913 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
918 if (cap_smb_fname
== NULL
) {
919 TALLOC_FREE(cappath
);
923 ret
= SMB_VFS_NEXT_LISTXATTR(handle
, cap_smb_fname
, list
, size
);
927 TALLOC_FREE(cappath
);
928 TALLOC_FREE(cap_smb_fname
);
935 static int cap_removexattr(vfs_handle_struct
*handle
,
936 const struct smb_filename
*smb_fname
,
939 struct smb_filename
*cap_smb_fname
= NULL
;
940 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
941 char *capname
= capencode(talloc_tos(), name
);
945 if (!cappath
|| !capname
) {
949 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
954 if (cap_smb_fname
== NULL
) {
955 TALLOC_FREE(cappath
);
956 TALLOC_FREE(capname
);
960 ret
= SMB_VFS_NEXT_REMOVEXATTR(handle
, cap_smb_fname
, capname
);
964 TALLOC_FREE(cappath
);
965 TALLOC_FREE(capname
);
966 TALLOC_FREE(cap_smb_fname
);
973 static int cap_fremovexattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
)
975 char *cappath
= capencode(talloc_tos(), path
);
981 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, cappath
);
984 static int cap_setxattr(vfs_handle_struct
*handle
,
985 const struct smb_filename
*smb_fname
,
991 struct smb_filename
*cap_smb_fname
= NULL
;
992 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
993 char *capname
= capencode(talloc_tos(), name
);
997 if (!cappath
|| !capname
) {
1001 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
1006 if (cap_smb_fname
== NULL
) {
1007 TALLOC_FREE(cappath
);
1008 TALLOC_FREE(capname
);
1012 ret
= SMB_VFS_NEXT_SETXATTR(handle
, cap_smb_fname
,
1013 capname
, value
, size
, flags
);
1015 saved_errno
= errno
;
1017 TALLOC_FREE(cappath
);
1018 TALLOC_FREE(capname
);
1019 TALLOC_FREE(cap_smb_fname
);
1021 errno
= saved_errno
;
1026 static int cap_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
, const void *value
, size_t size
, int flags
)
1028 char *cappath
= capencode(talloc_tos(), path
);
1034 return SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, cappath
, value
, size
, flags
);
1037 static struct vfs_fn_pointers vfs_cap_fns
= {
1038 .disk_free_fn
= cap_disk_free
,
1039 .get_quota_fn
= cap_get_quota
,
1040 .opendir_fn
= cap_opendir
,
1041 .readdir_fn
= cap_readdir
,
1042 .mkdir_fn
= cap_mkdir
,
1043 .rmdir_fn
= cap_rmdir
,
1044 .open_fn
= cap_open
,
1045 .rename_fn
= cap_rename
,
1046 .stat_fn
= cap_stat
,
1047 .lstat_fn
= cap_lstat
,
1048 .unlink_fn
= cap_unlink
,
1049 .chmod_fn
= cap_chmod
,
1050 .chown_fn
= cap_chown
,
1051 .lchown_fn
= cap_lchown
,
1052 .chdir_fn
= cap_chdir
,
1053 .ntimes_fn
= cap_ntimes
,
1054 .symlink_fn
= cap_symlink
,
1055 .readlink_fn
= cap_readlink
,
1056 .link_fn
= cap_link
,
1057 .mknod_fn
= cap_mknod
,
1058 .realpath_fn
= cap_realpath
,
1059 .chmod_acl_fn
= cap_chmod_acl
,
1060 .sys_acl_get_file_fn
= cap_sys_acl_get_file
,
1061 .sys_acl_set_file_fn
= cap_sys_acl_set_file
,
1062 .sys_acl_delete_def_file_fn
= cap_sys_acl_delete_def_file
,
1063 .getxattr_fn
= cap_getxattr
,
1064 .fgetxattr_fn
= cap_fgetxattr
,
1065 .listxattr_fn
= cap_listxattr
,
1066 .removexattr_fn
= cap_removexattr
,
1067 .fremovexattr_fn
= cap_fremovexattr
,
1068 .setxattr_fn
= cap_setxattr
,
1069 .fsetxattr_fn
= cap_fsetxattr
1073 NTSTATUS
vfs_cap_init(TALLOC_CTX
*ctx
)
1075 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "cap",
1079 /* For CAP functions */
1081 #define hex2bin(c) hex2bin_table[(unsigned char)(c)]
1082 #define bin2hex(c) bin2hex_table[(unsigned char)(c)]
1083 #define is_hex(s) ((s)[0] == hex_tag)
1085 static unsigned char hex2bin_table
[256] = {
1086 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
1087 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
1088 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
1089 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
1090 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x40 */
1091 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
1092 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
1093 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x60 */
1094 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
1095 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */
1096 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 */
1097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 */
1098 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 */
1099 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 */
1100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 */
1101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 */
1102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 */
1103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0 */
1105 static unsigned char bin2hex_table
[256] = "0123456789abcdef";
1107 /*******************************************************************
1108 original code -> ":xx" - CAP format
1109 ********************************************************************/
1111 static char *capencode(TALLOC_CTX
*ctx
, const char *from
)
1118 for (p1
= from
; *p1
; p1
++) {
1119 if ((unsigned char)*p1
>= 0x80) {
1127 to
= talloc_array(ctx
, char, len
);
1132 for (out
= to
; *from
;) {
1133 /* buffer husoku error */
1134 if ((unsigned char)*from
>= 0x80) {
1136 *out
++ = bin2hex (((*from
)>>4)&0x0f);
1137 *out
++ = bin2hex ((*from
)&0x0f);
1147 /*******************************************************************
1148 CAP -> original code
1149 ********************************************************************/
1150 /* ":xx" -> a byte */
1152 static char *capdecode(TALLOC_CTX
*ctx
, const char *from
)
1159 for (p1
= from
; *p1
; len
++) {
1168 to
= talloc_array(ctx
, char, len
);
1173 for (out
= to
; *from
;) {
1175 *out
++ = (hex2bin(from
[1])<<4) | (hex2bin(from
[2]));