summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c121
-rw-r--r--source3/client/client_proto.h2
-rw-r--r--source3/client/clitar.c114
-rw-r--r--source3/client/dnsbrowse.c2
-rw-r--r--source3/client/smbspool.c18
5 files changed, 101 insertions, 156 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index a12f8a2965..b485df7741 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -32,6 +32,7 @@
#include "../libcli/smbreadline/smbreadline.h"
#include "../libcli/security/security.h"
#include "system/select.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "trans2.h"
#include "libsmb/nmblib.h"
@@ -48,7 +49,6 @@ extern char tar_type;
static int port = 0;
static char *service;
static char *desthost;
-static char *calling_name;
static bool grepable = false;
static char *cmdstr = NULL;
const char *cmd_ptr = NULL;
@@ -505,7 +505,7 @@ static bool do_this_one(struct file_info *finfo)
return false;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
return true;
}
@@ -520,7 +520,7 @@ static bool do_this_one(struct file_info *finfo)
return false;
}
- if ((archive_level==1 || archive_level==2) && !(finfo->mode & aARCH)) {
+ if ((archive_level==1 || archive_level==2) && !(finfo->mode & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(3,("archive %s failed\n", finfo->name));
return false;
}
@@ -547,7 +547,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
if (!showacls) {
d_printf(" %-30s%7.7s %8.0f %s",
finfo->name,
- attrib_string(finfo->mode),
+ attrib_string(talloc_tos(), finfo->mode),
(double)finfo->size,
time_to_asc(t));
dir_total += finfo->size;
@@ -569,7 +569,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
}
/* print file meta date header */
d_printf( "FILENAME:%s\n", finfo->name);
- d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+ d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->mode));
d_printf( "SIZE:%.0f\n", (double)finfo->size);
d_printf( "MTIME:%s", time_to_asc(t));
status = cli_ntcreate(cli_state, afname, 0,
@@ -702,7 +702,7 @@ static void add_to_do_list_queue(const char *entry)
}
}
if (do_list_queue) {
- safe_strcpy_base(do_list_queue + do_list_queue_end,
+ strlcpy_base(do_list_queue + do_list_queue_end,
entry, do_list_queue, do_list_queue_size);
do_list_queue_end = new_end;
DEBUG(4,("added %s to do_list_queue (start=%d, end=%d)\n",
@@ -752,7 +752,7 @@ static NTSTATUS do_list_helper(const char *mntpoint, struct file_info *f,
*dir_end = '\0';
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (do_list_dirs && do_this_one(f)) {
status = do_list_fn(cli_state, f, dir);
if (!NT_STATUS_IS_OK(status)) {
@@ -924,7 +924,7 @@ NTSTATUS do_list(const char *mask,
static int cmd_dir(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mask = NULL;
char *buf = NULL;
int rc = 1;
@@ -974,7 +974,7 @@ static int cmd_dir(void)
static int cmd_du(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mask = NULL;
char *buf = NULL;
NTSTATUS status;
@@ -1147,8 +1147,8 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
close(handle);
}
- if (archive_level >= 2 && (attr & aARCH)) {
- cli_setatr(cli, rname, attr & ~(uint16)aARCH, 0);
+ if (archive_level >= 2 && (attr & FILE_ATTRIBUTE_ARCHIVE)) {
+ cli_setatr(cli, rname, attr & ~(uint16)FILE_ATTRIBUTE_ARCHIVE, 0);
}
{
@@ -1233,7 +1233,7 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_UNSUCCESSFUL;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (asprintf(&quest,
"Get directory %s? ",finfo->name) < 0) {
return NT_STATUS_NO_MEMORY;
@@ -1251,7 +1251,7 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
}
SAFE_FREE(quest);
- if (!(finfo->mode & aDIR)) {
+ if (!(finfo->mode & FILE_ATTRIBUTE_DIRECTORY)) {
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
@@ -1306,7 +1306,7 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_NO_MEMORY;
}
- status = do_list(mget_mask, aSYSTEM | aHIDDEN | aDIR,do_mget,false, true);
+ status = do_list(mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,false, true);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -1395,13 +1395,13 @@ static int cmd_more(void)
static int cmd_mget(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mget_mask = NULL;
char *buf = NULL;
NTSTATUS status = NT_STATUS_OK;
if (recurse) {
- attribute |= aDIR;
+ attribute |= FILE_ATTRIBUTE_DIRECTORY;
}
abort_mget = false;
@@ -1605,7 +1605,7 @@ static int cmd_altname(void)
static char *attr_str(TALLOC_CTX *mem_ctx, uint16_t mode)
{
- char *attrs = TALLOC_ZERO_ARRAY(mem_ctx, char, 17);
+ char *attrs = talloc_zero_array(mem_ctx, char, 17);
int i = 0;
if (!(mode & FILE_ATTRIBUTE_NORMAL)) {
@@ -2306,12 +2306,12 @@ static NTSTATUS do_del(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_NO_MEMORY;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
TALLOC_FREE(mask);
return NT_STATUS_OK;
}
- status = cli_unlink(cli_state, mask, aSYSTEM | aHIDDEN);
+ status = cli_unlink(cli_state, mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!NT_STATUS_IS_OK(status)) {
d_printf("%s deleting remote file %s\n",
nt_errstr(status), mask);
@@ -2330,10 +2330,10 @@ static int cmd_del(void)
char *mask = NULL;
char *buf = NULL;
NTSTATUS status = NT_STATUS_OK;
- uint16 attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
if (recurse) {
- attribute |= aDIR;
+ attribute |= FILE_ATTRIBUTE_DIRECTORY;
}
mask = talloc_strdup(ctx, client_get_cur_dir());
@@ -3875,11 +3875,12 @@ static int cmd_lcd(void)
buf, strerror(errno));
}
}
- d = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+ d = sys_getwd();
if (!d) {
return 1;
}
- DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
+ DEBUG(2,("the local directory is now %s\n",d));
+ SAFE_FREE(d);
return 0;
}
@@ -4516,7 +4517,7 @@ static NTSTATUS completion_remote_filter(const char *mnt,
return NT_STATUS_OK;
}
- if ((info->dirmask[0] == 0) && !(f->mode & aDIR))
+ if ((info->dirmask[0] == 0) && !(f->mode & FILE_ATTRIBUTE_DIRECTORY))
info->matches[info->count] = SMB_STRDUP(f->name);
else {
TALLOC_CTX *ctx = talloc_stackframe();
@@ -4532,7 +4533,7 @@ static NTSTATUS completion_remote_filter(const char *mnt,
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
tmp = talloc_asprintf_append(tmp, "%s",
CLI_DIRSEP_STR);
}
@@ -4546,7 +4547,7 @@ static NTSTATUS completion_remote_filter(const char *mnt,
if (info->matches[info->count] == NULL) {
return NT_STATUS_OK;
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
smb_readline_ca_char(0);
}
if (info->count == 1) {
@@ -4629,7 +4630,7 @@ static char **remote_completion(const char *text, int len)
if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
goto cleanup;
}
- status = cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
+ status = cli_list(targetcli, targetpath, FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
completion_remote_filter, (void *)&info);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
@@ -5036,46 +5037,16 @@ static int do_tar_op(const char *base_directory)
static int do_message_op(struct user_auth_info *a_info)
{
- struct sockaddr_storage ss;
- struct nmb_name called, calling;
- fstring server_name;
- char name_type_hex[10];
- int msg_port;
NTSTATUS status;
- make_nmb_name(&calling, calling_name, 0x0);
- make_nmb_name(&called , desthost, name_type);
-
- fstrcpy(server_name, desthost);
- snprintf(name_type_hex, sizeof(name_type_hex), "#%X", name_type);
- fstrcat(server_name, name_type_hex);
-
- zero_sockaddr(&ss);
- if (have_ip)
- ss = dest_ss;
-
- /* we can only do messages over port 139 (to windows clients at least) */
-
- msg_port = port ? port : 139;
-
- if (!(cli=cli_initialise())) {
- d_printf("Connection to %s failed\n", desthost);
- return 1;
- }
- cli_set_port(cli, msg_port);
-
- status = cli_connect(cli, server_name, &ss);
+ status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
+ port ? port : 139, name_type,
+ lp_netbios_name(), Undefined, &cli);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
return 1;
}
- if (!cli_session_request(cli, &calling, &called)) {
- d_printf("session request failed\n");
- cli_shutdown(cli);
- return 1;
- }
-
send_message(get_cmdline_auth_info_username(a_info));
cli_shutdown(cli);
@@ -5096,7 +5067,6 @@ static int do_message_op(struct user_auth_info *a_info)
poptContext pc;
char *p;
int rc = 0;
- fstring new_workgroup;
bool tar_opt = false;
bool service_opt = false;
struct poptOption long_options[] = {
@@ -5126,12 +5096,6 @@ static int do_message_op(struct user_auth_info *a_info)
exit(ENOMEM);
}
- /* initialize the workgroup name so we can determine whether or
- not it was set by a command line option */
-
- set_global_myworkgroup( "" );
- set_global_myname( "" );
-
/* set default debug level to 1 regardless of what smb.conf sets */
setup_logging( "smbclient", DEBUG_DEFAULT_STDERR );
load_case_tables();
@@ -5277,18 +5241,6 @@ static int do_message_op(struct user_auth_info *a_info)
poptGetArg(pc));
}
- /* save the workgroup...
-
- FIXME!! do we need to do this for other options as well
- (or maybe a generic way to keep lp_load() from overwriting
- everything)? */
-
- fstrcpy( new_workgroup, lp_workgroup() );
- calling_name = talloc_strdup(frame, global_myname() );
- if (!calling_name) {
- exit(ENOMEM);
- }
-
if ( override_logfile )
setup_logging( lp_logfile(), DEBUG_FILE );
@@ -5322,17 +5274,6 @@ static int do_message_op(struct user_auth_info *a_info)
}
}
- if ( strlen(new_workgroup) != 0 ) {
- set_global_myworkgroup( new_workgroup );
- }
-
- if ( strlen(calling_name) != 0 ) {
- set_global_myname( calling_name );
- } else {
- TALLOC_FREE(calling_name);
- calling_name = talloc_strdup(frame, global_myname() );
- }
-
smb_encrypt = get_cmdline_auth_info_smb_encrypt(auth_info);
if (!init_names()) {
fprintf(stderr, "init_names() failed\n");
diff --git a/source3/client/client_proto.h b/source3/client/client_proto.h
index fa3ca40d6b..d119014abd 100644
--- a/source3/client/client_proto.h
+++ b/source3/client/client_proto.h
@@ -23,6 +23,8 @@
#ifndef _CLIENT_PROTO_H_
#define _CLIENT_PROTO_H_
+struct cli_state;
+struct file_info;
/* The following definitions come from client/client.c */
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index b46115becf..4dc202e17e 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -38,6 +38,7 @@
#include "system/filesys.h"
#include "clitar.h"
#include "client/client_proto.h"
+#include "libsmb/libsmb.h"
static int clipfind(char **aret, int ret, char *tok);
@@ -70,7 +71,7 @@ extern struct cli_state *cli;
#define ATTRSET 1
#define ATTRRESET 0
-static uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+static uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
#ifndef CLIENT_TIMEOUT
#define CLIENT_TIMEOUT (30*1000)
@@ -101,7 +102,7 @@ char tar_type='\0';
static char **cliplist=NULL;
static int clipn=0;
static bool must_free_cliplist = False;
-extern const char *cmd_ptr;
+extern char *cmd_ptr;
extern bool lowercase;
extern uint16 cnum;
@@ -136,23 +137,6 @@ static void unfixtarname(char *tptr, char *fp, int l, bool first);
* tar specific utitlities
*/
-/*******************************************************************
-Create a string of size size+1 (for the null)
-*******************************************************************/
-
-static char *string_create_s(int size)
-{
- char *tmp;
-
- tmp = (char *)SMB_MALLOC(size+1);
-
- if (tmp == NULL) {
- DEBUG(0, ("Out of memory in string_create_s\n"));
- }
-
- return(tmp);
-}
-
/****************************************************************************
Write a tar header to buffer
****************************************************************************/
@@ -197,7 +181,7 @@ static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime
/* write out a "standard" tar format header */
hb.dbuf.name[NAMSIZ-1]='\0';
- safe_strcpy(hb.dbuf.mode, amode, sizeof(hb.dbuf.mode)-1);
+ strlcpy(hb.dbuf.mode, amode ? amode : "", sizeof(hb.dbuf.mode));
oct_it((uint64_t)0, 8, hb.dbuf.uid);
oct_it((uint64_t)0, 8, hb.dbuf.gid);
oct_it((uint64_t) size, 13, hb.dbuf.size);
@@ -263,12 +247,12 @@ static long readtarheader(union hblock *hb, file_info2 *finfo, const char *prefi
return -1;
}
- if ((finfo->name = string_create_s(strlen(prefix) + strlen(hb -> dbuf.name) + 3)) == NULL) {
+ if ((finfo->name = SMB_MALLOC(strlen(prefix) + strlen(hb -> dbuf.name) + 4)) == NULL) {
DEBUG(0, ("Out of space creating file_info2 for %s\n", hb -> dbuf.name));
return(-1);
}
- safe_strcpy(finfo->name, prefix, strlen(prefix) + strlen(hb -> dbuf.name) + 3);
+ strlcpy(finfo->name, prefix, strlen(prefix) + strlen(hb -> dbuf.name) + 4);
/* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */
unfixtarname(finfo->name + strlen(prefix), hb->dbuf.name,
@@ -294,7 +278,7 @@ of link other than a GNUtar Longlink - ignoring\n"));
if ((unoct(hb->dbuf.mode, sizeof(hb->dbuf.mode)) & S_IFDIR) ||
(*(finfo->name+strlen(finfo->name)-1) == '\\')) {
- finfo->mode=aDIR;
+ finfo->mode=FILE_ATTRIBUTE_DIRECTORY;
} else {
finfo->mode=0; /* we don't care about mode at the moment, we'll
* just make it a regular file */
@@ -521,14 +505,16 @@ static bool ensurepath(const char *fname)
/* ensures path exists */
char *partpath, *ffname;
+ size_t fnamelen = strlen(fname)+1;
const char *p=fname;
char *basehack;
char *saveptr;
+ NTSTATUS status;
DEBUG(5, ( "Ensurepath called with: %s\n", fname));
- partpath = string_create_s(strlen(fname));
- ffname = string_create_s(strlen(fname));
+ partpath = SMB_MALLOC(fnamelen);
+ ffname = SMB_MALLOC(fnamelen);
if ((partpath == NULL) || (ffname == NULL)){
DEBUG(0, ("Out of memory in ensurepath: %s\n", fname));
@@ -541,7 +527,7 @@ static bool ensurepath(const char *fname)
/* fname copied to ffname so can strtok_r */
- safe_strcpy(ffname, fname, strlen(fname));
+ strlcpy(ffname, fname, fnamelen);
/* do a `basename' on ffname, so don't try and make file name directory */
if ((basehack=strrchr_m(ffname, '\\')) == NULL) {
@@ -555,20 +541,22 @@ static bool ensurepath(const char *fname)
p=strtok_r(ffname, "\\", &saveptr);
while (p) {
- safe_strcat(partpath, p, strlen(fname) + 1);
+ strlcat(partpath, p, fnamelen);
- if (!NT_STATUS_IS_OK(cli_chkpath(cli, partpath))) {
- if (!NT_STATUS_IS_OK(cli_mkdir(cli, partpath))) {
+ status = cli_chkpath(cli, partpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ status = cli_mkdir(cli, partpath);
+ if (!NT_STATUS_IS_OK(status)) {
SAFE_FREE(partpath);
SAFE_FREE(ffname);
- DEBUG(0, ("Error mkdir %s\n", cli_errstr(cli)));
+ DEBUG(0, ("Error mkdir %s\n", nt_errstr(status)));
return False;
} else {
DEBUG(3, ("mkdirhiering %s\n", partpath));
}
}
- safe_strcat(partpath, "\\", strlen(fname) + 1);
+ strlcat(partpath, "\\", fnamelen);
p = strtok_r(NULL, "/\\", &saveptr);
}
@@ -596,6 +584,7 @@ static int padit(char *buf, uint64_t bufsize, uint64_t padsize)
static void do_setrattr(char *name, uint16 attr, int set)
{
uint16 oldattr;
+ NTSTATUS status;
if (!NT_STATUS_IS_OK(cli_getatr(cli, name, &oldattr, NULL, NULL))) {
return;
@@ -607,8 +596,9 @@ static void do_setrattr(char *name, uint16 attr, int set)
attr = oldattr & ~attr;
}
- if (!NT_STATUS_IS_OK(cli_setatr(cli, name, attr, 0))) {
- DEBUG(1,("setatr failed: %s\n", cli_errstr(cli)));
+ status = cli_setatr(cli, name, attr, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("setatr failed: %s\n", nt_errstr(status)));
}
}
@@ -671,28 +661,26 @@ static NTSTATUS do_atar(const char *rname_in, char *lname,
status = cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("%s opening remote file %s (%s)\n",
- cli_errstr(cli),rname, client_get_cur_dir()));
+ nt_errstr(status),rname, client_get_cur_dir()));
goto cleanup;
}
- finfo.name = string_create_s(strlen(rname));
+ finfo.name = smb_xstrdup(rname);
if (finfo.name == NULL) {
DEBUG(0, ("Unable to allocate space for finfo.name in do_atar\n"));
status = NT_STATUS_NO_MEMORY;
goto cleanup;
}
- safe_strcpy(finfo.name,rname, strlen(rname));
-
DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode));
- if (tar_inc && !(finfo.mode & aARCH)) {
+ if (tar_inc && !(finfo.mode & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name));
shallitime=0;
- } else if (!tar_system && (finfo.mode & aSYSTEM)) {
+ } else if (!tar_system && (finfo.mode & FILE_ATTRIBUTE_SYSTEM)) {
DEBUG(4, ("skipping %s - system bit is set\n", finfo.name));
shallitime=0;
- } else if (!tar_hidden && (finfo.mode & aHIDDEN)) {
+ } else if (!tar_hidden && (finfo.mode & FILE_ATTRIBUTE_HIDDEN)) {
DEBUG(4, ("skipping %s - hidden bit is set\n", finfo.name));
shallitime=0;
} else {
@@ -784,7 +772,7 @@ static NTSTATUS do_atar(const char *rname_in, char *lname,
/* if shallitime is true then we didn't skip */
if (tar_reset && !dry_run)
- (void) do_setrattr(finfo.name, aARCH, ATTRRESET);
+ (void) do_setrattr(finfo.name, FILE_ATTRIBUTE_ARCHIVE, ATTRRESET);
clock_gettime_mono(&tp_end);
this_time = (tp_end.tv_sec - tp_start.tv_sec)*1000 + (tp_end.tv_nsec - tp_start.tv_nsec)/1000000;
@@ -852,7 +840,7 @@ static NTSTATUS do_tar(struct cli_state *cli_state, struct file_info *finfo,
TALLOC_FREE(exclaim);
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
char *saved_curdir = NULL;
char *new_cd = NULL;
char *mtar_mask = NULL;
@@ -934,9 +922,12 @@ static void unfixtarname(char *tptr, char *fp, int l, bool first)
fp++;
l--;
}
+ if (l <= 0) {
+ return;
+ }
}
- safe_strcpy(tptr, fp, l);
+ strlcpy(tptr, fp, l);
string_replace(tptr, '/', '\\');
}
@@ -1045,8 +1036,12 @@ static int get_file(file_info2 finfo)
dsize = MIN(dsize, rsize); /* Should be only what is left */
DEBUG(5, ("writing %i bytes, bpos = %i ...\n", dsize, bpos));
- if (cli_write(cli, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) {
- DEBUG(0, ("Error writing remote file\n"));
+ status = cli_writeall(cli, fnum, 0,
+ (uint8_t *)(buffer_p + bpos), pos,
+ dsize, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Error writing remote file: %s\n",
+ nt_errstr(status)));
return 0;
}
@@ -1092,10 +1087,10 @@ static int get_file(file_info2 finfo)
}
/* Now close the file ... */
-
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Error %s closing remote file\n",
- cli_errstr(cli)));
+ nt_errstr(status)));
return(False);
}
@@ -1166,7 +1161,8 @@ static char *get_longfilename(file_info2 finfo)
return(NULL);
}
- unfixtarname(longname + offset, buffer_p, MIN(TBLOCK, finfo.size), first--);
+ unfixtarname(longname + offset, buffer_p,
+ namesize - offset, first--);
DEBUG(5, ("UnfixedName: %s, buffer: %s\n", longname, buffer_p));
offset += TBLOCK;
@@ -1301,7 +1297,7 @@ int cmd_block(void)
char *buf;
int block;
- if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ if (!next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
DEBUG(0, ("blocksize <n>\n"));
return 1;
}
@@ -1326,7 +1322,7 @@ int cmd_tarmode(void)
TALLOC_CTX *ctx = talloc_tos();
char *buf;
- while (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ while (next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
if (strequal(buf, "full"))
tar_inc=False;
else if (strequal(buf, "inc"))
@@ -1376,7 +1372,7 @@ int cmd_setmode(void)
attra[0] = attra[1] = 0;
- if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ if (!next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
return 1;
}
@@ -1389,7 +1385,7 @@ int cmd_setmode(void)
return 1;
}
- while (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ while (next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
q=buf;
while(*q) {
@@ -1401,16 +1397,16 @@ int cmd_setmode(void)
direct=0;
break;
case 'r':
- attra[direct]|=aRONLY;
+ attra[direct]|=FILE_ATTRIBUTE_READONLY;
break;
case 'h':
- attra[direct]|=aHIDDEN;
+ attra[direct]|=FILE_ATTRIBUTE_HIDDEN;
break;
case 's':
- attra[direct]|=aSYSTEM;
+ attra[direct]|=FILE_ATTRIBUTE_SYSTEM;
break;
case 'a':
- attra[direct]|=aARCH;
+ attra[direct]|=FILE_ATTRIBUTE_ARCHIVE;
break;
default:
DEBUG(0, ("setmode <filename> <perm=[+|-]rsha>\n"));
@@ -1491,7 +1487,7 @@ int cmd_tar(void)
int argcl = 0;
int ret;
- if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ if (!next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
DEBUG(0,("tar <c|x>[IXbgan] <filename>\n"));
return 1;
}
@@ -1717,7 +1713,7 @@ static int read_inclusion_file(char *filename)
}
}
- safe_strcpy(inclusion_buffer + inclusion_buffer_sofar, buf, inclusion_buffer_size - inclusion_buffer_sofar);
+ strlcpy(inclusion_buffer + inclusion_buffer_sofar, buf, inclusion_buffer_size - inclusion_buffer_sofar);
inclusion_buffer_sofar += strlen(buf) + 1;
clipn++;
}
diff --git a/source3/client/dnsbrowse.c b/source3/client/dnsbrowse.c
index c252b25343..03f87afe14 100644
--- a/source3/client/dnsbrowse.c
+++ b/source3/client/dnsbrowse.c
@@ -124,7 +124,7 @@ do_smb_browse_reply(DNSServiceRef sdRef, DNSServiceFlags flags,
return;
}
- bresult = TALLOC_ARRAY(talloc_tos(), struct mdns_smbsrv_result, 1);
+ bresult = talloc_array(talloc_tos(), struct mdns_smbsrv_result, 1);
if (bresult == NULL) {
return;
}
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 98c350d7dd..e16086dd67 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -25,6 +25,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "system/passwd.h"
+#include "libsmb/libsmb.h"
/*
* Starting with CUPS 1.3, Kerberos support is provided by cupsd including
@@ -595,14 +596,19 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
tbytes = 0;
while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
- if (cli_write(cli, fnum, 0, buffer, tbytes, nbytes) != nbytes) {
- int status = get_exit_code(cli, cli_nt_error(cli));
-
- fprintf(stderr, "ERROR: Error writing spool: %s\n", cli_errstr(cli));
- fprintf(stderr, "DEBUG: Returning status %d...\n", status);
+ NTSTATUS status;
+
+ status = cli_writeall(cli, fnum, 0, (uint8_t *)buffer,
+ tbytes, nbytes, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ int ret = get_exit_code(cli, status);
+ fprintf(stderr, "ERROR: Error writing spool: %s\n",
+ nt_errstr(status));
+ fprintf(stderr, "DEBUG: Returning status %d...\n",
+ ret);
cli_close(cli, fnum);
- return (status);
+ return (ret);
}
tbytes += nbytes;
}