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_renameat(vfs_handle_struct
*handle
,
220 files_struct
*srcfsp
,
221 const struct smb_filename
*smb_fname_src
,
222 files_struct
*dstfsp
,
223 const struct smb_filename
*smb_fname_dst
)
227 struct smb_filename
*smb_fname_src_tmp
= NULL
;
228 struct smb_filename
*smb_fname_dst_tmp
= NULL
;
231 capold
= capencode(talloc_tos(), smb_fname_src
->base_name
);
232 capnew
= capencode(talloc_tos(), smb_fname_dst
->base_name
);
233 if (!capold
|| !capnew
) {
238 /* Setup temporary smb_filename structs. */
239 smb_fname_src_tmp
= cp_smb_filename(talloc_tos(), smb_fname_src
);
240 if (smb_fname_src_tmp
== NULL
) {
244 smb_fname_dst_tmp
= cp_smb_filename(talloc_tos(), smb_fname_dst
);
245 if (smb_fname_dst_tmp
== NULL
) {
250 smb_fname_src_tmp
->base_name
= capold
;
251 smb_fname_dst_tmp
->base_name
= capnew
;
253 ret
= SMB_VFS_NEXT_RENAMEAT(handle
,
262 TALLOC_FREE(smb_fname_src_tmp
);
263 TALLOC_FREE(smb_fname_dst_tmp
);
268 static int cap_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
271 char *tmp_base_name
= NULL
;
274 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
281 tmp_base_name
= smb_fname
->base_name
;
282 smb_fname
->base_name
= cappath
;
284 ret
= SMB_VFS_NEXT_STAT(handle
, smb_fname
);
286 smb_fname
->base_name
= tmp_base_name
;
287 TALLOC_FREE(cappath
);
292 static int cap_lstat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
295 char *tmp_base_name
= NULL
;
298 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
305 tmp_base_name
= smb_fname
->base_name
;
306 smb_fname
->base_name
= cappath
;
308 ret
= SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
310 smb_fname
->base_name
= tmp_base_name
;
311 TALLOC_FREE(cappath
);
316 static int cap_unlink(vfs_handle_struct
*handle
,
317 const struct smb_filename
*smb_fname
)
319 struct smb_filename
*smb_fname_tmp
= NULL
;
320 char *cappath
= NULL
;
323 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
329 /* Setup temporary smb_filename structs. */
330 smb_fname_tmp
= cp_smb_filename(talloc_tos(), smb_fname
);
331 if (smb_fname_tmp
== NULL
) {
336 smb_fname_tmp
->base_name
= cappath
;
338 ret
= SMB_VFS_NEXT_UNLINK(handle
, smb_fname_tmp
);
340 TALLOC_FREE(smb_fname_tmp
);
344 static int cap_chmod(vfs_handle_struct
*handle
,
345 const struct smb_filename
*smb_fname
,
348 struct smb_filename
*cap_smb_fname
= NULL
;
349 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
358 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
363 if (cap_smb_fname
== NULL
) {
364 TALLOC_FREE(cappath
);
369 ret
= SMB_VFS_NEXT_CHMOD(handle
, cap_smb_fname
, mode
);
371 TALLOC_FREE(cappath
);
372 TALLOC_FREE(cap_smb_fname
);
377 static int cap_chown(vfs_handle_struct
*handle
,
378 const struct smb_filename
*smb_fname
,
382 struct smb_filename
*cap_smb_fname
= NULL
;
383 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
392 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
397 if (cap_smb_fname
== NULL
) {
398 TALLOC_FREE(cappath
);
403 ret
= SMB_VFS_NEXT_CHOWN(handle
, cap_smb_fname
, uid
, gid
);
405 TALLOC_FREE(cappath
);
406 TALLOC_FREE(cap_smb_fname
);
411 static int cap_lchown(vfs_handle_struct
*handle
,
412 const struct smb_filename
*smb_fname
,
416 struct smb_filename
*cap_smb_fname
= NULL
;
417 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
426 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
431 if (cap_smb_fname
== NULL
) {
432 TALLOC_FREE(cappath
);
437 ret
= SMB_VFS_NEXT_LCHOWN(handle
, cap_smb_fname
, uid
, gid
);
439 TALLOC_FREE(cappath
);
440 TALLOC_FREE(cap_smb_fname
);
445 static int cap_chdir(vfs_handle_struct
*handle
,
446 const struct smb_filename
*smb_fname
)
448 struct smb_filename
*cap_smb_fname
= NULL
;
449 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
457 DEBUG(3,("cap: cap_chdir for %s\n", smb_fname
->base_name
));
459 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
464 if (cap_smb_fname
== NULL
) {
465 TALLOC_FREE(cappath
);
469 ret
= SMB_VFS_NEXT_CHDIR(handle
, cap_smb_fname
);
473 TALLOC_FREE(cappath
);
474 TALLOC_FREE(cap_smb_fname
);
475 if (saved_errno
!= 0) {
481 static int cap_ntimes(vfs_handle_struct
*handle
,
482 const struct smb_filename
*smb_fname
,
483 struct smb_file_time
*ft
)
485 struct smb_filename
*smb_fname_tmp
= NULL
;
486 char *cappath
= NULL
;
489 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
496 /* Setup temporary smb_filename structs. */
497 smb_fname_tmp
= cp_smb_filename(talloc_tos(), smb_fname
);
498 if (smb_fname_tmp
== NULL
) {
503 smb_fname_tmp
->base_name
= cappath
;
505 ret
= SMB_VFS_NEXT_NTIMES(handle
, smb_fname_tmp
, ft
);
507 TALLOC_FREE(smb_fname_tmp
);
512 static int cap_symlink(vfs_handle_struct
*handle
,
513 const char *link_contents
,
514 const struct smb_filename
*new_smb_fname
)
516 char *capold
= capencode(talloc_tos(), link_contents
);
517 char *capnew
= capencode(talloc_tos(), new_smb_fname
->base_name
);
518 struct smb_filename
*new_cap_smb_fname
= NULL
;
522 if (!capold
|| !capnew
) {
526 new_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
530 new_smb_fname
->flags
);
531 if (new_cap_smb_fname
== NULL
) {
537 ret
= SMB_VFS_NEXT_SYMLINK(handle
,
545 TALLOC_FREE(new_cap_smb_fname
);
546 if (saved_errno
!= 0) {
552 static int cap_readlink(vfs_handle_struct
*handle
,
553 const struct smb_filename
*smb_fname
,
557 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
558 struct smb_filename
*cap_smb_fname
= NULL
;
566 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
571 if (cap_smb_fname
== NULL
) {
572 TALLOC_FREE(cappath
);
576 ret
= SMB_VFS_NEXT_READLINK(handle
, cap_smb_fname
, buf
, bufsiz
);
580 TALLOC_FREE(cappath
);
581 TALLOC_FREE(cap_smb_fname
);
582 if (saved_errno
!= 0) {
588 static int cap_readlinkat(vfs_handle_struct
*handle
,
589 files_struct
*dirfsp
,
590 const struct smb_filename
*smb_fname
,
594 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
595 struct smb_filename
*cap_smb_fname
= NULL
;
603 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
608 if (cap_smb_fname
== NULL
) {
609 TALLOC_FREE(cappath
);
613 ret
= SMB_VFS_NEXT_READLINKAT(handle
,
621 TALLOC_FREE(cappath
);
622 TALLOC_FREE(cap_smb_fname
);
623 if (saved_errno
!= 0) {
629 static int cap_linkat(vfs_handle_struct
*handle
,
630 files_struct
*srcfsp
,
631 const struct smb_filename
*old_smb_fname
,
632 files_struct
*dstfsp
,
633 const struct smb_filename
*new_smb_fname
,
636 char *capold
= capencode(talloc_tos(), old_smb_fname
->base_name
);
637 char *capnew
= capencode(talloc_tos(), new_smb_fname
->base_name
);
638 struct smb_filename
*old_cap_smb_fname
= NULL
;
639 struct smb_filename
*new_cap_smb_fname
= NULL
;
643 if (!capold
|| !capnew
) {
647 old_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
651 old_smb_fname
->flags
);
652 if (old_cap_smb_fname
== NULL
) {
658 new_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
662 new_smb_fname
->flags
);
663 if (new_cap_smb_fname
== NULL
) {
666 TALLOC_FREE(old_cap_smb_fname
);
670 ret
= SMB_VFS_NEXT_LINKAT(handle
,
681 TALLOC_FREE(old_cap_smb_fname
);
682 TALLOC_FREE(new_cap_smb_fname
);
683 if (saved_errno
!= 0) {
689 static int cap_mknodat(vfs_handle_struct
*handle
,
690 files_struct
*dirfsp
,
691 const struct smb_filename
*smb_fname
,
695 struct smb_filename
*cap_smb_fname
= NULL
;
696 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
704 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
709 if (cap_smb_fname
== NULL
) {
710 TALLOC_FREE(cappath
);
714 ret
= SMB_VFS_NEXT_MKNODAT(handle
,
722 TALLOC_FREE(cappath
);
723 TALLOC_FREE(cap_smb_fname
);
724 if (saved_errno
!= 0) {
730 static struct smb_filename
*cap_realpath(vfs_handle_struct
*handle
,
732 const struct smb_filename
*smb_fname
)
734 /* monyo need capencode'ed and capdecode'ed? */
735 struct smb_filename
*cap_smb_fname
= NULL
;
736 struct smb_filename
*return_fname
= NULL
;
737 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
744 cap_smb_fname
= synthetic_smb_fname(ctx
,
749 if (cap_smb_fname
== NULL
) {
750 TALLOC_FREE(cappath
);
754 return_fname
= SMB_VFS_NEXT_REALPATH(handle
, ctx
, cap_smb_fname
);
755 if (return_fname
== NULL
) {
758 TALLOC_FREE(cappath
);
759 TALLOC_FREE(cap_smb_fname
);
760 if (saved_errno
!= 0) {
766 static SMB_ACL_T
cap_sys_acl_get_file(vfs_handle_struct
*handle
,
767 const struct smb_filename
*smb_fname
,
771 struct smb_filename
*cap_smb_fname
= NULL
;
772 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
778 return (SMB_ACL_T
)NULL
;
780 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
785 if (cap_smb_fname
== NULL
) {
786 TALLOC_FREE(cappath
);
788 return (SMB_ACL_T
)NULL
;
790 ret
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, cap_smb_fname
,
795 TALLOC_FREE(cappath
);
796 TALLOC_FREE(cap_smb_fname
);
797 if (saved_errno
!= 0) {
803 static int cap_sys_acl_set_file(vfs_handle_struct
*handle
,
804 const struct smb_filename
*smb_fname
,
805 SMB_ACL_TYPE_T acltype
,
808 struct smb_filename
*cap_smb_fname
= NULL
;
809 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
817 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
822 if (cap_smb_fname
== NULL
) {
823 TALLOC_FREE(cappath
);
827 ret
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, cap_smb_fname
,
832 TALLOC_FREE(cappath
);
833 TALLOC_FREE(cap_smb_fname
);
834 if (saved_errno
!= 0) {
840 static int cap_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
841 const struct smb_filename
*smb_fname
)
843 struct smb_filename
*cap_smb_fname
= NULL
;
844 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
852 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
857 if (cap_smb_fname
== NULL
) {
858 TALLOC_FREE(cappath
);
862 ret
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, cap_smb_fname
);
866 TALLOC_FREE(cappath
);
867 TALLOC_FREE(cap_smb_fname
);
874 static ssize_t
cap_getxattr(vfs_handle_struct
*handle
,
875 const struct smb_filename
*smb_fname
,
880 struct smb_filename
*cap_smb_fname
= NULL
;
881 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
882 char *capname
= capencode(talloc_tos(), name
);
886 if (!cappath
|| !capname
) {
890 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
895 if (cap_smb_fname
== NULL
) {
896 TALLOC_FREE(cappath
);
897 TALLOC_FREE(capname
);
901 ret
= SMB_VFS_NEXT_GETXATTR(handle
, cap_smb_fname
,
902 capname
, value
, size
);
906 TALLOC_FREE(cappath
);
907 TALLOC_FREE(capname
);
908 TALLOC_FREE(cap_smb_fname
);
915 static ssize_t
cap_fgetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
, void *value
, size_t size
)
917 char *cappath
= capencode(talloc_tos(), path
);
923 return SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, cappath
, value
, size
);
926 static ssize_t
cap_listxattr(vfs_handle_struct
*handle
,
927 const struct smb_filename
*smb_fname
,
931 struct smb_filename
*cap_smb_fname
= NULL
;
932 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
940 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
945 if (cap_smb_fname
== NULL
) {
946 TALLOC_FREE(cappath
);
950 ret
= SMB_VFS_NEXT_LISTXATTR(handle
, cap_smb_fname
, list
, size
);
954 TALLOC_FREE(cappath
);
955 TALLOC_FREE(cap_smb_fname
);
962 static int cap_removexattr(vfs_handle_struct
*handle
,
963 const struct smb_filename
*smb_fname
,
966 struct smb_filename
*cap_smb_fname
= NULL
;
967 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
968 char *capname
= capencode(talloc_tos(), name
);
972 if (!cappath
|| !capname
) {
976 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
981 if (cap_smb_fname
== NULL
) {
982 TALLOC_FREE(cappath
);
983 TALLOC_FREE(capname
);
987 ret
= SMB_VFS_NEXT_REMOVEXATTR(handle
, cap_smb_fname
, capname
);
991 TALLOC_FREE(cappath
);
992 TALLOC_FREE(capname
);
993 TALLOC_FREE(cap_smb_fname
);
1000 static int cap_fremovexattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
)
1002 char *cappath
= capencode(talloc_tos(), path
);
1008 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, cappath
);
1011 static int cap_setxattr(vfs_handle_struct
*handle
,
1012 const struct smb_filename
*smb_fname
,
1018 struct smb_filename
*cap_smb_fname
= NULL
;
1019 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
1020 char *capname
= capencode(talloc_tos(), name
);
1022 int saved_errno
= 0;
1024 if (!cappath
|| !capname
) {
1028 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
1033 if (cap_smb_fname
== NULL
) {
1034 TALLOC_FREE(cappath
);
1035 TALLOC_FREE(capname
);
1039 ret
= SMB_VFS_NEXT_SETXATTR(handle
, cap_smb_fname
,
1040 capname
, value
, size
, flags
);
1042 saved_errno
= errno
;
1044 TALLOC_FREE(cappath
);
1045 TALLOC_FREE(capname
);
1046 TALLOC_FREE(cap_smb_fname
);
1048 errno
= saved_errno
;
1053 static int cap_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
, const void *value
, size_t size
, int flags
)
1055 char *cappath
= capencode(talloc_tos(), path
);
1061 return SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, cappath
, value
, size
, flags
);
1064 static struct vfs_fn_pointers vfs_cap_fns
= {
1065 .disk_free_fn
= cap_disk_free
,
1066 .get_quota_fn
= cap_get_quota
,
1067 .opendir_fn
= cap_opendir
,
1068 .readdir_fn
= cap_readdir
,
1069 .mkdir_fn
= cap_mkdir
,
1070 .rmdir_fn
= cap_rmdir
,
1071 .open_fn
= cap_open
,
1072 .renameat_fn
= cap_renameat
,
1073 .stat_fn
= cap_stat
,
1074 .lstat_fn
= cap_lstat
,
1075 .unlink_fn
= cap_unlink
,
1076 .chmod_fn
= cap_chmod
,
1077 .chown_fn
= cap_chown
,
1078 .lchown_fn
= cap_lchown
,
1079 .chdir_fn
= cap_chdir
,
1080 .ntimes_fn
= cap_ntimes
,
1081 .symlink_fn
= cap_symlink
,
1082 .readlink_fn
= cap_readlink
,
1083 .readlinkat_fn
= cap_readlinkat
,
1084 .linkat_fn
= cap_linkat
,
1085 .mknodat_fn
= cap_mknodat
,
1086 .realpath_fn
= cap_realpath
,
1087 .sys_acl_get_file_fn
= cap_sys_acl_get_file
,
1088 .sys_acl_set_file_fn
= cap_sys_acl_set_file
,
1089 .sys_acl_delete_def_file_fn
= cap_sys_acl_delete_def_file
,
1090 .getxattr_fn
= cap_getxattr
,
1091 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
1092 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
1093 .fgetxattr_fn
= cap_fgetxattr
,
1094 .listxattr_fn
= cap_listxattr
,
1095 .removexattr_fn
= cap_removexattr
,
1096 .fremovexattr_fn
= cap_fremovexattr
,
1097 .setxattr_fn
= cap_setxattr
,
1098 .fsetxattr_fn
= cap_fsetxattr
1102 NTSTATUS
vfs_cap_init(TALLOC_CTX
*ctx
)
1104 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "cap",
1108 /* For CAP functions */
1110 #define hex2bin(c) hex2bin_table[(unsigned char)(c)]
1111 #define bin2hex(c) bin2hex_table[(unsigned char)(c)]
1112 #define is_hex(s) ((s)[0] == hex_tag)
1114 static unsigned char hex2bin_table
[256] = {
1115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
1116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
1117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
1118 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
1119 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x40 */
1120 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
1121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
1122 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x60 */
1123 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
1124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */
1125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 */
1126 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 */
1127 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 */
1128 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 */
1129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 */
1130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 */
1131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 */
1132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0 */
1134 static unsigned char bin2hex_table
[256] = "0123456789abcdef";
1136 /*******************************************************************
1137 original code -> ":xx" - CAP format
1138 ********************************************************************/
1140 static char *capencode(TALLOC_CTX
*ctx
, const char *from
)
1147 for (p1
= from
; *p1
; p1
++) {
1148 if ((unsigned char)*p1
>= 0x80) {
1156 to
= talloc_array(ctx
, char, len
);
1161 for (out
= to
; *from
;) {
1162 /* buffer husoku error */
1163 if ((unsigned char)*from
>= 0x80) {
1165 *out
++ = bin2hex (((*from
)>>4)&0x0f);
1166 *out
++ = bin2hex ((*from
)&0x0f);
1176 /*******************************************************************
1177 CAP -> original code
1178 ********************************************************************/
1179 /* ":xx" -> a byte */
1181 static char *capdecode(TALLOC_CTX
*ctx
, const char *from
)
1188 for (p1
= from
; *p1
; len
++) {
1197 to
= talloc_array(ctx
, char, len
);
1202 for (out
= to
; *from
;) {
1204 *out
++ = (hex2bin(from
[1])<<4) | (hex2bin(from
[2]));