mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
libsmbclient: Put it back to a known, well-working state
For adapting unix extensions in our client libraries, we need a fresh start with additional APIs. We can't change existing application behaviour. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
0982980dc6
commit
9653a10738
@ -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
|
||||
|
@ -1,2 +0,0 @@
|
||||
# We don't have SMB3 unix extensions yet
|
||||
samba4.unix_ext.libsmbclient.readdirplus2.SMB3.readdirplus2.*
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -736,10 +736,66 @@ 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)
|
||||
/****************************************************************************
|
||||
Stat a file (UNIX extensions).
|
||||
****************************************************************************/
|
||||
|
||||
struct stat_state {
|
||||
SMB_STRUCT_STAT *sbuf;
|
||||
};
|
||||
|
||||
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,
|
||||
SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
ZERO_STRUCTP(sbuf);
|
||||
struct tevent_req *req = NULL, *subreq = NULL;
|
||||
struct stat_state *state = NULL;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state, struct stat_state);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
state->sbuf = sbuf;
|
||||
|
||||
subreq = cli_qpathinfo_send(state, ev, cli, fname,
|
||||
SMB_QUERY_FILE_UNIX_BASIC, 100, 100);
|
||||
if (tevent_req_nomem(subreq, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
tevent_req_set_callback(subreq, cli_posix_stat_done, req);
|
||||
return req;
|
||||
}
|
||||
|
||||
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;
|
||||
uint8_t *data;
|
||||
uint32_t num_data = 0;
|
||||
NTSTATUS status;
|
||||
|
||||
status = cli_qpathinfo_recv(subreq, state, &data, &num_data);
|
||||
TALLOC_FREE(subreq);
|
||||
if (tevent_req_nterror(req, status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (num_data != 100) {
|
||||
/*
|
||||
* Paranoia, cli_qpathinfo should have guaranteed
|
||||
* this, but you never know...
|
||||
*/
|
||||
tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
*sbuf = (SMB_STRUCT_STAT) { 0 };
|
||||
|
||||
/* total size, in bytes */
|
||||
sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(data, 0);
|
||||
@ -753,13 +809,13 @@ static void fetch_file_unix_basic_info(
|
||||
sbuf->st_ex_blocks /= 512;
|
||||
#endif
|
||||
/* time of last change */
|
||||
sbuf->st_ex_ctime = interpret_long_date((const char *)(data + 16));
|
||||
sbuf->st_ex_ctime = interpret_long_date((char *)(data + 16));
|
||||
|
||||
/* time of last access */
|
||||
sbuf->st_ex_atime = interpret_long_date((const char *)(data + 24));
|
||||
sbuf->st_ex_atime = interpret_long_date((char *)(data + 24));
|
||||
|
||||
/* time of last modification */
|
||||
sbuf->st_ex_mtime = interpret_long_date((const char *)(data + 32));
|
||||
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 */
|
||||
@ -780,91 +836,13 @@ static void fetch_file_unix_basic_info(
|
||||
|
||||
/* 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;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
struct tevent_req *req = NULL, *subreq = NULL;
|
||||
struct stat_state *state = NULL;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state, struct stat_state);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subreq = cli_qpathinfo_send(state, ev, cli, fname,
|
||||
SMB_QUERY_FILE_UNIX_BASIC, 100, 100);
|
||||
if (tevent_req_nomem(subreq, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
tevent_req_set_callback(subreq, cli_posix_stat_done, req);
|
||||
return req;
|
||||
}
|
||||
|
||||
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;
|
||||
uint8_t *data;
|
||||
uint32_t num_data = 0;
|
||||
NTSTATUS status;
|
||||
|
||||
status = cli_qpathinfo_recv(subreq, state, &data, &num_data);
|
||||
TALLOC_FREE(subreq);
|
||||
if (tevent_req_nterror(req, status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (num_data != 100) {
|
||||
/*
|
||||
* Paranoia, cli_qpathinfo should have guaranteed
|
||||
* this, but you never know...
|
||||
*/
|
||||
tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch_file_unix_basic_info(data, sbuf);
|
||||
|
||||
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);
|
||||
|
@ -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) {
|
||||
|
@ -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,11 +1359,7 @@ 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,
|
||||
setup_stat(st,
|
||||
path,
|
||||
smb_finfo->size,
|
||||
smb_finfo->attrs,
|
||||
@ -1388,7 +1368,6 @@ const struct libsmb_file_info *SMBC_readdirplus2_ctx(SMBCCTX *context,
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
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);
|
||||
|
@ -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
|
@ -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",
|
||||
|
@ -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')
|
||||
|
||||
|
@ -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 {
|
||||
/* Ensure mode is as expected. */
|
||||
/*
|
||||
* New file gets SMBC_FILE_MODE plus
|
||||
* archive bit -> S_IXUSR
|
||||
* !READONLY -> S_IWUSR.
|
||||
*/
|
||||
expected_mode = SMBC_FILE_MODE|S_IXUSR|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. */
|
||||
|
Loading…
Reference in New Issue
Block a user