*
**/
-static NTSTATUS connect_to_domain_password_server(struct cli_state **cli,
+static NTSTATUS connect_to_domain_password_server(struct smbcli_state **cli,
const char *server,
const char *setup_creds_as,
uint16_t sec_chan,
return NT_STATUS_NO_LOGON_SERVERS;
/* Attempt connection */
- result = cli_full_connection(cli, lp_netbios_name(), remote_machine,
+ result = smbcli_full_connection(cli, lp_netbios_name(), remote_machine,
&dest_ip, 0, "IPC$", "IPC", "", "", "",0, retry);
if (!NT_STATUS_IS_OK(result)) {
* into account also. This patch from "Bjart Kvarme" <bjart.kvarme@usit.uio.no>.
*/
- if(cli_nt_session_open(*cli, PI_NETLOGON) == False) {
+ if(smbcli_nt_session_open(*cli, PI_NETLOGON) == False) {
DEBUG(0,("connect_to_domain_password_server: unable to open the domain client session to \
-machine %s. Error was : %s.\n", remote_machine, cli_errstr(*cli)));
- cli_nt_session_close(*cli);
- cli_ulogoff(*cli);
- cli_shutdown(*cli);
+machine %s. Error was : %s.\n", remote_machine, smbcli_errstr(*cli)));
+ smbcli_nt_session_close(*cli);
+ smbcli_ulogoff(*cli);
+ smbcli_shutdown(*cli);
release_server_mutex();
return NT_STATUS_NO_LOGON_SERVERS;
}
return NT_STATUS_NO_MEMORY;
}
- result = cli_nt_setup_creds(*cli, sec_chan, trust_passwd, &neg_flags, 2);
+ result = smbcli_nt_setup_creds(*cli, sec_chan, trust_passwd, &neg_flags, 2);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0,("connect_to_domain_password_server: unable to setup the NETLOGON credentials to machine \
%s. Error was : %s.\n", remote_machine, nt_errstr(result)));
- cli_nt_session_close(*cli);
- cli_ulogoff(*cli);
- cli_shutdown(*cli);
+ smbcli_nt_session_close(*cli);
+ smbcli_ulogoff(*cli);
+ smbcli_shutdown(*cli);
release_server_mutex();
return result;
}
Utility function to attempt a connection to an IP address of a DC.
************************************************************************/
-static NTSTATUS attempt_connect_to_dc(struct cli_state **cli,
+static NTSTATUS attempt_connect_to_dc(struct smbcli_state **cli,
const char *domain,
struct in_addr *ip,
const char *setup_creds_as,
We have been asked to dynamically determine the IP addresses of
the PDC and BDC's for DOMAIN, and query them in turn.
************************************************************************/
-static NTSTATUS find_connect_dc(struct cli_state **cli,
+static NTSTATUS find_connect_dc(struct smbcli_state **cli,
const char *domain,
const char *setup_creds_as,
uint16_t sec_chan,
{
fstring remote_machine;
NET_USER_INFO_3 info3;
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
NTSTATUS nt_status = NT_STATUS_NO_LOGON_SERVERS;
/*
* in the info3 structure.
*/
- nt_status = cli_netlogon_sam_network_logon(cli, mem_ctx,
+ nt_status = smbcli_netlogon_sam_network_logon(cli, mem_ctx,
user_info->smb_name.str, user_info->domain.str,
user_info->wksta_name.str, chal,
user_info->lm_resp, user_info->nt_resp,
*/
if (NT_STATUS_IS_OK(status)) {
- if(cli_nt_logoff(&cli, &ctr) == False) {
+ if(smbcli_nt_logoff(&cli, &ctr) == False) {
DEBUG(0,("domain_client_validate: unable to log off user %s in domain \
-%s to Domain controller %s. Error was %s.\n", user, domain, remote_machine, cli_errstr(&cli)));
+%s to Domain controller %s. Error was %s.\n", user, domain, remote_machine, smbcli_errstr(&cli)));
nt_status = NT_STATUS_LOGON_FAILURE;
}
}
to allocate the other_sids and gids structures has been deleted - so
these pointers are no longer valid..... */
- cli_nt_session_close(cli);
- cli_ulogoff(cli);
- cli_shutdown(cli);
+ smbcli_nt_session_close(cli);
+ smbcli_ulogoff(cli);
+ smbcli_shutdown(cli);
release_server_mutex();
return nt_status;
}
Support for server level security.
****************************************************************************/
-static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
+static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
{
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
fstring desthost;
struct in_addr dest_ip;
const char *p;
char *pserver;
BOOL connected_ok = False;
- if (!(cli = cli_initialise(cli)))
+ if (!(cli = smbcli_initialise(cli)))
return NULL;
/* security = server just can't function with spnego */
return NULL;
}
- if (cli_connect(cli, desthost, &dest_ip)) {
+ if (smbcli_connect(cli, desthost, &dest_ip)) {
DEBUG(3,("connected to password server %s\n",desthost));
connected_ok = True;
break;
if (!connected_ok) {
release_server_mutex();
DEBUG(0,("password server not available\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return NULL;
}
desthost, &dest_ip)) {
release_server_mutex();
DEBUG(1,("password server fails session request\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return NULL;
}
DEBUG(3,("got session\n"));
- if (!cli_negprot(cli)) {
+ if (!smbcli_negprot(cli)) {
DEBUG(1,("%s rejected the negprot\n",desthost));
release_server_mutex();
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return NULL;
}
!(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
DEBUG(1,("%s isn't in user level security mode\n",desthost));
release_server_mutex();
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return NULL;
}
this one...
*/
- if (!cli_session_setup(cli, "", "", 0, "", 0,
+ if (!smbcli_session_setup(cli, "", "", 0, "", 0,
"")) {
DEBUG(0,("%s rejected the initial session setup (%s)\n",
- desthost, cli_errstr(cli)));
+ desthost, smbcli_errstr(cli)));
release_server_mutex();
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return NULL;
}
static void free_server_private_data(void **private_data_pointer)
{
- struct cli_state **cli = (struct cli_state **)private_data_pointer;
+ struct smbcli_state **cli = (struct smbcli_state **)private_data_pointer;
if (*cli && (*cli)->initialised) {
- cli_shutdown(*cli);
+ smbcli_shutdown(*cli);
}
}
static void send_server_keepalive(void **private_data_pointer)
{
- struct cli_state **cli = (struct cli_state **)private_data_pointer;
+ struct smbcli_state **cli = (struct smbcli_state **)private_data_pointer;
/* also send a keepalive to the password server if its still
connected */
if (cli && *cli && (*cli)->initialised) {
if (!send_nbt_keepalive((*cli)->fd)) {
DEBUG( 2, ( "password server keepalive failed.\n"));
- cli_shutdown(*cli);
+ smbcli_shutdown(*cli);
}
}
}
void **my_private_data,
TALLOC_CTX *mem_ctx)
{
- struct cli_state *cli = server_cryptkey(mem_ctx);
+ struct smbcli_state *cli = server_cryptkey(mem_ctx);
if (cli) {
DEBUG(3,("using password server validation\n"));
} else if (cli->secblob.length < 8) {
/* We can't do much if we don't get a full challenge */
DEBUG(2,("make_auth_info_server: Didn't receive a full challenge from server\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return data_blob(NULL, 0);
}
const auth_usersupplied_info *user_info,
auth_serversupplied_info **server_info)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
static uint8_t badpass[24];
static fstring baduser;
static BOOL tested_password_server = False;
*/
if ((!tested_password_server) && (lp_paranoid_server_security())) {
- if (cli_session_setup(cli, baduser, (char *)badpass, sizeof(badpass),
+ if (smbcli_session_setup(cli, baduser, (char *)badpass, sizeof(badpass),
(char *)badpass, sizeof(badpass), user_info->domain.str)) {
/*
with a bad password.\n", cli->desthost));
DEBUG(0,("server_validate: This is broken (and insecure) behaviour. Please do not \
use this machine as the password server.\n"));
- cli_ulogoff(cli);
+ smbcli_ulogoff(cli);
/*
* Password server has the bug.
bad_password_server = True;
return NT_STATUS_LOGON_FAILURE;
}
- cli_ulogoff(cli);
+ smbcli_ulogoff(cli);
}
} else {
if (!user_info->encrypted) {
/* Plaintext available */
- if (!cli_session_setup(cli, user_info->smb_name.str,
+ if (!smbcli_session_setup(cli, user_info->smb_name.str,
(char *)user_info->plaintext_password.data,
user_info->plaintext_password.length,
NULL, 0,
user_info->domain.str)) {
DEBUG(1,("password server %s rejected the password\n", cli->desthost));
- /* Make this cli_nt_error() when the conversion is in */
- nt_status = cli_nt_error(cli);
+ /* Make this smbcli_nt_error() when the conversion is in */
+ nt_status = smbcli_nt_error(cli);
} else {
nt_status = NT_STATUS_OK;
}
} else {
- if (!cli_session_setup(cli, user_info->smb_name.str,
+ if (!smbcli_session_setup(cli, user_info->smb_name.str,
(char *)user_info->lm_resp.data,
user_info->lm_resp.length,
(char *)user_info->nt_resp.data,
user_info->nt_resp.length,
user_info->domain.str)) {
DEBUG(1,("password server %s rejected the password\n", cli->desthost));
- /* Make this cli_nt_error() when the conversion is in */
- nt_status = cli_nt_error(cli);
+ /* Make this smbcli_nt_error() when the conversion is in */
+ nt_status = smbcli_nt_error(cli);
} else {
nt_status = NT_STATUS_OK;
}
nt_status = NT_STATUS_LOGON_FAILURE;
}
- cli_ulogoff(cli);
+ smbcli_ulogoff(cli);
if NT_STATUS_IS_OK(nt_status) {
struct passwd *pass = Get_Pwnam(user_info->internal_username.str);
}
if (locally_made_cli) {
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
}
return(nt_status);
#define REGISTER 0
#endif
-struct cli_state *cli;
+struct smbcli_state *cli;
extern BOOL in_client;
static int port = 0;
pstring cur_dir = "\\";
#define USENMB
/* some forward declarations */
-static struct cli_state *do_connect(const char *server, const char *share);
+static struct smbcli_state *do_connect(const char *server, const char *share);
/*******************************************************************
int total_len = 0;
int grp_id;
- if (!cli_message_start(cli->tree, desthost, username, &grp_id)) {
- d_printf("message start: %s\n", cli_errstr(cli->tree));
+ if (!smbcli_message_start(cli->tree, desthost, username, &grp_id)) {
+ d_printf("message start: %s\n", smbcli_errstr(cli->tree));
return;
}
msg[l] = c;
}
- if (!cli_message_text(cli->tree, msg, l, grp_id)) {
- d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli->tree));
+ if (!smbcli_message_text(cli->tree, msg, l, grp_id)) {
+ d_printf("SMBsendtxt failed (%s)\n",smbcli_errstr(cli->tree));
return;
}
else
d_printf("sent %d bytes\n",total_len);
- if (!cli_message_end(cli->tree, grp_id)) {
- d_printf("SMBsendend failed (%s)\n",cli_errstr(cli->tree));
+ if (!smbcli_message_end(cli->tree, grp_id)) {
+ d_printf("SMBsendend failed (%s)\n",smbcli_errstr(cli->tree));
return;
}
}
{
int total, bsize, avail;
- if (NT_STATUS_IS_ERR(cli_dskattr(cli->tree, &bsize, &total, &avail))) {
- d_printf("Error in dskattr: %s\n",cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_dskattr(cli->tree, &bsize, &total, &avail))) {
+ d_printf("Error in dskattr: %s\n",smbcli_errstr(cli->tree));
return 1;
}
dos_clean_name(cur_dir);
if (!strequal(cur_dir,"\\")) {
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, dname))) {
- d_printf("cd %s: %s\n", dname, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, dname))) {
+ d_printf("cd %s: %s\n", dname, smbcli_errstr(cli->tree));
pstrcpy(cur_dir,saved_dir);
}
}
/****************************************************************************
-a wrapper around cli_list that adds recursion
+a wrapper around smbcli_list that adds recursion
****************************************************************************/
void do_list(const char *mask,uint16_t attribute,void (*fn)(file_info *),BOOL rec, BOOL dirs)
{
{
/*
* Need to copy head so that it doesn't become
- * invalid inside the call to cli_list. This
+ * invalid inside the call to smbcli_list. This
* would happen if the list were expanded
* during the call.
* Fix from E. Jay Berkenbilt (ejb@ql.org)
*/
pstring head;
pstrcpy(head, do_list_queue_head());
- cli_list(cli->tree, head, attribute, do_list_helper, NULL);
+ smbcli_list(cli->tree, head, attribute, do_list_helper, NULL);
remove_do_list_queue_head();
if ((! do_list_queue_empty()) && (fn == display_finfo))
{
}
else
{
- if (cli_list(cli->tree, mask, attribute, do_list_helper, NULL) == -1)
+ if (smbcli_list(cli->tree, mask, attribute, do_list_helper, NULL) == -1)
{
- d_printf("%s listing %s\n", cli_errstr(cli->tree), mask);
+ d_printf("%s listing %s\n", smbcli_errstr(cli->tree), mask);
}
}
strlower(lname);
}
- fnum = cli_open(cli->tree, rname, O_RDONLY, DENY_NONE);
+ fnum = smbcli_open(cli->tree, rname, O_RDONLY, DENY_NONE);
if (fnum == -1) {
- d_printf("%s opening remote file %s\n",cli_errstr(cli->tree),rname);
+ d_printf("%s opening remote file %s\n",smbcli_errstr(cli->tree),rname);
return 1;
}
}
- if (NT_STATUS_IS_ERR(cli_qfileinfo(cli->tree, fnum,
+ if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum,
&attr, &size, NULL, NULL, NULL, NULL, NULL)) &&
- NT_STATUS_IS_ERR(cli_getattrE(cli->tree, fnum,
+ NT_STATUS_IS_ERR(smbcli_getattrE(cli->tree, fnum,
&attr, &size, NULL, NULL, NULL))) {
- d_printf("getattrib: %s\n",cli_errstr(cli->tree));
+ d_printf("getattrib: %s\n",smbcli_errstr(cli->tree));
return 1;
}
if(!(data = (char *)malloc(read_size))) {
d_printf("malloc fail for size %d\n", read_size);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
return 1;
}
while (1) {
- int n = cli_read(cli->tree, fnum, data, nread + start, read_size);
+ int n = smbcli_read(cli->tree, fnum, data, nread + start, read_size);
if (n <= 0) break;
SAFE_FREE(data);
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
- d_printf("Error %s closing remote file\n",cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
+ d_printf("Error %s closing remote file\n",smbcli_errstr(cli->tree));
rc = 1;
}
}
if (archive_level >= 2 && (attr & FILE_ATTRIBUTE_ARCHIVE)) {
- cli_setatr(cli->tree, rname, attr & ~(uint16_t)FILE_ATTRIBUTE_ARCHIVE, 0);
+ smbcli_setatr(cli->tree, rname, attr & ~(uint16_t)FILE_ATTRIBUTE_ARCHIVE, 0);
}
{
{
NTSTATUS status;
- if (NT_STATUS_IS_ERR(status = cli_mkdir(cli->tree, name))) {
+ if (NT_STATUS_IS_ERR(status = smbcli_mkdir(cli->tree, name))) {
d_printf("%s making remote directory %s\n",
- cli_errstr(cli->tree),name);
+ smbcli_errstr(cli->tree),name);
return status;
}
static BOOL do_altname(char *name)
{
const char *altname;
- if (!NT_STATUS_IS_OK(cli_qpathinfo_alt_name(cli->tree, name, &altname))) {
+ if (!NT_STATUS_IS_OK(smbcli_qpathinfo_alt_name(cli->tree, name, &altname))) {
d_printf("%s getting alt name for %s\n",
- cli_errstr(cli->tree),name);
+ smbcli_errstr(cli->tree),name);
return(False);
}
d_printf("%s\n", altname);
****************************************************************************/
static int cmd_quit(void)
{
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
exit(0);
/* NOTREACHED */
return 0;
p = strtok(ddir,"/\\");
while (p) {
pstrcat(ddir2,p);
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, ddir2))) {
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, ddir2))) {
do_mkdir(ddir2);
}
pstrcat(ddir2,"\\");
GetTimeOfDay(&tp_start);
if (reput) {
- fnum = cli_open(cli->tree, rname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, rname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum >= 0) {
- if (NT_STATUS_IS_ERR(cli_qfileinfo(cli->tree, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL)) &&
- NT_STATUS_IS_ERR(cli_getattrE(cli->tree, fnum, NULL, &start, NULL, NULL, NULL))) {
- d_printf("getattrib: %s\n",cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL)) &&
+ NT_STATUS_IS_ERR(smbcli_getattrE(cli->tree, fnum, NULL, &start, NULL, NULL, NULL))) {
+ d_printf("getattrib: %s\n",smbcli_errstr(cli->tree));
return 1;
}
}
} else {
- fnum = cli_open(cli->tree, rname, O_RDWR|O_CREAT|O_TRUNC,
+ fnum = smbcli_open(cli->tree, rname, O_RDWR|O_CREAT|O_TRUNC,
DENY_NONE);
}
if (fnum == -1) {
- d_printf("%s opening remote file %s\n",cli_errstr(cli->tree),rname);
+ d_printf("%s opening remote file %s\n",smbcli_errstr(cli->tree),rname);
return 1;
}
break;
}
- ret = cli_write(cli->tree, fnum, 0, buf, nread + start, n);
+ ret = smbcli_write(cli->tree, fnum, 0, buf, nread + start, n);
if (n != ret) {
- d_printf("Error writing file: %s\n", cli_errstr(cli->tree));
+ d_printf("Error writing file: %s\n", smbcli_errstr(cli->tree));
rc = 1;
break;
}
nread += n;
}
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
- d_printf("%s closing remote file %s\n",cli_errstr(cli->tree),rname);
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
+ d_printf("%s closing remote file %s\n",smbcli_errstr(cli->tree),rname);
x_fclose(f);
SAFE_FREE(buf);
return 1;
}
if (f == x_stdin) {
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
exit(0);
}
SAFE_FREE(rname);
if(asprintf(&rname, "%s%s", cur_dir, lname) < 0) break;
dos_format(rname);
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, rname)) &&
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, rname)) &&
NT_STATUS_IS_ERR(do_mkdir(rname))) {
DEBUG (0, ("Unable to make dir, skipping..."));
/* Skip the directory */
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY)
return;
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, mask))) {
- d_printf("%s deleting remote file %s\n",cli_errstr(cli->tree),mask);
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, mask))) {
+ d_printf("%s deleting remote file %s\n",smbcli_errstr(cli->tree),mask);
}
}
}
pstrcat(dname,buf);
- ret = cli_deltree(cli->tree, dname);
+ ret = smbcli_deltree(cli->tree, dname);
if (ret == -1) {
- printf("Failed to delete tree %s - %s\n", dname, cli_errstr(cli->tree));
+ printf("Failed to delete tree %s - %s\n", dname, smbcli_errstr(cli->tree));
return -1;
}
}
pstrcat(fname,buf);
- fnum = cli_open(cli->tree, fname, O_RDONLY, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDONLY, DENY_NONE);
if (fnum == -1) {
- d_printf("%s - %s\n", fname, cli_errstr(cli->tree));
+ d_printf("%s - %s\n", fname, smbcli_errstr(cli->tree));
return -1;
}
}
pstrcat(mask,buf);
- cli_open(cli->tree, mask, O_RDWR, DENY_ALL);
+ smbcli_open(cli->tree, mask, O_RDWR, DENY_ALL);
return 0;
}
}
pstrcat(mask,buf);
- if (NT_STATUS_IS_ERR(cli_rmdir(cli->tree, mask))) {
+ if (NT_STATUS_IS_ERR(smbcli_rmdir(cli->tree, mask))) {
d_printf("%s removing remote directory file %s\n",
- cli_errstr(cli->tree),mask);
+ smbcli_errstr(cli->tree),mask);
}
return 0;
pstrcat(src,buf);
pstrcat(dest,buf2);
- if (NT_STATUS_IS_ERR(cli_unix_hardlink(cli->tree, src, dest))) {
- d_printf("%s linking files (%s -> %s)\n", cli_errstr(cli->tree), src, dest);
+ if (NT_STATUS_IS_ERR(smbcli_unix_hardlink(cli->tree, src, dest))) {
+ d_printf("%s linking files (%s -> %s)\n", smbcli_errstr(cli->tree), src, dest);
return 1;
}
pstrcat(src,buf);
pstrcat(dest,buf2);
- if (NT_STATUS_IS_ERR(cli_unix_symlink(cli->tree, src, dest))) {
+ if (NT_STATUS_IS_ERR(smbcli_unix_symlink(cli->tree, src, dest))) {
d_printf("%s symlinking files (%s -> %s)\n",
- cli_errstr(cli->tree), src, dest);
+ smbcli_errstr(cli->tree), src, dest);
return 1;
}
mode = (mode_t)strtol(buf, NULL, 8);
pstrcat(src,buf2);
- if (NT_STATUS_IS_ERR(cli_unix_chmod(cli->tree, src, mode))) {
+ if (NT_STATUS_IS_ERR(smbcli_unix_chmod(cli->tree, src, mode))) {
d_printf("%s chmod file %s 0%o\n",
- cli_errstr(cli->tree), src, (uint_t)mode);
+ smbcli_errstr(cli->tree), src, (uint_t)mode);
return 1;
}
gid = (gid_t)atoi(buf2);
pstrcat(src,buf3);
- if (NT_STATUS_IS_ERR(cli_unix_chown(cli->tree, src, uid, gid))) {
+ if (NT_STATUS_IS_ERR(smbcli_unix_chown(cli->tree, src, uid, gid))) {
d_printf("%s chown file %s uid=%d, gid=%d\n",
- cli_errstr(cli->tree), src, (int)uid, (int)gid);
+ smbcli_errstr(cli->tree), src, (int)uid, (int)gid);
return 1;
}
pstrcat(src,buf);
pstrcat(dest,buf2);
- if (NT_STATUS_IS_ERR(cli_rename(cli->tree, src, dest))) {
- d_printf("%s renaming files\n",cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_rename(cli->tree, src, dest))) {
+ d_printf("%s renaming files\n",smbcli_errstr(cli->tree));
return 1;
}
} else
snprintf(dirmask, sizeof(dirmask), "%s*", cur_dir);
- if (cli_list(cli->tree, dirmask,
+ if (smbcli_list(cli->tree, dirmask,
FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
completion_remote_filter, &info) < 0)
goto cleanup;
last_t = t;
- cli_transport_process(cli->transport);
+ smbcli_transport_process(cli->transport);
if (cli->tree) {
- cli_chkpath(cli->tree, "\\");
+ smbcli_chkpath(cli->tree, "\\");
}
}
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *do_connect(const char *server, const char *share)
+static struct smbcli_state *do_connect(const char *server, const char *share)
{
- struct cli_state *c;
+ struct smbcli_state *c;
struct nmb_name called, calling;
const char *server_n;
struct in_addr ip;
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_state_init()) || !cli_socket_connect(c, server_n, &ip)) {
+ if (!(c=smbcli_state_init()) || !smbcli_socket_connect(c, server_n, &ip)) {
d_printf("Connection to %s failed\n", server_n);
return NULL;
}
- if (!cli_transport_establish(c, &calling, &called)) {
+ if (!smbcli_transport_establish(c, &calling, &called)) {
char *p;
d_printf("session request to %s failed (%s)\n",
- called.name, cli_errstr(c->tree));
- cli_shutdown(c);
+ called.name, smbcli_errstr(c->tree));
+ smbcli_shutdown(c);
if ((p=strchr_m(called.name, '.'))) {
*p = 0;
goto again;
DEBUG(4,(" session request ok\n"));
- if (NT_STATUS_IS_ERR(cli_negprot(c))) {
+ if (NT_STATUS_IS_ERR(smbcli_negprot(c))) {
d_printf("protocol negotiation failed\n");
- cli_shutdown(c);
+ smbcli_shutdown(c);
return NULL;
}
}
}
- status = cli_session_setup(c, username, password, lp_workgroup());
+ status = smbcli_session_setup(c, username, password, lp_workgroup());
if (NT_STATUS_IS_ERR(status)) {
d_printf("authenticated session setup failed: %s\n", nt_errstr(status));
/* if a password was not supplied then try again with a null username */
if (password[0] || !username[0] || use_kerberos) {
- status = cli_session_setup(c, "", "", lp_workgroup());
+ status = smbcli_session_setup(c, "", "", lp_workgroup());
}
if (NT_STATUS_IS_ERR(status)) {
d_printf("session setup failed: %s\n", nt_errstr(status));
- cli_shutdown(c);
+ smbcli_shutdown(c);
return NULL;
}
d_printf("Anonymous login successful\n");
DEBUG(4,(" session setup ok\n"));
- if (NT_STATUS_IS_ERR(cli_send_tconX(c, sharename, "?????", password))) {
- d_printf("tree connect failed: %s\n", cli_errstr(c->tree));
- cli_shutdown(c);
+ if (NT_STATUS_IS_ERR(smbcli_send_tconX(c, sharename, "?????", password))) {
+ d_printf("tree connect failed: %s\n", smbcli_errstr(c->tree));
+ smbcli_shutdown(c);
return NULL;
}
process_stdin();
}
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return rc;
}
ret=process_tar();
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return(ret);
}
zero_ip(&ip);
if (have_ip) ip = dest_ip;
- if (!(cli=cli_state_init()) || !cli_socket_connect(cli, server_name, &ip)) {
+ if (!(cli=smbcli_state_init()) || !smbcli_socket_connect(cli, server_name, &ip)) {
d_printf("Connection to %s failed\n", desthost);
return 1;
}
- if (!cli_transport_establish(cli, &calling, &called)) {
+ if (!smbcli_transport_establish(cli, &calling, &called)) {
d_printf("session request failed\n");
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return 1;
}
send_message();
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return 0;
}
} stack;
#define SEPARATORS " \t\n\r"
-extern struct cli_state *cli;
+extern struct smbcli_state *cli;
/* These defines are for the do_setrattr routine, to indicate
* setting and reseting of file attributes in the function call */
{
safe_strcat(partpath, p, strlen(fname) + 1);
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, partpath))) {
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, partpath)))
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, partpath))) {
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, partpath)))
{
DEBUG(0, ("Error mkdirhiering\n"));
return False;
{
uint16_t oldattr;
- if (NT_STATUS_IS_ERR(cli_getatr(cli->tree, name, &oldattr, NULL, NULL)))
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, name, &oldattr, NULL, NULL)))
return;
if (set == ATTRSET) {
attr = oldattr & ~attr;
}
- if (NT_STATUS_IS_ERR(cli_setatr(cli->tree, name, attr, 0))) {
- DEBUG(1,("setatr failed: %s\n", cli_errstr(cli->tree)));
+ if (NT_STATUS_IS_ERR(smbcli_setatr(cli->tree, name, attr, 0))) {
+ DEBUG(1,("setatr failed: %s\n", smbcli_errstr(cli->tree)));
}
}
return;
}
- fnum = cli_open(cli->tree, rname, O_RDONLY, DENY_NONE);
+ fnum = smbcli_open(cli->tree, rname, O_RDONLY, DENY_NONE);
dos_clean_name(rname);
if (fnum == -1) {
DEBUG(0,("%s opening remote file %s (%s)\n",
- cli_errstr(cli->tree),rname, cur_dir));
+ smbcli_errstr(cli->tree),rname, cur_dir));
return;
}
safe_strcpy(finfo.name,rname, strlen(rname));
if (!finfo1) {
size_t size;
- if (NT_STATUS_IS_ERR(cli_getattrE(cli->tree, fnum, &finfo.mode, &size, NULL, &finfo.atime, &finfo.mtime))) {
- DEBUG(0, ("getattrE: %s\n", cli_errstr(cli->tree)));
+ if (NT_STATUS_IS_ERR(smbcli_getattrE(cli->tree, fnum, &finfo.mode, &size, NULL, &finfo.atime, &finfo.mtime))) {
+ DEBUG(0, ("getattrE: %s\n", smbcli_errstr(cli->tree)));
return;
}
finfo.size = size;
DEBUG(3,("nread=%.0f\n",(double)nread));
- datalen = cli_read(cli->tree, fnum, data, nread, read_size);
+ datalen = smbcli_read(cli->tree, fnum, data, nread, read_size);
if (datalen == -1) {
- DEBUG(0,("Error reading file %s : %s\n", rname, cli_errstr(cli->tree)));
+ DEBUG(0,("Error reading file %s : %s\n", rname, smbcli_errstr(cli->tree)));
break;
}
ntarf++;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
if (shallitime)
{
DEBUG(5, ("get_file: file: %s, size %i\n", finfo.name, (int)finfo.size));
if (ensurepath(finfo.name) &&
- (fnum=cli_open(cli->tree, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
+ (fnum=smbcli_open(cli->tree, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
DEBUG(0, ("abandoning restore\n"));
return(False);
}
dsize = MIN(dsize, rsize); /* Should be only what is left */
DEBUG(5, ("writing %i bytes, bpos = %i ...\n", dsize, bpos));
- if (cli_write(cli->tree, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) {
+ if (smbcli_write(cli->tree, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) {
DEBUG(0, ("Error writing remote file\n"));
return 0;
}
/* Now close the file ... */
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
DEBUG(0, ("Error closing remote file\n"));
return(False);
}
DEBUG(5, ("Updating creation date on %s\n", finfo.name));
- if (NT_STATUS_IS_ERR(cli_setatr(cli->tree, finfo.name, finfo.mode, finfo.mtime))) {
+ if (NT_STATUS_IS_ERR(smbcli_setatr(cli->tree, finfo.name, finfo.mode, finfo.mtime))) {
if (tar_real_noisy) {
DEBUG(0, ("Could not set time on file: %s\n", finfo.name));
/*return(False); */ /* Ignore, as Win95 does not allow changes */
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *do_connection(char *the_service)
+static struct smbcli_state *do_connection(char *the_service)
{
- struct cli_state *c;
+ struct smbcli_state *c;
struct nmb_name called, calling;
char *server_n;
struct in_addr ip;
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != smb_port) ||
- !cli_connect(c, server_n, &ip)) {
+ if (!(c=smbcli_initialise(NULL)) || (smbcli_set_port(c, smb_port) != smb_port) ||
+ !smbcli_connect(c, server_n, &ip)) {
DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n));
if (c) {
- cli_shutdown(c);
+ smbcli_shutdown(c);
}
return NULL;
}
/* Use kerberos authentication if specified */
c->use_kerberos = use_kerberos;
- if (!cli_session_request(c, &calling, &called)) {
+ if (!smbcli_session_request(c, &calling, &called)) {
char *p;
DEBUG(0,("%d: session request to %s failed (%s)\n",
- sys_getpid(), called.name, cli_errstr(c)));
- cli_shutdown(c);
+ sys_getpid(), called.name, smbcli_errstr(c)));
+ smbcli_shutdown(c);
if ((p=strchr_m(called.name, '.'))) {
*p = 0;
goto again;
DEBUG(4,("%d: session request ok\n", sys_getpid()));
- if (!cli_negprot(c)) {
+ if (!smbcli_negprot(c)) {
DEBUG(0,("%d: protocol negotiation failed\n", sys_getpid()));
- cli_shutdown(c);
+ smbcli_shutdown(c);
return NULL;
}
c->force_dos_errors = True;
}
- if (!cli_session_setup(c, username,
+ if (!smbcli_session_setup(c, username,
password, strlen(password),
password, strlen(password),
workgroup)) {
/* if a password was not supplied then try again with a
null username */
if (password[0] || !username[0] ||
- !cli_session_setup(c, "", "", 0, "", 0, workgroup)) {
+ !smbcli_session_setup(c, "", "", 0, "", 0, workgroup)) {
DEBUG(0,("%d: session setup failed: %s\n",
- sys_getpid(), cli_errstr(c)));
- cli_shutdown(c);
+ sys_getpid(), smbcli_errstr(c)));
+ smbcli_shutdown(c);
return NULL;
}
DEBUG(0,("Anonymous login successful\n"));
DEBUG(4,("%d: session setup ok\n", sys_getpid()));
- if (!cli_send_tconX(c, share, "?????",
+ if (!smbcli_send_tconX(c, share, "?????",
password, strlen(password)+1)) {
DEBUG(0,("%d: tree connect failed: %s\n",
- sys_getpid(), cli_errstr(c)));
- cli_shutdown(c);
+ sys_getpid(), smbcli_errstr(c)));
+ smbcli_shutdown(c);
return NULL;
}
* not exit after open_sockets() or send_login() errors,
* as the smbfs mount would then have no way to recover.
*/
-static void send_fs_socket(char *the_service, char *mount_point, struct cli_state *c)
+static void send_fs_socket(char *the_service, char *mount_point, struct smbcli_state *c)
{
int fd, closed = 0, res = 1;
pid_t parentpid = getppid();
If we don't do this we will "leak" sockets and memory on
each reconnection we have to make. */
- cli_shutdown(c);
+ smbcli_shutdown(c);
c = NULL;
if (!closed) {
char mount_point[MAXPATHLEN+1];
pstring tmp;
pstring svc2;
- struct cli_state *c;
+ struct smbcli_state *c;
char *args[20];
int i, status;
*/
static void list_devices(void);
-static struct cli_state *smb_connect(const char *, const char *, const char *, const char *, const char *);
-static int smb_print(struct cli_state *, char *, FILE *);
+static struct smbcli_state *smb_connect(const char *, const char *, const char *, const char *, const char *);
+static int smb_print(struct smbcli_state *, char *, FILE *);
/*
const char *workgroup; /* Workgroup */
FILE *fp; /* File to print */
int status=0; /* Status of LPD job */
- struct cli_state *cli; /* SMB interface */
+ struct smbcli_state *cli; /* SMB interface */
/* we expect the URI in argv[0]. Detect the case where it is in argv[1] and cope */
if (argc > 2 && strncmp(argv[0],"smb://", 6) && !strncmp(argv[1],"smb://", 6)) {
if ((status = smb_print(cli, argv[3] /* title */, fp)) != 0)
break;
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
/*
* Return the queue status...
* 'smb_connect()' - Return a connection to a server.
*/
-static struct cli_state * /* O - SMB connection */
+static struct smbcli_state * /* O - SMB connection */
smb_connect(const char *workgroup, /* I - Workgroup */
const char *server, /* I - Server */
const char *share, /* I - Printer */
const char *username, /* I - Username */
const char *password) /* I - Password */
{
- struct cli_state *c; /* New connection */
+ struct smbcli_state *c; /* New connection */
char *myname; /* Client name */
NTSTATUS nt_status;
myname = get_myname();
- nt_status = cli_full_connection(&c, myname, server, NULL, 0, share, "?????",
+ nt_status = smbcli_full_connection(&c, myname, server, NULL, 0, share, "?????",
username, workgroup, password, 0, NULL);
free(myname);
*/
static int /* O - 0 = success, non-0 = failure */
-smb_print(struct cli_state *cli, /* I - SMB connection */
+smb_print(struct smbcli_state *cli, /* I - SMB connection */
char *title, /* I - Title/job name */
FILE *fp) /* I - File to print */
{
* Open the printer device...
*/
- if ((fnum = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE)) == -1)
+ if ((fnum = smbcli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE)) == -1)
{
fprintf(stderr, "ERROR: %s opening remote file %s\n",
- cli_errstr(cli), title);
+ smbcli_errstr(cli), title);
return (1);
}
while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0)
{
- if (cli_write(cli, fnum, 0, buffer, tbytes, nbytes) != nbytes)
+ if (smbcli_write(cli, fnum, 0, buffer, tbytes, nbytes) != nbytes)
{
- fprintf(stderr, "ERROR: Error writing file: %s\n", cli_errstr(cli));
+ fprintf(stderr, "ERROR: Error writing file: %s\n", smbcli_errstr(cli));
break;
}
tbytes += nbytes;
}
- if (!cli_close(cli, fnum))
+ if (!smbcli_close(cli, fnum))
{
fprintf(stderr, "ERROR: %s closing remote file %s\n",
- cli_errstr(cli), title);
+ smbcli_errstr(cli), title);
return (1);
}
else
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef _CLI_CONTEXT_H
-#define _CLI_CONTEXT_H
+#ifndef _SMBCLI_CONTEXT_H
+#define _SMBCLI_CONTEXT_H
-struct cli_tree; /* forward declare */
-struct cli_request; /* forward declare */
-struct cli_session; /* forward declare */
-struct cli_transport; /* forward declare */
+struct smbcli_tree; /* forward declare */
+struct smbcli_request; /* forward declare */
+struct smbcli_session; /* forward declare */
+struct smbcli_transport; /* forward declare */
/* context that will be and has been negotiated between the client and server */
-struct cli_negotiate {
+struct smbcli_negotiate {
/*
* negotiated maximum transmit size - this is given to us by the server
*/
uint32_t sesskey;
struct {
- void (*sign_outgoing_message)(struct cli_request *req);
- BOOL (*check_incoming_message)(struct cli_request *req);
- void (*free_signing_context)(struct cli_transport *transport);
+ void (*sign_outgoing_message)(struct smbcli_request *req);
+ BOOL (*check_incoming_message)(struct smbcli_request *req);
+ void (*free_signing_context)(struct smbcli_transport *transport);
void *signing_context;
BOOL negotiated_smb_signing;
BOOL allow_smb_signing;
};
/* this is the context for a SMB socket associated with the socket itself */
-struct cli_socket {
+struct smbcli_socket {
TALLOC_CTX *mem_ctx; /* life of socket pool */
/* when the reference count reaches zero then the socket is destroyed */
this structure allows applications to control the behaviour of the
client library
*/
-struct cli_options {
+struct smbcli_options {
uint_t use_oplocks:1;
uint_t use_level2_oplocks:1;
uint_t use_spnego:1;
};
/* this is the context for the client transport layer */
-struct cli_transport {
+struct smbcli_transport {
TALLOC_CTX *mem_ctx;
/* when the reference count reaches zero then the transport is destroyed */
int reference_count;
/* socket level info */
- struct cli_socket *socket;
+ struct smbcli_socket *socket;
/* the next mid to be allocated - needed for signing and
request matching */
uint16_t next_mid;
/* negotiated protocol information */
- struct cli_negotiate negotiate;
+ struct smbcli_negotiate negotiate;
/* options to control the behaviour of the client code */
- struct cli_options options;
+ struct smbcli_options options;
/* is a readbraw pending? we need to handle that case
specially on receiving packets */
called once every period seconds while we are waiting
for a packet */
struct {
- void (*func)(struct cli_transport *, void *);
+ void (*func)(struct smbcli_transport *, void *);
void *private;
uint_t period;
} idle;
struct {
/* a oplock break request handler */
- BOOL (*handler)(struct cli_transport *transport,
+ BOOL (*handler)(struct smbcli_transport *transport,
uint16_t tid, uint16_t fnum, uint8_t level, void *private);
/* private data passed to the oplock handler */
void *private;
} oplock;
/* a list of async requests that are pending for send on this connection */
- struct cli_request *pending_send;
+ struct smbcli_request *pending_send;
/* a list of async requests that are pending for receive on this connection */
- struct cli_request *pending_recv;
+ struct smbcli_request *pending_recv;
/* remember the called name - some sub-protocols require us to
know the server name */
/* this is the context for the user */
/* this is the context for the session layer */
-struct cli_session {
+struct smbcli_session {
TALLOC_CTX *mem_ctx; /* life of session */
/* when the reference count reaches zero then the session is destroyed */
int reference_count;
/* transport layer info */
- struct cli_transport *transport;
+ struct smbcli_transport *transport;
/* after a session setup the server provides us with
a vuid identifying the security context */
};
/*
- cli_tree context: internal state for a tree connection.
+ smbcli_tree context: internal state for a tree connection.
*/
-struct cli_tree {
+struct smbcli_tree {
/* life of tree tree */
TALLOC_CTX *mem_ctx;
int reference_count;
/* session layer info */
- struct cli_session *session;
+ struct smbcli_session *session;
uint16_t tid; /* tree id, aka cnum */
char *device;
/*
a client request moves between the following 4 states.
*/
-enum cli_request_state {CLI_REQUEST_INIT, /* we are creating the request */
- CLI_REQUEST_SEND, /* the request is in the outgoing socket Q */
- CLI_REQUEST_RECV, /* we are waiting for a matching reply */
- CLI_REQUEST_DONE, /* the request is finished */
- CLI_REQUEST_ERROR}; /* a packet or transport level error has occurred */
+enum smbcli_request_state {SMBCLI_REQUEST_INIT, /* we are creating the request */
+ SMBCLI_REQUEST_SEND, /* the request is in the outgoing socket Q */
+ SMBCLI_REQUEST_RECV, /* we are waiting for a matching reply */
+ SMBCLI_REQUEST_DONE, /* the request is finished */
+ SMBCLI_REQUEST_ERROR}; /* a packet or transport level error has occurred */
/* the context for a single SMB request. This is passed to any request-context
* functions (similar to context.h, the server version).
* This will allow requests to be multi-threaded. */
-struct cli_request {
+struct smbcli_request {
/* allow a request to be part of a list of requests */
- struct cli_request *next, *prev;
+ struct smbcli_request *next, *prev;
/* a talloc context for the lifetime of this request */
TALLOC_CTX *mem_ctx;
/* each request is in one of 4 possible states */
- enum cli_request_state state;
+ enum smbcli_request_state state;
/* a request always has a transport context, nearly always has
a session context and usually has a tree context */
- struct cli_transport *transport;
- struct cli_session *session;
- struct cli_tree *tree;
+ struct smbcli_transport *transport;
+ struct smbcli_session *session;
+ struct smbcli_tree *tree;
/* the flags2 from the SMB request, in raw form (host byte
order). Used to parse strings */
library (the application), not private to the library
*/
struct {
- void (*fn)(struct cli_request *);
+ void (*fn)(struct smbcli_request *);
void *private;
} async;
};
/*
- cli_state: internal state used in libcli library for single-threaded callers,
+ smbcli_state: internal state used in libcli library for single-threaded callers,
i.e. a single session on a single socket.
*/
-struct cli_state {
+struct smbcli_state {
TALLOC_CTX *mem_ctx; /* life of client pool */
- struct cli_transport *transport;
- struct cli_session *session;
- struct cli_tree *tree;
+ struct smbcli_transport *transport;
+ struct smbcli_session *session;
+ struct smbcli_tree *tree;
struct substitute_context substitute;
};
/* useful way of catching wct errors with file and line number */
-#define CLI_CHECK_MIN_WCT(req, wcount) if ((req)->in.wct < (wcount)) { \
+#define SMBCLI_CHECK_MIN_WCT(req, wcount) if ((req)->in.wct < (wcount)) { \
DEBUG(1,("Unexpected WCT %d at %s(%d) - expected min %d\n", (req)->in.wct, __FILE__, __LINE__, wcount)); \
req->status = NT_STATUS_INVALID_PARAMETER; \
goto failed; \
}
-#define CLI_CHECK_WCT(req, wcount) if ((req)->in.wct != (wcount)) { \
+#define SMBCLI_CHECK_WCT(req, wcount) if ((req)->in.wct != (wcount)) { \
DEBUG(1,("Unexpected WCT %d at %s(%d) - expected %d\n", (req)->in.wct, __FILE__, __LINE__, wcount)); \
req->status = NT_STATUS_INVALID_PARAMETER; \
goto failed; \
}
-#endif /* _CLI_CONTEXT_H */
+#endif /* _SMBCLI_CONTEXT_H */
overlap on the wire. This size gives us a nice read/write size, which
will be a multiple of the page size on almost any system */
#define CLI_BUFFER_SIZE (0xFFFF)
-#define CLI_DFS_MAX_REFERRAL_LEVEL 3
+#define SMBCLI_DFS_MAX_REFERRAL_LEVEL 3
#define SAFETY_MARGIN 1024
#define LARGE_WRITEX_HDR_SIZE 65
referral_info referrals[10];
} dfs_info;
-/* Internal client error codes for cli_request_context.internal_error_code */
-#define CLI_ERR_INVALID_TRANS_RESPONSE 100
+/* Internal client error codes for smbcli_request_context.internal_error_code */
+#define SMBCLI_ERR_INVALID_TRANS_RESPONSE 100
#define DFS_MAX_CLUSTER_SIZE 8
/* client_context: used by cliraw callers to maintain Dfs
int connection_flags; /* see CLI_FULL_CONN.. below */
uint16_t max_xmit_frag;
uint16_t max_recv_frag;
- struct cli_state *cli[DFS_MAX_CLUSTER_SIZE];
+ struct smbcli_state *cli[DFS_MAX_CLUSTER_SIZE];
};
-#define CLI_FULL_CONNECTION_DONT_SPNEGO 0x0001
-#define CLI_FULL_CONNECTION_USE_KERBEROS 0x0002
-#define CLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK 0x0004
-#define CLI_FULL_CONNECTION_USE_DFS 0x0008
+#define SMBCLI_FULL_CONNECTION_DONT_SPNEGO 0x0001
+#define SMBCLI_FULL_CONNECTION_USE_KERBEROS 0x0002
+#define SMBCLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK 0x0004
+#define SMBCLI_FULL_CONNECTION_USE_DFS 0x0008
#endif /* _CLIENT_H */
}
-WERROR get_remote_printer_publishing_data(struct cli_state *cli,
+WERROR get_remote_printer_publishing_data(struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
ADS_MODLIST *mods,
const char *printer)
return WERR_NOMEM;
}
- result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername,
+ result = smbcli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
servername, cli->user_name, &pol);
if (!W_ERROR_IS_OK(result)) {
return result;
}
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed,
+ result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed,
&pol, SPOOL_DSDRIVER_KEY, NULL);
if (W_ERROR_V(result) == ERRmoredata)
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, needed,
+ result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, needed,
NULL, &pol,
SPOOL_DSDRIVER_KEY,
&dsdriver_ctr);
dsdriver_ctr.values[i]);
}
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed,
+ result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed,
&pol, SPOOL_DSSPOOLER_KEY,
NULL);
if (W_ERROR_V(result) == ERRmoredata)
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, needed,
+ result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, needed,
NULL, &pol,
SPOOL_DSSPOOLER_KEY,
&dsspooler_ctr);
if (got_dsdriver) regval_ctr_destroy(&dsdriver_ctr);
if (got_dsspooler) regval_ctr_destroy(&dsspooler_ctr);
- cli_spoolss_close_printer(cli, mem_ctx, &pol);
+ smbcli_spoolss_close_printer(cli, mem_ctx, &pol);
return result;
}
#include "includes.h"
/*
- wrapper around cli_sock_connect()
+ wrapper around smbcli_sock_connect()
*/
-BOOL cli_socket_connect(struct cli_state *cli, const char *server, struct in_addr *ip)
+BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server, struct in_addr *ip)
{
- struct cli_socket *sock;
+ struct smbcli_socket *sock;
- sock = cli_sock_init();
+ sock = smbcli_sock_init();
if (!sock) return False;
- if (!cli_sock_connect_byname(sock, server, 0)) {
- cli_sock_close(sock);
+ if (!smbcli_sock_connect_byname(sock, server, 0)) {
+ smbcli_sock_close(sock);
return False;
}
- cli->transport = cli_transport_init(sock);
+ cli->transport = smbcli_transport_init(sock);
if (!cli->transport) {
- cli_sock_close(sock);
+ smbcli_sock_close(sock);
return False;
}
return True;
}
-/* wrapper around cli_transport_connect() */
-BOOL cli_transport_establish(struct cli_state *cli,
+/* wrapper around smbcli_transport_connect() */
+BOOL smbcli_transport_establish(struct smbcli_state *cli,
struct nmb_name *calling,
struct nmb_name *called)
{
- return cli_transport_connect(cli->transport, calling, called);
+ return smbcli_transport_connect(cli->transport, calling, called);
}
/* wrapper around smb_raw_negotiate() */
-NTSTATUS cli_negprot(struct cli_state *cli)
+NTSTATUS smbcli_negprot(struct smbcli_state *cli)
{
return smb_raw_negotiate(cli->transport);
}
/* wrapper around smb_raw_session_setup() */
-NTSTATUS cli_session_setup(struct cli_state *cli,
+NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
const char *user,
const char *password,
const char *domain)
NTSTATUS status;
TALLOC_CTX *mem_ctx;
- cli->session = cli_session_init(cli->transport);
+ cli->session = smbcli_session_init(cli->transport);
if (!cli->session) return NT_STATUS_UNSUCCESSFUL;
- mem_ctx = talloc_init("cli_session_setup");
+ mem_ctx = talloc_init("smbcli_session_setup");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
setup.generic.level = RAW_SESSSETUP_GENERIC;
}
/* wrapper around smb_tree_connect() */
-NTSTATUS cli_send_tconX(struct cli_state *cli, const char *sharename,
+NTSTATUS smbcli_send_tconX(struct smbcli_state *cli, const char *sharename,
const char *devtype, const char *password)
{
union smb_tcon tcon;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- cli->tree = cli_tree_init(cli->session);
+ cli->tree = smbcli_tree_init(cli->session);
if (!cli->tree) return NT_STATUS_UNSUCCESSFUL;
cli->tree->reference_count++;
/*
- easy way to get to a fully connected cli_state in one call
+ easy way to get to a fully connected smbcli_state in one call
*/
-NTSTATUS cli_full_connection(struct cli_state **ret_cli,
+NTSTATUS smbcli_full_connection(struct smbcli_state **ret_cli,
const char *myname,
const char *host,
struct in_addr *ip,
uint_t flags,
BOOL *retry)
{
- struct cli_tree *tree;
+ struct smbcli_tree *tree;
NTSTATUS status;
char *p;
TALLOC_CTX *mem_ctx;
- mem_ctx = talloc_init("cli_full_connection");
+ mem_ctx = talloc_init("smbcli_full_connection");
*ret_cli = NULL;
username = talloc_strdup(mem_ctx, p+1);
}
- status = cli_tree_full_connection(&tree, myname, host, 0, sharename, devtype,
+ status = smbcli_tree_full_connection(&tree, myname, host, 0, sharename, devtype,
username, domain, password);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- (*ret_cli) = cli_state_init();
+ (*ret_cli) = smbcli_state_init();
(*ret_cli)->tree = tree;
(*ret_cli)->session = tree->session;
/*
disconnect the tree
*/
-NTSTATUS cli_tdis(struct cli_state *cli)
+NTSTATUS smbcli_tdis(struct smbcli_state *cli)
{
return smb_tree_disconnect(cli->tree);
}
/****************************************************************************
Initialise a client state structure.
****************************************************************************/
-struct cli_state *cli_state_init(void)
+struct smbcli_state *smbcli_state_init(void)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
- mem_ctx = talloc_init("cli_state");
+ mem_ctx = talloc_init("smbcli_state");
if (!mem_ctx) return NULL;
cli = talloc_zero(mem_ctx, sizeof(*cli));
/****************************************************************************
Shutdown a client structure.
****************************************************************************/
-void cli_shutdown(struct cli_state *cli)
+void smbcli_shutdown(struct smbcli_state *cli)
{
if (!cli) return;
if (cli->tree) {
cli->tree->reference_count++;
- cli_tree_close(cli->tree);
+ smbcli_tree_close(cli->tree);
}
if (cli->mem_ctx) {
talloc_destroy(cli->mem_ctx);
#include "includes.h"
struct delete_state {
- struct cli_tree *tree;
+ struct smbcli_tree *tree;
int total_deleted;
BOOL failed;
};
asprintf(&s, "%s%s", n, finfo->name);
if (finfo->mode & FILE_ATTRIBUTE_READONLY) {
- if (NT_STATUS_IS_ERR(cli_setatr(dstate->tree, s, 0, 0))) {
+ if (NT_STATUS_IS_ERR(smbcli_setatr(dstate->tree, s, 0, 0))) {
DEBUG(2,("Failed to remove READONLY on %s - %s\n",
- s, cli_errstr(dstate->tree)));
+ s, smbcli_errstr(dstate->tree)));
}
}
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
char *s2;
asprintf(&s2, "%s\\*", s);
- cli_unlink(dstate->tree, s2);
- cli_list(dstate->tree, s2,
+ smbcli_unlink(dstate->tree, s2);
+ smbcli_list(dstate->tree, s2,
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
delete_fn, state);
free(s2);
- if (NT_STATUS_IS_ERR(cli_rmdir(dstate->tree, s))) {
+ if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate->tree, s))) {
DEBUG(2,("Failed to delete %s - %s\n",
- s, cli_errstr(dstate->tree)));
+ s, smbcli_errstr(dstate->tree)));
dstate->failed = True;
}
dstate->total_deleted++;
} else {
- if (NT_STATUS_IS_ERR(cli_unlink(dstate->tree, s))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlink(dstate->tree, s))) {
DEBUG(2,("Failed to delete %s - %s\n",
- s, cli_errstr(dstate->tree)));
+ s, smbcli_errstr(dstate->tree)));
dstate->failed = True;
}
dstate->total_deleted++;
recursively descend a tree deleting all files
returns the number of files deleted, or -1 on error
*/
-int cli_deltree(struct cli_tree *tree, const char *dname)
+int smbcli_deltree(struct smbcli_tree *tree, const char *dname)
{
char *mask;
struct delete_state dstate;
dstate.failed = False;
/* it might be a file */
- if (NT_STATUS_IS_OK(cli_unlink(tree, dname))) {
+ if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) {
return 1;
}
- 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)) {
+ if (NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
+ NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
+ NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_NO_SUCH_FILE)) {
return 0;
}
asprintf(&mask, "%s\\*", dname);
- cli_unlink(dstate.tree, mask);
- cli_list(dstate.tree, mask,
+ smbcli_unlink(dstate.tree, mask);
+ smbcli_list(dstate.tree, mask,
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
delete_fn, &dstate);
free(mask);
- if (NT_STATUS_IS_ERR(cli_rmdir(dstate.tree, dname))) {
+ if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate.tree, dname))) {
DEBUG(2,("Failed to delete %s - %s\n",
- dname, cli_errstr(dstate.tree)));
+ dname, smbcli_errstr(dstate.tree)));
return -1;
}
dstate.total_deleted++;
#include "includes.h"
-BOOL cli_client_initialize(struct cli_client* context,
+BOOL smbcli_client_initialize(struct smbcli_client* context,
const char* sockops,
char* username, char* password, char* workgroup,
int flags)
{
int i;
for (i=0; i < DFS_MAX_CLUSTER_SIZE ; i++) {
- context->cli[i] = cli_raw_initialise();
+ context->cli[i] = smbcli_raw_initialise();
}
context->sockops = sockops;
context->username = username;
context->password = password;
context->workgroup = workgroup;
context->connection_flags = flags;
- if (flags & CLI_FULL_CONNECTION_USE_DFS)
+ if (flags & SMBCLI_FULL_CONNECTION_USE_DFS)
context->use_dfs = True;
context->number_members = DFS_MAX_CLUSTER_SIZE;
return True;
The structure of a Dfs referral depends on the info level.
****************************************************************************/
-static int interpret_referral(struct cli_state *cli,
+static int interpret_referral(struct smbcli_state *cli,
int level,char *p,referral_info *rinfo)
{
char* q;
}
#if 0
-int cli_select_dfs_referral(struct cli_state *cli, dfs_info* dinfo)
+int smbcli_select_dfs_referral(struct smbcli_state *cli, dfs_info* dinfo)
{
return (int)sys_random()%dinfo->number_referrals;
}
-int cli_get_dfs_referral(struct cli_state *cli,const char *Fname, dfs_info* dinfo)
+int smbcli_get_dfs_referral(struct smbcli_state *cli,const char *Fname, dfs_info* dinfo)
{
struct smb_trans2 parms;
int info_level;
pstrcpy(fname,Fname);
setup = TRANSACT2_GET_DFS_REFERRAL ;
- SSVAL(param,0,CLI_DFS_MAX_REFERRAL_LEVEL); /* attribute */
+ SSVAL(param,0,SMBCLI_DFS_MAX_REFERRAL_LEVEL); /* attribute */
p = param+2;
p += clistr_push(cli, param+2, fname, -1,
STR_TERMINATE);
param_len = PTR_DIFF(p, param);
- DEBUG(3,("cli_get_dfs_referral: sending request\n"));
+ DEBUG(3,("smbcli_get_dfs_referral: sending request\n"));
trans_param.length = param_len;
trans_param.data = param;
trans_data.length = 0;
trans_data.data = NULL;
- if (!cli_send_trans(cli, SMBtrans2,
+ if (!smbcli_send_trans(cli, SMBtrans2,
NULL, /* Name */
-1, 0, /* fid, flags */
&setup, 1, 0, /* setup, length, max */
return 0;
}
- if (!cli_receive_trans(cli, SMBtrans2,
+ if (!smbcli_receive_trans(cli, SMBtrans2,
&rparam, ¶m_len,
&rdata, &data_len) &&
- cli_is_dos_error(cli)) {
+ smbcli_is_dos_error(cli)) {
return 0;
}
- //printf("cli_get_dfs_referral: received response, rdata=%p, rparam=%p\n",
+ //printf("smbcli_get_dfs_referral: received response, rdata=%p, rparam=%p\n",
// rdata, rparam);
- if (cli_is_error(cli) || !rdata)
+ if (smbcli_is_error(cli) || !rdata)
return 0;
/* parse out some important return info */
- //printf("cli_get_dfs_referral: valid response\n");
+ //printf("smbcli_get_dfs_referral: valid response\n");
p = rdata;
dinfo->path_consumed = SVAL(p,0);
dinfo->number_referrals = SVAL(p,2);
dinfo->referral_flags = SVAL(p,4);
- DEBUG(3,("cli_get_dfs_referral: path_consumed=%d, # referrals=%d, flags=0x%x\n",
+ DEBUG(3,("smbcli_get_dfs_referral: path_consumed=%d, # referrals=%d, flags=0x%x\n",
dinfo->path_consumed, dinfo->number_referrals,
dinfo->referral_flags));
DEBUG(3,("received %d Dfs referrals\n",
dinfo->number_referrals));
- dinfo->selected_referral = cli_select_dfs_referral(cli, dinfo);
+ dinfo->selected_referral = smbcli_select_dfs_referral(cli, dinfo);
DEBUG(3, ("selected Dfs referral %d %s\n",
dinfo->selected_referral, dinfo->referrals[dinfo->selected_referral].node));
#endif
/* check if the server produced Dfs redirect */
-BOOL cli_check_dfs_redirect(struct cli_state* c, char* fname,
+BOOL smbcli_check_dfs_redirect(struct smbcli_state* c, char* fname,
dfs_info* dinfo)
{
//printf("check_dfs_redirect: error %s\n",
- // cli_errstr(c));
- if (cli_is_dos_error(c)) {
+ // smbcli_errstr(c));
+ if (smbcli_is_dos_error(c)) {
printf("got dos error\n");
return False;
/* Check NT error */
- status = cli_nt_error(c);
+ status = smbcli_nt_error(c);
//printf("got nt error 0x%x\n", status);
if (NT_STATUS_V(NT_STATUS_PATH_NOT_COVERED) != NT_STATUS_V(status)) {
}
/* execute trans2 getdfsreferral */
//printf("check_dfs_redirect: process referral\n");
- //cli_get_dfs_referral(c, fname, dinfo);
+ //smbcli_get_dfs_referral(c, fname, dinfo);
return True;
}
-int cli_dfs_open_connection(struct cli_client* cluster,
+int smbcli_dfs_open_connection(struct smbcli_client* cluster,
char* host, char* share, int flags)
{
int i;
BOOL retry;
- struct cli_state* c;
+ struct smbcli_state* c;
// check if already connected
for (i=0; i < DFS_MAX_CLUSTER_SIZE; i++) {
- if (cluster->cli[i]->in_use && strequal(host, cli_state_get_host(cluster->cli[i]))
- && strequal(share, cli_state_get_share(cluster->cli[i]))) {
- DEBUG(3,("cli_dfs_open_connection: already connected to \\\\%s\\%s\n", host, share));
+ if (cluster->cli[i]->in_use && strequal(host, smbcli_state_get_host(cluster->cli[i]))
+ && strequal(share, smbcli_state_get_share(cluster->cli[i]))) {
+ DEBUG(3,("smbcli_dfs_open_connection: already connected to \\\\%s\\%s\n", host, share));
return i;
}
}
// open connection
- DEBUG(3,("cli_dfs_open_connection: opening \\\\%s\\%s %s@%s\n",
+ DEBUG(3,("smbcli_dfs_open_connection: opening \\\\%s\\%s %s@%s\n",
host, share, cluster->username, cluster->workgroup));
for (i=0; i < DFS_MAX_CLUSTER_SIZE; i++) {
if (!cluster->cli[i]->in_use) {
return -1;
c = cluster->cli[i];
- if (NT_STATUS_IS_ERR(cli_full_connection(&c,
+ if (NT_STATUS_IS_ERR(smbcli_full_connection(&c,
NULL, host, NULL, 0,
share, "?????",
cluster->username, cluster->workgroup,
cluster->password, flags,
&retry)))
return -1;
- cli_state_set_sockopt(cluster->cli[i], cluster->sockops);
- cli_state_set_host(cluster->cli[i], host);
- cli_state_set_share(cluster->cli[i], share);
+ smbcli_state_set_sockopt(cluster->cli[i], cluster->sockops);
+ smbcli_state_set_host(cluster->cli[i], host);
+ smbcli_state_set_share(cluster->cli[i], share);
cluster->cli[i]->in_use = True;
- DEBUG(3,("cli_dfs_open_connection: connected \\\\%s\\%s (%d) %s@%s\n",
- cli_state_get_host(cluster->cli[i]), cli_state_get_share(cluster->cli[i]), i,
+ DEBUG(3,("smbcli_dfs_open_connection: connected \\\\%s\\%s (%d) %s@%s\n",
+ smbcli_state_get_host(cluster->cli[i]), smbcli_state_get_share(cluster->cli[i]), i,
cluster->username, cluster->workgroup));
return i;
into the dfs_path structure
**********************************************************************/
-BOOL cli_parse_dfs_path(char* pathname, struct dfs_path* pdp)
+BOOL smbcli_parse_dfs_path(char* pathname, struct dfs_path* pdp)
{
pstring pathname_local;
char* p,*temp;
ZERO_STRUCTP(pdp);
trim_string(temp,"\\","\\");
- DEBUG(10,("temp in cli_parse_dfs_path: .%s. after trimming \\'s\n",temp));
+ DEBUG(10,("temp in smbcli_parse_dfs_path: .%s. after trimming \\'s\n",temp));
/* now tokenize */
/* parse out hostname */
return True;
}
-char* rebuild_filename(char *referral_fname, struct cli_state* c,
+char* rebuild_filename(char *referral_fname, struct smbcli_state* c,
char* fname, int path_consumed)
{
const char *template = "\\\\%s\\%s\\%s";
// TODO: handle consumed length
DEBUG(3,("rebuild_filename: %s, %d consumed of %d\n",
fname, path_consumed, strlen(fname)));
- if (cli_parse_dfs_path(fname, &dp)) {
+ if (smbcli_parse_dfs_path(fname, &dp)) {
DEBUG(3,("rebuild_filename: reqpath=%s\n",
dp.reqpath));
asprintf(&referral_fname,
- template, cli_state_get_host(c),
- cli_state_get_share(c), dp.reqpath);
+ template, smbcli_state_get_host(c),
+ smbcli_state_get_share(c), dp.reqpath);
}
else
return NULL;
Open a file (allowing for Dfs referral).
****************************************************************************/
-int cli_dfs_open(struct cli_client* cluster, int *server,
+int smbcli_dfs_open(struct smbcli_client* cluster, int *server,
char *fname_src, int flags, int share_mode)
{
int referral_number;
char *referral_fname;
int fnum;
- DEBUG(3,("cli_dfs_open: open %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
+ DEBUG(3,("smbcli_dfs_open: open %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
cluster->cli[*server]->dfs_referral = *server;
- if ((fnum = cli_open(cluster->cli[*server], fname_src, flags, share_mode)) < 0) {
- if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
+ if ((fnum = smbcli_open(cluster->cli[*server], fname_src, flags, share_mode)) < 0) {
+ if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
// choose referral, check if already connected, open if not
referral_number = dinfo.selected_referral;
- DEBUG(3,("cli_dfs_open: redirecting to %s\n", dinfo.referrals[referral_number].node));
- cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster,
+ DEBUG(3,("smbcli_dfs_open: redirecting to %s\n", dinfo.referrals[referral_number].node));
+ cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster,
dinfo.referrals[referral_number].host,
dinfo.referrals[referral_number].share,
cluster->connection_flags);
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
return False;
fname_src = referral_fname;
- DEBUG(3,("cli_dfs_open: Dfs open %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
- fnum = cli_open(cluster->cli[*server], fname_src, flags, share_mode);
+ DEBUG(3,("smbcli_dfs_open: Dfs open %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
+ fnum = smbcli_open(cluster->cli[*server], fname_src, flags, share_mode);
}
- if (cli_is_error(cluster->cli[*server])) {
- printf("cli_dfs_open: open of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
+ if (smbcli_is_error(cluster->cli[*server])) {
+ printf("smbcli_dfs_open: open of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
return -1;
}
}
- DEBUG(3,("cli_dfs_open: open %s fnum=%d\n",
+ DEBUG(3,("smbcli_dfs_open: open %s fnum=%d\n",
fname_src, fnum));
return fnum;
}
Delete a file (allowing for Dfs referral).
****************************************************************************/
-NTSTATUS cli_nt_unlink(struct cli_client* cluster, int *server,
+NTSTATUS smbcli_nt_unlink(struct smbcli_client* cluster, int *server,
char *fname_src, uint16_t FileAttributes)
{
int referral_number;
char *referral_fname;
struct smb_unlink parms;
- DEBUG(3,("cli_nt_unlink: delete %s on server %s(%d), attributes=0x%x\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server,
+ DEBUG(3,("smbcli_nt_unlink: delete %s on server %s(%d), attributes=0x%x\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server,
FileAttributes));
cluster->cli[*server]->dfs_referral = *server;
parms.in.pattern = fname_src;
parms.in.dirtype = FileAttributes;
- if (NT_STATUS_IS_ERR(cli_raw_unlink(cluster->cli[*server], &parms))) {
- printf("cli_nt_unlink: delete of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
- if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
+ if (NT_STATUS_IS_ERR(smbcli_raw_unlink(cluster->cli[*server], &parms))) {
+ printf("smbcli_nt_unlink: delete of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
+ if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
// choose referral, check if already connected, open if not
referral_number = dinfo.selected_referral;
- DEBUG(3,("cli_nt_unlink: redirecting to %s\n", dinfo.referrals[referral_number].node));
- cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster,
+ DEBUG(3,("smbcli_nt_unlink: redirecting to %s\n", dinfo.referrals[referral_number].node));
+ cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster,
dinfo.referrals[referral_number].host,
dinfo.referrals[referral_number].share,
cluster->connection_flags);
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
return NT_STATUS_INTERNAL_ERROR;
fname_src = referral_fname;
- DEBUG(3,("cli_nt_unlink: Dfs delete %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
- cli_raw_unlink(cluster->cli[*server], &parms);
+ DEBUG(3,("smbcli_nt_unlink: Dfs delete %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
+ smbcli_raw_unlink(cluster->cli[*server], &parms);
}
- if (cli_is_error(cluster->cli[*server])) {
- printf("cli_nt_unlink: delete of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
+ if (smbcli_is_error(cluster->cli[*server])) {
+ printf("smbcli_nt_unlink: delete of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
}
}
- return cli_nt_error(cluster->cli[*server]);
+ return smbcli_nt_error(cluster->cli[*server]);
}
/****************************************************************************
Rename a file (allowing for Dfs referral).
****************************************************************************/
-BOOL cli_dfs_rename(struct cli_client* cluster, int *server,
+BOOL smbcli_dfs_rename(struct smbcli_client* cluster, int *server,
char *fname_src, char *fname_dst)
{
int referral_number;
dfs_info dinfo;
char *referral_fname;
- DEBUG(3,("cli_dfs_rename: rename %s to %s on server %s(%d)\n",
- fname_src, fname_dst, cli_state_get_host(cluster->cli[*server]), *server));
+ DEBUG(3,("smbcli_dfs_rename: rename %s to %s on server %s(%d)\n",
+ fname_src, fname_dst, smbcli_state_get_host(cluster->cli[*server]), *server));
cluster->cli[*server]->dfs_referral = *server;
- if (!cli_rename(cluster->cli[*server], fname_src, fname_dst)) {
- if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
+ if (!smbcli_rename(cluster->cli[*server], fname_src, fname_dst)) {
+ if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
// choose referral, check if already connected, open if not
referral_number = dinfo.selected_referral;
- DEBUG(3,("cli_dfs_rename: redirecting to %s\n", dinfo.referrals[referral_number].node));
- cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster,
+ DEBUG(3,("smbcli_dfs_rename: redirecting to %s\n", dinfo.referrals[referral_number].node));
+ cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster,
dinfo.referrals[referral_number].host,
dinfo.referrals[referral_number].share,
cluster->connection_flags);
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
return False;
fname_src = referral_fname;
- DEBUG(3,("cli_dfs_rename: Dfs rename %s to %s on server %s(%d)\n",
- fname_src, fname_dst, cli_state_get_host(cluster->cli[*server]), *server));
- cli_rename(cluster->cli[*server], fname_src, fname_dst);
+ DEBUG(3,("smbcli_dfs_rename: Dfs rename %s to %s on server %s(%d)\n",
+ fname_src, fname_dst, smbcli_state_get_host(cluster->cli[*server]), *server));
+ smbcli_rename(cluster->cli[*server], fname_src, fname_dst);
}
- if (cli_is_error(cluster->cli[*server])) {
- printf("cli_dfs_rename: rename of %s to %s failed (%s)\n",
- fname_src, fname_dst, cli_errstr(cluster->cli[*server]));
+ if (smbcli_is_error(cluster->cli[*server])) {
+ printf("smbcli_dfs_rename: rename of %s to %s failed (%s)\n",
+ fname_src, fname_dst, smbcli_errstr(cluster->cli[*server]));
return False;
}
}
Make directory (allowing for Dfs referral).
****************************************************************************/
-BOOL cli_dfs_mkdir(struct cli_client* cluster, int *server,
+BOOL smbcli_dfs_mkdir(struct smbcli_client* cluster, int *server,
char *fname_src)
{
int referral_number;
dfs_info dinfo;
char *referral_fname;
- DEBUG(3,("cli_dfs_mkdir: mkdir %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
+ DEBUG(3,("smbcli_dfs_mkdir: mkdir %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
cluster->cli[*server]->dfs_referral = *server;
- if (!cli_mkdir(cluster->cli[*server], fname_src)) {
- printf("cli_dfs_mkdir: mkdir of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
- if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
+ if (!smbcli_mkdir(cluster->cli[*server], fname_src)) {
+ printf("smbcli_dfs_mkdir: mkdir of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
+ if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
// choose referral, check if already connected, open if not
referral_number = dinfo.selected_referral;
- DEBUG(3,("cli_dfs_mkdir: redirecting to %s\n", dinfo.referrals[referral_number].node));
- cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster,
+ DEBUG(3,("smbcli_dfs_mkdir: redirecting to %s\n", dinfo.referrals[referral_number].node));
+ cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster,
dinfo.referrals[referral_number].host,
dinfo.referrals[referral_number].share,
cluster->connection_flags);
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
return False;
fname_src = referral_fname;
- DEBUG(3,("cli_dfs_mkdir: Dfs mkdir %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
- cli_mkdir(cluster->cli[*server], fname_src);
+ DEBUG(3,("smbcli_dfs_mkdir: Dfs mkdir %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
+ smbcli_mkdir(cluster->cli[*server], fname_src);
}
- if (cli_is_error(cluster->cli[*server])) {
- printf("cli_dfs_mkdir: mkdir of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
+ if (smbcli_is_error(cluster->cli[*server])) {
+ printf("smbcli_dfs_mkdir: mkdir of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
return False;
}
}
Remove directory (allowing for Dfs referral).
****************************************************************************/
-BOOL cli_dfs_rmdir(struct cli_client* cluster, int *server,
+BOOL smbcli_dfs_rmdir(struct smbcli_client* cluster, int *server,
char *fname_src)
{
int referral_number;
dfs_info dinfo;
char *referral_fname;
- DEBUG(3,("cli_dfs_rmdir: rmdir %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
+ DEBUG(3,("smbcli_dfs_rmdir: rmdir %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
cluster->cli[*server]->dfs_referral = *server;
- if (!cli_rmdir(cluster->cli[*server], fname_src)) {
- printf("cli_dfs_rmdir: rmdir of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
- if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
+ if (!smbcli_rmdir(cluster->cli[*server], fname_src)) {
+ printf("smbcli_dfs_rmdir: rmdir of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
+ if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) {
// choose referral, check if already connected, open if not
referral_number = dinfo.selected_referral;
- DEBUG(3,("cli_dfs_rmdir: redirecting to %s\n", dinfo.referrals[referral_number].node));
- cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster,
+ DEBUG(3,("smbcli_dfs_rmdir: redirecting to %s\n", dinfo.referrals[referral_number].node));
+ cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster,
dinfo.referrals[referral_number].host,
dinfo.referrals[referral_number].share,
cluster->connection_flags);
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
return False;
fname_src = referral_fname;
- DEBUG(3,("cli_dfs_rmdir: Dfs rmdir %s on server %s(%d)\n",
- fname_src, cli_state_get_host(cluster->cli[*server]), *server));
- cli_rmdir(cluster->cli[*server], fname_src);
+ DEBUG(3,("smbcli_dfs_rmdir: Dfs rmdir %s on server %s(%d)\n",
+ fname_src, smbcli_state_get_host(cluster->cli[*server]), *server));
+ smbcli_rmdir(cluster->cli[*server], fname_src);
}
- if (cli_is_error(cluster->cli[*server])) {
- printf("cli_dfs_rmdir: rmdir of %s failed (%s)\n",
- fname_src, cli_errstr(cluster->cli[*server]));
+ if (smbcli_is_error(cluster->cli[*server])) {
+ printf("smbcli_dfs_rmdir: rmdir of %s failed (%s)\n",
+ fname_src, smbcli_errstr(cluster->cli[*server]));
return False;
}
}
Hard/Symlink a file (UNIX extensions).
****************************************************************************/
-static NTSTATUS cli_link_internal(struct cli_tree *tree,
+static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree,
const char *fname_src,
const char *fname_dst, BOOL hard_link)
{
/****************************************************************************
Symlink a file (UNIX extensions).
****************************************************************************/
-NTSTATUS cli_unix_symlink(struct cli_tree *tree, const char *fname_src,
+NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
- return cli_link_internal(tree, fname_src, fname_dst, False);
+ return smbcli_link_internal(tree, fname_src, fname_dst, False);
}
/****************************************************************************
Hard a file (UNIX extensions).
****************************************************************************/
-NTSTATUS cli_unix_hardlink(struct cli_tree *tree, const char *fname_src,
+NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
- return cli_link_internal(tree, fname_src, fname_dst, True);
+ return smbcli_link_internal(tree, fname_src, fname_dst, True);
}
/****************************************************************************
Chmod or chown a file internal (UNIX extensions).
****************************************************************************/
-static NTSTATUS cli_unix_chmod_chown_internal(struct cli_tree *tree,
+static NTSTATUS smbcli_unix_chmod_chown_internal(struct smbcli_tree *tree,
const char *fname,
uint32_t mode, uint32_t uid,
uint32_t gid)
chmod a file (UNIX extensions).
****************************************************************************/
-NTSTATUS cli_unix_chmod(struct cli_tree *tree, const char *fname, mode_t mode)
+NTSTATUS smbcli_unix_chmod(struct smbcli_tree *tree, const char *fname, mode_t mode)
{
- return cli_unix_chmod_chown_internal(tree, fname,
+ return smbcli_unix_chmod_chown_internal(tree, fname,
unix_perms_to_wire(mode),
SMB_UID_NO_CHANGE,
SMB_GID_NO_CHANGE);
/****************************************************************************
chown a file (UNIX extensions).
****************************************************************************/
-NTSTATUS cli_unix_chown(struct cli_tree *tree, const char *fname, uid_t uid,
+NTSTATUS smbcli_unix_chown(struct smbcli_tree *tree, const char *fname, uid_t uid,
gid_t gid)
{
- return cli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE,
+ return smbcli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE,
(uint32_t)uid, (uint32_t)gid);
}
/****************************************************************************
Rename a file.
****************************************************************************/
-NTSTATUS cli_rename(struct cli_tree *tree, const char *fname_src,
+NTSTATUS smbcli_rename(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
union smb_rename parms;
/****************************************************************************
Delete a file.
****************************************************************************/
-NTSTATUS cli_unlink(struct cli_tree *tree, const char *fname)
+NTSTATUS smbcli_unlink(struct smbcli_tree *tree, const char *fname)
{
struct smb_unlink parms;
/****************************************************************************
Create a directory.
****************************************************************************/
-NTSTATUS cli_mkdir(struct cli_tree *tree, const char *dname)
+NTSTATUS smbcli_mkdir(struct smbcli_tree *tree, const char *dname)
{
union smb_mkdir parms;
/****************************************************************************
Remove a directory.
****************************************************************************/
-NTSTATUS cli_rmdir(struct cli_tree *tree, const char *dname)
+NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname)
{
struct smb_rmdir parms;
/****************************************************************************
Set or clear the delete on close flag.
****************************************************************************/
-NTSTATUS cli_nt_delete_on_close(struct cli_tree *tree, int fnum, BOOL flag)
+NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum, BOOL flag)
{
union smb_setfileinfo parms;
NTSTATUS status;
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_tree *tree, const char *fname,
+int smbcli_nt_create_full(struct smbcli_tree *tree, const char *fname,
uint32_t CreatFlags, uint32_t DesiredAccess,
uint32_t FileAttributes, uint32_t ShareAccess,
uint32_t CreateDisposition, uint32_t CreateOptions,
Open a file (using SMBopenx)
WARNING: if you open with O_WRONLY then getattrE won't work!
****************************************************************************/
-int cli_open(struct cli_tree *tree, const char *fname, int flags,
+int smbcli_open(struct smbcli_tree *tree, const char *fname, int flags,
int share_mode)
{
union smb_open open_parms;
/****************************************************************************
Close a file.
****************************************************************************/
-NTSTATUS cli_close(struct cli_tree *tree, int fnum)
+NTSTATUS smbcli_close(struct smbcli_tree *tree, int fnum)
{
union smb_close close_parms;
NTSTATUS status;
send a lock with a specified locktype
this is used for testing LOCKING_ANDX_CANCEL_LOCK
****************************************************************************/
-NTSTATUS cli_locktype(struct cli_tree *tree, int fnum,
+NTSTATUS smbcli_locktype(struct smbcli_tree *tree, int fnum,
uint32_t offset, uint32_t len, int timeout,
uint8_t locktype)
{
/****************************************************************************
Lock a file.
****************************************************************************/
-NTSTATUS cli_lock(struct cli_tree *tree, int fnum,
+NTSTATUS smbcli_lock(struct smbcli_tree *tree, int fnum,
uint32_t offset, uint32_t len, int timeout,
enum brl_type lock_type)
{
/****************************************************************************
Unlock a file.
****************************************************************************/
-NTSTATUS cli_unlock(struct cli_tree *tree, int fnum, uint32_t offset, uint32_t len)
+NTSTATUS smbcli_unlock(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
/****************************************************************************
Lock a file with 64 bit offsets.
****************************************************************************/
-NTSTATUS cli_lock64(struct cli_tree *tree, int fnum,
+NTSTATUS smbcli_lock64(struct smbcli_tree *tree, int fnum,
SMB_OFF_T offset, SMB_OFF_T len, int timeout,
enum brl_type lock_type)
{
NTSTATUS status;
if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
- return cli_lock(tree, fnum, offset, len, timeout, lock_type);
+ return smbcli_lock(tree, fnum, offset, len, timeout, lock_type);
}
parms.lockx.level = RAW_LOCK_LOCKX;
/****************************************************************************
Unlock a file with 64 bit offsets.
****************************************************************************/
-NTSTATUS cli_unlock64(struct cli_tree *tree, int fnum, SMB_OFF_T offset,
+NTSTATUS smbcli_unlock64(struct smbcli_tree *tree, int fnum, SMB_OFF_T offset,
SMB_OFF_T len)
{
union smb_lock parms;
NTSTATUS status;
if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
- return cli_unlock(tree, fnum, offset, len);
+ return smbcli_unlock(tree, fnum, offset, len);
}
parms.lockx.level = RAW_LOCK_LOCKX;
/****************************************************************************
Do a SMBgetattrE call.
****************************************************************************/
-NTSTATUS cli_getattrE(struct cli_tree *tree, int fnum,
+NTSTATUS smbcli_getattrE(struct smbcli_tree *tree, int fnum,
uint16_t *attr, size_t *size,
time_t *c_time, time_t *a_time, time_t *m_time)
{
/****************************************************************************
Do a SMBgetatr call
****************************************************************************/
-NTSTATUS cli_getatr(struct cli_tree *tree, const char *fname,
+NTSTATUS smbcli_getatr(struct smbcli_tree *tree, const char *fname,
uint16_t *attr, size_t *size, time_t *t)
{
union smb_fileinfo parms;
/****************************************************************************
Do a SMBsetatr call.
****************************************************************************/
-NTSTATUS cli_setatr(struct cli_tree *tree, const char *fname, uint16_t mode,
+NTSTATUS smbcli_setatr(struct smbcli_tree *tree, const char *fname, uint16_t mode,
time_t t)
{
union smb_setfileinfo parms;
/****************************************************************************
Check for existence of a dir.
****************************************************************************/
-NTSTATUS cli_chkpath(struct cli_tree *tree, const char *path)
+NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path)
{
struct smb_chkpath parms;
char *path2;
/****************************************************************************
Query disk space.
****************************************************************************/
-NTSTATUS cli_dskattr(struct cli_tree *tree, int *bsize, int *total, int *avail)
+NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *avail)
{
union smb_fsinfo fsinfo_parms;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- mem_ctx = talloc_init("cli_dskattr");
+ mem_ctx = talloc_init("smbcli_dskattr");
fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR;
status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms);
/****************************************************************************
Create and open a temporary file.
****************************************************************************/
-int cli_ctemp(struct cli_tree *tree, const char *path, char **tmp_path)
+int smbcli_ctemp(struct smbcli_tree *tree, const char *path, char **tmp_path)
{
union smb_open open_parms;
TALLOC_CTX *mem_ctx;
}
/* callback function used for trans2 search */
-static BOOL cli_list_new_callback(void *private, union smb_search_data *file)
+static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
{
struct search_private *state = (struct search_private*) private;
file_info *tdl;
return True;
}
-int cli_list_new(struct cli_tree *tree, const char *Mask, uint16_t attribute,
+int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
void (*fn)(file_info *, const char *, void *),
void *caller_state)
{
/* initialize state for search */
state.dirlist = NULL;
- state.mem_ctx = talloc_init("cli_list_new");
+ state.mem_ctx = talloc_init("smbcli_list_new");
state.dirlist_len = 0;
state.total_received = 0;
status = smb_raw_search_first(tree,
state.mem_ctx, &first_parms,
- (void*)&state, cli_list_new_callback);
+ (void*)&state, smbcli_list_new_callback);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
return -1;
state.mem_ctx,
&next_parms,
(void*)&state,
- cli_list_new_callback);
+ smbcli_list_new_callback);
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
/* callback function used for smb_search */
-static BOOL cli_list_old_callback(void *private, union smb_search_data *file)
+static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
{
struct search_private *state = (struct search_private*) private;
file_info *tdl;
return True;
}
-int cli_list_old(struct cli_tree *tree, const char *Mask, uint16_t attribute,
+int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
void (*fn)(file_info *, const char *, void *),
void *caller_state)
{
/* initialize state for search */
state.dirlist = NULL;
- state.mem_ctx = talloc_init("cli_list_old");
+ state.mem_ctx = talloc_init("smbcli_list_old");
state.dirlist_len = 0;
state.total_received = 0;
status = smb_raw_search_first(tree, state.mem_ctx,
&first_parms,
(void*)&state,
- cli_list_old_callback);
+ smbcli_list_old_callback);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
status = smb_raw_search_next(tree, state.mem_ctx,
&next_parms,
(void*)&state,
- cli_list_old_callback);
+ smbcli_list_old_callback);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
This auto-switches between old and new style.
****************************************************************************/
-int cli_list(struct cli_tree *tree, const char *Mask,uint16_t attribute,
+int smbcli_list(struct smbcli_tree *tree, const char *Mask,uint16_t attribute,
void (*fn)(file_info *, const char *, void *), void *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);
+ return smbcli_list_old(tree, Mask, attribute, fn, state);
+ return smbcli_list_new(tree, Mask, attribute, fn, state);
}
/****************************************************************************
start a message sequence
****************************************************************************/
-BOOL cli_message_start(struct cli_tree *tree, char *host, char *username,
+BOOL smbcli_message_start(struct smbcli_tree *tree, char *host, char *username,
int *grp)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- 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(tree)) {
- cli_request_destroy(req);
+ req = smbcli_request_setup(tree, SMBsendstrt, 0, 0);
+ smbcli_req_append_string(req, username, STR_TERMINATE);
+ smbcli_req_append_string(req, host, STR_TERMINATE);
+ if (!smbcli_request_send(req) ||
+ !smbcli_request_receive(req) ||
+ smbcli_is_error(tree)) {
+ smbcli_request_destroy(req);
return False;
}
*grp = SVAL(req->in.vwv, VWV(0));
- cli_request_destroy(req);
+ smbcli_request_destroy(req);
return True;
}
/****************************************************************************
send a message
****************************************************************************/
-BOOL cli_message_text(struct cli_tree *tree, char *msg, int len, int grp)
+BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBsendtxt, 1, 0);
+ req = smbcli_request_setup(tree, SMBsendtxt, 1, 0);
SSVAL(req->out.vwv, VWV(0), grp);
- cli_req_append_bytes(req, msg, len);
+ smbcli_req_append_bytes(req, msg, len);
- if (!cli_request_send(req) ||
- !cli_request_receive(req) ||
- cli_is_error(tree)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req) ||
+ !smbcli_request_receive(req) ||
+ smbcli_is_error(tree)) {
+ smbcli_request_destroy(req);
return False;
}
- cli_request_destroy(req);
+ smbcli_request_destroy(req);
return True;
}
/****************************************************************************
end a message
****************************************************************************/
-BOOL cli_message_end(struct cli_tree *tree, int grp)
+BOOL smbcli_message_end(struct smbcli_tree *tree, int grp)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBsendend, 1, 0);
+ req = smbcli_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(tree)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req) ||
+ !smbcli_request_receive(req) ||
+ smbcli_is_error(tree)) {
+ smbcli_request_destroy(req);
return False;
}
- cli_request_destroy(req);
+ smbcli_request_destroy(req);
return True;
}
/****************************************************************************
Read size bytes at offset offset using SMBreadX.
****************************************************************************/
-ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset,
+ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, char *buf, off_t offset,
size_t size)
{
union smb_read parms;
0x0004 use raw named pipe protocol
0x0008 start of message mode named pipe protocol
****************************************************************************/
-ssize_t cli_write(struct cli_tree *tree,
+ssize_t smbcli_write(struct smbcli_tree *tree,
int fnum, uint16_t write_mode,
const char *buf, off_t offset, size_t size)
{
/****************************************************************************
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/
-ssize_t cli_smbwrite(struct cli_tree *tree,
+ssize_t smbcli_smbwrite(struct smbcli_tree *tree,
int fnum, char *buf, off_t offset, size_t size1)
{
union smb_write parms;
/****************************************************************************
query the security descriptor for a open file
****************************************************************************/
-SEC_DESC *cli_query_secdesc(struct cli_tree *tree, int fnum,
+SEC_DESC *smbcli_query_secdesc(struct smbcli_tree *tree, int fnum,
TALLOC_CTX *mem_ctx)
{
struct smb_nttrans parms;
/****************************************************************************
set the security descriptor for a open file
****************************************************************************/
-BOOL cli_set_secdesc(struct cli_tree *tree, int fnum, SEC_DESC *sd)
+BOOL smbcli_set_secdesc(struct smbcli_tree *tree, int fnum, SEC_DESC *sd)
{
struct smb_nttrans parms;
char param[8];
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- mem_ctx = talloc_init("cli_set_secdesc");
+ mem_ctx = talloc_init("smbcli_set_secdesc");
prs_init(&pd, 0, mem_ctx, MARSHALL);
prs_give_memory(&pd, NULL, 0, True);
/****************************************************************************
send a qpathinfo call
****************************************************************************/
-NTSTATUS cli_qpathinfo(struct cli_tree *tree, const char *fname,
+NTSTATUS smbcli_qpathinfo(struct smbcli_tree *tree, const char *fname,
time_t *c_time, time_t *a_time, time_t *m_time,
size_t *size, uint16_t *mode)
{
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- mem_ctx = talloc_init("cli_qpathinfo");
+ mem_ctx = talloc_init("smbcli_qpathinfo");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
parms.standard.level = RAW_FILEINFO_STANDARD;
/****************************************************************************
send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
****************************************************************************/
-NTSTATUS cli_qpathinfo2(struct cli_tree *tree, const char *fname,
+NTSTATUS smbcli_qpathinfo2(struct smbcli_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_t *mode,
SMB_INO_T *ino)
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- mem_ctx = talloc_init("cli_qfilename");
+ mem_ctx = talloc_init("smbcli_qfilename");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
parms.all_info.level = RAW_FILEINFO_ALL_INFO;
/****************************************************************************
send a qfileinfo QUERY_FILE_NAME_INFO call
****************************************************************************/
-NTSTATUS cli_qfilename(struct cli_tree *tree, int fnum, const char **name)
+NTSTATUS smbcli_qfilename(struct smbcli_tree *tree, int fnum, const char **name)
{
union smb_fileinfo parms;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- mem_ctx = talloc_init("cli_qfilename");
+ mem_ctx = talloc_init("smbcli_qfilename");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
parms.name_info.level = RAW_FILEINFO_NAME_INFO;
/****************************************************************************
send a qfileinfo call
****************************************************************************/
-NTSTATUS cli_qfileinfo(struct cli_tree *tree, int fnum,
+NTSTATUS smbcli_qfileinfo(struct smbcli_tree *tree, int fnum,
uint16_t *mode, size_t *size,
time_t *c_time, time_t *a_time, time_t *m_time,
time_t *w_time, SMB_INO_T *ino)
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- mem_ctx = talloc_init("cli_qfileinfo");
+ mem_ctx = talloc_init("smbcli_qfileinfo");
if (!mem_ctx)
return NT_STATUS_NO_MEMORY;
/****************************************************************************
send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
****************************************************************************/
-NTSTATUS cli_qpathinfo_alt_name(struct cli_tree *tree, const char *fname,
+NTSTATUS smbcli_qpathinfo_alt_name(struct smbcli_tree *tree, const char *fname,
const char **alt_name)
{
union smb_fileinfo parms;
parms.alt_name_info.level = RAW_FILEINFO_ALT_NAME_INFO;
parms.alt_name_info.in.fname = fname;
- mem_ctx = talloc_init("cli_qpathinfo_alt_name");
+ mem_ctx = talloc_init("smbcli_qpathinfo_alt_name");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
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(tree);
+ return smbcli_nt_error(tree);
}
if (!parms.alt_name_info.out.fname.s) {
/* We have the netbios name and IP address of a domain controller.
Ideally we should sent a SAMLOGON request to determine whether
the DC is alive and kicking. If we can catch a dead DC before
- performing a cli_connect() we can avoid a 30-second timeout. */
+ performing a smbcli_connect() we can avoid a 30-second timeout. */
DEBUG(3, ("rpc_find_dc: Returning DC %s (%s) for domain %s\n", srv_name,
inet_ntoa(dc_ip), domain));
/****************************************************************************
send an ack for an oplock break request
****************************************************************************/
-BOOL cli_oplock_ack(struct cli_tree *tree, uint16_t fnum, uint16_t ack_level)
+BOOL smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level)
{
BOOL ret;
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBlockingX, 8, 0);
+ req = smbcli_request_setup(tree, SMBlockingX, 8, 0);
SSVAL(req->out.vwv,VWV(0),0xFF);
SSVAL(req->out.vwv,VWV(1),0);
subsystem not to allocate an id for a reply */
req->one_way_request = 1;
- ret = cli_request_send(req);
+ ret = smbcli_request_send(req);
return ret;
}
/****************************************************************************
set the oplock handler for a connection
****************************************************************************/
-void cli_oplock_handler(struct cli_transport *transport,
- BOOL (*handler)(struct cli_transport *, uint16_t, uint16_t, uint8_t, void *),
+void smbcli_oplock_handler(struct smbcli_transport *transport,
+ BOOL (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
void *private)
{
transport->oplock.handler = handler;
#include "includes.h"
#define SETUP_REQUEST_SESSION(cmd, wct, buflen) do { \
- req = cli_request_setup_session(session, cmd, wct, buflen); \
+ req = smbcli_request_setup_session(session, cmd, wct, buflen); \
if (!req) return NULL; \
} while (0)
/****************************************************************************
Initialize the session context
****************************************************************************/
-struct cli_session *cli_session_init(struct cli_transport *transport)
+struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport)
{
- struct cli_session *session;
- TALLOC_CTX *mem_ctx = talloc_init("cli_session");
+ struct smbcli_session *session;
+ TALLOC_CTX *mem_ctx = talloc_init("smbcli_session");
if (mem_ctx == NULL) {
return NULL;
}
/****************************************************************************
reduce reference_count and destroy is <= 0
****************************************************************************/
-void cli_session_close(struct cli_session *session)
+void smbcli_session_close(struct smbcli_session *session)
{
session->reference_count--;
if (session->reference_count <= 0) {
- cli_transport_close(session->transport);
+ smbcli_transport_close(session->transport);
talloc_destroy(session->mem_ctx);
}
}
/****************************************************************************
Perform a session setup (async send)
****************************************************************************/
-struct cli_request *smb_raw_session_setup_send(struct cli_session *session, union smb_sesssetup *parms)
+struct smbcli_request *smb_raw_session_setup_send(struct smbcli_session *session, union smb_sesssetup *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->generic.level) {
case RAW_SESSSETUP_GENERIC:
SSVAL(req->out.vwv,VWV(4),parms->old.in.vc_num);
SIVAL(req->out.vwv,VWV(5),parms->old.in.sesskey);
SSVAL(req->out.vwv,VWV(7),parms->old.in.password.length);
- cli_req_append_blob(req, &parms->old.in.password);
- cli_req_append_string(req, parms->old.in.user, STR_TERMINATE);
- cli_req_append_string(req, parms->old.in.domain, STR_TERMINATE|STR_UPPER);
- cli_req_append_string(req, parms->old.in.os, STR_TERMINATE);
- cli_req_append_string(req, parms->old.in.lanman, STR_TERMINATE);
+ smbcli_req_append_blob(req, &parms->old.in.password);
+ smbcli_req_append_string(req, parms->old.in.user, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->old.in.domain, STR_TERMINATE|STR_UPPER);
+ smbcli_req_append_string(req, parms->old.in.os, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->old.in.lanman, STR_TERMINATE);
break;
case RAW_SESSSETUP_NT1:
SSVAL(req->out.vwv, VWV(8), parms->nt1.in.password2.length);
SIVAL(req->out.vwv, VWV(9), 0); /* reserved */
SIVAL(req->out.vwv, VWV(11), parms->nt1.in.capabilities);
- cli_req_append_blob(req, &parms->nt1.in.password1);
- cli_req_append_blob(req, &parms->nt1.in.password2);
- cli_req_append_string(req, parms->nt1.in.user, STR_TERMINATE);
- cli_req_append_string(req, parms->nt1.in.domain, STR_TERMINATE|STR_UPPER);
- cli_req_append_string(req, parms->nt1.in.os, STR_TERMINATE);
- cli_req_append_string(req, parms->nt1.in.lanman, STR_TERMINATE);
+ smbcli_req_append_blob(req, &parms->nt1.in.password1);
+ smbcli_req_append_blob(req, &parms->nt1.in.password2);
+ smbcli_req_append_string(req, parms->nt1.in.user, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->nt1.in.domain, STR_TERMINATE|STR_UPPER);
+ smbcli_req_append_string(req, parms->nt1.in.os, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->nt1.in.lanman, STR_TERMINATE);
break;
case RAW_SESSSETUP_SPNEGO:
SSVAL(req->out.vwv, VWV(7), parms->spnego.in.secblob.length);
SIVAL(req->out.vwv, VWV(8), 0); /* reserved */
SIVAL(req->out.vwv, VWV(10), parms->spnego.in.capabilities);
- cli_req_append_blob(req, &parms->spnego.in.secblob);
- cli_req_append_string(req, parms->spnego.in.os, STR_TERMINATE);
- cli_req_append_string(req, parms->spnego.in.lanman, STR_TERMINATE);
- cli_req_append_string(req, parms->spnego.in.domain, STR_TERMINATE);
+ smbcli_req_append_blob(req, &parms->spnego.in.secblob);
+ smbcli_req_append_string(req, parms->spnego.in.os, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->spnego.in.lanman, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->spnego.in.domain, STR_TERMINATE);
break;
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Perform a session setup (async recv)
****************************************************************************/
-NTSTATUS smb_raw_session_setup_recv(struct cli_request *req,
+NTSTATUS smb_raw_session_setup_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
union smb_sesssetup *parms)
{
uint16_t len;
char *p;
- if (!cli_request_receive(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req)) {
+ return smbcli_request_destroy(req);
}
if (!NT_STATUS_IS_OK(req->status) &&
!NT_STATUS_EQUAL(req->status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
switch (parms->generic.level) {
return NT_STATUS_INVALID_LEVEL;
case RAW_SESSSETUP_OLD:
- CLI_CHECK_WCT(req, 3);
+ SMBCLI_CHECK_WCT(req, 3);
ZERO_STRUCT(parms->old.out);
parms->old.out.vuid = SVAL(req->in.hdr, HDR_UID);
parms->old.out.action = SVAL(req->in.vwv, VWV(2));
p = req->in.data;
if (p) {
- p += cli_req_pull_string(req, mem_ctx, &parms->old.out.os, p, -1, STR_TERMINATE);
- p += cli_req_pull_string(req, mem_ctx, &parms->old.out.lanman, p, -1, STR_TERMINATE);
- p += cli_req_pull_string(req, mem_ctx, &parms->old.out.domain, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.os, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.lanman, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.domain, p, -1, STR_TERMINATE);
}
break;
case RAW_SESSSETUP_NT1:
- CLI_CHECK_WCT(req, 3);
+ SMBCLI_CHECK_WCT(req, 3);
ZERO_STRUCT(parms->nt1.out);
parms->nt1.out.vuid = SVAL(req->in.hdr, HDR_UID);
parms->nt1.out.action = SVAL(req->in.vwv, VWV(2));
p = req->in.data;
if (p) {
- p += cli_req_pull_string(req, mem_ctx, &parms->nt1.out.os, p, -1, STR_TERMINATE);
- p += cli_req_pull_string(req, mem_ctx, &parms->nt1.out.lanman, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.os, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.lanman, p, -1, STR_TERMINATE);
if (p < (req->in.data + req->in.data_size)) {
- p += cli_req_pull_string(req, mem_ctx, &parms->nt1.out.domain, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.domain, p, -1, STR_TERMINATE);
}
}
break;
case RAW_SESSSETUP_SPNEGO:
- CLI_CHECK_WCT(req, 4);
+ SMBCLI_CHECK_WCT(req, 4);
ZERO_STRUCT(parms->spnego.out);
parms->spnego.out.vuid = SVAL(req->in.hdr, HDR_UID);
parms->spnego.out.action = SVAL(req->in.vwv, VWV(2));
break;
}
- parms->spnego.out.secblob = cli_req_pull_blob(req, mem_ctx, p, len);
+ parms->spnego.out.secblob = smbcli_req_pull_blob(req, mem_ctx, p, len);
p += parms->spnego.out.secblob.length;
- p += cli_req_pull_string(req, mem_ctx, &parms->spnego.out.os, p, -1, STR_TERMINATE);
- p += cli_req_pull_string(req, mem_ctx, &parms->spnego.out.lanman, p, -1, STR_TERMINATE);
- p += cli_req_pull_string(req, mem_ctx, &parms->spnego.out.domain, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.os, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.lanman, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.domain, p, -1, STR_TERMINATE);
break;
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/*
/*
store the user session key for a transport
*/
-void cli_session_set_user_session_key(struct cli_session *session,
+void smbcli_session_set_user_session_key(struct smbcli_session *session,
const DATA_BLOB *session_key)
{
session->user_session_key = data_blob_talloc(session->mem_ctx,
/*
setup signing for a NT1 style session setup
*/
-static void use_nt1_session_keys(struct cli_session *session,
+static void use_nt1_session_keys(struct smbcli_session *session,
const char *password, const DATA_BLOB *nt_response)
{
- struct cli_transport *transport = session->transport;
+ struct smbcli_transport *transport = session->transport;
uint8_t nt_hash[16];
DATA_BLOB session_key = data_blob(NULL, 16);
E_md4hash(password, nt_hash);
SMBsesskeygen_ntv1(nt_hash, session_key.data);
- cli_transport_simple_set_signing(transport, session_key, *nt_response);
+ smbcli_transport_simple_set_signing(transport, session_key, *nt_response);
- cli_session_set_user_session_key(session, &session_key);
+ smbcli_session_set_user_session_key(session, &session_key);
data_blob_free(&session_key);
}
Perform a session setup (sync interface) using generic interface and the old
style sesssetup call
****************************************************************************/
-static NTSTATUS smb_raw_session_setup_generic_old(struct cli_session *session,
+static NTSTATUS smb_raw_session_setup_generic_old(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
union smb_sesssetup *parms)
{
Perform a session setup (sync interface) using generic interface and the NT1
style sesssetup call
****************************************************************************/
-static NTSTATUS smb_raw_session_setup_generic_nt1(struct cli_session *session,
+static NTSTATUS smb_raw_session_setup_generic_nt1(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
union smb_sesssetup *parms)
{
Perform a session setup (sync interface) using generic interface and the SPNEGO
style sesssetup call
****************************************************************************/
-static NTSTATUS smb_raw_session_setup_generic_spnego(struct cli_session *session,
+static NTSTATUS smb_raw_session_setup_generic_spnego(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
union smb_sesssetup *parms)
{
s2.spnego.in.lanman = "Samba";
s2.spnego.out.vuid = UID_FIELD_INVALID;
- cli_temp_set_signing(session->transport);
+ smbcli_temp_set_signing(session->transport);
status = gensec_client_start(&session->gensec);
if (!NT_STATUS_IS_OK(status)) {
session_key_err = gensec_session_key(session->gensec, &session_key);
}
if (NT_STATUS_IS_OK(session_key_err)) {
- cli_transport_simple_set_signing(session->transport, session_key, null_data_blob);
+ smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob);
}
session->vuid = s2.spnego.out.vuid;
return session_key_err;
}
- cli_session_set_user_session_key(session, &session_key);
+ smbcli_session_set_user_session_key(session, &session_key);
parms->generic.out.vuid = s2.spnego.out.vuid;
parms->generic.out.os = s2.spnego.out.os;
/****************************************************************************
Perform a session setup (sync interface) using generic interface
****************************************************************************/
-static NTSTATUS smb_raw_session_setup_generic(struct cli_session *session,
+static NTSTATUS smb_raw_session_setup_generic(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
union smb_sesssetup *parms)
{
this interface allows for RAW_SESSSETUP_GENERIC to auto-select session
setup variant based on negotiated protocol options
****************************************************************************/
-NTSTATUS smb_raw_session_setup(struct cli_session *session, TALLOC_CTX *mem_ctx,
+NTSTATUS smb_raw_session_setup(struct smbcli_session *session, TALLOC_CTX *mem_ctx,
union smb_sesssetup *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
if (parms->generic.level == RAW_SESSSETUP_GENERIC) {
NTSTATUS ret = smb_raw_session_setup_generic(session, mem_ctx, parms);
/****************************************************************************
Send a uloggoff (async send)
*****************************************************************************/
-struct cli_request *smb_raw_ulogoff_send(struct cli_session *session)
+struct smbcli_request *smb_raw_ulogoff_send(struct smbcli_session *session)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST_SESSION(SMBulogoffX, 2, 0);
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
SSVAL(req->out.vwv, VWV(1), 0);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Send a uloggoff (sync interface)
*****************************************************************************/
-NTSTATUS smb_raw_ulogoff(struct cli_session *session)
+NTSTATUS smb_raw_ulogoff(struct smbcli_session *session)
{
- struct cli_request *req = smb_raw_ulogoff_send(session);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_ulogoff_send(session);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Send a SMBexit
****************************************************************************/
-NTSTATUS smb_raw_exit(struct cli_session *session)
+NTSTATUS smb_raw_exit(struct smbcli_session *session)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup_session(session, SMBexit, 0, 0);
+ req = smbcli_request_setup_session(session, SMBexit, 0, 0);
- if (cli_request_send(req)) {
- cli_request_receive(req);
+ if (smbcli_request_send(req)) {
+ smbcli_request_receive(req);
}
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/*
- create a cli_socket context
+ create a smbcli_socket context
*/
-struct cli_socket *cli_sock_init(void)
+struct smbcli_socket *smbcli_sock_init(void)
{
- struct cli_socket *sock;
+ struct smbcli_socket *sock;
TALLOC_CTX *mem_ctx;
- mem_ctx = talloc_init("cli_socket");
+ mem_ctx = talloc_init("smbcli_socket");
if (!mem_ctx) return NULL;
sock = talloc_zero(mem_ctx, sizeof(*sock));
}
/*
- connect a cli_socket context to an IP/port pair
+ connect a smbcli_socket context to an IP/port pair
if port is 0 then choose 445 then 139
*/
-BOOL cli_sock_connect(struct cli_socket *sock, struct in_addr *ip, int port)
+BOOL smbcli_sock_connect(struct smbcli_socket *sock, struct in_addr *ip, int port)
{
if (getenv("LIBSMB_PROG")) {
sock->fd = sock_exec(getenv("LIBSMB_PROG"));
}
if (port == 0) {
- return cli_sock_connect(sock, ip, 445) ||
- cli_sock_connect(sock, ip, 139);
+ return smbcli_sock_connect(sock, ip, 445) ||
+ smbcli_sock_connect(sock, ip, 139);
}
sock->dest_ip = *ip;
/****************************************************************************
mark the socket as dead
****************************************************************************/
-void cli_sock_dead(struct cli_socket *sock)
+void smbcli_sock_dead(struct smbcli_socket *sock)
{
if (sock->fd != -1) {
close(sock->fd);
/****************************************************************************
reduce socket reference count - if it becomes zero then close
****************************************************************************/
-void cli_sock_close(struct cli_socket *sock)
+void smbcli_sock_close(struct smbcli_socket *sock)
{
sock->reference_count--;
if (sock->reference_count <= 0) {
- cli_sock_dead(sock);
+ smbcli_sock_dead(sock);
}
}
/****************************************************************************
Set socket options on a open connection.
****************************************************************************/
-void cli_sock_set_options(struct cli_socket *sock, const char *options)
+void smbcli_sock_set_options(struct smbcli_socket *sock, const char *options)
{
set_socket_options(sock->fd, options);
}
/****************************************************************************
Write to socket. Return amount written.
****************************************************************************/
-ssize_t cli_sock_write(struct cli_socket *sock, const char *data, size_t len)
+ssize_t smbcli_sock_write(struct smbcli_socket *sock, const char *data, size_t len)
{
if (sock->fd == -1) {
errno = EIO;
/****************************************************************************
Read from socket. return amount read
****************************************************************************/
-ssize_t cli_sock_read(struct cli_socket *sock, char *data, size_t len)
+ssize_t smbcli_sock_read(struct smbcli_socket *sock, char *data, size_t len)
{
if (sock->fd == -1) {
errno = EIO;
/****************************************************************************
resolve a hostname and connect
****************************************************************************/
-BOOL cli_sock_connect_byname(struct cli_socket *sock, const char *host, int port)
+BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, int port)
{
int name_type = 0x20;
struct in_addr ip;
return sock->fd != -1;
}
- mem_ctx = talloc_init("cli_sock_connect_byname");
+ mem_ctx = talloc_init("smbcli_sock_connect_byname");
if (!mem_ctx) return False;
name = talloc_strdup(mem_ctx, host);
return False;
}
- ret = cli_sock_connect(sock, &ip, port);
+ ret = smbcli_sock_connect(sock, &ip, port);
if (ret) {
sock->hostname = talloc_steal(mem_ctx, sock->mem_ctx, name);
/*
an event has happened on the socket
*/
-static void cli_transport_event_handler(struct event_context *ev, struct fd_event *fde,
+static void smbcli_transport_event_handler(struct event_context *ev, struct fd_event *fde,
time_t t, uint16_t flags)
{
- struct cli_transport *transport = fde->private;
+ struct smbcli_transport *transport = fde->private;
- cli_transport_process(transport);
+ smbcli_transport_process(transport);
}
/*
create a transport structure based on an established socket
*/
-struct cli_transport *cli_transport_init(struct cli_socket *sock)
+struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock)
{
TALLOC_CTX *mem_ctx;
- struct cli_transport *transport;
+ struct smbcli_transport *transport;
struct fd_event fde;
- mem_ctx = talloc_init("cli_transport");
+ mem_ctx = talloc_init("smbcli_transport");
if (!mem_ctx) return NULL;
transport = talloc_zero(mem_ctx, sizeof(*transport));
transport->options.use_spnego = lp_use_spnego();
transport->negotiate.max_xmit = ~0;
- cli_init_signing(transport);
+ smbcli_init_signing(transport);
transport->socket->reference_count++;
fde.fd = sock->fd;
fde.flags = EVENT_FD_READ;
- fde.handler = cli_transport_event_handler;
+ fde.handler = smbcli_transport_event_handler;
fde.private = transport;
fde.ref_count = 1;
decrease reference count on a transport, and destroy if it becomes
zero
*/
-void cli_transport_close(struct cli_transport *transport)
+void smbcli_transport_close(struct smbcli_transport *transport)
{
transport->reference_count--;
if (transport->reference_count <= 0) {
- cli_sock_close(transport->socket);
+ smbcli_sock_close(transport->socket);
event_remove_fd(transport->event.ctx, transport->event.fde);
event_remove_timed(transport->event.ctx, transport->event.te);
event_context_destroy(transport->event.ctx);
/*
mark the transport as dead
*/
-void cli_transport_dead(struct cli_transport *transport)
+void smbcli_transport_dead(struct smbcli_transport *transport)
{
- cli_sock_dead(transport->socket);
+ smbcli_sock_dead(transport->socket);
/* all pending sends become errors */
while (transport->pending_send) {
- struct cli_request *req = transport->pending_send;
- req->state = CLI_REQUEST_ERROR;
+ struct smbcli_request *req = transport->pending_send;
+ req->state = SMBCLI_REQUEST_ERROR;
req->status = NT_STATUS_NET_WRITE_FAULT;
DLIST_REMOVE(transport->pending_send, req);
if (req->async.fn) {
/* as do all pending receives */
while (transport->pending_recv) {
- struct cli_request *req = transport->pending_recv;
- req->state = CLI_REQUEST_ERROR;
+ struct smbcli_request *req = transport->pending_recv;
+ req->state = SMBCLI_REQUEST_ERROR;
req->status = NT_STATUS_NET_WRITE_FAULT;
DLIST_REMOVE(transport->pending_recv, req);
if (req->async.fn) {
/*
enable select for write on a transport
*/
-static void cli_transport_write_enable(struct cli_transport *transport)
+static void smbcli_transport_write_enable(struct smbcli_transport *transport)
{
transport->event.fde->flags |= EVENT_FD_WRITE;
}
/*
disable select for write on a transport
*/
-static void cli_transport_write_disable(struct cli_transport *transport)
+static void smbcli_transport_write_disable(struct smbcli_transport *transport)
{
transport->event.fde->flags &= ~EVENT_FD_WRITE;
}
/****************************************************************************
send a session request (if appropriate)
****************************************************************************/
-BOOL cli_transport_connect(struct cli_transport *transport,
+BOOL smbcli_transport_connect(struct smbcli_transport *transport,
struct nmb_name *calling,
struct nmb_name *called)
{
char *p;
int len = NBT_HDR_SIZE;
- struct cli_request *req;
+ struct smbcli_request *req;
if (called) {
transport->called = *called;
}
/* allocate output buffer */
- req = cli_request_setup_nonsmb(transport, NBT_HDR_SIZE + 2*nbt_mangled_name_len());
+ req = smbcli_request_setup_nonsmb(transport, NBT_HDR_SIZE + 2*nbt_mangled_name_len());
/* put in the destination name */
p = req->out.buffer + NBT_HDR_SIZE;
_smb_setlen(req->out.buffer,len-4);
SCVAL(req->out.buffer,0,0x81);
- if (!cli_request_send(req) ||
- !cli_request_receive(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req) ||
+ !smbcli_request_receive(req)) {
+ smbcli_request_destroy(req);
return False;
}
if (CVAL(req->in.buffer,0) != 0x82) {
transport->error.etype = ETYPE_NBT;
transport->error.e.nbt_error = CVAL(req->in.buffer,4);
- cli_request_destroy(req);
+ smbcli_request_destroy(req);
return False;
}
- cli_request_destroy(req);
+ smbcli_request_destroy(req);
return True;
}
/****************************************************************************
get next mid in sequence
****************************************************************************/
-uint16_t cli_transport_next_mid(struct cli_transport *transport)
+uint16_t smbcli_transport_next_mid(struct smbcli_transport *transport)
{
uint16_t mid;
- struct cli_request *req;
+ struct smbcli_request *req;
mid = transport->next_mid;
static void idle_handler(struct event_context *ev,
struct timed_event *te, time_t t)
{
- struct cli_transport *transport = te->private;
+ struct smbcli_transport *transport = te->private;
te->next_event = t + transport->idle.period;
transport->idle.func(transport, transport->idle.private);
}
setup the idle handler for a transport
the period is in seconds
*/
-void cli_transport_idle_handler(struct cli_transport *transport,
- void (*idle_func)(struct cli_transport *, void *),
+void smbcli_transport_idle_handler(struct smbcli_transport *transport,
+ void (*idle_func)(struct smbcli_transport *, void *),
uint_t period,
void *private)
{
/*
process some pending sends
*/
-static void cli_transport_process_send(struct cli_transport *transport)
+static void smbcli_transport_process_send(struct smbcli_transport *transport)
{
while (transport->pending_send) {
- struct cli_request *req = transport->pending_send;
+ struct smbcli_request *req = transport->pending_send;
ssize_t ret;
- ret = cli_sock_write(transport->socket, req->out.buffer, req->out.size);
+ ret = smbcli_sock_write(transport->socket, req->out.buffer, req->out.size);
if (ret == -1) {
if (errno == EAGAIN || errno == EINTR) {
return;
}
- cli_transport_dead(transport);
+ smbcli_transport_dead(transport);
}
req->out.buffer += ret;
req->out.size -= ret;
if (req->out.size == 0) {
DLIST_REMOVE(transport->pending_send, req);
if (req->one_way_request) {
- req->state = CLI_REQUEST_DONE;
- cli_request_destroy(req);
+ req->state = SMBCLI_REQUEST_DONE;
+ smbcli_request_destroy(req);
} else {
- req->state = CLI_REQUEST_RECV;
+ req->state = SMBCLI_REQUEST_RECV;
DLIST_ADD(transport->pending_recv, req);
}
}
/* we're out of requests to send, so don't wait for write
events any more */
- cli_transport_write_disable(transport);
+ smbcli_transport_write_disable(transport);
}
/*
we have a full request in our receive buffer - match it to a pending request
and process
*/
-static void cli_transport_finish_recv(struct cli_transport *transport)
+static void smbcli_transport_finish_recv(struct smbcli_transport *transport)
{
uint8_t *buffer, *hdr, *vwv;
int len;
uint16_t wct, mid = 0;
- struct cli_request *req;
+ struct smbcli_request *req;
buffer = transport->recv_buffer.buffer;
len = transport->recv_buffer.req_size;
/* handle non-SMB replies */
if (req->in.size < NBT_HDR_SIZE + MIN_SMB_SIZE) {
- req->state = CLI_REQUEST_ERROR;
+ req->state = SMBCLI_REQUEST_ERROR;
goto error;
}
if (req->in.size < NBT_HDR_SIZE + MIN_SMB_SIZE + VWV(wct)) {
DEBUG(2,("bad reply size for mid %d\n", mid));
req->status = NT_STATUS_UNSUCCESSFUL;
- req->state = CLI_REQUEST_ERROR;
+ req->state = SMBCLI_REQUEST_ERROR;
goto error;
}
req->status = transport->error.e.nt_status;
}
- if (!cli_request_check_sign_mac(req)) {
+ if (!smbcli_request_check_sign_mac(req)) {
transport->error.etype = ETYPE_SOCKET;
transport->error.e.socket_error = SOCKET_READ_BAD_SIG;
- req->state = CLI_REQUEST_ERROR;
+ req->state = SMBCLI_REQUEST_ERROR;
goto error;
};
notify that the reply has been received. This might destroy
the request so it must happen last */
DLIST_REMOVE(transport->pending_recv, req);
- req->state = CLI_REQUEST_DONE;
+ req->state = SMBCLI_REQUEST_DONE;
if (req->async.fn) {
req->async.fn(req);
}
error:
if (req) {
DLIST_REMOVE(transport->pending_recv, req);
- req->state = CLI_REQUEST_ERROR;
+ req->state = SMBCLI_REQUEST_ERROR;
}
}
/*
process some pending receives
*/
-static void cli_transport_process_recv(struct cli_transport *transport)
+static void smbcli_transport_process_recv(struct smbcli_transport *transport)
{
/* a incoming packet goes through 2 stages - first we read the
4 byte header, which tells us how much more is coming. Then
we read the rest */
if (transport->recv_buffer.received < NBT_HDR_SIZE) {
ssize_t ret;
- ret = cli_sock_read(transport->socket,
+ ret = smbcli_sock_read(transport->socket,
transport->recv_buffer.header +
transport->recv_buffer.received,
NBT_HDR_SIZE - transport->recv_buffer.received);
if (errno == EINTR || errno == EAGAIN) {
return;
}
- cli_transport_dead(transport);
+ smbcli_transport_dead(transport);
return;
}
transport->recv_buffer.buffer = talloc(transport->mem_ctx,
NBT_HDR_SIZE+transport->recv_buffer.req_size);
if (transport->recv_buffer.buffer == NULL) {
- cli_transport_dead(transport);
+ smbcli_transport_dead(transport);
return;
}
memcpy(transport->recv_buffer.buffer, transport->recv_buffer.header, NBT_HDR_SIZE);
if (transport->recv_buffer.received < transport->recv_buffer.req_size) {
ssize_t ret;
- ret = cli_sock_read(transport->socket,
+ ret = smbcli_sock_read(transport->socket,
transport->recv_buffer.buffer +
transport->recv_buffer.received,
transport->recv_buffer.req_size -
if (errno == EINTR || errno == EAGAIN) {
return;
}
- cli_transport_dead(transport);
+ smbcli_transport_dead(transport);
return;
}
transport->recv_buffer.received += ret;
if (transport->recv_buffer.received != 0 &&
transport->recv_buffer.received == transport->recv_buffer.req_size) {
- cli_transport_finish_recv(transport);
+ smbcli_transport_finish_recv(transport);
}
}
process some read/write requests that are pending
return False if the socket is dead
*/
-BOOL cli_transport_process(struct cli_transport *transport)
+BOOL smbcli_transport_process(struct smbcli_transport *transport)
{
- cli_transport_process_send(transport);
- cli_transport_process_recv(transport);
+ smbcli_transport_process_send(transport);
+ smbcli_transport_process_recv(transport);
if (transport->socket->fd == -1) {
return False;
}
/*
put a request into the send queue
*/
-void cli_transport_send(struct cli_request *req)
+void smbcli_transport_send(struct smbcli_request *req)
{
/* check if the transport is dead */
if (req->transport->socket->fd == -1) {
- req->state = CLI_REQUEST_ERROR;
+ req->state = SMBCLI_REQUEST_ERROR;
req->status = NT_STATUS_NET_WRITE_FAULT;
return;
}
/* put it on the outgoing socket queue */
- req->state = CLI_REQUEST_SEND;
- DLIST_ADD_END(req->transport->pending_send, req, struct cli_request *);
+ req->state = SMBCLI_REQUEST_SEND;
+ DLIST_ADD_END(req->transport->pending_send, req, struct smbcli_request *);
/* make sure we look for write events */
- cli_transport_write_enable(req->transport);
+ smbcli_transport_write_enable(req->transport);
}
#include "includes.h"
#define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \
- req = cli_request_setup(tree, cmd, wct, buflen); \
+ req = smbcli_request_setup(tree, cmd, wct, buflen); \
if (!req) return NULL; \
} while (0)
/****************************************************************************
Initialize the tree context
****************************************************************************/
-struct cli_tree *cli_tree_init(struct cli_session *session)
+struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session)
{
- struct cli_tree *tree;
- TALLOC_CTX *mem_ctx = talloc_init("cli_tree");
+ struct smbcli_tree *tree;
+ TALLOC_CTX *mem_ctx = talloc_init("smbcli_tree");
if (mem_ctx == NULL) {
return NULL;
}
/****************************************************************************
reduce reference count on a tree and destroy if <= 0
****************************************************************************/
-void cli_tree_close(struct cli_tree *tree)
+void smbcli_tree_close(struct smbcli_tree *tree)
{
if (!tree) return;
tree->reference_count--;
if (tree->reference_count <= 0) {
- cli_session_close(tree->session);
+ smbcli_session_close(tree->session);
talloc_destroy(tree->mem_ctx);
}
}
/****************************************************************************
Send a tconX (async send)
****************************************************************************/
-struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon *parms)
+struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->tcon.level) {
case RAW_TCON_TCON:
SETUP_REQUEST_TREE(SMBtcon, 0, 0);
- cli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII);
- cli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII);
- cli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII);
+ smbcli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII);
+ smbcli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII);
+ smbcli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII);
break;
case RAW_TCON_TCONX:
SSVAL(req->out.vwv, VWV(1), 0);
SSVAL(req->out.vwv, VWV(2), parms->tconx.in.flags);
SSVAL(req->out.vwv, VWV(3), parms->tconx.in.password.length);
- cli_req_append_blob(req, &parms->tconx.in.password);
- cli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER);
- cli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII);
+ smbcli_req_append_blob(req, &parms->tconx.in.password);
+ smbcli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER);
+ smbcli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII);
break;
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Send a tconX (async recv)
****************************************************************************/
-NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms)
+NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms)
{
char *p;
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
goto failed;
}
switch (parms->tcon.level) {
case RAW_TCON_TCON:
- CLI_CHECK_WCT(req, 2);
+ SMBCLI_CHECK_WCT(req, 2);
parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0));
parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1));
break;
p = req->in.data;
if (!p) break;
- p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type,
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type,
p, -1, STR_ASCII | STR_TERMINATE);
- p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type,
+ p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type,
p, -1, STR_TERMINATE);
break;
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Send a tconX (sync interface)
****************************************************************************/
-NTSTATUS smb_tree_connect(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms)
+NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms)
{
- struct cli_request *req = smb_tree_connect_send(tree, parms);
+ struct smbcli_request *req = smb_tree_connect_send(tree, parms);
return smb_tree_connect_recv(req, mem_ctx, parms);
}
/****************************************************************************
Send a tree disconnect.
****************************************************************************/
-NTSTATUS smb_tree_disconnect(struct cli_tree *tree)
+NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
{
- struct cli_request *req;
+ struct smbcli_request *req;
if (!tree) return NT_STATUS_OK;
- req = cli_request_setup(tree, SMBtdis, 0, 0);
+ req = smbcli_request_setup(tree, SMBtdis, 0, 0);
- if (cli_request_send(req)) {
- cli_request_receive(req);
+ if (smbcli_request_send(req)) {
+ smbcli_request_receive(req);
}
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/*
- a convenient function to establish a cli_tree from scratch, using reasonable default
+ a convenient function to establish a smbcli_tree from scratch, using reasonable default
parameters
*/
-NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree,
+NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
const char *my_name,
const char *dest_host, int port,
const char *service, const char *service_type,
const char *user, const char *domain,
const char *password)
{
- struct cli_socket *sock;
- struct cli_transport *transport;
- struct cli_session *session;
- struct cli_tree *tree;
+ struct smbcli_socket *sock;
+ struct smbcli_transport *transport;
+ struct smbcli_session *session;
+ struct smbcli_tree *tree;
NTSTATUS status;
struct nmb_name calling;
struct nmb_name called;
*ret_tree = NULL;
- sock = cli_sock_init();
+ sock = smbcli_sock_init();
if (!sock) {
return NT_STATUS_NO_MEMORY;
}
/* open a TCP socket to the server */
- if (!cli_sock_connect_byname(sock, dest_host, port)) {
+ if (!smbcli_sock_connect_byname(sock, dest_host, port)) {
DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno)));
return NT_STATUS_UNSUCCESSFUL;
}
- transport = cli_transport_init(sock);
+ transport = smbcli_transport_init(sock);
if (!transport) {
- cli_sock_close(sock);
+ smbcli_sock_close(sock);
return NT_STATUS_NO_MEMORY;
}
make_nmb_name(&calling, my_name, 0x0);
make_nmb_name(&called, dest_host, 0x20);
- if (!cli_transport_connect(transport, &calling, &called)) {
- cli_transport_close(transport);
+ if (!smbcli_transport_connect(transport, &calling, &called)) {
+ smbcli_transport_close(transport);
return NT_STATUS_UNSUCCESSFUL;
}
/* negotiate protocol options with the server */
status = smb_raw_negotiate(transport);
if (!NT_STATUS_IS_OK(status)) {
- cli_transport_close(transport);
+ smbcli_transport_close(transport);
return status;
}
- session = cli_session_init(transport);
+ session = smbcli_session_init(transport);
if (!session) {
- cli_transport_close(transport);
+ smbcli_transport_close(transport);
return NT_STATUS_NO_MEMORY;
}
status = smb_raw_session_setup(session, mem_ctx, &setup);
if (!NT_STATUS_IS_OK(status)) {
- cli_session_close(session);
+ smbcli_session_close(session);
talloc_destroy(mem_ctx);
return status;
}
session->vuid = setup.generic.out.vuid;
- tree = cli_tree_init(session);
+ tree = smbcli_tree_init(session);
if (!tree) {
- cli_session_close(session);
+ smbcli_session_close(session);
talloc_destroy(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
SAFE_FREE(in_path);
if (!NT_STATUS_IS_OK(status)) {
- cli_tree_close(tree);
+ smbcli_tree_close(tree);
talloc_destroy(mem_ctx);
return status;
}
/****************************************************************************
fetch file ACL (async send)
****************************************************************************/
-struct cli_request *smb_raw_query_secdesc_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_query_secdesc_send(struct smbcli_tree *tree,
struct smb_query_secdesc *query)
{
struct smb_nttrans nt;
/****************************************************************************
fetch file ACL (async recv)
****************************************************************************/
-NTSTATUS smb_raw_query_secdesc_recv(struct cli_request *req,
+NTSTATUS smb_raw_query_secdesc_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
struct smb_query_secdesc *query)
{
/****************************************************************************
fetch file ACL (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_query_secdesc(struct cli_tree *tree,
+NTSTATUS smb_raw_query_secdesc(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
struct smb_query_secdesc *query)
{
- struct cli_request *req = smb_raw_query_secdesc_send(tree, query);
+ struct smbcli_request *req = smb_raw_query_secdesc_send(tree, query);
return smb_raw_query_secdesc_recv(req, mem_ctx, query);
}
/****************************************************************************
set file ACL (async send)
****************************************************************************/
-struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_set_secdesc_send(struct smbcli_tree *tree,
struct smb_set_secdesc *set)
{
struct smb_nttrans nt;
uint8_t params[8];
struct ndr_push *ndr;
- struct cli_request *req;
+ struct smbcli_request *req;
NTSTATUS status;
nt.in.max_setup = 0;
put a dos date into a buffer (time/date format)
This takes GMT time and puts local time for zone_offset in the buffer
********************************************************************/
-void raw_push_dos_date(struct cli_transport *transport,
+void raw_push_dos_date(struct smbcli_transport *transport,
uint8_t *buf, int offset, time_t unixdate)
{
push_dos_date(buf, offset, unixdate, transport->negotiate.server_zone);
put a dos date into a buffer (date/time format)
This takes GMT time and puts local time in the buffer
********************************************************************/
-void raw_push_dos_date2(struct cli_transport *transport,
+void raw_push_dos_date2(struct smbcli_transport *transport,
char *buf, int offset, time_t unixdate)
{
push_dos_date2(buf, offset, unixdate, transport->negotiate.server_zone);
put a dos 32 bit "unix like" date into a buffer. This routine takes
GMT and converts it to LOCAL time in zone_offset before putting it
********************************************************************/
-void raw_push_dos_date3(struct cli_transport *transport,
+void raw_push_dos_date3(struct smbcli_transport *transport,
char *buf, int offset, time_t unixdate)
{
push_dos_date3(buf, offset, unixdate, transport->negotiate.server_zone);
/*******************************************************************
convert a dos date
********************************************************************/
-time_t raw_pull_dos_date(struct cli_transport *transport,
+time_t raw_pull_dos_date(struct smbcli_transport *transport,
const uint8_t *date_ptr)
{
return pull_dos_date(date_ptr, transport->negotiate.server_zone);
/*******************************************************************
like raw_pull_dos_date() but the words are reversed
********************************************************************/
-time_t raw_pull_dos_date2(struct cli_transport *transport,
+time_t raw_pull_dos_date2(struct smbcli_transport *transport,
const uint8_t *date_ptr)
{
return pull_dos_date2(date_ptr, transport->negotiate.server_zone);
create a unix GMT date from a dos date in 32 bit "unix like" format
these arrive in server zone, with corresponding DST
******************************************************************/
-time_t raw_pull_dos_date3(struct cli_transport *transport,
+time_t raw_pull_dos_date3(struct smbcli_transport *transport,
const uint8_t *date_ptr)
{
return pull_dos_date3(date_ptr, transport->negotiate.server_zone);
#include "includes.h"
#define SETUP_REQUEST(cmd, wct, buflen) do { \
- req = cli_request_setup(tree, cmd, wct, buflen); \
+ req = smbcli_request_setup(tree, cmd, wct, buflen); \
if (!req) return NULL; \
} while (0)
/****************************************************************************
Rename a file - async interface
****************************************************************************/
-struct cli_request *smb_raw_rename_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_rename_send(struct smbcli_tree *tree,
union smb_rename *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->generic.level) {
case RAW_RENAME_RENAME:
SETUP_REQUEST(SMBmv, 1, 0);
SSVAL(req->out.vwv, VWV(0), parms->rename.in.attrib);
- cli_req_append_ascii4(req, parms->rename.in.pattern1, STR_TERMINATE);
- cli_req_append_ascii4(req, parms->rename.in.pattern2, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->rename.in.pattern1, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->rename.in.pattern2, STR_TERMINATE);
break;
case RAW_RENAME_NTRENAME:
SSVAL(req->out.vwv, VWV(0), parms->ntrename.in.attrib);
SSVAL(req->out.vwv, VWV(1), parms->ntrename.in.flags);
SIVAL(req->out.vwv, VWV(2), parms->ntrename.in.cluster_size);
- cli_req_append_ascii4(req, parms->ntrename.in.old_name, STR_TERMINATE);
- cli_req_append_ascii4(req, parms->ntrename.in.new_name, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->ntrename.in.old_name, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->ntrename.in.new_name, STR_TERMINATE);
break;
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Rename a file - sync interface
****************************************************************************/
-NTSTATUS smb_raw_rename(struct cli_tree *tree,
+NTSTATUS smb_raw_rename(struct smbcli_tree *tree,
union smb_rename *parms)
{
- struct cli_request *req = smb_raw_rename_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_rename_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Delete a file - async interface
****************************************************************************/
-struct cli_request *smb_raw_unlink_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_unlink_send(struct smbcli_tree *tree,
struct smb_unlink *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST(SMBunlink, 1, 0);
SSVAL(req->out.vwv, VWV(0), parms->in.attrib);
- cli_req_append_ascii4(req, parms->in.pattern, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->in.pattern, STR_TERMINATE);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
return req;
/*
delete a file - sync interface
*/
-NTSTATUS smb_raw_unlink(struct cli_tree *tree,
+NTSTATUS smb_raw_unlink(struct smbcli_tree *tree,
struct smb_unlink *parms)
{
- struct cli_request *req = smb_raw_unlink_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_unlink_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
create a directory using TRANSACT2_MKDIR - async interface
****************************************************************************/
-static struct cli_request *smb_raw_t2mkdir_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_t2mkdir_send(struct smbcli_tree *tree,
union smb_mkdir *parms)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_MKDIR;
TALLOC_CTX *mem_ctx;
- struct cli_request *req;
+ struct smbcli_request *req;
uint16_t data_total;
mem_ctx = talloc_init("t2mkdir");
SIVAL(t2.in.params.data, VWV(0), 0); /* reserved */
- cli_blob_append_string(tree->session, mem_ctx,
+ smbcli_blob_append_string(tree->session, mem_ctx,
&t2.in.params, parms->t2mkdir.in.path, 0);
ea_put_list(t2.in.data.data, parms->t2mkdir.in.num_eas, parms->t2mkdir.in.eas);
/****************************************************************************
Create a directory - async interface
****************************************************************************/
-struct cli_request *smb_raw_mkdir_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_mkdir_send(struct smbcli_tree *tree,
union smb_mkdir *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
if (parms->generic.level == RAW_MKDIR_T2MKDIR) {
return smb_raw_t2mkdir_send(tree, parms);
SETUP_REQUEST(SMBmkdir, 0, 0);
- cli_req_append_ascii4(req, parms->mkdir.in.path, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->mkdir.in.path, STR_TERMINATE);
- if (!cli_request_send(req)) {
+ if (!smbcli_request_send(req)) {
return NULL;
}
/****************************************************************************
Create a directory - sync interface
****************************************************************************/
-NTSTATUS smb_raw_mkdir(struct cli_tree *tree,
+NTSTATUS smb_raw_mkdir(struct smbcli_tree *tree,
union smb_mkdir *parms)
{
- struct cli_request *req = smb_raw_mkdir_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_mkdir_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Remove a directory - async interface
****************************************************************************/
-struct cli_request *smb_raw_rmdir_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_rmdir_send(struct smbcli_tree *tree,
struct smb_rmdir *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST(SMBrmdir, 0, 0);
- cli_req_append_ascii4(req, parms->in.path, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->in.path, STR_TERMINATE);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Remove a directory - sync interface
****************************************************************************/
-NTSTATUS smb_raw_rmdir(struct cli_tree *tree,
+NTSTATUS smb_raw_rmdir(struct smbcli_tree *tree,
struct smb_rmdir *parms)
{
- struct cli_request *req = smb_raw_rmdir_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_rmdir_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Open a file using TRANSACT2_OPEN - async send
****************************************************************************/
-static struct cli_request *smb_raw_t2open_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_t2open_send(struct smbcli_tree *tree,
union smb_open *parms)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_OPEN;
TALLOC_CTX *mem_ctx = talloc_init("smb_raw_t2open");
- struct cli_request *req;
+ struct smbcli_request *req;
uint16_t list_size;
list_size = ea_list_size(parms->t2open.in.num_eas, parms->t2open.in.eas);
SIVAL(t2.in.params.data, VWV(11), 0);
SSVAL(t2.in.params.data, VWV(13), 0);
- cli_blob_append_string(tree->session, mem_ctx,
+ smbcli_blob_append_string(tree->session, mem_ctx,
&t2.in.params, parms->t2open.in.fname,
STR_TERMINATE);
/****************************************************************************
Open a file using TRANSACT2_OPEN - async recv
****************************************************************************/
-static NTSTATUS smb_raw_t2open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms)
+static NTSTATUS smb_raw_t2open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms)
{
- struct cli_transport *transport = req?req->transport:NULL;
+ struct smbcli_transport *transport = req?req->transport:NULL;
struct smb_trans2 t2;
NTSTATUS status;
/****************************************************************************
Open a file - async send
****************************************************************************/
-struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *parms)
+struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_open *parms)
{
int len;
- struct cli_request *req = NULL;
+ struct smbcli_request *req = NULL;
switch (parms->open.level) {
case RAW_OPEN_T2OPEN:
SETUP_REQUEST(SMBopen, 2, 0);
SSVAL(req->out.vwv, VWV(0), parms->open.in.flags);
SSVAL(req->out.vwv, VWV(1), parms->open.in.search_attrs);
- cli_req_append_ascii4(req, parms->open.in.fname, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->open.in.fname, STR_TERMINATE);
break;
case RAW_OPEN_OPENX:
SIVAL(req->out.vwv, VWV(9), parms->openx.in.size);
SIVAL(req->out.vwv, VWV(11),parms->openx.in.timeout);
SIVAL(req->out.vwv, VWV(13),0); /* reserved */
- cli_req_append_string(req, parms->openx.in.fname, STR_TERMINATE);
+ smbcli_req_append_string(req, parms->openx.in.fname, STR_TERMINATE);
break;
case RAW_OPEN_MKNEW:
SSVAL(req->out.vwv, VWV(0), parms->mknew.in.attrib);
raw_push_dos_date3(tree->session->transport,
req->out.vwv, VWV(1), parms->mknew.in.write_time);
- cli_req_append_ascii4(req, parms->mknew.in.fname, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->mknew.in.fname, STR_TERMINATE);
break;
case RAW_OPEN_CREATE:
SSVAL(req->out.vwv, VWV(0), parms->create.in.attrib);
raw_push_dos_date3(tree->session->transport,
req->out.vwv, VWV(1), parms->create.in.write_time);
- cli_req_append_ascii4(req, parms->create.in.fname, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->create.in.fname, STR_TERMINATE);
break;
case RAW_OPEN_CTEMP:
SSVAL(req->out.vwv, VWV(0), parms->ctemp.in.attrib);
raw_push_dos_date3(tree->session->transport,
req->out.vwv, VWV(1), parms->ctemp.in.write_time);
- cli_req_append_ascii4(req, parms->ctemp.in.directory, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->ctemp.in.directory, STR_TERMINATE);
break;
case RAW_OPEN_SPLOPEN:
SIVAL(req->out.vwv, 43, parms->ntcreatex.in.impersonation);
SCVAL(req->out.vwv, 47, parms->ntcreatex.in.security_flags);
- cli_req_append_string_len(req, parms->ntcreatex.in.fname, STR_TERMINATE, &len);
+ smbcli_req_append_string_len(req, parms->ntcreatex.in.fname, STR_TERMINATE, &len);
SSVAL(req->out.vwv, 5, len);
break;
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Open a file - async recv
****************************************************************************/
-NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms)
+NTSTATUS smb_raw_open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
goto failed;
}
return smb_raw_t2open_recv(req, mem_ctx, parms);
case RAW_OPEN_OPEN:
- CLI_CHECK_WCT(req, 7);
+ SMBCLI_CHECK_WCT(req, 7);
parms->open.out.fnum = SVAL(req->in.vwv, VWV(0));
parms->open.out.attrib = SVAL(req->in.vwv, VWV(1));
parms->open.out.write_time = raw_pull_dos_date3(req->transport,
break;
case RAW_OPEN_OPENX:
- CLI_CHECK_MIN_WCT(req, 15);
+ SMBCLI_CHECK_MIN_WCT(req, 15);
parms->openx.out.fnum = SVAL(req->in.vwv, VWV(2));
parms->openx.out.attrib = SVAL(req->in.vwv, VWV(3));
parms->openx.out.write_time = raw_pull_dos_date3(req->transport,
break;
case RAW_OPEN_MKNEW:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->mknew.out.fnum = SVAL(req->in.vwv, VWV(0));
break;
case RAW_OPEN_CREATE:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->create.out.fnum = SVAL(req->in.vwv, VWV(0));
break;
case RAW_OPEN_CTEMP:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->ctemp.out.fnum = SVAL(req->in.vwv, VWV(0));
- cli_req_pull_string(req, mem_ctx, &parms->ctemp.out.name, req->in.data, -1, STR_TERMINATE | STR_ASCII);
+ smbcli_req_pull_string(req, mem_ctx, &parms->ctemp.out.name, req->in.data, -1, STR_TERMINATE | STR_ASCII);
break;
case RAW_OPEN_SPLOPEN:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->splopen.out.fnum = SVAL(req->in.vwv, VWV(0));
break;
case RAW_OPEN_NTCREATEX:
- CLI_CHECK_MIN_WCT(req, 34);
+ SMBCLI_CHECK_MIN_WCT(req, 34);
parms->ntcreatex.out.oplock_level = CVAL(req->in.vwv, 4);
parms->ntcreatex.out.fnum = SVAL(req->in.vwv, 5);
parms->ntcreatex.out.create_action = IVAL(req->in.vwv, 7);
- parms->ntcreatex.out.create_time = cli_pull_nttime(req->in.vwv, 11);
- parms->ntcreatex.out.access_time = cli_pull_nttime(req->in.vwv, 19);
- parms->ntcreatex.out.write_time = cli_pull_nttime(req->in.vwv, 27);
- parms->ntcreatex.out.change_time = cli_pull_nttime(req->in.vwv, 35);
+ parms->ntcreatex.out.create_time = smbcli_pull_nttime(req->in.vwv, 11);
+ parms->ntcreatex.out.access_time = smbcli_pull_nttime(req->in.vwv, 19);
+ parms->ntcreatex.out.write_time = smbcli_pull_nttime(req->in.vwv, 27);
+ parms->ntcreatex.out.change_time = smbcli_pull_nttime(req->in.vwv, 35);
parms->ntcreatex.out.attrib = IVAL(req->in.vwv, 43);
parms->ntcreatex.out.alloc_size = BVAL(req->in.vwv, 47);
parms->ntcreatex.out.size = BVAL(req->in.vwv, 55);
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Open a file - sync interface
****************************************************************************/
-NTSTATUS smb_raw_open(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms)
+NTSTATUS smb_raw_open(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms)
{
- struct cli_request *req = smb_raw_open_send(tree, parms);
+ struct smbcli_request *req = smb_raw_open_send(tree, parms);
return smb_raw_open_recv(req, mem_ctx, parms);
}
/****************************************************************************
Close a file - async send
****************************************************************************/
-struct cli_request *smb_raw_close_send(struct cli_tree *tree, union smb_close *parms)
+struct smbcli_request *smb_raw_close_send(struct smbcli_tree *tree, union smb_close *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->generic.level) {
case RAW_CLOSE_GENERIC:
if (!req) return NULL;
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Close a file - sync interface
****************************************************************************/
-NTSTATUS smb_raw_close(struct cli_tree *tree, union smb_close *parms)
+NTSTATUS smb_raw_close(struct smbcli_tree *tree, union smb_close *parms)
{
- struct cli_request *req = smb_raw_close_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_close_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Locking calls - async interface
****************************************************************************/
-struct cli_request *smb_raw_lock_send(struct cli_tree *tree, union smb_lock *parms)
+struct smbcli_request *smb_raw_lock_send(struct smbcli_tree *tree, union smb_lock *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->generic.level) {
case RAW_LOCK_GENERIC:
}
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Locking calls - sync interface
****************************************************************************/
-NTSTATUS smb_raw_lock(struct cli_tree *tree, union smb_lock *parms)
+NTSTATUS smb_raw_lock(struct smbcli_tree *tree, union smb_lock *parms)
{
- struct cli_request *req = smb_raw_lock_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_lock_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Check for existence of a dir - async send
****************************************************************************/
-struct cli_request *smb_raw_chkpath_send(struct cli_tree *tree, struct smb_chkpath *parms)
+struct smbcli_request *smb_raw_chkpath_send(struct smbcli_tree *tree, struct smb_chkpath *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST(SMBchkpth, 0, 0);
- cli_req_append_ascii4(req, parms->in.path, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->in.path, STR_TERMINATE);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Check for existence of a dir - sync interface
****************************************************************************/
-NTSTATUS smb_raw_chkpath(struct cli_tree *tree, struct smb_chkpath *parms)
+NTSTATUS smb_raw_chkpath(struct smbcli_tree *tree, struct smb_chkpath *parms)
{
- struct cli_request *req = smb_raw_chkpath_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_chkpath_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
flush a file - async send
a flush to fnum 0xFFFF will flush all files
****************************************************************************/
-struct cli_request *smb_raw_flush_send(struct cli_tree *tree, struct smb_flush *parms)
+struct smbcli_request *smb_raw_flush_send(struct smbcli_tree *tree, struct smb_flush *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST(SMBflush, 1, 0);
SSVAL(req->out.vwv, VWV(0), parms->in.fnum);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
flush a file - sync interface
****************************************************************************/
-NTSTATUS smb_raw_flush(struct cli_tree *tree, struct smb_flush *parms)
+NTSTATUS smb_raw_flush(struct smbcli_tree *tree, struct smb_flush *parms)
{
- struct cli_request *req = smb_raw_flush_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_flush_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
seek a file - async send
****************************************************************************/
-struct cli_request *smb_raw_seek_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_seek_send(struct smbcli_tree *tree,
struct smb_seek *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST(SMBlseek, 4, 0);
SSVAL(req->out.vwv, VWV(1), parms->in.mode);
SIVALS(req->out.vwv, VWV(2), parms->in.offset);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
return req;
/****************************************************************************
seek a file - async receive
****************************************************************************/
-NTSTATUS smb_raw_seek_recv(struct cli_request *req,
+NTSTATUS smb_raw_seek_recv(struct smbcli_request *req,
struct smb_seek *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
- CLI_CHECK_WCT(req, 2);
+ SMBCLI_CHECK_WCT(req, 2);
parms->out.offset = IVAL(req->in.vwv, VWV(0));
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/*
seek a file - sync interface
*/
-NTSTATUS smb_raw_seek(struct cli_tree *tree,
+NTSTATUS smb_raw_seek(struct smbcli_tree *tree,
struct smb_seek *parms)
{
- struct cli_request *req = smb_raw_seek_send(tree, parms);
+ struct smbcli_request *req = smb_raw_seek_send(tree, parms);
return smb_raw_seek_recv(req, parms);
}
/****************************************************************************
Handle qfileinfo/qpathinfo trans2 backend.
****************************************************************************/
-static NTSTATUS smb_raw_info_backend(struct cli_session *session,
+static NTSTATUS smb_raw_info_backend(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
union smb_fileinfo *parms,
DATA_BLOB *blob)
if (blob->length != 36) {
FINFO_CHECK_SIZE(40);
}
- parms->basic_info.out.create_time = cli_pull_nttime(blob->data, 0);
- parms->basic_info.out.access_time = cli_pull_nttime(blob->data, 8);
- parms->basic_info.out.write_time = cli_pull_nttime(blob->data, 16);
- parms->basic_info.out.change_time = cli_pull_nttime(blob->data, 24);
+ parms->basic_info.out.create_time = smbcli_pull_nttime(blob->data, 0);
+ parms->basic_info.out.access_time = smbcli_pull_nttime(blob->data, 8);
+ parms->basic_info.out.write_time = smbcli_pull_nttime(blob->data, 16);
+ parms->basic_info.out.change_time = smbcli_pull_nttime(blob->data, 24);
parms->basic_info.out.attrib = IVAL(blob->data, 32);
return NT_STATUS_OK;
case RAW_FILEINFO_NAME_INFO:
case RAW_FILEINFO_NAME_INFORMATION:
FINFO_CHECK_MIN_SIZE(4);
- cli_blob_pull_string(session, mem_ctx, blob,
+ smbcli_blob_pull_string(session, mem_ctx, blob,
&parms->name_info.out.fname, 0, 4, STR_UNICODE);
return NT_STATUS_OK;
case RAW_FILEINFO_ALL_INFO:
case RAW_FILEINFO_ALL_INFORMATION:
FINFO_CHECK_MIN_SIZE(72);
- parms->all_info.out.create_time = cli_pull_nttime(blob->data, 0);
- parms->all_info.out.access_time = cli_pull_nttime(blob->data, 8);
- parms->all_info.out.write_time = cli_pull_nttime(blob->data, 16);
- parms->all_info.out.change_time = cli_pull_nttime(blob->data, 24);
+ parms->all_info.out.create_time = smbcli_pull_nttime(blob->data, 0);
+ parms->all_info.out.access_time = smbcli_pull_nttime(blob->data, 8);
+ parms->all_info.out.write_time = smbcli_pull_nttime(blob->data, 16);
+ parms->all_info.out.change_time = smbcli_pull_nttime(blob->data, 24);
parms->all_info.out.attrib = IVAL(blob->data, 32);
parms->all_info.out.alloc_size = BVAL(blob->data, 40);
parms->all_info.out.size = BVAL(blob->data, 48);
parms->all_info.out.delete_pending = CVAL(blob->data, 60);
parms->all_info.out.directory = CVAL(blob->data, 61);
parms->all_info.out.ea_size = IVAL(blob->data, 64);
- cli_blob_pull_string(session, mem_ctx, blob,
+ smbcli_blob_pull_string(session, mem_ctx, blob,
&parms->all_info.out.fname, 68, 72, STR_UNICODE);
return NT_STATUS_OK;
case RAW_FILEINFO_ALT_NAME_INFO:
case RAW_FILEINFO_ALT_NAME_INFORMATION:
FINFO_CHECK_MIN_SIZE(4);
- cli_blob_pull_string(session, mem_ctx, blob,
+ smbcli_blob_pull_string(session, mem_ctx, blob,
&parms->alt_name_info.out.fname, 0, 4, STR_UNICODE);
return NT_STATUS_OK;
}
parms->stream_info.out.streams[n].size = BVAL(blob->data, ofs + 8);
parms->stream_info.out.streams[n].alloc_size = BVAL(blob->data, ofs + 16);
- cli_blob_pull_string(session, mem_ctx, blob,
+ smbcli_blob_pull_string(session, mem_ctx, blob,
&parms->stream_info.out.streams[n].stream_name,
ofs+4, ofs+24, STR_UNICODE);
parms->stream_info.out.num_streams++;
FINFO_CHECK_SIZE(100);
parms->unix_basic_info.out.end_of_file = BVAL(blob->data, 0);
parms->unix_basic_info.out.num_bytes = BVAL(blob->data, 8);
- parms->unix_basic_info.out.status_change_time = cli_pull_nttime(blob->data, 16);
- parms->unix_basic_info.out.access_time = cli_pull_nttime(blob->data, 24);
- parms->unix_basic_info.out.change_time = cli_pull_nttime(blob->data, 32);
+ parms->unix_basic_info.out.status_change_time = smbcli_pull_nttime(blob->data, 16);
+ parms->unix_basic_info.out.access_time = smbcli_pull_nttime(blob->data, 24);
+ parms->unix_basic_info.out.change_time = smbcli_pull_nttime(blob->data, 32);
parms->unix_basic_info.out.uid = BVAL(blob->data, 40);
parms->unix_basic_info.out.gid = BVAL(blob->data, 48);
parms->unix_basic_info.out.file_type = IVAL(blob->data, 52);
return NT_STATUS_OK;
case RAW_FILEINFO_UNIX_LINK:
- cli_blob_pull_string(session, mem_ctx, blob,
+ smbcli_blob_pull_string(session, mem_ctx, blob,
&parms->unix_link_info.out.link_dest, 0, 4, STR_UNICODE);
return NT_STATUS_OK;
case RAW_FILEINFO_NETWORK_OPEN_INFORMATION:
FINFO_CHECK_SIZE(56);
- parms->network_open_information.out.create_time = cli_pull_nttime(blob->data, 0);
- parms->network_open_information.out.access_time = cli_pull_nttime(blob->data, 8);
- parms->network_open_information.out.write_time = cli_pull_nttime(blob->data, 16);
- parms->network_open_information.out.change_time = cli_pull_nttime(blob->data, 24);
+ parms->network_open_information.out.create_time = smbcli_pull_nttime(blob->data, 0);
+ parms->network_open_information.out.access_time = smbcli_pull_nttime(blob->data, 8);
+ parms->network_open_information.out.write_time = smbcli_pull_nttime(blob->data, 16);
+ parms->network_open_information.out.change_time = smbcli_pull_nttime(blob->data, 24);
parms->network_open_information.out.alloc_size = BVAL(blob->data, 32);
parms->network_open_information.out.size = BVAL(blob->data, 40);
parms->network_open_information.out.attrib = IVAL(blob->data, 48);
/****************************************************************************
Very raw query file info - returns param/data blobs - (async send)
****************************************************************************/
-static struct cli_request *smb_raw_fileinfo_blob_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_fileinfo_blob_send(struct smbcli_tree *tree,
uint16_t fnum, uint16_t info_level)
{
struct smb_trans2 tp;
uint16_t setup = TRANSACT2_QFILEINFO;
- struct cli_request *req;
+ struct smbcli_request *req;
TALLOC_CTX *mem_ctx = talloc_init("raw_fileinfo");
tp.in.max_setup = 0;
/****************************************************************************
Very raw query file info - returns param/data blobs - (async recv)
****************************************************************************/
-static NTSTATUS smb_raw_fileinfo_blob_recv(struct cli_request *req,
+static NTSTATUS smb_raw_fileinfo_blob_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
DATA_BLOB *blob)
{
/****************************************************************************
Very raw query path info - returns param/data blobs (async send)
****************************************************************************/
-static struct cli_request *smb_raw_pathinfo_blob_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_pathinfo_blob_send(struct smbcli_tree *tree,
const char *fname,
uint16_t info_level)
{
struct smb_trans2 tp;
uint16_t setup = TRANSACT2_QPATHINFO;
- struct cli_request *req;
+ struct smbcli_request *req;
TALLOC_CTX *mem_ctx = talloc_init("raw_pathinfo");
tp.in.max_setup = 0;
SSVAL(tp.in.params.data, 0, info_level);
SIVAL(tp.in.params.data, 2, 0);
- cli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
+ smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
fname, STR_TERMINATE);
req = smb_raw_trans2_send(tree, &tp);
/****************************************************************************
send a SMBgetatr (async send)
****************************************************************************/
-static struct cli_request *smb_raw_getattr_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_getattr_send(struct smbcli_tree *tree,
union smb_fileinfo *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBgetatr, 0, 0);
+ req = smbcli_request_setup(tree, SMBgetatr, 0, 0);
if (!req) return NULL;
- cli_req_append_ascii4(req, parms->getattr.in.fname, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->getattr.in.fname, STR_TERMINATE);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
send a SMBgetatr (async recv)
****************************************************************************/
-static NTSTATUS smb_raw_getattr_recv(struct cli_request *req,
+static NTSTATUS smb_raw_getattr_recv(struct smbcli_request *req,
union smb_fileinfo *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
- CLI_CHECK_WCT(req, 10);
+ SMBCLI_CHECK_WCT(req, 10);
parms->getattr.out.attrib = SVAL(req->in.vwv, VWV(0));
parms->getattr.out.write_time = raw_pull_dos_date3(req->transport,
req->in.vwv + VWV(1));
parms->getattr.out.size = IVAL(req->in.vwv, VWV(3));
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Handle SMBgetattrE (async send)
****************************************************************************/
-static struct cli_request *smb_raw_getattrE_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_getattrE_send(struct smbcli_tree *tree,
union smb_fileinfo *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBgetattrE, 1, 0);
+ req = smbcli_request_setup(tree, SMBgetattrE, 1, 0);
if (!req) return NULL;
SSVAL(req->out.vwv, VWV(0), parms->getattre.in.fnum);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Handle SMBgetattrE (async send)
****************************************************************************/
-static NTSTATUS smb_raw_getattrE_recv(struct cli_request *req,
+static NTSTATUS smb_raw_getattrE_recv(struct smbcli_request *req,
union smb_fileinfo *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
- CLI_CHECK_WCT(req, 11);
+ SMBCLI_CHECK_WCT(req, 11);
parms->getattre.out.create_time = raw_pull_dos_date2(req->transport,
req->in.vwv + VWV(0));
parms->getattre.out.access_time = raw_pull_dos_date2(req->transport,
parms->getattre.out.attrib = SVAL(req->in.vwv, VWV(10));
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Query file info (async send)
****************************************************************************/
-struct cli_request *smb_raw_fileinfo_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_fileinfo_send(struct smbcli_tree *tree,
union smb_fileinfo *parms)
{
/* pass off the non-trans2 level to specialised functions */
/****************************************************************************
Query file info (async recv)
****************************************************************************/
-NTSTATUS smb_raw_fileinfo_recv(struct cli_request *req,
+NTSTATUS smb_raw_fileinfo_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
union smb_fileinfo *parms)
{
DATA_BLOB blob;
NTSTATUS status;
- struct cli_session *session = req?req->session:NULL;
+ struct smbcli_session *session = req?req->session:NULL;
if (parms->generic.level == RAW_FILEINFO_GETATTRE) {
return smb_raw_getattrE_recv(req, parms);
/****************************************************************************
Query file info (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_fileinfo(struct cli_tree *tree,
+NTSTATUS smb_raw_fileinfo(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_fileinfo *parms)
{
- struct cli_request *req = smb_raw_fileinfo_send(tree, parms);
+ struct smbcli_request *req = smb_raw_fileinfo_send(tree, parms);
return smb_raw_fileinfo_recv(req, mem_ctx, parms);
}
/****************************************************************************
Query path info (async send)
****************************************************************************/
-struct cli_request *smb_raw_pathinfo_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_pathinfo_send(struct smbcli_tree *tree,
union smb_fileinfo *parms)
{
if (parms->generic.level == RAW_FILEINFO_GETATTR) {
/****************************************************************************
Query path info (async recv)
****************************************************************************/
-NTSTATUS smb_raw_pathinfo_recv(struct cli_request *req,
+NTSTATUS smb_raw_pathinfo_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
union smb_fileinfo *parms)
{
/****************************************************************************
Query path info (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_pathinfo(struct cli_tree *tree,
+NTSTATUS smb_raw_pathinfo(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_fileinfo *parms)
{
- struct cli_request *req = smb_raw_pathinfo_send(tree, parms);
+ struct smbcli_request *req = smb_raw_pathinfo_send(tree, parms);
return smb_raw_pathinfo_recv(req, mem_ctx, parms);
}
/****************************************************************************
Query FS Info - SMBdskattr call (async send)
****************************************************************************/
-static struct cli_request *smb_raw_dskattr_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_dskattr_send(struct smbcli_tree *tree,
union smb_fsinfo *fsinfo)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBdskattr, 0, 0);
+ req = smbcli_request_setup(tree, SMBdskattr, 0, 0);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Query FS Info - SMBdskattr call (async recv)
****************************************************************************/
-static NTSTATUS smb_raw_dskattr_recv(struct cli_request *req,
+static NTSTATUS smb_raw_dskattr_recv(struct smbcli_request *req,
union smb_fsinfo *fsinfo)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
goto failed;
}
- CLI_CHECK_WCT(req, 5);
+ SMBCLI_CHECK_WCT(req, 5);
fsinfo->dskattr.out.units_total = SVAL(req->in.vwv, VWV(0));
fsinfo->dskattr.out.blocks_per_unit = SVAL(req->in.vwv, VWV(1));
fsinfo->dskattr.out.block_size = SVAL(req->in.vwv, VWV(2));
fsinfo->dskattr.out.units_free = SVAL(req->in.vwv, VWV(3));
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
RAW_QFS_ trans2 interface via blobs (async send)
****************************************************************************/
-static struct cli_request *smb_raw_qfsinfo_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_qfsinfo_send(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
uint16_t info_level)
{
/****************************************************************************
RAW_QFS_ trans2 interface via blobs (async recv)
****************************************************************************/
-static NTSTATUS smb_raw_qfsinfo_blob_recv(struct cli_request *req,
+static NTSTATUS smb_raw_qfsinfo_blob_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
DATA_BLOB *blob)
{
/****************************************************************************
Query FSInfo raw interface (async send)
****************************************************************************/
-struct cli_request *smb_raw_fsinfo_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_fsinfo_send(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_fsinfo *fsinfo)
{
/****************************************************************************
Query FSInfo raw interface (async recv)
****************************************************************************/
-NTSTATUS smb_raw_fsinfo_recv(struct cli_request *req,
+NTSTATUS smb_raw_fsinfo_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
union smb_fsinfo *fsinfo)
{
DATA_BLOB blob;
NTSTATUS status;
int i;
- struct cli_session *session = req?req->session:NULL;
+ struct smbcli_session *session = req?req->session:NULL;
if (fsinfo->generic.level == RAW_QFS_DSKATTR) {
return smb_raw_dskattr_recv(req, fsinfo);
case RAW_QFS_VOLUME:
QFS_CHECK_MIN_SIZE(5);
fsinfo->volume.out.serial_number = IVAL(blob.data, 0);
- cli_blob_pull_string(session, mem_ctx, &blob,
+ smbcli_blob_pull_string(session, mem_ctx, &blob,
&fsinfo->volume.out.volume_name,
4, 5, STR_LEN8BIT | STR_NOALIGN);
break;
case RAW_QFS_VOLUME_INFO:
case RAW_QFS_VOLUME_INFORMATION:
QFS_CHECK_MIN_SIZE(18);
- fsinfo->volume_info.out.create_time = cli_pull_nttime(blob.data, 0);
+ fsinfo->volume_info.out.create_time = smbcli_pull_nttime(blob.data, 0);
fsinfo->volume_info.out.serial_number = IVAL(blob.data, 8);
- cli_blob_pull_string(session, mem_ctx, &blob,
+ smbcli_blob_pull_string(session, mem_ctx, &blob,
&fsinfo->volume_info.out.volume_name,
12, 18, STR_UNICODE);
break;
QFS_CHECK_MIN_SIZE(12);
fsinfo->attribute_info.out.fs_attr = IVAL(blob.data, 0);
fsinfo->attribute_info.out.max_file_component_length = IVAL(blob.data, 4);
- cli_blob_pull_string(session, mem_ctx, &blob,
+ smbcli_blob_pull_string(session, mem_ctx, &blob,
&fsinfo->attribute_info.out.fs_type,
8, 12, STR_UNICODE);
break;
/****************************************************************************
Query FSInfo raw interface (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_fsinfo(struct cli_tree *tree,
+NTSTATUS smb_raw_fsinfo(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_fsinfo *fsinfo)
{
- struct cli_request *req = smb_raw_fsinfo_send(tree, mem_ctx, fsinfo);
+ struct smbcli_request *req = smb_raw_fsinfo_send(tree, mem_ctx, fsinfo);
return smb_raw_fsinfo_recv(req, mem_ctx, fsinfo);
}
#include "includes.h"
#define SETUP_REQUEST(cmd, wct, buflen) do { \
- req = cli_request_setup(tree, cmd, wct, buflen); \
+ req = smbcli_request_setup(tree, cmd, wct, buflen); \
if (!req) return NULL; \
} while (0)
/*
send a raw smb ioctl - async send
*/
-static struct cli_request *smb_raw_smbioctl_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_smbioctl_send(struct smbcli_tree *tree,
union smb_ioctl *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
SETUP_REQUEST(SMBioctl, 3, 0);
SSVAL(req->out.vwv, VWV(0), parms->ioctl.in.fnum);
SIVAL(req->out.vwv, VWV(1), parms->ioctl.in.request);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/*
send a raw smb ioctl - async recv
*/
-static NTSTATUS smb_raw_smbioctl_recv(struct cli_request *req,
+static NTSTATUS smb_raw_smbioctl_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
union smb_ioctl *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
- parms->ioctl.out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1);
- return cli_request_destroy(req);
+ parms->ioctl.out.blob = smbcli_req_pull_blob(req, mem_ctx, req->in.data, -1);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
NT ioctl (async send)
****************************************************************************/
-static struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_ntioctl_send(struct smbcli_tree *tree,
union smb_ioctl *parms)
{
struct smb_nttrans nt;
/****************************************************************************
NT ioctl (async recv)
****************************************************************************/
-static NTSTATUS smb_raw_ntioctl_recv(struct cli_request *req,
+static NTSTATUS smb_raw_ntioctl_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
union smb_ioctl *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
- parms->ntioctl.out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1);
- return cli_request_destroy(req);
+ parms->ntioctl.out.blob = smbcli_req_pull_blob(req, mem_ctx, req->in.data, -1);
+ return smbcli_request_destroy(req);
}
/*
send a raw ioctl - async send
*/
-struct cli_request *smb_raw_ioctl_send(struct cli_tree *tree, union smb_ioctl *parms)
+struct smbcli_request *smb_raw_ioctl_send(struct smbcli_tree *tree, union smb_ioctl *parms)
{
- struct cli_request *req = NULL;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_IOCTL_IOCTL:
/*
recv a raw ioctl - async recv
*/
-NTSTATUS smb_raw_ioctl_recv(struct cli_request *req,
+NTSTATUS smb_raw_ioctl_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx, union smb_ioctl *parms)
{
switch (parms->generic.level) {
/*
send a raw ioctl - sync interface
*/
-NTSTATUS smb_raw_ioctl(struct cli_tree *tree,
+NTSTATUS smb_raw_ioctl(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx, union smb_ioctl *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
req = smb_raw_ioctl_send(tree, parms);
return smb_raw_ioctl_recv(req, mem_ctx, parms);
}
/****************************************************************************
Send a negprot command.
****************************************************************************/
-struct cli_request *smb_negprot_send(struct cli_transport *transport, int maxprotocol)
+struct smbcli_request *smb_negprot_send(struct smbcli_transport *transport, int maxprotocol)
{
- struct cli_request *req;
+ struct smbcli_request *req;
int i;
uint16_t flags2 = 0;
- req = cli_request_setup_transport(transport, SMBnegprot, 0, 0);
+ req = smbcli_request_setup_transport(transport, SMBnegprot, 0, 0);
if (!req) {
return NULL;
}
/* setup the protocol strings */
for (i=0; i < ARRAY_SIZE(prots) && prots[i].prot <= maxprotocol; i++) {
- cli_req_append_bytes(req, "\2", 1);
- cli_req_append_string(req, prots[i].name, STR_TERMINATE | STR_ASCII);
+ smbcli_req_append_bytes(req, "\2", 1);
+ smbcli_req_append_string(req, prots[i].name, STR_TERMINATE | STR_ASCII);
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Send a negprot command.
****************************************************************************/
-NTSTATUS smb_raw_negotiate(struct cli_transport *transport)
+NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport)
{
- struct cli_request *req;
+ struct smbcli_request *req;
int protocol;
req = smb_negprot_send(transport, PROTOCOL_NT1);
return NT_STATUS_UNSUCCESSFUL;
}
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
- CLI_CHECK_MIN_WCT(req, 1);
+ SMBCLI_CHECK_MIN_WCT(req, 1);
protocol = SVALS(req->in.vwv, VWV(0));
if (protocol >= ARRAY_SIZE(prots) || protocol < 0) {
req->status = NT_STATUS_UNSUCCESSFUL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
transport->negotiate.protocol = prots[protocol].prot;
NTTIME ntt;
/* NT protocol */
- CLI_CHECK_WCT(req, 17);
+ SMBCLI_CHECK_WCT(req, 17);
transport->negotiate.sec_mode = CVAL(req->in.vwv,VWV(1));
transport->negotiate.max_mux = SVAL(req->in.vwv,VWV(1)+1);
transport->negotiate.max_xmit = IVAL(req->in.vwv,VWV(3)+1);
transport->negotiate.capabilities = IVAL(req->in.vwv,VWV(9)+1);
/* this time arrives in real GMT */
- ntt = cli_pull_nttime(req->in.vwv, VWV(11)+1);
+ ntt = smbcli_pull_nttime(req->in.vwv, VWV(11)+1);
transport->negotiate.server_time = nt_time_to_unix(ntt);
transport->negotiate.server_zone = SVALS(req->in.vwv,VWV(15)+1) * 60;
transport->negotiate.key_len = CVAL(req->in.vwv,VWV(16)+1);
if (req->in.data_size < 16) {
goto failed;
}
- transport->negotiate.server_guid = cli_req_pull_blob(req, transport->mem_ctx, req->in.data, 16);
- transport->negotiate.secblob = cli_req_pull_blob(req, transport->mem_ctx, req->in.data + 16, req->in.data_size - 16);
+ transport->negotiate.server_guid = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data, 16);
+ transport->negotiate.secblob = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data + 16, req->in.data_size - 16);
} else {
if (req->in.data_size < (transport->negotiate.key_len)) {
goto failed;
}
- transport->negotiate.secblob = cli_req_pull_blob(req, transport->mem_ctx, req->in.data, transport->negotiate.key_len);
- cli_req_pull_string(req, transport->mem_ctx, &transport->negotiate.server_domain,
+ transport->negotiate.secblob = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data, transport->negotiate.key_len);
+ smbcli_req_pull_string(req, transport->mem_ctx, &transport->negotiate.server_domain,
req->in.data+transport->negotiate.key_len,
req->in.data_size-transport->negotiate.key_len, STR_UNICODE|STR_NOALIGN);
/* here comes the server name */
transport->negotiate.writebraw_supported = True;
}
} else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) {
- CLI_CHECK_WCT(req, 13);
+ SMBCLI_CHECK_WCT(req, 13);
transport->negotiate.sec_mode = SVAL(req->in.vwv,VWV(1));
transport->negotiate.max_xmit = SVAL(req->in.vwv,VWV(2));
transport->negotiate.sesskey = IVAL(req->in.vwv,VWV(6));
if ((SVAL(req->in.vwv,VWV(5)) & 0x2)) {
transport->negotiate.writebraw_supported = 1;
}
- transport->negotiate.secblob = cli_req_pull_blob(req, transport->mem_ctx,
+ transport->negotiate.secblob = smbcli_req_pull_blob(req, transport->mem_ctx,
req->in.data, req->in.data_size);
} else {
/* the old core protocol */
}
/* a way to force ascii SMB */
- if (getenv("CLI_FORCE_ASCII")) {
+ if (getenv("SMBCLI_FORCE_ASCII")) {
transport->negotiate.capabilities &= ~CAP_UNICODE;
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
change notify (async send)
****************************************************************************/
-struct cli_request *smb_raw_changenotify_send(struct cli_tree *tree, struct smb_notify *parms)
+struct smbcli_request *smb_raw_changenotify_send(struct smbcli_tree *tree, struct smb_notify *parms)
{
struct smb_nttrans nt;
uint16_t setup[4];
/****************************************************************************
change notify (async recv)
****************************************************************************/
-NTSTATUS smb_raw_changenotify_recv(struct cli_request *req,
+NTSTATUS smb_raw_changenotify_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx, struct smb_notify *parms)
{
struct smb_nttrans nt;
NTSTATUS status;
uint32_t ofs, i;
- struct cli_session *session = req?req->session:NULL;
+ struct smbcli_session *session = req?req->session:NULL;
status = smb_raw_nttrans_recv(req, mem_ctx, &nt);
if (!NT_STATUS_IS_OK(status)) {
for (i=ofs=0; i<parms->out.num_changes; i++) {
parms->out.changes[i].action = IVAL(nt.out.params.data, ofs+4);
- cli_blob_pull_string(session, mem_ctx, &nt.out.params,
+ smbcli_blob_pull_string(session, mem_ctx, &nt.out.params,
&parms->out.changes[i].name,
ofs+8, ofs+12, STR_UNICODE);
ofs += IVAL(nt.out.params.data, ofs);
used to cancel a pending change notify request
note that this request does not expect a response!
****************************************************************************/
-NTSTATUS smb_raw_ntcancel(struct cli_request *oldreq)
+NTSTATUS smb_raw_ntcancel(struct smbcli_request *oldreq)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup_transport(oldreq->transport, SMBntcancel, 0, 0);
+ req = smbcli_request_setup_transport(oldreq->transport, SMBntcancel, 0, 0);
SSVAL(req->out.hdr, HDR_MID, SVAL(oldreq->out.hdr, HDR_MID));
SSVAL(req->out.hdr, HDR_PID, SVAL(oldreq->out.hdr, HDR_PID));
req->sign_single_increment = 1;
req->one_way_request = 1;
- cli_request_send(req);
+ smbcli_request_send(req);
return NT_STATUS_OK;
}
#include "includes.h"
#define SETUP_REQUEST(cmd, wct, buflen) do { \
- req = cli_request_setup(tree, cmd, wct, buflen); \
+ req = smbcli_request_setup(tree, cmd, wct, buflen); \
if (!req) return NULL; \
} while (0)
/****************************************************************************
low level read operation (async send)
****************************************************************************/
-struct cli_request *smb_raw_read_send(struct cli_tree *tree, union smb_read *parms)
+struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms)
{
BOOL bigoffset = False;
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->generic.level) {
case RAW_READ_GENERIC:
break;
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
low level read operation (async recv)
****************************************************************************/
-NTSTATUS smb_raw_read_recv(struct cli_request *req, union smb_read *parms)
+NTSTATUS smb_raw_read_recv(struct smbcli_request *req, union smb_read *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
goto failed;
}
break;
case RAW_READ_LOCKREAD:
- CLI_CHECK_WCT(req, 5);
+ SMBCLI_CHECK_WCT(req, 5);
parms->lockread.out.nread = SVAL(req->in.vwv, VWV(0));
if (parms->lockread.out.nread > parms->lockread.in.count ||
- !cli_raw_pull_data(req, req->in.data+3,
+ !smbcli_raw_pull_data(req, req->in.data+3,
parms->lockread.out.nread, parms->lockread.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
}
case RAW_READ_READ:
/* there are 4 reserved words in the reply */
- CLI_CHECK_WCT(req, 5);
+ SMBCLI_CHECK_WCT(req, 5);
parms->read.out.nread = SVAL(req->in.vwv, VWV(0));
if (parms->read.out.nread > parms->read.in.count ||
- !cli_raw_pull_data(req, req->in.data+3,
+ !smbcli_raw_pull_data(req, req->in.data+3,
parms->read.out.nread, parms->read.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
}
case RAW_READ_READX:
/* there are 5 reserved words in the reply */
- CLI_CHECK_WCT(req, 12);
+ SMBCLI_CHECK_WCT(req, 12);
parms->readx.out.remaining = SVAL(req->in.vwv, VWV(2));
parms->readx.out.compaction_mode = SVAL(req->in.vwv, VWV(3));
parms->readx.out.nread = SVAL(req->in.vwv, VWV(5));
if (parms->readx.out.nread > MAX(parms->readx.in.mincnt, parms->readx.in.maxcnt) ||
- !cli_raw_pull_data(req, req->in.hdr + SVAL(req->in.vwv, VWV(6)),
+ !smbcli_raw_pull_data(req, req->in.hdr + SVAL(req->in.vwv, VWV(6)),
parms->readx.out.nread,
parms->readx.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
low level read operation (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_read(struct cli_tree *tree, union smb_read *parms)
+NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms)
{
- struct cli_request *req = smb_raw_read_send(tree, parms);
+ struct smbcli_request *req = smb_raw_read_send(tree, parms);
return smb_raw_read_recv(req, parms);
}
/****************************************************************************
raw write interface (async send)
****************************************************************************/
-struct cli_request *smb_raw_write_send(struct cli_tree *tree, union smb_write *parms)
+struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_write *parms)
{
BOOL bigoffset = False;
- struct cli_request *req;
+ struct smbcli_request *req;
switch (parms->generic.level) {
case RAW_WRITE_GENERIC:
break;
}
- if (!cli_request_send(req)) {
-cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
raw write interface (async recv)
****************************************************************************/
-NTSTATUS smb_raw_write_recv(struct cli_request *req, union smb_write *parms)
+NTSTATUS smb_raw_write_recv(struct smbcli_request *req, union smb_write *parms)
{
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
goto failed;
}
case RAW_WRITE_GENERIC:
break;
case RAW_WRITE_WRITEUNLOCK:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->writeunlock.out.nwritten = SVAL(req->in.vwv, VWV(0));
break;
case RAW_WRITE_WRITE:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->write.out.nwritten = SVAL(req->in.vwv, VWV(0));
break;
case RAW_WRITE_WRITECLOSE:
- CLI_CHECK_WCT(req, 1);
+ SMBCLI_CHECK_WCT(req, 1);
parms->writeclose.out.nwritten = SVAL(req->in.vwv, VWV(0));
break;
case RAW_WRITE_WRITEX:
- CLI_CHECK_WCT(req, 6);
+ SMBCLI_CHECK_WCT(req, 6);
parms->writex.out.nwritten = SVAL(req->in.vwv, VWV(2));
parms->writex.out.nwritten += (CVAL(req->in.vwv, VWV(4)) << 16);
parms->writex.out.remaining = SVAL(req->in.vwv, VWV(3));
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
raw write interface (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_write(struct cli_tree *tree, union smb_write *parms)
+NTSTATUS smb_raw_write(struct smbcli_tree *tree, union smb_write *parms)
{
- struct cli_request *req = smb_raw_write_send(tree, parms);
+ struct smbcli_request *req = smb_raw_write_send(tree, parms);
return smb_raw_write_recv(req, parms);
}
*/
/*
- this file implements functions for manipulating the 'struct cli_request' structure in libsmb
+ this file implements functions for manipulating the 'struct smbcli_request' structure in libsmb
*/
#include "includes.h"
#define MAX_BYTES_PER_CHAR 3
/* destroy a request structure and return final status */
-NTSTATUS cli_request_destroy(struct cli_request *req)
+NTSTATUS smbcli_request_destroy(struct smbcli_request *req)
{
NTSTATUS status;
low-level function to setup a request buffer for a non-SMB packet
at the transport level
*/
-struct cli_request *cli_request_setup_nonsmb(struct cli_transport *transport, uint_t size)
+struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *transport, uint_t size)
{
- struct cli_request *req;
+ struct smbcli_request *req;
TALLOC_CTX *mem_ctx;
/* each request gets its own talloc context. The request
structure itself is also allocated inside this context,
so we need to allocate it before we construct the request
*/
- mem_ctx = talloc_init("cli_request");
+ mem_ctx = talloc_init("smbcli_request");
if (!mem_ctx) {
return NULL;
}
- req = talloc(mem_ctx, sizeof(struct cli_request));
+ req = talloc(mem_ctx, sizeof(struct smbcli_request));
if (!req) {
return NULL;
}
ZERO_STRUCTP(req);
/* setup the request context */
- req->state = CLI_REQUEST_INIT;
+ req->state = SMBCLI_REQUEST_INIT;
req->mem_ctx = mem_ctx;
req->transport = transport;
req->session = NULL;
/*
setup a SMB packet at transport level
*/
-struct cli_request *cli_request_setup_transport(struct cli_transport *transport,
+struct smbcli_request *smbcli_request_setup_transport(struct smbcli_transport *transport,
uint8_t command, uint_t wct, uint_t buflen)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup_nonsmb(transport, NBT_HDR_SIZE + MIN_SMB_SIZE + wct*2 + buflen);
+ req = smbcli_request_setup_nonsmb(transport, NBT_HDR_SIZE + MIN_SMB_SIZE + wct*2 + buflen);
if (!req) return NULL;
SSVAL(req->out.hdr,HDR_FLG2, 0);
/* assign a mid */
- req->mid = cli_transport_next_mid(transport);
+ req->mid = smbcli_transport_next_mid(transport);
/* copy the pid, uid and mid to the request */
SSVAL(req->out.hdr, HDR_PID, 0);
/*
setup a reply in req->out with the given word count and initial data
buffer size. the caller will then fill in the command words and
- data before calling cli_request_send() to send the reply on its
+ data before calling smbcli_request_send() to send the reply on its
way. This interface is used before a session is setup.
*/
-struct cli_request *cli_request_setup_session(struct cli_session *session,
+struct smbcli_request *smbcli_request_setup_session(struct smbcli_session *session,
uint8_t command, uint_t wct, uint_t buflen)
{
- struct cli_request *req;
+ struct smbcli_request *req;
uint16_t flags2;
uint32_t capabilities;
- req = cli_request_setup_transport(session->transport, command, wct, buflen);
+ req = smbcli_request_setup_transport(session->transport, command, wct, buflen);
if (!req) return NULL;
/*
setup a request for tree based commands
*/
-struct cli_request *cli_request_setup(struct cli_tree *tree,
+struct smbcli_request *smbcli_request_setup(struct smbcli_tree *tree,
uint8_t command,
uint_t wct, uint_t buflen)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup_session(tree->session, command, wct, buflen);
+ req = smbcli_request_setup_session(tree->session, command, wct, buflen);
if (req) {
req->tree = tree;
SSVAL(req->out.hdr,HDR_TID,tree->tid);
To cope with this req->out.ptr is supplied. This will be updated to
point at the same offset into the packet as before this call
*/
-static void cli_req_grow_allocation(struct cli_request *req, uint_t new_size)
+static void smbcli_req_grow_allocation(struct smbcli_request *req, uint_t new_size)
{
int delta;
char *buf2;
To cope with this req->out.ptr is supplied. This will be updated to
point at the same offset into the packet as before this call
*/
-static void cli_req_grow_data(struct cli_request *req, uint_t new_size)
+static void smbcli_req_grow_data(struct smbcli_request *req, uint_t new_size)
{
int delta;
- cli_req_grow_allocation(req, new_size);
+ smbcli_req_grow_allocation(req, new_size);
delta = new_size - req->out.data_size;
/*
send a message
*/
-BOOL cli_request_send(struct cli_request *req)
+BOOL smbcli_request_send(struct smbcli_request *req)
{
if (IVAL(req->out.buffer, 0) == 0) {
_smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE);
}
- cli_request_calculate_sign_mac(req);
+ smbcli_request_calculate_sign_mac(req);
- cli_transport_send(req);
+ smbcli_transport_send(req);
return True;
}
/*
receive a response to a packet
*/
-BOOL cli_request_receive(struct cli_request *req)
+BOOL smbcli_request_receive(struct smbcli_request *req)
{
/* req can be NULL when a send has failed. This eliminates lots of NULL
checks in each module */
if (!req) return False;
/* keep receiving packets until this one is replied to */
- while (req->state <= CLI_REQUEST_RECV) {
+ while (req->state <= SMBCLI_REQUEST_RECV) {
event_loop_once(req->transport->event.ctx);
}
receive another reply to a request - this is used for requests that
have multi-part replies (such as SMBtrans2)
*/
-BOOL cli_request_receive_more(struct cli_request *req)
+BOOL smbcli_request_receive_more(struct smbcli_request *req)
{
- req->state = CLI_REQUEST_RECV;
+ req->state = SMBCLI_REQUEST_RECV;
DLIST_ADD(req->transport->pending_recv, req);
- return cli_request_receive(req);
+ return smbcli_request_receive(req);
}
handle oplock break requests from the server - return True if the request was
an oplock break
*/
-BOOL handle_oplock_break(struct cli_transport *transport, uint_t len, const char *hdr, const char *vwv)
+BOOL handle_oplock_break(struct smbcli_transport *transport, uint_t len, const char *hdr, const char *vwv)
{
/* we must be very fussy about what we consider an oplock break to avoid
matching readbraw replies */
wait for a reply to be received for a packet that just returns an error
code and nothing more
*/
-NTSTATUS cli_request_simple_recv(struct cli_request *req)
+NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req)
{
- cli_request_receive(req);
- return cli_request_destroy(req);
+ smbcli_request_receive(req);
+ return smbcli_request_destroy(req);
}
/* Return true if the last packet was in error */
-BOOL cli_request_is_error(struct cli_request *req)
+BOOL smbcli_request_is_error(struct smbcli_request *req)
{
return NT_STATUS_IS_ERR(req->status);
}
return the number of bytes added to the packet
*/
-size_t cli_req_append_string(struct cli_request *req, const char *str, uint_t flags)
+size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, uint_t flags)
{
size_t len;
len = (strlen(str)+2) * MAX_BYTES_PER_CHAR;
- cli_req_grow_allocation(req, len + req->out.data_size);
+ smbcli_req_grow_allocation(req, len + req->out.data_size);
len = push_string(NULL, req->out.data + req->out.data_size, str, len, flags);
- cli_req_grow_data(req, len + req->out.data_size);
+ smbcli_req_grow_data(req, len + req->out.data_size);
return len;
}
/*
- this is like cli_req_append_string but it also return the
+ this is like smbcli_req_append_string but it also return the
non-terminated string byte length, which can be less than the number
of bytes consumed in the packet for 2 reasons:
this is used in places where the non-terminated string byte length is
placed in the packet as a separate field
*/
-size_t cli_req_append_string_len(struct cli_request *req, const char *str, uint_t flags, int *len)
+size_t smbcli_req_append_string_len(struct smbcli_request *req, const char *str, uint_t flags, int *len)
{
int diff = 0;
size_t ret;
}
/* do the hard work */
- ret = cli_req_append_string(req, str, flags);
+ ret = smbcli_req_append_string(req, str, flags);
/* see if we need to subtract the termination */
if (flags & STR_TERMINATE) {
if dest_len is -1 then no limit applies
*/
-size_t cli_req_append_ascii4(struct cli_request *req, const char *str, uint_t flags)
+size_t smbcli_req_append_ascii4(struct smbcli_request *req, const char *str, uint_t flags)
{
size_t size;
- cli_req_append_bytes(req, (const uint8_t *)"\4", 1);
- size = cli_req_append_string(req, str, flags);
+ smbcli_req_append_bytes(req, (const uint8_t *)"\4", 1);
+ size = smbcli_req_append_string(req, str, flags);
return size + 1;
}
if dest is NULL, then put the blob at the end of the data portion of the packet
*/
-size_t cli_req_append_blob(struct cli_request *req, const DATA_BLOB *blob)
+size_t smbcli_req_append_blob(struct smbcli_request *req, const DATA_BLOB *blob)
{
- cli_req_grow_allocation(req, req->out.data_size + blob->length);
+ smbcli_req_grow_allocation(req, req->out.data_size + blob->length);
memcpy(req->out.data + req->out.data_size, blob->data, blob->length);
- cli_req_grow_data(req, req->out.data_size + blob->length);
+ smbcli_req_grow_data(req, req->out.data_size + blob->length);
return blob->length;
}
append raw bytes into the data portion of the request packet
return the number of bytes added
*/
-size_t cli_req_append_bytes(struct cli_request *req, const uint8_t *bytes, size_t byte_len)
+size_t smbcli_req_append_bytes(struct smbcli_request *req, const uint8_t *bytes, size_t byte_len)
{
- cli_req_grow_allocation(req, byte_len + req->out.data_size);
+ smbcli_req_grow_allocation(req, byte_len + req->out.data_size);
memcpy(req->out.data + req->out.data_size, bytes, byte_len);
- cli_req_grow_data(req, byte_len + req->out.data_size);
+ smbcli_req_grow_data(req, byte_len + req->out.data_size);
return byte_len;
}
append variable block (type 5 buffer) into the data portion of the request packet
return the number of bytes added
*/
-size_t cli_req_append_var_block(struct cli_request *req, const uint8_t *bytes, uint16_t byte_len)
+size_t smbcli_req_append_var_block(struct smbcli_request *req, const uint8_t *bytes, uint16_t byte_len)
{
- cli_req_grow_allocation(req, byte_len + 3 + req->out.data_size);
+ smbcli_req_grow_allocation(req, byte_len + 3 + req->out.data_size);
SCVAL(req->out.data + req->out.data_size, 0, 5);
SSVAL(req->out.data + req->out.data_size, 1, byte_len); /* add field length */
if (byte_len > 0) {
memcpy(req->out.data + req->out.data_size + 3, bytes, byte_len);
}
- cli_req_grow_data(req, byte_len + 3 + req->out.data_size);
+ smbcli_req_grow_data(req, byte_len + 3 + req->out.data_size);
return byte_len + 3;
}
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-static size_t cli_req_pull_ucs2(struct cli_request *req, TALLOC_CTX *mem_ctx,
+static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
char **dest, const char *src, int byte_len, uint_t flags)
{
int src_len, src_len2, alignment=0;
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-size_t cli_req_pull_ascii(struct cli_request *req, TALLOC_CTX *mem_ctx,
+size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
char **dest, const char *src, int byte_len, uint_t flags)
{
int src_len, src_len2;
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-size_t cli_req_pull_string(struct cli_request *req, TALLOC_CTX *mem_ctx,
+size_t smbcli_req_pull_string(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
char **dest, const char *src, int byte_len, uint_t flags)
{
if (!(flags & STR_ASCII) &&
(((flags & STR_UNICODE) || (req->flags2 & FLAGS2_UNICODE_STRINGS)))) {
- return cli_req_pull_ucs2(req, mem_ctx, dest, src, byte_len, flags);
+ return smbcli_req_pull_ucs2(req, mem_ctx, dest, src, byte_len, flags);
}
- return cli_req_pull_ascii(req, mem_ctx, dest, src, byte_len, flags);
+ return smbcli_req_pull_ascii(req, mem_ctx, dest, src, byte_len, flags);
}
if byte_len is -1 then limit the blob only by packet size
*/
-DATA_BLOB cli_req_pull_blob(struct cli_request *req, TALLOC_CTX *mem_ctx, const char *src, int byte_len)
+DATA_BLOB smbcli_req_pull_blob(struct smbcli_request *req, TALLOC_CTX *mem_ctx, const char *src, int byte_len)
{
int src_len;
/* check that a lump of data in a request is within the bounds of the data section of
the packet */
-static BOOL cli_req_data_oob(struct cli_request *req, const char *ptr, uint32_t count)
+static BOOL smbcli_req_data_oob(struct smbcli_request *req, const char *ptr, uint32_t count)
{
/* be careful with wraparound! */
if (ptr < req->in.data ||
return False if any part is outside the data portion of the packet
*/
-BOOL cli_raw_pull_data(struct cli_request *req, const char *src, int len, char *dest)
+BOOL smbcli_raw_pull_data(struct smbcli_request *req, const char *src, int len, char *dest)
{
if (len == 0) return True;
- if (cli_req_data_oob(req, src, len)) {
+ if (smbcli_req_data_oob(req, src, len)) {
return False;
}
/*
put a NTTIME into a packet
*/
-void cli_push_nttime(void *base, uint16_t offset, NTTIME t)
+void smbcli_push_nttime(void *base, uint16_t offset, NTTIME t)
{
SBVAL(base, offset, t);
}
/*
pull a NTTIME from a packet
*/
-NTTIME cli_pull_nttime(void *base, uint16_t offset)
+NTTIME smbcli_pull_nttime(void *base, uint16_t offset)
{
NTTIME ret = BVAL(base, offset);
return ret;
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the blob is returned
*/
-static size_t cli_blob_pull_ucs2(TALLOC_CTX* mem_ctx,
+static size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx,
DATA_BLOB *blob, const char **dest,
const char *src, int byte_len, uint_t flags)
{
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the blob is returned
*/
-static size_t cli_blob_pull_ascii(TALLOC_CTX *mem_ctx,
+static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx,
DATA_BLOB *blob, const char **dest,
const char *src, int byte_len, uint_t flags)
{
on failure zero is returned and dest->s is set to NULL, otherwise the number
of bytes consumed in the blob is returned
*/
-size_t cli_blob_pull_string(struct cli_session *session,
+size_t smbcli_blob_pull_string(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
DATA_BLOB *blob,
WIRE_STRING *dest,
if (flags & STR_LEN_NOTERM) {
extra = 2;
}
- return align + extra + cli_blob_pull_ucs2(mem_ctx, blob, &dest->s,
+ return align + extra + smbcli_blob_pull_ucs2(mem_ctx, blob, &dest->s,
blob->data+str_offset+align,
dest->private_length, flags);
}
extra = 1;
}
- return extra + cli_blob_pull_ascii(mem_ctx, blob, &dest->s,
+ return extra + smbcli_blob_pull_ascii(mem_ctx, blob, &dest->s,
blob->data+str_offset, dest->private_length, flags);
}
on failure zero is returned and dest->s is set to NULL, otherwise the number
of bytes consumed in the blob is returned
*/
-size_t cli_blob_pull_unix_string(struct cli_session *session,
+size_t smbcli_blob_pull_unix_string(struct smbcli_session *session,
TALLOC_CTX *mem_ctx,
DATA_BLOB *blob,
const char **dest,
if (flags & STR_LEN_NOTERM) {
extra = 2;
}
- return align + extra + cli_blob_pull_ucs2(mem_ctx, blob, dest,
+ return align + extra + smbcli_blob_pull_ucs2(mem_ctx, blob, dest,
blob->data+str_offset+align,
-1, flags);
}
extra = 1;
}
- return extra + cli_blob_pull_ascii(mem_ctx, blob, dest,
+ return extra + smbcli_blob_pull_ascii(mem_ctx, blob, dest,
blob->data+str_offset, -1, flags);
}
/*
append a string into a blob
*/
-size_t cli_blob_append_string(struct cli_session *session,
+size_t smbcli_blob_append_string(struct smbcli_session *session,
TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
const char *str, uint_t flags)
{
/****************************************************************************
Old style search backend - process output.
****************************************************************************/
-static void smb_raw_search_backend(struct cli_request *req,
+static void smb_raw_search_backend(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
uint16_t count,
void *private,
p = req->in.data + 3;
for (i=0; i < count; i++) {
- search_data.search.search_id = cli_req_pull_blob(req, mem_ctx, p, 21);
+ search_data.search.search_id = smbcli_req_pull_blob(req, mem_ctx, p, 21);
search_data.search.attrib = CVAL(p, 21);
search_data.search.write_time = raw_pull_dos_date(req->transport,
p + 22);
search_data.search.size = IVAL(p, 26);
- cli_req_pull_ascii(req, mem_ctx, &search_data.search.name, p+30, 13, STR_ASCII);
+ smbcli_req_pull_ascii(req, mem_ctx, &search_data.search.name, p+30, 13, STR_ASCII);
if (!callback(private, &search_data)) {
break;
}
/****************************************************************************
Old style search first.
****************************************************************************/
-static NTSTATUS smb_raw_search_first_old(struct cli_tree *tree,
+static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_search_first *io, void *private,
BOOL (*callback)(void *private, union smb_search_data *file))
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBsearch, 2, 0);
+ req = smbcli_request_setup(tree, SMBsearch, 2, 0);
if (!req) {
return NT_STATUS_NO_MEMORY;
}
SSVAL(req->out.vwv, VWV(0), io->search_first.in.max_count);
SSVAL(req->out.vwv, VWV(1), io->search_first.in.search_attrib);
- cli_req_append_ascii4(req, io->search_first.in.pattern, STR_TERMINATE);
- cli_req_append_var_block(req, NULL, 0);
+ smbcli_req_append_ascii4(req, io->search_first.in.pattern, STR_TERMINATE);
+ smbcli_req_append_var_block(req, NULL, 0);
- if (!cli_request_send(req) ||
- !cli_request_receive(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_send(req) ||
+ !smbcli_request_receive(req)) {
+ return smbcli_request_destroy(req);
}
if (NT_STATUS_IS_OK(req->status)) {
smb_raw_search_backend(req, mem_ctx, io->search_first.out.count, private, callback);
}
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Old style search next.
****************************************************************************/
-static NTSTATUS smb_raw_search_next_old(struct cli_tree *tree,
+static NTSTATUS smb_raw_search_next_old(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_search_next *io, void *private,
BOOL (*callback)(void *private, union smb_search_data *file))
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBsearch, 2, 0);
+ req = smbcli_request_setup(tree, SMBsearch, 2, 0);
if (!req) {
return NT_STATUS_NO_MEMORY;
}
SSVAL(req->out.vwv, VWV(0), io->search_next.in.max_count);
SSVAL(req->out.vwv, VWV(1), io->search_next.in.search_attrib);
- cli_req_append_ascii4(req, "", STR_TERMINATE);
- cli_req_append_var_block(req, io->search_next.in.search_id.data, 21);
+ smbcli_req_append_ascii4(req, "", STR_TERMINATE);
+ smbcli_req_append_var_block(req, io->search_next.in.search_id.data, 21);
- if (!cli_request_send(req) ||
- !cli_request_receive(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_send(req) ||
+ !smbcli_request_receive(req)) {
+ return smbcli_request_destroy(req);
}
if (NT_STATUS_IS_OK(req->status)) {
smb_raw_search_backend(req, mem_ctx, io->search_next.out.count, private, callback);
}
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Very raw search first - returns param/data blobs.
****************************************************************************/
-static NTSTATUS smb_raw_search_first_blob(struct cli_tree *tree,
+static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx, /* used to allocate output blobs */
union smb_search_first *io,
uint16_t info_level,
SSVAL(tp.in.params.data, 6, info_level);
SIVAL(tp.in.params.data, 8, io->t2ffirst.in.storage_type);
- cli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
+ smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
io->t2ffirst.in.pattern, STR_TERMINATE);
status = smb_raw_trans2(tree, mem_ctx, &tp);
Very raw search first - returns param/data blobs.
Used in CIFS-on-CIFS NTVFS.
****************************************************************************/
-static NTSTATUS smb_raw_search_next_blob(struct cli_tree *tree,
+static NTSTATUS smb_raw_search_next_blob(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_search_next *io,
uint16_t info_level,
SIVAL(tp.in.params.data, 6, io->t2fnext.in.resume_key);
SSVAL(tp.in.params.data, 10, io->t2fnext.in.flags);
- cli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
+ smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
io->t2fnext.in.last_name,
STR_TERMINATE);
return 0 for success with end of list
return -1 for a parse error
*/
-static int parse_trans2_search(struct cli_tree *tree,
+static int parse_trans2_search(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
enum smb_search_level level,
uint16_t flags,
data->standard.size = IVAL(blob->data, 12);
data->standard.alloc_size = IVAL(blob->data, 16);
data->standard.attrib = SVAL(blob->data, 20);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->standard.name,
22, 23, STR_LEN8BIT | STR_TERMINATE | STR_LEN_NOTERM);
return len + 23;
data->ea_size.alloc_size = IVAL(blob->data, 16);
data->ea_size.attrib = SVAL(blob->data, 20);
data->ea_size.ea_size = IVAL(blob->data, 22);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->ea_size.name,
26, 27, STR_LEN8BIT | STR_TERMINATE | STR_NOALIGN);
return len + 27 + 1;
if (blob->length < 65) return -1;
ofs = IVAL(blob->data, 0);
data->directory_info.file_index = IVAL(blob->data, 4);
- data->directory_info.create_time = cli_pull_nttime(blob->data, 8);
- data->directory_info.access_time = cli_pull_nttime(blob->data, 16);
- data->directory_info.write_time = cli_pull_nttime(blob->data, 24);
- data->directory_info.change_time = cli_pull_nttime(blob->data, 32);
+ data->directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
+ data->directory_info.access_time = smbcli_pull_nttime(blob->data, 16);
+ data->directory_info.write_time = smbcli_pull_nttime(blob->data, 24);
+ data->directory_info.change_time = smbcli_pull_nttime(blob->data, 32);
data->directory_info.size = BVAL(blob->data, 40);
data->directory_info.alloc_size = BVAL(blob->data, 48);
data->directory_info.attrib = IVAL(blob->data, 56);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->directory_info.name,
60, 64, 0);
if (ofs != 0 && ofs < 64+len) {
if (blob->length < 69) return -1;
ofs = IVAL(blob->data, 0);
data->full_directory_info.file_index = IVAL(blob->data, 4);
- data->full_directory_info.create_time = cli_pull_nttime(blob->data, 8);
- data->full_directory_info.access_time = cli_pull_nttime(blob->data, 16);
- data->full_directory_info.write_time = cli_pull_nttime(blob->data, 24);
- data->full_directory_info.change_time = cli_pull_nttime(blob->data, 32);
+ data->full_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
+ data->full_directory_info.access_time = smbcli_pull_nttime(blob->data, 16);
+ data->full_directory_info.write_time = smbcli_pull_nttime(blob->data, 24);
+ data->full_directory_info.change_time = smbcli_pull_nttime(blob->data, 32);
data->full_directory_info.size = BVAL(blob->data, 40);
data->full_directory_info.alloc_size = BVAL(blob->data, 48);
data->full_directory_info.attrib = IVAL(blob->data, 56);
data->full_directory_info.ea_size = IVAL(blob->data, 64);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->full_directory_info.name,
60, 68, 0);
if (ofs != 0 && ofs < 68+len) {
if (blob->length < 13) return -1;
ofs = IVAL(blob->data, 0);
data->name_info.file_index = IVAL(blob->data, 4);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->name_info.name,
8, 12, 0);
if (ofs != 0 && ofs < 12+len) {
if (blob->length < 95) return -1;
ofs = IVAL(blob->data, 0);
data->both_directory_info.file_index = IVAL(blob->data, 4);
- data->both_directory_info.create_time = cli_pull_nttime(blob->data, 8);
- data->both_directory_info.access_time = cli_pull_nttime(blob->data, 16);
- data->both_directory_info.write_time = cli_pull_nttime(blob->data, 24);
- data->both_directory_info.change_time = cli_pull_nttime(blob->data, 32);
+ data->both_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
+ data->both_directory_info.access_time = smbcli_pull_nttime(blob->data, 16);
+ data->both_directory_info.write_time = smbcli_pull_nttime(blob->data, 24);
+ data->both_directory_info.change_time = smbcli_pull_nttime(blob->data, 32);
data->both_directory_info.size = BVAL(blob->data, 40);
data->both_directory_info.alloc_size = BVAL(blob->data, 48);
data->both_directory_info.attrib = IVAL(blob->data, 56);
data->both_directory_info.ea_size = IVAL(blob->data, 64);
- cli_blob_pull_string(tree->session, mem_ctx, blob,
+ smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->both_directory_info.short_name,
68, 70, STR_LEN8BIT | STR_UNICODE);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->both_directory_info.name,
60, 94, 0);
if (ofs != 0 && ofs < 94+len) {
if (blob->length < 81) return -1;
ofs = IVAL(blob->data, 0);
data->id_full_directory_info.file_index = IVAL(blob->data, 4);
- data->id_full_directory_info.create_time = cli_pull_nttime(blob->data, 8);
- data->id_full_directory_info.access_time = cli_pull_nttime(blob->data, 16);
- data->id_full_directory_info.write_time = cli_pull_nttime(blob->data, 24);
- data->id_full_directory_info.change_time = cli_pull_nttime(blob->data, 32);
+ data->id_full_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
+ data->id_full_directory_info.access_time = smbcli_pull_nttime(blob->data, 16);
+ data->id_full_directory_info.write_time = smbcli_pull_nttime(blob->data, 24);
+ data->id_full_directory_info.change_time = smbcli_pull_nttime(blob->data, 32);
data->id_full_directory_info.size = BVAL(blob->data, 40);
data->id_full_directory_info.alloc_size = BVAL(blob->data, 48);
data->id_full_directory_info.attrib = IVAL(blob->data, 56);
data->id_full_directory_info.ea_size = IVAL(blob->data, 64);
data->id_full_directory_info.file_id = BVAL(blob->data, 72);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->id_full_directory_info.name,
60, 80, 0);
if (ofs != 0 && ofs < 80+len) {
if (blob->length < 105) return -1;
ofs = IVAL(blob->data, 0);
data->id_both_directory_info.file_index = IVAL(blob->data, 4);
- data->id_both_directory_info.create_time = cli_pull_nttime(blob->data, 8);
- data->id_both_directory_info.access_time = cli_pull_nttime(blob->data, 16);
- data->id_both_directory_info.write_time = cli_pull_nttime(blob->data, 24);
- data->id_both_directory_info.change_time = cli_pull_nttime(blob->data, 32);
+ data->id_both_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
+ data->id_both_directory_info.access_time = smbcli_pull_nttime(blob->data, 16);
+ data->id_both_directory_info.write_time = smbcli_pull_nttime(blob->data, 24);
+ data->id_both_directory_info.change_time = smbcli_pull_nttime(blob->data, 32);
data->id_both_directory_info.size = BVAL(blob->data, 40);
data->id_both_directory_info.alloc_size = BVAL(blob->data, 48);
data->id_both_directory_info.attrib = SVAL(blob->data, 56);
data->id_both_directory_info.ea_size = IVAL(blob->data, 64);
- cli_blob_pull_string(tree->session, mem_ctx, blob,
+ smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->id_both_directory_info.short_name,
68, 70, STR_LEN8BIT | STR_UNICODE);
data->id_both_directory_info.file_id = BVAL(blob->data, 96);
- len = cli_blob_pull_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
&data->id_both_directory_info.name,
60, 104, 0);
if (ofs != 0 && ofs < 104+len) {
data->unix_info.file_index = IVAL(blob->data, 4);
data->unix_info.size = BVAL(blob->data, 8);
data->unix_info.alloc_size = BVAL(blob->data, 16);
- data->unix_info.status_change_time = cli_pull_nttime(blob->data, 24);
- data->unix_info.access_time = cli_pull_nttime(blob->data, 32);
- data->unix_info.change_time = cli_pull_nttime(blob->data, 40);
+ data->unix_info.status_change_time = smbcli_pull_nttime(blob->data, 24);
+ data->unix_info.access_time = smbcli_pull_nttime(blob->data, 32);
+ data->unix_info.change_time = smbcli_pull_nttime(blob->data, 40);
data->unix_info.uid = IVAL(blob->data, 48);
data->unix_info.gid = IVAL(blob->data, 56);
data->unix_info.file_type = IVAL(blob->data, 64);
data->unix_info.permissions = IVAL(blob->data, 92);
data->unix_info.nlink = IVAL(blob->data, 100);
/* There is no length field for this name but we know it's null terminated. */
- len = cli_blob_pull_unix_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_pull_unix_string(tree->session, mem_ctx, blob,
&data->unix_info.name, 108, 0);
if (ofs != 0 && ofs < 108+len) {
return -1;
/****************************************************************************
Trans2 search backend - process output.
****************************************************************************/
-static NTSTATUS smb_raw_t2search_backend(struct cli_tree *tree,
+static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
enum smb_search_level level,
uint16_t flags,
/* Implements trans2findfirst2 and old search
*/
-NTSTATUS smb_raw_search_first(struct cli_tree *tree,
+NTSTATUS smb_raw_search_first(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_search_first *io, void *private,
BOOL (*callback)(void *private, union smb_search_data *file))
/* Implements trans2findnext2 and old smbsearch
*/
-NTSTATUS smb_raw_search_next(struct cli_tree *tree,
+NTSTATUS smb_raw_search_next(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_search_next *io, void *private,
BOOL (*callback)(void *private, union smb_search_data *file))
/*
Implements trans2findclose2
*/
-NTSTATUS smb_raw_search_close(struct cli_tree *tree,
+NTSTATUS smb_raw_search_close(struct smbcli_tree *tree,
union smb_search_close *io)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBfindclose, 1, 0);
+ req = smbcli_request_setup(tree, SMBfindclose, 1, 0);
if (!req) {
return NT_STATUS_NO_MEMORY;
}
SSVAL(req->out.vwv, VWV(0), io->findclose.in.handle);
- if (cli_request_send(req)) {
- cli_request_receive(req);
+ if (smbcli_request_send(req)) {
+ smbcli_request_receive(req);
}
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/****************************************************************************
Handle setfileinfo/setpathinfo trans2 backend.
****************************************************************************/
-static BOOL smb_raw_setinfo_backend(struct cli_tree *tree,
+static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_setfileinfo *parms,
DATA_BLOB *blob)
case RAW_SFILEINFO_BASIC_INFO:
case RAW_SFILEINFO_BASIC_INFORMATION:
NEED_BLOB(40);
- cli_push_nttime(blob->data, 0, parms->basic_info.in.create_time);
- cli_push_nttime(blob->data, 8, parms->basic_info.in.access_time);
- cli_push_nttime(blob->data, 16, parms->basic_info.in.write_time);
- cli_push_nttime(blob->data, 24, parms->basic_info.in.change_time);
+ smbcli_push_nttime(blob->data, 0, parms->basic_info.in.create_time);
+ smbcli_push_nttime(blob->data, 8, parms->basic_info.in.access_time);
+ smbcli_push_nttime(blob->data, 16, parms->basic_info.in.write_time);
+ smbcli_push_nttime(blob->data, 24, parms->basic_info.in.change_time);
SIVAL(blob->data, 32, parms->basic_info.in.attrib);
SIVAL(blob->data, 36, 0); /* padding */
return True;
NEED_BLOB(92);
SBVAL(blob->data, 0, parms->unix_basic.in.end_of_file);
SBVAL(blob->data, 8, parms->unix_basic.in.num_bytes);
- cli_push_nttime(blob->data, 16, parms->unix_basic.in.status_change_time);
- cli_push_nttime(blob->data, 24, parms->unix_basic.in.access_time);
- cli_push_nttime(blob->data, 32, parms->unix_basic.in.change_time);
+ smbcli_push_nttime(blob->data, 16, parms->unix_basic.in.status_change_time);
+ smbcli_push_nttime(blob->data, 24, parms->unix_basic.in.access_time);
+ smbcli_push_nttime(blob->data, 32, parms->unix_basic.in.change_time);
SBVAL(blob->data, 40, parms->unix_basic.in.uid);
SBVAL(blob->data, 48, parms->unix_basic.in.gid);
SIVAL(blob->data, 56, parms->unix_basic.in.file_type);
NEED_BLOB(12);
SIVAL(blob->data, 0, parms->rename_information.in.overwrite);
SIVAL(blob->data, 4, parms->rename_information.in.root_fid);
- len = cli_blob_append_string(tree->session, mem_ctx, blob,
+ len = smbcli_blob_append_string(tree->session, mem_ctx, blob,
parms->rename_information.in.new_name,
STR_UNICODE|STR_TERMINATE);
SIVAL(blob->data, 8, len - 2);
/****************************************************************************
Very raw set file info - takes data blob (async send)
****************************************************************************/
-static struct cli_request *smb_raw_setfileinfo_blob_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_setfileinfo_blob_send(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
uint16_t fnum,
uint16_t info_level,
/****************************************************************************
Very raw set path info - takes data blob
****************************************************************************/
-static struct cli_request *smb_raw_setpathinfo_blob_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_setpathinfo_blob_send(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
const char *fname,
uint16_t info_level,
}
SSVAL(tp.in.params.data, 0, info_level);
SSVAL(tp.in.params.data, 2, 0);
- cli_blob_append_string(tree->session, mem_ctx,
+ smbcli_blob_append_string(tree->session, mem_ctx,
&tp.in.params,
fname, STR_TERMINATE);
/****************************************************************************
Handle setattr (async send)
****************************************************************************/
-static struct cli_request *smb_raw_setattr_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_setattr_send(struct smbcli_tree *tree,
union smb_setfileinfo *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBsetatr, 8, 0);
+ req = smbcli_request_setup(tree, SMBsetatr, 8, 0);
if (!req) return NULL;
SSVAL(req->out.vwv, VWV(0), parms->setattr.in.attrib);
raw_push_dos_date3(tree->session->transport,
req->out.vwv, VWV(1), parms->setattr.in.write_time);
memset(req->out.vwv + VWV(3), 0, 10); /* reserved */
- cli_req_append_ascii4(req, parms->setattr.file.fname, STR_TERMINATE);
- cli_req_append_ascii4(req, "", STR_TERMINATE);
+ smbcli_req_append_ascii4(req, parms->setattr.file.fname, STR_TERMINATE);
+ smbcli_req_append_ascii4(req, "", STR_TERMINATE);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Handle setattrE. (async send)
****************************************************************************/
-static struct cli_request *smb_raw_setattrE_send(struct cli_tree *tree,
+static struct smbcli_request *smb_raw_setattrE_send(struct smbcli_tree *tree,
union smb_setfileinfo *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
- req = cli_request_setup(tree, SMBsetattrE, 7, 0);
+ req = smbcli_request_setup(tree, SMBsetattrE, 7, 0);
if (!req) return NULL;
SSVAL(req->out.vwv, VWV(0), parms->setattre.file.fnum);
raw_push_dos_date2(tree->session->transport,
req->out.vwv, VWV(5), parms->setattre.in.write_time);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
Set file info (async send)
****************************************************************************/
-struct cli_request *smb_raw_setfileinfo_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_setfileinfo_send(struct smbcli_tree *tree,
union smb_setfileinfo *parms)
{
DATA_BLOB blob;
TALLOC_CTX *mem_ctx;
- struct cli_request *req;
+ struct smbcli_request *req;
if (parms->generic.level == RAW_SFILEINFO_SETATTRE) {
return smb_raw_setattrE_send(tree, parms);
/****************************************************************************
Set file info (async send)
****************************************************************************/
-NTSTATUS smb_raw_setfileinfo(struct cli_tree *tree,
+NTSTATUS smb_raw_setfileinfo(struct smbcli_tree *tree,
union smb_setfileinfo *parms)
{
- struct cli_request *req = smb_raw_setfileinfo_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_setfileinfo_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/****************************************************************************
Set path info (async send)
****************************************************************************/
-struct cli_request *smb_raw_setpathinfo_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_setpathinfo_send(struct smbcli_tree *tree,
union smb_setfileinfo *parms)
{
DATA_BLOB blob;
TALLOC_CTX *mem_ctx;
- struct cli_request *req;
+ struct smbcli_request *req;
if (parms->generic.level == RAW_SFILEINFO_SETATTR) {
return smb_raw_setattr_send(tree, parms);
/****************************************************************************
Set path info (sync interface)
****************************************************************************/
-NTSTATUS smb_raw_setpathinfo(struct cli_tree *tree,
+NTSTATUS smb_raw_setpathinfo(struct smbcli_tree *tree,
union smb_setfileinfo *parms)
{
- struct cli_request *req = smb_raw_setpathinfo_send(tree, parms);
- return cli_request_simple_recv(req);
+ struct smbcli_request *req = smb_raw_setpathinfo_send(tree, parms);
+ return smbcli_request_simple_recv(req);
}
/*
check out of bounds for incoming data
*/
-static BOOL raw_trans_oob(struct cli_request *req,
+static BOOL raw_trans_oob(struct smbcli_request *req,
uint_t offset, uint_t count)
{
char *ptr;
/****************************************************************************
receive a SMB trans or trans2 response allocating the necessary memory
****************************************************************************/
-NTSTATUS smb_raw_trans2_recv(struct cli_request *req,
+NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
struct smb_trans2 *parms)
{
parms->out.params.length = 0;
parms->out.params.data = NULL;
- if (!cli_request_receive(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req)) {
+ return smbcli_request_destroy(req);
}
/*
* be treated as such.
*/
if (NT_STATUS_IS_ERR(req->status)) {
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
- CLI_CHECK_MIN_WCT(req, 10);
+ SMBCLI_CHECK_MIN_WCT(req, 10);
/* parse out the lengths */
total_data = SVAL(req->in.vwv, VWV(1));
if (!tdata) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data));
req->status = NT_STATUS_NO_MEMORY;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
parms->out.data.data = tdata;
}
if (!tparam) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param));
req->status = NT_STATUS_NO_MEMORY;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
parms->out.params.data = tparam;
}
parms->out.setup_count = SVAL(req->in.vwv, VWV(9));
- CLI_CHECK_WCT(req, 10 + parms->out.setup_count);
+ SMBCLI_CHECK_WCT(req, 10 + parms->out.setup_count);
if (parms->out.setup_count > 0) {
int i;
parms->out.setup = talloc(mem_ctx, 2 * parms->out.setup_count);
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
for (i=0;i<parms->out.setup_count;i++) {
parms->out.setup[i] = SVAL(req->in.vwv, VWV(10+i));
/* they must *only* shrink */
DEBUG(1,("smb_raw_receive_trans: data/params expanded!\n"));
req->status = NT_STATUS_BUFFER_TOO_SMALL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
total_data = total_data2;
param_count + param_disp > total_param) {
DEBUG(1,("smb_raw_receive_trans: Buffer overflow\n"));
req->status = NT_STATUS_BUFFER_TOO_SMALL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/* check the server isn't being nasty */
raw_trans_oob(req, data_ofs, data_count)) {
DEBUG(1,("smb_raw_receive_trans: out of bounds parameters!\n"));
req->status = NT_STATUS_BUFFER_TOO_SMALL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
if (data_count) {
if (total_data <= parms->out.data.length && total_param <= parms->out.params.length)
break;
- if (!cli_request_receive_more(req)) {
+ if (!smbcli_request_receive_more(req)) {
req->status = NT_STATUS_UNSUCCESSFUL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
-NTSTATUS smb_raw_trans_recv(struct cli_request *req,
+NTSTATUS smb_raw_trans_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
struct smb_trans2 *parms)
{
trans/trans2 raw async interface - only BLOBs used in this interface.
note that this doesn't yet support multi-part requests
****************************************************************************/
-struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree,
+struct smbcli_request *smb_raw_trans_send_backend(struct smbcli_tree *tree,
struct smb_trans2 *parms,
uint8_t command)
{
int wct = 14 + parms->in.setup_count;
- struct cli_request *req;
+ struct smbcli_request *req;
char *outdata,*outparam;
int i;
int padding;
else
padding = 3;
- req = cli_request_setup(tree, command, wct, padding);
+ req = smbcli_request_setup(tree, command, wct, padding);
if (!req) {
return NULL;
}
memset(req->out.data, 0, padding);
if (command == SMBtrans && parms->in.trans_name) {
- namelen = cli_req_append_string(req, parms->in.trans_name,
+ namelen = smbcli_req_append_string(req, parms->in.trans_name,
STR_TERMINATE);
}
SSVAL(req->out.vwv,VWV(14)+i*2,parms->in.setup[i]);
}
if (parms->in.params.data) {
- cli_req_append_blob(req, &parms->in.params);
+ smbcli_req_append_blob(req, &parms->in.params);
}
if (parms->in.data.data) {
- cli_req_append_blob(req, &parms->in.data);
+ smbcli_req_append_blob(req, &parms->in.data);
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
note that this doesn't yet support multi-part requests
****************************************************************************/
-struct cli_request *smb_raw_trans_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_trans_send(struct smbcli_tree *tree,
struct smb_trans2 *parms)
{
return smb_raw_trans_send_backend(tree, parms, SMBtrans);
}
-struct cli_request *smb_raw_trans2_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_trans2_send(struct smbcli_tree *tree,
struct smb_trans2 *parms)
{
return smb_raw_trans_send_backend(tree, parms, SMBtrans2);
/*
trans2 synchronous blob interface
*/
-NTSTATUS smb_raw_trans2(struct cli_tree *tree,
+NTSTATUS smb_raw_trans2(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
struct smb_trans2 *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
req = smb_raw_trans2_send(tree, parms);
if (!req) return NT_STATUS_UNSUCCESSFUL;
return smb_raw_trans2_recv(req, mem_ctx, parms);
/*
trans synchronous blob interface
*/
-NTSTATUS smb_raw_trans(struct cli_tree *tree,
+NTSTATUS smb_raw_trans(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
struct smb_trans2 *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
req = smb_raw_trans_send(tree, parms);
if (!req) return NT_STATUS_UNSUCCESSFUL;
return smb_raw_trans_recv(req, mem_ctx, parms);
/****************************************************************************
receive a SMB nttrans response allocating the necessary memory
****************************************************************************/
-NTSTATUS smb_raw_nttrans_recv(struct cli_request *req,
+NTSTATUS smb_raw_nttrans_recv(struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
struct smb_nttrans *parms)
{
uint32_t total_data, recvd_data=0;
uint32_t total_param, recvd_param=0;
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
/* sanity check */
"SMBnttrans",
CVAL(req->in.hdr,HDR_COM)));
req->status = NT_STATUS_UNSUCCESSFUL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
- CLI_CHECK_MIN_WCT(req, 18);
+ SMBCLI_CHECK_MIN_WCT(req, 18);
/* parse out the lengths */
total_param = IVAL(req->in.vwv, 3);
if (parms->out.data.length != total_data ||
parms->out.params.length != total_param) {
req->status = NT_STATUS_NO_MEMORY;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
parms->out.setup_count = CVAL(req->in.vwv, 35);
- CLI_CHECK_WCT(req, 18 + parms->out.setup_count);
+ SMBCLI_CHECK_WCT(req, 18 + parms->out.setup_count);
if (parms->out.setup_count > 0) {
int i;
parms->out.setup = talloc(mem_ctx, 2 * parms->out.setup_count);
if (!parms->out.setup) {
req->status = NT_STATUS_NO_MEMORY;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
for (i=0;i<parms->out.setup_count;i++) {
parms->out.setup[i] = SVAL(req->in.vwv, VWV(18+i));
/* they must *only* shrink */
DEBUG(1,("smb_raw_receive_nttrans: data/params expanded!\n"));
req->status = NT_STATUS_BUFFER_TOO_SMALL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
total_data = total_data2;
param_count + param_disp > total_param) {
DEBUG(1,("smb_raw_receive_nttrans: Buffer overflow\n"));
req->status = NT_STATUS_BUFFER_TOO_SMALL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
/* check the server isn't being nasty */
raw_trans_oob(req, data_ofs, data_count)) {
DEBUG(1,("smb_raw_receive_nttrans: out of bounds parameters!\n"));
req->status = NT_STATUS_BUFFER_TOO_SMALL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
if (data_count) {
break;
}
- if (!cli_request_receive(req) ||
- cli_request_is_error(req)) {
- return cli_request_destroy(req);
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ return smbcli_request_destroy(req);
}
/* sanity check */
DEBUG(0,("smb_raw_receive_nttrans: Expected nttranss, got command 0x%02x\n",
CVAL(req->in.hdr, HDR_COM)));
req->status = NT_STATUS_UNSUCCESSFUL;
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
}
failed:
- return cli_request_destroy(req);
+ return smbcli_request_destroy(req);
}
nttrans raw - only BLOBs used in this interface.
at the moment we only handle a single primary request
****************************************************************************/
-struct cli_request *smb_raw_nttrans_send(struct cli_tree *tree,
+struct smbcli_request *smb_raw_nttrans_send(struct smbcli_tree *tree,
struct smb_nttrans *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
char *outdata, *outparam;
int i;
int align = 0;
align = 3;
}
- req = cli_request_setup(tree, SMBnttrans,
+ req = smbcli_request_setup(tree, SMBnttrans,
19 + parms->in.setup_count,
align +
parms->in.params.length +
memcpy(outparam, parms->in.data.data, parms->in.data.length);
}
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
return NULL;
}
/****************************************************************************
receive a SMB nttrans response allocating the necessary memory
****************************************************************************/
-NTSTATUS smb_raw_nttrans(struct cli_tree *tree,
+NTSTATUS smb_raw_nttrans(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
struct smb_nttrans *parms)
{
- struct cli_request *req;
+ struct smbcli_request *req;
req = smb_raw_nttrans_send(tree, parms);
if (!req) {
/***********************************************************
SMB signing - Common code before we set a new signing implementation
************************************************************/
-static BOOL set_smb_signing_common(struct cli_transport *transport)
+static BOOL set_smb_signing_common(struct smbcli_transport *transport)
{
if (!(transport->negotiate.sec_mode &
(NEGOTIATE_SECURITY_SIGNATURES_REQUIRED|NEGOTIATE_SECURITY_SIGNATURES_ENABLED))) {
/***********************************************************
SMB signing - Common code for 'real' implementations
************************************************************/
-static BOOL set_smb_signing_real_common(struct cli_transport *transport)
+static BOOL set_smb_signing_real_common(struct smbcli_transport *transport)
{
if (transport->negotiate.sign_info.mandatory_signing) {
DEBUG(5, ("Mandatory SMB signing enabled!\n"));
SSVAL(out->hdr, HDR_FLG2, flags2);
}
-static BOOL signing_good(struct cli_request *req, unsigned int seq, BOOL good)
+static BOOL signing_good(struct smbcli_request *req, unsigned int seq, BOOL good)
{
if (good) {
if (!req->transport->negotiate.sign_info.doing_signing) {
req->transport->negotiate.sign_info.doing_signing = False;
if (req->transport->negotiate.sign_info.free_signing_context)
req->transport->negotiate.sign_info.free_signing_context(req->transport);
- cli_null_set_signing(req->transport);
+ smbcli_null_set_signing(req->transport);
return True;
} else {
/* bad packet after signing started - fail and disconnect. */
/***********************************************************
SMB signing - Simple implementation - calculate a MAC to send.
************************************************************/
-static void cli_request_simple_sign_outgoing_message(struct cli_request *req)
+static void smbcli_request_simple_sign_outgoing_message(struct smbcli_request *req)
{
struct smb_basic_signing_context *data = req->transport->negotiate.sign_info.signing_context;
/***********************************************************
SMB signing - Simple implementation - check a MAC sent by server.
************************************************************/
-static BOOL cli_request_simple_check_incoming_message(struct cli_request *req)
+static BOOL smbcli_request_simple_check_incoming_message(struct smbcli_request *req)
{
struct smb_basic_signing_context *data
= req->transport->negotiate.sign_info.signing_context;
/***********************************************************
SMB signing - Simple implementation - free signing context
************************************************************/
-static void cli_transport_simple_free_signing_context(struct cli_transport *transport)
+static void smbcli_transport_simple_free_signing_context(struct smbcli_transport *transport)
{
struct smb_basic_signing_context *data = transport->negotiate.sign_info.signing_context;
/***********************************************************
SMB signing - Simple implementation - setup the MAC key.
************************************************************/
-BOOL cli_transport_simple_set_signing(struct cli_transport *transport,
+BOOL smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
const DATA_BLOB user_session_key,
const DATA_BLOB response)
{
/* Initialise the sequence number */
data->next_seq_num = 0;
- transport->negotiate.sign_info.sign_outgoing_message = cli_request_simple_sign_outgoing_message;
- transport->negotiate.sign_info.check_incoming_message = cli_request_simple_check_incoming_message;
- transport->negotiate.sign_info.free_signing_context = cli_transport_simple_free_signing_context;
+ transport->negotiate.sign_info.sign_outgoing_message = smbcli_request_simple_sign_outgoing_message;
+ transport->negotiate.sign_info.check_incoming_message = smbcli_request_simple_check_incoming_message;
+ transport->negotiate.sign_info.free_signing_context = smbcli_transport_simple_free_signing_context;
return True;
}
/***********************************************************
SMB signing - NULL implementation - calculate a MAC to send.
************************************************************/
-static void cli_request_null_sign_outgoing_message(struct cli_request *req)
+static void smbcli_request_null_sign_outgoing_message(struct smbcli_request *req)
{
/* we can't zero out the sig, as we might be trying to send a
transport request - which is NBT-level, not SMB level and doesn't
/***********************************************************
SMB signing - NULL implementation - check a MAC sent by server.
************************************************************/
-static BOOL cli_request_null_check_incoming_message(struct cli_request *req)
+static BOOL smbcli_request_null_check_incoming_message(struct smbcli_request *req)
{
return True;
}
/***********************************************************
SMB signing - NULL implementation - free signing context
************************************************************/
-static void cli_null_free_signing_context(struct cli_transport *transport)
+static void smbcli_null_free_signing_context(struct smbcli_transport *transport)
{
}
@note Used as an initialisation only - it will not correctly
shut down a real signing mechanism
*/
-BOOL cli_null_set_signing(struct cli_transport *transport)
+BOOL smbcli_null_set_signing(struct smbcli_transport *transport)
{
transport->negotiate.sign_info.signing_context = NULL;
- transport->negotiate.sign_info.sign_outgoing_message = cli_request_null_sign_outgoing_message;
- transport->negotiate.sign_info.check_incoming_message = cli_request_null_check_incoming_message;
- transport->negotiate.sign_info.free_signing_context = cli_null_free_signing_context;
+ transport->negotiate.sign_info.sign_outgoing_message = smbcli_request_null_sign_outgoing_message;
+ transport->negotiate.sign_info.check_incoming_message = smbcli_request_null_check_incoming_message;
+ transport->negotiate.sign_info.free_signing_context = smbcli_null_free_signing_context;
return True;
}
/***********************************************************
SMB signing - TEMP implementation - calculate a MAC to send.
************************************************************/
-static void cli_request_temp_sign_outgoing_message(struct cli_request *req)
+static void smbcli_request_temp_sign_outgoing_message(struct smbcli_request *req)
{
/* mark the packet as signed - BEFORE we sign it...*/
mark_packet_signed(&req->out);
/***********************************************************
SMB signing - TEMP implementation - check a MAC sent by server.
************************************************************/
-static BOOL cli_request_temp_check_incoming_message(struct cli_request *req)
+static BOOL smbcli_request_temp_check_incoming_message(struct smbcli_request *req)
{
return True;
}
/***********************************************************
SMB signing - NULL implementation - free signing context
************************************************************/
-static void cli_temp_free_signing_context(struct cli_transport *transport)
+static void smbcli_temp_free_signing_context(struct smbcli_transport *transport)
{
return;
}
@note Used as an initialisation only - it will not correctly
shut down a real signing mechanism
*/
-BOOL cli_temp_set_signing(struct cli_transport *transport)
+BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
{
if (!set_smb_signing_common(transport)) {
return False;
transport->negotiate.sign_info.signing_context = NULL;
- transport->negotiate.sign_info.sign_outgoing_message = cli_request_temp_sign_outgoing_message;
- transport->negotiate.sign_info.check_incoming_message = cli_request_temp_check_incoming_message;
- transport->negotiate.sign_info.free_signing_context = cli_temp_free_signing_context;
+ transport->negotiate.sign_info.sign_outgoing_message = smbcli_request_temp_sign_outgoing_message;
+ transport->negotiate.sign_info.check_incoming_message = smbcli_request_temp_check_incoming_message;
+ transport->negotiate.sign_info.free_signing_context = smbcli_temp_free_signing_context;
return True;
}
/**
* Free the signing context
*/
-void cli_transport_free_signing_context(struct cli_transport *transport)
+void smbcli_transport_free_signing_context(struct smbcli_transport *transport)
{
if (transport->negotiate.sign_info.free_signing_context) {
transport->negotiate.sign_info.free_signing_context(transport);
}
- cli_null_set_signing(transport);
+ smbcli_null_set_signing(transport);
}
/**
* Sign a packet with the current mechanism
*/
-void cli_request_calculate_sign_mac(struct cli_request *req)
+void smbcli_request_calculate_sign_mac(struct smbcli_request *req)
{
req->transport->negotiate.sign_info.sign_outgoing_message(req);
}
* @return False if we had an established signing connection
* which had a back checksum, True otherwise
*/
-BOOL cli_request_check_sign_mac(struct cli_request *req)
+BOOL smbcli_request_check_sign_mac(struct smbcli_request *req)
{
BOOL good;
}
-BOOL cli_init_signing(struct cli_transport *transport)
+BOOL smbcli_init_signing(struct smbcli_transport *transport)
{
- if (!cli_null_set_signing(transport)) {
+ if (!smbcli_null_set_signing(transport)) {
return False;
}
/***************************************************************************
Return an error message from the last response
****************************************************************************/
-const char *cli_errstr(struct cli_tree *tree)
+const char *smbcli_errstr(struct smbcli_tree *tree)
{
switch (tree->session->transport->error.etype) {
case ETYPE_DOS:
/* Return the 32-bit NT status code from the last packet */
-NTSTATUS cli_nt_error(struct cli_tree *tree)
+NTSTATUS smbcli_nt_error(struct smbcli_tree *tree)
{
switch (tree->session->transport->error.etype) {
case ETYPE_NT:
/* Return the DOS error from the last packet - an error class and an error
code. */
-void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode)
+void smbcli_dos_error(struct smbcli_state *cli, uint8_t *eclass, uint32_t *ecode)
{
if (cli->transport->error.etype == ETYPE_DOS) {
ntstatus_to_dos(cli->transport->error.e.nt_status,
/* Return true if the last packet was an error */
-BOOL cli_is_error(struct cli_tree *tree)
+BOOL smbcli_is_error(struct smbcli_tree *tree)
{
- return NT_STATUS_IS_ERR(cli_nt_error(tree));
+ return NT_STATUS_IS_ERR(smbcli_nt_error(tree));
}
/* Return true if the last error was a DOS error */
-BOOL cli_is_dos_error(struct cli_tree *tree)
+BOOL smbcli_is_dos_error(struct smbcli_tree *tree)
{
return tree->session->transport->error.etype == ETYPE_DOS;
}
of the ".." name.
*******************************************************************/
-BOOL mask_match(struct cli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive)
+BOOL mask_match(struct smbcli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive)
{
fstring p2, s2;
/* Does the md5 encryption from the Key Response for NTLMv2. */
void SMBOWFencrypt_ntv2(const uint8_t kr[16],
const DATA_BLOB *srv_chal,
- const DATA_BLOB *cli_chal,
+ const DATA_BLOB *smbcli_chal,
uint8_t resp_buf[16])
{
HMACMD5Context ctx;
hmac_md5_init_limK_to_64(kr, 16, &ctx);
hmac_md5_update(srv_chal->data, srv_chal->length, &ctx);
- hmac_md5_update(cli_chal->data, cli_chal->length, &ctx);
+ hmac_md5_update(smbcli_chal->data, smbcli_chal->length, &ctx);
hmac_md5_final(resp_buf, &ctx);
#ifdef DEBUG_PASSWORD
- DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, cli_chal, resp_buf\n"));
+ DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, smbcli_chal, resp_buf\n"));
dump_data(100, srv_chal->data, srv_chal->length);
- dump_data(100, cli_chal->data, cli_chal->length);
+ dump_data(100, smbcli_chal->data, smbcli_chal->length);
dump_data(100, resp_buf, 16);
#endif
}
/* transport private information used by SMB pipe transport */
struct smb_private {
uint16_t fnum;
- struct cli_tree *tree;
+ struct smbcli_tree *tree;
};
-static struct cli_request *dcerpc_raw_send(struct dcerpc_pipe *p, DATA_BLOB *blob)
+static struct smbcli_request *dcerpc_raw_send(struct dcerpc_pipe *p, DATA_BLOB *blob)
{
struct smb_private *smb = p->transport.private;
struct smb_trans2 trans;
uint16_t setup[2];
- struct cli_request *req;
+ struct smbcli_request *req;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("dcerpc_raw_send");
static NTSTATUS dcerpc_raw_recv(struct dcerpc_pipe *p,
- struct cli_request *req,
+ struct smbcli_request *req,
TALLOC_CTX *mem_ctx,
DATA_BLOB *blob)
{
DATA_BLOB *request_blob,
DATA_BLOB *reply_blob)
{
- struct cli_request *req;
+ struct smbcli_request *req;
req = dcerpc_raw_send(p, request_blob);
return dcerpc_raw_recv(p, req, mem_ctx, reply_blob);
}
c.close.in.fnum = smb->fnum;
c.close.in.write_time = 0;
smb_raw_close(smb->tree, &c);
- cli_tree_close(smb->tree);
+ smbcli_tree_close(smb->tree);
return NT_STATUS_OK;
}
open a rpc connection to a named pipe
*/
NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe **p,
- struct cli_tree *tree,
+ struct smbcli_tree *tree,
const char *pipe_name)
{
struct smb_private *smb;
/*
return the SMB tree used for a dcerpc over SMB pipe
*/
-struct cli_tree *dcerpc_smb_tree(struct dcerpc_pipe *p)
+struct smbcli_tree *dcerpc_smb_tree(struct dcerpc_pipe *p)
{
struct smb_private *smb = p->transport.private;
{
NTSTATUS status;
BOOL retry;
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *pipe_name;
if (!binding->options || !binding->options[0]) {
}
if ((binding->flags & DCERPC_SCHANNEL_ANY) || !username || !username[0]) {
- status = cli_full_connection(&cli, lp_netbios_name(),
+ status = smbcli_full_connection(&cli, lp_netbios_name(),
binding->host, NULL,
"ipc$", "?????",
"", "", NULL, 0, &retry);
} else {
- status = cli_full_connection(&cli, lp_netbios_name(),
+ status = smbcli_full_connection(&cli, lp_netbios_name(),
binding->host, NULL,
"ipc$", "?????",
username, domain,
status = dcerpc_pipe_open_smb(p, cli->tree, pipe_name);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to open pipe %s - %s\n", pipe_name, nt_errstr(status)));
- cli_tdis(cli);
- cli_shutdown(cli);
+ smbcli_tdis(cli);
+ smbcli_shutdown(cli);
return status;
}
/* this ensures that the reference count is decremented so
a pipe close will really close the link */
- cli_tree_close(cli->tree);
+ smbcli_tree_close(cli->tree);
(*p)->flags = binding->flags;
const char *pipe_uuid,
uint32_t pipe_version)
{
- struct cli_tree *tree;
+ struct smbcli_tree *tree;
NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
struct dcerpc_binding b;
NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
DATA_BLOB *session_key)
{
- struct cli_tree *tree;
+ struct smbcli_tree *tree;
if (p->security_state.generic_state) {
return gensec_session_key(p->security_state.generic_state, session_key);
/* this is stored in ntvfs_private */
struct cvfs_private {
- struct cli_tree *tree;
- struct cli_transport *transport;
+ struct smbcli_tree *tree;
+ struct smbcli_transport *transport;
struct smbsrv_tcon *tcon;
const char *map_calls;
};
this function won't be needed once all of the cifs backend
and the core of smbd is converted to use async calls
*/
-static void idle_func(struct cli_transport *transport, void *p_private)
+static void idle_func(struct smbcli_transport *transport, void *p_private)
{
struct cvfs_private *private = p_private;
if (socket_pending(private->tcon->smb_conn->connection->socket->fde->fd)) {
a handler for oplock break events from the server - these need to be passed
along to the client
*/
-static BOOL oplock_handler(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
+static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
{
struct cvfs_private *private = p_private;
DEBUG(5,("cifs_socket_handler event on fd %d\n", fde->fd));
- if (!cli_transport_process(private->transport)) {
+ if (!smbcli_transport_process(private->transport)) {
/* the connection to our server is dead */
close_cnum(tcon);
}
req->tcon->ntvfs_private = (void *)private;
- status = cli_tree_full_connection(&private->tree,
+ status = smbcli_tree_full_connection(&private->tree,
"vfs_cifs",
host,
0,
}
/* we need to receive oplock break requests from the server */
- cli_oplock_handler(private->transport, oplock_handler, private);
- cli_transport_idle_handler(private->transport, idle_func, 1, private);
+ smbcli_oplock_handler(private->transport, oplock_handler, private);
+ smbcli_transport_idle_handler(private->transport, idle_func, 1, private);
private->transport->event.fde->handler = cifs_socket_handler;
private->transport->event.fde->private = private;
struct cvfs_private *private = tcon->ntvfs_private;
smb_tree_disconnect(private->tree);
- cli_tree_close(private->tree);
+ smbcli_tree_close(private->tree);
return NT_STATUS_OK;
}
this handler can only be used for functions that don't return any
parameters (those that just return a status code)
*/
-static void async_simple(struct cli_request *c_req)
+static void async_simple(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = cli_request_simple_recv(c_req);
+ req->async.status = smbcli_request_simple_recv(c_req);
req->async.send_fn(req);
}
static NTSTATUS cvfs_unlink(struct smbsrv_request *req, struct smb_unlink *unl)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
/* see if the front end will allow us to perform this
function asynchronously. */
/*
a handler for async ioctl replies
*/
-static void async_ioctl(struct cli_request *c_req)
+static void async_ioctl(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
/* see if the front end will allow us to perform this
function asynchronously. */
static NTSTATUS cvfs_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_chkpath(private->tree, cp);
/*
a handler for async qpathinfo replies
*/
-static void async_qpathinfo(struct cli_request *c_req)
+static void async_qpathinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_pathinfo(private->tree, req->mem_ctx, info);
/*
a handler for async qfileinfo replies
*/
-static void async_qfileinfo(struct cli_request *c_req)
+static void async_qfileinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_fileinfo(private->tree, req->mem_ctx, info);
static NTSTATUS cvfs_setpathinfo(struct smbsrv_request *req, union smb_setfileinfo *st)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_setpathinfo(private->tree, st);
/*
a handler for async open replies
*/
-static void async_open(struct cli_request *c_req)
+static void async_open(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_open(struct smbsrv_request *req, union smb_open *io)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (private->map_calls && in_list("open", private->map_calls, True) &&
io->generic.level != RAW_OPEN_GENERIC) {
static NTSTATUS cvfs_mkdir(struct smbsrv_request *req, union smb_mkdir *md)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_mkdir(private->tree, md);
static NTSTATUS cvfs_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_rmdir(private->tree, rd);
static NTSTATUS cvfs_rename(struct smbsrv_request *req, union smb_rename *ren)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_rename(private->tree, ren);
/*
a handler for async read replies
*/
-static void async_read(struct cli_request *c_req)
+static void async_read(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_read(struct smbsrv_request *req, union smb_read *rd)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_read(private->tree, rd);
/*
a handler for async write replies
*/
-static void async_write(struct cli_request *c_req)
+static void async_write(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_write(struct smbsrv_request *req, union smb_write *wr)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_write(private->tree, wr);
static NTSTATUS cvfs_close(struct smbsrv_request *req, union smb_close *io)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_close(private->tree, io);
static NTSTATUS cvfs_lock(struct smbsrv_request *req, union smb_lock *lck)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_lock(private->tree, lck);
union smb_setfileinfo *info)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_setfileinfo(private->tree, info);
/*
a handler for async fsinfo replies
*/
-static void async_fsinfo(struct cli_request *c_req)
+static void async_fsinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_fsinfo(private->tree, req->mem_ctx, fs);
/*
a handler for async trans2 replies
*/
-static void async_trans2(struct cli_request *c_req)
+static void async_trans2(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
static NTSTATUS cvfs_trans2(struct smbsrv_request *req, struct smb_trans2 *trans2)
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- struct cli_request *c_req;
+ struct smbcli_request *c_req;
if (!req->async.send_fn) {
return smb_raw_trans2(private->tree, req->mem_ctx, trans2);
#include "includes.h"
-int create_complex_file(struct cli_state *cli, TALLOC_CTX *mem_ctx, const char *fname);
+int create_complex_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *fname);
struct trans2_blobs {
struct trans2_blobs *next, *prev;
};
/* look for aliases for a query */
-static void gen_aliases(struct cli_state *cli, struct smb_trans2 *t2, int level_offset)
+static void gen_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int level_offset)
{
TALLOC_CTX *mem_ctx;
uint16_t level;
}
/* look for qfsinfo aliases */
-static void qfsinfo_aliases(struct cli_state *cli)
+static void qfsinfo_aliases(struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_QFSINFO;
}
/* look for qfileinfo aliases */
-static void qfileinfo_aliases(struct cli_state *cli)
+static void qfileinfo_aliases(struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_QFILEINFO;
t2.in.params = data_blob(NULL, 4);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
}
- cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ smbcli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
SSVAL(t2.in.params.data, 0, fnum);
gen_aliases(cli, &t2, 2);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
}
/* look for qpathinfo aliases */
-static void qpathinfo_aliases(struct cli_state *cli)
+static void qpathinfo_aliases(struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_QPATHINFO;
t2.in.params = data_blob_talloc(mem_ctx, NULL, 6);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
}
- cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
- cli_close(cli->tree, fnum);
+ smbcli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ smbcli_close(cli->tree, fnum);
SIVAL(t2.in.params.data, 2, 0);
- cli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
+ smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
fname, STR_TERMINATE);
gen_aliases(cli, &t2, 0);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
talloc_destroy(mem_ctx);
}
/* look for trans2 findfirst aliases */
-static void findfirst_aliases(struct cli_state *cli)
+static void findfirst_aliases(struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_FINDFIRST;
t2.in.params = data_blob_talloc(mem_ctx, NULL, 12);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
}
- cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
- cli_close(cli->tree, fnum);
+ smbcli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ smbcli_close(cli->tree, fnum);
SSVAL(t2.in.params.data, 0, 0);
SSVAL(t2.in.params.data, 2, 1);
SSVAL(t2.in.params.data, 6, 0);
SIVAL(t2.in.params.data, 8, 0);
- cli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
+ smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
fname, STR_TERMINATE);
gen_aliases(cli, &t2, 6);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
talloc_destroy(mem_ctx);
}
/* look for aliases for a set function */
-static void gen_set_aliases(struct cli_state *cli, struct smb_trans2 *t2, int level_offset)
+static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int level_offset)
{
TALLOC_CTX *mem_ctx;
uint16_t level;
/* look for setfileinfo aliases */
-static void setfileinfo_aliases(struct cli_state *cli)
+static void setfileinfo_aliases(struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_SETFILEINFO;
t2.in.params = data_blob(NULL, 6);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
}
- cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ smbcli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
SSVAL(t2.in.params.data, 0, fnum);
SSVAL(t2.in.params.data, 4, 0);
gen_set_aliases(cli, &t2, 2);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
}
/* look for setpathinfo aliases */
-static void setpathinfo_aliases(struct cli_state *cli)
+static void setpathinfo_aliases(struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_SETPATHINFO;
t2.in.params = data_blob_talloc(mem_ctx, NULL, 4);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
}
- cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
- cli_close(cli->tree, fnum);
+ smbcli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ smbcli_close(cli->tree, fnum);
SSVAL(t2.in.params.data, 2, 0);
- cli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
+ smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
fname, STR_TERMINATE);
gen_set_aliases(cli, &t2, 0);
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, fname))) {
- printf("unlink: %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
+ printf("unlink: %s\n", smbcli_errstr(cli->tree));
}
talloc_destroy(mem_ctx);
}
/* look for aliased info levels in trans2 calls */
BOOL torture_trans2_aliases(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
if (!torture_open_connection(&cli)) {
return False;
the prefix BASEDIR is added before the name
*/
-static NTSTATUS unicode_open(struct cli_tree *tree,
+static NTSTATUS unicode_open(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
uint32_t open_disposition,
const uint32_t *u_name,
/*
see if the server recognises composed characters
*/
-static BOOL test_composed(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_composed(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {0x61, 0x308};
const uint32_t name2[] = {0xe4};
/*
see if the server recognises a naked diacritical
*/
-static BOOL test_diacritical(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_diacritical(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {0x308};
const uint32_t name2[] = {0x308, 0x308};
/*
see if the server recognises a partial surrogate pair
*/
-static BOOL test_surrogate(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_surrogate(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {0xd800};
const uint32_t name2[] = {0xdc00};
/*
see if the server recognises wide-a characters
*/
-static BOOL test_widea(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_widea(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {'a'};
const uint32_t name2[] = {0xff41};
BOOL torture_charset(int dummy)
{
- static struct cli_state *cli;
+ static struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
printf("Starting charset tests\n");
- if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to clean " BASEDIR "\n");
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
*/
BOOL torture_denytest1(int dummy)
{
- static struct cli_state *cli1;
+ static struct smbcli_state *cli1;
int fnum1, fnum2;
int i;
BOOL correct = True;
printf("Testing deny modes with 1 connection\n");
for (i=0;i<2;i++) {
- cli_unlink(cli1->tree, fnames[i]);
- fnum1 = cli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
- cli_write(cli1->tree, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
- cli_close(cli1->tree, fnum1);
+ smbcli_unlink(cli1->tree, fnames[i]);
+ fnum1 = smbcli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
+ smbcli_write(cli1->tree, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+ smbcli_close(cli1->tree, fnum1);
}
printf("testing %d entries\n", ARRAY_SIZE(denytable1));
progress_bar(i, ARRAY_SIZE(denytable1));
- fnum1 = cli_open(cli1->tree, fname,
+ fnum1 = smbcli_open(cli1->tree, fname,
denytable1[i].mode1,
denytable1[i].deny1);
- fnum2 = cli_open(cli1->tree, fname,
+ fnum2 = smbcli_open(cli1->tree, fname,
denytable1[i].mode2,
denytable1[i].deny2);
} else {
char x = 1;
res = A_0;
- if (cli_read(cli1->tree, fnum2, (void *)&x, 0, 1) == 1) {
+ if (smbcli_read(cli1->tree, fnum2, (void *)&x, 0, 1) == 1) {
res += A_R;
}
- if (cli_write(cli1->tree, fnum2, 0, (void *)&x, 0, 1) == 1) {
+ if (smbcli_write(cli1->tree, fnum2, 0, (void *)&x, 0, 1) == 1) {
res += A_W;
}
}
resultstr(denytable1[i].result));
}
- cli_close(cli1->tree, fnum1);
- cli_close(cli1->tree, fnum2);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
}
for (i=0;i<2;i++) {
- cli_unlink(cli1->tree, fnames[i]);
+ smbcli_unlink(cli1->tree, fnames[i]);
}
if (!torture_close_connection(cli1)) {
*/
BOOL torture_denytest2(int dummy)
{
- static struct cli_state *cli1, *cli2;
+ static struct smbcli_state *cli1, *cli2;
int fnum1, fnum2;
int i;
BOOL correct = True;
printf("Testing deny modes with 2 connections\n");
for (i=0;i<2;i++) {
- cli_unlink(cli1->tree, fnames[i]);
- fnum1 = cli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
- cli_write(cli1->tree, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
- cli_close(cli1->tree, fnum1);
+ smbcli_unlink(cli1->tree, fnames[i]);
+ fnum1 = smbcli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
+ smbcli_write(cli1->tree, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+ smbcli_close(cli1->tree, fnum1);
}
GetTimeOfDay(&tv_start);
progress_bar(i, ARRAY_SIZE(denytable1));
- fnum1 = cli_open(cli1->tree, fname,
+ fnum1 = smbcli_open(cli1->tree, fname,
denytable2[i].mode1,
denytable2[i].deny1);
- fnum2 = cli_open(cli2->tree, fname,
+ fnum2 = smbcli_open(cli2->tree, fname,
denytable2[i].mode2,
denytable2[i].deny2);
} else {
char x = 1;
res = A_0;
- if (cli_read(cli2->tree, fnum2, (void *)&x, 0, 1) == 1) {
+ if (smbcli_read(cli2->tree, fnum2, (void *)&x, 0, 1) == 1) {
res += A_R;
}
- if (cli_write(cli2->tree, fnum2, 0, (void *)&x, 0, 1) == 1) {
+ if (smbcli_write(cli2->tree, fnum2, 0, (void *)&x, 0, 1) == 1) {
res += A_W;
}
}
resultstr(denytable2[i].result));
}
- cli_close(cli1->tree, fnum1);
- cli_close(cli2->tree, fnum2);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli2->tree, fnum2);
}
for (i=0;i<2;i++) {
- cli_unlink(cli1->tree, fnames[i]);
+ smbcli_unlink(cli1->tree, fnames[i]);
}
if (!torture_close_connection(cli1)) {
#define DFS_SERVER_COUNT 6
#define DFS_FILE_COUNT 8
extern char *host, *share, *password, *username;
-static struct cli_client context;
+static struct smbcli_client context;
static const char *sockops="TCP_NODELAY";
/*
const char *template = "\\\\%s\\%s\\dfstest%d.tmp";
char *filedata;
int server_count = 0;
- int connection_flags = CLI_FULL_CONNECTION_USE_KERBEROS
- | CLI_FULL_CONNECTION_USE_DFS
+ int connection_flags = SMBCLI_FULL_CONNECTION_USE_KERBEROS
+ | SMBCLI_FULL_CONNECTION_USE_DFS
;
printf("starting dfs_basic_test\n");
- cli_client_initialize(&context, sockops, username, password, lp_workgroup(), connection_flags);
+ smbcli_client_initialize(&context, sockops, username, password, lp_workgroup(), connection_flags);
- if ((current_server = cli_dfs_open_connection(&context, host, share, connection_flags) < 0))
+ if ((current_server = smbcli_dfs_open_connection(&context, host, share, connection_flags) < 0))
return False;
for (i=0; i < DFS_FILE_COUNT ; i++) {
file_server[i] = 0;
DEBUG(4,("host=%s share=%s cli host=%s cli share=%s\n",
- host, share, cli_state_get_host(context.cli[file_server[i]]),
- cli_state_get_share(context.cli[file_server[i]])));
- host = cli_state_get_host(context.cli[file_server[i]]);
- share = cli_state_get_share(context.cli[file_server[i]]);
+ host, share, smbcli_state_get_host(context.cli[file_server[i]]),
+ smbcli_state_get_share(context.cli[file_server[i]])));
+ host = smbcli_state_get_host(context.cli[file_server[i]]);
+ share = smbcli_state_get_share(context.cli[file_server[i]]);
asprintf(&fname[i], template, host, share, i);
DEBUG(3,("unlinking %s\n", fname[i]));
- cli_nt_unlink(&context, &file_server[i], fname[i], 0);
+ smbcli_nt_unlink(&context, &file_server[i], fname[i], 0);
}
for (i=0; i < DFS_FILE_COUNT ; i++) {
- host = cli_state_get_host(context.cli[file_server[i]]);
- share = cli_state_get_share(context.cli[file_server[i]]);
+ host = smbcli_state_get_host(context.cli[file_server[i]]);
+ share = smbcli_state_get_share(context.cli[file_server[i]]);
asprintf(&fname[i], template, host, share, i);
DEBUG(3,("open %s on server %s(%d)\n",
fname[i], host, file_server[i]));
- fnum[i] = cli_dfs_open(&context, &file_server[i], fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum[i] = smbcli_dfs_open(&context, &file_server[i], fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum[i] == -1)
{
- printf("open of %s failed (%s)\n", fname[i], cli_errstr(context.cli[file_server[i]]));
+ printf("open of %s failed (%s)\n", fname[i], smbcli_errstr(context.cli[file_server[i]]));
return False;
}
asprintf(&filedata, "%s %d", fname[i], fnum[i]);
DEBUG(3,("write %d bytes (%s) to %s (fid %d) on server %s(%d)\n",
strlen(filedata), filedata, fname[i], fnum[i],
host, file_server[i]));
- if (cli_write(context.cli[file_server[i]], fnum[i], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
+ if (smbcli_write(context.cli[file_server[i]], fnum[i], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
{
- printf("write failed (%s)\n", cli_errstr(context.cli[file_server[i]]));
+ printf("write failed (%s)\n", smbcli_errstr(context.cli[file_server[i]]));
return False;
}
- if (!cli_close(context.cli[file_server[i]], fnum[i])) {
- printf("close of %s failed (%s)\n", fname[i], cli_errstr(context.cli[file_server[i]]));
+ if (!smbcli_close(context.cli[file_server[i]], fnum[i])) {
+ printf("close of %s failed (%s)\n", fname[i], smbcli_errstr(context.cli[file_server[i]]));
return False;
}
}
DEBUG(3,("used Dfs servers:"));
for (i=0; i < DFS_SERVER_COUNT ; i++) {
server_count++;
- DEBUG(3,(" %s(%d)", cli_state_get_host(context.cli[file_server[i]]), i));
+ DEBUG(3,(" %s(%d)", smbcli_state_get_host(context.cli[file_server[i]]), i));
if (!torture_close_connection(context.cli[i]))
return False;
}
const char *template2new = "\\\\%s\\%s\\~dfstestnew.txt";
char *filedata, *newdata;
int server_count = 0;
- int connection_flags = CLI_FULL_CONNECTION_USE_KERBEROS
- | CLI_FULL_CONNECTION_USE_DFS
+ int connection_flags = SMBCLI_FULL_CONNECTION_USE_KERBEROS
+ | SMBCLI_FULL_CONNECTION_USE_DFS
;
printf("starting dfs_rename_test\n");
- cli_client_initialize(&context, sockops, username, password,
+ smbcli_client_initialize(&context, sockops, username, password,
lp_workgroup(), connection_flags);
- if ((current_server = cli_dfs_open_connection(&context, host, share, connection_flags)) < 0)
+ if ((current_server = smbcli_dfs_open_connection(&context, host, share, connection_flags)) < 0)
return False;
for (i=0; i < DFS_FILE_COUNT ; i++) {
file_server[i] = 0;
slprintf(fname[i],sizeof(fstring)-1,template, host, share, i);
DEBUG(3,("unlinking %s\n", fname[i]));
- cli_nt_unlink(&context, &file_server[i], fname[i], 0);
+ smbcli_nt_unlink(&context, &file_server[i], fname[i], 0);
}
/* Simple rename test */
for (i=0; i < 1 ; i++) {
slprintf(fname[i],sizeof(fstring)-1,template,
- cli_state_get_host(context.cli[file_server[i]]),
- cli_state_get_share(context.cli[file_server[i]]), i);
+ smbcli_state_get_host(context.cli[file_server[i]]),
+ smbcli_state_get_share(context.cli[file_server[i]]), i);
DEBUG(3,("open %s on server %s(%d)\n",
- fname[i], cli_state_get_host(context.cli[file_server[i]]), file_server[i]));
+ fname[i], smbcli_state_get_host(context.cli[file_server[i]]), file_server[i]));
- fnum[i] = cli_dfs_open(&context, &file_server[i], fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum[i] = smbcli_dfs_open(&context, &file_server[i], fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum[i] == -1) {
- printf("open of %s failed (%s)\n", fname[i], cli_errstr(context.cli[file_server[i]]));
+ printf("open of %s failed (%s)\n", fname[i], smbcli_errstr(context.cli[file_server[i]]));
return False;
}
asprintf(&filedata, "%s %d", fname[i], (int)getpid());
DEBUG(3,("write %d bytes (%s) to %s (fid %d) on server %s(%d)\n",
strlen(filedata), filedata, fname[i], fnum[i],
- cli_state_get_host(context.cli[file_server[i]]), file_server[i]));
- if (cli_write(context.cli[file_server[i]], fnum[i], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
+ smbcli_state_get_host(context.cli[file_server[i]]), file_server[i]));
+ if (smbcli_write(context.cli[file_server[i]], fnum[i], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
{
- printf("write failed (%s)\n", cli_errstr(context.cli[file_server[i]]));
+ printf("write failed (%s)\n", smbcli_errstr(context.cli[file_server[i]]));
return False;
}
- if (!cli_close(context.cli[file_server[i]], fnum[i])) {
- printf("close of %s failed (%s)\n", fname[i], cli_errstr(context.cli[file_server[i]]));
+ if (!smbcli_close(context.cli[file_server[i]], fnum[i])) {
+ printf("close of %s failed (%s)\n", fname[i], smbcli_errstr(context.cli[file_server[i]]));
return False;
}
}
// now attempt to rename the file
DEBUG(3,("rename %s to %s on server %s(%d)\n",
- fname[0], fname[1], cli_state_get_host(context.cli[file_server[i]]), file_server[0]));
- if (!cli_dfs_rename(&context, &file_server[0], fname[0], fname[1])) {
- printf("rename of %s to %s failed (%s)\n", fname[0], fname[1], cli_errstr(context.cli[file_server[0]]));
+ fname[0], fname[1], smbcli_state_get_host(context.cli[file_server[i]]), file_server[0]));
+ if (!smbcli_dfs_rename(&context, &file_server[0], fname[0], fname[1])) {
+ printf("rename of %s to %s failed (%s)\n", fname[0], fname[1], smbcli_errstr(context.cli[file_server[0]]));
return False;
}
// clean up
DEBUG(3,("used Dfs servers:"));
for (i=0; i < DFS_SERVER_COUNT ; i++) {
server_count++;
- DEBUG(3,(" %s(%d)", cli_state_get_host(context.cli[file_server[i]]), i));
+ DEBUG(3,(" %s(%d)", smbcli_state_get_host(context.cli[file_server[i]]), i));
if (!torture_close_connection(context.cli[i]))
return False;
}
* Then open, write to new temp name file (~x.new), close.
* Then rename old file name to old temp name file (~x.old).
* Then rename new temp name file to oroginal name (x). */
- cli_client_initialize(&context, sockops, username, password,
+ smbcli_client_initialize(&context, sockops, username, password,
lp_workgroup(), connection_flags);
- if ((current_server = cli_dfs_open_connection(&context, host, share, connection_flags)) < 0)
+ if ((current_server = smbcli_dfs_open_connection(&context, host, share, connection_flags)) < 0)
return False;
slprintf(fname[0],sizeof(fname[0])-1,template2orig, host, share);
slprintf(fname[1],sizeof(fname[1])-1,template2old, host, share);
file_server[i] = 0;
fnum[i] = 0;
DEBUG(3,("unlinking %s\n", fname[i]));
- cli_nt_unlink(&context, &file_server[i], fname[i], 0);
+ smbcli_nt_unlink(&context, &file_server[i], fname[i], 0);
}
asprintf(&fname[0],template2orig,
- cli_state_get_host(context.cli[0]),
- cli_state_get_share(context.cli[0]), 0);
+ smbcli_state_get_host(context.cli[0]),
+ smbcli_state_get_share(context.cli[0]), 0);
asprintf(&fname[1],template2old,
- cli_state_get_host(context.cli[1]),
- cli_state_get_share(context.cli[1]), 1);
+ smbcli_state_get_host(context.cli[1]),
+ smbcli_state_get_share(context.cli[1]), 1);
asprintf(&fname[2],template2new,
- cli_state_get_host(context.cli[2]),
- cli_state_get_share(context.cli[2]), 2);
+ smbcli_state_get_host(context.cli[2]),
+ smbcli_state_get_share(context.cli[2]), 2);
DEBUG(3,("edit(MS Word) %s on server %s(%d)\n",
- fname[0], cli_state_get_host(context.cli[0]), file_server[0]));
+ fname[0], smbcli_state_get_host(context.cli[0]), file_server[0]));
DEBUG(3,("open %s on server %s(%d)\n",
- fname[0], cli_state_get_host(context.cli[0]), file_server[0]));
+ fname[0], smbcli_state_get_host(context.cli[0]), file_server[0]));
- fnum[0] = cli_dfs_open(&context, &file_server[0], fname[0], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum[0] = smbcli_dfs_open(&context, &file_server[0], fname[0], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum[0] == -1)
{
- printf("open of %s failed (%s)\n", fname[0], cli_errstr(context.cli[file_server[0]]));
+ printf("open of %s failed (%s)\n", fname[0], smbcli_errstr(context.cli[file_server[0]]));
return False;
}
slprintf(filedata, sizeof(fstring)-1, "%s %d", fname[0], (int)getpid());
DEBUG(3,("write %d bytes (%s) to %s (fid %d) on server %s(%d)\n",
strlen(filedata), filedata, fname[0], fnum[0],
- cli_state_get_host(context.cli[0]), file_server[0]));
- if (cli_write(context.cli[file_server[0]], fnum[0], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
+ smbcli_state_get_host(context.cli[0]), file_server[0]));
+ if (smbcli_write(context.cli[file_server[0]], fnum[0], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
{
- printf("write failed (%s)\n", cli_errstr(context.cli[file_server[0]]));
+ printf("write failed (%s)\n", smbcli_errstr(context.cli[file_server[0]]));
return False;
}
// read data from original file
DEBUG(3,("read %s (fid %d) on server %s(%d)\n",
- fname[0], fnum[0], cli_state_get_host(context.cli[0]), file_server[0]));
- if (cli_read(context.cli[file_server[0]], fnum[0], filedata, 0, strlen(filedata)) != strlen(filedata))
+ fname[0], fnum[0], smbcli_state_get_host(context.cli[0]), file_server[0]));
+ if (smbcli_read(context.cli[file_server[0]], fnum[0], filedata, 0, strlen(filedata)) != strlen(filedata))
{
- printf("read failed (%s)", cli_errstr(context.cli[file_server[0]]));
+ printf("read failed (%s)", smbcli_errstr(context.cli[file_server[0]]));
return False;
}
DEBUG(3,("close %s on server %s(%d)\n",
- fname[0], cli_state_get_host(context.cli[0]), file_server[0]));
- if (!cli_close(context.cli[file_server[0]], fnum[0])) {
- printf("close of %s failed (%s)\n", fname[0], cli_errstr(context.cli[file_server[0]]));
+ fname[0], smbcli_state_get_host(context.cli[0]), file_server[0]));
+ if (!smbcli_close(context.cli[file_server[0]], fnum[0])) {
+ printf("close of %s failed (%s)\n", fname[0], smbcli_errstr(context.cli[file_server[0]]));
return False;
}
// open new temp file, write data
DEBUG(3,("open %s on server %s(%d)\n",
- fname[2], cli_state_get_host(context.cli[2]), file_server[2]));
- fnum[2] = cli_dfs_open(&context, &file_server[2], fname[2], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fname[2], smbcli_state_get_host(context.cli[2]), file_server[2]));
+ fnum[2] = smbcli_dfs_open(&context, &file_server[2], fname[2], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum[2] == -1)
{
- printf("open of %s failed (%s)\n", fname[2], cli_errstr(context.cli[file_server[2]]));
+ printf("open of %s failed (%s)\n", fname[2], smbcli_errstr(context.cli[file_server[2]]));
return False;
}
DEBUG(3,("write %d bytes (%s) to %s (fid %d) on server %s(%d)\n",
strlen(filedata), filedata, fname[2], fnum[2],
- cli_state_get_host(context.cli[2]), file_server[2]));
- if (cli_write(context.cli[file_server[2]], fnum[2], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
+ smbcli_state_get_host(context.cli[2]), file_server[2]));
+ if (smbcli_write(context.cli[file_server[2]], fnum[2], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
{
- printf("write failed (%s)\n", cli_errstr(context.cli[file_server[2]]));
+ printf("write failed (%s)\n", smbcli_errstr(context.cli[file_server[2]]));
return False;
}
slprintf(newdata, sizeof(fstring)-1, "new data: %s %d", fname[0], (int)getpid());
DEBUG(3,("write new data %d bytes (%s) to %s (fid %d) on server %s(%d)\n",
strlen(newdata), newdata, fname[2], fnum[2],
- cli_state_get_host(context.cli[2]), file_server[2]));
- if (cli_write(context.cli[file_server[2]], fnum[2], 0, newdata, strlen(filedata), strlen(newdata)) != strlen(newdata))
+ smbcli_state_get_host(context.cli[2]), file_server[2]));
+ if (smbcli_write(context.cli[file_server[2]], fnum[2], 0, newdata, strlen(filedata), strlen(newdata)) != strlen(newdata))
{
- printf("write failed (%s)\n", cli_errstr(context.cli[file_server[2]]));
+ printf("write failed (%s)\n", smbcli_errstr(context.cli[file_server[2]]));
return False;
}
DEBUG(3,("close %s on server %s(%d)\n",
- fname[2], cli_state_get_host(context.cli[2]), file_server[2]));
- if (!cli_close(context.cli[file_server[2]], fnum[2])) {
- printf("close of %s failed (%s)\n", fname[2], cli_errstr(context.cli[file_server[2]]));
+ fname[2], smbcli_state_get_host(context.cli[2]), file_server[2]));
+ if (!smbcli_close(context.cli[file_server[2]], fnum[2])) {
+ printf("close of %s failed (%s)\n", fname[2], smbcli_errstr(context.cli[file_server[2]]));
return False;
}
DEBUG(3,("close successful %s on server %s(%d)\n",
- fname[2], cli_state_get_host(context.cli[2]), file_server[2]));
+ fname[2], smbcli_state_get_host(context.cli[2]), file_server[2]));
// rename original file to temp
DEBUG(4,("file_server[0]=%d\n", file_server[0]));
- DEBUG(4,("context.cli[file_server[0]].desthost=%s\n", cli_state_get_host(context.cli[0])));
+ DEBUG(4,("context.cli[file_server[0]].desthost=%s\n", smbcli_state_get_host(context.cli[0])));
DEBUG(3,("rename %s to %s on server %s(%d)\n",
- fname[0], fname[1], cli_state_get_host(context.cli[0]), file_server[0]));
- if (!cli_dfs_rename(&context, &file_server[0], fname[0], fname[1])) {
- printf("rename of %s to %s failed (%s)\n", fname[0], fname[1], cli_errstr(context.cli[file_server[0]]));
+ fname[0], fname[1], smbcli_state_get_host(context.cli[0]), file_server[0]));
+ if (!smbcli_dfs_rename(&context, &file_server[0], fname[0], fname[1])) {
+ printf("rename of %s to %s failed (%s)\n", fname[0], fname[1], smbcli_errstr(context.cli[file_server[0]]));
return False;
}
// name new temp file to original
DEBUG(3,("rename %s to %s on server %s(%d)\n",
- fname[2], fname[0], cli_state_get_host(context.cli[2]), file_server[2]));
- if (!cli_dfs_rename(&context, &file_server[2], fname[2], fname[0])) {
- printf("rename of %s to %s failed (%s)\n", fname[2], fname[0], cli_errstr(context.cli[file_server[2]]));
+ fname[2], fname[0], smbcli_state_get_host(context.cli[2]), file_server[2]));
+ if (!smbcli_dfs_rename(&context, &file_server[2], fname[2], fname[0])) {
+ printf("rename of %s to %s failed (%s)\n", fname[2], fname[0], smbcli_errstr(context.cli[file_server[2]]));
return False;
}
printf("Dfstest: passed MS Word rename test\n");
DEBUG(3,("used Dfs servers:"));
for (i=0; i < DFS_SERVER_COUNT ; i++) {
server_count++;
- DEBUG(3,(" %s(%d)", cli_state_get_host(context.cli[i]), i));
+ DEBUG(3,(" %s(%d)", smbcli_state_get_host(context.cli[i]), i));
if (!torture_close_connection(context.cli[i]))
return False;
}
return True;
}
struct list_fn_parms {
- struct cli_client *context;
+ struct smbcli_client *context;
char* rname;
} list_fn_parms;
DEBUG(3,("deleting file %s in %s\n", finfo->name, rname));
asprintf(&fname, "%s\\%s", rname, finfo->name);
- cli_nt_unlink(&context, &server, fname, 0);
+ smbcli_nt_unlink(&context, &server, fname, 0);
}
void delete_directory(file_info *finfo, const char *rname)
{
DEBUG(3,("deleting directory %s in %s\n", finfo->name, rname));
asprintf(&dname, "%s%s\\*", rname, finfo->name);
- cli_nt_unlink(&context, &server, dname, 0);
+ smbcli_nt_unlink(&context, &server, dname, 0);
asprintf(&dname, "%s%s\\*", rname, finfo->name);
asprintf(&rname2, "%s%s", rname, finfo->name);
- cli_search(context.cli[0], dname, FILE_ATTRIBUTE_DIRECTORY,
+ smbcli_search(context.cli[0], dname, FILE_ATTRIBUTE_DIRECTORY,
dfs_list_fn, (void*)rname2);
- cli_dfs_rmdir(&context, &server, rname2);
+ smbcli_dfs_rmdir(&context, &server, rname2);
}
void dfs_list_fn(file_info *finfo, const char *name, void* parmsp)
char *filedata;
int server_count = 0;
int file_count;
- int connection_flags = CLI_FULL_CONNECTION_USE_KERBEROS
- | CLI_FULL_CONNECTION_USE_DFS
+ int connection_flags = SMBCLI_FULL_CONNECTION_USE_KERBEROS
+ | SMBCLI_FULL_CONNECTION_USE_DFS
;
printf("starting dfs_random_test\n");
- cli_client_initialize(&context, sockops, username, password,
+ smbcli_client_initialize(&context, sockops, username, password,
lp_workgroup(), connection_flags);
- if ((dir_server[0] = cli_dfs_open_connection(&context, host, share, connection_flags)) < 0)
+ if ((dir_server[0] = smbcli_dfs_open_connection(&context, host, share, connection_flags)) < 0)
return False;
// get list of directories named dfsdir*.
// delete all files in these directories using wild card,
// then delete directory.
asprintf(&rname, "\\\\%s\\%s\\",
- cli_state_get_host(context.cli[0]),
- cli_state_get_share(context.cli[0]));
+ smbcli_state_get_host(context.cli[0]),
+ smbcli_state_get_share(context.cli[0]));
asprintf(&fname[0], alltemplate,
- cli_state_get_host(context.cli[0]),
- cli_state_get_share(context.cli[0]));
+ smbcli_state_get_host(context.cli[0]),
+ smbcli_state_get_share(context.cli[0]));
DEBUG(3,("deleting files %s in %s on server %s(%d)\n",
- fname[0], rname, cli_state_get_host(context.cli[0]), dir_server[0]));
- file_count = cli_search(context.cli[0], fname[0], FILE_ATTRIBUTE_DIRECTORY, dfs_list_fn, (void*)rname);
+ fname[0], rname, smbcli_state_get_host(context.cli[0]), dir_server[0]));
+ file_count = smbcli_search(context.cli[0], fname[0], FILE_ATTRIBUTE_DIRECTORY, dfs_list_fn, (void*)rname);
// create random directory names with 0-n levels
asprintf(&dname[0], "\\\\%s\\%s\\",
- cli_state_get_host(context.cli[0]),
- cli_state_get_share(context.cli[0]));
+ smbcli_state_get_host(context.cli[0]),
+ smbcli_state_get_share(context.cli[0]));
DEBUG(3,("creating directories in %s on server %s(%d)\n",
- rname, cli_state_get_host(context.cli[0]), dir_server[0]));
+ rname, smbcli_state_get_host(context.cli[0]), dir_server[0]));
for (i=1; i < DFS_RANDOM_DIR_COUNT; i++) {
dir_server[i] = 0;
asprintf(&dname[i],
"\\\\%s\\%s\\dfsdir%d.tmp",
- cli_state_get_host(context.cli[dir_server[i]]),
- cli_state_get_share(context.cli[dir_server[i]]),
+ smbcli_state_get_host(context.cli[dir_server[i]]),
+ smbcli_state_get_share(context.cli[dir_server[i]]),
(int)sys_random()%10000);
DEBUG(3,("mkdir %s on server %s(%d)\n",
- dname[i], cli_state_get_host(context.cli[dir_server[i]]), dir_server[i]));
- if (!cli_dfs_mkdir(&context, &dir_server[i], dname[i])) {
- printf("mkdir of %s failed (%s)\n", dname[i], cli_errstr(context.cli[dir_server[i]]));
+ dname[i], smbcli_state_get_host(context.cli[dir_server[i]]), dir_server[i]));
+ if (!smbcli_dfs_mkdir(&context, &dir_server[i], dname[i])) {
+ printf("mkdir of %s failed (%s)\n", dname[i], smbcli_errstr(context.cli[dir_server[i]]));
return False;
}
}
file_server[i] = dir_server[dn];
asprintf(&fname[i], ftemplate, dname[dn], i);
DEBUG(3,("open %s on server %s(%d)\n",
- fname[i], cli_state_get_host(context.cli[dir_server[i]]), file_server[i]));
- fnum[i] = cli_dfs_open(&context, &file_server[i], fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fname[i], smbcli_state_get_host(context.cli[dir_server[i]]), file_server[i]));
+ fnum[i] = smbcli_dfs_open(&context, &file_server[i], fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum[i] == -1)
{
- printf("open of %s failed (%s)\n", fname[i], cli_errstr(context.cli[file_server[i]]));
+ printf("open of %s failed (%s)\n", fname[i], smbcli_errstr(context.cli[file_server[i]]));
return False;
}
asprintf(&filedata, "%s %d", fname[i], fnum[i]);
DEBUG(3,("write %d bytes (%s) to %s (fid %d) on server %s(%d)\n",
strlen(filedata), filedata, fname[i], fnum[i],
- cli_state_get_host(context.cli[dir_server[i]]), file_server[i]));
- if (cli_write(context.cli[file_server[i]], fnum[i], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
+ smbcli_state_get_host(context.cli[dir_server[i]]), file_server[i]));
+ if (smbcli_write(context.cli[file_server[i]], fnum[i], 0, filedata, 0, strlen(filedata)) != strlen(filedata))
{
- printf("write failed (%s)\n", cli_errstr(context.cli[file_server[i]]));
+ printf("write failed (%s)\n", smbcli_errstr(context.cli[file_server[i]]));
return False;
}
- if (!cli_close(context.cli[file_server[i]], fnum[i])) {
- printf("close of %s failed (%s)\n", fname[i], cli_errstr(context.cli[file_server[i]]));
+ if (!smbcli_close(context.cli[file_server[i]], fnum[i])) {
+ printf("close of %s failed (%s)\n", fname[i], smbcli_errstr(context.cli[file_server[i]]));
return False;
}
}
DEBUG(3,("used Dfs servers:"));
for (i=0; i < DFS_SERVER_COUNT ; i++) {
server_count++;
- DEBUG(3,(" %s(%d)", cli_state_get_host(context.cli[i]), i));
+ DEBUG(3,(" %s(%d)", smbcli_state_get_host(context.cli[i]), i));
if (!torture_close_connection(context.cli[i]))
return False;
}
static uint_t total, collisions, failures;
-static BOOL test_one(struct cli_state *cli, const char *name)
+static BOOL test_one(struct smbcli_state *cli, const char *name)
{
int fnum;
const char *shortname;
total++;
- fnum = cli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = smbcli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", name, cli_errstr(cli->tree));
+ printf("open of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
- printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
+ printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
return False;
}
/* get the short name */
- status = cli_qpathinfo_alt_name(cli->tree, name, &shortname);
+ status = smbcli_qpathinfo_alt_name(cli->tree, name, &shortname);
if (!NT_STATUS_IS_OK(status)) {
- printf("query altname of %s failed (%s)\n", name, cli_errstr(cli->tree));
+ printf("query altname of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
return False;
}
snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname);
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, name2))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name2))) {
printf("unlink of %s (%s) failed (%s)\n",
- name2, name, cli_errstr(cli->tree));
+ name2, name, smbcli_errstr(cli->tree));
return False;
}
/* recreate by short name */
- fnum = cli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = smbcli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli->tree));
+ printf("open2 of %s failed (%s)\n", name2, smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
- printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
+ printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
return False;
}
/* and unlink by long name */
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, name))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name))) {
printf("unlink2 of %s (%s) failed (%s)\n",
- name, name2, cli_errstr(cli->tree));
+ name, name2, smbcli_errstr(cli->tree));
failures++;
- cli_unlink(cli->tree, name2);
+ smbcli_unlink(cli->tree, name2);
return True;
}
BOOL torture_mangle(int dummy)
{
extern int torture_numops;
- static struct cli_state *cli;
+ static struct smbcli_state *cli;
int i;
printf("starting mangle test\n");
return False;
}
- cli_unlink(cli->tree, "\\mangle_test\\*");
- cli_rmdir(cli->tree, "\\mangle_test");
+ smbcli_unlink(cli->tree, "\\mangle_test\\*");
+ smbcli_rmdir(cli->tree, "\\mangle_test");
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\mangle_test"))) {
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\mangle_test"))) {
printf("ERROR: Failed to make directory\n");
return False;
}
}
}
- cli_unlink(cli->tree, "\\mangle_test\\*");
- if (NT_STATUS_IS_ERR(cli_rmdir(cli->tree, "\\mangle_test"))) {
+ smbcli_unlink(cli->tree, "\\mangle_test\\*");
+ if (NT_STATUS_IS_ERR(smbcli_rmdir(cli->tree, "\\mangle_test"))) {
printf("ERROR: Failed to remove directory\n");
return False;
}
/****************************************************************************
check for existance of a trans2 call
****************************************************************************/
-static NTSTATUS try_trans2(struct cli_state *cli,
+static NTSTATUS try_trans2(struct smbcli_state *cli,
int op,
char *param, char *data,
int param_len, int data_len,
}
-static NTSTATUS try_trans2_len(struct cli_state *cli,
+static NTSTATUS try_trans2_len(struct smbcli_state *cli,
const char *format,
int op, int level,
char *param, char *data,
/****************************************************************************
check whether a trans2 opnum exists at all
****************************************************************************/
-static BOOL trans2_op_exists(struct cli_state *cli, int op)
+static BOOL trans2_op_exists(struct smbcli_state *cli, int op)
{
int data_len = 0;
int param_len = 0;
/****************************************************************************
check for existance of a trans2 call
****************************************************************************/
-static BOOL scan_trans2(struct cli_state *cli, int op, int level,
+static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
int fnum, int dnum, int qfnum, const char *fname)
{
int data_len = 0;
status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_unlink(cli->tree, "\\newfile.dat");
- cli_rmdir(cli->tree, "\\newfile.dat");
+ smbcli_unlink(cli->tree, "\\newfile.dat");
+ smbcli_rmdir(cli->tree, "\\newfile.dat");
if (NT_STATUS_IS_OK(status)) return True;
/* try dfs style */
- cli_mkdir(cli->tree, "\\testdir");
+ smbcli_mkdir(cli->tree, "\\testdir");
param_len = 2;
SSVAL(param, 0, level);
param_len += push_string(NULL, ¶m[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE);
status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_rmdir(cli->tree, "\\testdir");
+ smbcli_rmdir(cli->tree, "\\testdir");
if (NT_STATUS_IS_OK(status)) return True;
return False;
BOOL torture_trans2_scan(int dummy)
{
- static struct cli_state *cli;
+ static struct smbcli_state *cli;
int op, level;
const char *fname = "\\scanner.dat";
int fnum, dnum, qfnum;
return False;
}
- fnum = cli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
if (fnum == -1) {
- printf("file open failed - %s\n", cli_errstr(cli->tree));
+ printf("file open failed - %s\n", smbcli_errstr(cli->tree));
}
- dnum = cli_nt_create_full(cli->tree, "\\",
+ dnum = smbcli_nt_create_full(cli->tree, "\\",
0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE,
NTCREATEX_DISP_OPEN,
NTCREATEX_OPTIONS_DIRECTORY, 0);
if (dnum == -1) {
- printf("directory open failed - %s\n", cli_errstr(cli->tree));
+ printf("directory open failed - %s\n", smbcli_errstr(cli->tree));
}
- qfnum = cli_nt_create_full(cli->tree, "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION",
+ qfnum = smbcli_nt_create_full(cli->tree, "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION",
NTCREATEX_FLAGS_EXTENDED,
SEC_RIGHTS_MAXIMUM_ALLOWED,
0,
NTCREATEX_DISP_OPEN,
0, 0);
if (qfnum == -1) {
- printf("quota open failed - %s\n", cli_errstr(cli->tree));
+ printf("quota open failed - %s\n", smbcli_errstr(cli->tree));
}
for (op=OP_MIN; op<=OP_MAX; op++) {
/****************************************************************************
check for existence of a nttrans call
****************************************************************************/
-static NTSTATUS try_nttrans(struct cli_state *cli,
+static NTSTATUS try_nttrans(struct smbcli_state *cli,
int op,
char *param, char *data,
int param_len, int data_len,
}
-static NTSTATUS try_nttrans_len(struct cli_state *cli,
+static NTSTATUS try_nttrans_len(struct smbcli_state *cli,
const char *format,
int op, int level,
char *param, char *data,
/****************************************************************************
check for existance of a nttrans call
****************************************************************************/
-static BOOL scan_nttrans(struct cli_state *cli, int op, int level,
+static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
int fnum, int dnum, const char *fname)
{
int data_len = 0;
status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_unlink(cli->tree, "\\newfile.dat");
- cli_rmdir(cli->tree, "\\newfile.dat");
+ smbcli_unlink(cli->tree, "\\newfile.dat");
+ smbcli_rmdir(cli->tree, "\\newfile.dat");
if (NT_STATUS_IS_OK(status)) return True;
/* try dfs style */
- cli_mkdir(cli->tree, "\\testdir");
+ smbcli_mkdir(cli->tree, "\\testdir");
param_len = 2;
SSVAL(param, 0, level);
param_len += push_string(NULL, ¶m[2], "\\testdir", -1, STR_TERMINATE | STR_UNICODE);
status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_rmdir(cli->tree, "\\testdir");
+ smbcli_rmdir(cli->tree, "\\testdir");
if (NT_STATUS_IS_OK(status)) return True;
return False;
BOOL torture_nttrans_scan(int dummy)
{
- static struct cli_state *cli;
+ static struct smbcli_state *cli;
int op, level;
const char *fname = "\\scanner.dat";
int fnum, dnum;
return False;
}
- fnum = cli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
+ fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
DENY_NONE);
- dnum = cli_open(cli->tree, "\\", O_RDONLY, DENY_NONE);
+ dnum = smbcli_open(cli->tree, "\\", O_RDONLY, DENY_NONE);
for (op=OP_MIN; op<=OP_MAX; op++) {
printf("Scanning op=%d\n", op);
/* scan for valid base SMB requests */
BOOL torture_smb_scan(int dummy)
{
- static struct cli_state *cli;
+ static struct smbcli_state *cli;
int op;
- struct cli_request *req;
+ struct smbcli_request *req;
NTSTATUS status;
for (op=0x0;op<=0xFF;op++) {
return False;
}
- req = cli_request_setup(cli->tree, op, 0, 0);
+ req = smbcli_request_setup(cli->tree, op, 0, 0);
- if (!cli_request_send(req)) {
- cli_request_destroy(req);
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
break;
}
usleep(10000);
- cli_transport_process(cli->transport);
- if (req->state > CLI_REQUEST_RECV) {
- status = cli_request_simple_recv(req);
+ smbcli_transport_process(cli->transport);
+ if (req->state > SMBCLI_REQUEST_RECV) {
+ status = smbcli_request_simple_recv(req);
printf("op=0x%x status=%s\n", op, nt_errstr(status));
torture_close_connection(cli);
continue;
}
sleep(1);
- cli_transport_process(cli->transport);
- if (req->state > CLI_REQUEST_RECV) {
- status = cli_request_simple_recv(req);
+ smbcli_transport_process(cli->transport);
+ if (req->state > SMBCLI_REQUEST_RECV) {
+ status = smbcli_request_simple_recv(req);
printf("op=0x%x status=%s\n", op, nt_errstr(status));
} else {
printf("op=0x%x no reply\n", op);
- cli_request_destroy(req);
+ smbcli_request_destroy(req);
continue; /* don't attempt close! */
}
BOOL torture_utable(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
fstring fname;
const char *alt_name;
int fnum;
memset(valid, 0, sizeof(valid));
- cli_mkdir(cli->tree, "\\utable");
- cli_unlink(cli->tree, "\\utable\\*");
+ smbcli_mkdir(cli->tree, "\\utable");
+ smbcli_unlink(cli->tree, "\\utable\\*");
for (c=1; c < 0x10000; c++) {
char *p;
p[len] = 0;
fstrcat(fname,"_a_long_extension");
- fnum = cli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
+ fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
DENY_NONE);
if (fnum == -1) continue;
chars_allowed++;
- cli_qpathinfo_alt_name(cli->tree, fname, &alt_name);
+ smbcli_qpathinfo_alt_name(cli->tree, fname, &alt_name);
if (strncmp(alt_name, "X_A_L", 5) != 0) {
alt_allowed++;
d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name);
}
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
if (c % 100 == 0) {
printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
}
printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
- cli_rmdir(cli->tree, "\\utable");
+ smbcli_rmdir(cli->tree, "\\utable");
d_printf("%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed);
BOOL torture_casetable(int dummy)
{
- static struct cli_state *cli;
+ static struct smbcli_state *cli;
char *fname;
int fnum;
int c, i;
memset(equiv, 0, sizeof(equiv));
- cli_deltree(cli->tree, "\\utable");
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\utable"))) {
+ smbcli_deltree(cli->tree, "\\utable");
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\utable"))) {
printf("Failed to create utable directory!\n");
return False;
}
d_printf("%04x (%c)\n", c, isprint(c)?c:'.');
fname = form_name(c);
- fnum = cli_nt_create_full(cli->tree, fname, 0,
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0,
#if 0
SEC_RIGHT_MAXIMUM_ALLOWED,
#else
size = 0;
- if (NT_STATUS_IS_ERR(cli_qfileinfo(cli->tree, fnum, NULL, &size,
+ if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &size,
NULL, NULL, NULL, NULL, NULL))) continue;
if (size > 0) {
if (size/sizeof(int) >= MAX_EQUIVALENCE) {
printf("too many chars match?? size=%d c=0x%04x\n",
size, c);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
return False;
}
- cli_read(cli->tree, fnum, (char *)c2, 0, size);
+ smbcli_read(cli->tree, fnum, (char *)c2, 0, size);
printf("%04x: ", c);
equiv[c][0] = c;
for (i=0; i<size/sizeof(int); i++) {
fflush(stdout);
}
- cli_write(cli->tree, fnum, 0, (char *)&c, size, sizeof(c));
- cli_close(cli->tree, fnum);
+ smbcli_write(cli->tree, fnum, 0, (char *)&c, size, sizeof(c));
+ smbcli_close(cli->tree, fnum);
}
- cli_unlink(cli->tree, "\\utable\\*");
- cli_rmdir(cli->tree, "\\utable");
+ smbcli_unlink(cli->tree, "\\utable\\*");
+ smbcli_rmdir(cli->tree, "\\utable");
return True;
}
/* state information for the servers. We open NINSTANCES connections to
each server */
static struct {
- struct cli_state *cli[NINSTANCES];
+ struct smbcli_state *cli[NINSTANCES];
char *server_name;
char *share_name;
char *username;
#define BAD_HANDLE 0xFFFE
-static BOOL oplock_handler(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
-static void idle_func(struct cli_transport *transport, void *private);
+static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
+static void idle_func(struct smbcli_transport *transport, void *private);
/*
check if a string should be ignored. This is used as the basis
for (h=0;h<options.max_open_handles;h++) {
if (!open_handles[h].active) continue;
for (i=0;i<NSERVERS;i++) {
- if (NT_STATUS_IS_ERR((cli_close(servers[i].cli[open_handles[h].instance]->tree,
+ if (NT_STATUS_IS_ERR((smbcli_close(servers[i].cli[open_handles[h].instance]->tree,
open_handles[h].server_fnum[i])))) {
return False;
}
for (i=0;i<NSERVERS;i++) {
for (j=0;j<NINSTANCES;j++) {
if (servers[i].cli[j]) {
- cli_tdis(servers[i].cli[j]);
- cli_shutdown(servers[i].cli[j]);
+ smbcli_tdis(servers[i].cli[j]);
+ smbcli_shutdown(servers[i].cli[j]);
servers[i].cli[j] = NULL;
}
}
printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
servers[i].server_name, servers[i].share_name,
servers[i].username, j);
- status = cli_full_connection(&servers[i].cli[j],
+ status = smbcli_full_connection(&servers[i].cli[j],
"gentest",
servers[i].server_name, NULL,
servers[i].share_name, "?????",
return False;
}
- cli_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL);
- cli_transport_idle_handler(servers[i].cli[j]->transport, idle_func, 1, NULL);
+ smbcli_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL);
+ smbcli_transport_idle_handler(servers[i].cli[j]->transport, idle_func, 1, NULL);
}
}
/* we have to force close a random handle */
h = random() % options.max_open_handles;
for (i=0;i<NSERVERS;i++) {
- if (NT_STATUS_IS_ERR((cli_close(servers[i].cli[open_handles[h].instance]->tree,
+ if (NT_STATUS_IS_ERR((smbcli_close(servers[i].cli[open_handles[h].instance]->tree,
open_handles[h].server_fnum[i])))) {
printf("INTERNAL ERROR: Close failed when recovering handle! - %s\n",
- cli_errstr(servers[i].cli[open_handles[h].instance]->tree));
+ smbcli_errstr(servers[i].cli[open_handles[h].instance]->tree));
}
}
printf("Recovered handle %d\n", h);
/*
this is called when a change notify reply comes in
*/
-static void async_notify(struct cli_request *req)
+static void async_notify(struct smbcli_request *req)
{
struct smb_notify notify;
NTSTATUS status;
int i, j;
uint16_t tid;
- struct cli_transport *transport = req->transport;
+ struct smbcli_transport *transport = req->transport;
tid = SVAL(req->in.hdr, HDR_TID);
/*
the oplock handler will either ack the break or close the file
*/
-static BOOL oplock_handler(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
+static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
{
union smb_close io;
NTSTATUS status;
int i, j;
BOOL do_close;
- struct cli_tree *tree = NULL;
+ struct smbcli_tree *tree = NULL;
srandom(current_op.seed);
do_close = gen_chance(50);
if (!do_close) {
printf("oplock ack fnum=%d\n", fnum);
- return cli_oplock_ack(tree, fnum, level);
+ return smbcli_oplock_ack(tree, fnum, level);
}
printf("oplock close fnum=%d\n", fnum);
an operation on another connection blocking until that break is acked
we check for operations on all transports in the idle function
*/
-static void idle_func(struct cli_transport *transport, void *private)
+static void idle_func(struct smbcli_transport *transport, void *private)
{
int i, j;
for (i=0;i<NSERVERS;i++) {
for (j=0;j<NINSTANCES;j++) {
if (servers[i].cli[j] &&
transport != servers[i].cli[j]->transport) {
- cli_transport_process(servers[i].cli[j]->transport);
+ smbcli_transport_process(servers[i].cli[j]->transport);
}
}
}
for (j=0;j<NINSTANCES;j++) {
for (i=0;i<NSERVERS;i++) {
- cli_transport_process(servers[i].cli[j]->transport);
+ smbcli_transport_process(servers[i].cli[j]->transport);
}
}
}
ZERO_STRUCT(oplocks); \
ZERO_STRUCT(notifies); \
for (i=0;i<NSERVERS;i++) { \
- struct cli_tree *tree = servers[i].cli[instance]->tree; \
+ struct smbcli_tree *tree = servers[i].cli[instance]->tree; \
status[i] = call; \
} \
current_op.status = status[0]; \
GEN_SET_FNUM(in.fnum);
for (n=0;n<NSERVERS;n++) {
- struct cli_request *req;
+ struct smbcli_request *req;
req = smb_raw_changenotify_send(servers[n].cli[instance]->tree, &parm[n]);
req->async.fn = async_notify;
}
{
int i;
for (i=0;i<NSERVERS;i++) {
- int n = cli_deltree(servers[i].cli[0]->tree, "\\gentest");
+ int n = smbcli_deltree(servers[i].cli[0]->tree, "\\gentest");
if (n == -1) {
printf("Failed to wipe tree on server %d\n", i);
exit(1);
}
- if (NT_STATUS_IS_ERR(cli_mkdir(servers[i].cli[0]->tree, "\\gentest"))) {
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(servers[i].cli[0]->tree, "\\gentest"))) {
printf("Failed to create \\gentest - %s\n",
- cli_errstr(servers[i].cli[0]->tree));
+ smbcli_errstr(servers[i].cli[0]->tree));
exit(1);
}
if (n > 0) {
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *connect_one(char *share, int snum)
+static struct smbcli_state *connect_one(char *share, int snum)
{
- struct cli_state *c;
+ struct smbcli_state *c;
fstring server, myname;
uint_t flags = 0;
NTSTATUS status;
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), snum);
if (use_kerberos)
- flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+ flags |= SMBCLI_FULL_CONNECTION_USE_KERBEROS;
do {
- status = cli_full_connection(&c, myname,
+ status = smbcli_full_connection(&c, myname,
server, NULL,
share, "?????",
username[snum], lp_workgroup(),
}
-static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
+static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
char *share[NSERVERS])
{
int server, conn, f;
if (cli[server][conn]) {
for (f=0;f<NFILES;f++) {
if (fnum[server][conn][f] != -1) {
- cli_close(cli[server][conn]->tree, fnum[server][conn][f]);
+ smbcli_close(cli[server][conn]->tree, fnum[server][conn][f]);
fnum[server][conn][f] = -1;
}
}
- cli_shutdown(cli[server][conn]);
+ smbcli_shutdown(cli[server][conn]);
}
cli[server][conn] = connect_one(share[server], server);
if (!cli[server][conn]) {
-static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NCONNECTIONS][NFILES],
struct record *rec)
{
case OP_LOCK:
/* set a lock */
for (server=0;server<NSERVERS;server++) {
- ret[server] = NT_STATUS_IS_OK(cli_lock64(cli[server][conn]->tree,
+ ret[server] = NT_STATUS_IS_OK(smbcli_lock64(cli[server][conn]->tree,
fnum[server][conn][f],
start, len, LOCK_TIMEOUT, op));
- status[server] = cli_nt_error(cli[server][conn]->tree);
+ status[server] = smbcli_nt_error(cli[server][conn]->tree);
if (!exact_error_codes &&
NT_STATUS_EQUAL(status[server],
NT_STATUS_FILE_LOCK_CONFLICT)) {
case OP_UNLOCK:
/* unset a lock */
for (server=0;server<NSERVERS;server++) {
- ret[server] = NT_STATUS_IS_OK(cli_unlock64(cli[server][conn]->tree,
+ ret[server] = NT_STATUS_IS_OK(smbcli_unlock64(cli[server][conn]->tree,
fnum[server][conn][f],
start, len));
- status[server] = cli_nt_error(cli[server][conn]->tree);
+ status[server] = smbcli_nt_error(cli[server][conn]->tree);
}
if (showall ||
(!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1]))) {
case OP_REOPEN:
/* reopen the file */
for (server=0;server<NSERVERS;server++) {
- cli_close(cli[server][conn]->tree, fnum[server][conn][f]);
+ smbcli_close(cli[server][conn]->tree, fnum[server][conn][f]);
fnum[server][conn][f] = -1;
}
for (server=0;server<NSERVERS;server++) {
- fnum[server][conn][f] = cli_open(cli[server][conn]->tree, FILENAME,
+ fnum[server][conn][f] = smbcli_open(cli[server][conn]->tree, FILENAME,
O_RDWR|O_CREAT,
DENY_NONE);
if (fnum[server][conn][f] == -1) {
return True;
}
-static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NCONNECTIONS][NFILES])
{
int server, conn, f;
for (conn=0;conn<NCONNECTIONS;conn++)
for (f=0;f<NFILES;f++) {
if (fnum[server][conn][f] != -1) {
- cli_close(cli[server][conn]->tree, fnum[server][conn][f]);
+ smbcli_close(cli[server][conn]->tree, fnum[server][conn][f]);
fnum[server][conn][f] = -1;
}
}
for (server=0;server<NSERVERS;server++) {
- cli_unlink(cli[server][0]->tree, FILENAME);
+ smbcli_unlink(cli[server][0]->tree, FILENAME);
}
}
-static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void open_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NCONNECTIONS][NFILES])
{
int server, conn, f;
for (server=0;server<NSERVERS;server++)
for (conn=0;conn<NCONNECTIONS;conn++)
for (f=0;f<NFILES;f++) {
- fnum[server][conn][f] = cli_open(cli[server][conn]->tree, FILENAME,
+ fnum[server][conn][f] = smbcli_open(cli[server][conn]->tree, FILENAME,
O_RDWR|O_CREAT,
DENY_NONE);
if (fnum[server][conn][f] == -1) {
}
-static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NCONNECTIONS][NFILES],
int n)
{
*/
static void test_locks(char *share[NSERVERS])
{
- struct cli_state *cli[NSERVERS][NCONNECTIONS];
+ struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
int n, i, n1, skip, r1, r2;
static struct record *recorded;
-static int try_open(struct cli_state *c, char *nfs, int fstype, const char *fname, int flags)
+static int try_open(struct smbcli_state *c, char *nfs, int fstype, const char *fname, int flags)
{
pstring path;
switch (fstype) {
case FSTYPE_SMB:
- return cli_open(c, fname, flags, DENY_NONE);
+ return smbcli_open(c, fname, flags, DENY_NONE);
case FSTYPE_NFS:
slprintf(path, sizeof(path), "%s%s", nfs, fname);
return -1;
}
-static BOOL try_close(struct cli_state *c, int fstype, int fd)
+static BOOL try_close(struct smbcli_state *c, int fstype, int fd)
{
switch (fstype) {
case FSTYPE_SMB:
- return cli_close(c, fd);
+ return smbcli_close(c, fd);
case FSTYPE_NFS:
return close(fd) == 0;
return False;
}
-static BOOL try_lock(struct cli_state *c, int fstype,
+static BOOL try_lock(struct smbcli_state *c, int fstype,
int fd, uint_t start, uint_t len,
enum brl_type op)
{
switch (fstype) {
case FSTYPE_SMB:
- return cli_lock(c, fd, start, len, LOCK_TIMEOUT, op);
+ return smbcli_lock(c, fd, start, len, LOCK_TIMEOUT, op);
case FSTYPE_NFS:
lock.l_type = (op==READ_LOCK) ? F_RDLCK:F_WRLCK;
return False;
}
-static BOOL try_unlock(struct cli_state *c, int fstype,
+static BOOL try_unlock(struct smbcli_state *c, int fstype,
int fd, uint_t start, uint_t len)
{
struct flock lock;
switch (fstype) {
case FSTYPE_SMB:
- return cli_unlock(c, fd, start, len);
+ return smbcli_unlock(c, fd, start, len);
case FSTYPE_NFS:
lock.l_type = F_UNLCK;
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *connect_one(char *share)
+static struct smbcli_state *connect_one(char *share)
{
- struct cli_state *c;
+ struct smbcli_state *c;
char *server_n;
fstring server;
fstring myname;
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
- nt_status = cli_full_connection(&c, myname, server_n, NULL, 0, share, "?????",
+ nt_status = smbcli_full_connection(&c, myname, server_n, NULL, 0, share, "?????",
username, lp_workgroup(), password, 0,
NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(0, ("cli_full_connection failed with error %s\n", nt_errstr(nt_status)));
+ DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
return NULL;
}
}
-static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
char *share1, char *share2)
for (conn=0;conn<NCONNECTIONS;conn++) {
if (cli[server][conn]) {
for (f=0;f<NFILES;f++) {
- cli_close(cli[server][conn], fnum[server][fstype][conn][f]);
+ smbcli_close(cli[server][conn], fnum[server][fstype][conn][f]);
}
- cli_ulogoff(cli[server][conn]);
- cli_shutdown(cli[server][conn]);
+ smbcli_ulogoff(cli[server][conn]);
+ smbcli_shutdown(cli[server][conn]);
}
cli[server][conn] = connect_one(share[server]);
if (!cli[server][conn]) {
-static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
struct record *rec)
return True;
}
-static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES])
{
}
}
for (server=0;server<NSERVERS;server++) {
- cli_unlink(cli[server][0], FILENAME);
+ smbcli_unlink(cli[server][0], FILENAME);
}
}
-static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void open_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES])
{
}
-static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
int n)
*/
static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2)
{
- struct cli_state *cli[NSERVERS][NCONNECTIONS];
+ struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
char *nfs[NSERVERS];
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES];
int n, i, n1;
return ms_fnmatch_lanman_core(pattern, string);
}
-static BOOL reg_match_one(struct cli_state *cli, const char *pattern, const char *file)
+static BOOL reg_match_one(struct smbcli_state *cli, const char *pattern, const char *file)
{
/* oh what a weird world this is */
if (old_list && strcmp(pattern, "*.*") == 0) return True;
return ms_fnmatch(pattern, file, cli->transport->negotiate.protocol)==0;
}
-static char *reg_test(struct cli_state *cli, char *pattern, char *long_name, char *short_name)
+static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name, char *short_name)
{
static fstring ret;
fstrcpy(ret, "---");
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *connect_one(char *share)
+static struct smbcli_state *connect_one(char *share)
{
- struct cli_state *c;
+ struct smbcli_state *c;
fstring server;
uint_t flags = 0;
NTSTATUS status;
*share = 0;
share++;
- status = cli_full_connection(&c, "masktest",
+ status = smbcli_full_connection(&c, "masktest",
server, NULL,
share, "?????",
username, lp_workgroup(),
f_info_hit = True;
}
-static void get_real_name(struct cli_state *cli,
+static void get_real_name(struct smbcli_state *cli,
pstring long_name, fstring short_name)
{
const char *mask;
f_info_hit = False;
- cli_list_new(cli->tree, mask,
+ smbcli_list_new(cli->tree, mask,
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
listfn, NULL);
}
}
-static void testpair(struct cli_state *cli, char *mask, char *file)
+static void testpair(struct smbcli_state *cli, char *mask, char *file)
{
int fnum;
fstring res1;
fstrcpy(res1, "---");
- fnum = cli_open(cli->tree, file, O_CREAT|O_TRUNC|O_RDWR, 0);
+ fnum = smbcli_open(cli->tree, file, O_CREAT|O_TRUNC|O_RDWR, 0);
if (fnum == -1) {
DEBUG(0,("Can't create %s\n", file));
return;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
resultp = res1;
fstrcpy(short_name, "");
get_real_name(cli, long_name, short_name);
fstrcpy(res1, "---");
- cli_list(cli->tree, mask,
+ smbcli_list(cli->tree, mask,
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
listfn, NULL);
if (die_on_error) exit(1);
}
- cli_unlink(cli->tree, file);
+ smbcli_unlink(cli->tree, file);
if (count % 100 == 0) DEBUG(0,("%d\n", count));
}
static void test_mask(int argc, char *argv[],
- struct cli_state *cli)
+ struct smbcli_state *cli)
{
pstring mask, file;
int l1, l2, i, l;
int mc_len = strlen(maskchars);
int fc_len = strlen(filechars);
- cli_mkdir(cli->tree, "\\masktest");
+ smbcli_mkdir(cli->tree, "\\masktest");
- cli_unlink(cli->tree, "\\masktest\\*");
+ smbcli_unlink(cli->tree, "\\masktest\\*");
if (argc >= 2) {
while (argc >= 2) {
}
finished:
- cli_rmdir(cli->tree, "\\masktest");
+ smbcli_rmdir(cli->tree, "\\masktest");
}
int main(int argc,char *argv[])
{
char *share;
- struct cli_state *cli;
+ struct smbcli_state *cli;
int opt;
char *p;
int seed;
#define ival(s) strtol(s, NULL, 0)
/* run a test that simulates an approximate netbench client load */
-static BOOL run_netbench(struct cli_state *cli, int client)
+static BOOL run_netbench(struct smbcli_state *cli, int client)
{
int i;
pstring line;
{
BOOL correct = True;
extern int torture_nprocs;
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *p;
p = lp_parm_string(-1, "torture", "timelimit");
-static struct cli_state *c;
+static struct smbcli_state *c;
/*
a handler function for oplock break requests
*/
-static BOOL oplock_handler(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
+static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
{
- struct cli_tree *tree = private;
- return cli_oplock_ack(tree, fnum, level);
+ struct smbcli_tree *tree = private;
+ return smbcli_oplock_ack(tree, fnum, level);
}
-void nb_setup(struct cli_state *cli, int id, int warmupt)
+void nb_setup(struct smbcli_state *cli, int id, int warmupt)
{
warmup = warmupt;
nbio_id = id;
printf("skipping I/O\n");
if (cli) {
- cli_oplock_handler(cli->transport, oplock_handler, cli->tree);
+ smbcli_oplock_handler(cli->transport, oplock_handler, cli->tree);
}
}
TALLOC_CTX *mem_ctx;
NTSTATUS ret;
- mem_ctx = talloc_init("cli_dskattr");
+ mem_ctx = talloc_init("smbcli_dskattr");
io.generic.level = level;
ret = smb_raw_fsinfo(c->tree, mem_ctx, &io);
TALLOC_CTX *mem_ctx;
NTSTATUS ret;
- mem_ctx = talloc_init("cli_dskattr");
+ mem_ctx = talloc_init("smbcli_dskattr");
io.t2ffirst.level = level;
io.t2ffirst.in.max_count = maxcnt;
free(f);
}
- total_deleted = cli_deltree(c->tree, dname);
+ total_deleted = smbcli_deltree(c->tree, dname);
if (total_deleted == -1) {
printf("Failed to cleanup tree %s - exiting\n", dname);
exit(1);
}
- cli_rmdir(c->tree, dname);
+ smbcli_rmdir(c->tree, dname);
}
void nb_cleanup(const char *cname)
asprintf(&dname, "\\clients\\%s", cname);
nb_deltree(dname);
free(dname);
- cli_rmdir(c->tree, "clients");
+ smbcli_rmdir(c->tree, "clients");
children[nbio_id].done = 1;
}
return NT_STATUS_OK;
}
-static NTSTATUS rap_cli_do_call(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rap_cli_do_call(struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
struct rap_call *call)
{
NTSTATUS result;
goto done; \
} while (0)
-static NTSTATUS cli_rap_netshareenum(struct cli_state *cli,
+static NTSTATUS smbcli_rap_netshareenum(struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
struct rap_NetShareEnum *r)
{
return result;
}
-static BOOL test_netshareenum(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_netshareenum(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
struct rap_NetShareEnum r;
int i;
r.in.level = 1;
r.in.bufsize = 8192;
- if (!NT_STATUS_IS_OK(cli_rap_netshareenum(cli, mem_ctx, &r)))
+ if (!NT_STATUS_IS_OK(smbcli_rap_netshareenum(cli, mem_ctx, &r)))
return False;
for (i=0; i<r.out.count; i++) {
return True;
}
-static NTSTATUS cli_rap_netserverenum2(struct cli_state *cli,
+static NTSTATUS smbcli_rap_netserverenum2(struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
struct rap_NetServerEnum2 *r)
{
return result;
}
-static BOOL test_netserverenum(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_netserverenum(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
struct rap_NetServerEnum2 r;
int i;
r.in.servertype = 0x80000000;
r.in.domain = NULL;
- if (!NT_STATUS_IS_OK(cli_rap_netserverenum2(cli, mem_ctx, &r)))
+ if (!NT_STATUS_IS_OK(smbcli_rap_netserverenum2(cli, mem_ctx, &r)))
return False;
for (i=0; i<r.out.count; i++) {
-static BOOL test_rap(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_rap(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
BOOL res = True;
BOOL torture_raw_rap(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
}} while (0)
-static BOOL test_chkpath(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
struct smb_chkpath io;
NTSTATUS status;
fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\test.txt");
if (fnum == -1) {
- printf("failed to open test.txt - %s\n", cli_errstr(cli->tree));
+ printf("failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
return ret;
}
*/
BOOL torture_raw_chkpath(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
int fnum;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("torture_raw_chkpath");
- if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to clean " BASEDIR "\n");
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR "\\nt"))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt"))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR "\\nt\\Visual Studio"))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\Visual Studio"))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR "\\nt\\Visual Studio\\VB98"))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\Visual Studio\\VB98"))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\nt\\Visual Studio\\VB98\\vb6.exe");
if (fnum == -1) {
- printf("failed to open \\nt\\Visual Studio\\VB98\\vb6.exe - %s\n", cli_errstr(cli->tree));
+ printf("failed to open \\nt\\Visual Studio\\VB98\\vb6.exe - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
*/
BOOL torture_raw_close(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
union smb_close io;
}
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
REOPEN;
finfo2.generic.in.fname = fname;
CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
printf("testing flush\n");
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
io_flush.in.fnum = fnum;
status = smb_raw_flush(cli->tree, &io_flush);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
/*
test session ops
*/
-static BOOL test_session(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
BOOL ret = True;
char *username, *domain, *password;
- struct cli_session *session;
- struct cli_tree *tree;
+ struct smbcli_session *session;
+ struct smbcli_tree *tree;
union smb_sesssetup setup;
union smb_open io;
union smb_write wr;
printf("TESTING SESSION HANDLING\n");
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
domain = lp_workgroup();
printf("create a second security context on the same transport\n");
- session = cli_session_init(cli->transport);
+ session = smbcli_session_init(cli->transport);
setup.generic.level = RAW_SESSSETUP_GENERIC;
setup.generic.in.sesskey = cli->transport->negotiate.sesskey;
setup.generic.in.capabilities = 0; /* ignored in secondary session setup */
session->vuid = setup.generic.out.vuid;
printf("use the same tree as the existing connection\n");
- tree = cli_tree_init(session);
+ tree = smbcli_tree_init(session);
tree->tid = cli->tree->tid;
cli->tree->reference_count++;
/* close down the new tree, which will also close the session
as the reference count will be 0 */
- cli_tree_close(tree);
+ smbcli_tree_close(tree);
done:
return ret;
/*
test tree ops
*/
-static BOOL test_tree(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
BOOL ret = True;
char *share;
- struct cli_tree *tree;
+ struct smbcli_tree *tree;
union smb_tcon tcon;
union smb_open io;
union smb_write wr;
printf("TESTING TREE HANDLING\n");
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
share = lp_parm_string(-1, "torture", "share");
printf("create a second tree context on the same session\n");
- tree = cli_tree_init(cli->session);
+ tree = smbcli_tree_init(cli->session);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
/* close down the new tree */
- cli_tree_close(tree);
+ smbcli_tree_close(tree);
done:
return ret;
/*
test pid ops
*/
-static BOOL test_pid(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_pid(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
BOOL ret = True;
printf("TESTING PID HANDLING\n");
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
*/
BOOL torture_raw_context(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
}
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
/* test some ioctls */
-static BOOL test_ioctl(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_ioctl ctl;
int fnum;
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("Failed to create test.dat - %s\n", cli_errstr(cli->tree));
+ printf("Failed to create test.dat - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
return ret;
}
/* test some filesystem control functions */
-static BOOL test_fsctl(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
int fnum;
NTSTATUS status;
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("Failed to create test.dat - %s\n", cli_errstr(cli->tree));
+ printf("Failed to create test.dat - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
#endif
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
return ret;
}
*/
BOOL torture_raw_ioctl(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("torture_raw_ioctl");
- if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to clean " BASEDIR "\n");
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
}
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
/*
test SMBlock and SMBunlock ops
*/
-static BOOL test_lock(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_lock io;
NTSTATUS status;
int fnum;
const char *fname = BASEDIR "\\test.txt";
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_LOCK_LOCK\n");
io.generic.level = RAW_LOCK_LOCK;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test locking&X ops
*/
-static BOOL test_lockx(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_lockx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_lock io;
struct smb_lock_entry lock[1];
int fnum;
const char *fname = BASEDIR "\\test.txt";
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_LOCK_LOCKX\n");
io.generic.level = RAW_LOCK_LOCKX;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test high pid
*/
-static BOOL test_pidhigh(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_pidhigh(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_lock io;
struct smb_lock_entry lock[1];
const char *fname = BASEDIR "\\test.txt";
char c = 1;
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
cli->session->pid = 1;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- if (cli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) {
- printf("Failed to write 1 byte - %s\n", cli_errstr(cli->tree));
+ if (smbcli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) {
+ printf("Failed to write 1 byte - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (cli_read(cli->tree, fnum, &c, 0, 1) != 1) {
- printf("Failed to read 1 byte - %s\n", cli_errstr(cli->tree));
+ if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
+ printf("Failed to read 1 byte - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
cli->session->pid = 2;
- if (cli_read(cli->tree, fnum, &c, 0, 1) == 1) {
+ if (smbcli_read(cli->tree, fnum, &c, 0, 1) == 1) {
printf("pid is incorrect handled for read with lock!\n");
ret = False;
goto done;
cli->session->pid = 0x10001;
- if (cli_read(cli->tree, fnum, &c, 0, 1) != 1) {
+ if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
printf("High pid is used on this server!\n");
ret = False;
} else {
}
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_lock(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
/*
test mkdir ops
*/
-static BOOL test_mkdir(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_mkdir md;
struct smb_rmdir rd;
BOOL ret = True;
/* cleanup */
- cli_rmdir(cli->tree, path);
- cli_unlink(cli->tree, path);
+ smbcli_rmdir(cli->tree, path);
+ smbcli_unlink(cli->tree, path);
/*
basic mkdir
printf("testing mkdir collision with file\n");
/* name collision with a file */
- cli_close(cli->tree, create_complex_file(cli, mem_ctx, path));
+ smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, path));
status = smb_raw_mkdir(cli->tree, &md);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION);
status = smb_raw_rmdir(cli->tree, &rd);
CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
- cli_unlink(cli->tree, path);
+ smbcli_unlink(cli->tree, path);
printf("testing invalid dir\n");
done:
- cli_rmdir(cli->tree, path);
- cli_unlink(cli->tree, path);
+ smbcli_rmdir(cli->tree, path);
+ smbcli_unlink(cli->tree, path);
return ret;
}
*/
BOOL torture_raw_mkdir(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
/*
test the delayed reply to a open that leads to a sharing violation
*/
-static BOOL test_mux_open(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
NTSTATUS status;
int fnum;
BOOL ret = True;
- struct cli_request *req;
+ struct smbcli_request *req;
printf("testing multiplexed open/open/close\n");
req = smb_raw_open_send(cli->tree, &io);
/* and close the file */
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
/* see if the async open succeeded */
status = smb_raw_open_recv(req, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.ntcreatex.out.fnum);
+ smbcli_close(cli->tree, io.ntcreatex.out.fnum);
done:
return ret;
/*
test a write that hits a byte range lock and send the close after the write
*/
-static BOOL test_mux_write(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_write io;
NTSTATUS status;
int fnum;
BOOL ret = True;
- struct cli_request *req;
+ struct smbcli_request *req;
printf("testing multiplexed lock/write/close\n");
- fnum = cli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("open failed in mux_write - %s\n", cli_errstr(cli->tree));
+ printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
cli->session->pid = 1;
/* lock a range */
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum, 0, 4, 0, WRITE_LOCK))) {
- printf("lock failed in mux_write - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 0, 4, 0, WRITE_LOCK))) {
+ printf("lock failed in mux_write - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
/* unlock the range */
cli->session->pid = 1;
- cli_unlock(cli->tree, fnum, 0, 4);
+ smbcli_unlock(cli->tree, fnum, 0, 4);
/* and recv the async write reply */
status = smb_raw_write_recv(req, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
done:
return ret;
/*
test a lock that conflicts with an existing lock
*/
-static BOOL test_mux_lock(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_lock io;
NTSTATUS status;
int fnum;
BOOL ret = True;
- struct cli_request *req;
+ struct smbcli_request *req;
struct smb_lock_entry lock[1];
printf("TESTING MULTIPLEXED LOCK/LOCK/UNLOCK\n");
- fnum = cli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("open failed in mux_write - %s\n", cli_errstr(cli->tree));
+ printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
printf("recv the async reply\n");
- status = cli_request_simple_recv(req);
+ status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_OK);
printf("reopening with an exit\n");
smb_raw_exit(cli->session);
- fnum = cli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
printf("Now trying with a cancel\n");
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- status = cli_request_simple_recv(req);
+ status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
done:
return ret;
*/
BOOL torture_raw_mux(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("torture_raw_mux");
/* cleanup */
- if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to cleanup " BASEDIR "\n");
ret = False;
goto done;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
printf("Failed to create %s\n", BASEDIR);
ret = False;
goto done;
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
*/
BOOL torture_raw_notify(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
struct smb_notify notify;
union smb_open io;
int fnum = -1;
- struct cli_request *req;
+ struct smbcli_request *req;
if (!torture_open_connection(&cli)) {
return False;
mem_ctx = talloc_init("torture_raw_notify");
/* cleanup */
- if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to cleanup " BASEDIR "\n");
ret = False;
goto done;
printf("testing notify mkdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
- cli_mkdir(cli->tree, BASEDIR "\\subdir-name");
+ smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
printf("testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
- cli_rmdir(cli->tree, BASEDIR "\\subdir-name");
+ smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
req = smb_raw_changenotify_send(cli->tree, ¬ify);
smb_raw_ntcancel(req);
- cli_mkdir(cli->tree, BASEDIR "\\subdir-name");
+ smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_CANCELLED);
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
/*
check if a open file can be read/written
*/
-static enum rdwr_mode check_rdwr(struct cli_tree *tree, int fnum)
+static enum rdwr_mode check_rdwr(struct smbcli_tree *tree, int fnum)
{
char c = 1;
- BOOL can_read = (cli_read(tree, fnum, &c, 0, 1) == 1);
- BOOL can_write = (cli_write(tree, fnum, 0, &c, 0, 1) == 1);
+ BOOL can_read = (smbcli_read(tree, fnum, &c, 0, 1) == 1);
+ BOOL can_write = (smbcli_write(tree, fnum, 0, &c, 0, 1) == 1);
if ( can_read && can_write) return RDWR_RDWR;
if ( can_read && !can_write) return RDWR_RDONLY;
if (!can_read && can_write) return RDWR_WRONLY;
#define CREATE_FILE do { \
fnum = create_complex_file(cli, mem_ctx, fname); \
if (fnum == -1) { \
- printf("(%d) Failed to create %s - %s\n", __LINE__, fname, cli_errstr(cli->tree)); \
+ printf("(%d) Failed to create %s - %s\n", __LINE__, fname, smbcli_errstr(cli->tree)); \
ret = False; \
goto done; \
}} while (0)
/*
test RAW_OPEN_OPEN
*/
-static BOOL test_open(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
fnum = io.open.out.fnum;
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
CREATE_FILE;
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_STATUS(status, NT_STATUS_OK);
fnum2 = io.open.out.fnum;
CHECK_RDWR(fnum2, RDWR_RDWR);
- cli_close(cli->tree, fnum2);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum);
/* check the read/write modes */
io.open.level = RAW_OPEN_OPEN;
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.open.out.fnum;
CHECK_RDWR(fnum, RDWR_RDONLY);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
io.open.in.flags = OPEN_FLAGS_OPEN_WRITE;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.open.out.fnum;
CHECK_RDWR(fnum, RDWR_WRONLY);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
io.open.in.flags = OPEN_FLAGS_OPEN_RDWR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.open.out.fnum;
CHECK_RDWR(fnum, RDWR_RDWR);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
/* check the share modes roughly - not a complete matrix */
io.open.in.flags = OPEN_FLAGS_OPEN_RDWR | OPEN_FLAGS_DENY_WRITE;
CHECK_STATUS(status, NT_STATUS_OK);
fnum2 = io.open.out.fnum;
CHECK_RDWR(fnum2, RDWR_RDONLY);
- cli_close(cli->tree, fnum);
- cli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum2);
/* check the returned write time */
CHECK_ALL_INFO(io.open.out.attrib, attrib);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
/*
test RAW_OPEN_OPENX
*/
-static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
};
printf("Checking RAW_OPEN_OPENX\n");
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
io.openx.level = RAW_OPEN_OPENX;
io.openx.in.fname = fname;
if (open_funcs[i].with_file) {
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli->tree));
+ d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
}
io.openx.in.open_func = open_funcs[i].open_func;
status = smb_raw_open(cli->tree, mem_ctx, &io);
ret = False;
}
if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
- cli_close(cli->tree, io.openx.out.fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, io.openx.out.fnum);
+ smbcli_unlink(cli->tree, fname);
}
}
CHECK_VAL(io.openx.out.ftype, 0);
CHECK_VAL(io.openx.out.devstate, 0);
CHECK_VAL(io.openx.out.action, OPENX_ACTION_CREATED);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* check the fields when the file already existed */
fnum2 = create_complex_file(cli, mem_ctx, fname);
ret = False;
goto done;
}
- cli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum2);
io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_VAL(io.openx.out.action, OPENX_ACTION_EXISTED);
CHECK_VAL(io.openx.out.unknown, 0);
CHECK_ALL_INFO(io.openx.out.attrib, attrib);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
/* now check the search attrib for hidden files - win2003 ignores this? */
SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN);
io.openx.in.search_attrs = FILE_ATTRIBUTE_HIDDEN;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.openx.out.fnum);
+ smbcli_close(cli->tree, io.openx.out.fnum);
io.openx.in.search_attrs = 0;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.openx.out.fnum);
+ smbcli_close(cli->tree, io.openx.out.fnum);
SET_ATTRIB(FILE_ATTRIBUTE_NORMAL);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
/* and check attrib on create */
io.openx.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE, attrib);
- cli_close(cli->tree, io.openx.out.fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, io.openx.out.fnum);
+ smbcli_unlink(cli->tree, fname);
/* check timeout on create - win2003 ignores the timeout! */
io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
__LINE__, (int)end_timer());
ret = False;
}
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* now this is a really weird one - open for execute implies create?! */
io.openx.in.fname = fname;
io.openx.in.timeout = 0;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.openx.out.fnum);
+ smbcli_close(cli->tree, io.openx.out.fnum);
/* check the extended return flag */
io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO | OPENX_FLAGS_EXTENDED_RETURN;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VAL(io.openx.out.access_mask, STD_RIGHT_ALL_ACCESS);
- cli_close(cli->tree, io.openx.out.fnum);
+ smbcli_close(cli->tree, io.openx.out.fnum);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
is why you see all the ACCESS_DENIED results below. When we finally work this out then this
test will make more sense
*/
-static BOOL test_t2open(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
if (open_funcs[i].with_file) {
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli->tree));
+ d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
}
io.t2open.in.open_func = open_funcs[i].open_func;
status = smb_raw_open(cli->tree, mem_ctx, &io);
ret = False;
}
if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
- cli_close(cli->tree, io.t2open.out.fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, io.t2open.out.fnum);
+ smbcli_unlink(cli->tree, fname);
}
}
/* check the basic return fields */
fnum = create_complex_file(cli, mem_ctx, fname);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
io.t2open.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VAL(io.t2open.out.ftype, 0);
CHECK_VAL(io.t2open.out.devstate, 0);
CHECK_VAL(io.t2open.out.action, OPENX_ACTION_EXISTED);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
/* now check the search attrib for hidden files - win2003 ignores this? */
SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN);
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.t2open.out.fnum);
+ smbcli_close(cli->tree, io.t2open.out.fnum);
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.t2open.out.fnum);
+ smbcli_close(cli->tree, io.t2open.out.fnum);
SET_ATTRIB(FILE_ATTRIBUTE_NORMAL);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
/* and check attrib on create */
io.t2open.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE;
CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
/*
test RAW_OPEN_NTCREATEX
*/
-static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
/* test the open disposition */
for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
if (open_funcs[i].with_file) {
- fnum = cli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE);
if (fnum == -1) {
- d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli->tree));
+ d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
}
io.ntcreatex.in.open_disposition = open_funcs[i].open_disp;
status = smb_raw_open(cli->tree, mem_ctx, &io);
ret = False;
}
if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
- cli_close(cli->tree, io.ntcreatex.out.fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, io.ntcreatex.out.fnum);
+ smbcli_unlink(cli->tree, fname);
}
}
CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
/* check fields when the file already existed */
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
ret = False;
goto done;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_ALL_INFO(io.ntcreatex.out.size, size);
CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* create a directory */
io.ntcreatex.in.fname = dname;
fname = dname;
- cli_rmdir(cli->tree, fname);
- cli_unlink(cli->tree, fname);
+ smbcli_rmdir(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
io.ntcreatex.in.access_mask = SEC_RIGHT_MAXIMUM_ALLOWED;
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
CHECK_VAL(io.ntcreatex.out.size, 0);
CHECK_VAL(io.ntcreatex.out.alloc_size, 0);
CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
open_disposition==NTCREATEX_DISP_OVERWRITE_IF. Windows 2003 allows the
second open.
*/
-static BOOL test_ntcreatex_brlocked(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io, io1;
union smb_lock io2;
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli->tree, io.ntcreatex.out.fnum);
- cli_close(cli->tree, io1.ntcreatex.out.fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, io.ntcreatex.out.fnum);
+ smbcli_close(cli->tree, io1.ntcreatex.out.fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
/*
test RAW_OPEN_MKNEW
*/
-static BOOL test_mknew(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_mknew.txt";
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* make sure write_time works */
io.mknew.in.write_time = basetime;
fnum = io.mknew.out.fnum;
CHECK_TIME(basetime, write_time);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* make sure file_attrs works */
io.mknew.in.attrib = FILE_ATTRIBUTE_HIDDEN;
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE, attrib);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
/*
test RAW_OPEN_CREATE
*/
-static BOOL test_create(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_create.txt";
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli->tree, io.create.out.fnum);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, io.create.out.fnum);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* make sure write_time works */
io.create.in.write_time = basetime;
fnum = io.create.out.fnum;
CHECK_TIME(basetime, write_time);
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
/* make sure file_attrs works */
io.create.in.attrib = FILE_ATTRIBUTE_HIDDEN;
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE, attrib);
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
/*
test RAW_OPEN_CTEMP
*/
-static BOOL test_ctemp(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
NTSTATUS status;
CHECK_TIME(basetime, write_time);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
if (fname) {
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
}
return ret;
*/
BOOL torture_raw_open(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("torture_raw_open");
- if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to clean " BASEDIR "\n");
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
}
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
/*
a handler function for oplock break requests
*/
-static BOOL oplock_handler_ack(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
+static BOOL oplock_handler_ack(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
{
- struct cli_tree *tree = private;
+ struct smbcli_tree *tree = private;
break_info.fnum = fnum;
break_info.level = level;
break_info.count++;
printf("Acking in oplock handler\n");
- return cli_oplock_ack(tree, fnum, level);
+ return smbcli_oplock_ack(tree, fnum, level);
}
/*
a handler function for oplock break requests - close the file
*/
-static BOOL oplock_handler_close(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
+static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
{
union smb_close io;
NTSTATUS status;
- struct cli_tree *tree = private;
+ struct smbcli_tree *tree = private;
break_info.fnum = fnum;
break_info.level = level;
/*
test oplock ops
*/
-static BOOL test_oplock(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_oplock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const char *fname = "\\test_oplock.dat";
NTSTATUS status;
uint16_t fnum=0, fnum2=0;
/* cleanup */
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
- cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
+ smbcli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
/*
base ntcreatex parms
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
/*
with a batch oplock we get a break
CHECK_VAL(break_info.count, 1);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
printf("if we close on break then the unlink can succeed\n");
ZERO_STRUCT(break_info);
- cli_oplock_handler(cli->transport, oplock_handler_close, cli->tree);
+ smbcli_oplock_handler(cli->transport, oplock_handler_close, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
printf("a self read should not cause a break\n");
ZERO_STRUCT(break_info);
- cli_close(cli->tree, fnum);
- cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
+ smbcli_close(cli->tree, fnum);
+ smbcli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
printf("a 2nd open should give a break\n");
ZERO_STRUCT(break_info);
- cli_close(cli->tree, fnum);
- cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
+ smbcli_close(cli->tree, fnum);
+ smbcli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
printf("a 2nd open should get an oplock when we close instead of ack\n");
ZERO_STRUCT(break_info);
- cli_close(cli->tree, fnum);
- cli_oplock_handler(cli->transport, oplock_handler_close, cli->tree);
+ smbcli_close(cli->tree, fnum);
+ smbcli_oplock_handler(cli->transport, oplock_handler_close, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
CHECK_VAL(break_info.fnum, fnum2);
CHECK_VAL(break_info.level, 1);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
printf("open with batch oplock\n");
ZERO_STRUCT(break_info);
- cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
+ smbcli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
CHECK_VAL(break_info.fnum, 0);
CHECK_VAL(break_info.level, 0);
- cli_close(cli->tree, fnum);
- cli_close(cli->tree, fnum2);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum2);
+ smbcli_unlink(cli->tree, fname);
printf("open with attributes only can create file\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
printf("Subsequent normal open should break oplock on attribute only open to level II\n");
ZERO_STRUCT(break_info);
- cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
+ smbcli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
done:
- cli_close(cli->tree, fnum);
- cli_close(cli->tree, fnum2);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum2);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
*/
BOOL torture_raw_oplock(int dummy)
{
- struct cli_state *cli1;
+ struct smbcli_state *cli1;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
*/
BOOL torture_raw_qfileinfo(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int i;
BOOL ret = True;
int count;
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);
/* and make sure we can open by alternate name */
- cli_close(cli->tree, fnum);
- fnum = cli_nt_create_full(cli->tree, correct_name, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ smbcli_close(cli->tree, fnum);
+ fnum = smbcli_nt_create_full(cli->tree, correct_name, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
NTCREATEX_DISP_OVERWRITE_IF,
0, 0);
if (fnum == -1) {
- printf("Unable to open by alt_name - %s\n", cli_errstr(cli->tree));
+ printf("Unable to open by alt_name - %s\n", smbcli_errstr(cli->tree));
ret = False;
}
done:
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
*/
BOOL torture_raw_qfsinfo(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int i;
BOOL ret = True;
int count;
/*
test read ops
*/
-static BOOL test_read(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_read(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_read io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_READ\n");
io.generic.level = RAW_READ_READ;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io.read.in.fnum = fnum;
- cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
+ smbcli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.read.in.fnum = fnum;
CHECK_VALUE(io.read.out.nread, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
+ smbcli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
printf("Trying locked region\n");
cli->session->pid++;
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test lockread ops
*/
-static BOOL test_lockread(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_lockread(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_read io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_LOCKREAD\n");
io.generic.level = RAW_READ_LOCKREAD;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io.lockread.in.fnum = fnum;
- cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
+ smbcli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.lockread.in.fnum = fnum;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- cli_unlock(cli->tree, fnum, 0, 1);
+ smbcli_unlock(cli->tree, fnum, 0, 1);
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
io.lockread.in.count = strlen(test_data);
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
- cli_unlock(cli->tree, fnum, 0, strlen(test_data));
+ smbcli_unlock(cli->tree, fnum, 0, strlen(test_data));
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.lockread.out.nread, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
+ smbcli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
io.lockread.in.count = ~0;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
- cli_unlock(cli->tree, fnum, 1, strlen(test_data));
+ smbcli_unlock(cli->tree, fnum, 1, strlen(test_data));
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_BUFFER(buf, seed, io.lockread.out.nread);
- cli_unlock(cli->tree, fnum, 0, 0xFFFF);
+ smbcli_unlock(cli->tree, fnum, 0, 0xFFFF);
printf("Trying locked region\n");
cli->session->pid++;
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
done:
- cli_close(cli->tree, fnum);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_close(cli->tree, fnum);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test readx ops
*/
-static BOOL test_readx(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_read io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_READX\n");
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io.readx.in.fnum = fnum;
- cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
+ smbcli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.readx.in.fnum = fnum;
CHECK_VALUE(io.readx.out.compaction_mode, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
+ smbcli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
printf("Trying locked region\n");
cli->session->pid++;
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.readx.out.nread, 0);
- if (NT_STATUS_IS_ERR(cli_lock64(cli->tree, fnum, io.readx.in.offset, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock64(cli->tree, fnum, io.readx.in.offset, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.readx.out.nread, 0);
done:
- cli_close(cli->tree, fnum);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_close(cli->tree, fnum);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test readbraw ops
*/
-static BOOL test_readbraw(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_readbraw(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_read io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_READBRAW\n");
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.readbraw.out.nread, 0);
io.readbraw.in.fnum = fnum;
- cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
+ smbcli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.readbraw.in.fnum = fnum;
CHECK_VALUE(io.readbraw.out.nread, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
+ smbcli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
printf("Trying locked region\n");
cli->session->pid++;
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.readbraw.out.nread, 0);
done:
- cli_close(cli->tree, fnum);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_close(cli->tree, fnum);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_read(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
/*
test SMBmv ops
*/
-static BOOL test_mv(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_rename io;
NTSTATUS status;
printf("Testing SMBmv\n");
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test SMBntrename ops
*/
-static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_rename io;
NTSTATUS status;
printf("Testing SMBntrename\n");
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL);
- cli_unlink(cli->tree, fname2);
+ smbcli_unlink(cli->tree, fname2);
finfo.generic.in.fname = fname1;
status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL);
- cli_unlink(cli->tree, fname2);
+ smbcli_unlink(cli->tree, fname2);
finfo.generic.in.fname = fname1;
status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
#if 0
{
char buf[16384];
- fnum = cli_open(cli->tree, fname1, O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname1, O_RDWR, DENY_NONE);
memset(buf, 1, sizeof(buf));
- cli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
- cli_close(cli->tree, fnum);
+ smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
+ smbcli_close(cli->tree, fnum);
- fnum = cli_open(cli->tree, fname2, O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname2, O_RDWR, DENY_NONE);
memset(buf, 1, sizeof(buf));
- cli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf)-1);
- cli_close(cli->tree, fnum);
+ smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf)-1);
+ smbcli_close(cli->tree, fnum);
torture_all_info(cli->tree, fname1);
torture_all_info(cli->tree, fname2);
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_rename(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
/*
do a single file (non-wildcard) search
*/
-static NTSTATUS single_search(struct cli_state *cli,
+static NTSTATUS single_search(struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
const char *pattern,
enum smb_search_level level,
/*
basic testing of all RAW_SEARCH_* calls using a single file
*/
-static BOOL test_one_file(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
BOOL ret = True;
int fnum;
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
done:
smb_raw_exit(cli->session);
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
return ret;
}
/*
do a single file (non-wildcard) search
*/
-static NTSTATUS multiple_search(struct cli_state *cli,
+static NTSTATUS multiple_search(struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
const char *pattern,
enum smb_search_level level,
/*
basic testing of search calls using many files
*/
-static BOOL test_many_files(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const int num_files = 700;
int i, fnum, t;
{"SEARCH", "ID", RAW_SEARCH_SEARCH, CONT_RESUME_KEY}
};
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
return False;
}
for (i=0;i<num_files;i++) {
asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
- fnum = cli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
free(fname);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
}
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_search(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
/*
test seek ops
*/
-static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
struct smb_seek io;
union smb_fileinfo finfo;
const char *fname = BASEDIR "\\test.txt";
char c[2];
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
if (fnum == -1) {
- printf("Failed to open test.txt - %s\n", cli_errstr(cli->tree));
+ printf("Failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
printf("trying write to update offset\n");
ZERO_STRUCT(c);
- if (cli_write(cli->tree, fnum, 0, c, 0, 2) != 2) {
- printf("Write failed - %s\n", cli_errstr(cli->tree));
+ if (smbcli_write(cli->tree, fnum, 0, c, 0, 2) != 2) {
+ printf("Write failed - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.out.offset, 2);
- if (cli_read(cli->tree, fnum, c, 0, 1) != 1) {
- printf("Read failed - %s\n", cli_errstr(cli->tree));
+ if (smbcli_read(cli->tree, fnum, c, 0, 1) != 1) {
+ printf("Read failed - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.out.offset, 1);
printf("Testing position information\n");
- fnum2 = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("2nd open failed - %s\n", cli_errstr(cli->tree));
+ printf("2nd open failed - %s\n", smbcli_errstr(cli->tree));
ret = False;
goto done;
}
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_seek(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
*/
BOOL torture_raw_sfileinfo(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
int fnum_saved, d_fnum, fnum2, fnum = -1;
mem_ctx = talloc_init("torture_sfileinfo");
- cli_deltree(cli->tree, BASEDIR);
- cli_mkdir(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
+ smbcli_mkdir(cli->tree, BASEDIR);
#define RECREATE_FILE(fname) do { \
- if (fnum != -1) cli_close(cli->tree, fnum); \
+ if (fnum != -1) smbcli_close(cli->tree, fnum); \
fnum = create_complex_file(cli, mem_ctx, fname); \
if (fnum == -1) { \
printf("(%d) ERROR: open of %s failed (%s)\n", \
- __LINE__, fname, cli_errstr(cli->tree)); \
+ __LINE__, fname, smbcli_errstr(cli->tree)); \
ret = False; \
goto done; \
}} while (0)
#define RECREATE_BOTH do { \
RECREATE_FILE(path_fname); \
- cli_close(cli->tree, fnum); \
+ smbcli_close(cli->tree, fnum); \
RECREATE_FILE(fnum_fname); \
} while (0)
CHECK_VALUE(MODE_INFORMATION, mode_information, mode, 0);
#if 1
printf("finally the rename_information level\n");
- cli_close(cli->tree, create_complex_file(cli, mem_ctx, fnum_fname_new));
- cli_close(cli->tree, create_complex_file(cli, mem_ctx, path_fname_new));
+ smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, fnum_fname_new));
+ smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, path_fname_new));
sfinfo.rename_information.in.overwrite = 0;
sfinfo.rename_information.in.root_fid = 0;
printf("Trying rename with dest file open and delete_on_close\n");
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_ACCESS_DENIED);
- cli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum2);
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
sfinfo.rename_information.in.overwrite = 0;
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new);
- cli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum2);
sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
sfinfo.rename_information.in.overwrite = 0;
done:
smb_raw_exit(cli->session);
- cli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, fnum_fname))) {
- printf("Failed to delete %s - %s\n", fnum_fname, cli_errstr(cli->tree));
+ smbcli_close(cli->tree, fnum);
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fnum_fname))) {
+ printf("Failed to delete %s - %s\n", fnum_fname, smbcli_errstr(cli->tree));
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, path_fname))) {
- printf("Failed to delete %s - %s\n", path_fname, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, path_fname))) {
+ printf("Failed to delete %s - %s\n", path_fname, smbcli_errstr(cli->tree));
}
torture_close_connection(cli);
*/
BOOL torture_raw_sfileinfo_bug(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
const char *fname = "\\bug3.txt";
union smb_setfileinfo sfinfo;
mem_ctx = talloc_init("torture_sfileinfo");
fnum = create_complex_file(cli, mem_ctx, fname);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
sfinfo.generic.level = RAW_SFILEINFO_STANDARD;
sfinfo.generic.file.fname = fname;
/*
test unlink ops
*/
-static BOOL test_unlink(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_unlink(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
struct smb_unlink io;
NTSTATUS status;
BOOL ret = True;
const char *fname = BASEDIR "\\test.txt";
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
status = smb_raw_unlink(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
- cli_close(cli->tree, cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
+ smbcli_close(cli->tree, smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
io.in.pattern = fname;
io.in.attrib = 0;
CHECK_STATUS(status, NT_STATUS_OK);
printf("Trying a hidden file\n");
- cli_close(cli->tree, cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
+ smbcli_close(cli->tree, smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
torture_set_file_attribute(cli->tree, fname, FILE_ATTRIBUTE_HIDDEN);
io.in.pattern = fname;
CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
printf("Trying wildcards\n");
- cli_close(cli->tree, cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
+ smbcli_close(cli->tree, smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
io.in.pattern = BASEDIR "\\t*.t";
io.in.attrib = 0;
status = smb_raw_unlink(cli->tree, &io);
done:
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_unlink(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
/*
test write ops
*/
-static BOOL test_write(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_write io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITE\n");
io.generic.level = RAW_WRITE_WRITE;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.write.out.nwritten, io.write.in.count);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.write.out.nwritten, 4000);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_ALL_INFO(io.write.in.count + (uint64_t)io.write.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_BUFFER(buf, seed, 4000);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test writex ops
*/
-static BOOL test_writex(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_write io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITEX\n");
io.generic.level = RAW_WRITE_WRITEX;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.writex.out.nwritten, io.writex.in.count);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.writex.out.nwritten, 4000);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
printf("Trying locked region\n");
cli->session->pid++;
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
CHECK_ALL_INFO(io.writex.in.count + (uint64_t)io.writex.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_ALL_INFO(io.writex.in.count + (uint64_t)io.writex.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
setup_buffer(buf, seed, maxsize);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test write unlock ops
*/
-static BOOL test_writeunlock(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_write io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITEUNLOCK\n");
io.generic.level = RAW_WRITE_WRITEUNLOCK;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
io.writeunlock.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(IVAL(buf,0), 0);
setup_buffer(buf, seed, maxsize);
- cli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
+ smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
0, WRITE_LOCK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeunlock.out.nwritten, io.writeunlock.in.count);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
io.writeunlock.in.count = 4000;
io.writeunlock.in.offset = 0;
io.writeunlock.in.data = buf;
- cli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
+ smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
0, WRITE_LOCK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
io.writeunlock.in.count = 4000;
io.writeunlock.in.offset = 0xFFFFFFFF - 2000;
io.writeunlock.in.data = buf;
- cli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
+ smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
0, WRITE_LOCK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_ALL_INFO(io.writeunlock.in.count + (uint64_t)io.writeunlock.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_BUFFER(buf, seed, 4000);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test write close ops
*/
-static BOOL test_writeclose(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_write io;
NTSTATUS status;
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
+ printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITECLOSE\n");
io.generic.level = RAW_WRITE_WRITECLOSE;
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
+ printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
- fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
- if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, io.writeclose.in.count);
- fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
- fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.writeclose.out.nwritten, 4000);
CHECK_ALL_INFO(io.writeclose.in.count + (uint64_t)io.writeclose.in.offset, size);
- fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
memset(buf, 0, maxsize);
- if (cli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
+ if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_BUFFER(buf, seed, 4000);
done:
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli->tree, BASEDIR);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
*/
BOOL torture_raw_write(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
int torture_entries=1000;
int torture_failures=1;
static int procnum; /* records process count number when forking */
-static struct cli_state *current_cli;
+static struct smbcli_state *current_cli;
static BOOL use_oplocks;
static BOOL use_level_II_oplocks;
static BOOL use_kerberos;
#define CHECK_MAX_FAILURES(label) do { if (++failures >= torture_failures) goto label; } while (0)
-static struct cli_state *open_nbt_connection(void)
+static struct smbcli_state *open_nbt_connection(void)
{
struct nmb_name called, calling;
struct in_addr ip;
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *host = lp_parm_string(-1, "torture", "host");
make_nmb_name(&calling, lp_netbios_name(), 0x0);
zero_ip(&ip);
- cli = cli_state_init();
+ cli = smbcli_state_init();
if (!cli) {
- printf("Failed initialize cli_struct to connect with %s\n", host);
+ printf("Failed initialize smbcli_struct to connect with %s\n", host);
return NULL;
}
- if (!cli_socket_connect(cli, host, &ip)) {
+ if (!smbcli_socket_connect(cli, host, &ip)) {
printf("Failed to connect with %s\n", host);
return cli;
}
cli->transport->socket->timeout = 120000; /* set a really long timeout (2 minutes) */
- if (!cli_transport_establish(cli, &calling, &called)) {
+ if (!smbcli_transport_establish(cli, &calling, &called)) {
/*
* Well, that failed, try *SMBSERVER ...
* However, we must reconnect as well ...
*/
- if (!cli_socket_connect(cli, host, &ip)) {
+ if (!smbcli_socket_connect(cli, host, &ip)) {
printf("Failed to connect with %s\n", host);
return False;
}
make_nmb_name(&called, "*SMBSERVER", 0x20);
- if (!cli_transport_establish(cli, &calling, &called)) {
+ if (!smbcli_transport_establish(cli, &calling, &called)) {
printf("%s rejected the session\n",host);
printf("We tried with a called name of %s & %s\n",
host, "*SMBSERVER");
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return NULL;
}
}
return cli;
}
-BOOL torture_open_connection_share(struct cli_state **c,
+BOOL torture_open_connection_share(struct smbcli_state **c,
const char *hostname,
const char *sharename)
{
const char *password = lp_parm_string(-1, "torture", "password");
if (use_kerberos)
- flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+ flags |= SMBCLI_FULL_CONNECTION_USE_KERBEROS;
- status = cli_full_connection(c, lp_netbios_name(),
+ status = smbcli_full_connection(c, lp_netbios_name(),
hostname, NULL,
sharename, "?????",
username, username[0]?lp_workgroup():"",
return True;
}
-BOOL torture_open_connection(struct cli_state **c)
+BOOL torture_open_connection(struct smbcli_state **c)
{
const char *host = lp_parm_string(-1, "torture", "host");
const char *share = lp_parm_string(-1, "torture", "share");
-BOOL torture_close_connection(struct cli_state *c)
+BOOL torture_close_connection(struct smbcli_state *c)
{
BOOL ret = True;
- DEBUG(9,("torture_close_connection: cli_state@%p\n", c));
+ DEBUG(9,("torture_close_connection: smbcli_state@%p\n", c));
if (!c) return True;
- if (NT_STATUS_IS_ERR(cli_tdis(c))) {
- printf("tdis failed (%s)\n", cli_errstr(c->tree));
+ if (NT_STATUS_IS_ERR(smbcli_tdis(c))) {
+ printf("tdis failed (%s)\n", smbcli_errstr(c->tree));
ret = False;
}
- DEBUG(9,("torture_close_connection: call cli_shutdown\n"));
- cli_shutdown(c);
+ DEBUG(9,("torture_close_connection: call smbcli_shutdown\n"));
+ smbcli_shutdown(c);
DEBUG(9,("torture_close_connection: exit\n"));
return ret;
}
/* check if the server produced the expected error code */
-static BOOL check_error(int line, struct cli_state *c,
+static BOOL check_error(int line, struct smbcli_state *c,
uint8_t eclass, uint32_t ecode, NTSTATUS nterr)
{
- if (cli_is_dos_error(c->tree)) {
+ if (smbcli_is_dos_error(c->tree)) {
uint8_t class;
uint32_t num;
/* Check DOS error */
- cli_dos_error(c, &class, &num);
+ smbcli_dos_error(c, &class, &num);
if (eclass != class || ecode != num) {
printf("unexpected error code class=%d code=%d\n",
/* Check NT error */
- status = cli_nt_error(c->tree);
+ status = smbcli_nt_error(c->tree);
if (NT_STATUS_V(nterr) != NT_STATUS_V(status)) {
printf("unexpected error code %s\n", nt_errstr(status));
}
-static BOOL wait_lock(struct cli_state *c, int fnum, uint32_t offset, uint32_t len)
+static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len)
{
- while (NT_STATUS_IS_ERR(cli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) {
+ while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) {
if (!check_error(__LINE__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
return True;
}
-static BOOL rw_torture(struct cli_state *c)
+static BOOL rw_torture(struct smbcli_state *c)
{
const char *lockfname = "\\torture.lck";
char *fname;
char buf[1024];
BOOL correct = True;
- fnum2 = cli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
if (fnum2 == -1)
- fnum2 = cli_open(c->tree, lockfname, O_RDWR, DENY_NONE);
+ fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open of %s failed (%s)\n", lockfname, cli_errstr(c->tree));
+ printf("open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree));
return False;
}
return False;
}
- fnum = cli_open(c->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL);
+ fnum = smbcli_open(c->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL);
if (fnum == -1) {
- printf("open failed (%s)\n", cli_errstr(c->tree));
+ printf("open failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
break;
}
- if (cli_write(c->tree, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
- printf("write failed (%s)\n", cli_errstr(c->tree));
+ if (smbcli_write(c->tree, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
+ printf("write failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
for (j=0;j<50;j++) {
- if (cli_write(c->tree, fnum, 0, (char *)buf,
+ if (smbcli_write(c->tree, fnum, 0, (char *)buf,
sizeof(pid)+(j*sizeof(buf)),
sizeof(buf)) != sizeof(buf)) {
- printf("write failed (%s)\n", cli_errstr(c->tree));
+ printf("write failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
}
pid2 = 0;
- if (cli_read(c->tree, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
- printf("read failed (%s)\n", cli_errstr(c->tree));
+ if (smbcli_read(c->tree, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
+ printf("read failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_close(c->tree, fnum))) {
- printf("close failed (%s)\n", cli_errstr(c->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) {
+ printf("close failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_unlink(c->tree, fname))) {
- printf("unlink failed (%s)\n", cli_errstr(c->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) {
+ printf("unlink failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) {
- printf("unlock failed (%s)\n", cli_errstr(c->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) {
+ printf("unlock failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
free(fname);
}
- cli_close(c->tree, fnum2);
- cli_unlink(c->tree, lockfname);
+ smbcli_close(c->tree, fnum2);
+ smbcli_unlink(c->tree, lockfname);
printf("%d\n", i);
return correct;
}
-static BOOL run_torture(struct cli_state *cli, int dummy)
+static BOOL run_torture(struct smbcli_state *cli, int dummy)
{
BOOL ret;
return ret;
}
-static BOOL rw_torture3(struct cli_state *c, const char *lockfname)
+static BOOL rw_torture3(struct smbcli_state *c, const char *lockfname)
{
int fnum = -1;
uint_t i = 0;
if (procnum == 0)
{
- fnum = cli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ fnum = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
if (fnum == -1) {
printf("first open read/write of %s failed (%s)\n",
- lockfname, cli_errstr(c->tree));
+ lockfname, smbcli_errstr(c->tree));
return False;
}
}
{
for (i = 0; i < 500 && fnum == -1; i++)
{
- fnum = cli_open(c->tree, lockfname, O_RDONLY,
+ fnum = smbcli_open(c->tree, lockfname, O_RDONLY,
DENY_NONE);
msleep(10);
}
if (fnum == -1) {
printf("second open read-only of %s failed (%s)\n",
- lockfname, cli_errstr(c->tree));
+ lockfname, smbcli_errstr(c->tree));
return False;
}
}
sent = sizeof(buf) - count;
}
- if (cli_write(c->tree, fnum, 0, buf+count, count, (size_t)sent) != sent) {
- printf("write failed (%s)\n", cli_errstr(c->tree));
+ if (smbcli_write(c->tree, fnum, 0, buf+count, count, (size_t)sent) != sent) {
+ printf("write failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
}
else
{
- sent = cli_read(c->tree, fnum, buf_rd+count, count,
+ sent = smbcli_read(c->tree, fnum, buf_rd+count, count,
sizeof(buf)-count);
if (sent < 0)
{
printf("read failed offset:%d size:%d (%s)\n",
count, sizeof(buf)-count,
- cli_errstr(c->tree));
+ smbcli_errstr(c->tree));
correct = False;
sent = 0;
}
}
- if (NT_STATUS_IS_ERR(cli_close(c->tree, fnum))) {
- printf("close failed (%s)\n", cli_errstr(c->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) {
+ printf("close failed (%s)\n", smbcli_errstr(c->tree));
correct = False;
}
return correct;
}
-static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
+static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2)
{
const char *lockfname = "\\torture2.lck";
int fnum1;
BOOL correct = True;
ssize_t bytes_read, bytes_written;
- if (cli_deltree(c1->tree, lockfname) == -1) {
- printf("unlink failed (%s)\n", cli_errstr(c1->tree));
+ if (smbcli_deltree(c1->tree, lockfname) == -1) {
+ printf("unlink failed (%s)\n", smbcli_errstr(c1->tree));
}
- fnum1 = cli_open(c1->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ fnum1 = smbcli_open(c1->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
if (fnum1 == -1) {
printf("first open read/write of %s failed (%s)\n",
- lockfname, cli_errstr(c1->tree));
+ lockfname, smbcli_errstr(c1->tree));
return False;
}
- fnum2 = cli_open(c2->tree, lockfname, O_RDONLY,
+ fnum2 = smbcli_open(c2->tree, lockfname, O_RDONLY,
DENY_NONE);
if (fnum2 == -1) {
printf("second open read-only of %s failed (%s)\n",
- lockfname, cli_errstr(c2->tree));
- cli_close(c1->tree, fnum1);
+ lockfname, smbcli_errstr(c2->tree));
+ smbcli_close(c1->tree, fnum1);
return False;
}
generate_random_buffer(buf, buf_size);
- if ((bytes_written = cli_write(c1->tree, fnum1, 0, buf, 0, buf_size)) != buf_size) {
- printf("write failed (%s)\n", cli_errstr(c1->tree));
+ if ((bytes_written = smbcli_write(c1->tree, fnum1, 0, buf, 0, buf_size)) != buf_size) {
+ printf("write failed (%s)\n", smbcli_errstr(c1->tree));
printf("wrote %d, expected %d\n", bytes_written, buf_size);
correct = False;
break;
}
- if ((bytes_read = cli_read(c2->tree, fnum2, buf_rd, 0, buf_size)) != buf_size) {
- printf("read failed (%s)\n", cli_errstr(c2->tree));
+ if ((bytes_read = smbcli_read(c2->tree, fnum2, buf_rd, 0, buf_size)) != buf_size) {
+ printf("read failed (%s)\n", smbcli_errstr(c2->tree));
printf("read %d, expected %d\n", bytes_read, buf_size);
correct = False;
break;
}
}
- if (NT_STATUS_IS_ERR(cli_close(c2->tree, fnum2))) {
- printf("close failed (%s)\n", cli_errstr(c2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(c2->tree, fnum2))) {
+ printf("close failed (%s)\n", smbcli_errstr(c2->tree));
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_close(c1->tree, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(c1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(c1->tree, fnum1))) {
+ printf("close failed (%s)\n", smbcli_errstr(c1->tree));
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_unlink(c1->tree, lockfname))) {
- printf("unlink failed (%s)\n", cli_errstr(c1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(c1->tree, lockfname))) {
+ printf("unlink failed (%s)\n", smbcli_errstr(c1->tree));
correct = False;
}
static BOOL run_readwritetest(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
BOOL test1, test2 = True;
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
return (test1 && test2);
}
-static BOOL run_readwritemulti(struct cli_state *cli, int dummy)
+static BOOL run_readwritemulti(struct smbcli_state *cli, int dummy)
{
BOOL test;
*/
static BOOL run_locktest1(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
const char *fname = "\\lockt1.lck";
int fnum1, fnum2, fnum3;
time_t t1, t2;
printf("starting locktest1\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- fnum2 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ fnum2 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- fnum3 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
+ fnum3 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum3 == -1) {
- printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("open3 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
- printf("lock1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
+ printf("lock1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) {
printf("lock2 succeeded! This is a locking bug\n");
return False;
} else {
lock_timeout = (6 + (random() % 20));
printf("Testing lock timeout with timeout=%u\n", lock_timeout);
t1 = time(NULL);
- if (NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK))) {
printf("lock3 succeeded! This is a locking bug\n");
return False;
} else {
printf("server slept for %u seconds for a %u second timeout\n",
(uint_t)(t2-t1), lock_timeout);
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum2))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
+ printf("close1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) {
printf("lock4 succeeded! This is a locking bug\n");
return False;
} else {
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum3))) {
- printf("close3 failed (%s)\n", cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum3))) {
+ printf("close3 failed (%s)\n", smbcli_errstr(cli2->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli1->tree, fname))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli1->tree, fname))) {
+ printf("unlink failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
*/
static BOOL run_tcon_test(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *fname = "\\tcontest.tmp";
int fnum1;
uint16_t cnum1, cnum2, cnum3;
uint16_t vuid1, vuid2;
char buf[4];
BOOL ret = True;
- struct cli_tree *tree1;
+ struct smbcli_tree *tree1;
const char *host = lp_parm_string(-1, "torture", "host");
const char *share = lp_parm_string(-1, "torture", "share");
const char *password = lp_parm_string(-1, "torture", "password");
printf("starting tcontest\n");
- if (cli_deltree(cli->tree, fname) == -1) {
- printf("unlink of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, fname) == -1) {
+ printf("unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
}
- fnum1 = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
vuid1 = cli->session->vuid;
memset(&buf, 0, 4); /* init buf so valgrind won't complain */
- if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) != 4) {
- printf("initial write failed (%s)\n", cli_errstr(cli->tree));
+ if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("initial write failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
tree1 = cli->tree; /* save old tree connection */
- if (NT_STATUS_IS_ERR(cli_send_tconX(cli, share, "?????", password))) {
+ if (NT_STATUS_IS_ERR(smbcli_send_tconX(cli, share, "?????", password))) {
printf("%s refused 2nd tree connect (%s)\n", host,
- cli_errstr(cli->tree));
- cli_shutdown(cli);
+ smbcli_errstr(cli->tree));
+ smbcli_shutdown(cli);
return False;
}
/* try a write with the wrong tid */
cli->tree->tid = cnum2;
- if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
+ if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
printf("* server allows write with wrong TID\n");
ret = False;
} else {
- printf("server fails write with wrong TID : %s\n", cli_errstr(cli->tree));
+ printf("server fails write with wrong TID : %s\n", smbcli_errstr(cli->tree));
}
/* try a write with an invalid tid */
cli->tree->tid = cnum3;
- if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
+ if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
printf("* server allows write with invalid TID\n");
ret = False;
} else {
- printf("server fails write with invalid TID : %s\n", cli_errstr(cli->tree));
+ printf("server fails write with invalid TID : %s\n", smbcli_errstr(cli->tree));
}
/* try a write with an invalid vuid */
cli->session->vuid = vuid2;
cli->tree->tid = cnum1;
- if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
+ if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
printf("* server allows write with invalid VUID\n");
ret = False;
} else {
- printf("server fails write with invalid VUID : %s\n", cli_errstr(cli->tree));
+ printf("server fails write with invalid VUID : %s\n", smbcli_errstr(cli->tree));
}
cli->session->vuid = vuid1;
cli->tree->tid = cnum1;
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum1))) {
+ printf("close failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
cli->tree->tid = cnum2;
- if (NT_STATUS_IS_ERR(cli_tdis(cli))) {
- printf("secondary tdis failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_tdis(cli))) {
+ printf("secondary tdis failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
-static BOOL tcon_devtest(struct cli_state *cli,
+static BOOL tcon_devtest(struct smbcli_state *cli,
const char *myshare, const char *devtype,
NTSTATUS expected_error)
{
BOOL ret;
const char *password = lp_parm_string(-1, "torture", "password");
- status = NT_STATUS_IS_OK(cli_send_tconX(cli, myshare, devtype,
+ status = NT_STATUS_IS_OK(smbcli_send_tconX(cli, myshare, devtype,
password));
printf("Trying share %s with devtype %s\n", myshare, devtype);
myshare, devtype);
ret = False;
}
- cli_tdis(cli);
+ smbcli_tdis(cli);
} else {
if (status) {
printf("tconx to share %s with type %s "
myshare, devtype);
ret = False;
} else {
- if (NT_STATUS_EQUAL(cli_nt_error(cli->tree),
+ if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),
expected_error)) {
ret = True;
} else {
*/
static BOOL run_tcon_devtype_test(int dummy)
{
- struct cli_state *cli1 = NULL;
+ struct smbcli_state *cli1 = NULL;
BOOL retry;
int flags = 0;
NTSTATUS status;
const char *username = lp_parm_string(-1, "torture", "username");
const char *password = lp_parm_string(-1, "torture", "password");
- status = cli_full_connection(&cli1, lp_netbios_name(),
+ status = smbcli_full_connection(&cli1, lp_netbios_name(),
host, NULL,
share, "?????",
username, lp_workgroup(),
if (!tcon_devtest(cli1, share, "FOOBA", NT_STATUS_BAD_DEVICE_TYPE))
ret = False;
- cli_shutdown(cli1);
+ smbcli_shutdown(cli1);
if (ret)
printf("Passed tcondevtest\n");
*/
static BOOL run_locktest2(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *fname = "\\lockt2.lck";
int fnum1, fnum2, fnum3;
BOOL correct = True;
printf("starting locktest2\n");
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
printf("Testing pid context\n");
cli->session->pid = 1;
- fnum1 = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
- fnum2 = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open2 of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
cli->session->pid = 2;
- fnum3 = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+ fnum3 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum3 == -1) {
- printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open3 of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
cli->session->pid = 1;
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
- printf("lock1 failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
+ printf("lock1 failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
printf("WRITE lock1 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK))) {
printf("WRITE lock2 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK))) {
printf("READ lock2 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
- if (NT_STATUS_IS_ERR(cli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK))) {
- printf("lock at 100 failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK))) {
+ printf("lock at 100 failed (%s)\n", smbcli_errstr(cli->tree));
}
cli->session->pid = 2;
- if (NT_STATUS_IS_OK(cli_unlock(cli->tree, fnum1, 100, 4))) {
+ if (NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 100, 4))) {
printf("unlock at 100 succeeded! This is a locking bug\n");
correct = False;
}
- if (NT_STATUS_IS_OK(cli_unlock(cli->tree, fnum1, 0, 4))) {
+ if (NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 4))) {
printf("unlock1 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_RANGE_NOT_LOCKED)) return False;
}
- if (NT_STATUS_IS_OK(cli_unlock(cli->tree, fnum1, 0, 8))) {
+ if (NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 8))) {
printf("unlock2 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_RANGE_NOT_LOCKED)) return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK))) {
printf("lock3 succeeded! This is a locking bug\n");
correct = False;
} else {
cli->session->pid = 1;
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum1))) {
+ printf("close1 failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum2))) {
- printf("close2 failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum2))) {
+ printf("close2 failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum3))) {
- printf("close3 failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum3))) {
+ printf("close3 failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
*/
static BOOL run_locktest3(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
const char *fname = "\\lockt3.lck";
int fnum1, fnum2, i;
uint32_t offset;
printf("Testing 32 bit offset ranges\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- fnum2 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
+ fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("open2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
return False;
}
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (NT_STATUS_IS_ERR(cli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK))) {
printf("lock1 %d failed (%s)\n",
i,
- cli_errstr(cli1->tree));
+ smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK))) {
printf("lock2 %d failed (%s)\n",
i,
- cli_errstr(cli1->tree));
+ smbcli_errstr(cli1->tree));
return False;
}
}
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, offset-2, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, offset-2, 1, 0, WRITE_LOCK))) {
printf("error: lock1 %d succeeded!\n", i);
return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, offset-1, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, offset-1, 1, 0, WRITE_LOCK))) {
printf("error: lock2 %d succeeded!\n", i);
return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK))) {
printf("error: lock3 %d succeeded!\n", i);
return False;
}
- if (NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK))) {
+ if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK))) {
printf("error: lock4 %d succeeded!\n", i);
return False;
}
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (NT_STATUS_IS_ERR(cli_unlock(cli1->tree, fnum1, offset-1, 1))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlock(cli1->tree, fnum1, offset-1, 1))) {
printf("unlock1 %d failed (%s)\n",
i,
- cli_errstr(cli1->tree));
+ smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_unlock(cli2->tree, fnum2, offset-2, 1))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlock(cli2->tree, fnum2, offset-2, 1))) {
printf("unlock2 %d failed (%s)\n",
i,
- cli_errstr(cli1->tree));
+ smbcli_errstr(cli1->tree));
return False;
}
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("close2 failed (%s)\n", cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("close2 failed (%s)\n", smbcli_errstr(cli2->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli1->tree, fname))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli1->tree, fname))) {
+ printf("unlink failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
*/
static BOOL run_locktest4(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
const char *fname = "\\lockt4.lck";
int fnum1, fnum2, f;
BOOL ret;
printf("starting locktest4\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- fnum2 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
correct = False;
goto fail;
}
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 2, 4, 0, WRITE_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 2, 4, 0, WRITE_LOCK));
EXPECTED(ret, False);
printf("the same process %s set overlapping write locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 10, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 12, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 10, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 12, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("the same process %s set overlapping read locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 20, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, 22, 4, 0, WRITE_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 20, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 22, 4, 0, WRITE_LOCK));
EXPECTED(ret, False);
printf("a different connection %s set overlapping write locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 30, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, 32, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 30, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 32, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("a different connection %s set overlapping read locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK((cli1->session->pid = 1, cli_lock(cli1->tree, fnum1, 40, 4, 0, WRITE_LOCK))) &&
- NT_STATUS_IS_OK((cli1->session->pid = 2, cli_lock(cli1->tree, fnum1, 42, 4, 0, WRITE_LOCK)));
+ ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 40, 4, 0, WRITE_LOCK))) &&
+ NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 42, 4, 0, WRITE_LOCK)));
EXPECTED(ret, False);
printf("a different pid %s set overlapping write locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK((cli1->session->pid = 1, cli_lock(cli1->tree, fnum1, 50, 4, 0, READ_LOCK))) &&
- NT_STATUS_IS_OK((cli1->session->pid = 2, cli_lock(cli1->tree, fnum1, 52, 4, 0, READ_LOCK)));
+ ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 50, 4, 0, READ_LOCK))) &&
+ NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 52, 4, 0, READ_LOCK)));
EXPECTED(ret, True);
printf("a different pid %s set overlapping read locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("the same process %s set the same read lock twice\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK));
EXPECTED(ret, False);
printf("the same process %s set the same write lock twice\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 80, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 80, 4, 0, WRITE_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, WRITE_LOCK));
EXPECTED(ret, False);
printf("the same process %s overlay a read lock with a write lock\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 90, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 90, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("the same process %s overlay a write lock with a read lock\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK((cli1->session->pid = 1, cli_lock(cli1->tree, fnum1, 100, 4, 0, WRITE_LOCK))) &&
- NT_STATUS_IS_OK((cli1->session->pid = 2, cli_lock(cli1->tree, fnum1, 100, 4, 0, READ_LOCK)));
+ ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, WRITE_LOCK))) &&
+ NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, READ_LOCK)));
EXPECTED(ret, False);
printf("a different pid %s overlay a write lock with a read lock\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 110, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 112, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 110, 6));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 110, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 112, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 110, 6));
EXPECTED(ret, False);
printf("the same process %s coalesce read locks\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 120, 4, 0, WRITE_LOCK)) &&
- (cli_read(cli2->tree, fnum2, buf, 120, 4) == 4);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 120, 4, 0, WRITE_LOCK)) &&
+ (smbcli_read(cli2->tree, fnum2, buf, 120, 4) == 4);
EXPECTED(ret, False);
printf("this server %s strict write locking\n", ret?"doesn't do":"does");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK)) &&
- (cli_write(cli2->tree, fnum2, 0, buf, 130, 4) == 4);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK)) &&
+ (smbcli_write(cli2->tree, fnum2, 0, buf, 130, 4) == 4);
EXPECTED(ret, False);
printf("this server %s strict read locking\n", ret?"doesn't do":"does");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 140, 4)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 140, 4));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4));
EXPECTED(ret, True);
printf("this server %s do recursive read locking\n", ret?"does":"doesn't");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 150, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 150, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 150, 4)) &&
- (cli_read(cli2->tree, fnum2, buf, 150, 4) == 4) &&
- !(cli_write(cli2->tree, fnum2, 0, buf, 150, 4) == 4) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 150, 4));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 150, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 150, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 150, 4)) &&
+ (smbcli_read(cli2->tree, fnum2, buf, 150, 4) == 4) &&
+ !(smbcli_write(cli2->tree, fnum2, 0, buf, 150, 4) == 4) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 150, 4));
EXPECTED(ret, True);
printf("this server %s do recursive lock overlays\n", ret?"does":"doesn't");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 160, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 160, 4)) &&
- (cli_write(cli2->tree, fnum2, 0, buf, 160, 4) == 4) &&
- (cli_read(cli2->tree, fnum2, buf, 160, 4) == 4);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 160, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 160, 4)) &&
+ (smbcli_write(cli2->tree, fnum2, 0, buf, 160, 4) == 4) &&
+ (smbcli_read(cli2->tree, fnum2, buf, 160, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove a read lock using write locking\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 170, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 170, 4)) &&
- (cli_write(cli2->tree, fnum2, 0, buf, 170, 4) == 4) &&
- (cli_read(cli2->tree, fnum2, buf, 170, 4) == 4);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 170, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 170, 4)) &&
+ (smbcli_write(cli2->tree, fnum2, 0, buf, 170, 4) == 4) &&
+ (smbcli_read(cli2->tree, fnum2, buf, 170, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove a write lock using read locking\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 190, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 190, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 190, 4)) &&
- !(cli_write(cli2->tree, fnum2, 0, buf, 190, 4) == 4) &&
- (cli_read(cli2->tree, fnum2, buf, 190, 4) == 4);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 190, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 190, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 190, 4)) &&
+ !(smbcli_write(cli2->tree, fnum2, 0, buf, 190, 4) == 4) &&
+ (smbcli_read(cli2->tree, fnum2, buf, 190, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove the first lock first\n", ret?"does":"doesn't");
- cli_close(cli1->tree, fnum1);
- cli_close(cli2->tree, fnum2);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
- f = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, f, 0, 1, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_close(cli1->tree, fnum1)) &&
- ((fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE)) != -1) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK));
- cli_close(cli1->tree, f);
- cli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli2->tree, fnum2);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ f = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, f, 0, 1, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_close(cli1->tree, fnum1)) &&
+ ((fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE)) != -1) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK));
+ smbcli_close(cli1->tree, f);
+ smbcli_close(cli1->tree, fnum1);
EXPECTED(ret, True);
printf("the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't");
fail:
- cli_close(cli1->tree, fnum1);
- cli_close(cli2->tree, fnum2);
- cli_unlink(cli1->tree, fname);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli2->tree, fnum2);
+ smbcli_unlink(cli1->tree, fname);
torture_close_connection(cli1);
torture_close_connection(cli2);
*/
static BOOL run_locktest5(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
const char *fname = "\\lockt5.lck";
int fnum1, fnum2, fnum3;
BOOL ret;
printf("starting locktest5\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- fnum2 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
- fnum3 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
+ fnum3 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
correct = False;
goto fail;
}
/* Check for NT bug... */
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum3, 0, 1, 0, READ_LOCK));
- cli_close(cli1->tree, fnum1);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum3, 0, 1, 0, READ_LOCK));
+ smbcli_close(cli1->tree, fnum1);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK));
EXPECTED(ret, True);
printf("this server %s the NT locking bug\n", ret ? "doesn't have" : "has");
- cli_close(cli1->tree, fnum1);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
- cli_unlock(cli1->tree, fnum3, 0, 1);
+ smbcli_close(cli1->tree, fnum1);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ smbcli_unlock(cli1->tree, fnum3, 0, 1);
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 1, 1, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 1, 1, 0, READ_LOCK));
EXPECTED(ret, True);
printf("the same process %s overlay a write with a read lock\n", ret?"can":"cannot");
- ret = NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK));
EXPECTED(ret, False);
printf("a different processs %s get a read lock on the first process lock stack\n", ret?"can":"cannot");
/* Unlock the process 2 lock. */
- cli_unlock(cli2->tree, fnum2, 0, 4);
+ smbcli_unlock(cli2->tree, fnum2, 0, 4);
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum3, 0, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum3, 0, 4, 0, READ_LOCK));
EXPECTED(ret, False);
printf("the same processs on a different fnum %s get a read lock\n", ret?"can":"cannot");
/* Unlock the process 1 fnum3 lock. */
- cli_unlock(cli1->tree, fnum3, 0, 4);
+ smbcli_unlock(cli1->tree, fnum3, 0, 4);
/* Stack 2 more locks here. */
- ret = NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK)) &&
- NT_STATUS_IS_OK(cli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("the same process %s stack read locks\n", ret?"can":"cannot");
/* Unlock the first process lock, then check this was the WRITE lock that was
removed. */
-ret = NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 0, 4)) &&
- NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK));
+ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) &&
+ NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("the first unlock removes the %s lock\n", ret?"WRITE":"READ");
/* Unlock the process 2 lock. */
- cli_unlock(cli2->tree, fnum2, 0, 4);
+ smbcli_unlock(cli2->tree, fnum2, 0, 4);
/* We should have 3 stacked locks here. Ensure we need to do 3 unlocks. */
- ret = NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 1, 1)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 0, 4)) &&
- NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 0, 4));
+ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 1, 1)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) &&
+ NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4));
EXPECTED(ret, True);
printf("the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot");
/* Ensure the next unlock fails. */
- ret = NT_STATUS_IS_OK(cli_unlock(cli1->tree, fnum1, 0, 4));
+ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4));
EXPECTED(ret, False);
printf("the same process %s count the lock stack\n", !ret?"can":"cannot");
/* Ensure connection 2 can get a write lock. */
- ret = NT_STATUS_IS_OK(cli_lock(cli2->tree, fnum2, 0, 4, 0, WRITE_LOCK));
+ ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, WRITE_LOCK));
EXPECTED(ret, True);
printf("a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot");
fail:
- cli_close(cli1->tree, fnum1);
- cli_close(cli2->tree, fnum2);
- cli_unlink(cli1->tree, fname);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli2->tree, fnum2);
+ smbcli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
correct = False;
}
*/
static BOOL run_locktest6(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *fname[1] = { "\\lock6.txt" };
int i;
int fnum;
for (i=0;i<1;i++) {
printf("Testing %s\n", fname[i]);
- cli_unlink(cli->tree, fname[i]);
+ smbcli_unlink(cli->tree, fname[i]);
- fnum = cli_open(cli->tree, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- status = cli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE);
- cli_close(cli->tree, fnum);
+ fnum = smbcli_open(cli->tree, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ status = smbcli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE);
+ smbcli_close(cli->tree, fnum);
printf("CHANGE_LOCKTYPE gave %s\n", nt_errstr(status));
- fnum = cli_open(cli->tree, fname[i], O_RDWR, DENY_NONE);
- status = cli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CANCEL_LOCK);
- cli_close(cli->tree, fnum);
+ fnum = smbcli_open(cli->tree, fname[i], O_RDWR, DENY_NONE);
+ status = smbcli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CANCEL_LOCK);
+ smbcli_close(cli->tree, fnum);
printf("CANCEL_LOCK gave %s\n", nt_errstr(status));
- cli_unlink(cli->tree, fname[i]);
+ smbcli_unlink(cli->tree, fname[i]);
}
torture_close_connection(cli);
static BOOL run_locktest7(int dummy)
{
- struct cli_state *cli1;
+ struct smbcli_state *cli1;
const char *fname = "\\lockt7.lck";
int fnum1;
int fnum2;
printf("starting locktest7\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
goto fail;
}
cli1->session->pid = 1;
- if (NT_STATUS_IS_ERR(cli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK))) {
- printf("Unable to apply read lock on range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK))) {
+ printf("Unable to apply read lock on range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully locked range 130:4 for READ\n");
}
- if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
- printf("pid1 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid1 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully read the range 130:4\n");
}
- if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
- if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid1 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
+ if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
cli1->session->pid = 2;
- if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
- printf("pid2 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid2 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
} else {
printf("pid2 successfully read the range 130:4\n");
}
- if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
- if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid2 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
+ if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
}
cli1->session->pid = 1;
- cli_unlock(cli1->tree, fnum1, 130, 4);
+ smbcli_unlock(cli1->tree, fnum1, 130, 4);
- if (NT_STATUS_IS_ERR(cli_lock(cli1->tree, fnum1, 130, 4, 0, WRITE_LOCK))) {
- printf("Unable to apply write lock on range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, WRITE_LOCK))) {
+ printf("Unable to apply write lock on range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully locked range 130:4 for WRITE\n");
}
- if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
- printf("pid1 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid1 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully read the range 130:4\n");
}
- if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid1 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully wrote to the range 130:4\n");
cli1->session->pid = 2;
- if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
- printf("pid2 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
- if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid2 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
+ if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
goto fail;
}
- if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
- if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid2 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
+ if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
printf("Testing truncate of locked file.\n");
- fnum2 = cli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
+ fnum2 = smbcli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
if (fnum2 == -1) {
printf("Unable to truncate locked file.\n");
printf("Truncated locked file.\n");
}
- if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &size, NULL))) {
- printf("getatr failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &size, NULL))) {
+ printf("getatr failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
cli1->session->pid = 1;
- cli_unlock(cli1->tree, fnum1, 130, 4);
+ smbcli_unlock(cli1->tree, fnum1, 130, 4);
correct = True;
fail:
- cli_close(cli1->tree, fnum1);
- cli_close(cli1->tree, fnum2);
- cli_unlink(cli1->tree, fname);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+ smbcli_unlink(cli1->tree, fname);
torture_close_connection(cli1);
printf("finished locktest7\n");
*/
static BOOL run_fdpasstest(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
const char *fname = "\\fdpass.tst";
int fnum1, oldtid;
pstring buf;
printf("starting fdpasstest\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("Opening a file on connection 1\n");
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
printf("writing to file on connection 1\n");
- if (cli_write(cli1->tree, fnum1, 0, "hello world\n", 0, 13) != 13) {
- printf("write failed (%s)\n", cli_errstr(cli1->tree));
+ if (smbcli_write(cli1->tree, fnum1, 0, "hello world\n", 0, 13) != 13) {
+ printf("write failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
printf("reading from file on connection 2\n");
- if (cli_read(cli2->tree, fnum1, buf, 0, 13) == 13) {
+ if (smbcli_read(cli2->tree, fnum1, buf, 0, 13) == 13) {
printf("read succeeded! nasty security hole [%s]\n",
buf);
return False;
}
- cli_close(cli1->tree, fnum1);
- cli_unlink(cli1->tree, fname);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_unlink(cli1->tree, fname);
cli2->tree->tid = oldtid;
*/
static BOOL run_unlinktest(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *fname = "\\unlink.tst";
int fnum;
BOOL correct = True;
printf("starting unlink test\n");
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
cli->session->pid = 1;
printf("Opening a file\n");
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
printf("Unlinking a open file\n");
- if (NT_STATUS_IS_OK(cli_unlink(cli->tree, fname))) {
+ if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) {
printf("error: server allowed unlink on an open file\n");
correct = False;
} else {
NT_STATUS_SHARING_VIOLATION);
}
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
if (!torture_close_connection(cli)) {
correct = False;
/*
test the timing of deferred open requests
*/
-static BOOL run_deferopen(struct cli_state *cli, int dummy)
+static BOOL run_deferopen(struct smbcli_state *cli, int dummy)
{
const char *fname = "\\defer_open_test.dat";
int retries=4;
do {
struct timeval tv_start, tv_end;
GetTimeOfDay(&tv_start);
- fnum = cli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE,
NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum != -1) {
break;
}
GetTimeOfDay(&tv_end);
- if (NT_STATUS_EQUAL(cli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
+ if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
/* Sharing violation errors need to be 1 second apart. */
int64_t tdif = usec_time_diff(&tv_end, &tv_start);
if (tdif < 500000 || tdif > 1500000) {
tdif % (int64_t)1000000);
}
}
- } while (NT_STATUS_EQUAL(cli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
+ } while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
if (fnum == -1) {
- fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli->tree));
+ fprintf(stderr,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree));
return False;
}
sleep(10);
i++;
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
- fprintf(stderr,"Failed to close %s, error=%s\n", fname, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
+ fprintf(stderr,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree));
return False;
}
sleep(2);
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, fname))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
/* All until the last unlink will fail with sharing violation. */
- if (!NT_STATUS_EQUAL(cli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
- printf("unlink of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ if (!NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
+ printf("unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
correct = False;
}
}
/*
test how many open files this server supports on the one socket
*/
-static BOOL run_maxfidtest(struct cli_state *cli, int dummy)
+static BOOL run_maxfidtest(struct smbcli_state *cli, int dummy)
{
const char *template = "\\maxfid.%d.%d";
char *fname;
for (i=0; i<0x11000; i++) {
asprintf(&fname, template, i,(int)getpid());
- if ((fnums[i] = cli_open(cli->tree, fname,
+ if ((fnums[i] = smbcli_open(cli->tree, fname,
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) ==
-1) {
printf("open of %s failed (%s)\n",
- fname, cli_errstr(cli->tree));
+ fname, smbcli_errstr(cli->tree));
printf("maximum fnum is %d\n", i);
break;
}
printf("cleaning up\n");
for (;i>=0;i--) {
asprintf(&fname, template, i,(int)getpid());
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnums[i]))) {
- printf("Close of fnum %d failed - %s\n", fnums[i], cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnums[i]))) {
+ printf("Close of fnum %d failed - %s\n", fnums[i], smbcli_errstr(cli->tree));
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, fname))) {
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
printf("unlink of %s failed (%s)\n",
- fname, cli_errstr(cli->tree));
+ fname, smbcli_errstr(cli->tree));
correct = False;
}
free(fname);
static BOOL run_negprot_nowait(int dummy)
{
int i;
- struct cli_state *cli, *cli2;
+ struct smbcli_state *cli, *cli2;
BOOL correct = True;
printf("starting negprot nowait test\n");
printf("Filling send buffer\n");
for (i=0;i<10000;i++) {
- struct cli_request *req;
+ struct smbcli_request *req;
time_t t1 = time(NULL);
req = smb_negprot_send(cli->transport, PROTOCOL_NT1);
- while (req->state == CLI_REQUEST_SEND && time(NULL) < t1+5) {
- cli_transport_process(cli->transport);
+ while (req->state == SMBCLI_REQUEST_SEND && time(NULL) < t1+5) {
+ smbcli_transport_process(cli->transport);
}
- if (req->state == CLI_REQUEST_ERROR) {
+ if (req->state == SMBCLI_REQUEST_ERROR) {
printf("Failed to fill pipe - %s\n", nt_errstr(req->status));
torture_close_connection(cli);
return correct;
}
- if (req->state == CLI_REQUEST_SEND) {
+ if (req->state == SMBCLI_REQUEST_SEND) {
break;
}
}
*/
static BOOL run_attrtest(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int fnum;
time_t t, t2;
const char *fname = "\\attrib123456789.tst";
return False;
}
- cli_unlink(cli->tree, fname);
- fnum = cli_open(cli->tree, fname,
+ smbcli_unlink(cli->tree, fname);
+ fnum = smbcli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(cli_getatr(cli->tree, fname, NULL, NULL, &t))) {
- printf("getatr failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) {
+ printf("getatr failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
}
printf("Setting file time to %s", ctime(&t2));
- if (NT_STATUS_IS_ERR(cli_setatr(cli->tree, fname, 0, t2))) {
- printf("setatr failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_setatr(cli->tree, fname, 0, t2))) {
+ printf("setatr failed (%s)\n", smbcli_errstr(cli->tree));
correct = True;
}
- if (NT_STATUS_IS_ERR(cli_getatr(cli->tree, fname, NULL, NULL, &t))) {
- printf("getatr failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) {
+ printf("getatr failed (%s)\n", smbcli_errstr(cli->tree));
correct = True;
}
correct = True;
}
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
if (!torture_close_connection(cli)) {
correct = False;
*/
static BOOL run_trans2test(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int fnum;
size_t size;
time_t c_time, a_time, m_time, w_time, m_time2;
return False;
}
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
printf("Testing qfileinfo\n");
- fnum = cli_open(cli->tree, fname,
+ fnum = smbcli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- if (NT_STATUS_IS_ERR(cli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time,
+ if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time,
NULL, NULL))) {
- printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(cli->tree));
+ printf("ERROR: qfileinfo failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
}
printf("Testing NAME_INFO\n");
- if (NT_STATUS_IS_ERR(cli_qfilename(cli->tree, fnum, &pname))) {
- printf("ERROR: qfilename failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_qfilename(cli->tree, fnum, &pname))) {
+ printf("ERROR: qfilename failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
}
correct = False;
}
- cli_close(cli->tree, fnum);
- cli_unlink(cli->tree, fname);
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
- fnum = cli_open(cli->tree, fname,
+ fnum = smbcli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
printf("Checking for sticky create times\n");
- if (NT_STATUS_IS_ERR(cli_qpathinfo(cli->tree, fname, &c_time, &a_time, &m_time, &size, NULL))) {
- printf("ERROR: qpathinfo failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo(cli->tree, fname, &c_time, &a_time, &m_time, &size, NULL))) {
+ printf("ERROR: qpathinfo failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
} else {
if (c_time != m_time) {
}
- cli_unlink(cli->tree, fname);
- fnum = cli_open(cli->tree, fname,
+ smbcli_unlink(cli->tree, fname);
+ fnum = smbcli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- cli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(cli_qpathinfo2(cli->tree, fname, &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) {
- printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli->tree));
+ smbcli_close(cli->tree, fnum);
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, fname, &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) {
+ printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
} else {
if (w_time < 60*60*24*2) {
}
}
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
/* check if the server updates the directory modification time
when creating a new file */
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, dname))) {
- printf("ERROR: mkdir failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) {
+ printf("ERROR: mkdir failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
}
sleep(3);
- if (NT_STATUS_IS_ERR(cli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) {
- printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) {
+ printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
}
- fnum = cli_open(cli->tree, fname2,
+ fnum = smbcli_open(cli->tree, fname2,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- cli_write(cli->tree, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
- cli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(cli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL))) {
- printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli->tree));
+ smbcli_write(cli->tree, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
+ smbcli_close(cli->tree, fnum);
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL))) {
+ printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
} else {
if (m_time2 == m_time) {
correct = False;
}
}
- cli_unlink(cli->tree, fname2);
- cli_rmdir(cli->tree, dname);
+ smbcli_unlink(cli->tree, fname2);
+ smbcli_rmdir(cli->tree, dname);
if (!torture_close_connection(cli)) {
correct = False;
*/
static BOOL run_deletetest(int dummy)
{
- struct cli_state *cli1;
- struct cli_state *cli2 = NULL;
+ struct smbcli_state *cli1;
+ struct smbcli_state *cli2 = NULL;
const char *fname = "\\delete.file";
int fnum1 = -1;
int fnum2 = -1;
/* Test 1 - this should delete the file on close. */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF,
NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
if (fnum1 == -1) {
- printf("[1] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[1] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[1] close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[1] close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
if (fnum1 != -1) {
printf("[1] open of %s succeeded (should fail)\n", fname);
correct = False;
/* Test 2 - this should delete the file on close. */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE,
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[2] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[2] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
- printf("[2] setting delete_on_close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ printf("[2] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[2] close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[2] close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[2] open of %s succeeded should have been deleted on close !\n", fname);
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[2] close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[2] close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
} else
printf("second delete on close test succeeded.\n");
/* Test 3 - ... */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[3] open - 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[3] open - 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail with a sharing violation - open for delete is only compatible
with SHARE_DELETE. */
- fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE,
NTCREATEX_DISP_OPEN, 0, 0);
/* This should succeed. */
- fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[3] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[3] open - 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
- printf("[3] setting delete_on_close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ printf("[3] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[3] close 1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[3] close 1 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum2))) {
- printf("[3] close 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
+ printf("[3] close 2 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - file should no longer be there. */
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[3] open of %s succeeded should have been deleted on close !\n", fname);
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[3] close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[3] close failed (%s)\n", smbcli_errstr(cli1->tree));
}
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
correct = False;
goto fail;
} else
printf("third delete on close test succeeded.\n");
/* Test 4 ... */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA |
SA_RIGHT_FILE_WRITE_DATA |
STD_RIGHT_DELETE_ACCESS,
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[4] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[4] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should succeed. */
- fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ,
+ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE |
NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[4] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[4] open - 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum2))) {
- printf("[4] close - 1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
+ printf("[4] close - 1 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
- printf("[4] setting delete_on_close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ printf("[4] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - no more opens once delete on close set. */
- fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ,
+ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 != -1) {
} else
printf("fourth delete on close test succeeded.\n");
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[4] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[4] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* Test 5 ... */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[5] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - only allowed on NT opens with DELETE access. */
- if (NT_STATUS_IS_OK(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n");
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[5] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[5] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
printf("fifth delete on close test succeeded.\n");
/* Test 6 ... */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA | SA_RIGHT_FILE_WRITE_DATA,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[6] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[6] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - only allowed on NT opens with DELETE access. */
- if (NT_STATUS_IS_OK(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n");
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[6] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[6] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
printf("sixth delete on close test succeeded.\n");
/* Test 7 ... */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA |
SA_RIGHT_FILE_WRITE_DATA |
STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[7] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[7] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
printf("[7] setting delete_on_close on file failed !\n");
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_nt_delete_on_close(cli1->tree, fnum1, False))) {
+ if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) {
printf("[7] unsetting delete_on_close on file failed !\n");
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[7] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This next open should succeed - we reset the flag. */
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 == -1) {
- printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[5] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[7] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
printf("seventh delete on close test succeeded.\n");
/* Test 7 ... */
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
if (!torture_open_connection(&cli2)) {
printf("[8] failed to open second connection.\n");
goto fail;
}
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[8] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[8] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_nt_delete_on_close(cli1->tree, fnum1, True))) {
+ if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
printf("[8] setting delete_on_close on file failed !\n");
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[8] close - 1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[8] close - 1 failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("[8] close - 2 failed (%s)\n", cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("[8] close - 2 failed (%s)\n", smbcli_errstr(cli2->tree));
correct = False;
goto fail;
}
/* This should fail.. */
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[8] open of %s succeeded should have been deleted on close !\n", fname);
goto fail;
printf("eighth delete on close test succeeded.\n");
/* This should fail - we need to set DELETE_ACCESS. */
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0,SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
if (fnum1 != -1) {
printf("ninth delete on close test succeeded.\n");
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
if (fnum1 == -1) {
- printf("[10] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("[10] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should delete the file. */
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("[10] close failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("[10] close failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail.. */
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[10] open of %s succeeded should have been deleted on close !\n", fname);
goto fail;
* intialized, because these functions don't handle
* uninitialized connections. */
- cli_close(cli1->tree, fnum1);
- cli_close(cli1->tree, fnum2);
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
correct = False;
*/
static BOOL run_properties(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL correct = True;
printf("starting properties test\n");
*/
static BOOL run_xcopy(int dummy)
{
- struct cli_state *cli1;
+ struct smbcli_state *cli1;
const char *fname = "\\test.txt";
BOOL correct = True;
int fnum1, fnum2;
return False;
}
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF,
0x4044, 0);
if (fnum1 == -1) {
- printf("First open failed - %s\n", cli_errstr(cli1->tree));
+ printf("First open failed - %s\n", smbcli_errstr(cli1->tree));
return False;
}
- fnum2 = cli_nt_create_full(cli1->tree, fname, 0,
+ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0,
SECOND_DESIRED_ACCESS, 0,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN,
0x200000, 0);
if (fnum2 == -1) {
- printf("second open failed - %s\n", cli_errstr(cli1->tree));
+ printf("second open failed - %s\n", smbcli_errstr(cli1->tree));
return False;
}
*/
static BOOL run_rename(int dummy)
{
- struct cli_state *cli1;
+ struct smbcli_state *cli1;
const char *fname = "\\test.txt";
const char *fname1 = "\\test1.txt";
BOOL correct = True;
return False;
}
- cli_unlink(cli1->tree, fname);
- cli_unlink(cli1->tree, fname1);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ smbcli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname1);
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("First open failed - %s\n", cli_errstr(cli1->tree));
+ printf("First open failed - %s\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_rename(cli1->tree, fname, fname1))) {
- printf("First rename failed (this is correct) - %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
+ printf("First rename failed (this is correct) - %s\n", smbcli_errstr(cli1->tree));
} else {
printf("First rename succeeded - this should have failed !\n");
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close - 1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close - 1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1->tree, fname);
- cli_unlink(cli1->tree, fname1);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ smbcli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname1);
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE|NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("Second open failed - %s\n", cli_errstr(cli1->tree));
+ printf("Second open failed - %s\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_rename(cli1->tree, fname, fname1))) {
- printf("Second rename failed - this should have succeeded - %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
+ printf("Second rename failed - this should have succeeded - %s\n", smbcli_errstr(cli1->tree));
correct = False;
} else {
printf("Second rename succeeded\n");
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close - 2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1->tree, fname);
- cli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname1);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("Third open failed - %s\n", cli_errstr(cli1->tree));
+ printf("Third open failed - %s\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_rename(cli1->tree, fname, fname1))) {
- printf("Third rename failed - this should have succeeded - %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
+ printf("Third rename failed - this should have succeeded - %s\n", smbcli_errstr(cli1->tree));
correct = False;
} else {
printf("Third rename succeeded\n");
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close - 3 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close - 3 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1->tree, fname);
- cli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname1);
if (!torture_close_connection(cli1)) {
correct = False;
*/
static BOOL run_pipe_number(int dummy)
{
- struct cli_state *cli1;
+ struct smbcli_state *cli1;
const char *pipe_name = "\\WKSSVC";
int fnum;
int num_pipes = 0;
}
while(1) {
- fnum = cli_nt_create_full(cli1->tree, pipe_name, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ fnum = smbcli_nt_create_full(cli1->tree, pipe_name, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum == -1) {
- printf("Open of pipe %s failed with error (%s)\n", pipe_name, cli_errstr(cli1->tree));
+ printf("Open of pipe %s failed with error (%s)\n", pipe_name, smbcli_errstr(cli1->tree));
break;
}
num_pipes++;
static BOOL torture_holdcon(int dummy)
{
int i;
- struct cli_state **cli;
+ struct smbcli_state **cli;
int num_dead = 0;
printf("Opening %d connections\n", torture_numops);
- cli = malloc(sizeof(struct cli_state *) * torture_numops);
+ cli = malloc(sizeof(struct smbcli_state *) * torture_numops);
for (i=0;i<torture_numops;i++) {
if (!torture_open_connection(&cli[i])) {
for (i=0;i<torture_numops;i++) {
NTSTATUS status;
if (cli[i]) {
- status = cli_chkpath(cli[i]->tree, "\\");
+ status = smbcli_chkpath(cli[i]->tree, "\\");
if (!NT_STATUS_IS_OK(status)) {
printf("Connection %d is dead\n", i);
cli[i] = NULL;
static BOOL run_vuidtest(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
const char *fname = "\\vuid.tst";
int fnum;
size_t size;
return False;
}
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
- fnum = cli_open(cli->tree, fname,
+ fnum = smbcli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
orig_vuid = cli->session->vuid;
printf("Testing qfileinfo with wrong vuid\n");
- if (NT_STATUS_IS_OK(result = cli_qfileinfo(cli->tree, fnum, NULL,
+ if (NT_STATUS_IS_OK(result = smbcli_qfileinfo(cli->tree, fnum, NULL,
&size, &c_time, &a_time,
&m_time, NULL, NULL))) {
printf("ERROR: qfileinfo passed with wrong vuid\n");
(cli->transport->error.e.dos.ecode != ERRbaduid) ) {
printf("ERROR: qfileinfo should have returned DOS error "
"ERRSRV:ERRbaduid\n but returned %s\n",
- cli_errstr(cli->tree));
+ smbcli_errstr(cli->tree));
correct = False;
}
cli->session->vuid -= 1234;
- if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
- printf("close failed (%s)\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
+ printf("close failed (%s)\n", smbcli_errstr(cli->tree));
correct = False;
}
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
if (!torture_close_connection(cli)) {
correct = False;
*/
static BOOL run_opentest(int dummy)
{
- static struct cli_state *cli1;
- static struct cli_state *cli2;
+ static struct smbcli_state *cli1;
+ static struct smbcli_state *cli2;
const char *fname = "\\readonly.file";
int fnum1, fnum2;
char buf[20];
return False;
}
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_setatr(cli1->tree, fname, FILE_ATTRIBUTE_READONLY, 0))) {
- printf("cli_setatr failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_setatr(cli1->tree, fname, FILE_ATTRIBUTE_READONLY, 0))) {
+ printf("smbcli_setatr failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test1);
return False;
}
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test1);
return False;
}
/* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */
- fnum2 = cli_open(cli1->tree, fname, O_RDWR, DENY_ALL);
+ fnum2 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_ALL);
if (check_error(__LINE__, cli1, ERRDOS, ERRnoaccess,
NT_STATUS_ACCESS_DENIED)) {
printf("finished open test 1\n");
error_test1:
- cli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum1);
/* Now try not readonly and ensure ERRbadshare is returned. */
- cli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
/* This will fail - but the error should be ERRshare. */
- fnum2 = cli_open(cli1->tree, fname, O_RDWR, DENY_ALL);
+ fnum2 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_ALL);
if (check_error(__LINE__, cli1, ERRDOS, ERRbadshare,
NT_STATUS_SHARING_VIOLATION)) {
printf("correct error code ERRDOS/ERRbadshare returned\n");
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("finished open test 2\n");
/* Test truncate open disposition on file opened for read. */
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("(3) open (1) of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("(3) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
memset(buf, '\0', 20);
- if (cli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
- printf("write failed (%s)\n", cli_errstr(cli1->tree));
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
+ printf("write failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("(3) close1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("(3) close1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
/* Ensure size == 20. */
- if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
- printf("(3) getatr failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
+ printf("(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
return False;
}
/* Now test if we can truncate a file opened for readonly. */
- fnum1 = cli_open(cli1->tree, fname, O_RDONLY|O_TRUNC, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY|O_TRUNC, DENY_NONE);
if (fnum1 == -1) {
- printf("(3) open (2) of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("(3) open (2) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
/* Ensure size == 0. */
- if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
- printf("(3) getatr failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
+ printf("(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
return False;
}
}
printf("finished open test 3\n");
error_test3:
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("testing ctemp\n");
- fnum1 = cli_ctemp(cli1->tree, "\\", &tmp_path);
+ fnum1 = smbcli_ctemp(cli1->tree, "\\", &tmp_path);
if (fnum1 == -1) {
- printf("ctemp failed (%s)\n", cli_errstr(cli1->tree));
+ printf("ctemp failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test4);
return False;
}
printf("ctemp gave path %s\n", tmp_path);
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close of temp failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close of temp failed (%s)\n", smbcli_errstr(cli1->tree));
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli1->tree, tmp_path))) {
- printf("unlink of temp failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli1->tree, tmp_path))) {
+ printf("unlink of temp failed (%s)\n", smbcli_errstr(cli1->tree));
}
error_test4:
/* Test the non-io opens... */
return False;
}
- cli_setatr(cli2->tree, fname, 0, 0);
- cli_unlink(cli2->tree, fname);
+ smbcli_setatr(cli2->tree, fname, 0, 0);
+ smbcli_unlink(cli2->tree, fname);
printf("TEST #1 testing 2 non-io opens (no delete)\n");
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 1 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test10);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 1 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test10);
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
return False;
}
printf("non-io open test #1 passed.\n");
error_test10:
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("TEST #2 testing 2 non-io opens (first with delete)\n");
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 2 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test20);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 2 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test20);
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
printf("non-io open test #2 passed.\n");
error_test20:
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("TEST #3 testing 2 non-io opens (second with delete)\n");
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 3 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test30);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 3 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test30);
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 3 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("test 3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("test 3 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
return False;
}
printf("non-io open test #3 passed.\n");
error_test30:
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("TEST #4 testing 2 non-io opens (both with delete)\n");
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 4 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test40);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 != -1) {
- printf("test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test40);
return False;
}
- printf("test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2->tree), "sharing violation");
+ printf("test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation");
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 4 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
printf("non-io open test #4 passed.\n");
error_test40:
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
printf("TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n");
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 5 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test50);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 5 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test50);
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 5 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("test 5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("test 5 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
return False;
}
error_test50:
printf("TEST #6 testing 1 non-io open, one io open\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 6 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test60);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 6 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test60);
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 6 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli2->tree, fnum2))) {
- printf("test 6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
+ printf("test 6 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
return False;
}
error_test60:
printf("TEST #7 testing 1 non-io open, one io open with delete\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("test 7 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test70);
return False;
}
- fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 != -1) {
- printf("test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2->tree));
+ printf("test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test70);
return False;
}
- printf("test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2->tree), "sharing violation");
+ printf("test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation");
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("test 7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("test 7 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
printf("TEST #8 testing one normal open, followed by lock, followed by open with truncate\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- printf("(8) open (1) of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("(8) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
memset(buf, '\0', 20);
- if (cli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
- printf("(8) write failed (%s)\n", cli_errstr(cli1->tree));
+ if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
+ printf("(8) write failed (%s)\n", smbcli_errstr(cli1->tree));
correct = False;
}
/* Ensure size == 20. */
- if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
- printf("(8) getatr (1) failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
+ printf("(8) getatr (1) failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test80);
return False;
}
}
/* Get an exclusive lock on the open file. */
- if (NT_STATUS_IS_ERR(cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
- printf("(8) lock1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
+ printf("(8) lock1 failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test80);
return False;
}
- fnum2 = cli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
+ fnum2 = smbcli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
if (fnum1 == -1) {
- printf("(8) open (2) of %s with truncate failed (%s)\n", fname, cli_errstr(cli1->tree));
+ printf("(8) open (2) of %s with truncate failed (%s)\n", fname, smbcli_errstr(cli1->tree));
return False;
}
/* Ensure size == 0. */
- if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
- printf("(8) getatr (2) failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
+ printf("(8) getatr (2) failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test80);
return False;
}
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("(8) close1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum2))) {
- printf("(8) close1 failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
+ printf("(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
printf("open test #8 passed.\n");
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
correct = False;
static BOOL run_openattrtest(int dummy)
{
- struct cli_state *cli1;
+ struct smbcli_state *cli1;
const char *fname = "\\openattr.file";
int fnum1;
BOOL correct = True;
}
for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32_t); i++) {
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_WRITE_DATA, open_attrs_table[i],
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_WRITE_DATA, open_attrs_table[i],
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("open %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1->tree));
+ printf("open %d (1) of %s failed (%s)\n", i, fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close %d (1) of %s failed (%s)\n", i, fname, smbcli_errstr(cli1->tree));
return False;
}
for (j = 0; j < ARRAY_SIZE(open_attrs_table); j++) {
- fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA,
open_attrs_table[j],
NTCREATEX_SHARE_ACCESS_NONE,
printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(0x%x:%s)\n",
k, open_attrs_table[i],
open_attrs_table[j],
- fname, NT_STATUS_V(cli_nt_error(cli1->tree)), cli_errstr(cli1->tree));
+ fname, NT_STATUS_V(smbcli_nt_error(cli1->tree)), smbcli_errstr(cli1->tree));
correct = False;
CHECK_MAX_FAILURES(error_exit);
}
}
- if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
+ if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n",
k, open_attrs_table[i], open_attrs_table[j],
- cli_errstr(cli1->tree));
+ smbcli_errstr(cli1->tree));
correct = False;
CHECK_MAX_FAILURES(error_exit);
}
continue;
}
- if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
- printf("close %d (2) of %s failed (%s)\n", j, fname, cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+ printf("close %d (2) of %s failed (%s)\n", j, fname, smbcli_errstr(cli1->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, &attr, NULL, NULL))) {
- printf("getatr(2) failed (%s)\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, &attr, NULL, NULL))) {
+ printf("getatr(2) failed (%s)\n", smbcli_errstr(cli1->tree));
return False;
}
}
}
error_exit:
- cli_setatr(cli1->tree, fname, 0, 0);
- cli_unlink(cli1->tree, fname);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
printf("open attr test %s.\n", correct ? "passed" : "failed");
static BOOL run_dirtest(int dummy)
{
int i;
- struct cli_state *cli;
+ struct smbcli_state *cli;
int fnum;
double t1;
BOOL correct = True;
for (i=0;i<torture_numops;i++) {
char *fname;
asprintf(&fname, "\\%x", (int)random());
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
fprintf(stderr,"Failed to open %s\n", fname);
return False;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
free(fname);
}
t1 = end_timer();
- printf("Matched %d\n", cli_list(cli->tree, "a*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli->tree, "b*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli->tree, "xyzabc", 0, list_fn, NULL));
+ printf("Matched %d\n", smbcli_list(cli->tree, "a*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", smbcli_list(cli->tree, "b*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", smbcli_list(cli->tree, "xyzabc", 0, list_fn, NULL));
printf("dirtest core %g seconds\n", end_timer() - t1);
for (i=0;i<torture_numops;i++) {
char *fname;
asprintf(&fname, "\\%x", (int)random());
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
free(fname);
}
*/
BOOL torture_ioctl_test(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
uint16_t device, function;
int fnum;
const char *fname = "\\ioctl.dat";
printf("starting ioctl test\n");
- cli_unlink(cli->tree, fname);
+ smbcli_unlink(cli->tree, fname);
- fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
return False;
}
parms.ioctl.in.fnum = fnum;
parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO;
status = smb_raw_ioctl(cli->tree, mem_ctx, &parms);
- printf("ioctl job info: %s\n", cli_errstr(cli->tree));
+ printf("ioctl job info: %s\n", smbcli_errstr(cli->tree));
for (device=0;device<0x100;device++) {
printf("testing device=0x%x\n", device);
*/
BOOL torture_chkpath_test(int dummy)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int fnum;
BOOL ret;
printf("Testing valid and invalid paths\n");
/* cleanup from an old run */
- cli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
- cli_unlink(cli->tree, "\\chkpath.dir\\*");
- cli_rmdir(cli->tree, "\\chkpath.dir");
+ smbcli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
+ smbcli_unlink(cli->tree, "\\chkpath.dir\\*");
+ smbcli_rmdir(cli->tree, "\\chkpath.dir");
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\chkpath.dir"))) {
- printf("mkdir1 failed : %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir"))) {
+ printf("mkdir1 failed : %s\n", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\chkpath.dir\\dir2"))) {
- printf("mkdir2 failed : %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir\\dir2"))) {
+ printf("mkdir2 failed : %s\n", smbcli_errstr(cli->tree));
return False;
}
- fnum = cli_open(cli->tree, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = smbcli_open(cli->tree, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open1 failed (%s)\n", cli_errstr(cli->tree));
+ printf("open1 failed (%s)\n", smbcli_errstr(cli->tree));
return False;
}
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, "\\chkpath.dir"))) {
- printf("chkpath1 failed: %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir"))) {
+ printf("chkpath1 failed: %s\n", smbcli_errstr(cli->tree));
ret = False;
}
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, "\\chkpath.dir\\dir2"))) {
- printf("chkpath2 failed: %s\n", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dir2"))) {
+ printf("chkpath2 failed: %s\n", smbcli_errstr(cli->tree));
ret = False;
}
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, "\\chkpath.dir\\foo.txt"))) {
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\foo.txt"))) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadpath,
NT_STATUS_NOT_A_DIRECTORY);
} else {
ret = False;
}
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, "\\chkpath.dir\\bar.txt"))) {
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\bar.txt"))) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadfile,
NT_STATUS_OBJECT_NAME_NOT_FOUND);
} else {
ret = False;
}
- if (NT_STATUS_IS_ERR(cli_chkpath(cli->tree, "\\chkpath.dir\\dirxx\\bar.txt"))) {
+ if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dirxx\\bar.txt"))) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadpath,
NT_STATUS_OBJECT_PATH_NOT_FOUND);
} else {
ret = False;
}
- cli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
- cli_unlink(cli->tree, "\\chkpath.dir\\*");
- cli_rmdir(cli->tree, "\\chkpath.dir");
+ smbcli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
+ smbcli_unlink(cli->tree, "\\chkpath.dir\\*");
+ smbcli_rmdir(cli->tree, "\\chkpath.dir");
if (!torture_close_connection(cli)) {
return False;
static BOOL run_dirtest1(int dummy)
{
int i;
- struct cli_state *cli;
+ struct smbcli_state *cli;
int fnum, num_seen;
BOOL correct = True;
return False;
}
- if (cli_deltree(cli->tree, "\\LISTDIR") == -1) {
- fprintf(stderr,"Failed to deltree %s, error=%s\n", "\\LISTDIR", cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, "\\LISTDIR") == -1) {
+ fprintf(stderr,"Failed to deltree %s, error=%s\n", "\\LISTDIR", smbcli_errstr(cli->tree));
return False;
}
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\LISTDIR"))) {
- fprintf(stderr,"Failed to mkdir %s, error=%s\n", "\\LISTDIR", cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\LISTDIR"))) {
+ fprintf(stderr,"Failed to mkdir %s, error=%s\n", "\\LISTDIR", smbcli_errstr(cli->tree));
return False;
}
for (i=0;i<torture_entries;i++) {
char *fname;
asprintf(&fname, "\\LISTDIR\\f%d", i);
- fnum = cli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum == -1) {
- fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli->tree));
+ fprintf(stderr,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree));
return False;
}
free(fname);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
}
for (i=0;i<torture_entries;i++) {
char *fname;
asprintf(&fname, "\\LISTDIR\\d%d", i);
- if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, fname))) {
- fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) {
+ fprintf(stderr,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree));
return False;
}
free(fname);
}
/* Now ensure that doing an old list sees both files and directories. */
- num_seen = cli_list_old(cli->tree, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
+ num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
printf("num_seen = %d\n", num_seen );
/* We should see (torture_entries) each of files & directories + . and .. */
if (num_seen != (2*torture_entries)+2) {
/* Ensure if we have the "must have" bits we only see the
* relevant entries.
*/
- num_seen = cli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
+ num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
printf("num_seen = %d\n", num_seen );
if (num_seen != torture_entries+2) {
correct = False;
torture_entries+2, num_seen);
}
- num_seen = cli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
+ num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
printf("num_seen = %d\n", num_seen );
if (num_seen != torture_entries) {
correct = False;
}
/* Delete everything. */
- if (cli_deltree(cli->tree, "\\LISTDIR") == -1) {
- fprintf(stderr,"Failed to deltree %s, error=%s\n", "\\LISTDIR", cli_errstr(cli->tree));
+ if (smbcli_deltree(cli->tree, "\\LISTDIR") == -1) {
+ fprintf(stderr,"Failed to deltree %s, error=%s\n", "\\LISTDIR", smbcli_errstr(cli->tree));
return False;
}
#if 0
- printf("Matched %d\n", cli_list(cli->tree, "a*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli->tree, "b*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli->tree, "xyzabc", 0, list_fn, NULL));
+ printf("Matched %d\n", smbcli_list(cli->tree, "a*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", smbcli_list(cli->tree, "b*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", smbcli_list(cli->tree, "xyzabc", 0, list_fn, NULL));
#endif
if (!torture_close_connection(cli)) {
*/
static BOOL run_deny3test(int dummy)
{
- struct cli_state *cli1, *cli2;
+ struct smbcli_state *cli1, *cli2;
int fnum1, fnum2;
const char *fname;
fname = "\\deny_dos1.dat";
- cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- fnum2 = cli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- if (fnum1 != -1) cli_close(cli1->tree, fnum1);
- if (fnum2 != -1) cli_close(cli1->tree, fnum2);
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
+ fnum1 = smbcli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ fnum2 = smbcli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ if (fnum1 != -1) smbcli_close(cli1->tree, fnum1);
+ if (fnum2 != -1) smbcli_close(cli1->tree, fnum2);
+ smbcli_unlink(cli1->tree, fname);
printf("fnum1=%d fnum2=%d\n", fnum1, fnum2);
fname = "\\deny_dos2.dat";
- cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- fnum2 = cli_open(cli2->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- if (fnum1 != -1) cli_close(cli1->tree, fnum1);
- if (fnum2 != -1) cli_close(cli2->tree, fnum2);
- cli_unlink(cli1->tree, fname);
+ smbcli_unlink(cli1->tree, fname);
+ fnum1 = smbcli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ fnum2 = smbcli_open(cli2->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ if (fnum1 != -1) smbcli_close(cli1->tree, fnum1);
+ if (fnum2 != -1) smbcli_close(cli2->tree, fnum2);
+ smbcli_unlink(cli1->tree, fname);
printf("fnum1=%d fnum2=%d\n", fnum1, fnum2);
{
}
-double torture_create_procs(BOOL (*fn)(struct cli_state *, int), BOOL *result)
+double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result)
{
int i, status;
volatile pid_t *child_status;
/*
create a directory, returning a handle to it
*/
-int create_directory_handle(struct cli_tree *tree, const char *dname)
+int create_directory_handle(struct smbcli_tree *tree, const char *dname)
{
NTSTATUS status;
union smb_open io;
sometimes we need a fairly complex file to work with, so we can test
all possible attributes.
*/
-int create_complex_file(struct cli_state *cli, TALLOC_CTX *mem_ctx, const char *fname)
+int create_complex_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *fname)
{
int fnum;
char buf[7] = "abc";
time_t t = (time(NULL) & ~1);
NTSTATUS status;
- cli_unlink(cli->tree, fname);
- fnum = cli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ smbcli_unlink(cli->tree, fname);
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
0, 0);
if (fnum == -1) return -1;
- cli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
+ smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
/* setup some EAs */
setfile.generic.level = RAW_SFILEINFO_EA_SET;
/*
dump file infor by name
*/
-void torture_all_info(struct cli_tree *tree, const char *fname)
+void torture_all_info(struct smbcli_tree *tree, const char *fname)
{
TALLOC_CTX *mem_ctx = talloc_init(fname);
union smb_fileinfo finfo;
/*
set a attribute on a file
*/
-BOOL torture_set_file_attribute(struct cli_tree *tree, const char *fname, uint16_t attrib)
+BOOL torture_set_file_attribute(struct smbcli_tree *tree, const char *fname, uint16_t attrib)
{
union smb_setfileinfo sfinfo;
NTSTATUS status;
/*
set a file descriptor as sparse
*/
-NTSTATUS torture_set_sparse(struct cli_tree *tree, int fnum)
+NTSTATUS torture_set_sparse(struct smbcli_tree *tree, int fnum)
{
union smb_ioctl nt;
NTSTATUS status;
/****************************************************************************
connect to \\server\ipc$
****************************************************************************/
-NTSTATUS connect_to_ipc(struct cli_state **c, struct in_addr *server_ip,
+NTSTATUS connect_to_ipc(struct smbcli_state **c, struct in_addr *server_ip,
const char *server_name)
{
NTSTATUS nt_status;
}
}
- nt_status = cli_full_connection(c, opt_requester_name, server_name,
+ nt_status = smbcli_full_connection(c, opt_requester_name, server_name,
server_ip, opt_port,
"IPC$", "IPC",
opt_user_name, opt_workgroup,
/****************************************************************************
connect to \\server\ipc$ anonymously
****************************************************************************/
-NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
+NTSTATUS connect_to_ipc_anonymous(struct smbcli_state **c,
struct in_addr *server_ip, const char *server_name)
{
NTSTATUS nt_status;
- nt_status = cli_full_connection(c, opt_requester_name, server_name,
+ nt_status = smbcli_full_connection(c, opt_requester_name, server_name,
server_ip, opt_port,
"IPC$", "IPC",
"", "",
}
-struct cli_state *net_make_ipc_connection(uint_t flags)
+struct smbcli_state *net_make_ipc_connection(uint_t flags)
{
char *server_name = NULL;
struct in_addr server_ip;
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
NTSTATUS nt_status;
if (!net_find_server(flags, &server_ip, &server_name)) {
ADS_STRUCT *ads;
ADS_STATUS rc;
const char *servername;
- struct cli_state *cli;
+ struct smbcli_state *cli;
struct in_addr server_ip;
NTSTATUS nt_status;
TALLOC_CTX *mem_ctx = talloc_init("net_ads_printer_publish");
resolve_name(servername, &server_ip, 0x20);
- nt_status = cli_full_connection(&cli, lp_netbios_name(), servername,
+ nt_status = smbcli_full_connection(&cli, lp_netbios_name(), servername,
&server_ip, 0,
"IPC$", "IPC",
opt_user_name, opt_workgroup,
opt_password ? opt_password : "",
- CLI_FULL_CONNECTION_USE_KERBEROS,
+ SMBCLI_FULL_CONNECTION_USE_KERBEROS,
NULL);
- cli_nt_session_open(cli, PI_SPOOLSS);
+ smbcli_nt_session_open(cli, PI_SPOOLSS);
get_remote_printer_publishing_data(cli, mem_ctx, &mods, argv[0]);
rc = ads_add_printer_entry(ads, prt_dn, mem_ctx, &mods);
static int rap_file_close(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0) {
d_printf("\nMissing fileid of file to close\n\n");
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetFileClose(cli, atoi(argv[0]));
- cli_shutdown(cli);
+ ret = smbcli_NetFileClose(cli, atoi(argv[0]));
+ smbcli_shutdown(cli);
return ret;
}
static int rap_file_info(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0)
return net_rap_file_usage(argc, argv);
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetFileGetInfo(cli, atoi(argv[0]), one_file_fn);
- cli_shutdown(cli);
+ ret = smbcli_NetFileGetInfo(cli, atoi(argv[0]), one_file_fn);
+ smbcli_shutdown(cli);
return ret;
}
};
if (argc == 0) {
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
"\nEnumerating open files on remote server:\n\n"\
"\nFileId Opened by Perms Locks Path \n"\
"------ --------- ----- ----- ---- \n");
- ret = cli_NetFileEnum(cli, NULL, NULL, file_fn);
- cli_shutdown(cli);
+ ret = smbcli_NetFileEnum(cli, NULL, NULL, file_fn);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_share_delete(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0) {
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetShareDelete(cli, argv[0]);
- cli_shutdown(cli);
+ ret = smbcli_NetShareDelete(cli, argv[0]);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_share_add(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
RAP_SHARE_INFO_2 sinfo;
memset(sinfo.password, '\0', sizeof(sinfo.password));
sinfo.reserved2 = '\0';
- ret = cli_NetShareAdd(cli, &sinfo);
- cli_shutdown(cli);
+ ret = smbcli_NetShareAdd(cli, &sinfo);
+ smbcli_shutdown(cli);
return ret;
}
};
if (argc == 0) {
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
"\nEnumerating shared resources (exports) on remote server:\n\n"\
"\nShare name Type Description\n"\
"---------- ---- -----------\n");
- ret = cli_RNetShareEnum(cli, long_share_fn, NULL);
+ ret = smbcli_RNetShareEnum(cli, long_share_fn, NULL);
}
- ret = cli_RNetShareEnum(cli, share_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_RNetShareEnum(cli, share_fn, NULL);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_session_info(int argc, const char **argv)
{
const char *sessname;
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
sessname = argv[0];
- ret = cli_NetSessionGetInfo(cli, sessname, display_session_func);
+ ret = smbcli_NetSessionGetInfo(cli, sessname, display_session_func);
if (ret < 0) {
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return ret;
}
d_printf("Share name Type # Opens\n-------------------------"\
"-----------------------------------------------------\n");
- ret = cli_NetConnectionEnum(cli, sessname, display_conns_func);
- cli_shutdown(cli);
+ ret = smbcli_NetConnectionEnum(cli, sessname, display_conns_func);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_session_delete(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
if (argc == 0)
return net_rap_session_usage(argc, argv);
- ret = cli_NetSessionDel(cli, argv[0]);
- cli_shutdown(cli);
+ ret = smbcli_NetSessionDel(cli, argv[0]);
+ smbcli_shutdown(cli);
return ret;
}
};
if (argc == 0) {
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
"Client Type Opens Idle time\n"\
"------------------------------------------"\
"------------------------------------\n");
- ret = cli_NetSessionEnum(cli, list_sessions_func);
+ ret = smbcli_NetSessionEnum(cli, list_sessions_func);
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return ret;
}
int net_rap_server(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
"\tServer name Server description\n"\
"\t------------- ----------------------------\n");
- ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL,
+ ret = smbcli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL,
display_server_func,NULL);
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return ret;
}
int net_rap_domain(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
"\tDomain name Server name of Browse Master\n"\
"\t------------- ----------------------------\n");
- ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM,
+ ret = smbcli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM,
display_server_func,NULL);
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_printq_info(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0)
return -1;
d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
- ret = cli_NetPrintQGetInfo(cli, argv[0], enum_queue, enum_jobs);
- cli_shutdown(cli);
+ ret = smbcli_NetPrintQGetInfo(cli, argv[0], enum_queue, enum_jobs);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_printq_delete(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0)
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_printjob_del(cli, atoi(argv[0]));
- cli_shutdown(cli);
+ ret = smbcli_printjob_del(cli, atoi(argv[0]));
+ smbcli_shutdown(cli);
return ret;
}
int net_rap_printq(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
struct functable func[] = {
return -1;
d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
- ret = cli_NetPrintQEnum(cli, enum_queue, enum_jobs);
- cli_shutdown(cli);
+ ret = smbcli_NetPrintQEnum(cli, enum_queue, enum_jobs);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_user_delete(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0) {
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetUserDelete(cli, argv[0]);
- cli_shutdown(cli);
+ ret = smbcli_NetUserDelete(cli, argv[0]);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_user_add(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
RAP_USER_INFO_1 userinfo;
userinfo.home_dir = NULL;
userinfo.logon_script = NULL;
- ret = cli_NetUserAdd(cli, &userinfo);
+ ret = smbcli_NetUserAdd(cli, &userinfo);
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_user_info(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nUser name not specified\n");
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetUserGetGroups(cli, argv[0], group_member_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_NetUserGetGroups(cli, argv[0], group_member_fn, NULL);
+ smbcli_shutdown(cli);
return ret;
}
};
if (argc == 0) {
- struct cli_state *cli;
+ struct smbcli_state *cli;
if (!(cli = net_make_ipc_connection(0)))
goto done;
if (opt_long_list_entries) {
d_printf("\nUser name Comment"\
"\n-----------------------------\n");
- ret = cli_RNetUserEnum(cli, long_user_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_RNetUserEnum(cli, long_user_fn, NULL);
+ smbcli_shutdown(cli);
goto done;
}
- ret = cli_RNetUserEnum(cli, user_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_RNetUserEnum(cli, user_fn, NULL);
+ smbcli_shutdown(cli);
goto done;
}
static int rap_group_delete(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nGroup name not specified\n");
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetGroupDelete(cli, argv[0]);
- cli_shutdown(cli);
+ ret = smbcli_NetGroupDelete(cli, argv[0]);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_group_add(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
RAP_GROUP_INFO_1 grinfo;
grinfo.reserved1 = '\0';
grinfo.comment = smb_xstrdup(opt_comment);
- ret = cli_NetGroupAdd(cli, &grinfo);
- cli_shutdown(cli);
+ ret = smbcli_NetGroupAdd(cli, &grinfo);
+ smbcli_shutdown(cli);
return ret;
}
};
if (argc == 0) {
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
return -1;
if (opt_long_list_entries) {
d_printf("Group name Comment\n");
d_printf("-----------------------------\n");
- ret = cli_RNetGroupEnum(cli, long_group_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_RNetGroupEnum(cli, long_group_fn, NULL);
+ smbcli_shutdown(cli);
return ret;
}
- ret = cli_RNetGroupEnum(cli, group_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_RNetGroupEnum(cli, group_fn, NULL);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_groupmember_add(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc != 2) {
d_printf("\n\nGroup or user name not specified\n");
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetGroupAddUser(cli, argv[0], argv[1]);
- cli_shutdown(cli);
+ ret = smbcli_NetGroupAddUser(cli, argv[0], argv[1]);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_groupmember_delete(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc != 2) {
d_printf("\n\nGroup or user name not specified\n");
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetGroupDelUser(cli, argv[0], argv[1]);
- cli_shutdown(cli);
+ ret = smbcli_NetGroupDelUser(cli, argv[0], argv[1]);
+ smbcli_shutdown(cli);
return ret;
}
static int rap_groupmember_list(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nGroup name not specified\n");
if (!(cli = net_make_ipc_connection(0)))
return -1;
- ret = cli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL );
- cli_shutdown(cli);
+ ret = smbcli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL );
+ smbcli_shutdown(cli);
return ret;
}
};
if (argc == 0) {
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (!(cli = net_make_ipc_connection(0)))
return -1;
if (opt_long_list_entries) {
d_printf("Service name Comment\n");
d_printf("-----------------------------\n");
- ret = cli_RNetServiceEnum(cli, long_group_fn, NULL);
+ ret = smbcli_RNetServiceEnum(cli, long_group_fn, NULL);
}
- ret = cli_RNetServiceEnum(cli, group_fn, NULL);
- cli_shutdown(cli);
+ ret = smbcli_RNetServiceEnum(cli, group_fn, NULL);
+ smbcli_shutdown(cli);
return ret;
}
int net_rap_password(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
int ret;
if (argc < 3)
return -1;
/* BB Add check for password lengths? */
- ret = cli_oem_change_password(cli, argv[0], argv[2], argv[1]);
- cli_shutdown(cli);
+ ret = smbcli_oem_change_password(cli, argv[0], argv[2], argv[1]);
+ smbcli_shutdown(cli);
return ret;
}
/* A function of this type is passed to the 'run_rpc_command' wrapper */
-typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *, struct cli_state *, TALLOC_CTX *, int, const char **);
+typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *, struct smbcli_state *, TALLOC_CTX *, int, const char **);
/**
* Many of the RPC functions need the domain sid. This function gets
* it at the start of every run
*
- * @param cli A cli_state already connected to the remote machine
+ * @param cli A smbcli_state already connected to the remote machine
*
* @return The Domain SID of the remote machine.
**/
-static DOM_SID *net_get_remote_domain_sid(struct cli_state *cli)
+static DOM_SID *net_get_remote_domain_sid(struct smbcli_state *cli)
{
DOM_SID *domain_sid;
POLICY_HND pol;
}
- if (!cli_nt_session_open (cli, PI_LSARPC)) {
+ if (!smbcli_nt_session_open (cli, PI_LSARPC)) {
fprintf(stderr, "could not initialise lsa pipe\n");
goto error;
}
- result = cli_lsa_open_policy(cli, mem_ctx, True,
+ result = smbcli_lsa_open_policy(cli, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol);
if (!NT_STATUS_IS_OK(result)) {
goto error;
}
- result = cli_lsa_query_info_policy(cli, mem_ctx, &pol, info_class,
+ result = smbcli_lsa_query_info_policy(cli, mem_ctx, &pol, info_class,
domain_name, domain_sid);
if (!NT_STATUS_IS_OK(result)) {
goto error;
}
- cli_lsa_close(cli, mem_ctx, &pol);
- cli_nt_session_close(cli);
+ smbcli_lsa_close(cli, mem_ctx, &pol);
+ smbcli_nt_session_close(cli);
talloc_destroy(mem_ctx);
return domain_sid;
* @return A shell status integer (0 for success)
*/
-static int run_rpc_command(struct cli_state *cli_arg, const int pipe_idx, int conn_flags,
+static int run_rpc_command(struct smbcli_state *smbcli_arg, const int pipe_idx, int conn_flags,
rpc_command_fn fn,
int argc, const char **argv)
{
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
TALLOC_CTX *mem_ctx;
NTSTATUS nt_status;
DOM_SID *domain_sid;
- /* make use of cli_state handed over as an argument, if possible */
- if (!cli_arg)
+ /* make use of smbcli_state handed over as an argument, if possible */
+ if (!smbcli_arg)
cli = net_make_ipc_connection(conn_flags);
else
- cli = cli_arg;
+ cli = smbcli_arg;
if (!cli) {
return -1;
if (!(mem_ctx = talloc_init("run_rpc_command"))) {
DEBUG(0, ("talloc_init() failed\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return -1;
}
- if (!cli_nt_session_open(cli, pipe_idx)) {
+ if (!smbcli_nt_session_open(cli, pipe_idx)) {
DEBUG(0, ("Could not initialise pipe\n"));
}
if (cli->nt_pipe_fnum)
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
/* close the connection only if it was opened here */
- if (!cli_arg)
- cli_shutdown(cli);
+ if (!smbcli_arg)
+ smbcli_shutdown(cli);
talloc_destroy(mem_ctx);
* argc, argv which are passes through.
*
* @param domain_sid The domain sid aquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_changetrustpw_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_changetrustpw_internals(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv) {
return trust_pw_find_change_and_store_it(cli, mem_ctx, opt_target_workgroup);
* argc, argv which are passes through.
*
* @param domain_sid The domain sid aquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_join_oldstyle_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_join_oldstyle_internals(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv) {
fstring trust_passwd;
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_info_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_info_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
sid_to_string(sid_str, domain_sid);
/* Get sam policy handle */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
}
ZERO_STRUCT(ctr);
- result = cli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
2, &ctr);
if (NT_STATUS_IS_OK(result)) {
TALLOC_CTX *ctx = talloc_init("rpc_info_internals");
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_getsid_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_getsid_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
fstring sid_str;
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv) {
POLICY_HND connect_pol, domain_pol, user_pol;
/* Get sam policy handle */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
/* Get domain policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
acb_info = ACB_NORMAL;
unknown = 0xe005000b; /* No idea what this is - a permission mask? */
- result = cli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
acct_name, acb_info, unknown,
&user_pol, &user_rid);
if (!NT_STATUS_IS_OK(result)) {
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid,
- struct cli_state *cli,
+ struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
}
/* Get sam policy and domain handles */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
uint32_t *user_rids, num_rids, *name_types;
uint32_t flags = 0x000003e8; /* Unknown */
- result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_lookup_names(cli, mem_ctx, &domain_pol,
flags, 1, &argv[0],
&num_rids, &user_rids,
&name_types);
goto done;
}
- result = cli_samr_open_user(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_open_user(cli, mem_ctx, &domain_pol,
MAXIMUM_ALLOWED_ACCESS,
user_rids[0], &user_pol);
/* Delete user */
- result = cli_samr_delete_dom_user(cli, mem_ctx, &user_pol);
+ result = smbcli_samr_delete_dom_user(cli, mem_ctx, &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_user_info_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_user_info_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, user_pol;
}
/* Get sam policy handle */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Get domain policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Get handle on user */
- result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_lookup_names(cli, mem_ctx, &domain_pol,
flags, 1, &argv[0],
&num_rids, &rids, &name_types);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = cli_samr_open_user(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_open_user(cli, mem_ctx, &domain_pol,
MAXIMUM_ALLOWED_ACCESS,
rids[0], &user_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = cli_samr_query_usergroups(cli, mem_ctx, &user_pol,
+ result = smbcli_samr_query_usergroups(cli, mem_ctx, &user_pol,
&num_rids, &user_gids);
/* Look up rids */
for (i = 0; i < num_rids; i++)
rids[i] = user_gids[i].g_rid;
- result = cli_samr_lookup_rids(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_lookup_rids(cli, mem_ctx, &domain_pol,
flags, num_rids, rids,
&num_names, &names, &name_types);
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_user_list_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_user_list_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
/* Get sam policy handle */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
/* Get domain policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
get_query_dispinfo_params(
loop_count, &max_entries, &max_size);
- result = cli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
&start_idx, 1, &num_entries,
max_entries, max_size, &ctr);
loop_count++;
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_group_list_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_group_list_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
/* Get sam policy handle */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
/* Get domain policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
d_printf("\nGroup name Comment"\
"\n-----------------------------\n");
do {
- result = cli_samr_enum_dom_groups(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_enum_dom_groups(cli, mem_ctx, &domain_pol,
&start_idx, max_entries,
&groups, &num_entries);
} while (!NT_STATUS_IS_OK(result));
/* query domain aliases */
do {
- result = cli_samr_enum_als_groups(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_enum_als_groups(cli, mem_ctx, &domain_pol,
&start_idx, max_entries,
&groups, &num_entries);
printf("%-21.21s\n", groups[i].acct_name);
}
} while (!NT_STATUS_IS_OK(result));
- cli_samr_close(cli, mem_ctx, &domain_pol);
+ smbcli_samr_close(cli, mem_ctx, &domain_pol);
/* Get builtin policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
&global_sid_Builtin, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
}
/* query builtin aliases */
do {
- result = cli_samr_enum_als_groups(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_enum_als_groups(cli, mem_ctx, &domain_pol,
&start_idx, max_entries,
&groups, &num_entries);
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
static NTSTATUS
-rpc_share_add_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_share_add_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,int argc, const char **argv)
{
WERROR result;
return NT_STATUS_UNSUCCESSFUL;
*path++ = '\0';
- result = cli_srvsvc_net_share_add(cli, mem_ctx, sharename, type,
+ result = smbcli_srvsvc_net_share_add(cli, mem_ctx, sharename, type,
opt_comment, perms, opt_maxusers,
num_users, path, password);
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
static NTSTATUS
-rpc_share_del_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_share_del_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,int argc, const char **argv)
{
WERROR result;
- result = cli_srvsvc_net_share_del(cli, mem_ctx, argv[0]);
+ result = smbcli_srvsvc_net_share_del(cli, mem_ctx, argv[0]);
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_share_list_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_share_list_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
SRV_SHARE_INFO_CTR ctr;
init_enum_hnd(&hnd, 0);
- result = cli_srvsvc_net_share_enum(
+ result = smbcli_srvsvc_net_share_enum(
cli, mem_ctx, 1, &ctr, preferred_len, &hnd);
if (!W_ERROR_IS_OK(result))
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
static NTSTATUS
-rpc_file_close_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_file_close_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
WERROR result;
- result = cli_srvsvc_net_file_close(cli, mem_ctx, atoi(argv[0]));
+ result = smbcli_srvsvc_net_file_close(cli, mem_ctx, atoi(argv[0]));
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
* argc, argv which are passes through.
*
* @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
**/
static NTSTATUS
-rpc_file_list_internals(const DOM_SID *domain_sid, struct cli_state *cli,
+rpc_file_list_internals(const DOM_SID *domain_sid, struct smbcli_state *cli,
TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
SRV_FILE_INFO_CTR ctr;
if (argc > 0)
username = smb_xstrdup(argv[0]);
- result = cli_srvsvc_net_file_enum(
+ result = smbcli_srvsvc_net_file_enum(
cli, mem_ctx, 3, username, &ctr, preferred_len, &hnd);
if (!W_ERROR_IS_OK(result))
* argc, argv which are passed through.
*
* @param domain_sid The domain sid aquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- result = cli_reg_abort_shutdown(cli, mem_ctx);
+ result = smbcli_reg_abort_shutdown(cli, mem_ctx);
if (NT_STATUS_IS_OK(result))
DEBUG(5,("cmd_reg_abort_shutdown: query succeeded\n"));
* argc, argv which are passes through.
*
* @param domain_sid The domain sid aquired from the remote server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_shutdown_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_shutdown_internals(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
}
/* create an entry */
- result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, opt_reboot, opt_force);
+ result = smbcli_reg_shutdown(cli, mem_ctx, msg, timeout, opt_reboot, opt_force);
if (NT_STATUS_IS_OK(result))
DEBUG(5,("Shutdown of remote machine succeeded\n"));
* function.
*
* @param domain_sid The domain sid acquired from the server
- * @param cli A cli_state connected to the server.
+ * @param cli A smbcli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
* @return normal NTSTATUS return code
*/
-static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv) {
POLICY_HND connect_pol, domain_pol, user_pol;
strupper(acct_name);
/* Get samr policy handle */
- result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = smbcli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
- result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ result = smbcli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
unknown = 0xe005000b; /* No idea what this is - a permission mask?
mimir: yes, most probably it is */
- result = cli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
acct_name, acb_info, unknown,
&user_pol, &user_rid);
if (!NT_STATUS_IS_OK(result)) {
static int rpc_trustdom_establish(int argc, const char **argv)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
struct in_addr server_ip;
POLICY_HND connect_hnd;
TALLOC_CTX *mem_ctx;
* Use NetServerEnum2 to make sure we're talking to a proper server
*/
- if (!cli_get_pdc_name(cli, domain_name, (char*)pdc_name)) {
+ if (!smbcli_get_pdc_name(cli, domain_name, (char*)pdc_name)) {
DEBUG(0, ("NetServerEnum2 error: Couldn't find primary domain controller\
for domain %s\n", domain_name));
}
* note: It is now used only to get unicode domain name
*/
- if (!cli_nt_session_open(cli, PI_WKSSVC)) {
+ if (!smbcli_nt_session_open(cli, PI_WKSSVC)) {
DEBUG(0, ("Couldn't not initialise wkssvc pipe\n"));
return -1;
}
if (!(mem_ctx = talloc_init("establishing trust relationship to domain %s",
domain_name))) {
DEBUG(0, ("talloc_init() failed\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return -1;
}
- nt_status = cli_wks_query_info(cli, mem_ctx, &wks_info);
+ nt_status = smbcli_wks_query_info(cli, mem_ctx, &wks_info);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("WksQueryInfo call failed.\n"));
}
if (cli->nt_pipe_fnum)
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
/*
if (!(mem_ctx = talloc_init("rpc_trustdom_establish"))) {
DEBUG(0, ("talloc_init() failed\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return -1;
}
- if (!cli_nt_session_open(cli, PI_LSARPC)) {
+ if (!smbcli_nt_session_open(cli, PI_LSARPC)) {
DEBUG(0, ("Could not initialise lsa pipe\n"));
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return -1;
}
- nt_status = cli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_QUERY_VALUE,
+ nt_status = smbcli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
/* Querying info level 5 */
- nt_status = cli_lsa_query_info_policy(cli, mem_ctx, &connect_hnd,
+ nt_status = smbcli_lsa_query_info_policy(cli, mem_ctx, &connect_hnd,
5 /* info level */, domain_name,
&domain_sid);
if (NT_STATUS_IS_ERR(nt_status)) {
* Close the pipes and clean up
*/
- nt_status = cli_lsa_close(cli, mem_ctx, &connect_hnd);
+ nt_status = smbcli_lsa_close(cli, mem_ctx, &connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't close LSA pipe. Error was %s\n",
nt_errstr(nt_status)));
}
if (cli->nt_pipe_fnum)
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
talloc_destroy(mem_ctx);
}
-static NTSTATUS rpc_query_domain_sid(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_query_domain_sid(const DOM_SID *domain_sid, struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
fstring str_sid;
{
/* common variables */
TALLOC_CTX* mem_ctx;
- struct cli_state *cli, *remote_cli;
+ struct smbcli_state *cli, *remote_cli;
NTSTATUS nt_status;
const char *domain_name = NULL;
DOM_SID queried_dom_sid;
return -1;
};
- if (!cli_nt_session_open(cli, PI_LSARPC)) {
+ if (!smbcli_nt_session_open(cli, PI_LSARPC)) {
DEBUG(0, ("Could not initialise lsa pipe\n"));
return -1;
};
- nt_status = cli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_QUERY_VALUE,
+ nt_status = smbcli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
};
/* query info level 5 to obtain sid of a domain being queried */
- nt_status = cli_lsa_query_info_policy(cli, mem_ctx, &connect_hnd,
+ nt_status = smbcli_lsa_query_info_policy(cli, mem_ctx, &connect_hnd,
5 /* info level */, domain_name, &queried_dom_sid);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
d_printf("Trusted domains list:\n\n");
do {
- nt_status = cli_lsa_enum_trust_dom(cli, mem_ctx, &connect_hnd, &enum_ctx,
+ nt_status = smbcli_lsa_enum_trust_dom(cli, mem_ctx, &connect_hnd, &enum_ctx,
&num_domains,
&trusted_dom_names, &domain_sids);
} while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
/* close this connection before doing next one */
- nt_status = cli_lsa_close(cli, mem_ctx, &connect_hnd);
+ nt_status = smbcli_lsa_close(cli, mem_ctx, &connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n",
nt_errstr(nt_status)));
return -1;
};
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
/*
* Listing trusting domains (stored in passdb backend, if local)
/*
* Open \PIPE\samr and get needed policy handles
*/
- if (!cli_nt_session_open(cli, PI_SAMR)) {
+ if (!smbcli_nt_session_open(cli, PI_SAMR)) {
DEBUG(0, ("Could not initialise samr pipe\n"));
return -1;
};
/* SamrConnect */
- nt_status = cli_samr_connect(cli, mem_ctx, SA_RIGHT_SAM_OPEN_DOMAIN,
+ nt_status = smbcli_samr_connect(cli, mem_ctx, SA_RIGHT_SAM_OPEN_DOMAIN,
&connect_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
/* SamrOpenDomain - we have to open domain policy handle in order to be
able to enumerate accounts*/
- nt_status = cli_samr_open_domain(cli, mem_ctx, &connect_hnd,
+ nt_status = smbcli_samr_open_domain(cli, mem_ctx, &connect_hnd,
SA_RIGHT_DOMAIN_ENUM_ACCOUNTS,
&queried_dom_sid, &domain_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
enum_ctx = 0; /* reset enumeration context from last enumeration */
do {
- nt_status = cli_samr_enum_dom_users(cli, mem_ctx, &domain_hnd,
+ nt_status = smbcli_samr_enum_dom_users(cli, mem_ctx, &domain_hnd,
&enum_ctx, ACB_DOMTRUST, 0xffff,
&trusting_dom_names, &trusting_dom_rids,
&num_domains);
if (run_rpc_command(remote_cli, PI_LSARPC, 0, rpc_query_domain_sid, argc, argv))
d_printf("couldn't get domain's sid\n");
- cli_shutdown(remote_cli);
+ smbcli_shutdown(remote_cli);
} else {
d_printf("domain controller is not responding\n");
} while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
/* close opened samr and domain policy handles */
- nt_status = cli_samr_close(cli, mem_ctx, &domain_hnd);
+ nt_status = smbcli_samr_close(cli, mem_ctx, &domain_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't properly close domain policy handle for domain %s\n", domain_name));
};
- nt_status = cli_samr_close(cli, mem_ctx, &connect_hnd);
+ nt_status = smbcli_samr_close(cli, mem_ctx, &connect_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't properly close samr policy handle for domain %s\n", domain_name));
};
/* close samr pipe and connection to IPC$ */
- cli_nt_session_close(cli);
- cli_shutdown(cli);
+ smbcli_nt_session_close(cli);
+ smbcli_shutdown(cli);
talloc_destroy(mem_ctx);
return 0;
*/
BOOL net_rpc_check(uint_t flags)
{
- struct cli_state cli;
+ struct smbcli_state cli;
BOOL ret = False;
struct in_addr server_ip;
char *server_name = NULL;
return False;
ZERO_STRUCT(cli);
- if (cli_initialise(&cli) == False)
+ if (smbcli_initialise(&cli) == False)
return False;
- if (!cli_connect(&cli, server_name, &server_ip))
+ if (!smbcli_connect(&cli, server_name, &server_ip))
goto done;
if (!attempt_netbios_session_request(&cli, lp_netbios_name(),
server_name, &server_ip))
goto done;
- if (!cli_negprot(&cli))
+ if (!smbcli_negprot(&cli))
goto done;
if (cli.protocol < PROTOCOL_NT1)
goto done;
ret = True;
done:
- cli_shutdown(&cli);
+ smbcli_shutdown(&cli);
return ret;
}
**/
int net_rpc_join_ok(const char *domain)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
uint8_t stored_md4_trust_password[16];
int retval = 1;
uint32_t channel;
return 1;
}
- if (!cli_nt_session_open(cli, PI_NETLOGON)) {
+ if (!smbcli_nt_session_open(cli, PI_NETLOGON)) {
DEBUG(0,("Error connecting to NETLOGON pipe\n"));
goto done;
}
channel = SEC_CHAN_WKSTA;
}
- CHECK_RPC_ERR(cli_nt_setup_creds(cli,
+ CHECK_RPC_ERR(smbcli_nt_setup_creds(cli,
channel,
stored_md4_trust_password, &neg_flags, 2),
"error in domain join verification");
done:
/* Close down pipe - this will clean up open policy handles */
if (cli->nt_pipe_fnum)
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
return retval;
}
/* libsmb variables */
- struct cli_state *cli;
+ struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
uint32_t acb_info;
/* Fetch domain sid */
- if (!cli_nt_session_open(cli, PI_LSARPC)) {
+ if (!smbcli_nt_session_open(cli, PI_LSARPC)) {
DEBUG(0, ("Error connecting to SAM pipe\n"));
goto done;
}
- CHECK_RPC_ERR(cli_lsa_open_policy(cli, mem_ctx, True,
+ CHECK_RPC_ERR(smbcli_lsa_open_policy(cli, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&lsa_pol),
"error opening lsa policy handle");
- CHECK_RPC_ERR(cli_lsa_query_info_policy(cli, mem_ctx, &lsa_pol,
+ CHECK_RPC_ERR(smbcli_lsa_query_info_policy(cli, mem_ctx, &lsa_pol,
5, domain, &domain_sid),
"error querying info policy");
- cli_lsa_close(cli, mem_ctx, &lsa_pol);
+ smbcli_lsa_close(cli, mem_ctx, &lsa_pol);
- cli_nt_session_close(cli); /* Done with this pipe */
+ smbcli_nt_session_close(cli); /* Done with this pipe */
/* Create domain user */
- if (!cli_nt_session_open(cli, PI_SAMR)) {
+ if (!smbcli_nt_session_open(cli, PI_SAMR)) {
DEBUG(0, ("Error connecting to SAM pipe\n"));
goto done;
}
- CHECK_RPC_ERR(cli_samr_connect(cli, mem_ctx,
+ CHECK_RPC_ERR(smbcli_samr_connect(cli, mem_ctx,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&sam_pol),
"could not connect to SAM database");
- CHECK_RPC_ERR(cli_samr_open_domain(cli, mem_ctx, &sam_pol,
+ CHECK_RPC_ERR(smbcli_samr_open_domain(cli, mem_ctx, &sam_pol,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&domain_sid, &domain_pol),
"could not open domain");
acb_info = ((lp_server_role() == ROLE_DOMAIN_BDC) || lp_server_role() == ROLE_DOMAIN_PDC) ? ACB_SVRTRUST : ACB_WSTRUST;
- result = cli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
+ result = smbcli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
acct_name, acb_info,
0xe005000b, &user_pol,
&user_rid);
/* We *must* do this.... don't ask... */
if (NT_STATUS_IS_OK(result))
- cli_samr_close(cli, mem_ctx, &user_pol);
+ smbcli_samr_close(cli, mem_ctx, &user_pol);
- CHECK_RPC_ERR_DEBUG(cli_samr_lookup_names(cli, mem_ctx,
+ CHECK_RPC_ERR_DEBUG(smbcli_samr_lookup_names(cli, mem_ctx,
&domain_pol, flags,
1, &const_acct_name,
&num_rids,
/* Open handle on user */
CHECK_RPC_ERR_DEBUG(
- cli_samr_open_user(cli, mem_ctx, &domain_pol,
+ smbcli_samr_open_user(cli, mem_ctx, &domain_pol,
SEC_RIGHTS_MAXIMUM_ALLOWED,
user_rid, &user_pol),
("could not re-open existing user %s: %s\n",
ctr.switch_value = 24;
ctr.info.id24 = &p24;
- CHECK_RPC_ERR(cli_samr_set_userinfo(cli, mem_ctx, &user_pol, 24,
+ CHECK_RPC_ERR(smbcli_samr_set_userinfo(cli, mem_ctx, &user_pol, 24,
cli->user_session_key, &ctr),
"error setting trust account password");
/* Ignoring the return value is necessary for joining a domain
as a normal user with "Add workstation to domain" privilege. */
- result = cli_samr_set_userinfo2(cli, mem_ctx, &user_pol, 0x10,
+ result = smbcli_samr_set_userinfo2(cli, mem_ctx, &user_pol, 0x10,
sess_key, &ctr);
/* Now store the secret in the secrets database */
}
/* Now check the whole process from top-to-bottom */
- cli_samr_close(cli, mem_ctx, &user_pol);
- cli_nt_session_close(cli); /* Done with this pipe */
+ smbcli_samr_close(cli, mem_ctx, &user_pol);
+ smbcli_nt_session_close(cli); /* Done with this pipe */
retval = net_rpc_join_ok(domain);
/* Close down pipe - this will clean up open policy handles */
if (cli->nt_pipe_fnum)
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
/* Display success or failure */
printf("Joined domain %s.\n",domain);
}
- cli_shutdown(cli);
+ smbcli_shutdown(cli);
SAFE_FREE(clear_trust_password);
}
-static void dump_database(struct cli_state *cli, uint_t db_type, DOM_CRED *ret_creds)
+static void dump_database(struct smbcli_state *cli, uint_t db_type, DOM_CRED *ret_creds)
{
uint_t sync_context = 0;
NTSTATUS result;
d_printf("Dumping database %u\n", db_type);
do {
- result = cli_netlogon_sam_sync(cli, mem_ctx, ret_creds, db_type,
+ result = smbcli_netlogon_sam_sync(cli, mem_ctx, ret_creds, db_type,
sync_context,
&num_deltas, &hdr_deltas, &deltas);
clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), ret_creds);
int rpc_samdump(int argc, const char **argv)
{
NTSTATUS result;
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
uint8_t trust_password[16];
DOM_CRED ret_creds;
uint32_t neg_flags = 0x000001ff;
return 1;
}
- if (!cli_nt_session_open(cli, PI_NETLOGON)) {
+ if (!smbcli_nt_session_open(cli, PI_NETLOGON)) {
DEBUG(0,("Error connecting to NETLOGON pipe\n"));
goto fail;
}
goto fail;
}
- result = cli_nt_setup_creds(cli, SEC_CHAN_BDC, trust_password, &neg_flags, 2);
+ result = smbcli_nt_setup_creds(cli, SEC_CHAN_BDC, trust_password, &neg_flags, 2);
if (!NT_STATUS_IS_OK(result)) {
d_printf("Failed to setup BDC creds\n");
goto fail;
dump_database(cli, SAM_DATABASE_BUILTIN, &ret_creds);
dump_database(cli, SAM_DATABASE_PRIVS, &ret_creds);
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
return 0;
fail:
if (cli) {
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
}
return -1;
}
}
static void
-fetch_database(struct cli_state *cli, uint_t db_type, DOM_CRED *ret_creds,
+fetch_database(struct smbcli_state *cli, uint_t db_type, DOM_CRED *ret_creds,
DOM_SID dom_sid)
{
uint_t sync_context = 0;
d_printf("Fetching database %u\n", db_type);
do {
- result = cli_netlogon_sam_sync(cli, mem_ctx, ret_creds,
+ result = smbcli_netlogon_sam_sync(cli, mem_ctx, ret_creds,
db_type, sync_context,
&num_deltas,
&hdr_deltas, &deltas);
int rpc_vampire(int argc, const char **argv)
{
NTSTATUS result;
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
uint8_t trust_password[16];
DOM_CRED ret_creds;
uint32_t neg_flags = 0x000001ff;
return 1;
}
- if (!cli_nt_session_open(cli, PI_NETLOGON)) {
+ if (!smbcli_nt_session_open(cli, PI_NETLOGON)) {
DEBUG(0,("Error connecting to NETLOGON pipe\n"));
goto fail;
}
goto fail;
}
- result = cli_nt_setup_creds(cli, SEC_CHAN_BDC, trust_password,
+ result = smbcli_nt_setup_creds(cli, SEC_CHAN_BDC, trust_password,
&neg_flags, 2);
if (!NT_STATUS_IS_OK(result)) {
d_printf("Failed to setup BDC creds\n");
/* Currently we crash on PRIVS somewhere in unmarshalling */
/* Dump_database(cli, SAM_DATABASE_PRIVS, &ret_creds); */
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
return 0;
fail:
if (cli) {
- cli_nt_session_close(cli);
+ smbcli_nt_session_close(cli);
}
return -1;
}
/*
return the time on a server. This does not require any authentication
*/
-static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone)
+static time_t smbcli_servertime(const char *host, struct in_addr *ip, int *zone)
{
struct nmb_name calling, called;
time_t ret = 0;
- struct cli_state *cli = NULL;
+ struct smbcli_state *cli = NULL;
- cli = cli_initialise(NULL);
+ cli = smbcli_initialise(NULL);
if (!cli) goto done;
- if (!cli_connect(cli, host, ip)) {
+ if (!smbcli_connect(cli, host, ip)) {
fprintf(stderr,"Can't contact server\n");
goto done;
}
make_nmb_name(&called, "*SMBSERVER", 0x20);
}
- if (!cli_session_request(cli, &calling, &called)) {
+ if (!smbcli_session_request(cli, &calling, &called)) {
fprintf(stderr,"Session request failed\n");
goto done;
}
- if (!cli_negprot(cli)) {
+ if (!smbcli_negprot(cli)) {
fprintf(stderr,"Protocol negotiation failed\n");
goto done;
}
if (zone) *zone = cli->serverzone;
done:
- if (cli) cli_shutdown(cli);
+ if (cli) smbcli_shutdown(cli);
return ret;
}
/* find the servers time on the opt_host host */
static time_t nettime(int *zone)
{
- return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone);
+ return smbcli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone);
}
/* return a time as a string ready to be passed to /bin/date */
}
/* default - print the time */
- t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, NULL);
+ t = smbcli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, NULL);
if (t == 0) return -1;
d_printf("%s", ctime(&t));