diff options
-rw-r--r-- | selftest/knownfail | 3 | ||||
-rw-r--r-- | selftest/knownfail.d/libsmbclient | 2 | ||||
-rw-r--r-- | selftest/selftesthelpers.py | 15 | ||||
-rw-r--r-- | source3/include/client.h | 6 | ||||
-rw-r--r-- | source3/include/libsmb_internal.h | 4 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 122 | ||||
-rw-r--r-- | source3/libsmb/clilist.c | 69 | ||||
-rw-r--r-- | source3/libsmb/libsmb_dir.c | 64 | ||||
-rw-r--r-- | source3/libsmb/libsmb_file.c | 44 | ||||
-rw-r--r-- | source3/libsmb/libsmb_misc.c | 15 | ||||
-rw-r--r-- | source3/libsmb/libsmb_server.c | 1 | ||||
-rw-r--r-- | source3/libsmb/libsmb_stat.c | 2 | ||||
-rw-r--r-- | source3/libsmb/proto.h | 8 | ||||
-rwxr-xr-x | source3/script/tests/test_smbtorture_s3_no_unix_ext.sh | 14 | ||||
-rwxr-xr-x | source3/selftest/tests.py | 24 | ||||
-rwxr-xr-x | source4/selftest/tests.py | 47 | ||||
-rw-r--r-- | source4/torture/libsmbclient/libsmbclient.c | 24 |
17 files changed, 131 insertions, 333 deletions
diff --git a/selftest/knownfail b/selftest/knownfail index d4381b39a84..4dc434aca7e 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -19,6 +19,7 @@ ^samba3.nbt.dgram.*netlogon2\(nt4_dc\) ^samba3.*rap.sam.*.useradd # Not provided by Samba 3 ^samba3.*rap.sam.*.userdelete # Not provided by Samba 3 +^samba3.libsmbclient.opendir # This requires a workgroup called 'WORKGROUP' and for netbios browse lists to have been registered # see bug 8412 ^samba3.smb2.rename.*.simple_nodelete ^samba3.smb2.rename.*.no_share_delete_no_delete_access @@ -140,7 +141,7 @@ ^samba4.smb2.acls.*.ACCESSBASED ^samba4.ldap.dirsync.python.ad_dc_ntvfs..__main__.ExtendedDirsyncTests.test_dirsync_deleted_items #^samba4.ldap.dirsync.python.ad_dc_ntvfs..__main__.ExtendedDirsyncTests.* -^samba4.*libsmbclient.opendir.(NT1|SMB3).opendir # This requires netbios browsing +^samba4.libsmbclient.opendir.(NT1|SMB3).opendir # This requires netbios browsing ^samba4.rpc.drsuapi.*.drsuapi.DsGetDomainControllerInfo\(.*\)$ ^samba4.smb2.oplock.exclusive2\(.*\)$ # samba 4 oplocks are a mess ^samba4.smb2.oplock.exclusive5\(.*\)$ # samba 4 oplocks are a mess diff --git a/selftest/knownfail.d/libsmbclient b/selftest/knownfail.d/libsmbclient deleted file mode 100644 index 43c3fb6774d..00000000000 --- a/selftest/knownfail.d/libsmbclient +++ /dev/null @@ -1,2 +0,0 @@ -# We don't have SMB3 unix extensions yet -samba4.unix_ext.libsmbclient.readdirplus2.SMB3.readdirplus2.* diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py index 1fdb2e461e1..1afabf3cdca 100644 --- a/selftest/selftesthelpers.py +++ b/selftest/selftesthelpers.py @@ -172,21 +172,14 @@ smbtorture4_options = [ "--format=subunit" ] + get_env_torture_options() -def smbtorture4testsuite_cmdarray(name, env, options, target): - cmdarray = [ valgrindify(smbtorture4), "$LISTOPT", "$LOADLIST" ] - cmdarray += smbtorture4_options - cmdarray += [ "--target=%s" % target ] - cmdarray += options - cmdarray += [ name ] - return cmdarray def plansmbtorture4testsuite(name, env, options, target, modname=None): if modname is None: modname = "samba4.%s" % name - if isinstance(options, str): - options = options.split() - cmdarray = smbtorture4testsuite_cmdarray(name, env, options, target) - cmdline = " ".join(cmdarray) + if isinstance(options, list): + options = " ".join(options) + options = " ".join(smbtorture4_options + ["--target=%s" % target]) + " " + options + cmdline = "%s $LISTOPT $LOADLIST %s %s" % (valgrindify(smbtorture4), options, name) plantestsuite_loadlist(modname, env, cmdline) diff --git a/source3/include/client.h b/source3/include/client.h index 34b6a9fc383..23ba86d2a2c 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -114,12 +114,6 @@ struct file_info { struct timespec mtime_ts; struct timespec atime_ts; struct timespec ctime_ts; - - /* - * Native sbuf from posix extensions. Valid if st_ex_nlink!=0. - */ - SMB_STRUCT_STAT posix_sbuf; - char *name; char *short_name; }; diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 78c2cb555e0..21a11c1a024 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -98,7 +98,6 @@ struct smbc_dir_list { struct smbc_dirplus_list { struct smbc_dirplus_list *next; struct libsmb_file_info *smb_finfo; - SMB_STRUCT_STAT *posix_sbuf; uint64_t ino; }; @@ -432,7 +431,8 @@ SMBC_ftruncate_ctx(SMBCCTX *context, /* Functions in libsmb_misc.c */ -bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p); +int +SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p); int SMBC_errno(SMBCCTX *context, diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 164be11386c..dd08b0e30f3 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -736,65 +736,12 @@ NTSTATUS cli_posix_setacl(struct cli_state *cli, return status; } -static void fetch_file_unix_basic_info( - const uint8_t data[100], SMB_STRUCT_STAT *sbuf) -{ - ZERO_STRUCTP(sbuf); - - /* total size, in bytes */ - sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(data, 0); - - /* number of blocks allocated */ - sbuf->st_ex_blocks = IVAL2_TO_SMB_BIG_UINT(data,8); -#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE) - sbuf->st_ex_blocks /= STAT_ST_BLOCKSIZE; -#else - /* assume 512 byte blocks */ - sbuf->st_ex_blocks /= 512; -#endif - /* time of last change */ - sbuf->st_ex_ctime = interpret_long_date((const char *)(data + 16)); - - /* time of last access */ - sbuf->st_ex_atime = interpret_long_date((const char *)(data + 24)); - - /* time of last modification */ - sbuf->st_ex_mtime = interpret_long_date((const char *)(data + 32)); - - sbuf->st_ex_uid = (uid_t) IVAL(data, 40); /* user ID of owner */ - sbuf->st_ex_gid = (gid_t) IVAL(data, 48); /* group ID of owner */ - sbuf->st_ex_mode = unix_filetype_from_wire(IVAL(data, 56)); - -#if defined(HAVE_MAKEDEV) - { - uint32_t dev_major = IVAL(data,60); - uint32_t dev_minor = IVAL(data,68); - sbuf->st_ex_rdev = makedev(dev_major, dev_minor); - } -#endif - /* inode */ - sbuf->st_ex_ino = (SMB_INO_T)IVAL2_TO_SMB_BIG_UINT(data, 76); - - /* protection */ - sbuf->st_ex_mode |= wire_perms_to_unix(IVAL(data, 84)); - - /* number of hard links */ - sbuf->st_ex_nlink = BIG_UINT(data, 92); -} - -void fetch_file_unix_basic_info2( - const uint8_t data[116], SMB_STRUCT_STAT *sbuf) -{ - fetch_file_unix_basic_info(data, sbuf); - sbuf->st_ex_btime = interpret_long_date((const char *)(data + 100)); -} - /**************************************************************************** Stat a file (UNIX extensions). ****************************************************************************/ struct stat_state { - SMB_STRUCT_STAT sbuf; + SMB_STRUCT_STAT *sbuf; }; static void cli_posix_stat_done(struct tevent_req *subreq); @@ -802,7 +749,8 @@ static void cli_posix_stat_done(struct tevent_req *subreq); struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - const char *fname) + const char *fname, + SMB_STRUCT_STAT *sbuf) { struct tevent_req *req = NULL, *subreq = NULL; struct stat_state *state = NULL; @@ -811,6 +759,7 @@ struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx, if (req == NULL) { return NULL; } + state->sbuf = sbuf; subreq = cli_qpathinfo_send(state, ev, cli, fname, SMB_QUERY_FILE_UNIX_BASIC, 100, 100); @@ -826,7 +775,7 @@ static void cli_posix_stat_done(struct tevent_req *subreq) struct tevent_req *req = tevent_req_callback_data( subreq, struct tevent_req); struct stat_state *state = tevent_req_data(req, struct stat_state); - SMB_STRUCT_STAT *sbuf = &state->sbuf; + SMB_STRUCT_STAT *sbuf = state->sbuf; uint8_t *data; uint32_t num_data = 0; NTSTATUS status; @@ -846,25 +795,54 @@ static void cli_posix_stat_done(struct tevent_req *subreq) return; } - fetch_file_unix_basic_info(data, sbuf); + *sbuf = (SMB_STRUCT_STAT) { 0 }; + + /* total size, in bytes */ + sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(data, 0); + + /* number of blocks allocated */ + sbuf->st_ex_blocks = IVAL2_TO_SMB_BIG_UINT(data,8); +#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE) + sbuf->st_ex_blocks /= STAT_ST_BLOCKSIZE; +#else + /* assume 512 byte blocks */ + sbuf->st_ex_blocks /= 512; +#endif + /* time of last change */ + sbuf->st_ex_ctime = interpret_long_date((char *)(data + 16)); + + /* time of last access */ + sbuf->st_ex_atime = interpret_long_date((char *)(data + 24)); + + /* time of last modification */ + sbuf->st_ex_mtime = interpret_long_date((char *)(data + 32)); + + sbuf->st_ex_uid = (uid_t) IVAL(data, 40); /* user ID of owner */ + sbuf->st_ex_gid = (gid_t) IVAL(data, 48); /* group ID of owner */ + sbuf->st_ex_mode = unix_filetype_from_wire(IVAL(data, 56)); + +#if defined(HAVE_MAKEDEV) + { + uint32_t dev_major = IVAL(data,60); + uint32_t dev_minor = IVAL(data,68); + sbuf->st_ex_rdev = makedev(dev_major, dev_minor); + } +#endif + /* inode */ + sbuf->st_ex_ino = (SMB_INO_T)IVAL2_TO_SMB_BIG_UINT(data, 76); + + /* protection */ + sbuf->st_ex_mode |= wire_perms_to_unix(IVAL(data, 84)); + + /* number of hard links */ + sbuf->st_ex_nlink = BIG_UINT(data, 92); tevent_req_done(req); } -NTSTATUS cli_posix_stat_recv(struct tevent_req *req, - SMB_STRUCT_STAT *sbuf) +NTSTATUS cli_posix_stat_recv(struct tevent_req *req) { - struct stat_state *state = tevent_req_data(req, struct stat_state); - NTSTATUS status; - - if (tevent_req_is_nterror(req, &status)) { - return status; - } - if (sbuf != NULL) { - *sbuf = state->sbuf; - } - tevent_req_received(req); - return NT_STATUS_OK; + return tevent_req_simple_recv_ntstatus(req); } NTSTATUS cli_posix_stat(struct cli_state *cli, @@ -890,7 +868,7 @@ NTSTATUS cli_posix_stat(struct cli_state *cli, goto fail; } - req = cli_posix_stat_send(frame, ev, cli, fname); + req = cli_posix_stat_send(frame, ev, cli, fname, sbuf); if (req == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; @@ -900,7 +878,7 @@ NTSTATUS cli_posix_stat(struct cli_state *cli, goto fail; } - status = cli_posix_stat_recv(req, sbuf); + status = cli_posix_stat_recv(req); fail: TALLOC_FREE(frame); diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index ca6d8b53129..f868e72a239 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -305,63 +305,6 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx, } return calc_next_entry_offset(base, pdata_end); } - case SMB_FIND_FILE_UNIX_INFO2: - { - SMB_STRUCT_STAT *sbuf = &finfo->posix_sbuf; - size_t namelen; - - if (pdata_end - base < 128) { - return pdata_end - base; - } - - p += 4; /* next entry offset */ - - if (p_resume_key) { - *p_resume_key = IVAL(p,0); - } - p += 4; /* fileindex */ - - fetch_file_unix_basic_info2((const uint8_t *)p, sbuf); - p += 116; - - finfo->mode = S_ISDIR(sbuf->st_ex_mode) ? - FILE_ATTRIBUTE_DIRECTORY : - FILE_ATTRIBUTE_NORMAL; - if (sbuf->st_ex_mode & S_IXUSR) { - finfo->mode |= FILE_ATTRIBUTE_ARCHIVE; - } - - finfo->size = sbuf->st_ex_size; - finfo->allocated_size = - sbuf->st_ex_blksize * sbuf->st_ex_blocks; - finfo->uid = sbuf->st_ex_uid; - finfo->gid = sbuf->st_ex_gid; - finfo->ino = sbuf->st_ex_ino; - finfo->btime_ts = sbuf->st_ex_btime; - finfo->mtime_ts = sbuf->st_ex_mtime; - finfo->atime_ts = sbuf->st_ex_atime; - finfo->ctime_ts = sbuf->st_ex_ctime; - - namelen = IVAL(p, 0); - p += 4; - - if (namelen > (pdata_end - p)) { - return pdata_end - base; - } - - ret = clistr_pull_talloc( - ctx, - base_ptr, - recv_flags2, - &finfo->name, - p, - namelen, - 0); - if (ret == (size_t)-1) { - return pdata_end - base; - } - return calc_next_entry_offset(base, pdata_end); - } } DEBUG(1,("Unknown long filename format %d\n",level)); @@ -1100,7 +1043,6 @@ NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16_t attribute, NTSTATUS status = NT_STATUS_NO_MEMORY; struct file_info *finfo; size_t i, num_finfo = 0; - uint32_t caps; uint16_t info_level; if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { @@ -1121,15 +1063,8 @@ NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16_t attribute, goto fail; } - caps = smb1cli_conn_capabilities(cli->conn); - - if (caps & CAP_UNIX) { - info_level = SMB_FIND_FILE_UNIX_INFO2; - } else if (caps & CAP_NT_SMBS) { - info_level = SMB_FIND_FILE_BOTH_DIRECTORY_INFO; - } else { - info_level = SMB_FIND_INFO_STANDARD; - } + info_level = (smb1cli_conn_capabilities(cli->conn) & CAP_NT_SMBS) + ? SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_INFO_STANDARD; req = cli_list_send(frame, ev, cli, mask, attribute, info_level); if (req == NULL) { diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 801d556f53b..00d2a878e84 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -49,7 +49,6 @@ static void remove_dirplus(SMBCFILE *dir) struct smbc_dirplus_list *f = d; d = d->next; - SAFE_FREE(f->posix_sbuf); SAFE_FREE(f->smb_finfo->short_name); SAFE_FREE(f->smb_finfo->name); SAFE_FREE(f->smb_finfo); @@ -213,20 +212,6 @@ static int add_dirplus(SMBCFILE *dir, struct file_info *finfo) } new_entry->smb_finfo = info; - if (finfo->posix_sbuf.st_ex_nlink != 0) { - new_entry->posix_sbuf = SMB_MALLOC_P(SMB_STRUCT_STAT); - if (new_entry->posix_sbuf == NULL) { - SAFE_FREE(info->short_name); - SAFE_FREE(info->name); - SAFE_FREE(info); - SAFE_FREE(new_entry); - dir->dir_error = ENOMEM; - return -1; - } - *new_entry->posix_sbuf = finfo->posix_sbuf; - new_entry->posix_sbuf->st_ex_dev = dir->srv->dev; - } - /* Now add to the list. */ if (dir->dirplus_list == NULL) { /* Empty list - point everything at new_entry. */ @@ -561,12 +546,6 @@ SMBC_opendir_ctx(SMBCCTX *context, dir->cli_fd = 0; dir->fname = SMB_STRDUP(fname); - if (dir->fname == NULL) { - SAFE_FREE(dir); - TALLOC_FREE(frame); - errno = ENOMEM; - return NULL; - } dir->srv = NULL; dir->offset = 0; dir->file = False; @@ -1055,7 +1034,7 @@ SMBC_closedir_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -1168,7 +1147,7 @@ SMBC_readdir_ctx(SMBCCTX *context, } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n")); @@ -1247,7 +1226,9 @@ SMBC_readdirplus_ctx(SMBCCTX *context, return NULL; } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if (dir == NULL || + SMBC_dlist_contains(context->internal->files, + dir) == 0) { DBG_ERR("Invalid dir in SMBC_readdirplus_ctx()\n"); TALLOC_FREE(frame); errno = EBADF; @@ -1326,7 +1307,10 @@ const struct libsmb_file_info *SMBC_readdirplus2_ctx(SMBCCTX *context, return NULL; } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if (dir == NULL || + SMBC_dlist_contains(context->internal->files, + dir) == 0) + { DBG_ERR("Invalid dir in SMBC_readdirplus2_ctx()\n"); TALLOC_FREE(frame); errno = EBADF; @@ -1375,20 +1359,15 @@ const struct libsmb_file_info *SMBC_readdirplus2_ctx(SMBCCTX *context, return NULL; } - if (dp_list->posix_sbuf != NULL) { - setup_stat_from_stat_ex(dp_list->posix_sbuf, path, st); - } else { - setup_stat( - st, - path, - smb_finfo->size, - smb_finfo->attrs, - ino, - dir->srv->dev, - smb_finfo->atime_ts, - smb_finfo->ctime_ts, - smb_finfo->mtime_ts); - } + setup_stat(st, + path, + smb_finfo->size, + smb_finfo->attrs, + ino, + dir->srv->dev, + smb_finfo->atime_ts, + smb_finfo->ctime_ts, + smb_finfo->mtime_ts); TALLOC_FREE(full_pathname); @@ -1436,7 +1415,7 @@ SMBC_getdents_ctx(SMBCCTX *context, } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); @@ -1803,7 +1782,7 @@ SMBC_telldir_ctx(SMBCCTX *context, } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); @@ -2651,7 +2630,8 @@ SMBC_notify_ctx(SMBCCTX *context, SMBCFILE *dir, smbc_bool recursive, errno = EINVAL; return -1; } - if (!SMBC_dlist_contains(context->internal->files, dir)) { + if ((dir == NULL) || + !SMBC_dlist_contains(context->internal->files, dir)) { TALLOC_FREE(frame); errno = EBADF; return -1; diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 512827e134d..1577010e490 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -125,21 +125,8 @@ SMBC_open_ctx(SMBCCTX *context, } /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/ - if (srv->try_posixinfo) { - status = cli_posix_open( - targetcli, - targetpath, - flags, - mode, - &fd); - } else { - status = cli_open( - targetcli, - targetpath, - flags, - context->internal->share_mode, - &fd); - } + status = cli_open(targetcli, targetpath, flags, + context->internal->share_mode, &fd); if (!NT_STATUS_IS_OK(status)) { /* Handle the error ... */ @@ -269,9 +256,9 @@ SMBC_read_ctx(SMBCCTX *context, return -1; } - DEBUG(4, ("smbc_read(%p, %zu)\n", file, count)); + DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); - if (!SMBC_dlist_contains(context->internal->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -297,7 +284,7 @@ SMBC_read_ctx(SMBCCTX *context, file->offset += ret; - DEBUG(4, (" --> %zu\n", ret)); + DEBUG(4, (" --> %ld\n", (unsigned long)ret)); TALLOC_FREE(frame); return ret; /* Success, ret bytes of data ... */ @@ -321,13 +308,17 @@ SMBC_splice_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, srcfile)) { + if (!srcfile || + !SMBC_dlist_contains(context->internal->files, srcfile)) + { errno = EBADF; TALLOC_FREE(frame); return -1; } - if (!SMBC_dlist_contains(context->internal->files, dstfile)) { + if (!dstfile || + !SMBC_dlist_contains(context->internal->files, dstfile)) + { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -372,7 +363,7 @@ SMBC_write_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -418,7 +409,7 @@ SMBC_close_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -484,7 +475,7 @@ SMBC_getatr(SMBCCTX * context, } /* path fixup for . and .. */ - if (ISDOT(path) || ISDOTDOT(path)) { + if (strequal(path, ".") || strequal(path, "..")) { fixedpath = talloc_strdup(frame, "\\"); if (!fixedpath) { errno = ENOMEM; @@ -516,9 +507,8 @@ SMBC_getatr(SMBCCTX * context, if (srv->try_posixinfo) { SMB_STRUCT_STAT sbuf; - status = cli_posix_stat(targetcli, targetpath, &sbuf); + status = cli_posix_stat(targetcli, frame, &sbuf); if (NT_STATUS_IS_OK(status)) { - sbuf.st_ex_dev = srv->dev; setup_stat_from_stat_ex(&sbuf, path, sb); TALLOC_FREE(frame); @@ -711,7 +701,7 @@ SMBC_lseek_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -774,7 +764,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/libsmb_misc.c b/source3/libsmb/libsmb_misc.c index 28e2ca842cf..1d874c74cd8 100644 --- a/source3/libsmb/libsmb_misc.c +++ b/source3/libsmb/libsmb_misc.c @@ -31,18 +31,15 @@ /* * check if an element is part of the list. */ -bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p) +int +SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p) { - if ((p == NULL) || (list == NULL)) { - return false; - } + if (!p || !list) return False; do { - if (p == list) { - return true; - } + if (p == list) return True; list = list->next; - } while (list != NULL); - return false; + } while (list); + return False; } diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 104a04a6fc8..d4f71d8c8b7 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -296,6 +296,7 @@ SMBC_server_internal(TALLOC_CTX *ctx, bool use_ccache = false; bool pw_nt_hash = false; + ZERO_STRUCT(c); *in_cache = false; if (server[0] == 0) { diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index a4aaf6c327f..f20f79579e2 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -251,7 +251,7 @@ SMBC_fstat_ctx(SMBCCTX *context, return -1; } - if (!SMBC_dlist_contains(context->internal->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 07c22a696fe..0e2c1adb4ae 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -283,8 +283,6 @@ NTSTATUS cli_posix_hardlink(struct cli_state *cli, const char *newname); uint32_t unix_perms_to_wire(mode_t perms); mode_t wire_perms_to_unix(uint32_t perms); -void fetch_file_unix_basic_info2( - const uint8_t data[116], SMB_STRUCT_STAT *sbuf); struct tevent_req *cli_posix_getacl_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, @@ -312,9 +310,9 @@ NTSTATUS cli_posix_setacl(struct cli_state *cli, struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - const char *fname); -NTSTATUS cli_posix_stat_recv(struct tevent_req *req, - SMB_STRUCT_STAT *sbuf); + const char *fname, + SMB_STRUCT_STAT *sbuf); +NTSTATUS cli_posix_stat_recv(struct tevent_req *req); NTSTATUS cli_posix_stat(struct cli_state *cli, const char *fname, SMB_STRUCT_STAT *sbuf); diff --git a/source3/script/tests/test_smbtorture_s3_no_unix_ext.sh b/source3/script/tests/test_smbtorture_s3_no_unix_ext.sh deleted file mode 100755 index 19af4ff3f3e..00000000000 --- a/source3/script/tests/test_smbtorture_s3_no_unix_ext.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# this runs test_smbtorture_s3 with disabled unix extensions - -if [ -z "$SERVERCONFFILE" ] ; then - echo \$SERVERCONFFILE not defined - exit 1 -fi -inject=${SERVERCONFFILE%/*}/global_inject.conf - -echo "unix extensions = no" > ${inject} -$(dirname $0)/test_smbtorture_s3.sh $* -ret=$? -> ${inject} -exit $ret diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index ff6ab1a6b15..fa7b6c3772a 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -90,7 +90,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7" "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "WILDDELETE", "PROPERTIES", "W2K", "TCON2", "IOCTL", "CHKPATH", "FDSESS", "CHAIN1", "CHAIN2", "OWNER-RIGHTS", "CHAIN3", "PIDHIGH", "CLI_SPLICE", - "UID-REGRESSION-TEST", + "UID-REGRESSION-TEST", "SHORTNAME-TEST", "CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", "SMB2-NEGPROT", "SMB2-SESSION-REAUTH", "SMB2-SESSION-RECONNECT", "SMB2-FTRUNCATE", "SMB2-ANONYMOUS", "SMB2-DIR-FSYNC", @@ -113,26 +113,6 @@ for t in tests: plantestsuite("samba3.smbtorture_s3.plain.%s" % t, "fileserver", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/tmp', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH", "-mNT1"]) plantestsuite("samba3.smbtorture_s3.plain.%s" % t, "ad_dc_ntvfs", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/tmp', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"]) -nonunix_tests = [ - "SHORTNAME-TEST" - ] - -for t in nonunix_tests: - plantestsuite( - "samba3.smbtorture_s3.plain.%s" % t, - "fileserver", - [os.path.join(samba3srcdir, - "script/tests/test_smbtorture_s3_no_unix_ext.sh"), - t, - '//$SERVER_IP/tmp', - '$USERNAME', - '$PASSWORD', - smbtorture3, - "", - "-l $LOCAL_PATH"]) - # Can't run SMB1 encrypted tests without unix extensions. This - # will have to be added once we do SMB3 unix extensions. - t = "TLDAP" plantestsuite("samba3.smbtorture_s3.plain.%s" % t, "ad_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER/tmp', '$DC_USERNAME', '$DC_PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"]) @@ -191,7 +171,7 @@ shares = [ for s in shares: plantestsuite("samba3.smbtorture_s3.%s(simpleserver).SMB2-BASIC" % s, "simpleserver", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), 'SMB2-BASIC', '//$SERVER_IP/' + s, '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"]) t = "smb2.compound_find" - plansmbtorture4testsuite(t, "simpleserver", "//%s/%s %s" % ('$SERVER_IP', s, '-U$USERNAME%$PASSWORD'), description=s) + plansmbtorture4testsuite(t, "simpleserver", "//%s/%s %s" % ('$SERVER_IP', s, ' -U$USERNAME%$PASSWORD'), description=s) posix_tests = ["POSIX", "POSIX-APPEND", "POSIX-SYMLINK-ACL", "POSIX-SYMLINK-EA", "POSIX-OFD-LOCK", "POSIX-STREAM-DELETE", "WINDOWS-BAD-SYMLINK", "POSIX-MKDIR", diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index c55f33c1a2e..389a142db7d 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -365,53 +365,28 @@ netapi = smbtorture4_testsuites("netapi.") for t in base + raw + smb2 + netapi: plansmbtorture4testsuite(t, "ad_dc_ntvfs", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + ntvfsargs) -def planlibsmbclienttest(name, testargs, proto): - env = "nt4_dc" - - url = "--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER" - - cmdarray = selftesthelpers.smbtorture4testsuite_cmdarray( - name, - env, - testargs + [ "--option=torture:clientprotocol=%s" % proto], - 'samba4') - - urloption = url - if name != "libsmbclient.list_shares": - urloption += "/posix_share" - - plantestsuite_loadlist( - "samba4.unix_ext.%s.%s" % (t, proto), - env, - " ".join(cmdarray + - ["--option=torture:unix_extensions=true"] + - [urloption])) - - urloption = url - if name != "libsmbclient.list_shares": - urloption += "/tmp" - - plantestsuite_loadlist( - "samba4.non_unix_ext.%s.%s" % (t, proto), - env, - "(inject=\"${SERVERCONFFILE%/*}/global_inject.conf\"; " + - "echo \"unix extensions = no\" > ${inject} ; " + - " ".join(cmdarray + [urloption]) + - "; > ${inject})") - - libsmbclient = smbtorture4_testsuites("libsmbclient.") protocols = [ 'NT1', 'SMB3' ] for t in libsmbclient: + url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp" + if t == "libsmbclient.list_shares": + url = "smb://$USERNAME:$PASSWORD@$SERVER" + libsmbclient_testargs = [ '//$SERVER/tmp', '-U$USERNAME%$PASSWORD', + "--option=torture:smburl=" + url, "--option=torture:replace_smbconf=" "%s/testdata/samba3/smb_new.conf" % srcdir() ] for proto in protocols: - planlibsmbclienttest(t, libsmbclient_testargs, proto) + plansmbtorture4testsuite( + t, + "nt4_dc", + libsmbclient_testargs + + [ "--option=torture:clientprotocol=%s" % proto], + "samba4.%s.%s" % (t, proto)) plansmbtorture4testsuite("raw.qfileinfo.ipc", "ad_dc_ntvfs", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD') diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c index 13bde24e9c0..c1508680d99 100644 --- a/source4/torture/libsmbclient/libsmbclient.c +++ b/source4/torture/libsmbclient/libsmbclient.c @@ -824,9 +824,6 @@ static bool torture_libsmbclient_readdirplus2(struct torture_context *tctx) struct stat st = {0}; int ret; const char *smburl = torture_setting_string(tctx, "smburl", NULL); - bool unix_extensions = torture_setting_bool( - tctx, "unix_extensions", false); - mode_t expected_mode = 0; if (smburl == NULL) { torture_fail(tctx, @@ -903,26 +900,21 @@ static bool torture_libsmbclient_readdirplus2(struct torture_context *tctx) filename)); } - if (unix_extensions) { - expected_mode = S_IFREG | 0666; - } else { - /* - * New file gets SMBC_FILE_MODE plus - * archive bit -> S_IXUSR - * !READONLY -> S_IWUSR. - */ - expected_mode = SMBC_FILE_MODE|S_IXUSR|S_IWUSR; - } - + /* Ensure mode is as expected. */ + /* + * New file gets SMBC_FILE_MODE plus + * archive bit -> S_IXUSR + * !READONLY -> S_IWUSR. + */ torture_assert_int_equal_goto(tctx, st2.st_mode, - expected_mode, + SMBC_FILE_MODE|S_IXUSR|S_IWUSR, success, done, talloc_asprintf(tctx, "file %s st_mode should be 0%o, got 0%o'", filename, - expected_mode, + SMBC_FILE_MODE|S_IXUSR|S_IWUSR, (unsigned int)st2.st_mode)); /* Ensure smbc_stat() gets the same data. */ |