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
;
680 printf("Usage: rename <old> <new>\n");
684 smb_fname_src
= synthetic_smb_fname_split(mem_ctx
,
686 lp_posix_pathnames());
687 if (smb_fname_src
== NULL
) {
688 return NT_STATUS_NO_MEMORY
;
691 smb_fname_dst
= synthetic_smb_fname_split(mem_ctx
,
693 lp_posix_pathnames());
694 if (smb_fname_dst
== NULL
) {
695 TALLOC_FREE(smb_fname_src
);
696 return NT_STATUS_NO_MEMORY
;
699 ret
= SMB_VFS_RENAMEAT(vfs
->conn
,
705 TALLOC_FREE(smb_fname_src
);
706 TALLOC_FREE(smb_fname_dst
);
708 printf("rename: error=%d (%s)\n", errno
, strerror(errno
));
709 return NT_STATUS_UNSUCCESSFUL
;
712 printf("rename: ok\n");
716 static NTSTATUS
cmd_fsync(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
720 printf("Usage: fsync <fd>\n");
725 ret
= smb_vfs_fsync_sync(vfs
->files
[fd
]);
727 printf("fsync: error=%d (%s)\n", errno
, strerror(errno
));
728 return NT_STATUS_UNSUCCESSFUL
;
731 printf("fsync: ok\n");
736 static NTSTATUS
cmd_stat(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
741 struct passwd
*pwd
= NULL
;
742 struct group
*grp
= NULL
;
743 struct smb_filename
*smb_fname
= NULL
;
748 printf("Usage: stat <fname>\n");
752 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
754 lp_posix_pathnames());
755 if (smb_fname
== NULL
) {
756 return NT_STATUS_NO_MEMORY
;
759 ret
= SMB_VFS_STAT(vfs
->conn
, smb_fname
);
761 printf("stat: error=%d (%s)\n", errno
, strerror(errno
));
762 TALLOC_FREE(smb_fname
);
763 return NT_STATUS_UNSUCCESSFUL
;
766 TALLOC_FREE(smb_fname
);
768 pwd
= getpwuid(st
.st_ex_uid
);
769 if (pwd
!= NULL
) user
= pwd
->pw_name
;
770 else user
= null_string
;
771 grp
= getgrgid(st
.st_ex_gid
);
772 if (grp
!= NULL
) group
= grp
->gr_name
;
773 else group
= null_string
;
775 printf("stat: ok\n");
776 printf(" File: %s", argv
[1]);
777 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
778 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
779 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
780 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
781 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
782 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
783 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
784 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
785 #ifdef HAVE_STAT_ST_BLOCKS
786 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
788 #ifdef HAVE_STAT_ST_BLKSIZE
789 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
791 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
792 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
793 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
794 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
795 printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st
.st_ex_uid
, user
,
796 (unsigned long)st
.st_ex_gid
, group
);
797 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
798 printf(" Access: %s", ctime(&tmp_time
));
799 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
800 printf(" Modify: %s", ctime(&tmp_time
));
801 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
802 printf(" Change: %s", ctime(&tmp_time
));
808 static NTSTATUS
cmd_fstat(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
813 struct passwd
*pwd
= NULL
;
814 struct group
*grp
= NULL
;
819 printf("Usage: fstat <fd>\n");
824 if (fd
< 0 || fd
>= 1024) {
825 printf("fstat: error=%d (file descriptor out of range)\n", EBADF
);
829 if (vfs
->files
[fd
] == NULL
) {
830 printf("fstat: error=%d (invalid file descriptor)\n", EBADF
);
834 if (SMB_VFS_FSTAT(vfs
->files
[fd
], &st
) == -1) {
835 printf("fstat: error=%d (%s)\n", errno
, strerror(errno
));
836 return NT_STATUS_UNSUCCESSFUL
;
839 pwd
= getpwuid(st
.st_ex_uid
);
840 if (pwd
!= NULL
) user
= pwd
->pw_name
;
841 else user
= null_string
;
842 grp
= getgrgid(st
.st_ex_gid
);
843 if (grp
!= NULL
) group
= grp
->gr_name
;
844 else group
= null_string
;
846 printf("fstat: ok\n");
847 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
848 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
849 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
850 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
851 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
852 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
853 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
854 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
855 #ifdef HAVE_STAT_ST_BLOCKS
856 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
858 #ifdef HAVE_STAT_ST_BLKSIZE
859 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
861 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
862 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
863 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
864 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
865 printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st
.st_ex_uid
, user
,
866 (unsigned long)st
.st_ex_gid
, group
);
867 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
868 printf(" Access: %s", ctime(&tmp_time
));
869 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
870 printf(" Modify: %s", ctime(&tmp_time
));
871 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
872 printf(" Change: %s", ctime(&tmp_time
));
878 static NTSTATUS
cmd_lstat(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
882 struct passwd
*pwd
= NULL
;
883 struct group
*grp
= NULL
;
884 struct smb_filename
*smb_fname
= NULL
;
889 printf("Usage: lstat <path>\n");
893 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
895 lp_posix_pathnames());
896 if (smb_fname
== NULL
) {
897 return NT_STATUS_NO_MEMORY
;
900 if (SMB_VFS_LSTAT(vfs
->conn
, smb_fname
) == -1) {
901 printf("lstat: error=%d (%s)\n", errno
, strerror(errno
));
902 TALLOC_FREE(smb_fname
);
903 return NT_STATUS_UNSUCCESSFUL
;
906 TALLOC_FREE(smb_fname
);
908 pwd
= getpwuid(st
.st_ex_uid
);
909 if (pwd
!= NULL
) user
= pwd
->pw_name
;
910 else user
= null_string
;
911 grp
= getgrgid(st
.st_ex_gid
);
912 if (grp
!= NULL
) group
= grp
->gr_name
;
913 else group
= null_string
;
915 printf("lstat: ok\n");
916 if (S_ISREG(st
.st_ex_mode
)) printf(" Regular File\n");
917 else if (S_ISDIR(st
.st_ex_mode
)) printf(" Directory\n");
918 else if (S_ISCHR(st
.st_ex_mode
)) printf(" Character Device\n");
919 else if (S_ISBLK(st
.st_ex_mode
)) printf(" Block Device\n");
920 else if (S_ISFIFO(st
.st_ex_mode
)) printf(" Fifo\n");
921 else if (S_ISLNK(st
.st_ex_mode
)) printf(" Symbolic Link\n");
922 else if (S_ISSOCK(st
.st_ex_mode
)) printf(" Socket\n");
923 printf(" Size: %10u", (unsigned int)st
.st_ex_size
);
924 #ifdef HAVE_STAT_ST_BLOCKS
925 printf(" Blocks: %9u", (unsigned int)st
.st_ex_blocks
);
927 #ifdef HAVE_STAT_ST_BLKSIZE
928 printf(" IO Block: %u\n", (unsigned int)st
.st_ex_blksize
);
930 printf(" Device: 0x%10x", (unsigned int)st
.st_ex_dev
);
931 printf(" Inode: %10u", (unsigned int)st
.st_ex_ino
);
932 printf(" Links: %10u\n", (unsigned int)st
.st_ex_nlink
);
933 printf(" Access: %05o", (int)((st
.st_ex_mode
) & 007777));
934 printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st
.st_ex_uid
, user
,
935 (unsigned long)st
.st_ex_gid
, group
);
936 tmp_time
= convert_timespec_to_time_t(st
.st_ex_atime
);
937 printf(" Access: %s", ctime(&tmp_time
));
938 tmp_time
= convert_timespec_to_time_t(st
.st_ex_mtime
);
939 printf(" Modify: %s", ctime(&tmp_time
));
940 tmp_time
= convert_timespec_to_time_t(st
.st_ex_ctime
);
941 printf(" Change: %s", ctime(&tmp_time
));
947 static NTSTATUS
cmd_chmod(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
949 struct smb_filename
*smb_fname
= NULL
;
951 struct smb_filename
*pathref_fname
= NULL
;
954 printf("Usage: chmod <path> <mode>\n");
958 mode
= atoi(argv
[2]);
960 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
962 lp_posix_pathnames());
963 if (smb_fname
== NULL
) {
964 return NT_STATUS_NO_MEMORY
;
967 status
= synthetic_pathref(mem_ctx
,
969 smb_fname
->base_name
,
975 if (!NT_STATUS_IS_OK(status
)) {
978 if (SMB_VFS_FCHMOD(pathref_fname
->fsp
, mode
) == -1) {
979 printf("chmod: error=%d (%s)\n", errno
, strerror(errno
));
980 return NT_STATUS_UNSUCCESSFUL
;
983 printf("chmod: ok\n");
988 static NTSTATUS
cmd_fchmod(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
993 printf("Usage: fchmod <fd> <mode>\n");
998 mode
= atoi(argv
[2]);
999 if (fd
< 0 || fd
>= 1024) {
1000 printf("fchmod: error=%d (file descriptor out of range)\n", EBADF
);
1001 return NT_STATUS_OK
;
1003 if (vfs
->files
[fd
] == NULL
) {
1004 printf("fchmod: error=%d (invalid file descriptor)\n", EBADF
);
1005 return NT_STATUS_OK
;
1008 if (SMB_VFS_FCHMOD(vfs
->files
[fd
], mode
) == -1) {
1009 printf("fchmod: error=%d (%s)\n", errno
, strerror(errno
));
1010 return NT_STATUS_UNSUCCESSFUL
;
1013 printf("fchmod: ok\n");
1014 return NT_STATUS_OK
;
1017 static NTSTATUS
cmd_fchown(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1023 printf("Usage: fchown <fd> <uid> <gid>\n");
1024 return NT_STATUS_OK
;
1027 uid
= atoi(argv
[2]);
1028 gid
= atoi(argv
[3]);
1030 if (fd
< 0 || fd
>= 1024) {
1031 printf("fchown: failure=%d (file descriptor out of range)\n", EBADF
);
1032 return NT_STATUS_OK
;
1034 if (vfs
->files
[fd
] == NULL
) {
1035 printf("fchown: error=%d (invalid file descriptor)\n", EBADF
);
1036 return NT_STATUS_OK
;
1038 if (SMB_VFS_FCHOWN(vfs
->files
[fd
], uid
, gid
) == -1) {
1039 printf("fchown error=%d (%s)\n", errno
, strerror(errno
));
1040 return NT_STATUS_UNSUCCESSFUL
;
1043 printf("fchown: ok\n");
1044 return NT_STATUS_OK
;
1048 static NTSTATUS
cmd_getwd(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1050 struct smb_filename
*smb_fname
= SMB_VFS_GETWD(vfs
->conn
, talloc_tos());
1051 if (smb_fname
== NULL
) {
1052 printf("getwd: error=%d (%s)\n", errno
, strerror(errno
));
1053 return NT_STATUS_UNSUCCESSFUL
;
1056 printf("getwd: %s\n", smb_fname
->base_name
);
1057 TALLOC_FREE(smb_fname
);
1058 return NT_STATUS_OK
;
1061 static NTSTATUS
cmd_utime(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1063 struct smb_file_time ft
;
1064 struct files_struct
*dirfsp
= NULL
;
1065 struct smb_filename
*smb_fname
= NULL
;
1069 printf("Usage: utime <path> <access> <modify>\n");
1070 return NT_STATUS_OK
;
1073 init_smb_file_time(&ft
);
1075 ft
.atime
= time_t_to_full_timespec(atoi(argv
[2]));
1076 ft
.mtime
= time_t_to_full_timespec(atoi(argv
[3]));
1078 status
= filename_convert_dirfsp(mem_ctx
,
1085 if (!NT_STATUS_IS_OK(status
)) {
1086 printf("utime: %s\n", nt_errstr(status
));
1090 if (SMB_VFS_FNTIMES(smb_fname
->fsp
, &ft
) != 0) {
1091 printf("utime: error=%d (%s)\n", errno
, strerror(errno
));
1092 TALLOC_FREE(smb_fname
);
1093 return NT_STATUS_UNSUCCESSFUL
;
1096 TALLOC_FREE(smb_fname
);
1097 printf("utime: ok\n");
1098 return NT_STATUS_OK
;
1101 static NTSTATUS
cmd_ftruncate(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1106 printf("Usage: ftruncate <fd> <length>\n");
1107 return NT_STATUS_OK
;
1111 off
= atoi(argv
[2]);
1112 if (fd
< 0 || fd
>= 1024) {
1113 printf("ftruncate: error=%d (file descriptor out of range)\n", EBADF
);
1114 return NT_STATUS_OK
;
1116 if (vfs
->files
[fd
] == NULL
) {
1117 printf("ftruncate: error=%d (invalid file descriptor)\n", EBADF
);
1118 return NT_STATUS_OK
;
1121 if (SMB_VFS_FTRUNCATE(vfs
->files
[fd
], off
) == -1) {
1122 printf("ftruncate: error=%d (%s)\n", errno
, strerror(errno
));
1123 return NT_STATUS_UNSUCCESSFUL
;
1126 printf("ftruncate: ok\n");
1127 return NT_STATUS_OK
;
1130 static NTSTATUS
cmd_lock(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1137 const char *typestr
;
1140 printf("Usage: lock <fd> <op> <offset> <count> <type>\n");
1141 printf(" ops: G = F_GETLK\n");
1142 printf(" S = F_SETLK\n");
1143 printf(" W = F_SETLKW\n");
1144 printf(" type: R = F_RDLCK\n");
1145 printf(" W = F_WRLCK\n");
1146 printf(" U = F_UNLCK\n");
1147 return NT_STATUS_OK
;
1150 if (sscanf(argv
[1], "%d", &fd
) == 0) {
1151 printf("lock: error=-1 (error parsing fd)\n");
1152 return NT_STATUS_UNSUCCESSFUL
;
1167 printf("lock: error=-1 (invalid op flag!)\n");
1168 return NT_STATUS_UNSUCCESSFUL
;
1171 if (sscanf(argv
[3], "%ld", &offset
) == 0) {
1172 printf("lock: error=-1 (error parsing fd)\n");
1173 return NT_STATUS_UNSUCCESSFUL
;
1176 if (sscanf(argv
[4], "%ld", &count
) == 0) {
1177 printf("lock: error=-1 (error parsing fd)\n");
1178 return NT_STATUS_UNSUCCESSFUL
;
1195 printf("lock: error=-1 (invalid type flag!)\n");
1196 return NT_STATUS_UNSUCCESSFUL
;
1201 printf("lock: debug lock(fd=%d, op=%d, offset=%ld, count=%ld, type=%d))\n", fd
, op
, offset
, count
, type
);
1203 if (SMB_VFS_LOCK(vfs
->files
[fd
], op
, offset
, count
, type
) == False
) {
1204 printf("lock: error=%d (%s)\n", errno
, strerror(errno
));
1205 return NT_STATUS_UNSUCCESSFUL
;
1208 printf("lock: ok\n");
1209 return NT_STATUS_OK
;
1212 static NTSTATUS
cmd_symlink(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1215 char *target
= NULL
;
1216 struct smb_filename target_fname
;
1217 struct smb_filename
*new_smb_fname
= NULL
;
1221 printf("Usage: symlink <path> <link>\n");
1222 return NT_STATUS_OK
;
1225 new_smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1227 lp_posix_pathnames());
1228 if (new_smb_fname
== NULL
) {
1229 return NT_STATUS_NO_MEMORY
;
1232 target
= talloc_strdup(mem_ctx
, argv
[1]);
1233 if (target
== NULL
) {
1234 return NT_STATUS_NO_MEMORY
;
1237 target_fname
= (struct smb_filename
) {
1238 .base_name
= target
,
1241 /* Removes @GMT tokens if any */
1242 status
= canonicalize_snapshot_path(&target_fname
, UCF_GMT_PATHNAME
, 0);
1243 if (!NT_STATUS_IS_OK(status
)) {
1247 ret
= SMB_VFS_SYMLINKAT(vfs
->conn
,
1252 printf("symlink: error=%d (%s)\n", errno
, strerror(errno
));
1253 return NT_STATUS_UNSUCCESSFUL
;
1256 printf("symlink: ok\n");
1257 return NT_STATUS_OK
;
1261 static NTSTATUS
cmd_readlink(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1263 char buffer
[PATH_MAX
];
1264 struct smb_filename
*smb_fname
= NULL
;
1268 printf("Usage: readlink <path>\n");
1269 return NT_STATUS_OK
;
1272 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1274 lp_posix_pathnames());
1275 if (smb_fname
== NULL
) {
1276 return NT_STATUS_NO_MEMORY
;
1278 size
= SMB_VFS_READLINKAT(vfs
->conn
,
1285 printf("readlink: error=%d (%s)\n", errno
, strerror(errno
));
1286 return NT_STATUS_UNSUCCESSFUL
;
1289 buffer
[size
] = '\0';
1290 printf("readlink: %s\n", buffer
);
1291 return NT_STATUS_OK
;
1295 static NTSTATUS
cmd_link(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1297 struct smb_filename
*old_smb_fname
= NULL
;
1298 struct smb_filename
*new_smb_fname
= NULL
;
1302 printf("Usage: link <path> <link>\n");
1303 return NT_STATUS_OK
;
1306 old_smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1308 lp_posix_pathnames());
1309 if (old_smb_fname
== NULL
) {
1310 return NT_STATUS_NO_MEMORY
;
1312 new_smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1314 lp_posix_pathnames());
1315 if (new_smb_fname
== NULL
) {
1316 return NT_STATUS_NO_MEMORY
;
1319 ret
= SMB_VFS_LINKAT(vfs
->conn
,
1326 printf("link: error=%d (%s)\n", errno
, strerror(errno
));
1327 return NT_STATUS_UNSUCCESSFUL
;
1330 printf("link: ok\n");
1331 return NT_STATUS_OK
;
1334 static NTSTATUS
cmd_mknod(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1338 unsigned int dev_val
;
1340 struct smb_filename
*smb_fname
= NULL
;
1344 printf("Usage: mknod <path> <mode> <dev>\n");
1345 printf(" mode is octal\n");
1346 printf(" dev is hex\n");
1347 return NT_STATUS_OK
;
1350 if (sscanf(argv
[2], "%ho", &_mode
) == 0) {
1351 printf("open: error=-1 (invalid mode!)\n");
1352 return NT_STATUS_UNSUCCESSFUL
;
1356 if (sscanf(argv
[3], "%x", &dev_val
) == 0) {
1357 printf("open: error=-1 (invalid dev!)\n");
1358 return NT_STATUS_UNSUCCESSFUL
;
1360 dev
= (SMB_DEV_T
)dev_val
;
1362 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1364 lp_posix_pathnames());
1365 if (smb_fname
== NULL
) {
1366 return NT_STATUS_NO_MEMORY
;
1369 ret
= SMB_VFS_MKNODAT(vfs
->conn
,
1376 printf("mknod: error=%d (%s)\n", errno
, strerror(errno
));
1377 return NT_STATUS_UNSUCCESSFUL
;
1380 printf("mknod: ok\n");
1381 return NT_STATUS_OK
;
1384 static NTSTATUS
cmd_realpath(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1386 struct smb_filename
*smb_fname
= NULL
;
1389 printf("Usage: realpath <path>\n");
1390 return NT_STATUS_OK
;
1393 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1395 lp_posix_pathnames());
1396 if (smb_fname
== NULL
) {
1397 return NT_STATUS_NO_MEMORY
;
1399 if (SMB_VFS_REALPATH(vfs
->conn
, mem_ctx
, smb_fname
) == NULL
) {
1400 printf("realpath: error=%d (%s)\n", errno
, strerror(errno
));
1401 return NT_STATUS_UNSUCCESSFUL
;
1404 printf("realpath: ok\n");
1405 return NT_STATUS_OK
;
1408 static NTSTATUS
cmd_getxattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1409 int argc
, const char **argv
)
1413 struct smb_filename
*smb_fname
= NULL
;
1414 struct smb_filename
*pathref_fname
= NULL
;
1418 printf("Usage: getxattr <path> <xattr>\n");
1419 return NT_STATUS_OK
;
1424 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1426 lp_posix_pathnames());
1427 if (smb_fname
== NULL
) {
1428 return NT_STATUS_NO_MEMORY
;
1430 status
= synthetic_pathref(mem_ctx
,
1432 smb_fname
->base_name
,
1438 if (!NT_STATUS_IS_OK(status
)) {
1441 ret
= SMB_VFS_FGETXATTR(pathref_fname
->fsp
,
1444 talloc_get_size(buf
));
1447 printf("getxattr returned (%s)\n", strerror(err
));
1448 return map_nt_error_from_unix(err
);
1450 buf
= talloc_array(mem_ctx
, uint8_t, ret
);
1452 return NT_STATUS_NO_MEMORY
;
1454 ret
= SMB_VFS_FGETXATTR(pathref_fname
->fsp
,
1457 talloc_get_size(buf
));
1460 printf("getxattr returned (%s)\n", strerror(err
));
1461 return map_nt_error_from_unix(err
);
1463 dump_data_file(buf
, talloc_get_size(buf
), false, stdout
);
1464 return NT_STATUS_OK
;
1467 static NTSTATUS
cmd_listxattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1468 int argc
, const char **argv
)
1472 struct smb_filename
*smb_fname
= NULL
;
1473 struct smb_filename
*pathref_fname
= NULL
;
1476 printf("Usage: listxattr <path>\n");
1477 return NT_STATUS_OK
;
1482 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1484 lp_posix_pathnames());
1485 if (smb_fname
== NULL
) {
1486 return NT_STATUS_NO_MEMORY
;
1488 status
= synthetic_pathref(mem_ctx
,
1490 smb_fname
->base_name
,
1496 if (!NT_STATUS_IS_OK(status
)) {
1500 ret
= SMB_VFS_FLISTXATTR(pathref_fname
->fsp
,
1501 buf
, talloc_get_size(buf
));
1504 printf("listxattr returned (%s)\n", strerror(err
));
1505 return map_nt_error_from_unix(err
);
1507 buf
= talloc_array(mem_ctx
, char, ret
);
1509 return NT_STATUS_NO_MEMORY
;
1511 ret
= SMB_VFS_FLISTXATTR(pathref_fname
->fsp
,
1512 buf
, talloc_get_size(buf
));
1515 printf("listxattr returned (%s)\n", strerror(err
));
1516 return map_nt_error_from_unix(err
);
1519 return NT_STATUS_OK
;
1521 if (buf
[ret
-1] != '\0') {
1522 printf("listxattr returned non 0-terminated strings\n");
1523 return NT_STATUS_INTERNAL_ERROR
;
1527 while (p
< buf
+ret
) {
1532 return NT_STATUS_OK
;
1535 static NTSTATUS
cmd_fsetxattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1536 int argc
, const char **argv
)
1540 struct smb_filename
*smb_fname
= NULL
;
1541 struct smb_filename
*pathref_fname
= NULL
;
1544 if ((argc
< 4) || (argc
> 5)) {
1545 printf("Usage: setxattr <path> <xattr> <value> [flags]\n");
1546 return NT_STATUS_OK
;
1550 flags
= atoi(argv
[4]);
1553 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1555 lp_posix_pathnames());
1556 if (smb_fname
== NULL
) {
1557 return NT_STATUS_NO_MEMORY
;
1560 status
= synthetic_pathref(mem_ctx
,
1562 smb_fname
->base_name
,
1568 if (!NT_STATUS_IS_OK(status
)) {
1572 ret
= SMB_VFS_FSETXATTR(pathref_fname
->fsp
, argv
[2],
1573 argv
[3], strlen(argv
[3]), flags
);
1576 printf("fsetxattr returned (%s)\n", strerror(err
));
1577 return map_nt_error_from_unix(err
);
1579 return NT_STATUS_OK
;
1582 static NTSTATUS
cmd_removexattr(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1583 int argc
, const char **argv
)
1586 struct smb_filename
*smb_fname
= NULL
;
1587 struct smb_filename
*pathref_fname
= NULL
;
1591 printf("Usage: removexattr <path> <xattr>\n");
1592 return NT_STATUS_OK
;
1595 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1597 lp_posix_pathnames());
1598 if (smb_fname
== NULL
) {
1599 return NT_STATUS_NO_MEMORY
;
1601 status
= synthetic_pathref(mem_ctx
,
1603 smb_fname
->base_name
,
1609 if (!NT_STATUS_IS_OK(status
)) {
1612 ret
= SMB_VFS_FREMOVEXATTR(pathref_fname
->fsp
, argv
[2]);
1615 printf("removexattr returned (%s)\n", strerror(err
));
1616 return map_nt_error_from_unix(err
);
1618 return NT_STATUS_OK
;
1621 static NTSTATUS
cmd_fget_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1622 int argc
, const char **argv
)
1626 struct security_descriptor
*sd
;
1629 printf("Usage: fget_nt_acl <fd>\n");
1630 return NT_STATUS_OK
;
1634 if (fd
< 0 || fd
>= 1024) {
1635 printf("fget_nt_acl: error=%d (file descriptor out of range)\n", EBADF
);
1636 return NT_STATUS_OK
;
1638 if (vfs
->files
[fd
] == NULL
) {
1639 printf("fget_nt_acl: error=%d (invalid file descriptor)\n", EBADF
);
1640 return NT_STATUS_OK
;
1643 status
= SMB_VFS_FGET_NT_ACL(metadata_fsp(vfs
->files
[fd
]),
1644 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1646 if (!NT_STATUS_IS_OK(status
)) {
1647 printf("fget_nt_acl returned (%s)\n", nt_errstr(status
));
1650 printf("%s\n", sddl_encode(talloc_tos(), sd
, get_global_sam_sid()));
1652 return NT_STATUS_OK
;
1655 static NTSTATUS
cmd_get_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1656 int argc
, const char **argv
)
1659 struct security_descriptor
*sd
;
1660 struct smb_filename
*smb_fname
= NULL
;
1661 struct smb_filename
*pathref_fname
= NULL
;
1664 printf("Usage: get_nt_acl <path>\n");
1665 return NT_STATUS_OK
;
1668 smb_fname
= synthetic_smb_fname(talloc_tos(),
1675 if (smb_fname
== NULL
) {
1676 return NT_STATUS_NO_MEMORY
;
1679 status
= synthetic_pathref(mem_ctx
,
1681 smb_fname
->base_name
,
1687 if (!NT_STATUS_IS_OK(status
)) {
1688 TALLOC_FREE(smb_fname
);
1691 status
= SMB_VFS_FGET_NT_ACL(pathref_fname
->fsp
,
1692 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1695 if (!NT_STATUS_IS_OK(status
)) {
1696 printf("get_nt_acl returned (%s)\n", nt_errstr(status
));
1697 TALLOC_FREE(smb_fname
);
1698 TALLOC_FREE(pathref_fname
);
1701 printf("%s\n", sddl_encode(talloc_tos(), sd
, get_global_sam_sid()));
1703 TALLOC_FREE(smb_fname
);
1704 TALLOC_FREE(pathref_fname
);
1705 return NT_STATUS_OK
;
1708 static NTSTATUS
cmd_fset_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1709 int argc
, const char **argv
)
1713 struct security_descriptor
*sd
;
1716 printf("Usage: fset_nt_acl <fd> <sddl>\n");
1717 return NT_STATUS_OK
;
1721 if (fd
< 0 || fd
>= 1024) {
1722 printf("fset_nt_acl: error=%d (file descriptor out of range)\n", EBADF
);
1723 return NT_STATUS_OK
;
1725 if (vfs
->files
[fd
] == NULL
) {
1726 printf("fset_nt_acl: error=%d (invalid file descriptor)\n", EBADF
);
1727 return NT_STATUS_OK
;
1730 sd
= sddl_decode(talloc_tos(), argv
[2], get_global_sam_sid());
1732 printf("sddl_decode failed to parse %s as SDDL\n", argv
[2]);
1733 return NT_STATUS_INVALID_PARAMETER
;
1736 status
= SMB_VFS_FSET_NT_ACL(
1737 metadata_fsp(vfs
->files
[fd
]),
1738 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1740 if (!NT_STATUS_IS_OK(status
)) {
1741 printf("fset_nt_acl returned (%s)\n", nt_errstr(status
));
1745 return NT_STATUS_OK
;
1748 static NTSTATUS
cmd_set_nt_acl(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
, int argc
, const char **argv
)
1750 struct vfs_open_how how
= { .mode
= 0400, };
1752 struct files_struct
*fspcwd
= NULL
;
1753 struct smb_filename
*smb_fname
= NULL
;
1755 struct security_descriptor
*sd
= NULL
;
1759 printf("Usage: set_nt_acl <file> <sddl>\n");
1760 return NT_STATUS_OK
;
1764 fsp
= talloc_zero(vfs
, struct files_struct
);
1766 return NT_STATUS_NO_MEMORY
;
1768 fsp
->fh
= fd_handle_create(fsp
);
1769 if (fsp
->fh
== NULL
) {
1771 return NT_STATUS_NO_MEMORY
;
1773 fsp
->conn
= vfs
->conn
;
1775 smb_fname
= synthetic_smb_fname_split(NULL
,
1777 lp_posix_pathnames());
1778 if (smb_fname
== NULL
) {
1780 return NT_STATUS_NO_MEMORY
;
1783 fsp
->fsp_name
= smb_fname
;
1785 status
= vfs_at_fspcwd(fsp
, vfs
->conn
, &fspcwd
);
1786 if (!NT_STATUS_IS_OK(status
)) {
1791 fd
= SMB_VFS_OPENAT(vfs
->conn
,
1796 if (fd
== -1 && errno
== EISDIR
) {
1798 how
.flags
= O_RDONLY
|O_DIRECTORY
;
1800 /* POSIX allows us to open a directory with O_RDONLY. */
1801 how
.flags
= O_RDONLY
;
1803 fd
= SMB_VFS_OPENAT(vfs
->conn
,
1810 printf("open: error=%d (%s)\n", errno
, strerror(errno
));
1812 TALLOC_FREE(smb_fname
);
1813 return NT_STATUS_UNSUCCESSFUL
;
1815 fsp_set_fd(fsp
, fd
);
1817 status
= vfs_stat_fsp(fsp
);
1818 if (!NT_STATUS_IS_OK(status
)) {
1819 /* If we have an fd, this stat should succeed. */
1820 DEBUG(0,("Error doing fstat on open file %s "
1822 smb_fname_str_dbg(smb_fname
),
1823 nt_errstr(status
) ));
1827 fsp
->file_id
= vfs_file_id_from_sbuf(vfs
->conn
, &smb_fname
->st
);
1828 fsp
->vuid
= UID_FIELD_INVALID
;
1830 fsp
->fsp_flags
.can_lock
= true;
1831 fsp
->fsp_flags
.can_read
= true;
1832 fsp
->fsp_flags
.can_write
= true;
1833 fsp
->print_file
= NULL
;
1834 fsp
->fsp_flags
.modified
= false;
1835 fsp
->sent_oplock_break
= NO_BREAK_SENT
;
1836 fsp
->fsp_flags
.is_directory
= S_ISDIR(smb_fname
->st
.st_ex_mode
);
1838 sd
= sddl_decode(talloc_tos(), argv
[2], get_global_sam_sid());
1840 printf("sddl_decode failed to parse %s as SDDL\n", argv
[2]);
1841 status
= NT_STATUS_INVALID_PARAMETER
;
1845 status
= SMB_VFS_FSET_NT_ACL(
1847 SECINFO_OWNER
| SECINFO_GROUP
| SECINFO_DACL
,
1849 if (!NT_STATUS_IS_OK(status
)) {
1850 printf("fset_nt_acl returned (%s)\n", nt_errstr(status
));
1856 status
= fd_close(fsp
);
1857 if (!NT_STATUS_IS_OK(status
))
1858 printf("close: error= (%s)\n", nt_errstr(status
));
1867 static NTSTATUS
cmd_sys_acl_get_fd(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1868 int argc
, const char **argv
)
1875 printf("Usage: sys_acl_get_fd <fd>\n");
1876 return NT_STATUS_OK
;
1880 if (fd
< 0 || fd
>= 1024) {
1881 printf("sys_acl_get_fd: error=%d (file descriptor out of range)\n", EBADF
);
1882 return NT_STATUS_OK
;
1884 if (vfs
->files
[fd
] == NULL
) {
1885 printf("sys_acl_get_fd: error=%d (invalid file descriptor)\n", EBADF
);
1886 return NT_STATUS_OK
;
1889 acl
= SMB_VFS_SYS_ACL_GET_FD(vfs
->files
[fd
],
1890 SMB_ACL_TYPE_ACCESS
,
1893 printf("sys_acl_get_fd failed (%s)\n", strerror(errno
));
1894 return NT_STATUS_UNSUCCESSFUL
;
1896 acl_text
= sys_acl_to_text(acl
, NULL
);
1897 printf("%s", acl_text
);
1899 SAFE_FREE(acl_text
);
1900 return NT_STATUS_OK
;
1903 static NTSTATUS
cmd_sys_acl_get_file(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
1904 int argc
, const char **argv
)
1909 struct smb_filename
*smb_fname
= NULL
;
1910 struct smb_filename
*pathref_fname
= NULL
;
1914 printf("Usage: sys_acl_get_file <path> <type>\n");
1915 return NT_STATUS_OK
;
1918 smb_fname
= synthetic_smb_fname_split(talloc_tos(),
1920 lp_posix_pathnames());
1921 if (smb_fname
== NULL
) {
1922 return NT_STATUS_NO_MEMORY
;
1924 type
= atoi(argv
[2]);
1926 status
= synthetic_pathref(mem_ctx
,
1928 smb_fname
->base_name
,
1934 if (!NT_STATUS_IS_OK(status
)) {
1935 TALLOC_FREE(smb_fname
);
1939 acl
= SMB_VFS_SYS_ACL_GET_FD(pathref_fname
->fsp
,
1940 type
, talloc_tos());
1942 printf("sys_acl_get_fd failed (%s)\n", strerror(errno
));
1943 TALLOC_FREE(smb_fname
);
1944 TALLOC_FREE(pathref_fname
);
1945 return NT_STATUS_UNSUCCESSFUL
;
1947 acl_text
= sys_acl_to_text(acl
, NULL
);
1948 printf("%s", acl_text
);
1950 TALLOC_FREE(smb_fname
);
1951 TALLOC_FREE(pathref_fname
);
1952 SAFE_FREE(acl_text
);
1953 return NT_STATUS_OK
;
1956 static NTSTATUS
cmd_sys_acl_blob_get_file(struct vfs_state
*vfs
,
1957 TALLOC_CTX
*mem_ctx
,
1958 int argc
, const char **argv
)
1964 struct smb_filename
*smb_fname
= NULL
;
1965 struct smb_filename
*pathref_fname
= NULL
;
1969 printf("Usage: sys_acl_blob_get_file <path>\n");
1970 return NT_STATUS_OK
;
1973 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
1975 lp_posix_pathnames());
1976 if (smb_fname
== NULL
) {
1977 return NT_STATUS_NO_MEMORY
;
1979 status
= synthetic_pathref(mem_ctx
,
1981 smb_fname
->base_name
,
1987 if (!NT_STATUS_IS_OK(status
)) {
1988 TALLOC_FREE(smb_fname
);
1992 ret
= SMB_VFS_SYS_ACL_BLOB_GET_FD(pathref_fname
->fsp
,
1997 status
= map_nt_error_from_unix(errno
);
1998 printf("sys_acl_blob_get_file failed (%s)\n", strerror(errno
));
1999 TALLOC_FREE(smb_fname
);
2000 TALLOC_FREE(pathref_fname
);
2003 printf("Description: %s\n", description
);
2004 for (i
= 0; i
< blob
.length
; i
++) {
2005 printf("%.2x ", blob
.data
[i
]);
2009 TALLOC_FREE(smb_fname
);
2010 TALLOC_FREE(pathref_fname
);
2011 return NT_STATUS_OK
;
2014 static NTSTATUS
cmd_sys_acl_blob_get_fd(struct vfs_state
*vfs
,
2015 TALLOC_CTX
*mem_ctx
,
2016 int argc
, const char **argv
)
2025 printf("Usage: sys_acl_blob_get_fd <fd>\n");
2026 return NT_STATUS_OK
;
2030 if (fd
< 0 || fd
>= 1024) {
2031 printf("sys_acl_blob_get_fd: error=%d "
2032 "(file descriptor out of range)\n", EBADF
);
2033 return NT_STATUS_OK
;
2035 if (vfs
->files
[fd
] == NULL
) {
2036 printf("sys_acl_blob_get_fd: error=%d "
2037 "(invalid file descriptor)\n", EBADF
);
2038 return NT_STATUS_OK
;
2041 ret
= SMB_VFS_SYS_ACL_BLOB_GET_FD(vfs
->files
[fd
], talloc_tos(),
2042 &description
, &blob
);
2044 printf("sys_acl_blob_get_fd failed (%s)\n", strerror(errno
));
2045 return map_nt_error_from_unix(errno
);
2047 printf("Description: %s\n", description
);
2048 for (i
= 0; i
< blob
.length
; i
++) {
2049 printf("%.2x ", blob
.data
[i
]);
2053 return NT_STATUS_OK
;
2058 static NTSTATUS
cmd_sys_acl_delete_def_file(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
2059 int argc
, const char **argv
)
2062 struct smb_filename
*smb_fname
= NULL
;
2063 struct smb_filename
*pathref_fname
= NULL
;
2067 printf("Usage: sys_acl_delete_def_file <path>\n");
2068 return NT_STATUS_OK
;
2071 smb_fname
= synthetic_smb_fname_split(mem_ctx
,
2073 lp_posix_pathnames());
2074 if (smb_fname
== NULL
) {
2075 return NT_STATUS_NO_MEMORY
;
2077 status
= synthetic_pathref(mem_ctx
,
2079 smb_fname
->base_name
,
2085 if (!NT_STATUS_IS_OK(status
)) {
2086 TALLOC_FREE(smb_fname
);
2089 if (!pathref_fname
->fsp
->fsp_flags
.is_directory
) {
2090 printf("sys_acl_delete_def_file - %s is not a directory\n",
2091 smb_fname
->base_name
);
2092 TALLOC_FREE(smb_fname
);
2093 TALLOC_FREE(pathref_fname
);
2094 return NT_STATUS_INVALID_PARAMETER
;
2096 ret
= SMB_VFS_SYS_ACL_DELETE_DEF_FD(pathref_fname
->fsp
);
2099 printf("sys_acl_delete_def_file failed (%s)\n", strerror(err
));
2100 TALLOC_FREE(smb_fname
);
2101 TALLOC_FREE(pathref_fname
);
2102 return map_nt_error_from_unix(err
);
2104 TALLOC_FREE(smb_fname
);
2105 TALLOC_FREE(pathref_fname
);
2106 return NT_STATUS_OK
;
2109 /* Afaik translate name was first introduced with vfs_catia, to be able
2110 to translate unix file/dir-names, containing invalid windows characters,
2111 to valid windows names.
2112 The used translation direction is always unix --> windows
2114 static NTSTATUS
cmd_translate_name(struct vfs_state
*vfs
, TALLOC_CTX
*mem_ctx
,
2115 int argc
, const char **argv
)
2117 const char *dname
= NULL
;
2118 char *dname_talloced
= NULL
;
2120 char *translated
= NULL
;
2121 struct smb_filename
*smb_fname
= NULL
;
2125 DEBUG(0, ("Usage: translate_name unix_filename\n"));
2126 return NT_STATUS_UNSUCCESSFUL
;
2129 smb_fname
= synthetic_smb_fname(talloc_tos(),
2135 if (smb_fname
== NULL
) {
2136 return NT_STATUS_NO_MEMORY
;
2139 status
= OpenDir(vfs
->conn
,
2145 if (!NT_STATUS_IS_OK(status
)) {
2146 int err
= map_errno_from_nt_status(status
);
2147 DEBUG(0, ("cmd_translate_name: opendir error=%d (%s)\n",
2148 err
, strerror(err
)));
2149 TALLOC_FREE(smb_fname
);
2151 return NT_STATUS_UNSUCCESSFUL
;
2155 /* ReadDirName() returns Windows "encoding" */
2156 dname
= ReadDirName(vfs
->currentdir
, &dname_talloced
);
2157 if (dname
== NULL
) {
2161 /* Convert Windows "encoding" from ReadDirName() to UNIX */
2162 status
= SMB_VFS_TRANSLATE_NAME(vfs
->conn
,
2164 vfs_translate_to_unix
,
2167 if (!NT_STATUS_IS_OK(status
)) {
2168 DBG_ERR("file '%s' cannot be translated\n", argv
[1]);
2173 * argv[1] uses UNIX "encoding", so compare with translation
2176 if (strcmp(translated
, argv
[1]) == 0) {
2180 TALLOC_FREE(dname_talloced
);
2181 TALLOC_FREE(translated
);
2185 DEBUG(0, ("cmd_translate_name: file '%s' not found.\n",
2187 status
= NT_STATUS_UNSUCCESSFUL
;
2191 /* translation success. But that could also mean
2192 that translating "aaa" to "aaa" was successful :-(
2194 DBG_ERR("file '%s' --> '%s'\n", argv
[1], dname
);
2195 status
= NT_STATUS_OK
;
2198 TALLOC_FREE(dname_talloced
);
2199 TALLOC_FREE(translated
);
2200 TALLOC_FREE(smb_fname
);
2201 TALLOC_FREE(vfs
->currentdir
);
2206 * This is a quick hack to demonstrate a crash in the full_audit
2207 * module when passing fsp->smb_fname into SMB_VFS_CREATE_FILE leading
2210 * Feel free to expand with more options as needed
2212 static NTSTATUS
cmd_create_file(
2213 struct vfs_state
*vfs
,
2214 TALLOC_CTX
*mem_ctx
,
2218 struct smb_filename
*fname
= NULL
;
2219 struct files_struct
*fsp
= NULL
;
2224 DBG_ERR("Usage: create_file filename\n");
2225 return NT_STATUS_UNSUCCESSFUL
;
2228 fname
= synthetic_smb_fname(
2229 talloc_tos(), argv
[1], NULL
, NULL
, 0, 0);
2230 if (fname
== NULL
) {
2231 return NT_STATUS_NO_MEMORY
;
2234 ret
= vfs_stat(vfs
->conn
, fname
);
2236 status
= map_nt_error_from_unix(errno
);
2237 DBG_DEBUG("vfs_stat() failed: %s\n", strerror(errno
));
2242 status
= openat_pathref_fsp(vfs
->conn
->cwd_fsp
, fname
);
2243 if (!NT_STATUS_IS_OK(status
)) {
2244 DBG_DEBUG("Could not open %s: %s\n",
2251 status
= SMB_VFS_CREATE_FILE(
2257 * Using fname->fsp->fsp_name seems to be legal,
2258 * there's code to handle this in
2259 * create_file_unixpath(). And it is actually very
2260 * worthwhile re-using the fsp_name, we can save quite
2261 * a few copies of smb_filename with that.
2263 fname
->fsp
->fsp_name
,
2267 FILE_NON_DIRECTORY_FILE
,
2280 DBG_DEBUG("create_file returned %s\n", nt_errstr(status
));
2284 return NT_STATUS_OK
;
2287 struct cmd_set vfs_commands
[] = {
2289 { .name
= "VFS Commands" },
2291 { "load", cmd_load_module
, "Load a module", "load <module.so>" },
2292 { "populate", cmd_populate
, "Populate a data buffer", "populate <char> <size>" },
2293 { "showdata", cmd_show_data
, "Show data currently in data buffer", "show_data [<offset> <len>]"},
2294 { "connect", cmd_connect
, "VFS connect()", "connect" },
2295 { "disconnect", cmd_disconnect
, "VFS disconnect()", "disconnect" },
2296 { "disk_free", cmd_disk_free
, "VFS disk_free()", "disk_free <path>" },
2297 { "opendir", cmd_opendir
, "VFS opendir()", "opendir <fname>" },
2298 { "readdir", cmd_readdir
, "VFS readdir()", "readdir" },
2299 { "mkdir", cmd_mkdir
, "VFS mkdir()", "mkdir <path>" },
2300 { "rmdir", cmd_pathfunc
, "VFS rmdir()", "rmdir <path>" },
2301 { "closedir", cmd_closedir
, "VFS closedir()", "closedir" },
2302 { "open", cmd_open
, "VFS open()", "open <fname> <flags> <mode>" },
2303 { "close", cmd_close
, "VFS close()", "close <fd>" },
2304 { "read", cmd_read
, "VFS read()", "read <fd> <size>" },
2305 { "write", cmd_write
, "VFS write()", "write <fd> <size>" },
2306 { "lseek", cmd_lseek
, "VFS lseek()", "lseek <fd> <offset> <whence>" },
2307 { "rename", cmd_rename
, "VFS rename()", "rename <old> <new>" },
2308 { "fsync", cmd_fsync
, "VFS fsync()", "fsync <fd>" },
2309 { "stat", cmd_stat
, "VFS stat()", "stat <fname>" },
2310 { "fstat", cmd_fstat
, "VFS fstat()", "fstat <fd>" },
2311 { "lstat", cmd_lstat
, "VFS lstat()", "lstat <fname>" },
2312 { "unlink", cmd_pathfunc
, "VFS unlink()", "unlink <fname>" },
2313 { "chmod", cmd_chmod
, "VFS chmod()", "chmod <path> <mode>" },
2314 { "fchmod", cmd_fchmod
, "VFS fchmod()", "fchmod <fd> <mode>" },
2315 { "fchown", cmd_fchown
, "VFS fchown()", "fchown <fd> <uid> <gid>" },
2316 { "chdir", cmd_pathfunc
, "VFS chdir()", "chdir <path>" },
2317 { "getwd", cmd_getwd
, "VFS getwd()", "getwd" },
2318 { "utime", cmd_utime
, "VFS utime()", "utime <path> <access> <modify>" },
2319 { "ftruncate", cmd_ftruncate
, "VFS ftruncate()", "ftruncate <fd> <length>" },
2320 { "lock", cmd_lock
, "VFS lock()", "lock <f> <op> <offset> <count> <type>" },
2321 { "symlink", cmd_symlink
, "VFS symlink()", "symlink <old> <new>" },
2322 { "readlink", cmd_readlink
, "VFS readlink()", "readlink <path>" },
2323 { "link", cmd_link
, "VFS link()", "link <oldpath> <newpath>" },
2324 { "mknod", cmd_mknod
, "VFS mknod()", "mknod <path> <mode> <dev>" },
2325 { "realpath", cmd_realpath
, "VFS realpath()", "realpath <path>" },
2326 { "getxattr", cmd_getxattr
, "VFS getxattr()",
2327 "getxattr <path> <name>" },
2328 { "listxattr", cmd_listxattr
, "VFS listxattr()",
2329 "listxattr <path>" },
2330 { "fsetxattr", cmd_fsetxattr
, "VFS fsetxattr()",
2331 "fsetxattr <path> <name> <value> [<flags>]" },
2332 { "removexattr", cmd_removexattr
, "VFS removexattr()",
2333 "removexattr <path> <name>\n" },
2334 { "fget_nt_acl", cmd_fget_nt_acl
, "VFS fget_nt_acl()",
2335 "fget_nt_acl <fd>\n" },
2336 { "get_nt_acl", cmd_get_nt_acl
, "VFS get_nt_acl()",
2337 "get_nt_acl <path>\n" },
2338 { "fset_nt_acl", cmd_fset_nt_acl
, "VFS fset_nt_acl()",
2339 "fset_nt_acl <fd>\n" },
2340 { "set_nt_acl", cmd_set_nt_acl
, "VFS open() and fset_nt_acl()",
2341 "set_nt_acl <file>\n" },
2342 { "sys_acl_get_file", cmd_sys_acl_get_file
, "VFS sys_acl_get_file()", "sys_acl_get_file <path>" },
2343 { "sys_acl_get_fd", cmd_sys_acl_get_fd
, "VFS sys_acl_get_fd()", "sys_acl_get_fd <fd>" },
2344 { "sys_acl_blob_get_file", cmd_sys_acl_blob_get_file
,
2345 "VFS sys_acl_blob_get_file()", "sys_acl_blob_get_file <path>" },
2346 { "sys_acl_blob_get_fd", cmd_sys_acl_blob_get_fd
,
2347 "VFS sys_acl_blob_get_fd()", "sys_acl_blob_get_fd <path>" },
2348 { "sys_acl_delete_def_file", cmd_sys_acl_delete_def_file
, "VFS sys_acl_delete_def_file()", "sys_acl_delete_def_file <path>" },
2351 #if defined(WITH_SMB1SERVER)
2352 { "test_chain", cmd_test_chain
, "test chain code",
2355 { "translate_name", cmd_translate_name
, "VFS translate_name()", "translate_name unix_filename" },
2358 "VFS create_file()",
2359 "create_file <filename>"