summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/cmd_vfs.c180
-rw-r--r--source3/torture/torture.c87
2 files changed, 183 insertions, 84 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 80ee3ec0e8..1664f9a94d 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -157,31 +157,35 @@ static NTSTATUS cmd_readdir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc
printf("readdir: %s\n", dent->d_name);
if (VALID_STAT(st)) {
+ time_t tmp_time;
printf(" stat available");
- if (S_ISREG(st.st_mode)) printf(" Regular File\n");
- else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
- else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
- else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
- else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
- else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
- else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
- printf(" Size: %10u", (unsigned int)st.st_size);
+ if (S_ISREG(st.st_ex_mode)) printf(" Regular File\n");
+ else if (S_ISDIR(st.st_ex_mode)) printf(" Directory\n");
+ else if (S_ISCHR(st.st_ex_mode)) printf(" Character Device\n");
+ else if (S_ISBLK(st.st_ex_mode)) printf(" Block Device\n");
+ else if (S_ISFIFO(st.st_ex_mode)) printf(" Fifo\n");
+ else if (S_ISLNK(st.st_ex_mode)) printf(" Symbolic Link\n");
+ else if (S_ISSOCK(st.st_ex_mode)) printf(" Socket\n");
+ printf(" Size: %10u", (unsigned int)st.st_ex_size);
#ifdef HAVE_STAT_ST_BLOCKS
- printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+ printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
#endif
#ifdef HAVE_STAT_ST_BLKSIZE
- printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+ printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
#endif
- printf(" Device: 0x%10x", (unsigned int)st.st_dev);
- printf(" Inode: %10u", (unsigned int)st.st_ino);
- printf(" Links: %10u\n", (unsigned int)st.st_nlink);
- printf(" Access: %05o", (int)((st.st_mode) & 007777));
+ printf(" Device: 0x%10x", (unsigned int)st.st_ex_dev);
+ printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+ printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+ printf(" Access: %05o", (int)((st.st_ex_mode) & 007777));
printf(" Uid: %5lu Gid: %5lu\n",
- (unsigned long)st.st_uid,
- (unsigned long)st.st_gid);
- printf(" Access: %s", ctime(&(st.st_atime)));
- printf(" Modify: %s", ctime(&(st.st_mtime)));
- printf(" Change: %s", ctime(&(st.st_ctime)));
+ (unsigned long)st.st_ex_uid,
+ (unsigned long)st.st_ex_gid);
+ tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+ printf(" Access: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+ printf(" Modify: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+ printf(" Change: %s", ctime(&tmp_time));
}
return NT_STATUS_OK;
@@ -540,6 +544,7 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
struct passwd *pwd = NULL;
struct group *grp = NULL;
SMB_STRUCT_STAT st;
+ time_t tmp_time;
if (argc != 2) {
printf("Usage: stat <fname>\n");
@@ -552,38 +557,41 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
return NT_STATUS_UNSUCCESSFUL;
}
- pwd = sys_getpwuid(st.st_uid);
+ pwd = sys_getpwuid(st.st_ex_uid);
if (pwd != NULL) user = pwd->pw_name;
else user = null_string;
- grp = sys_getgrgid(st.st_gid);
+ grp = sys_getgrgid(st.st_ex_gid);
if (grp != NULL) group = grp->gr_name;
else group = null_string;
printf("stat: ok\n");
printf(" File: %s", argv[1]);
- if (S_ISREG(st.st_mode)) printf(" Regular File\n");
- else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
- else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
- else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
- else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
- else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
- else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
- printf(" Size: %10u", (unsigned int)st.st_size);
+ if (S_ISREG(st.st_ex_mode)) printf(" Regular File\n");
+ else if (S_ISDIR(st.st_ex_mode)) printf(" Directory\n");
+ else if (S_ISCHR(st.st_ex_mode)) printf(" Character Device\n");
+ else if (S_ISBLK(st.st_ex_mode)) printf(" Block Device\n");
+ else if (S_ISFIFO(st.st_ex_mode)) printf(" Fifo\n");
+ else if (S_ISLNK(st.st_ex_mode)) printf(" Symbolic Link\n");
+ else if (S_ISSOCK(st.st_ex_mode)) printf(" Socket\n");
+ printf(" Size: %10u", (unsigned int)st.st_ex_size);
#ifdef HAVE_STAT_ST_BLOCKS
- printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+ printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
#endif
#ifdef HAVE_STAT_ST_BLKSIZE
- printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+ printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
#endif
- printf(" Device: 0x%10x", (unsigned int)st.st_dev);
- printf(" Inode: %10u", (unsigned int)st.st_ino);
- printf(" Links: %10u\n", (unsigned int)st.st_nlink);
- printf(" Access: %05o", (int)((st.st_mode) & 007777));
- printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user,
- (unsigned long)st.st_gid, group);
- printf(" Access: %s", ctime(&(st.st_atime)));
- printf(" Modify: %s", ctime(&(st.st_mtime)));
- printf(" Change: %s", ctime(&(st.st_ctime)));
+ printf(" Device: 0x%10x", (unsigned int)st.st_ex_dev);
+ printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+ printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+ printf(" Access: %05o", (int)((st.st_ex_mode) & 007777));
+ printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_ex_uid, user,
+ (unsigned long)st.st_ex_gid, group);
+ tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+ printf(" Access: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+ printf(" Modify: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+ printf(" Change: %s", ctime(&tmp_time));
return NT_STATUS_OK;
}
@@ -597,6 +605,7 @@ static NTSTATUS cmd_fstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
struct passwd *pwd = NULL;
struct group *grp = NULL;
SMB_STRUCT_STAT st;
+ time_t tmp_time;
if (argc != 2) {
printf("Usage: fstat <fd>\n");
@@ -619,37 +628,40 @@ static NTSTATUS cmd_fstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
return NT_STATUS_UNSUCCESSFUL;
}
- pwd = sys_getpwuid(st.st_uid);
+ pwd = sys_getpwuid(st.st_ex_uid);
if (pwd != NULL) user = pwd->pw_name;
else user = null_string;
- grp = sys_getgrgid(st.st_gid);
+ grp = sys_getgrgid(st.st_ex_gid);
if (grp != NULL) group = grp->gr_name;
else group = null_string;
printf("fstat: ok\n");
- if (S_ISREG(st.st_mode)) printf(" Regular File\n");
- else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
- else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
- else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
- else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
- else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
- else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
- printf(" Size: %10u", (unsigned int)st.st_size);
+ if (S_ISREG(st.st_ex_mode)) printf(" Regular File\n");
+ else if (S_ISDIR(st.st_ex_mode)) printf(" Directory\n");
+ else if (S_ISCHR(st.st_ex_mode)) printf(" Character Device\n");
+ else if (S_ISBLK(st.st_ex_mode)) printf(" Block Device\n");
+ else if (S_ISFIFO(st.st_ex_mode)) printf(" Fifo\n");
+ else if (S_ISLNK(st.st_ex_mode)) printf(" Symbolic Link\n");
+ else if (S_ISSOCK(st.st_ex_mode)) printf(" Socket\n");
+ printf(" Size: %10u", (unsigned int)st.st_ex_size);
#ifdef HAVE_STAT_ST_BLOCKS
- printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+ printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
#endif
#ifdef HAVE_STAT_ST_BLKSIZE
- printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+ printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
#endif
- printf(" Device: 0x%10x", (unsigned int)st.st_dev);
- printf(" Inode: %10u", (unsigned int)st.st_ino);
- printf(" Links: %10u\n", (unsigned int)st.st_nlink);
- printf(" Access: %05o", (int)((st.st_mode) & 007777));
- printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user,
- (unsigned long)st.st_gid, group);
- printf(" Access: %s", ctime(&(st.st_atime)));
- printf(" Modify: %s", ctime(&(st.st_mtime)));
- printf(" Change: %s", ctime(&(st.st_ctime)));
+ printf(" Device: 0x%10x", (unsigned int)st.st_ex_dev);
+ printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+ printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+ printf(" Access: %05o", (int)((st.st_ex_mode) & 007777));
+ printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_ex_uid, user,
+ (unsigned long)st.st_ex_gid, group);
+ tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+ printf(" Access: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+ printf(" Modify: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+ printf(" Change: %s", ctime(&tmp_time));
return NT_STATUS_OK;
}
@@ -662,6 +674,7 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
struct passwd *pwd = NULL;
struct group *grp = NULL;
SMB_STRUCT_STAT st;
+ time_t tmp_time;
if (argc != 2) {
printf("Usage: lstat <path>\n");
@@ -673,37 +686,40 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
return NT_STATUS_UNSUCCESSFUL;
}
- pwd = sys_getpwuid(st.st_uid);
+ pwd = sys_getpwuid(st.st_ex_uid);
if (pwd != NULL) user = pwd->pw_name;
else user = null_string;
- grp = sys_getgrgid(st.st_gid);
+ grp = sys_getgrgid(st.st_ex_gid);
if (grp != NULL) group = grp->gr_name;
else group = null_string;
printf("lstat: ok\n");
- if (S_ISREG(st.st_mode)) printf(" Regular File\n");
- else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
- else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
- else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
- else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
- else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
- else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
- printf(" Size: %10u", (unsigned int)st.st_size);
+ if (S_ISREG(st.st_ex_mode)) printf(" Regular File\n");
+ else if (S_ISDIR(st.st_ex_mode)) printf(" Directory\n");
+ else if (S_ISCHR(st.st_ex_mode)) printf(" Character Device\n");
+ else if (S_ISBLK(st.st_ex_mode)) printf(" Block Device\n");
+ else if (S_ISFIFO(st.st_ex_mode)) printf(" Fifo\n");
+ else if (S_ISLNK(st.st_ex_mode)) printf(" Symbolic Link\n");
+ else if (S_ISSOCK(st.st_ex_mode)) printf(" Socket\n");
+ printf(" Size: %10u", (unsigned int)st.st_ex_size);
#ifdef HAVE_STAT_ST_BLOCKS
- printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+ printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
#endif
#ifdef HAVE_STAT_ST_BLKSIZE
- printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+ printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
#endif
- printf(" Device: 0x%10x", (unsigned int)st.st_dev);
- printf(" Inode: %10u", (unsigned int)st.st_ino);
- printf(" Links: %10u\n", (unsigned int)st.st_nlink);
- printf(" Access: %05o", (int)((st.st_mode) & 007777));
- printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user,
- (unsigned long)st.st_gid, group);
- printf(" Access: %s", ctime(&(st.st_atime)));
- printf(" Modify: %s", ctime(&(st.st_mtime)));
- printf(" Change: %s", ctime(&(st.st_ctime)));
+ printf(" Device: 0x%10x", (unsigned int)st.st_ex_dev);
+ printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+ printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+ printf(" Access: %05o", (int)((st.st_ex_mode) & 007777));
+ printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_ex_uid, user,
+ (unsigned long)st.st_ex_gid, group);
+ tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+ printf(" Access: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+ printf(" Modify: %s", ctime(&tmp_time));
+ tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+ printf(" Change: %s", ctime(&tmp_time));
return NT_STATUS_OK;
}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 41343cab87..b05ca44f0e 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4135,8 +4135,12 @@ static bool run_opentest(int dummy)
static bool run_simple_posix_open_test(int dummy)
{
static struct cli_state *cli1;
- const char *fname = "\\posix:file";
- const char *dname = "\\posix:dir";
+ const char *fname = "posix:file";
+ const char *hname = "posix:hlink";
+ const char *sname = "posix:symlink";
+ const char *dname = "posix:dir";
+ char buf[10];
+ char namebuf[11];
uint16 major, minor;
uint32 caplow, caphigh;
uint16_t fnum1 = (uint16_t)-1;
@@ -4171,6 +4175,10 @@ static bool run_simple_posix_open_test(int dummy)
cli_posix_unlink(cli1, fname);
cli_setatr(cli1, dname, 0, 0);
cli_posix_rmdir(cli1, dname);
+ cli_setatr(cli1, hname, 0, 0);
+ cli_posix_unlink(cli1, hname);
+ cli_setatr(cli1, sname, 0, 0);
+ cli_posix_unlink(cli1, sname);
/* Create a directory. */
if (!NT_STATUS_IS_OK(cli_posix_mkdir(cli1, dname, 0777))) {
@@ -4222,6 +4230,77 @@ static bool run_simple_posix_open_test(int dummy)
}
}
+ /* Create the file. */
+ if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600, &fnum1))) {
+ printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Write some data into it. */
+ if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) {
+ printf("cli_write failed: %s\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ cli_close(cli1, fnum1);
+
+ /* Now create a hardlink. */
+ if (!NT_STATUS_IS_OK(cli_posix_hardlink(cli1, fname, hname))) {
+ printf("POSIX hardlink of %s failed (%s)\n", hname, cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Now create a symlink. */
+ if (!NT_STATUS_IS_OK(cli_posix_symlink(cli1, fname, sname))) {
+ printf("POSIX symlink of %s failed (%s)\n", sname, cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Open the hardlink for read. */
+ if (!NT_STATUS_IS_OK(cli_posix_open(cli1, hname, O_RDONLY, 0, &fnum1))) {
+ printf("POSIX open of %s failed (%s)\n", hname, cli_errstr(cli1));
+ goto out;
+ }
+
+ if (cli_read(cli1, fnum1, buf, 0, 10) != 10) {
+ printf("POSIX read of %s failed (%s)\n", hname, cli_errstr(cli1));
+ goto out;
+ }
+
+ if (memcmp(buf, "TEST DATA\n", 10)) {
+ printf("invalid data read from hardlink\n");
+ goto out;
+ }
+
+ cli_close(cli1, fnum1);
+
+ /* Open the symlink for read - this should fail. A POSIX
+ client should not be doing opens on a symlink. */
+ if (NT_STATUS_IS_OK(cli_posix_open(cli1, sname, O_RDONLY, 0, &fnum1))) {
+ printf("POSIX open of %s succeeded (should have failed)\n", sname);
+ goto out;
+ } else {
+ if (!check_error(__LINE__, cli1, ERRDOS, ERRbadpath,
+ NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ printf("POSIX open of %s should have failed "
+ "with NT_STATUS_OBJECT_PATH_NOT_FOUND, "
+ "failed with %s instead.\n",
+ sname, cli_errstr(cli1));
+ goto out;
+ }
+ }
+
+ if (!NT_STATUS_IS_OK(cli_posix_readlink(cli1, sname, namebuf, sizeof(namebuf)))) {
+ printf("POSIX readlink on %s failed (%s)\n", sname, cli_errstr(cli1));
+ goto out;
+ }
+
+ if (strcmp(namebuf, fname) != 0) {
+ printf("POSIX readlink on %s failed to match name %s (read %s)\n",
+ sname, fname, namebuf);
+ goto out;
+ }
+
if (!NT_STATUS_IS_OK(cli_posix_rmdir(cli1, dname))) {
printf("POSIX rmdir failed (%s)\n", cli_errstr(cli1));
goto out;
@@ -4237,6 +4316,10 @@ static bool run_simple_posix_open_test(int dummy)
fnum1 = (uint16_t)-1;
}
+ cli_setatr(cli1, sname, 0, 0);
+ cli_posix_unlink(cli1, sname);
+ cli_setatr(cli1, hname, 0, 0);
+ cli_posix_unlink(cli1, hname);
cli_setatr(cli1, fname, 0, 0);
cli_posix_unlink(cli1, fname);
cli_setatr(cli1, dname, 0, 0);