mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r5542: fix a few more msdfs bugs in smbclient against both smbd and 2k dfs root
shares.
This commit is contained in:
parent
3e04def033
commit
5d2624c453
@ -498,6 +498,9 @@ static int do_cd(char *newdir)
|
||||
pstring dname;
|
||||
pstring targetpath;
|
||||
struct cli_state *targetcli;
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
uint32 attributes;
|
||||
pstring fullpath;
|
||||
|
||||
dos_format(newdir);
|
||||
|
||||
@ -513,7 +516,7 @@ static int do_cd(char *newdir)
|
||||
if (*(cur_dir+strlen(cur_dir)-1) != '\\') {
|
||||
pstrcat(cur_dir, "\\");
|
||||
}
|
||||
|
||||
|
||||
dos_clean_name(cur_dir);
|
||||
pstrcpy( dname, cur_dir );
|
||||
pstrcat(cur_dir,"\\");
|
||||
@ -522,18 +525,39 @@ static int do_cd(char *newdir)
|
||||
if ( !cli_resolve_path( cli, dname, &targetcli, targetpath ) ) {
|
||||
d_printf("cd %s: %s\n", dname, cli_errstr(cli));
|
||||
pstrcpy(cur_dir,saved_dir);
|
||||
goto out;
|
||||
}
|
||||
|
||||
pstrcat( targetpath, "\\" );
|
||||
dos_clean_name( targetpath );
|
||||
|
||||
if ( !strequal(targetpath,"\\") ) {
|
||||
|
||||
if ( strequal(targetpath,"\\" ) )
|
||||
return 0;
|
||||
|
||||
/* use a trans2_qpathinfo to test directories for modern servers */
|
||||
|
||||
if ( targetcli->protocol >= PROTOCOL_LANMAN2 ) {
|
||||
if ( !cli_qpathinfo_basic( targetcli, targetpath, &sbuf, &attributes ) ) {
|
||||
d_printf("cd %s: %s\n", dname, cli_errstr(targetcli));
|
||||
pstrcpy(cur_dir,saved_dir);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ( !(attributes&FILE_ATTRIBUTE_DIRECTORY) ) {
|
||||
d_printf("cd %s: not a directory\n", dname);
|
||||
pstrcpy(cur_dir,saved_dir);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pstrcat( targetpath, "\\" );
|
||||
dos_clean_name( targetpath );
|
||||
|
||||
if ( !cli_chkpath(targetcli, targetpath) ) {
|
||||
d_printf("cd %s: %s\n", dname, cli_errstr(targetcli));
|
||||
pstrcpy(cur_dir,saved_dir);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
pstrcpy(cd_path,cur_dir);
|
||||
|
||||
return 0;
|
||||
|
@ -254,6 +254,8 @@ BOOL cli_resolve_path( struct cli_state *rootcli, const char *path,
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
uint32 attributes;
|
||||
|
||||
*targetcli = NULL;
|
||||
|
||||
if ( !rootcli || !path || !targetcli )
|
||||
return False;
|
||||
|
||||
@ -264,7 +266,7 @@ BOOL cli_resolve_path( struct cli_state *rootcli, const char *path,
|
||||
|
||||
/* don't bother continuing if this is not a dfs root */
|
||||
|
||||
if ( !rootcli->dfsroot || cli_qpathinfo_basic( rootcli, fullpath, &sbuf, &attributes ) ) {
|
||||
if ( !rootcli->dfsroot || cli_qpathinfo_basic( rootcli, cleanpath, &sbuf, &attributes ) ) {
|
||||
*targetcli = rootcli;
|
||||
pstrcpy( targetpath, path );
|
||||
return True;
|
||||
@ -309,9 +311,11 @@ BOOL cli_resolve_path( struct cli_state *rootcli, const char *path,
|
||||
/* check for another dfs refeerrali, note that we are not
|
||||
checking for loops here */
|
||||
|
||||
if ( cli_resolve_path( *targetcli, targetpath, &newcli, newpath ) ) {
|
||||
*targetcli = newcli;
|
||||
pstrcpy( targetpath, newpath );
|
||||
if ( !strequal( targetpath, "\\" ) ) {
|
||||
if ( cli_resolve_path( *targetcli, targetpath, &newcli, newpath ) ) {
|
||||
*targetcli = newcli;
|
||||
pstrcpy( targetpath, newpath );
|
||||
}
|
||||
}
|
||||
|
||||
return True;
|
||||
|
@ -655,12 +655,27 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name,
|
||||
char param[sizeof(pstring)+6];
|
||||
char *rparam=NULL, *rdata=NULL;
|
||||
char *p;
|
||||
pstring path;
|
||||
int len;
|
||||
|
||||
/* send full paths to dfs root shares */
|
||||
|
||||
if ( cli->dfsroot )
|
||||
pstr_sprintf(path, "\\%s\\%s\\%s", cli->desthost, cli->share, name );
|
||||
else
|
||||
pstrcpy( path, name );
|
||||
|
||||
/* cleanup */
|
||||
|
||||
len = strlen( path );
|
||||
if ( path[len] == '\\' )
|
||||
path[len] = '\0';
|
||||
|
||||
p = param;
|
||||
memset(p, 0, 6);
|
||||
SSVAL(p, 0, SMB_QUERY_FILE_BASIC_INFO);
|
||||
p += 6;
|
||||
p += clistr_push(cli, p, name, sizeof(pstring)-6, STR_TERMINATE);
|
||||
p += clistr_push(cli, p, path, sizeof(pstring)-6, STR_TERMINATE);
|
||||
param_len = PTR_DIFF(p, param);
|
||||
|
||||
if (!cli_send_trans(cli, SMBtrans2,
|
||||
|
Loading…
Reference in New Issue
Block a user