2 Unix SMB/CIFS implementation.
5 Copyright (C) Simo Sorce 2002
6 Copyright (C) Eric Lorimer 2002
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "smbd/smbd.h"
24 #include "system/passwd.h"
25 #include "system/filesys.h"
27 #include "../lib/util/util_pw.h"
28 #include "libcli/security/security.h"
29 #include "passdb/machine_sid.h"
30 #include "source3/smbd/dir.h"
32 static const char *null_string
= "";
34 static uint32_t ssf_flags(void)
36 return lp_posix_pathnames() ? SMB_FILENAME_POSIX_PATH
: 0;
39 static NTSTATUS
cmd_load_module(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
44 printf("Usage: load <modules>\n");
48 for (i
=argc
-1;i
>0;i
--) {
49 if (!vfs_init_custom(vfs
->conn
, argv
[i
])) {
50 DEBUG(0, ("load: (vfs_init_custom failed for %s)\n", argv
[i
]));
51 return NT_STATUS_UNSUCCESSFUL
;
58 static NTSTATUS
cmd_populate(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
63 printf("Usage: populate <char> <size>\n");
68 vfs
->data
= talloc_array(mem_ctx
, char, size
);
69 if (vfs
->data
== NULL
) {
70 printf("populate: error=-1 (not enough memory)");
71 return NT_STATUS_UNSUCCESSFUL
;
73 memset(vfs
->data
, c
, size
);
74 vfs
->data_size
= size
;
78 static NTSTATUS
cmd_show_data(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
82 if (argc
!= 1 && argc
!= 3) {
83 printf("Usage: showdata [<offset> <len>]\n");
86 if (vfs
->data
== NULL
|| vfs
->data_size
== 0) {
87 printf("show_data: error=-1 (buffer empty)\n");
88 return NT_STATUS_UNSUCCESSFUL
;
92 offset
= atoi(argv
[1]);
98 if ((offset
+ len
) > vfs
->data_size
) {
99 printf("show_data: error=-1 (not enough data in buffer)\n");
100 return NT_STATUS_UNSUCCESSFUL
;
102 dump_data(0, (uint8_t *)(vfs
->data
) + offset
, len
);
106 static NTSTATUS
cmd_connect(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
108 const struct loadparm_substitution
*lp_sub
=
109 loadparm_s3_global_substitution();
111 SMB_VFS_CONNECT(vfs
->conn
, lp_servicename(talloc_tos(), lp_sub
, SNUM(vfs
->conn
)), "vfstest");
115 static NTSTATUS
cmd_disconnect(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
117 SMB_VFS_DISCONNECT(vfs
->conn
);
121 static NTSTATUS
cmd_disk_free(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
123 struct smb_filename
*smb_fname
= NULL
;
124 uint64_t diskfree
, bsize
, dfree
, dsize
;
126 printf("Usage: disk_free <path>\n");
130 smb_fname
= synthetic_smb_fname(talloc_tos(),
136 if (smb_fname
== NULL
) {
137 return NT_STATUS_NO_MEMORY
;
139 diskfree
= SMB_VFS_DISK_FREE(vfs
->conn
, smb_fname
,
140 &bsize
, &dfree
, &dsize
);
141 printf("disk_free: %lu, bsize = %lu, dfree = %lu, dsize = %lu\n",
142 (unsigned long)diskfree
,
143 (unsigned long)bsize
,
144 (unsigned long)dfree
,
145 (unsigned long)dsize
);
150 static NTSTATUS
cmd_opendir(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
152 struct smb_filename
*smb_fname
= NULL
;
156 printf("Usage: opendir <fname>\n");
160 smb_fname
= synthetic_smb_fname(talloc_tos(),
166 if (smb_fname
== NULL
) {
167 return NT_STATUS_NO_MEMORY
;
170 status
= OpenDir(vfs
->conn
,
176 if (!NT_STATUS_IS_OK(status
)) {
177 int err
= map_errno_from_nt_status(status
);
178 printf("opendir error=%d (%s)\n", err
, strerror(err
));
179 TALLOC_FREE(smb_fname
);
181 return NT_STATUS_UNSUCCESSFUL
;
184 TALLOC_FREE(smb_fname
);
185 printf("opendir: ok\n");
190 static NTSTATUS
cmd_readdir(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
192 struct smb_Dir
*currentdir
= vfs
->currentdir
;
193 files_struct
*dirfsp
= dir_hnd_fetch_fsp(currentdir
);
194 connection_struct
*conn
= dirfsp
->conn
;
196 const char *dname
= NULL
;
197 struct smb_filename
*fname
= NULL
;
198 char *talloced
= NULL
;
201 if (vfs
->currentdir
== NULL
) {
202 printf("readdir: error=-1 (no open directory)\n");
203 return NT_STATUS_UNSUCCESSFUL
;
206 dname
= ReadDirName(vfs
->currentdir
, &talloced
);
208 printf("readdir: NULL\n");
212 fname
= synthetic_smb_fname(
213 talloc_tos(), dname
, NULL
, 0, 0, ssf_flags());
215 printf("readdir: no memory\n");
219 printf("readdir: %s\n", dname
);
221 ret
= SMB_VFS_FSTATAT(conn
, dirfsp
, fname
, &st
, AT_SYMLINK_NOFOLLOW
);
223 if ((ret
== 0) && VALID_STAT(st
)) {
225 printf(" stat available");
226 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
227 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
228 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
229 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
230 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
231 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
232 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
233 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
234 #ifdef HAVE_STAT_ST_BLOCKS
235 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
237 #ifdef HAVE_STAT_ST_BLKSIZE
238 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
240 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
241 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
242 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
243 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
244 printf(" Uid: %5lu Gid: %5lu\n",
245 (unsigned long)st
.st_ex_uid
,
246 (unsigned long)st
.st_ex_gid
);
247 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
248 printf(" Access: %s", ctime(&tmp_time
));
249 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
250 printf(" Modify: %s", ctime(&tmp_time
));
251 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
252 printf(" Change: %s", ctime(&tmp_time
));
255 TALLOC_FREE(talloced
);
260 static NTSTATUS
cmd_mkdir(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
262 struct smb_filename
*smb_fname
= NULL
;
266 printf("Usage: mkdir <path>\n");
270 smb_fname
= synthetic_smb_fname(talloc_tos(),
277 if (smb_fname
== NULL
) {
278 return NT_STATUS_NO_MEMORY
;
281 ret
= SMB_VFS_MKDIRAT(vfs
->conn
,
286 printf("mkdir error=%d (%s)\n", errno
, strerror(errno
));
287 return NT_STATUS_UNSUCCESSFUL
;
290 printf("mkdir: ok\n");
295 static NTSTATUS
cmd_closedir(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
297 if (vfs
->currentdir
== NULL
) {
298 printf("closedir: failure (no directory open)\n");
299 return NT_STATUS_UNSUCCESSFUL
;
302 TALLOC_FREE(vfs
->currentdir
);
304 printf("closedir: ok\n");
309 static NTSTATUS
cmd_open(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
311 struct vfs_open_how how
= { .mode
= 0400, };
314 struct files_struct
*fspcwd
= NULL
;
315 struct smb_filename
*smb_fname
= NULL
;
319 if (argc
< 3 || argc
> 5) {
320 printf("Usage: open <filename> <flags> <mode>\n");
321 printf(" flags: O = O_RDONLY\n");
322 printf(" R = O_RDWR\n");
323 printf(" W = O_WRONLY\n");
324 printf(" C = O_CREAT\n");
325 printf(" E = O_EXCL\n");
326 printf(" T = O_TRUNC\n");
327 printf(" A = O_APPEND\n");
328 printf(" N = O_NONBLOCK/O_NDELAY\n");
330 printf(" S = O_SYNC\n");
333 printf(" F = O_NOFOLLOW\n");
335 printf(" mode: see open.2\n");
336 printf(" mode is ignored if C flag not present\n");
337 printf(" mode defaults to 00400\n");
344 how
.flags
|= O_RDONLY
;
350 how
.flags
|= O_WRONLY
;
353 how
.flags
|= O_CREAT
;
359 how
.flags
|= O_TRUNC
;
362 how
.flags
|= O_APPEND
;
365 how
.flags
|= O_NONBLOCK
;
374 how
.flags
|= O_NOFOLLOW
;
378 printf("open: error=-1 (invalid flag!)\n");
379 return NT_STATUS_UNSUCCESSFUL
;
383 if ((how
.flags
& O_CREAT
) && argc
== 4) {
386 if (sscanf(argv
[3], "%ho", &_mode
) == 0) {
387 printf("open: error=-1 (invalid mode!)\n");
388 return NT_STATUS_UNSUCCESSFUL
;
394 fsp
= talloc_zero(vfs
, struct files_struct
);
398 fsp
->fh
= fd_handle_create(fsp
);
399 if (fsp
->fh
== NULL
) {
402 fsp
->conn
= vfs
->conn
;
404 smb_fname
= synthetic_smb_fname_split(NULL
,
406 lp_posix_pathnames());
407 if (smb_fname
== NULL
) {
411 fsp
->fsp_name
= smb_fname
;
413 status
= vfs_at_fspcwd(fsp
, vfs
->conn
, &fspcwd
);
414 if (!NT_STATUS_IS_OK(status
)) {
418 if (is_named_stream(smb_fname
)) {
419 struct smb_filename
*base_name
= NULL
;
421 base_name
= cp_smb_filename_nostream(NULL
, smb_fname
);
422 if (base_name
== NULL
) {
426 status
= openat_pathref_fsp(fspcwd
, base_name
);
427 if (!NT_STATUS_IS_OK(status
)) {
433 fsp
->base_fsp
= base_name
->fsp
;
436 fd
= SMB_VFS_OPENAT(vfs
->conn
,
442 printf("open: error=%d (%s)\n", errno
, strerror(errno
));
443 status
= map_nt_error_from_unix(errno
);
448 status
= vfs_stat_fsp(fsp
);
449 if (!NT_STATUS_IS_OK(status
)) {
450 /* If we have an fd, this stat should succeed. */
451 DEBUG(0,("Error doing fstat on open file %s "
453 smb_fname_str_dbg(smb_fname
),
454 nt_errstr(status
) ));
455 } else if (S_ISDIR(smb_fname
->st
.st_ex_mode
)) {
457 status
= NT_STATUS_FILE_IS_A_DIRECTORY
;
460 if (!NT_STATUS_IS_OK(status
)) {
465 fsp
->file_id
= vfs_file_id_from_sbuf(vfs
->conn
, &smb_fname
->st
);
466 fsp
->vuid
= UID_FIELD_INVALID
;
468 fsp
->fsp_flags
.can_lock
= true;
469 fsp
->fsp_flags
.can_read
= true;
470 fsp
->fsp_flags
.can_write
= CAN_WRITE(vfs
->conn
);
471 fsp
->print_file
= NULL
;
472 fsp
->fsp_flags
.modified
= false;
473 fsp
->sent_oplock_break
= NO_BREAK_SENT
;
474 fsp
->fsp_flags
.is_directory
= false;
476 vfs
->files
[fsp_get_pathref_fd(fsp
)] = fsp
;
477 printf("open: fd=%d\n", fsp_get_pathref_fd(fsp
));
481 status
= NT_STATUS_NO_MEMORY
;
483 TALLOC_FREE(smb_fname
);
489 static NTSTATUS
cmd_pathfunc(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
491 struct smb_filename
*smb_fname
= NULL
;
495 printf("Usage: %s <path>\n", argv
[0]);
499 smb_fname
= synthetic_smb_fname(talloc_tos(),
506 if (smb_fname
== NULL
) {
507 return NT_STATUS_NO_MEMORY
;
510 if (strcmp("rmdir", argv
[0]) == 0 ) {
511 ret
= SMB_VFS_UNLINKAT(vfs
->conn
,
515 TALLOC_FREE(smb_fname
);
516 } else if (strcmp("unlink", argv
[0]) == 0 ) {
517 TALLOC_FREE(smb_fname
);
518 /* unlink can be a stream:name */
519 smb_fname
= synthetic_smb_fname_split(talloc_tos(),
521 lp_posix_pathnames());
522 if (smb_fname
== NULL
) {
523 return NT_STATUS_NO_MEMORY
;
525 ret
= SMB_VFS_UNLINKAT(vfs
->conn
,
529 TALLOC_FREE(smb_fname
);
530 } else if (strcmp("chdir", argv
[0]) == 0 ) {
531 ret
= SMB_VFS_CHDIR(vfs
->conn
, smb_fname
);
532 TALLOC_FREE(smb_fname
);
534 printf("%s: error=%d (invalid function name!)\n", argv
[0], errno
);
535 return NT_STATUS_UNSUCCESSFUL
;
539 printf("%s: error=%d (%s)\n", argv
[0], errno
, strerror(errno
));
540 return NT_STATUS_UNSUCCESSFUL
;
543 printf("%s: ok\n", argv
[0]);
548 static NTSTATUS
cmd_close(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
554 printf("Usage: close <fd>\n");
559 if (vfs
->files
[fd
] == NULL
) {
560 printf("close: error=-1 (invalid file descriptor)\n");
564 status
= fd_close(vfs
->files
[fd
]);
565 if (!NT_STATUS_IS_OK(status
))
566 printf("close: error=%s\n", nt_errstr(status
));
568 printf("close: ok\n");
570 TALLOC_FREE(vfs
->files
[fd
]);
571 vfs
->files
[fd
] = NULL
;
576 static NTSTATUS
cmd_read(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
583 printf("Usage: read <fd> <size>\n");
587 /* do some error checking on these */
589 size
= atoi(argv
[2]);
590 vfs
->data
= talloc_array(mem_ctx
, char, size
);
591 if (vfs
->data
== NULL
) {
592 printf("read: error=-1 (not enough memory)");
593 return NT_STATUS_UNSUCCESSFUL
;
595 vfs
->data_size
= size
;
597 rsize
= read_file(vfs
->files
[fd
], vfs
->data
, 0, size
);
599 printf("read: error=%d (%s)\n", errno
, strerror(errno
));
600 return NT_STATUS_UNSUCCESSFUL
;
603 printf("read: ok\n");
608 static NTSTATUS
cmd_write(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
614 printf("Usage: write <fd> <size>\n");
618 /* some error checking should go here */
620 size
= atoi(argv
[2]);
621 if (vfs
->data
== NULL
) {
622 printf("write: error=-1 (buffer empty, please populate it before writing)");
623 return NT_STATUS_UNSUCCESSFUL
;
626 if (vfs
->data_size
< size
) {
627 printf("write: error=-1 (buffer too small, please put some more data in)");
628 return NT_STATUS_UNSUCCESSFUL
;
631 wsize
= write_file(NULL
, vfs
->files
[fd
], vfs
->data
, 0, size
);
634 printf("write: error=%d (%s)\n", errno
, strerror(errno
));
635 return NT_STATUS_UNSUCCESSFUL
;
638 printf("write: ok\n");
643 static NTSTATUS
cmd_lseek(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
645 int fd
, offset
, whence
;
649 printf("Usage: lseek <fd> <offset> <whence>\n...where whence is 1 => SEEK_SET, 2 => SEEK_CUR, 3 => SEEK_END\n");
654 offset
= atoi(argv
[2]);
655 whence
= atoi(argv
[3]);
657 case 1: whence
= SEEK_SET
; break;
658 case 2: whence
= SEEK_CUR
; break;
659 default: whence
= SEEK_END
;
662 pos
= SMB_VFS_LSEEK(vfs
->files
[fd
], offset
, whence
);
663 if (pos
== (off_t
)-1) {
664 printf("lseek: error=%d (%s)\n", errno
, strerror(errno
));
665 return NT_STATUS_UNSUCCESSFUL
;
668 printf("lseek: ok\n");
673 static NTSTATUS
cmd_rename(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
676 struct smb_filename
*smb_fname_src
= NULL
;
677 struct smb_filename
*smb_fname_dst
= NULL
;
678 struct vfs_rename_how rhow
= { .flags
= 0, };
681 printf("Usage: rename <old> <new>\n");
685 smb_fname_src
= synthetic_smb_fname_split(mem_ctx
,
687 lp_posix_pathnames());
688 if (smb_fname_src
== NULL
) {
689 return NT_STATUS_NO_MEMORY
;
692 smb_fname_dst
= synthetic_smb_fname_split(mem_ctx
,
694 lp_posix_pathnames());
695 if (smb_fname_dst
== NULL
) {
696 TALLOC_FREE(smb_fname_src
);
697 return NT_STATUS_NO_MEMORY
;
700 ret
= SMB_VFS_RENAMEAT(vfs
->conn
,
707 TALLOC_FREE(smb_fname_src
);
708 TALLOC_FREE(smb_fname_dst
);
710 printf("rename: error=%d (%s)\n", errno
, strerror(errno
));
711 return NT_STATUS_UNSUCCESSFUL
;
714 printf("rename: ok\n");
718 static NTSTATUS
cmd_fsync(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
722 printf("Usage: fsync <fd>\n");
727 ret
= smb_vfs_fsync_sync(vfs
->files
[fd
]);
729 printf("fsync: error=%d (%s)\n", errno
, strerror(errno
));
730 return NT_STATUS_UNSUCCESSFUL
;
733 printf("fsync: ok\n");
738 static NTSTATUS
cmd_stat(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
743 struct passwd
*pwd
= NULL
;
744 struct group
*grp
= NULL
;
745 struct smb_filename
*smb_fname
= NULL
;
750 printf("Usage: stat <fname>\n");
754 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
756 lp_posix_pathnames());
757 if (smb_fname
== NULL
) {
758 return NT_STATUS_NO_MEMORY
;
761 ret
= SMB_VFS_STAT(vfs
->conn
, smb_fname
);
763 printf("stat: error=%d (%s)\n", errno
, strerror(errno
));
764 TALLOC_FREE(smb_fname
);
765 return NT_STATUS_UNSUCCESSFUL
;
768 TALLOC_FREE(smb_fname
);
770 pwd
= getpwuid(st
.st_ex_uid
);
771 if (pwd
!= NULL
) user
= pwd
->pw_name
;
772 else user
= null_string
;
773 grp
= getgrgid(st
.st_ex_gid
);
774 if (grp
!= NULL
) group
= grp
->gr_name
;
775 else group
= null_string
;
777 printf("stat: ok\n");
778 printf(" File: %s", argv
[1]);
779 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
780 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
781 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
782 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
783 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
784 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
785 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
786 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
787 #ifdef HAVE_STAT_ST_BLOCKS
788 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
790 #ifdef HAVE_STAT_ST_BLKSIZE
791 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
793 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
794 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
795 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
796 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
797 printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st
.st_ex_uid
, user
,
798 (unsigned long)st
.st_ex_gid
, group
);
799 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
800 printf(" Access: %s", ctime(&tmp_time
));
801 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
802 printf(" Modify: %s", ctime(&tmp_time
));
803 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
804 printf(" Change: %s", ctime(&tmp_time
));
810 static NTSTATUS
cmd_fstat(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
815 struct passwd
*pwd
= NULL
;
816 struct group
*grp
= NULL
;
821 printf("Usage: fstat <fd>\n");
826 if (fd
< 0 || fd
>= 1024) {
827 printf("fstat: error=%d (file descriptor out of range)\n", EBADF
);
831 if (vfs
->files
[fd
] == NULL
) {
832 printf("fstat: error=%d (invalid file descriptor)\n", EBADF
);
836 if (SMB_VFS_FSTAT(vfs
->files
[fd
], &st
) == -1) {
837 printf("fstat: error=%d (%s)\n", errno
, strerror(errno
));
838 return NT_STATUS_UNSUCCESSFUL
;
841 pwd
= getpwuid(st
.st_ex_uid
);
842 if (pwd
!= NULL
) user
= pwd
->pw_name
;
843 else user
= null_string
;
844 grp
= getgrgid(st
.st_ex_gid
);
845 if (grp
!= NULL
) group
= grp
->gr_name
;
846 else group
= null_string
;
848 printf("fstat: ok\n");
849 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
850 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
851 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
852 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
853 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
854 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
855 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
856 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
857 #ifdef HAVE_STAT_ST_BLOCKS
858 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
860 #ifdef HAVE_STAT_ST_BLKSIZE
861 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
863 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
864 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
865 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
866 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
867 printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st
.st_ex_uid
, user
,
868 (unsigned long)st
.st_ex_gid
, group
);
869 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
870 printf(" Access: %s", ctime(&tmp_time
));
871 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
872 printf(" Modify: %s", ctime(&tmp_time
));
873 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
874 printf(" Change: %s", ctime(&tmp_time
));
880 static NTSTATUS
cmd_lstat(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
884 struct passwd
*pwd
= NULL
;
885 struct group
*grp
= NULL
;
886 struct smb_filename
*smb_fname
= NULL
;
891 printf("Usage: lstat <path>\n");
895 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
897 lp_posix_pathnames());
898 if (smb_fname
== NULL
) {
899 return NT_STATUS_NO_MEMORY
;
902 if (SMB_VFS_LSTAT(vfs
->conn
, smb_fname
) == -1) {
903 printf("lstat: error=%d (%s)\n", errno
, strerror(errno
));
904 TALLOC_FREE(smb_fname
);
905 return NT_STATUS_UNSUCCESSFUL
;
908 TALLOC_FREE(smb_fname
);
910 pwd
= getpwuid(st
.st_ex_uid
);
911 if (pwd
!= NULL
) user
= pwd
->pw_name
;
912 else user
= null_string
;
913 grp
= getgrgid(st
.st_ex_gid
);
914 if (grp
!= NULL
) group
= grp
->gr_name
;
915 else group
= null_string
;
917 printf("lstat: ok\n");
918 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
919 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
920 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
921 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
922 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
923 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
924 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
925 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
926 #ifdef HAVE_STAT_ST_BLOCKS
927 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
929 #ifdef HAVE_STAT_ST_BLKSIZE
930 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
932 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
933 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
934 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
935 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
936 printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st
.st_ex_uid
, user
,
937 (unsigned long)st
.st_ex_gid
, group
);
938 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
939 printf(" Access: %s", ctime(&tmp_time
));
940 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
941 printf(" Modify: %s", ctime(&tmp_time
));
942 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
943 printf(" Change: %s", ctime(&tmp_time
));
949 static NTSTATUS
cmd_chmod(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
951 struct smb_filename
*smb_fname
= NULL
;
953 struct smb_filename
*pathref_fname
= NULL
;
956 printf("Usage: chmod <path> <mode>\n");
960 mode
= atoi(argv
[2]);
962 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
964 lp_posix_pathnames());
965 if (smb_fname
== NULL
) {
966 return NT_STATUS_NO_MEMORY
;
969 status
= synthetic_pathref(mem_ctx
,
971 smb_fname
->base_name
,
977 if (!NT_STATUS_IS_OK(status
)) {
980 if (SMB_VFS_FCHMOD(pathref_fname
->fsp
, mode
) == -1) {
981 printf("chmod: error=%d (%s)\n", errno
, strerror(errno
));
982 return NT_STATUS_UNSUCCESSFUL
;
985 printf("chmod: ok\n");
990 static NTSTATUS
cmd_fchmod(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
995 printf("Usage: fchmod <fd> <mode>\n");
1000 mode
= atoi(argv
[2]);
1001 if (fd
< 0 || fd
>= 1024) {
1002 printf("fchmod: error=%d (file descriptor out of range)\n", EBADF
);
1003 return NT_STATUS_OK
;
1005 if (vfs
->files
[fd
] == NULL
) {
1006 printf("fchmod: error=%d (invalid file descriptor)\n", EBADF
);
1007 return NT_STATUS_OK
;
1010 if (SMB_VFS_FCHMOD(vfs
->files
[fd
], mode
) == -1) {
1011 printf("fchmod: error=%d (%s)\n", errno
, strerror(errno
));
1012 return NT_STATUS_UNSUCCESSFUL
;
1015 printf("fchmod: ok\n");
1016 return NT_STATUS_OK
;
1019 static NTSTATUS
cmd_fchown(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1025 printf("Usage: fchown <fd> <uid> <gid>\n");
1026 return NT_STATUS_OK
;
1029 uid
= atoi(argv
[2]);
1030 gid
= atoi(argv
[3]);
1032 if (fd
< 0 || fd
>= 1024) {
1033 printf("fchown: failure=%d (file descriptor out of range)\n", EBADF
);
1034 return NT_STATUS_OK
;
1036 if (vfs
->files
[fd
] == NULL
) {
1037 printf("fchown: error=%d (invalid file descriptor)\n", EBADF
);
1038 return NT_STATUS_OK
;
1040 if (SMB_VFS_FCHOWN(vfs
->files
[fd
], uid
, gid
) == -1) {
1041 printf("fchown error=%d (%s)\n", errno
, strerror(errno
));
1042 return NT_STATUS_UNSUCCESSFUL
;
1045 printf("fchown: ok\n");
1046 return NT_STATUS_OK
;
1050 static NTSTATUS
cmd_getwd(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1052 struct smb_filename
*smb_fname
= SMB_VFS_GETWD(vfs
->conn
, talloc_tos());
1053 if (smb_fname
== NULL
) {
1054 printf("getwd: error=%d (%s)\n", errno
, strerror(errno
));
1055 return NT_STATUS_UNSUCCESSFUL
;
1058 printf("getwd: %s\n", smb_fname
->base_name
);
1059 TALLOC_FREE(smb_fname
);
1060 return NT_STATUS_OK
;
1063 static NTSTATUS
cmd_utime(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1065 struct smb_file_time ft
;
1066 struct files_struct
*dirfsp
= NULL
;
1067 struct smb_filename
*smb_fname
= NULL
;
1071 printf("Usage: utime <path> <access> <modify>\n");
1072 return NT_STATUS_OK
;
1075 init_smb_file_time(&ft
);
1077 ft
.atime
= time_t_to_full_timespec(atoi(argv
[2]));
1078 ft
.mtime
= time_t_to_full_timespec(atoi(argv
[3]));
1080 status
= filename_convert_dirfsp(mem_ctx
,
1087 if (!NT_STATUS_IS_OK(status
)) {
1088 printf("utime: %s\n", nt_errstr(status
));
1092 if (SMB_VFS_FNTIMES(smb_fname
->fsp
, &ft
) != 0) {
1093 printf("utime: error=%d (%s)\n", errno
, strerror(errno
));
1094 TALLOC_FREE(smb_fname
);
1095 return NT_STATUS_UNSUCCESSFUL
;
1098 TALLOC_FREE(smb_fname
);
1099 printf("utime: ok\n");
1100 return NT_STATUS_OK
;
1103 static NTSTATUS
cmd_ftruncate(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1108 printf("Usage: ftruncate <fd> <length>\n");
1109 return NT_STATUS_OK
;
1113 off
= atoi(argv
[2]);
1114 if (fd
< 0 || fd
>= 1024) {
1115 printf("ftruncate: error=%d (file descriptor out of range)\n", EBADF
);
1116 return NT_STATUS_OK
;
1118 if (vfs
->files
[fd
] == NULL
) {
1119 printf("ftruncate: error=%d (invalid file descriptor)\n", EBADF
);
1120 return NT_STATUS_OK
;
1123 if (SMB_VFS_FTRUNCATE(vfs
->files
[fd
], off
) == -1) {
1124 printf("ftruncate: error=%d (%s)\n", errno
, strerror(errno
));
1125 return NT_STATUS_UNSUCCESSFUL
;
1128 printf("ftruncate: ok\n");
1129 return NT_STATUS_OK
;
1132 static NTSTATUS
cmd_lock(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1139 const char *typestr
;
1142 printf("Usage: lock <fd> <op> <offset> <count> <type>\n");
1143 printf(" ops: G = F_GETLK\n");
1144 printf(" S = F_SETLK\n");
1145 printf(" W = F_SETLKW\n");
1146 printf(" type: R = F_RDLCK\n");
1147 printf(" W = F_WRLCK\n");
1148 printf(" U = F_UNLCK\n");
1149 return NT_STATUS_OK
;
1152 if (sscanf(argv
[1], "%d", &fd
) == 0) {
1153 printf("lock: error=-1 (error parsing fd)\n");
1154 return NT_STATUS_UNSUCCESSFUL
;
1169 printf("lock: error=-1 (invalid op flag!)\n");
1170 return NT_STATUS_UNSUCCESSFUL
;
1173 if (sscanf(argv
[3], "%ld", &offset
) == 0) {
1174 printf("lock: error=-1 (error parsing fd)\n");
1175 return NT_STATUS_UNSUCCESSFUL
;
1178 if (sscanf(argv
[4], "%ld", &count
) == 0) {
1179 printf("lock: error=-1 (error parsing fd)\n");
1180 return NT_STATUS_UNSUCCESSFUL
;
1197 printf("lock: error=-1 (invalid type flag!)\n");
1198 return NT_STATUS_UNSUCCESSFUL
;
1203 printf("lock: debug lock(fd=%d, op=%d, offset=%ld, count=%ld, type=%d))\n", fd
, op
, offset
, count
, type
);
1205 if (SMB_VFS_LOCK(vfs
->files
[fd
], op
, offset
, count
, type
) == False
) {
1206 printf("lock: error=%d (%s)\n", errno
, strerror(errno
));
1207 return NT_STATUS_UNSUCCESSFUL
;
1210 printf("lock: ok\n");
1211 return NT_STATUS_OK
;
1214 static NTSTATUS
cmd_symlink(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1217 char *target
= NULL
;
1218 struct smb_filename target_fname
;
1219 struct smb_filename
*new_smb_fname
= NULL
;
1223 printf("Usage: symlink <path> <link>\n");
1224 return NT_STATUS_OK
;
1227 new_smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1229 lp_posix_pathnames());
1230 if (new_smb_fname
== NULL
) {
1231 return NT_STATUS_NO_MEMORY
;
1234 target
= talloc_strdup(mem_ctx
, argv
[1]);
1235 if (target
== NULL
) {
1236 return NT_STATUS_NO_MEMORY
;
1239 target_fname
= (struct smb_filename
) {
1240 .base_name
= target
,
1243 /* Removes @GMT tokens if any */
1244 status
= canonicalize_snapshot_path(&target_fname
, UCF_GMT_PATHNAME
, 0);
1245 if (!NT_STATUS_IS_OK(status
)) {
1249 ret
= SMB_VFS_SYMLINKAT(vfs
->conn
,
1254 printf("symlink: error=%d (%s)\n", errno
, strerror(errno
));
1255 return NT_STATUS_UNSUCCESSFUL
;
1258 printf("symlink: ok\n");
1259 return NT_STATUS_OK
;
1263 static NTSTATUS
cmd_readlink(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1265 char buffer
[PATH_MAX
];
1266 struct smb_filename
*smb_fname
= NULL
;
1270 printf("Usage: readlink <path>\n");
1271 return NT_STATUS_OK
;
1274 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1276 lp_posix_pathnames());
1277 if (smb_fname
== NULL
) {
1278 return NT_STATUS_NO_MEMORY
;
1280 size
= SMB_VFS_READLINKAT(vfs
->conn
,
1287 printf("readlink: error=%d (%s)\n", errno
, strerror(errno
));
1288 return NT_STATUS_UNSUCCESSFUL
;
1291 buffer
[size
] = '\0';
1292 printf("readlink: %s\n", buffer
);
1293 return NT_STATUS_OK
;
1297 static NTSTATUS
cmd_link(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1299 struct smb_filename
*old_smb_fname
= NULL
;
1300 struct smb_filename
*new_smb_fname
= NULL
;
1304 printf("Usage: link <path> <link>\n");
1305 return NT_STATUS_OK
;
1308 old_smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1310 lp_posix_pathnames());
1311 if (old_smb_fname
== NULL
) {
1312 return NT_STATUS_NO_MEMORY
;
1314 new_smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1316 lp_posix_pathnames());
1317 if (new_smb_fname
== NULL
) {
1318 return NT_STATUS_NO_MEMORY
;
1321 ret
= SMB_VFS_LINKAT(vfs
->conn
,
1328 printf("link: error=%d (%s)\n", errno
, strerror(errno
));
1329 return NT_STATUS_UNSUCCESSFUL
;
1332 printf("link: ok\n");
1333 return NT_STATUS_OK
;
1336 static NTSTATUS
cmd_mknod(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1340 unsigned int dev_val
;
1342 struct smb_filename
*smb_fname
= NULL
;
1346 printf("Usage: mknod <path> <mode> <dev>\n");
1347 printf(" mode is octal\n");
1348 printf(" dev is hex\n");
1349 return NT_STATUS_OK
;
1352 if (sscanf(argv
[2], "%ho", &_mode
) == 0) {
1353 printf("open: error=-1 (invalid mode!)\n");
1354 return NT_STATUS_UNSUCCESSFUL
;
1358 if (sscanf(argv
[3], "%x", &dev_val
) == 0) {
1359 printf("open: error=-1 (invalid dev!)\n");
1360 return NT_STATUS_UNSUCCESSFUL
;
1362 dev
= (SMB_DEV_T
)dev_val
;
1364 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1366 lp_posix_pathnames());
1367 if (smb_fname
== NULL
) {
1368 return NT_STATUS_NO_MEMORY
;
1371 ret
= SMB_VFS_MKNODAT(vfs
->conn
,
1378 printf("mknod: error=%d (%s)\n", errno
, strerror(errno
));
1379 return NT_STATUS_UNSUCCESSFUL
;
1382 printf("mknod: ok\n");
1383 return NT_STATUS_OK
;
1386 static NTSTATUS
cmd_realpath(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1388 struct smb_filename
*smb_fname
= NULL
;
1391 printf("Usage: realpath <path>\n");
1392 return NT_STATUS_OK
;
1395 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1397 lp_posix_pathnames());
1398 if (smb_fname
== NULL
) {
1399 return NT_STATUS_NO_MEMORY
;
1401 if (SMB_VFS_REALPATH(vfs
->conn
, mem_ctx
, smb_fname
) == NULL
) {
1402 printf("realpath: error=%d (%s)\n", errno
, strerror(errno
));
1403 return NT_STATUS_UNSUCCESSFUL
;
1406 printf("realpath: ok\n");
1407 return NT_STATUS_OK
;
1410 static NTSTATUS
cmd_getxattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1411 int argc
, const char **argv
)
1415 struct smb_filename
*smb_fname
= NULL
;
1416 struct smb_filename
*pathref_fname
= NULL
;
1420 printf("Usage: getxattr <path> <xattr>\n");
1421 return NT_STATUS_OK
;
1426 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1428 lp_posix_pathnames());
1429 if (smb_fname
== NULL
) {
1430 return NT_STATUS_NO_MEMORY
;
1432 status
= synthetic_pathref(mem_ctx
,
1434 smb_fname
->base_name
,
1440 if (!NT_STATUS_IS_OK(status
)) {
1443 ret
= SMB_VFS_FGETXATTR(pathref_fname
->fsp
,
1446 talloc_get_size(buf
));
1449 printf("getxattr returned (%s)\n", strerror(err
));
1450 return map_nt_error_from_unix(err
);
1452 buf
= talloc_array(mem_ctx
, uint8_t, ret
);
1454 return NT_STATUS_NO_MEMORY
;
1456 ret
= SMB_VFS_FGETXATTR(pathref_fname
->fsp
,
1459 talloc_get_size(buf
));
1462 printf("getxattr returned (%s)\n", strerror(err
));
1463 return map_nt_error_from_unix(err
);
1465 dump_data_file(buf
, talloc_get_size(buf
), false, stdout
);
1466 return NT_STATUS_OK
;
1469 static NTSTATUS
cmd_listxattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1470 int argc
, const char **argv
)
1474 struct smb_filename
*smb_fname
= NULL
;
1475 struct smb_filename
*pathref_fname
= NULL
;
1478 printf("Usage: listxattr <path>\n");
1479 return NT_STATUS_OK
;
1484 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1486 lp_posix_pathnames());
1487 if (smb_fname
== NULL
) {
1488 return NT_STATUS_NO_MEMORY
;
1490 status
= synthetic_pathref(mem_ctx
,
1492 smb_fname
->base_name
,
1498 if (!NT_STATUS_IS_OK(status
)) {
1502 ret
= SMB_VFS_FLISTXATTR(pathref_fname
->fsp
,
1503 buf
, talloc_get_size(buf
));
1506 printf("listxattr returned (%s)\n", strerror(err
));
1507 return map_nt_error_from_unix(err
);
1509 buf
= talloc_array(mem_ctx
, char, ret
);
1511 return NT_STATUS_NO_MEMORY
;
1513 ret
= SMB_VFS_FLISTXATTR(pathref_fname
->fsp
,
1514 buf
, talloc_get_size(buf
));
1517 printf("listxattr returned (%s)\n", strerror(err
));
1518 return map_nt_error_from_unix(err
);
1521 return NT_STATUS_OK
;
1523 if (buf
[ret
-1] != '\0') {
1524 printf("listxattr returned non 0-terminated strings\n");
1525 return NT_STATUS_INTERNAL_ERROR
;
1529 while (p
< buf
+ret
) {
1534 return NT_STATUS_OK
;
1537 static NTSTATUS
cmd_fsetxattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1538 int argc
, const char **argv
)
1542 struct smb_filename
*smb_fname
= NULL
;
1543 struct smb_filename
*pathref_fname
= NULL
;
1546 if ((argc
< 4) || (argc
> 5)) {
1547 printf("Usage: setxattr <path> <xattr> <value> [flags]\n");
1548 return NT_STATUS_OK
;
1552 flags
= atoi(argv
[4]);
1555 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1557 lp_posix_pathnames());
1558 if (smb_fname
== NULL
) {
1559 return NT_STATUS_NO_MEMORY
;
1562 status
= synthetic_pathref(mem_ctx
,
1564 smb_fname
->base_name
,
1570 if (!NT_STATUS_IS_OK(status
)) {
1574 ret
= SMB_VFS_FSETXATTR(pathref_fname
->fsp
, argv
[2],
1575 argv
[3], strlen(argv
[3]), flags
);
1578 printf("fsetxattr returned (%s)\n", strerror(err
));
1579 return map_nt_error_from_unix(err
);
1581 return NT_STATUS_OK
;
1584 static NTSTATUS
cmd_removexattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1585 int argc
, const char **argv
)
1588 struct smb_filename
*smb_fname
= NULL
;
1589 struct smb_filename
*pathref_fname
= NULL
;
1593 printf("Usage: removexattr <path> <xattr>\n");
1594 return NT_STATUS_OK
;
1597 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1599 lp_posix_pathnames());
1600 if (smb_fname
== NULL
) {
1601 return NT_STATUS_NO_MEMORY
;
1603 status
= synthetic_pathref(mem_ctx
,
1605 smb_fname
->base_name
,
1611 if (!NT_STATUS_IS_OK(status
)) {
1614 ret
= SMB_VFS_FREMOVEXATTR(pathref_fname
->fsp
, argv
[2]);
1617 printf("removexattr returned (%s)\n", strerror(err
));
1618 return map_nt_error_from_unix(err
);
1620 return NT_STATUS_OK
;
1623 static NTSTATUS
cmd_fget_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1624 int argc
, const char **argv
)
1628 struct security_descriptor
*sd
;
1631 printf("Usage: fget_nt_acl <fd>\n");
1632 return NT_STATUS_OK
;
1636 if (fd
< 0 || fd
>= 1024) {
1637 printf("fget_nt_acl: error=%d (file descriptor out of range)\n", EBADF
);
1638 return NT_STATUS_OK
;
1640 if (vfs
->files
[fd
] == NULL
) {
1641 printf("fget_nt_acl: error=%d (invalid file descriptor)\n", EBADF
);
1642 return NT_STATUS_OK
;
1645 status
= SMB_VFS_FGET_NT_ACL(metadata_fsp(vfs
->files
[fd
]),
1646 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1648 if (!NT_STATUS_IS_OK(status
)) {
1649 printf("fget_nt_acl returned (%s)\n", nt_errstr(status
));
1652 printf("%s\n", sddl_encode(talloc_tos(), sd
, get_global_sam_sid()));
1654 return NT_STATUS_OK
;
1657 static NTSTATUS
cmd_get_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1658 int argc
, const char **argv
)
1661 struct security_descriptor
*sd
;
1662 struct smb_filename
*smb_fname
= NULL
;
1663 struct smb_filename
*pathref_fname
= NULL
;
1666 printf("Usage: get_nt_acl <path>\n");
1667 return NT_STATUS_OK
;
1670 smb_fname
= synthetic_smb_fname(talloc_tos(),
1677 if (smb_fname
== NULL
) {
1678 return NT_STATUS_NO_MEMORY
;
1681 status
= synthetic_pathref(mem_ctx
,
1683 smb_fname
->base_name
,
1689 if (!NT_STATUS_IS_OK(status
)) {
1690 TALLOC_FREE(smb_fname
);
1693 status
= SMB_VFS_FGET_NT_ACL(pathref_fname
->fsp
,
1694 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1697 if (!NT_STATUS_IS_OK(status
)) {
1698 printf("get_nt_acl returned (%s)\n", nt_errstr(status
));
1699 TALLOC_FREE(smb_fname
);
1700 TALLOC_FREE(pathref_fname
);
1703 printf("%s\n", sddl_encode(talloc_tos(), sd
, get_global_sam_sid()));
1705 TALLOC_FREE(smb_fname
);
1706 TALLOC_FREE(pathref_fname
);
1707 return NT_STATUS_OK
;
1710 static NTSTATUS
cmd_fset_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1711 int argc
, const char **argv
)
1715 struct security_descriptor
*sd
;
1718 printf("Usage: fset_nt_acl <fd> <sddl>\n");
1719 return NT_STATUS_OK
;
1723 if (fd
< 0 || fd
>= 1024) {
1724 printf("fset_nt_acl: error=%d (file descriptor out of range)\n", EBADF
);
1725 return NT_STATUS_OK
;
1727 if (vfs
->files
[fd
] == NULL
) {
1728 printf("fset_nt_acl: error=%d (invalid file descriptor)\n", EBADF
);
1729 return NT_STATUS_OK
;
1732 sd
= sddl_decode(talloc_tos(), argv
[2], get_global_sam_sid());
1734 printf("sddl_decode failed to parse %s as SDDL\n", argv
[2]);
1735 return NT_STATUS_INVALID_PARAMETER
;
1738 status
= SMB_VFS_FSET_NT_ACL(
1739 metadata_fsp(vfs
->files
[fd
]),
1740 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1742 if (!NT_STATUS_IS_OK(status
)) {
1743 printf("fset_nt_acl returned (%s)\n", nt_errstr(status
));
1747 return NT_STATUS_OK
;
1750 static NTSTATUS
cmd_set_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1752 struct vfs_open_how how
= { .mode
= 0400, };
1754 struct files_struct
*fspcwd
= NULL
;
1755 struct smb_filename
*smb_fname
= NULL
;
1757 struct security_descriptor
*sd
= NULL
;
1761 printf("Usage: set_nt_acl <file> <sddl>\n");
1762 return NT_STATUS_OK
;
1766 fsp
= talloc_zero(vfs
, struct files_struct
);
1768 return NT_STATUS_NO_MEMORY
;
1770 fsp
->fh
= fd_handle_create(fsp
);
1771 if (fsp
->fh
== NULL
) {
1773 return NT_STATUS_NO_MEMORY
;
1775 fsp
->conn
= vfs
->conn
;
1777 smb_fname
= synthetic_smb_fname_split(NULL
,
1779 lp_posix_pathnames());
1780 if (smb_fname
== NULL
) {
1782 return NT_STATUS_NO_MEMORY
;
1785 fsp
->fsp_name
= smb_fname
;
1787 status
= vfs_at_fspcwd(fsp
, vfs
->conn
, &fspcwd
);
1788 if (!NT_STATUS_IS_OK(status
)) {
1793 fd
= SMB_VFS_OPENAT(vfs
->conn
,
1798 if (fd
== -1 && errno
== EISDIR
) {
1800 how
.flags
= O_RDONLY
|O_DIRECTORY
;
1802 /* POSIX allows us to open a directory with O_RDONLY. */
1803 how
.flags
= O_RDONLY
;
1805 fd
= SMB_VFS_OPENAT(vfs
->conn
,
1812 printf("open: error=%d (%s)\n", errno
, strerror(errno
));
1814 TALLOC_FREE(smb_fname
);
1815 return NT_STATUS_UNSUCCESSFUL
;
1817 fsp_set_fd(fsp
, fd
);
1819 status
= vfs_stat_fsp(fsp
);
1820 if (!NT_STATUS_IS_OK(status
)) {
1821 /* If we have an fd, this stat should succeed. */
1822 DEBUG(0,("Error doing fstat on open file %s "
1824 smb_fname_str_dbg(smb_fname
),
1825 nt_errstr(status
) ));
1829 fsp
->file_id
= vfs_file_id_from_sbuf(vfs
->conn
, &smb_fname
->st
);
1830 fsp
->vuid
= UID_FIELD_INVALID
;
1832 fsp
->fsp_flags
.can_lock
= true;
1833 fsp
->fsp_flags
.can_read
= true;
1834 fsp
->fsp_flags
.can_write
= true;
1835 fsp
->print_file
= NULL
;
1836 fsp
->fsp_flags
.modified
= false;
1837 fsp
->sent_oplock_break
= NO_BREAK_SENT
;
1838 fsp
->fsp_flags
.is_directory
= S_ISDIR(smb_fname
->st
.st_ex_mode
);
1840 sd
= sddl_decode(talloc_tos(), argv
[2], get_global_sam_sid());
1842 printf("sddl_decode failed to parse %s as SDDL\n", argv
[2]);
1843 status
= NT_STATUS_INVALID_PARAMETER
;
1847 status
= SMB_VFS_FSET_NT_ACL(
1849 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1851 if (!NT_STATUS_IS_OK(status
)) {
1852 printf("fset_nt_acl returned (%s)\n", nt_errstr(status
));
1858 status
= fd_close(fsp
);
1859 if (!NT_STATUS_IS_OK(status
))
1860 printf("close: error= (%s)\n", nt_errstr(status
));
1869 static NTSTATUS
cmd_sys_acl_get_fd(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1870 int argc
, const char **argv
)
1877 printf("Usage: sys_acl_get_fd <fd>\n");
1878 return NT_STATUS_OK
;
1882 if (fd
< 0 || fd
>= 1024) {
1883 printf("sys_acl_get_fd: error=%d (file descriptor out of range)\n", EBADF
);
1884 return NT_STATUS_OK
;
1886 if (vfs
->files
[fd
] == NULL
) {
1887 printf("sys_acl_get_fd: error=%d (invalid file descriptor)\n", EBADF
);
1888 return NT_STATUS_OK
;
1891 acl
= SMB_VFS_SYS_ACL_GET_FD(vfs
->files
[fd
],
1892 SMB_ACL_TYPE_ACCESS
,
1895 printf("sys_acl_get_fd failed (%s)\n", strerror(errno
));
1896 return NT_STATUS_UNSUCCESSFUL
;
1898 acl_text
= sys_acl_to_text(acl
, NULL
);
1899 printf("%s", acl_text
);
1901 SAFE_FREE(acl_text
);
1902 return NT_STATUS_OK
;
1905 static NTSTATUS
cmd_sys_acl_get_file(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1906 int argc
, const char **argv
)
1911 struct smb_filename
*smb_fname
= NULL
;
1912 struct smb_filename
*pathref_fname
= NULL
;
1916 printf("Usage: sys_acl_get_file <path> <type>\n");
1917 return NT_STATUS_OK
;
1920 smb_fname
= synthetic_smb_fname_split(talloc_tos(),
1922 lp_posix_pathnames());
1923 if (smb_fname
== NULL
) {
1924 return NT_STATUS_NO_MEMORY
;
1926 type
= atoi(argv
[2]);
1928 status
= synthetic_pathref(mem_ctx
,
1930 smb_fname
->base_name
,
1936 if (!NT_STATUS_IS_OK(status
)) {
1937 TALLOC_FREE(smb_fname
);
1941 acl
= SMB_VFS_SYS_ACL_GET_FD(pathref_fname
->fsp
,
1942 type
, talloc_tos());
1944 printf("sys_acl_get_fd failed (%s)\n", strerror(errno
));
1945 TALLOC_FREE(smb_fname
);
1946 TALLOC_FREE(pathref_fname
);
1947 return NT_STATUS_UNSUCCESSFUL
;
1949 acl_text
= sys_acl_to_text(acl
, NULL
);
1950 printf("%s", acl_text
);
1952 TALLOC_FREE(smb_fname
);
1953 TALLOC_FREE(pathref_fname
);
1954 SAFE_FREE(acl_text
);
1955 return NT_STATUS_OK
;
1958 static NTSTATUS
cmd_sys_acl_blob_get_file(struct vfs_state
*vfs
,
1959 TALLOC_CTX
*mem_ctx
,
1960 int argc
, const char **argv
)
1966 struct smb_filename
*smb_fname
= NULL
;
1967 struct smb_filename
*pathref_fname
= NULL
;
1971 printf("Usage: sys_acl_blob_get_file <path>\n");
1972 return NT_STATUS_OK
;
1975 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1977 lp_posix_pathnames());
1978 if (smb_fname
== NULL
) {
1979 return NT_STATUS_NO_MEMORY
;
1981 status
= synthetic_pathref(mem_ctx
,
1983 smb_fname
->base_name
,
1989 if (!NT_STATUS_IS_OK(status
)) {
1990 TALLOC_FREE(smb_fname
);
1994 ret
= SMB_VFS_SYS_ACL_BLOB_GET_FD(pathref_fname
->fsp
,
1999 status
= map_nt_error_from_unix(errno
);
2000 printf("sys_acl_blob_get_file failed (%s)\n", strerror(errno
));
2001 TALLOC_FREE(smb_fname
);
2002 TALLOC_FREE(pathref_fname
);
2005 printf("Description: %s\n", description
);
2006 for (i
= 0; i
< blob
.length
; i
++) {
2007 printf("%.2x ", blob
.data
[i
]);
2011 TALLOC_FREE(smb_fname
);
2012 TALLOC_FREE(pathref_fname
);
2013 return NT_STATUS_OK
;
2016 static NTSTATUS
cmd_sys_acl_blob_get_fd(struct vfs_state
*vfs
,
2017 TALLOC_CTX
*mem_ctx
,
2018 int argc
, const char **argv
)
2027 printf("Usage: sys_acl_blob_get_fd <fd>\n");
2028 return NT_STATUS_OK
;
2032 if (fd
< 0 || fd
>= 1024) {
2033 printf("sys_acl_blob_get_fd: error=%d "
2034 "(file descriptor out of range)\n", EBADF
);
2035 return NT_STATUS_OK
;
2037 if (vfs
->files
[fd
] == NULL
) {
2038 printf("sys_acl_blob_get_fd: error=%d "
2039 "(invalid file descriptor)\n", EBADF
);
2040 return NT_STATUS_OK
;
2043 ret
= SMB_VFS_SYS_ACL_BLOB_GET_FD(vfs
->files
[fd
], talloc_tos(),
2044 &description
, &blob
);
2046 printf("sys_acl_blob_get_fd failed (%s)\n", strerror(errno
));
2047 return map_nt_error_from_unix(errno
);
2049 printf("Description: %s\n", description
);
2050 for (i
= 0; i
< blob
.length
; i
++) {
2051 printf("%.2x ", blob
.data
[i
]);
2055 return NT_STATUS_OK
;
2060 static NTSTATUS
cmd_sys_acl_delete_def_file(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
2061 int argc
, const char **argv
)
2064 struct smb_filename
*smb_fname
= NULL
;
2065 struct smb_filename
*pathref_fname
= NULL
;
2069 printf("Usage: sys_acl_delete_def_file <path>\n");
2070 return NT_STATUS_OK
;
2073 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
2075 lp_posix_pathnames());
2076 if (smb_fname
== NULL
) {
2077 return NT_STATUS_NO_MEMORY
;
2079 status
= synthetic_pathref(mem_ctx
,
2081 smb_fname
->base_name
,
2087 if (!NT_STATUS_IS_OK(status
)) {
2088 TALLOC_FREE(smb_fname
);
2091 if (!pathref_fname
->fsp
->fsp_flags
.is_directory
) {
2092 printf("sys_acl_delete_def_file - %s is not a directory\n",
2093 smb_fname
->base_name
);
2094 TALLOC_FREE(smb_fname
);
2095 TALLOC_FREE(pathref_fname
);
2096 return NT_STATUS_INVALID_PARAMETER
;
2098 ret
= SMB_VFS_SYS_ACL_DELETE_DEF_FD(pathref_fname
->fsp
);
2101 printf("sys_acl_delete_def_file failed (%s)\n", strerror(err
));
2102 TALLOC_FREE(smb_fname
);
2103 TALLOC_FREE(pathref_fname
);
2104 return map_nt_error_from_unix(err
);
2106 TALLOC_FREE(smb_fname
);
2107 TALLOC_FREE(pathref_fname
);
2108 return NT_STATUS_OK
;
2111 /* Afaik translate name was first introduced with vfs_catia, to be able
2112 to translate unix file/dir-names, containing invalid windows characters,
2113 to valid windows names.
2114 The used translation direction is always unix --> windows
2116 static NTSTATUS
cmd_translate_name(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
2117 int argc
, const char **argv
)
2119 const char *dname
= NULL
;
2120 char *dname_talloced
= NULL
;
2122 char *translated
= NULL
;
2123 struct smb_filename
*smb_fname
= NULL
;
2127 DEBUG(0, ("Usage: translate_name unix_filename\n"));
2128 return NT_STATUS_UNSUCCESSFUL
;
2131 smb_fname
= synthetic_smb_fname(talloc_tos(),
2137 if (smb_fname
== NULL
) {
2138 return NT_STATUS_NO_MEMORY
;
2141 status
= OpenDir(vfs
->conn
,
2147 if (!NT_STATUS_IS_OK(status
)) {
2148 int err
= map_errno_from_nt_status(status
);
2149 DEBUG(0, ("cmd_translate_name: opendir error=%d (%s)\n",
2150 err
, strerror(err
)));
2151 TALLOC_FREE(smb_fname
);
2153 return NT_STATUS_UNSUCCESSFUL
;
2157 /* ReadDirName() returns Windows "encoding" */
2158 dname
= ReadDirName(vfs
->currentdir
, &dname_talloced
);
2159 if (dname
== NULL
) {
2163 /* Convert Windows "encoding" from ReadDirName() to UNIX */
2164 status
= SMB_VFS_TRANSLATE_NAME(vfs
->conn
,
2166 vfs_translate_to_unix
,
2169 if (!NT_STATUS_IS_OK(status
)) {
2170 DBG_ERR("file '%s' cannot be translated\n", argv
[1]);
2175 * argv[1] uses UNIX "encoding", so compare with translation
2178 if (strcmp(translated
, argv
[1]) == 0) {
2182 TALLOC_FREE(dname_talloced
);
2183 TALLOC_FREE(translated
);
2187 DEBUG(0, ("cmd_translate_name: file '%s' not found.\n",
2189 status
= NT_STATUS_UNSUCCESSFUL
;
2193 /* translation success. But that could also mean
2194 that translating "aaa" to "aaa" was successful :-(
2196 DBG_ERR("file '%s' --> '%s'\n", argv
[1], dname
);
2197 status
= NT_STATUS_OK
;
2200 TALLOC_FREE(dname_talloced
);
2201 TALLOC_FREE(translated
);
2202 TALLOC_FREE(smb_fname
);
2203 TALLOC_FREE(vfs
->currentdir
);
2208 * This is a quick hack to demonstrate a crash in the full_audit
2209 * module when passing fsp->smb_fname into SMB_VFS_CREATE_FILE leading
2212 * Feel free to expand with more options as needed
2214 static NTSTATUS
cmd_create_file(
2215 struct vfs_state
*vfs
,
2216 TALLOC_CTX
*mem_ctx
,
2220 struct smb_filename
*fname
= NULL
;
2221 struct files_struct
*fsp
= NULL
;
2226 DBG_ERR("Usage: create_file filename\n");
2227 return NT_STATUS_UNSUCCESSFUL
;
2230 fname
= synthetic_smb_fname(
2231 talloc_tos(), argv
[1], NULL
, NULL
, 0, 0);
2232 if (fname
== NULL
) {
2233 return NT_STATUS_NO_MEMORY
;
2236 ret
= vfs_stat(vfs
->conn
, fname
);
2238 status
= map_nt_error_from_unix(errno
);
2239 DBG_DEBUG("vfs_stat() failed: %s\n", strerror(errno
));
2244 status
= openat_pathref_fsp(vfs
->conn
->cwd_fsp
, fname
);
2245 if (!NT_STATUS_IS_OK(status
)) {
2246 DBG_DEBUG("Could not open %s: %s\n",
2253 status
= SMB_VFS_CREATE_FILE(
2259 * Using fname->fsp->fsp_name seems to be legal,
2260 * there's code to handle this in
2261 * create_file_unixpath(). And it is actually very
2262 * worthwhile re-using the fsp_name, we can save quite
2263 * a few copies of smb_filename with that.
2265 fname
->fsp
->fsp_name
,
2269 FILE_NON_DIRECTORY_FILE
,
2282 DBG_DEBUG("create_file returned %s\n", nt_errstr(status
));
2286 return NT_STATUS_OK
;
2289 struct cmd_set vfs_commands
[] = {
2291 { .name
= "VFS Commands" },
2293 { "load", cmd_load_module
, "Load a module", "load <module.so>" },
2294 { "populate", cmd_populate
, "Populate a data buffer", "populate <char> <size>" },
2295 { "showdata", cmd_show_data
, "Show data currently in data buffer", "show_data [<offset> <len>]"},
2296 { "connect", cmd_connect
, "VFS connect()", "connect" },
2297 { "disconnect", cmd_disconnect
, "VFS disconnect()", "disconnect" },
2298 { "disk_free", cmd_disk_free
, "VFS disk_free()", "disk_free <path>" },
2299 { "opendir", cmd_opendir
, "VFS opendir()", "opendir <fname>" },
2300 { "readdir", cmd_readdir
, "VFS readdir()", "readdir" },
2301 { "mkdir", cmd_mkdir
, "VFS mkdir()", "mkdir <path>" },
2302 { "rmdir", cmd_pathfunc
, "VFS rmdir()", "rmdir <path>" },
2303 { "closedir", cmd_closedir
, "VFS closedir()", "closedir" },
2304 { "open", cmd_open
, "VFS open()", "open <fname> <flags> <mode>" },
2305 { "close", cmd_close
, "VFS close()", "close <fd>" },
2306 { "read", cmd_read
, "VFS read()", "read <fd> <size>" },
2307 { "write", cmd_write
, "VFS write()", "write <fd> <size>" },
2308 { "lseek", cmd_lseek
, "VFS lseek()", "lseek <fd> <offset> <whence>" },
2309 { "rename", cmd_rename
, "VFS rename()", "rename <old> <new>" },
2310 { "fsync", cmd_fsync
, "VFS fsync()", "fsync <fd>" },
2311 { "stat", cmd_stat
, "VFS stat()", "stat <fname>" },
2312 { "fstat", cmd_fstat
, "VFS fstat()", "fstat <fd>" },
2313 { "lstat", cmd_lstat
, "VFS lstat()", "lstat <fname>" },
2314 { "unlink", cmd_pathfunc
, "VFS unlink()", "unlink <fname>" },
2315 { "chmod", cmd_chmod
, "VFS chmod()", "chmod <path> <mode>" },
2316 { "fchmod", cmd_fchmod
, "VFS fchmod()", "fchmod <fd> <mode>" },
2317 { "fchown", cmd_fchown
, "VFS fchown()", "fchown <fd> <uid> <gid>" },
2318 { "chdir", cmd_pathfunc
, "VFS chdir()", "chdir <path>" },
2319 { "getwd", cmd_getwd
, "VFS getwd()", "getwd" },
2320 { "utime", cmd_utime
, "VFS utime()", "utime <path> <access> <modify>" },
2321 { "ftruncate", cmd_ftruncate
, "VFS ftruncate()", "ftruncate <fd> <length>" },
2322 { "lock", cmd_lock
, "VFS lock()", "lock <f> <op> <offset> <count> <type>" },
2323 { "symlink", cmd_symlink
, "VFS symlink()", "symlink <old> <new>" },
2324 { "readlink", cmd_readlink
, "VFS readlink()", "readlink <path>" },
2325 { "link", cmd_link
, "VFS link()", "link <oldpath> <newpath>" },
2326 { "mknod", cmd_mknod
, "VFS mknod()", "mknod <path> <mode> <dev>" },
2327 { "realpath", cmd_realpath
, "VFS realpath()", "realpath <path>" },
2328 { "getxattr", cmd_getxattr
, "VFS getxattr()",
2329 "getxattr <path> <name>" },
2330 { "listxattr", cmd_listxattr
, "VFS listxattr()",
2331 "listxattr <path>" },
2332 { "fsetxattr", cmd_fsetxattr
, "VFS fsetxattr()",
2333 "fsetxattr <path> <name> <value> [<flags>]" },
2334 { "removexattr", cmd_removexattr
, "VFS removexattr()",
2335 "removexattr <path> <name>\n" },
2336 { "fget_nt_acl", cmd_fget_nt_acl
, "VFS fget_nt_acl()",
2337 "fget_nt_acl <fd>\n" },
2338 { "get_nt_acl", cmd_get_nt_acl
, "VFS get_nt_acl()",
2339 "get_nt_acl <path>\n" },
2340 { "fset_nt_acl", cmd_fset_nt_acl
, "VFS fset_nt_acl()",
2341 "fset_nt_acl <fd>\n" },
2342 { "set_nt_acl", cmd_set_nt_acl
, "VFS open() and fset_nt_acl()",
2343 "set_nt_acl <file>\n" },
2344 { "sys_acl_get_file", cmd_sys_acl_get_file
, "VFS sys_acl_get_file()", "sys_acl_get_file <path>" },
2345 { "sys_acl_get_fd", cmd_sys_acl_get_fd
, "VFS sys_acl_get_fd()", "sys_acl_get_fd <fd>" },
2346 { "sys_acl_blob_get_file", cmd_sys_acl_blob_get_file
,
2347 "VFS sys_acl_blob_get_file()", "sys_acl_blob_get_file <path>" },
2348 { "sys_acl_blob_get_fd", cmd_sys_acl_blob_get_fd
,
2349 "VFS sys_acl_blob_get_fd()", "sys_acl_blob_get_fd <path>" },
2350 { "sys_acl_delete_def_file", cmd_sys_acl_delete_def_file
, "VFS sys_acl_delete_def_file()", "sys_acl_delete_def_file <path>" },
2353 #if defined(WITH_SMB1SERVER)
2354 { "test_chain", cmd_test_chain
, "test chain code",
2357 { "translate_name", cmd_translate_name
, "VFS translate_name()", "translate_name unix_filename" },
2360 "VFS create_file()",
2361 "create_file <filename>"