mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r4013: got rid of a bunch of unused or unmaintained code
- removed the clitar code. It is unmaintained, and a horribly badly done hack - removed client.h as it contained mostly unused definitions - removed the unused clidfs.c code
This commit is contained in:
parent
44d9761962
commit
31a7bddbb3
@ -23,7 +23,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "dynconfig.h"
|
||||
#include "client.h"
|
||||
#include "clilist.h"
|
||||
#include "lib/cmdline/popt_common.h"
|
||||
#include "librpc/gen_ndr/ndr_srvsvc.h"
|
||||
#include "libcli/raw/libcliraw.h"
|
||||
@ -174,7 +174,7 @@ static int readfile(char *b, int n, XFILE *f)
|
||||
return x_fread(b,1,n,f);
|
||||
|
||||
i = 0;
|
||||
while (i < (n - 1) && (i < CLI_BUFFER_SIZE)) {
|
||||
while (i < (n - 1)) {
|
||||
if ((c = x_getc(f)) == EOF) {
|
||||
break;
|
||||
}
|
||||
@ -358,9 +358,9 @@ BOOL mask_match(struct smbcli_state *c, const char *string, char *pattern,
|
||||
/*******************************************************************
|
||||
decide if a file should be operated on
|
||||
********************************************************************/
|
||||
static BOOL do_this_one(struct file_info *finfo)
|
||||
static BOOL do_this_one(struct clilist_file_info *finfo)
|
||||
{
|
||||
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) return(True);
|
||||
if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY) return(True);
|
||||
|
||||
if (*fileselection &&
|
||||
!mask_match(cli, finfo->name,fileselection,False)) {
|
||||
@ -373,7 +373,7 @@ static BOOL do_this_one(struct file_info *finfo)
|
||||
return(False);
|
||||
}
|
||||
|
||||
if ((archive_level==1 || archive_level==2) && !(finfo->mode & FILE_ATTRIBUTE_ARCHIVE)) {
|
||||
if ((archive_level==1 || archive_level==2) && !(finfo->attrib & FILE_ATTRIBUTE_ARCHIVE)) {
|
||||
DEBUG(3,("archive %s failed\n", finfo->name));
|
||||
return(False);
|
||||
}
|
||||
@ -384,11 +384,11 @@ static BOOL do_this_one(struct file_info *finfo)
|
||||
/****************************************************************************
|
||||
display info about a file
|
||||
****************************************************************************/
|
||||
static void display_finfo(struct file_info *finfo)
|
||||
static void display_finfo(struct clilist_file_info *finfo)
|
||||
{
|
||||
if (do_this_one(finfo)) {
|
||||
time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
|
||||
char *astr = attrib_string(NULL, finfo->mode);
|
||||
char *astr = attrib_string(NULL, finfo->attrib);
|
||||
d_printf(" %-30s%7.7s %8.0f %s",
|
||||
finfo->name,
|
||||
astr,
|
||||
@ -403,7 +403,7 @@ static void display_finfo(struct file_info *finfo)
|
||||
/****************************************************************************
|
||||
accumulate size of a file
|
||||
****************************************************************************/
|
||||
static void do_du(struct file_info *finfo)
|
||||
static void do_du(struct clilist_file_info *finfo)
|
||||
{
|
||||
if (do_this_one(finfo)) {
|
||||
dir_total += finfo->size;
|
||||
@ -416,7 +416,7 @@ static char *do_list_queue = 0;
|
||||
static long do_list_queue_size = 0;
|
||||
static long do_list_queue_start = 0;
|
||||
static long do_list_queue_end = 0;
|
||||
static void (*do_list_fn)(struct file_info *);
|
||||
static void (*do_list_fn)(struct clilist_file_info *);
|
||||
|
||||
/****************************************************************************
|
||||
functions for do_list_queue
|
||||
@ -535,9 +535,9 @@ static int do_list_queue_empty(void)
|
||||
/****************************************************************************
|
||||
a helper for do_list
|
||||
****************************************************************************/
|
||||
static void do_list_helper(struct file_info *f, const char *mask, void *state)
|
||||
static void do_list_helper(struct clilist_file_info *f, const char *mask, void *state)
|
||||
{
|
||||
if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
if (f->attrib & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
if (do_list_dirs && do_this_one(f)) {
|
||||
do_list_fn(f);
|
||||
}
|
||||
@ -567,7 +567,8 @@ static void do_list_helper(struct file_info *f, const char *mask, void *state)
|
||||
/****************************************************************************
|
||||
a wrapper around smbcli_list that adds recursion
|
||||
****************************************************************************/
|
||||
void do_list(const char *mask,uint16_t attribute,void (*fn)(struct file_info *),BOOL rec, BOOL dirs)
|
||||
void do_list(const char *mask,uint16_t attribute,
|
||||
void (*fn)(struct clilist_file_info *),BOOL rec, BOOL dirs)
|
||||
{
|
||||
static int in_do_list = 0;
|
||||
|
||||
@ -882,7 +883,7 @@ static BOOL yesno(char *p)
|
||||
/****************************************************************************
|
||||
do a mget operation on one file
|
||||
****************************************************************************/
|
||||
static void do_mget(struct file_info *finfo)
|
||||
static void do_mget(struct clilist_file_info *finfo)
|
||||
{
|
||||
pstring rname;
|
||||
pstring quest;
|
||||
@ -897,7 +898,7 @@ static void do_mget(struct file_info *finfo)
|
||||
return;
|
||||
}
|
||||
|
||||
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY)
|
||||
if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
slprintf(quest,sizeof(pstring)-1,
|
||||
"Get directory %s? ",finfo->name);
|
||||
else
|
||||
@ -906,7 +907,7 @@ static void do_mget(struct file_info *finfo)
|
||||
|
||||
if (prompt && !yesno(quest)) return;
|
||||
|
||||
if (!(finfo->mode & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
if (!(finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
pstrcpy(rname,cur_dir);
|
||||
pstrcat(rname,finfo->name);
|
||||
do_get(rname, finfo->name, False);
|
||||
@ -2386,7 +2387,6 @@ static struct
|
||||
{"acl",cmd_acl,"<file> show file ACL",{COMPL_NONE,COMPL_NONE}},
|
||||
{"allinfo",cmd_allinfo,"<file> show all possible info about a file",{COMPL_NONE,COMPL_NONE}},
|
||||
{"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
|
||||
{"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
|
||||
{"cancel",cmd_cancel,"<jobid> cancel a print queue entry",{COMPL_NONE,COMPL_NONE}},
|
||||
{"cd",cmd_cd,"[directory] change/report the remote directory",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"chmod",cmd_chmod,"<src> <mode> chmod a file using UNIX permission",{COMPL_REMOTE,COMPL_REMOTE}},
|
||||
@ -2426,10 +2426,7 @@ static struct
|
||||
{"reput",cmd_reput,"<local name> [remote name] put a file restarting at end of remote file",{COMPL_LOCAL,COMPL_REMOTE}},
|
||||
{"rm",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"rmdir",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
|
||||
{"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"symlink",cmd_symlink,"<src> <dest> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
|
||||
{"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
|
||||
{"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
|
||||
{"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
|
||||
|
||||
/* Yes, this must be here, see crh's comment above. */
|
||||
@ -2550,12 +2547,12 @@ typedef struct {
|
||||
int len;
|
||||
} completion_remote_t;
|
||||
|
||||
static void completion_remote_filter(struct file_info *f, const char *mask, void *state)
|
||||
static void completion_remote_filter(struct clilist_file_info *f, const char *mask, void *state)
|
||||
{
|
||||
completion_remote_t *info = (completion_remote_t *)state;
|
||||
|
||||
if ((info->count < MAX_COMPLETIONS - 1) && (strncmp(info->text, f->name, info->len) == 0) && (strcmp(f->name, ".") != 0) && (strcmp(f->name, "..") != 0)) {
|
||||
if ((info->dirmask[0] == 0) && !(f->mode & FILE_ATTRIBUTE_DIRECTORY))
|
||||
if ((info->dirmask[0] == 0) && !(f->attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
info->matches[info->count] = strdup(f->name);
|
||||
else {
|
||||
pstring tmp;
|
||||
@ -2565,13 +2562,13 @@ static void completion_remote_filter(struct file_info *f, const char *mask, void
|
||||
else
|
||||
tmp[0] = 0;
|
||||
pstrcat(tmp, f->name);
|
||||
if (f->mode & FILE_ATTRIBUTE_DIRECTORY)
|
||||
if (f->attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
pstrcat(tmp, "/");
|
||||
info->matches[info->count] = strdup(tmp);
|
||||
}
|
||||
if (info->matches[info->count] == NULL)
|
||||
return;
|
||||
if (f->mode & FILE_ATTRIBUTE_DIRECTORY)
|
||||
if (f->attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
smb_readline_ca_char(0);
|
||||
|
||||
if (info->count == 1)
|
||||
@ -2911,31 +2908,6 @@ static int do_host_query(char *query_host)
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
handle a tar operation
|
||||
****************************************************************************/
|
||||
static int do_tar_op(char *base_directory)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* do we already have a connection? */
|
||||
if (!cli) {
|
||||
cli = do_connect(desthost, service);
|
||||
if (!cli)
|
||||
return 1;
|
||||
}
|
||||
|
||||
recurse=True;
|
||||
|
||||
if (*base_directory) do_cd(base_directory);
|
||||
|
||||
ret=process_tar();
|
||||
|
||||
smbcli_shutdown(cli);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
handle a message operation
|
||||
****************************************************************************/
|
||||
@ -2997,7 +2969,6 @@ static void remember_query_host(const char *arg,
|
||||
int opt;
|
||||
pstring query_host;
|
||||
BOOL message = False;
|
||||
extern char tar_type;
|
||||
pstring term_code;
|
||||
poptContext pc;
|
||||
char *p;
|
||||
@ -3011,7 +2982,6 @@ static void remember_query_host(const char *arg,
|
||||
{ "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" },
|
||||
{ "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" },
|
||||
{ "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" },
|
||||
{ "tar", 'T', POPT_ARG_STRING, NULL, 'T', "Command line tar", "<c|x>IXFqgbNan" },
|
||||
{ "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" },
|
||||
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
|
||||
{ "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" },
|
||||
@ -3074,12 +3044,6 @@ static void remember_query_host(const char *arg,
|
||||
case 't':
|
||||
pstrcpy(term_code, poptGetOptArg(pc));
|
||||
break;
|
||||
case 'T':
|
||||
if (!tar_parseargs(argc, argv, poptGetOptArg(pc), optind)) {
|
||||
poptPrintUsage(pc, stderr, 0);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
fstrcpy(base_directory,poptGetOptArg(pc));
|
||||
break;
|
||||
@ -3111,7 +3075,7 @@ static void remember_query_host(const char *arg,
|
||||
|
||||
/*init_names(); */
|
||||
|
||||
if (!tar_type && !*query_host && !*service && !message) {
|
||||
if (!*query_host && !*service && !message) {
|
||||
poptPrintUsage(pc, stderr, 0);
|
||||
exit(1);
|
||||
}
|
||||
@ -3125,11 +3089,6 @@ static void remember_query_host(const char *arg,
|
||||
DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
if (tar_type) {
|
||||
if (cmdstr)
|
||||
process_command_string(cmdstr);
|
||||
return do_tar_op(base_directory);
|
||||
}
|
||||
|
||||
if ((p=strchr_m(query_host,'#'))) {
|
||||
*p = 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,8 +4,7 @@
|
||||
# Start BINARY smbclient
|
||||
[BINARY::smbclient]
|
||||
OBJ_FILES = \
|
||||
client/client.o \
|
||||
client/clitar.o
|
||||
client/client.o
|
||||
REQUIRED_SUBSYSTEMS = \
|
||||
CONFIG \
|
||||
LIBCMDLINE \
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
||||
Copyright (C) Jeremy Allison 1998
|
||||
Copyright (C) James Myers 2003 <myersjj@samba.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _CLIENT_H
|
||||
#define _CLIENT_H
|
||||
|
||||
/* the client asks for a smaller buffer to save ram and also to get more
|
||||
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 SMBCLI_DFS_MAX_REFERRAL_LEVEL 3
|
||||
|
||||
#define SAFETY_MARGIN 1024
|
||||
#define LARGE_WRITEX_HDR_SIZE 65
|
||||
|
||||
|
||||
/*
|
||||
* These definitions depend on smb.h
|
||||
*/
|
||||
|
||||
struct file_info
|
||||
{
|
||||
uint64_t size;
|
||||
uint16_t mode;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
/* these times are normally kept in GMT */
|
||||
time_t mtime;
|
||||
time_t atime;
|
||||
time_t ctime;
|
||||
const char *name;
|
||||
char short_name[13*3]; /* the *3 is to cope with multi-byte */
|
||||
};
|
||||
|
||||
struct print_job_info
|
||||
{
|
||||
uint16_t id;
|
||||
uint16_t priority;
|
||||
size_t size;
|
||||
fstring user;
|
||||
fstring name;
|
||||
time_t t;
|
||||
};
|
||||
|
||||
typedef struct referral_info
|
||||
{
|
||||
int server_type;
|
||||
int referral_flags;
|
||||
int proximity;
|
||||
int ttl;
|
||||
int pathOffset;
|
||||
int altPathOffset;
|
||||
int nodeOffset;
|
||||
char *path;
|
||||
char *altPath;
|
||||
char *node;
|
||||
char *host;
|
||||
char *share;
|
||||
} referral_info;
|
||||
|
||||
typedef struct dfs_info
|
||||
{
|
||||
int path_consumed;
|
||||
int referral_flags;
|
||||
int selected_referral;
|
||||
int number_referrals;
|
||||
referral_info referrals[10];
|
||||
} dfs_info;
|
||||
|
||||
/* 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
|
||||
* state across multiple Dfs servers
|
||||
*/
|
||||
struct cli_client
|
||||
{
|
||||
const char* sockops;
|
||||
char* username;
|
||||
char* password;
|
||||
char* workgroup;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
int number_members;
|
||||
BOOL use_dfs; /* True if client should support Dfs */
|
||||
int connection_flags; /* see CLI_FULL_CONN.. below */
|
||||
uint16_t max_xmit_frag;
|
||||
uint16_t max_recv_frag;
|
||||
struct smbcli_state *cli[DFS_MAX_CLUSTER_SIZE];
|
||||
};
|
||||
|
||||
#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 */
|
28
source/include/clilist.h
Normal file
28
source/include/clilist.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
struct clilist_file_info {
|
||||
uint64_t size;
|
||||
uint16_t attrib;
|
||||
time_t mtime;
|
||||
const char *name;
|
||||
const char *short_name;
|
||||
};
|
||||
|
@ -108,7 +108,7 @@ union libnet_RemoteTOD;
|
||||
struct net_functable;
|
||||
struct net_context;
|
||||
|
||||
struct file_info;
|
||||
struct clilist_file_info;
|
||||
|
||||
struct xattr_DosEAs;
|
||||
struct xattr_DosStreams;
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "client.h"
|
||||
#include "clilist.h"
|
||||
|
||||
struct delete_state {
|
||||
struct smbcli_tree *tree;
|
||||
@ -30,7 +30,7 @@ struct delete_state {
|
||||
/*
|
||||
callback function for torture_deltree()
|
||||
*/
|
||||
static void delete_fn(struct file_info *finfo, const char *name, void *state)
|
||||
static void delete_fn(struct clilist_file_info *finfo, const char *name, void *state)
|
||||
{
|
||||
struct delete_state *dstate = state;
|
||||
char *s, *n;
|
||||
@ -41,14 +41,14 @@ static void delete_fn(struct file_info *finfo, const char *name, void *state)
|
||||
n[strlen(n)-1] = 0;
|
||||
asprintf(&s, "%s%s", n, finfo->name);
|
||||
|
||||
if (finfo->mode & FILE_ATTRIBUTE_READONLY) {
|
||||
if (finfo->attrib & FILE_ATTRIBUTE_READONLY) {
|
||||
if (NT_STATUS_IS_ERR(smbcli_setatr(dstate->tree, s, 0, 0))) {
|
||||
DEBUG(2,("Failed to remove READONLY on %s - %s\n",
|
||||
s, smbcli_errstr(dstate->tree)));
|
||||
}
|
||||
}
|
||||
|
||||
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
char *s2;
|
||||
asprintf(&s2, "%s\\*", s);
|
||||
smbcli_unlink(dstate->tree, s2);
|
||||
|
@ -1,558 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Dfs routines
|
||||
Copyright (C) James Myers 2003
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
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] = smbcli_raw_initialise();
|
||||
}
|
||||
context->sockops = sockops;
|
||||
context->username = username;
|
||||
context->password = password;
|
||||
context->workgroup = workgroup;
|
||||
context->connection_flags = flags;
|
||||
if (flags & SMBCLI_FULL_CONNECTION_USE_DFS)
|
||||
context->use_dfs = True;
|
||||
context->number_members = DFS_MAX_CLUSTER_SIZE;
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Interpret a Dfs referral structure.
|
||||
The length of the structure is returned
|
||||
The structure of a Dfs referral depends on the info level.
|
||||
****************************************************************************/
|
||||
|
||||
static int interpret_referral(struct smbcli_state *cli,
|
||||
int level,char *p,referral_info *rinfo)
|
||||
{
|
||||
char* q;
|
||||
int version, size;
|
||||
|
||||
version = SVAL(p,0);
|
||||
size = SVAL(p,2);
|
||||
rinfo->server_type = SVAL(p,4);
|
||||
rinfo->referral_flags = SVAL(p,6);
|
||||
rinfo->proximity = SVAL(p,8);
|
||||
rinfo->ttl = SVAL(p,10);
|
||||
rinfo->pathOffset = SVAL(p,12);
|
||||
rinfo->altPathOffset = SVAL(p,14);
|
||||
rinfo->nodeOffset = SVAL(p,16);
|
||||
DEBUG(3,("referral version=%d, size=%d, server_type=%d, flags=0x%x, proximity=%d, ttl=%d, pathOffset=%d, altPathOffset=%d, nodeOffset=%d\n",
|
||||
version, size, rinfo->server_type, rinfo->referral_flags,
|
||||
rinfo->proximity, rinfo->ttl, rinfo->pathOffset,
|
||||
rinfo->altPathOffset, rinfo->nodeOffset));
|
||||
|
||||
q = (char*)(p + (rinfo->pathOffset));
|
||||
//printf("p=%p, q=%p, offset=%d\n", p, q, rinfo->pathOffset);
|
||||
//printf("hex=0x%x, string=%s\n", q, q);
|
||||
clistr_pull(cli, rinfo->path, q,
|
||||
sizeof(rinfo->path),
|
||||
-1, STR_TERMINATE);
|
||||
DEBUG(4,("referral path=%s\n", rinfo->path));
|
||||
q = (char*)(p + (rinfo->altPathOffset)/sizeof(char));
|
||||
if (rinfo->altPathOffset > 0)
|
||||
clistr_pull(cli, rinfo->altPath, q,
|
||||
sizeof(rinfo->altPath),
|
||||
-1, STR_TERMINATE);
|
||||
DEBUG(4,("referral alt path=%s\n", rinfo->altPath));
|
||||
q = (char*)(p + (rinfo->nodeOffset)/sizeof(char));
|
||||
if (rinfo->nodeOffset > 0)
|
||||
clistr_pull(cli, rinfo->node, q,
|
||||
sizeof(rinfo->node),
|
||||
-1, STR_TERMINATE);
|
||||
DEBUG(4,("referral node=%s\n", rinfo->node));
|
||||
fstrcpy(rinfo->host, &rinfo->node[1]);
|
||||
p = strchr_m(&rinfo->host[1],'\\');
|
||||
if (!p) {
|
||||
printf("invalid referral node %s\n", rinfo->node);
|
||||
return -1;
|
||||
}
|
||||
*p = 0;
|
||||
rinfo->share = talloc_strdup(cli->mem_ctx, p+1);
|
||||
DEBUG(3,("referral host=%s share=%s\n",
|
||||
rinfo->host, rinfo->share));
|
||||
return size;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int smbcli_select_dfs_referral(struct smbcli_state *cli, dfs_info* dinfo)
|
||||
{
|
||||
return (int)sys_random()%dinfo->number_referrals;
|
||||
}
|
||||
|
||||
int smbcli_get_dfs_referral(struct smbcli_state *cli,const char *Fname, dfs_info* dinfo)
|
||||
{
|
||||
struct smb_trans2 parms;
|
||||
int info_level;
|
||||
char *p;
|
||||
pstring fname;
|
||||
int i;
|
||||
char *rparam=NULL, *rdata=NULL;
|
||||
int param_len, data_len;
|
||||
uint16_t setup;
|
||||
pstring param;
|
||||
DATA_BLOB trans_param, trans_data;
|
||||
|
||||
/* NT uses 260, OS/2 uses 2. Both accept 1. */
|
||||
info_level = (cli->capabilities&CAP_NT_SMBS)?260:1;
|
||||
|
||||
pstrcpy(fname,Fname);
|
||||
|
||||
setup = TRANSACT2_GET_DFS_REFERRAL ;
|
||||
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,("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 (!smbcli_send_trans(cli, SMBtrans2,
|
||||
NULL, /* Name */
|
||||
-1, 0, /* fid, flags */
|
||||
&setup, 1, 0, /* setup, length, max */
|
||||
&trans_param, 10, /* param, length, max */
|
||||
&trans_data,
|
||||
cli->max_xmit /* data, length, max */
|
||||
)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smbcli_receive_trans(cli, SMBtrans2,
|
||||
&rparam, ¶m_len,
|
||||
&rdata, &data_len) &&
|
||||
smbcli_is_dos_error(cli)) {
|
||||
return 0;
|
||||
}
|
||||
//printf("smbcli_get_dfs_referral: received response, rdata=%p, rparam=%p\n",
|
||||
// rdata, rparam);
|
||||
|
||||
if (smbcli_is_error(cli) || !rdata)
|
||||
return 0;
|
||||
|
||||
/* parse out some important return info */
|
||||
//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,("smbcli_get_dfs_referral: path_consumed=%d, # referrals=%d, flags=0x%x\n",
|
||||
dinfo->path_consumed, dinfo->number_referrals,
|
||||
dinfo->referral_flags));
|
||||
|
||||
/* point to the referral bytes */
|
||||
p+=8;
|
||||
for (i=0; i < dinfo->number_referrals; i++) {
|
||||
p += interpret_referral(cli,info_level,p,&dinfo->referrals[i]);
|
||||
}
|
||||
|
||||
SAFE_FREE(rdata);
|
||||
SAFE_FREE(rparam);
|
||||
|
||||
DEBUG(3,("received %d Dfs referrals\n",
|
||||
dinfo->number_referrals));
|
||||
|
||||
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));
|
||||
|
||||
return(dinfo->number_referrals);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* check if the server produced Dfs redirect */
|
||||
BOOL smbcli_check_dfs_redirect(struct smbcli_state* c, char* fname,
|
||||
dfs_info* dinfo)
|
||||
{
|
||||
//printf("check_dfs_redirect: error %s\n",
|
||||
// smbcli_errstr(c));
|
||||
if (smbcli_is_dos_error(c)) {
|
||||
printf("got dos error\n");
|
||||
return False;
|
||||
|
||||
} else {
|
||||
NTSTATUS status;
|
||||
|
||||
/* Check NT error */
|
||||
|
||||
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)) {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
/* execute trans2 getdfsreferral */
|
||||
//printf("check_dfs_redirect: process referral\n");
|
||||
//smbcli_get_dfs_referral(c, fname, dinfo);
|
||||
return True;
|
||||
}
|
||||
|
||||
int smbcli_dfs_open_connection(struct smbcli_client* cluster,
|
||||
char* host, char* share, int flags)
|
||||
{
|
||||
int i;
|
||||
BOOL retry;
|
||||
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, 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,("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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= DFS_MAX_CLUSTER_SIZE)
|
||||
return -1;
|
||||
|
||||
c = cluster->cli[i];
|
||||
if (NT_STATUS_IS_ERR(smbcli_full_connection(NULL, &c,
|
||||
NULL, host, NULL, 0,
|
||||
share, "?????",
|
||||
cluster->username, cluster->workgroup,
|
||||
cluster->password, flags,
|
||||
&retry)))
|
||||
return -1;
|
||||
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,("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;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Parse the pathname of the form \hostname\service\reqpath
|
||||
into the dfs_path structure
|
||||
**********************************************************************/
|
||||
|
||||
BOOL smbcli_parse_dfs_path(char* pathname, struct dfs_path* pdp)
|
||||
{
|
||||
pstring pathname_local;
|
||||
char* p,*temp;
|
||||
|
||||
pstrcpy(pathname_local,pathname);
|
||||
p = temp = pathname_local;
|
||||
|
||||
ZERO_STRUCTP(pdp);
|
||||
|
||||
trim_string(temp,"\\","\\");
|
||||
DEBUG(10,("temp in smbcli_parse_dfs_path: .%s. after trimming \\'s\n",temp));
|
||||
|
||||
/* now tokenize */
|
||||
/* parse out hostname */
|
||||
p = strchr(temp,'\\');
|
||||
if(p == NULL)
|
||||
return False;
|
||||
*p = '\0';
|
||||
pstrcpy(pdp->hostname,temp);
|
||||
DEBUG(10,("hostname: %s\n",pdp->hostname));
|
||||
|
||||
/* parse out servicename */
|
||||
temp = p+1;
|
||||
p = strchr(temp,'\\');
|
||||
if(p == NULL) {
|
||||
pstrcpy(pdp->servicename,temp);
|
||||
pdp->reqpath[0] = '\0';
|
||||
return True;
|
||||
}
|
||||
*p = '\0';
|
||||
pstrcpy(pdp->servicename,temp);
|
||||
DEBUG(10,("servicename: %s\n",pdp->servicename));
|
||||
|
||||
/* rest is reqpath */
|
||||
pstrcpy(pdp->reqpath, p+1);
|
||||
|
||||
DEBUG(10,("rest of the path: %s\n",pdp->reqpath));
|
||||
return True;
|
||||
}
|
||||
|
||||
char* rebuild_filename(char *referral_fname, struct smbcli_state* c,
|
||||
char* fname, int path_consumed)
|
||||
{
|
||||
const char *template = "\\\\%s\\%s\\%s";
|
||||
struct dfs_path dp;
|
||||
|
||||
// TODO: handle consumed length
|
||||
DEBUG(3,("rebuild_filename: %s, %d consumed of %d\n",
|
||||
fname, path_consumed, strlen(fname)));
|
||||
if (smbcli_parse_dfs_path(fname, &dp)) {
|
||||
DEBUG(3,("rebuild_filename: reqpath=%s\n",
|
||||
dp.reqpath));
|
||||
asprintf(&referral_fname,
|
||||
template, smbcli_state_get_host(c),
|
||||
smbcli_state_get_share(c), dp.reqpath);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
DEBUG(3,("rebuild_filename: %s -> %s\n", fname, referral_fname));
|
||||
return referral_fname;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Open a file (allowing for Dfs referral).
|
||||
****************************************************************************/
|
||||
|
||||
int smbcli_dfs_open(struct smbcli_client* cluster, int *server,
|
||||
char *fname_src, int flags, int share_mode)
|
||||
{
|
||||
int referral_number;
|
||||
dfs_info dinfo;
|
||||
char *referral_fname;
|
||||
int fnum;
|
||||
|
||||
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 = 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,("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);
|
||||
*server = cluster->cli[*server]->dfs_referral;
|
||||
if (server < 0)
|
||||
return False;
|
||||
// rebuild file name and retry operation.
|
||||
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
|
||||
return False;
|
||||
fname_src = referral_fname;
|
||||
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 (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,("smbcli_dfs_open: open %s fnum=%d\n",
|
||||
fname_src, fnum));
|
||||
return fnum;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Delete a file (allowing for Dfs referral).
|
||||
****************************************************************************/
|
||||
|
||||
NTSTATUS smbcli_nt_unlink(struct smbcli_client* cluster, int *server,
|
||||
char *fname_src, uint16_t FileAttributes)
|
||||
{
|
||||
int referral_number;
|
||||
dfs_info dinfo;
|
||||
char *referral_fname;
|
||||
struct smb_unlink parms;
|
||||
|
||||
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(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,("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);
|
||||
*server = cluster->cli[*server]->dfs_referral;
|
||||
if (server < 0)
|
||||
return NT_STATUS_INTERNAL_ERROR;
|
||||
// rebuild file name and retry operation.
|
||||
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,("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 (smbcli_is_error(cluster->cli[*server])) {
|
||||
printf("smbcli_nt_unlink: delete of %s failed (%s)\n",
|
||||
fname_src, smbcli_errstr(cluster->cli[*server]));
|
||||
}
|
||||
}
|
||||
return smbcli_nt_error(cluster->cli[*server]);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Rename a file (allowing for Dfs referral).
|
||||
****************************************************************************/
|
||||
|
||||
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,("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 (!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,("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);
|
||||
*server = cluster->cli[*server]->dfs_referral;
|
||||
if (server < 0)
|
||||
return False;
|
||||
// rebuild file name and retry operation.
|
||||
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
|
||||
return False;
|
||||
fname_src = referral_fname;
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Make directory (allowing for Dfs referral).
|
||||
****************************************************************************/
|
||||
|
||||
BOOL smbcli_dfs_mkdir(struct smbcli_client* cluster, int *server,
|
||||
char *fname_src)
|
||||
{
|
||||
int referral_number;
|
||||
dfs_info dinfo;
|
||||
char *referral_fname;
|
||||
|
||||
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 (!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,("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);
|
||||
*server = cluster->cli[*server]->dfs_referral;
|
||||
if (server < 0)
|
||||
return False;
|
||||
// rebuild file name and retry operation.
|
||||
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
|
||||
return False;
|
||||
fname_src = referral_fname;
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Remove directory (allowing for Dfs referral).
|
||||
****************************************************************************/
|
||||
|
||||
BOOL smbcli_dfs_rmdir(struct smbcli_client* cluster, int *server,
|
||||
char *fname_src)
|
||||
{
|
||||
int referral_number;
|
||||
dfs_info dinfo;
|
||||
char *referral_fname;
|
||||
|
||||
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 (!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,("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);
|
||||
*server = cluster->cli[*server]->dfs_referral;
|
||||
if (server < 0)
|
||||
return False;
|
||||
// rebuild file name and retry operation.
|
||||
if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL)
|
||||
return False;
|
||||
fname_src = referral_fname;
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
@ -20,11 +20,11 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "client.h"
|
||||
#include "clilist.h"
|
||||
#include "libcli/raw/libcliraw.h"
|
||||
|
||||
struct search_private {
|
||||
struct file_info *dirlist;
|
||||
struct clilist_file_info *dirlist;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
int dirlist_len;
|
||||
int ff_searchcount; /* total received in 1 server trip */
|
||||
@ -40,9 +40,9 @@ struct search_private {
|
||||
****************************************************************************/
|
||||
static BOOL interpret_long_filename(enum smb_search_level level,
|
||||
union smb_search_data *info,
|
||||
struct file_info *finfo)
|
||||
struct clilist_file_info *finfo)
|
||||
{
|
||||
struct file_info finfo2;
|
||||
struct clilist_file_info finfo2;
|
||||
|
||||
if (!finfo) finfo = &finfo2;
|
||||
ZERO_STRUCTP(finfo);
|
||||
@ -50,23 +50,17 @@ static BOOL interpret_long_filename(enum smb_search_level level,
|
||||
switch (level) {
|
||||
case RAW_SEARCH_STANDARD:
|
||||
finfo->size = info->standard.size;
|
||||
finfo->ctime = info->standard.create_time;
|
||||
finfo->atime = info->standard.access_time;
|
||||
finfo->mtime = info->standard.write_time;
|
||||
finfo->mode = info->standard.attrib;
|
||||
finfo->attrib = info->standard.attrib;
|
||||
finfo->name = info->standard.name.s;
|
||||
finfo->short_name = info->standard.name.s;
|
||||
break;
|
||||
|
||||
case RAW_SEARCH_BOTH_DIRECTORY_INFO:
|
||||
finfo->size = info->both_directory_info.size;
|
||||
finfo->ctime = nt_time_to_unix(info->both_directory_info.create_time);
|
||||
finfo->atime = nt_time_to_unix(info->both_directory_info.access_time);
|
||||
finfo->mtime = nt_time_to_unix(info->both_directory_info.write_time);
|
||||
finfo->mode = info->both_directory_info.attrib; /* 32 bit->16 bit attrib */
|
||||
if (info->both_directory_info.short_name.s) {
|
||||
strncpy(finfo->short_name, info->both_directory_info.short_name.s,
|
||||
sizeof(finfo->short_name)-1);
|
||||
}
|
||||
finfo->attrib = info->both_directory_info.attrib;
|
||||
finfo->short_name = info->both_directory_info.short_name.s;
|
||||
finfo->name = info->both_directory_info.name.s;
|
||||
break;
|
||||
|
||||
@ -82,18 +76,18 @@ static BOOL interpret_long_filename(enum smb_search_level level,
|
||||
static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
|
||||
{
|
||||
struct search_private *state = (struct search_private*) private;
|
||||
struct file_info *tdl;
|
||||
struct clilist_file_info *tdl;
|
||||
|
||||
/* add file info to the dirlist pool */
|
||||
tdl = talloc_realloc(state,
|
||||
state->dirlist,
|
||||
state->dirlist_len + sizeof(struct file_info));
|
||||
state->dirlist_len + sizeof(struct clilist_file_info));
|
||||
|
||||
if (!tdl) {
|
||||
return False;
|
||||
}
|
||||
state->dirlist = tdl;
|
||||
state->dirlist_len += sizeof(struct file_info);
|
||||
state->dirlist_len += sizeof(struct clilist_file_info);
|
||||
|
||||
interpret_long_filename(state->info_level, file, &state->dirlist[state->total_received]);
|
||||
|
||||
@ -106,7 +100,7 @@ static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
|
||||
|
||||
int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
|
||||
enum smb_search_level level,
|
||||
void (*fn)(struct file_info *, const char *, void *),
|
||||
void (*fn)(struct clilist_file_info *, const char *, void *),
|
||||
void *caller_state)
|
||||
{
|
||||
union smb_search_first first_parms;
|
||||
@ -209,19 +203,18 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
|
||||
****************************************************************************/
|
||||
static BOOL interpret_short_filename(int level,
|
||||
union smb_search_data *info,
|
||||
struct file_info *finfo)
|
||||
struct clilist_file_info *finfo)
|
||||
{
|
||||
struct file_info finfo2;
|
||||
struct clilist_file_info finfo2;
|
||||
|
||||
if (!finfo) finfo = &finfo2;
|
||||
ZERO_STRUCTP(finfo);
|
||||
|
||||
finfo->ctime = info->search.write_time;
|
||||
finfo->atime = info->search.write_time;
|
||||
finfo->mtime = info->search.write_time;
|
||||
finfo->size = info->search.size;
|
||||
finfo->mode = info->search.attrib;
|
||||
finfo->attrib = info->search.attrib;
|
||||
finfo->name = info->search.name;
|
||||
finfo->short_name = info->search.name;
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -229,18 +222,18 @@ static BOOL interpret_short_filename(int level,
|
||||
static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
|
||||
{
|
||||
struct search_private *state = (struct search_private*) private;
|
||||
struct file_info *tdl;
|
||||
struct clilist_file_info *tdl;
|
||||
|
||||
/* add file info to the dirlist pool */
|
||||
tdl = talloc_realloc(state,
|
||||
state->dirlist,
|
||||
state->dirlist_len + sizeof(struct file_info));
|
||||
state->dirlist_len + sizeof(struct clilist_file_info));
|
||||
|
||||
if (!tdl) {
|
||||
return False;
|
||||
}
|
||||
state->dirlist = tdl;
|
||||
state->dirlist_len += sizeof(struct file_info);
|
||||
state->dirlist_len += sizeof(struct clilist_file_info);
|
||||
|
||||
interpret_short_filename(state->info_level, file, &state->dirlist[state->total_received]);
|
||||
|
||||
@ -252,7 +245,7 @@ static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
|
||||
}
|
||||
|
||||
int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
|
||||
void (*fn)(struct file_info *, const char *, void *),
|
||||
void (*fn)(struct clilist_file_info *, const char *, void *),
|
||||
void *caller_state)
|
||||
{
|
||||
union smb_search_first first_parms;
|
||||
@ -338,7 +331,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
|
||||
****************************************************************************/
|
||||
|
||||
int smbcli_list(struct smbcli_tree *tree, const char *Mask,uint16_t attribute,
|
||||
void (*fn)(struct file_info *, const char *, void *), void *state)
|
||||
void (*fn)(struct clilist_file_info *, const char *, void *), void *state)
|
||||
{
|
||||
if (tree->session->transport->negotiate.protocol <= PROTOCOL_LANMAN1)
|
||||
return smbcli_list_old(tree, Mask, attribute, fn, state);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "includes.h"
|
||||
#include "librpc/gen_ndr/ndr_security.h"
|
||||
|
||||
static void list_fn(struct file_info *finfo, const char *name, void *state)
|
||||
static void list_fn(struct clilist_file_info *finfo, const char *name, void *state)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "dynconfig.h"
|
||||
#include "client.h"
|
||||
#include "clilist.h"
|
||||
#include "libcli/raw/libcliraw.h"
|
||||
#include "system/time.h"
|
||||
|
||||
@ -98,7 +98,7 @@ static struct {
|
||||
} last_hit;
|
||||
static BOOL f_info_hit;
|
||||
|
||||
static void listfn(struct file_info *f, const char *s, void *state)
|
||||
static void listfn(struct clilist_file_info *f, const char *s, void *state)
|
||||
{
|
||||
if (strcmp(f->name,".") == 0) {
|
||||
resultp[0] = '+';
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "dynconfig.h"
|
||||
#include "client.h"
|
||||
#include "clilist.h"
|
||||
#include "lib/cmdline/popt_common.h"
|
||||
#include "libcli/raw/libcliraw.h"
|
||||
#include "system/time.h"
|
||||
@ -37,7 +37,6 @@ static int procnum; /* records process count number when forking */
|
||||
static struct smbcli_state *current_cli;
|
||||
static BOOL use_oplocks;
|
||||
static BOOL use_level_II_oplocks;
|
||||
static BOOL use_kerberos;
|
||||
|
||||
BOOL torture_showall = False;
|
||||
|
||||
@ -99,9 +98,6 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
|
||||
const char *userdomain = lp_parm_string(-1, "torture", "userdomain");
|
||||
const char *password = lp_parm_string(-1, "torture", "password");
|
||||
|
||||
if (use_kerberos)
|
||||
flags |= SMBCLI_FULL_CONNECTION_USE_KERBEROS;
|
||||
|
||||
status = smbcli_full_connection(NULL,
|
||||
c, lp_netbios_name(),
|
||||
hostname, NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user