summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/clideltree.c38
-rw-r--r--source4/libcli/clifile.c141
-rw-r--r--source4/libcli/clilist.c41
-rw-r--r--source4/libcli/climessage.c20
-rw-r--r--source4/libcli/clireadwrite.c20
-rw-r--r--source4/libcli/clisecdesc.c8
-rw-r--r--source4/libcli/clitrans2.c22
-rw-r--r--source4/libcli/util/clierror.c30
8 files changed, 168 insertions, 152 deletions
diff --git a/source4/libcli/clideltree.c b/source4/libcli/clideltree.c
index 8769b8dfa7..d28950f136 100644
--- a/source4/libcli/clideltree.c
+++ b/source4/libcli/clideltree.c
@@ -21,7 +21,7 @@
#include "includes.h"
struct delete_state {
- struct cli_state *cli;
+ struct cli_tree *tree;
int total_deleted;
BOOL failed;
};
@@ -41,30 +41,30 @@ static void delete_fn(file_info *finfo, const char *name, void *state)
asprintf(&s, "%s%s", n, finfo->name);
if (finfo->mode & FILE_ATTRIBUTE_READONLY) {
- if (!cli_setatr(dstate->cli, s, 0, 0)) {
+ if (!cli_setatr(dstate->tree, s, 0, 0)) {
DEBUG(2,("Failed to remove READONLY on %s - %s\n",
- s, cli_errstr(dstate->cli)));
+ s, cli_errstr(dstate->tree)));
}
}
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
char *s2;
asprintf(&s2, "%s\\*", s);
- cli_unlink(dstate->cli, s2);
- cli_list(dstate->cli, s2,
+ cli_unlink(dstate->tree, s2);
+ cli_list(dstate->tree, s2,
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
delete_fn, state);
free(s2);
- if (!cli_rmdir(dstate->cli, s)) {
+ if (!cli_rmdir(dstate->tree, s)) {
DEBUG(2,("Failed to delete %s - %s\n",
- s, cli_errstr(dstate->cli)));
+ s, cli_errstr(dstate->tree)));
dstate->failed = True;
}
dstate->total_deleted++;
} else {
- if (!cli_unlink(dstate->cli, s)) {
+ if (!cli_unlink(dstate->tree, s)) {
DEBUG(2,("Failed to delete %s - %s\n",
- s, cli_errstr(dstate->cli)));
+ s, cli_errstr(dstate->tree)));
dstate->failed = True;
}
dstate->total_deleted++;
@@ -77,34 +77,34 @@ static void delete_fn(file_info *finfo, const char *name, void *state)
recursively descend a tree deleting all files
returns the number of files deleted, or -1 on error
*/
-int cli_deltree(struct cli_state *cli, const char *dname)
+int cli_deltree(struct cli_tree *tree, const char *dname)
{
char *mask;
struct delete_state dstate;
- dstate.cli = cli;
+ dstate.tree = tree;
dstate.total_deleted = 0;
dstate.failed = False;
/* it might be a file */
- if (cli_unlink(cli, dname)) {
+ if (cli_unlink(tree, dname)) {
return 1;
}
- if (NT_STATUS_EQUAL(cli_nt_error(cli), NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
- NT_STATUS_EQUAL(cli_nt_error(cli), NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
- NT_STATUS_EQUAL(cli_nt_error(cli), NT_STATUS_NO_SUCH_FILE)) {
+ if (NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
+ NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
+ NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_NO_SUCH_FILE)) {
return 0;
}
asprintf(&mask, "%s\\*", dname);
- cli_unlink(cli, mask);
- cli_list(dstate.cli, mask,
+ cli_unlink(dstate.tree, mask);
+ cli_list(dstate.tree, mask,
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
delete_fn, &dstate);
free(mask);
- if (!cli_rmdir(dstate.cli, dname)) {
+ if (!cli_rmdir(dstate.tree, dname)) {
DEBUG(2,("Failed to delete %s - %s\n",
- dname, cli_errstr(dstate.cli)));
+ dname, cli_errstr(dstate.tree)));
return -1;
}
dstate.total_deleted++;
diff --git a/source4/libcli/clifile.c b/source4/libcli/clifile.c
index 27ead40740..6606455e49 100644
--- a/source4/libcli/clifile.c
+++ b/source4/libcli/clifile.c
@@ -26,7 +26,7 @@
Hard/Symlink a file (UNIX extensions).
****************************************************************************/
-static BOOL cli_link_internal(struct cli_state *cli,
+static BOOL cli_link_internal(struct cli_tree *tree,
const char *fname_src,
const char *fname_dst, BOOL hard_link)
{
@@ -43,7 +43,7 @@ static BOOL cli_link_internal(struct cli_state *cli,
parms.unix_link.in.link_dest = fname_dst;
}
- status = smb_raw_setpathinfo(cli->tree, &parms);
+ status = smb_raw_setpathinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -79,24 +79,27 @@ static uint32 unix_perms_to_wire(mode_t perms)
/****************************************************************************
Symlink a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_symlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_unix_symlink(struct cli_tree *tree, const char *fname_src,
+ const char *fname_dst)
{
- return cli_link_internal(cli, fname_src, fname_dst, False);
+ return cli_link_internal(tree, fname_src, fname_dst, False);
}
/****************************************************************************
Hard a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_unix_hardlink(struct cli_tree *tree, const char *fname_src,
+ const char *fname_dst)
{
- return cli_link_internal(cli, fname_src, fname_dst, True);
+ return cli_link_internal(tree, fname_src, fname_dst, True);
}
/****************************************************************************
Chmod or chown a file internal (UNIX extensions).
****************************************************************************/
-static BOOL cli_unix_chmod_chown_internal(struct cli_state *cli, const char *fname,
+static BOOL cli_unix_chmod_chown_internal(struct cli_tree *tree,
+ const char *fname,
uint32 mode, uint32 uid, uint32 gid)
{
union smb_setfileinfo parms;
@@ -108,7 +111,7 @@ static BOOL cli_unix_chmod_chown_internal(struct cli_state *cli, const char *fna
parms.unix_basic.in.gid = gid;
parms.unix_basic.in.mode = mode;
- status = smb_raw_setpathinfo(cli->tree, &parms);
+ status = smb_raw_setpathinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -117,25 +120,30 @@ static BOOL cli_unix_chmod_chown_internal(struct cli_state *cli, const char *fna
chmod a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_chmod(struct cli_state *cli, const char *fname, mode_t mode)
+BOOL cli_unix_chmod(struct cli_tree *tree, const char *fname, mode_t mode)
{
- return cli_unix_chmod_chown_internal(cli, fname,
- unix_perms_to_wire(mode), SMB_UID_NO_CHANGE, SMB_GID_NO_CHANGE);
+ return cli_unix_chmod_chown_internal(tree, fname,
+ unix_perms_to_wire(mode),
+ SMB_UID_NO_CHANGE,
+ SMB_GID_NO_CHANGE);
}
/****************************************************************************
chown a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_chown(struct cli_state *cli, const char *fname, uid_t uid, gid_t gid)
+BOOL cli_unix_chown(struct cli_tree *tree, const char *fname, uid_t uid,
+ gid_t gid)
{
- return cli_unix_chmod_chown_internal(cli, fname, SMB_MODE_NO_CHANGE, (uint32)uid, (uint32)gid);
+ return cli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE,
+ (uint32)uid, (uint32)gid);
}
/****************************************************************************
Rename a file.
****************************************************************************/
-BOOL cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_rename(struct cli_tree *tree, const char *fname_src,
+ const char *fname_dst)
{
union smb_rename parms;
@@ -143,14 +151,14 @@ BOOL cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_
parms.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
parms.rename.in.pattern1 = fname_src;
parms.rename.in.pattern2 = fname_dst;
- return NT_STATUS_IS_OK(smb_raw_rename(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_rename(tree, &parms));
}
/****************************************************************************
Delete a file.
****************************************************************************/
-BOOL cli_unlink(struct cli_state *cli, const char *fname)
+BOOL cli_unlink(struct cli_tree *tree, const char *fname)
{
struct smb_unlink parms;
@@ -160,39 +168,39 @@ BOOL cli_unlink(struct cli_state *cli, const char *fname)
} else {
parms.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
}
- return NT_STATUS_IS_OK(smb_raw_unlink(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_unlink(tree, &parms));
}
/****************************************************************************
Create a directory.
****************************************************************************/
-BOOL cli_mkdir(struct cli_state *cli, const char *dname)
+BOOL cli_mkdir(struct cli_tree *tree, const char *dname)
{
union smb_mkdir parms;
parms.mkdir.level = RAW_MKDIR_MKDIR;
parms.mkdir.in.path = dname;
- return NT_STATUS_IS_OK(smb_raw_mkdir(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_mkdir(tree, &parms));
}
/****************************************************************************
Remove a directory.
****************************************************************************/
-BOOL cli_rmdir(struct cli_state *cli, const char *dname)
+BOOL cli_rmdir(struct cli_tree *tree, const char *dname)
{
struct smb_rmdir parms;
parms.in.path = dname;
- return NT_STATUS_IS_OK(smb_raw_rmdir(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_rmdir(tree, &parms));
}
/****************************************************************************
Set or clear the delete on close flag.
****************************************************************************/
-BOOL cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag)
+BOOL cli_nt_delete_on_close(struct cli_tree *tree, int fnum, BOOL flag)
{
union smb_setfileinfo parms;
NTSTATUS status;
@@ -201,7 +209,7 @@ BOOL cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag)
parms.disposition_info.file.fnum = fnum;
parms.disposition_info.in.delete_on_close = flag;
- status = smb_raw_setfileinfo(cli->tree, &parms);
+ status = smb_raw_setfileinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -211,11 +219,11 @@ BOOL cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag)
Create/open a file - exposing the full horror of the NT API :-).
Used in CIFS-on-CIFS NTVFS.
****************************************************************************/
-int cli_nt_create_full(struct cli_state *cli, const char *fname,
- uint32 CreatFlags, uint32 DesiredAccess,
- uint32 FileAttributes, uint32 ShareAccess,
- uint32 CreateDisposition, uint32 CreateOptions,
- uint8 SecurityFlags)
+int cli_nt_create_full(struct cli_tree *tree, const char *fname,
+ uint32 CreatFlags, uint32 DesiredAccess,
+ uint32 FileAttributes, uint32 ShareAccess,
+ uint32 CreateDisposition, uint32 CreateOptions,
+ uint8 SecurityFlags)
{
union smb_open open_parms;
TALLOC_CTX *mem_ctx;
@@ -237,7 +245,7 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
open_parms.ntcreatex.in.security_flags = SecurityFlags;
open_parms.ntcreatex.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &open_parms);
+ status = smb_raw_open(tree, mem_ctx, &open_parms);
talloc_destroy(mem_ctx);
if (NT_STATUS_IS_OK(status)) {
@@ -252,7 +260,8 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
Open a file (using SMBopenx)
WARNING: if you open with O_WRONLY then getattrE won't work!
****************************************************************************/
-int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode)
+int cli_open(struct cli_tree *tree, const char *fname, int flags,
+ int share_mode)
{
union smb_open open_parms;
unsigned openfn=0;
@@ -303,7 +312,7 @@ int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode
open_parms.openx.in.timeout = 0;
open_parms.openx.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &open_parms);
+ status = smb_raw_open(tree, mem_ctx, &open_parms);
talloc_destroy(mem_ctx);
if (NT_STATUS_IS_OK(status)) {
@@ -317,7 +326,7 @@ int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode
/****************************************************************************
Close a file.
****************************************************************************/
-BOOL cli_close(struct cli_state *cli, int fnum)
+BOOL cli_close(struct cli_tree *tree, int fnum)
{
union smb_close close_parms;
NTSTATUS status;
@@ -325,7 +334,7 @@ BOOL cli_close(struct cli_state *cli, int fnum)
close_parms.close.level = RAW_CLOSE_CLOSE;
close_parms.close.in.fnum = fnum;
close_parms.close.in.write_time = 0;
- status = smb_raw_close(cli->tree, &close_parms);
+ status = smb_raw_close(tree, &close_parms);
return NT_STATUS_IS_OK(status);
}
@@ -333,7 +342,7 @@ BOOL cli_close(struct cli_state *cli, int fnum)
send a lock with a specified locktype
this is used for testing LOCKING_ANDX_CANCEL_LOCK
****************************************************************************/
-NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
+NTSTATUS cli_locktype(struct cli_tree *tree, int fnum,
uint32 offset, uint32 len, int timeout, unsigned char locktype)
{
union smb_lock parms;
@@ -346,12 +355,12 @@ NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
parms.lockx.in.timeout = timeout;
parms.lockx.in.ulock_cnt = 0;
parms.lockx.in.lock_cnt = 1;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return status;
}
@@ -360,7 +369,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
/****************************************************************************
Lock a file.
****************************************************************************/
-BOOL cli_lock(struct cli_state *cli, int fnum,
+BOOL cli_lock(struct cli_tree *tree, int fnum,
uint32 offset, uint32 len, int timeout, enum brl_type lock_type)
{
union smb_lock parms;
@@ -373,12 +382,12 @@ BOOL cli_lock(struct cli_state *cli, int fnum,
parms.lockx.in.timeout = timeout;
parms.lockx.in.ulock_cnt = 0;
parms.lockx.in.lock_cnt = 1;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -387,7 +396,7 @@ BOOL cli_lock(struct cli_state *cli, int fnum,
/****************************************************************************
Unlock a file.
****************************************************************************/
-BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
+BOOL cli_unlock(struct cli_tree *tree, int fnum, uint32 offset, uint32 len)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
@@ -399,12 +408,12 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
parms.lockx.in.timeout = 0;
parms.lockx.in.ulock_cnt = 1;
parms.lockx.in.lock_cnt = 0;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -412,7 +421,7 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
/****************************************************************************
Lock a file with 64 bit offsets.
****************************************************************************/
-BOOL cli_lock64(struct cli_state *cli, int fnum,
+BOOL cli_lock64(struct cli_tree *tree, int fnum,
SMB_OFF_T offset, SMB_OFF_T len, int timeout, enum brl_type lock_type)
{
union smb_lock parms;
@@ -420,8 +429,8 @@ BOOL cli_lock64(struct cli_state *cli, int fnum,
struct smb_lock_entry lock[1];
NTSTATUS status;
- if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
- return cli_lock(cli, fnum, offset, len, timeout, lock_type);
+ if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+ return cli_lock(tree, fnum, offset, len, timeout, lock_type);
}
parms.lockx.level = RAW_LOCK_LOCKX;
@@ -433,12 +442,12 @@ BOOL cli_lock64(struct cli_state *cli, int fnum,
parms.lockx.in.timeout = timeout;
parms.lockx.in.ulock_cnt = 0;
parms.lockx.in.lock_cnt = 1;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -447,14 +456,14 @@ BOOL cli_lock64(struct cli_state *cli, int fnum,
/****************************************************************************
Unlock a file with 64 bit offsets.
****************************************************************************/
-BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_OFF_T offset, SMB_OFF_T len)
+BOOL cli_unlock64(struct cli_tree *tree, int fnum, SMB_OFF_T offset, SMB_OFF_T len)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
NTSTATUS status;
- if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
- return cli_unlock(cli, fnum, offset, len);
+ if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+ return cli_unlock(tree, fnum, offset, len);
}
parms.lockx.level = RAW_LOCK_LOCKX;
@@ -463,12 +472,12 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_OFF_T offset, SMB_OFF_T l
parms.lockx.in.timeout = 0;
parms.lockx.in.ulock_cnt = 1;
parms.lockx.in.lock_cnt = 0;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -477,9 +486,9 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_OFF_T offset, SMB_OFF_T l
/****************************************************************************
Do a SMBgetattrE call.
****************************************************************************/
-BOOL cli_getattrE(struct cli_state *cli, int fd,
- uint16 *attr, size_t *size,
- time_t *c_time, time_t *a_time, time_t *m_time)
+BOOL cli_getattrE(struct cli_tree *tree, int fd,
+ uint16 *attr, size_t *size,
+ time_t *c_time, time_t *a_time, time_t *m_time)
{
union smb_fileinfo parms;
NTSTATUS status;
@@ -487,7 +496,7 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
parms.getattre.level = RAW_FILEINFO_GETATTRE;
parms.getattre.in.fnum = fd;
- status = smb_raw_fileinfo(cli->tree, NULL, &parms);
+ status = smb_raw_fileinfo(tree, NULL, &parms);
if (!NT_STATUS_IS_OK(status))
return False;
@@ -518,7 +527,7 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
/****************************************************************************
Do a SMBgetatr call
****************************************************************************/
-BOOL cli_getatr(struct cli_state *cli, const char *fname,
+BOOL cli_getatr(struct cli_tree *tree, const char *fname,
uint16 *attr, size_t *size, time_t *t)
{
union smb_fileinfo parms;
@@ -527,7 +536,7 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
parms.getattr.level = RAW_FILEINFO_GETATTR;
parms.getattr.in.fname = fname;
- status = smb_raw_pathinfo(cli->tree, NULL, &parms);
+ status = smb_raw_pathinfo(tree, NULL, &parms);
if (!NT_STATUS_IS_OK(status)) {
return False;
@@ -552,7 +561,7 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
/****************************************************************************
Do a SMBsetatr call.
****************************************************************************/
-BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 mode, time_t t)
+BOOL cli_setatr(struct cli_tree *tree, const char *fname, uint16 mode, time_t t)
{
union smb_setfileinfo parms;
NTSTATUS status;
@@ -562,7 +571,7 @@ BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 mode, time_t t)
parms.setattr.in.write_time = t;
parms.setattr.file.fname = fname;
- status = smb_raw_setpathinfo(cli->tree, &parms);
+ status = smb_raw_setpathinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
@@ -571,7 +580,7 @@ BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 mode, time_t t)
/****************************************************************************
Check for existence of a dir.
****************************************************************************/
-BOOL cli_chkpath(struct cli_state *cli, const char *path)
+BOOL cli_chkpath(struct cli_tree *tree, const char *path)
{
struct smb_chkpath parms;
char *path2;
@@ -586,7 +595,7 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
parms.in.path = path2;
- status = smb_raw_chkpath(cli->tree, &parms);
+ status = smb_raw_chkpath(tree, &parms);
free(path2);
@@ -597,7 +606,7 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
/****************************************************************************
Query disk space.
****************************************************************************/
-BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
+BOOL cli_dskattr(struct cli_tree *tree, int *bsize, int *total, int *avail)
{
union smb_fsinfo fsinfo_parms;
TALLOC_CTX *mem_ctx;
@@ -606,7 +615,7 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
mem_ctx = talloc_init("cli_dskattr");
fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR;
- status = smb_raw_fsinfo(cli->tree, mem_ctx, &fsinfo_parms);
+ status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms);
if (NT_STATUS_IS_OK(status)) {
*bsize = fsinfo_parms.dskattr.out.block_size;
*total = fsinfo_parms.dskattr.out.units_total;
@@ -622,7 +631,7 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
/****************************************************************************
Create and open a temporary file.
****************************************************************************/
-int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
+int cli_ctemp(struct cli_tree *tree, const char *path, char **tmp_path)
{
union smb_open open_parms;
TALLOC_CTX *mem_ctx;
@@ -635,7 +644,7 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
open_parms.ctemp.in.attrib = 0;
open_parms.ctemp.in.directory = path;
- status = smb_raw_open(cli->tree, mem_ctx, &open_parms);
+ status = smb_raw_open(tree, mem_ctx, &open_parms);
if (tmp_path) {
*tmp_path = strdup(open_parms.ctemp.out.name);
}
diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c
index 425a6002cc..ee0357579c 100644
--- a/source4/libcli/clilist.c
+++ b/source4/libcli/clilist.c
@@ -81,8 +81,9 @@ static BOOL cli_list_new_callback(void *private, union smb_search_data *file)
return True;
}
-int cli_list_new(struct cli_state *cli, const char *Mask, uint16 attribute,
- void (*fn)(file_info *, const char *, void *), void *caller_state)
+int cli_list_new(struct cli_tree *tree, const char *Mask, uint16 attribute,
+ void (*fn)(file_info *, const char *, void *),
+ void *caller_state)
{
union smb_search_first first_parms;
union smb_search_next next_parms;
@@ -104,7 +105,7 @@ int cli_list_new(struct cli_state *cli, const char *Mask, uint16 attribute,
mask = talloc_strdup(state.mem_ctx, Mask);
- if (cli->transport->negotiate.capabilities & CAP_NT_SMBS) {
+ if (tree->session->transport->negotiate.capabilities & CAP_NT_SMBS) {
level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
} else {
level = RAW_SEARCH_STANDARD;
@@ -122,7 +123,7 @@ int cli_list_new(struct cli_state *cli, const char *Mask, uint16 attribute,
first_parms.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
first_parms.t2ffirst.in.storage_type = 0;
- status = smb_raw_search_first(cli->tree,
+ status = smb_raw_search_first(tree,
state.mem_ctx, &first_parms,
(void*)&state, cli_list_new_callback);
if (!NT_STATUS_IS_OK(status)) {
@@ -148,7 +149,7 @@ int cli_list_new(struct cli_state *cli, const char *Mask, uint16 attribute,
next_parms.t2fnext.in.resume_key = 0;
next_parms.t2fnext.in.flags = FLAG_TRANS2_FIND_CONTINUE | FLAG_TRANS2_FIND_CLOSE_IF_END;
- status = smb_raw_search_next(cli->tree,
+ status = smb_raw_search_next(tree,
state.mem_ctx,
&next_parms,
(void*)&state,
@@ -223,8 +224,9 @@ static BOOL cli_list_old_callback(void *private, union smb_search_data *file)
return True;
}
-int cli_list_old(struct cli_state *cli, const char *Mask, uint16 attribute,
- void (*fn)(file_info *, const char *, void *), void *caller_state)
+int cli_list_old(struct cli_tree *tree, const char *Mask, uint16 attribute,
+ void (*fn)(file_info *, const char *, void *),
+ void *caller_state)
{
union smb_search_first first_parms;
union smb_search_next next_parms;
@@ -254,10 +256,11 @@ int cli_list_old(struct cli_state *cli, const char *Mask, uint16 attribute,
first_parms.search_first.in.search_attrib = attribute;
first_parms.search_first.in.pattern = mask;
- status = smb_raw_search_first(cli->tree, state.mem_ctx,
- &first_parms,
- (void*)&state,
- cli_list_old_callback);
+ status = smb_raw_search_first(tree, state.mem_ctx,
+ &first_parms,
+ (void*)&state,
+ cli_list_old_callback);
+
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
return -1;
@@ -274,10 +277,10 @@ int cli_list_old(struct cli_state *cli, const char *Mask, uint16 attribute,
next_parms.search_next.in.search_attrib = attribute;
next_parms.search_next.in.search_id = state.status;
- status = smb_raw_search_next(cli->tree, state.mem_ctx,
- &next_parms,
- (void*)&state,
- cli_list_old_callback);
+ status = smb_raw_search_next(tree, state.mem_ctx,
+ &next_parms,
+ (void*)&state,
+ cli_list_old_callback);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
@@ -304,10 +307,10 @@ int cli_list_old(struct cli_state *cli, const char *Mask, uint16 attribute,
This auto-switches between old and new style.
****************************************************************************/
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+int cli_list(struct cli_tree *tree, const char *Mask,uint16 attribute,
void (*fn)(file_info *, const char *, void *), void *state)
{
- if (cli->transport->negotiate.protocol <= PROTOCOL_LANMAN1)
- return cli_list_old(cli, Mask, attribute, fn, state);
- return cli_list_new(cli, Mask, attribute, fn, state);
+ if (tree->session->transport->negotiate.protocol <= PROTOCOL_LANMAN1)
+ return cli_list_old(tree, Mask, attribute, fn, state);
+ return cli_list_new(tree, Mask, attribute, fn, state);
}
diff --git a/source4/libcli/climessage.c b/source4/libcli/climessage.c
index ad5d41545b..6470f4c154 100644
--- a/source4/libcli/climessage.c
+++ b/source4/libcli/climessage.c
@@ -25,17 +25,17 @@
/****************************************************************************
start a message sequence
****************************************************************************/
-BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
- int *grp)
+BOOL cli_message_start(struct cli_tree *tree, char *host, char *username,
+ int *grp)
{
struct cli_request *req;
- req = cli_request_setup(cli->tree, SMBsendstrt, 0, 0);
+ req = cli_request_setup(tree, SMBsendstrt, 0, 0);
cli_req_append_string(req, username, STR_TERMINATE);
cli_req_append_string(req, host, STR_TERMINATE);
if (!cli_request_send(req) ||
!cli_request_receive(req) ||
- cli_is_error(cli)) {
+ cli_is_error(tree)) {
cli_request_destroy(req);
return False;
}
@@ -50,18 +50,18 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
/****************************************************************************
send a message
****************************************************************************/
-BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
+BOOL cli_message_text(struct cli_tree *tree, char *msg, int len, int grp)
{
struct cli_request *req;
- req = cli_request_setup(cli->tree, SMBsendtxt, 1, 0);
+ req = cli_request_setup(tree, SMBsendtxt, 1, 0);
SSVAL(req->out.vwv, VWV(0), grp);
cli_req_append_bytes(req, msg, len);
if (!cli_request_send(req) ||
!cli_request_receive(req) ||
- cli_is_error(cli)) {
+ cli_is_error(tree)) {
cli_request_destroy(req);
return False;
}
@@ -73,16 +73,16 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
/****************************************************************************
end a message
****************************************************************************/
-BOOL cli_message_end(struct cli_state *cli, int grp)
+BOOL cli_message_end(struct cli_tree *tree, int grp)
{
struct cli_request *req;
- req = cli_request_setup(cli->tree, SMBsendend, 1, 0);
+ req = cli_request_setup(tree, SMBsendend, 1, 0);
SSVAL(req->out.vwv, VWV(0), grp);
if (!cli_request_send(req) ||
!cli_request_receive(req) ||
- cli_is_error(cli)) {
+ cli_is_error(tree)) {
cli_request_destroy(req);
return False;
}
diff --git a/source4/libcli/clireadwrite.c b/source4/libcli/clireadwrite.c
index 1e6c0fc064..7b47281e2c 100644
--- a/source4/libcli/clireadwrite.c
+++ b/source4/libcli/clireadwrite.c
@@ -24,7 +24,8 @@
/****************************************************************************
Read size bytes at offset offset using SMBreadX.
****************************************************************************/
-ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size)
+ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset,
+ size_t size)
{
union smb_read parms;
int readsize;
@@ -41,7 +42,8 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
* Set readsize to the maximum size we can handle in one readX,
* rounded down to a multiple of 1024.
*/
- readsize = (cli->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
+ readsize = (tree->session->transport->negotiate.max_xmit -
+ (MIN_SMB_SIZE+32)) & ~1023;
if (readsize > 0xFFFF) readsize = 0xFFFF;
while (total < size) {
@@ -55,7 +57,7 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
parms.readx.in.remaining = size - total;
parms.readx.out.data = buf + total;
- status = smb_raw_read(cli->tree, &parms);
+ status = smb_raw_read(tree, &parms);
if (!NT_STATUS_IS_OK(status)) {
return -1;
@@ -80,12 +82,12 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
0x0004 use raw named pipe protocol
0x0008 start of message mode named pipe protocol
****************************************************************************/
-ssize_t cli_write(struct cli_state *cli,
+ssize_t cli_write(struct cli_tree *tree,
int fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size)
{
union smb_write parms;
- int block = (cli->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
+ int block = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
ssize_t total = 0;
if (size == 0) {
@@ -109,7 +111,7 @@ ssize_t cli_write(struct cli_state *cli,
parms.writex.in.count = block;
parms.writex.in.data = buf;
- status = smb_raw_write(cli->tree, &parms);
+ status = smb_raw_write(tree, &parms);
if (!NT_STATUS_IS_OK(status)) {
return -1;
@@ -126,7 +128,7 @@ ssize_t cli_write(struct cli_state *cli,
/****************************************************************************
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/
-ssize_t cli_smbwrite(struct cli_state *cli,
+ssize_t cli_smbwrite(struct cli_tree *tree,
int fnum, char *buf, off_t offset, size_t size1)
{
union smb_write parms;
@@ -136,7 +138,7 @@ ssize_t cli_smbwrite(struct cli_state *cli,
parms.write.in.remaining = 0;
do {
- size_t size = MIN(size1, cli->transport->negotiate.max_xmit - 48);
+ size_t size = MIN(size1, tree->session->transport->negotiate.max_xmit - 48);
if (size > 0xFFFF) size = 0xFFFF;
parms.write.in.fnum = fnum;
@@ -144,7 +146,7 @@ ssize_t cli_smbwrite(struct cli_state *cli,
parms.write.in.count = size;
parms.write.in.data = buf + total;
- if (NT_STATUS_IS_ERR(smb_raw_write(cli->tree, &parms)))
+ if (NT_STATUS_IS_ERR(smb_raw_write(tree, &parms)))
return -1;
size = parms.write.out.nwritten;
diff --git a/source4/libcli/clisecdesc.c b/source4/libcli/clisecdesc.c
index 66272251ec..7f3ec0f6bf 100644
--- a/source4/libcli/clisecdesc.c
+++ b/source4/libcli/clisecdesc.c
@@ -24,7 +24,7 @@
/****************************************************************************
query the security descriptor for a open file
****************************************************************************/
-SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
+SEC_DESC *cli_query_secdesc(struct cli_tree *tree, int fnum,
TALLOC_CTX *mem_ctx)
{
struct smb_nttrans parms;
@@ -48,7 +48,7 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
parms.in.params = param_blob;
parms.in.data = data_blob(NULL, 0);
- status = smb_raw_nttrans(cli->tree, mem_ctx, &parms);
+ status = smb_raw_nttrans(tree, mem_ctx, &parms);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1,("Failed to send NT_TRANSACT_QUERY_SECURITY_DESC\n"));
@@ -72,7 +72,7 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
/****************************************************************************
set the security descriptor for a open file
****************************************************************************/
-BOOL cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
+BOOL cli_set_secdesc(struct cli_tree *tree, int fnum, SEC_DESC *sd)
{
struct smb_nttrans parms;
char param[8];
@@ -106,7 +106,7 @@ BOOL cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
parms.in.params = param_blob;
parms.in.data = data_blob(NULL, 0);
- status = smb_raw_nttrans(cli->tree, mem_ctx, &parms);
+ status = smb_raw_nttrans(tree, mem_ctx, &parms);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(1,("Failed to send NT_TRANSACT_SET_SECURITY_DESC\n"));
diff --git a/source4/libcli/clitrans2.c b/source4/libcli/clitrans2.c
index 0ceac925f7..c8f7db5a9d 100644
--- a/source4/libcli/clitrans2.c
+++ b/source4/libcli/clitrans2.c
@@ -23,7 +23,7 @@
/****************************************************************************
send a qpathinfo call
****************************************************************************/
-BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
+BOOL cli_qpathinfo(struct cli_tree *tree, const char *fname,
time_t *c_time, time_t *a_time, time_t *m_time,
size_t *size, uint16 *mode)
{
@@ -37,7 +37,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
parms.standard.level = RAW_FILEINFO_STANDARD;
parms.standard.in.fname = fname;
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_pathinfo(tree, mem_ctx, &parms);
talloc_destroy(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
return False;
@@ -65,7 +65,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
/****************************************************************************
send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
****************************************************************************/
-BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
+BOOL cli_qpathinfo2(struct cli_tree *tree, const char *fname,
time_t *c_time, time_t *a_time, time_t *m_time,
time_t *w_time, size_t *size, uint16 *mode,
SMB_INO_T *ino)
@@ -80,7 +80,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
parms.all_info.level = RAW_FILEINFO_ALL_INFO;
parms.all_info.in.fname = fname;
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_pathinfo(tree, mem_ctx, &parms);
talloc_destroy(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
return False;
@@ -112,7 +112,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
/****************************************************************************
send a qfileinfo QUERY_FILE_NAME_INFO call
****************************************************************************/
-BOOL cli_qfilename(struct cli_state *cli, int fnum,
+BOOL cli_qfilename(struct cli_tree *tree, int fnum,
const char **name)
{
union smb_fileinfo parms;
@@ -125,7 +125,7 @@ BOOL cli_qfilename(struct cli_state *cli, int fnum,
parms.name_info.level = RAW_FILEINFO_NAME_INFO;
parms.name_info.in.fnum = fnum;
- status = smb_raw_fileinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_fileinfo(tree, mem_ctx, &parms);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(mem_ctx);
*name = NULL;
@@ -143,7 +143,7 @@ BOOL cli_qfilename(struct cli_state *cli, int fnum,
/****************************************************************************
send a qfileinfo call
****************************************************************************/
-BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
+BOOL cli_qfileinfo(struct cli_tree *tree, int fnum,
uint16 *mode, size_t *size,
time_t *c_time, time_t *a_time, time_t *m_time,
time_t *w_time, SMB_INO_T *ino)
@@ -158,7 +158,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
parms.all_info.level = RAW_FILEINFO_ALL_INFO;
parms.all_info.in.fnum = fnum;
- status = smb_raw_fileinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_fileinfo(tree, mem_ctx, &parms);
talloc_destroy(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
return False;
@@ -193,7 +193,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
/****************************************************************************
send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
****************************************************************************/
-NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname,
+NTSTATUS cli_qpathinfo_alt_name(struct cli_tree *tree, const char *fname,
const char **alt_name)
{
union smb_fileinfo parms;
@@ -206,11 +206,11 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname,
mem_ctx = talloc_init("cli_qpathinfo_alt_name");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_pathinfo(tree, mem_ctx, &parms);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(mem_ctx);
*alt_name = NULL;
- return cli_nt_error(cli);
+ return cli_nt_error(tree);
}
if (!parms.alt_name_info.out.fname.s) {
diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c
index 4fa1daa3be..97436d2106 100644
--- a/source4/libcli/util/clierror.c
+++ b/source4/libcli/util/clierror.c
@@ -25,14 +25,15 @@
/***************************************************************************
Return an error message from the last response
****************************************************************************/
-const char *cli_errstr(struct cli_state *cli)
+const char *cli_errstr(struct cli_tree *tree)
{
- switch (cli->transport->error.etype) {
+ switch (tree->session->transport->error.etype) {
case ETYPE_DOS:
- return dos_errstr(cli->transport->error.e.dos.eclass,
- cli->transport->error.e.dos.ecode);
+ return dos_errstr(
+ tree->session->transport->error.e.dos.eclass,
+ tree->session->transport->error.e.dos.ecode);
case ETYPE_NT:
- return nt_errstr(cli->transport->error.e.nt_status);
+ return nt_errstr(tree->session->transport->error.e.nt_status);
case ETYPE_SOCKET:
return "socket_error";
@@ -48,15 +49,16 @@ const char *cli_errstr(struct cli_state *cli)
/* Return the 32-bit NT status code from the last packet */
-NTSTATUS cli_nt_error(struct cli_state *cli)
+NTSTATUS cli_nt_error(struct cli_tree *tree)
{
- switch (cli->transport->error.etype) {
+ switch (tree->session->transport->error.etype) {
case ETYPE_NT:
- return cli->transport->error.e.nt_status;
+ return tree->session->transport->error.e.nt_status;
case ETYPE_DOS:
- return dos_to_ntstatus(cli->transport->error.e.dos.eclass,
- cli->transport->error.e.dos.ecode);
+ return dos_to_ntstatus(
+ tree->session->transport->error.e.dos.eclass,
+ tree->session->transport->error.e.dos.ecode);
case ETYPE_SOCKET:
return NT_STATUS_UNSUCCESSFUL;
@@ -87,13 +89,13 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode)
/* Return true if the last packet was an error */
-BOOL cli_is_error(struct cli_state *cli)
+BOOL cli_is_error(struct cli_tree *tree)
{
- return NT_STATUS_IS_ERR(cli_nt_error(cli));
+ return NT_STATUS_IS_ERR(cli_nt_error(tree));
}
/* Return true if the last error was a DOS error */
-BOOL cli_is_dos_error(struct cli_state *cli)
+BOOL cli_is_dos_error(struct cli_tree *tree)
{
- return cli->transport->error.etype == ETYPE_DOS;
+ return tree->session->transport->error.etype == ETYPE_DOS;
}