mirror of
https://github.com/obarthel/amiga-smbfs.git
synced 2025-12-08 14:58:35 +00:00
Updated to version 1.128
Please keep in mind that this is still a development version and might surprise you (not necessarily in a good way). Do not let me discourage you to build and test this version, although there will be some risks involved such as data corruption or loss of data.
This commit is contained in:
@@ -1361,3 +1361,40 @@ smbfs 1.125 (8.5.2018)
|
||||
- You can disable the use of SMB_COM_WRITE_RAW and SMB_COM_READ_RAW,
|
||||
respectively through the new DISABLEWRITERAW and DISABLEREADRAW
|
||||
options. These are intended for testing purposes only.
|
||||
|
||||
|
||||
smbfs 1.126 (9.5.2018)
|
||||
|
||||
- Added the TIMEOUT option which can be used to set a send/receive
|
||||
timeout. The timeout is given as the number of seconds to wait for
|
||||
the reception/transmission to pick up again. If it fails to pick up
|
||||
an error condition will be flagged.
|
||||
|
||||
- Not all the calls to the recv() function took into account that
|
||||
the request to read the incoming data could be fulfilled only
|
||||
partly. The recv() calls have been replaced by a single function
|
||||
which makes sure that either all the requested data has been
|
||||
received, the connection has been closed or an error has
|
||||
occured. This bug is at least 20 years old, since it is present
|
||||
in the original "Sharity-Light" code which I ported in the
|
||||
year 2000.
|
||||
|
||||
|
||||
smbfs 1.127 (10.5.2018)
|
||||
|
||||
- If the smb_receive_raw() function receives fewer data than
|
||||
expected it will always lead to the connection getting closed.
|
||||
Previously, missing data could lead to the session getting
|
||||
out of sync with what the server expected the client to
|
||||
process.
|
||||
|
||||
|
||||
smbfs 1.128 (10.5.2018)
|
||||
|
||||
- Added support for built-in CP437 and CP850 "OEM character set"
|
||||
translation. CP850 appears to be the default character set
|
||||
encoding for file and directory names which Samba uses.
|
||||
|
||||
- The code page based translation now checks if the respective
|
||||
file or directory name can be translated and will ignore or
|
||||
reject it if necessary.
|
||||
|
||||
@@ -46,7 +46,9 @@ LFLAGS = -nostartfiles -nostdlib -L.
|
||||
|
||||
###############################################################################
|
||||
|
||||
OBJS = main.o proc.o smb_abstraction.o sock.o crypt.o quad_math.o dump_smb.o utf-8-iso-8859-1-conversion.o
|
||||
OBJS = \
|
||||
main.o proc.o smb_abstraction.o sock.o crypt.o quad_math.o dump_smb.o \
|
||||
utf-8-iso-8859-1-conversion.o cp437.o cp850.o
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -64,8 +66,10 @@ $(PROJECT): $(OBJS)
|
||||
###############################################################################
|
||||
|
||||
assert.o : assert.c
|
||||
cp437.o : cp437.c cp437.h
|
||||
cp850.o : cp850.c cp850.h
|
||||
crypt.o : crypt.c system_headers.h assert.h smbfs.h
|
||||
main.o : main.c system_headers.h assert.h smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h utf-8-iso-8859-1-conversion.h
|
||||
main.o : main.c system_headers.h assert.h smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h utf-8-iso-8859-1-conversion.h cp437.h cp850.h
|
||||
proc.o : proc.c system_headers.h assert.h smbfs.h quad_math.h
|
||||
quad_math.o : quad_math.c quad_math.h
|
||||
smb_abstraction.o : smb_abstraction.c system_headers.h assert.h smbfs.h smb_abstraction.h
|
||||
|
||||
@@ -51,7 +51,9 @@ LFLAGS = -nostartfiles -nostdlib -L.
|
||||
|
||||
###########################################################################
|
||||
|
||||
OBJS = main.o proc.o smb_abstraction.o sock.o crypt.o quad_math.o dump_smb.o utf-8-iso-8859-1-conversion.o assert.o
|
||||
OBJS = \
|
||||
main.o proc.o smb_abstraction.o sock.o crypt.o quad_math.o dump_smb.o \
|
||||
utf-8-iso-8859-1-conversion.o cp437.o cp850.o assert.o
|
||||
|
||||
###########################################################################
|
||||
|
||||
@@ -69,8 +71,10 @@ $(PROJECT): $(OBJS)
|
||||
###########################################################################
|
||||
|
||||
assert.o : assert.c assert.h
|
||||
cp437.o : cp437.c cp437.h
|
||||
cp850.o : cp850.c cp850.h
|
||||
crypt.o : crypt.c system_headers.h assert.h smbfs.h
|
||||
main.o : main.c system_headers.h assert.h smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h utf-8-iso-8859-1-conversion.h
|
||||
main.o : main.c system_headers.h assert.h smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h utf-8-iso-8859-1-conversion.h cp437.h cp850.h
|
||||
proc.o : proc.c system_headers.h assert.h smbfs.h quad_math.h
|
||||
quad_math.o : quad_math.c quad_math.h
|
||||
smb_abstraction.o : smb_abstraction.c system_headers.h assert.h smbfs.h smb_abstraction.h
|
||||
|
||||
Regular → Executable
@@ -62,6 +62,9 @@ struct smb_server
|
||||
|
||||
/* olsen (2018-05-08): Always use SMB_COM_READ, even if SMB_COM_READ_RAW were possible. */
|
||||
int disable_read_raw;
|
||||
|
||||
/* olsen (2018-05-09): Timeout for send/receive operations in seconds. */
|
||||
int timeout;
|
||||
};
|
||||
|
||||
#define NEGOTIATE_USER_SECURITY 0x01 /* If set, the server supports
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
|
||||
struct smb_mount_data
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
struct sockaddr_in addr;
|
||||
struct sockaddr_in addr;
|
||||
|
||||
char workgroup_name[17];
|
||||
char server_name[17];
|
||||
char client_name[17];
|
||||
char service[64];
|
||||
char workgroup_name[17];
|
||||
char server_name[17];
|
||||
char client_name[17];
|
||||
char service[64];
|
||||
|
||||
char username[64];
|
||||
char password[64];
|
||||
char username[64];
|
||||
char password[64];
|
||||
|
||||
int given_max_xmit;
|
||||
int given_max_xmit;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Regular → Executable
+197
-47
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "smb_abstraction.h"
|
||||
#include "utf-8-iso-8859-1-conversion.h"
|
||||
#include "cp437.h"
|
||||
#include "cp850.h"
|
||||
#include "dump_smb.h"
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -171,10 +173,10 @@ STATIC ULONG stack_usage_exit(const struct StackSwapStruct * stk);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
INLINE STATIC BOOL ReallyRemoveDosEntry(struct DosList *entry);
|
||||
INLINE STATIC LONG BuildFullName(const UBYTE * parent_name, STRPTR name, STRPTR *result_ptr, LONG *result_size_ptr);
|
||||
INLINE STATIC VOID TranslateCName(UBYTE *name, const UBYTE *map);
|
||||
INLINE STATIC VOID ConvertCString(void * bstring, LONG max_len, const UBYTE * cstring, LONG len);
|
||||
STATIC BOOL ReallyRemoveDosEntry(struct DosList *entry);
|
||||
STATIC LONG BuildFullName(const UBYTE * parent_name, STRPTR name, STRPTR *result_ptr, LONG *result_size_ptr);
|
||||
STATIC BOOL TranslateCName(UBYTE *name, const UBYTE *map);
|
||||
STATIC VOID ConvertCString(void * bstring, LONG max_len, const UBYTE * cstring, LONG len);
|
||||
STATIC VOID DisplayErrorList(VOID);
|
||||
STATIC VOID AddError(STRPTR fmt, APTR args);
|
||||
STATIC LONG CVSPrintf(STRPTR format_string, APTR args);
|
||||
@@ -186,9 +188,9 @@ STATIC LONG CheckAccessModeCollision(STRPTR name, LONG mode);
|
||||
STATIC LONG NameAlreadyInUse(STRPTR name);
|
||||
STATIC BOOL IsReservedName(STRPTR name);
|
||||
STATIC LONG MapErrnoToIoErr(int error);
|
||||
STATIC VOID TranslateBName(UBYTE *name, const UBYTE *map);
|
||||
STATIC BOOL TranslateBName(UBYTE *name, const UBYTE *map);
|
||||
STATIC VOID Cleanup(VOID);
|
||||
STATIC BOOL Setup(STRPTR program_name, STRPTR service, STRPTR workgroup, STRPTR username, STRPTR opt_password, BOOL opt_changecase, STRPTR opt_clientname, STRPTR opt_servername, int opt_cachesize, int opt_max_transmit, LONG *opt_time_zone_offset, LONG *opt_dst_offset, BOOL opt_raw_smb, BOOL opt_write_behind, BOOL opt_prefer_write_raw, BOOL opt_disable_write_raw, BOOL opt_disable_read_raw, STRPTR device_name, STRPTR volume_name, STRPTR translation_file);
|
||||
STATIC BOOL Setup(STRPTR program_name, STRPTR service, STRPTR workgroup, STRPTR username, STRPTR opt_password, BOOL opt_changecase, STRPTR opt_clientname, STRPTR opt_servername, int opt_cachesize, int opt_max_transmit, int opt_timeout, LONG *opt_time_zone_offset, LONG *opt_dst_offset, BOOL opt_raw_smb, BOOL opt_write_behind, BOOL opt_prefer_write_raw, BOOL opt_disable_write_raw, BOOL opt_disable_read_raw, STRPTR device_name, STRPTR volume_name, STRPTR translation_file);
|
||||
STATIC VOID ConvertBString(LONG max_len, STRPTR cstring, const void * bstring);
|
||||
STATIC BPTR Action_Parent(struct FileLock *parent, LONG *error_ptr);
|
||||
STATIC LONG Action_DeleteObject(struct FileLock *parent, const void * bcpl_name, LONG *error_ptr);
|
||||
@@ -621,6 +623,7 @@ main(VOID)
|
||||
KEY VolumeName;
|
||||
NUMBER CacheSize;
|
||||
NUMBER MaxTransmit;
|
||||
NUMBER Timeout;
|
||||
NUMBER DebugLevel;
|
||||
KEY DebugFile;
|
||||
NUMBER TimeZoneOffset;
|
||||
@@ -634,6 +637,8 @@ main(VOID)
|
||||
NUMBER DumpSMBLevel;
|
||||
KEY DumpSMBFile;
|
||||
SWITCH UTF8;
|
||||
SWITCH CP437;
|
||||
SWITCH CP850;
|
||||
KEY TranslationFile;
|
||||
KEY Service;
|
||||
} args;
|
||||
@@ -652,6 +657,7 @@ main(VOID)
|
||||
"VOLUME=VOLUMENAME/K,"
|
||||
"CACHE=CACHESIZE/N/K,"
|
||||
"MAXTRANSMIT/N/K,"
|
||||
"TIMEOUT/N/K,"
|
||||
"DEBUGLEVEL=DEBUG/N/K,"
|
||||
"DEBUGFILE/K,"
|
||||
"TZ=TIMEZONEOFFSET/N/K,"
|
||||
@@ -665,6 +671,8 @@ main(VOID)
|
||||
"DUMPSMBLEVEL/N/K,"
|
||||
"DUMPSMBFILE/K,"
|
||||
"UTF8/S,"
|
||||
"CP437/S,"
|
||||
"CP850/S,"
|
||||
"TRANSLATE=TRANSLATIONFILE/K,"
|
||||
"SERVICE/A";
|
||||
|
||||
@@ -676,6 +684,7 @@ main(VOID)
|
||||
LONG other_number;
|
||||
LONG cache_size = 0;
|
||||
LONG max_transmit = -1;
|
||||
LONG timeout = 0;
|
||||
char env_workgroup_name[17];
|
||||
char env_user_name[64];
|
||||
char env_password[64];
|
||||
@@ -834,12 +843,6 @@ main(VOID)
|
||||
|
||||
args.VolumeName = str;
|
||||
|
||||
str = FindToolType(Icon->do_ToolTypes,"TRANSLATE");
|
||||
if(str == NULL)
|
||||
str = FindToolType(Icon->do_ToolTypes,"TRANSLATIONFILE");
|
||||
|
||||
args.TranslationFile = str;
|
||||
|
||||
str = FindToolType(Icon->do_ToolTypes,"SERVICE");
|
||||
args.Service = str;
|
||||
|
||||
@@ -902,8 +905,23 @@ main(VOID)
|
||||
if(FindToolType(Icon->do_ToolTypes,"DISABLEREADRAW") != NULL)
|
||||
args.DisableReadRaw = TRUE;
|
||||
|
||||
if(FindToolType(Icon->do_ToolTypes,"UTF8") != NULL)
|
||||
args.UTF8 = TRUE;
|
||||
str = FindToolType(Icon->do_ToolTypes,"TRANSLATE");
|
||||
if(str == NULL)
|
||||
str = FindToolType(Icon->do_ToolTypes,"TRANSLATIONFILE");
|
||||
|
||||
if(str != NULL)
|
||||
{
|
||||
args.TranslationFile = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FindToolType(Icon->do_ToolTypes,"UTF8") != NULL)
|
||||
args.UTF8 = TRUE;
|
||||
else if (FindToolType(Icon->do_ToolTypes,"CP437") != NULL)
|
||||
args.CP437 = TRUE;
|
||||
else if (FindToolType(Icon->do_ToolTypes,"CP850") != NULL)
|
||||
args.CP850 = TRUE;
|
||||
}
|
||||
|
||||
str = FindToolType(Icon->do_ToolTypes,"DST");
|
||||
if(str == NULL)
|
||||
@@ -947,6 +965,18 @@ main(VOID)
|
||||
max_transmit = number;
|
||||
}
|
||||
|
||||
str = FindToolType(Icon->do_ToolTypes,"TIMEOUT");
|
||||
if(str != NULL)
|
||||
{
|
||||
if(StrToLong(str,&number) == -1 || number < 0)
|
||||
{
|
||||
ReportError("Invalid number '%s' for 'TIMEOUT' parameter.",str);
|
||||
goto out;
|
||||
}
|
||||
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
if(args.Workgroup == NULL)
|
||||
{
|
||||
ReportError("Required 'WORKGROUP' parameter was not provided.");
|
||||
@@ -1019,6 +1049,9 @@ main(VOID)
|
||||
|
||||
if(args.MaxTransmit != NULL)
|
||||
max_transmit = (*args.MaxTransmit);
|
||||
|
||||
if(args.Timeout != NULL && (*args.Timeout) >= 0)
|
||||
timeout = (*args.Timeout);
|
||||
}
|
||||
|
||||
/* Use the default if no user name is given. */
|
||||
@@ -1029,9 +1062,36 @@ main(VOID)
|
||||
if(args.DeviceName == NULL && args.VolumeName == NULL)
|
||||
args.DeviceName = "SMBFS";
|
||||
|
||||
/* UTF8 file name translation disables code-page based translation. */
|
||||
if(args.UTF8)
|
||||
args.TranslationFile = NULL;
|
||||
/* Code page based translation using a file disables
|
||||
* UTF-8 and built-in CP437 and CP850 translation.
|
||||
*/
|
||||
if(args.TranslationFile != NULL)
|
||||
{
|
||||
args.UTF8 = args.CP437 = args.CP850 = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.UTF8)
|
||||
args.CP437 = args.CP850 = FALSE;
|
||||
else if (args.CP437)
|
||||
args.CP850 = FALSE;
|
||||
}
|
||||
|
||||
/* Use one of the built-in code page translation tables? */
|
||||
if (args.CP437)
|
||||
{
|
||||
memmove(A2M,unicode_to_cp437,sizeof(unicode_to_cp437));
|
||||
memmove(M2A,cp437_to_unicode,sizeof(cp437_to_unicode));
|
||||
|
||||
TranslateNames = TRUE;
|
||||
}
|
||||
else if (args.CP850)
|
||||
{
|
||||
memmove(A2M,unicode_to_cp850,sizeof(unicode_to_cp850));
|
||||
memmove(M2A,cp850_to_unicode,sizeof(cp850_to_unicode));
|
||||
|
||||
TranslateNames = TRUE;
|
||||
}
|
||||
|
||||
CaseSensitive = (BOOL)args.CaseSensitive;
|
||||
OmitHidden = (BOOL)args.OmitHidden;
|
||||
@@ -1121,6 +1181,7 @@ main(VOID)
|
||||
args.ServerName,
|
||||
cache_size,
|
||||
max_transmit,
|
||||
timeout,
|
||||
args.TimeZoneOffset,
|
||||
args.DSTOffset,
|
||||
!args.NetBIOSTransport, /* Use raw SMB transport instead of NetBIOS transport? */
|
||||
@@ -2251,32 +2312,69 @@ MapErrnoToIoErr(int error)
|
||||
/****************************************************************************/
|
||||
|
||||
/* Translate a BCPL style file name (i.e. length is in the first byte)
|
||||
* via a mapping table.
|
||||
* via a mapping table. Returns TRUE if the translation could be performed
|
||||
* and FALSE if at least one character cannot be translated.
|
||||
*/
|
||||
INLINE STATIC VOID
|
||||
STATIC BOOL
|
||||
TranslateBName(UBYTE * name,const UBYTE * map)
|
||||
{
|
||||
LONG len;
|
||||
UBYTE c;
|
||||
BOOL success = TRUE;
|
||||
UBYTE c, d;
|
||||
int len;
|
||||
|
||||
len = (*name++);
|
||||
|
||||
while(len-- > 0)
|
||||
{
|
||||
c = (*name);
|
||||
d = map[c];
|
||||
|
||||
(*name++) = map[c];
|
||||
/* Only the NUL character maps to itself, any
|
||||
* other mapping which produces a NUL means that
|
||||
* the respective mapping cannot represent the
|
||||
* desired character.
|
||||
*/
|
||||
if(d == '\0' && c != d)
|
||||
{
|
||||
success = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
(*name++) = d;
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
/* Translate a NUL terminated file name via a mapping table. */
|
||||
INLINE STATIC VOID
|
||||
/* Translate a NUL terminated file name via a mapping table. Returns TRUE if
|
||||
* the translation could be performed and FALSE if at least one character
|
||||
* cannot be translated.
|
||||
*/
|
||||
STATIC BOOL
|
||||
TranslateCName(UBYTE * name,const UBYTE * map)
|
||||
{
|
||||
BOOL success = TRUE;
|
||||
UBYTE c;
|
||||
|
||||
while((c = (*name)) != '\0')
|
||||
(*name++) = map[c];
|
||||
{
|
||||
c = map[c];
|
||||
|
||||
/* Only the NUL character maps to itself, any
|
||||
* other mapping which produces a NUL means that
|
||||
* the respective mapping cannot represent the
|
||||
* desired character.
|
||||
*/
|
||||
if(c == '\0')
|
||||
{
|
||||
success = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
(*name++) = c;
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -2504,6 +2602,7 @@ Setup(
|
||||
STRPTR opt_servername,
|
||||
int opt_cachesize,
|
||||
int opt_max_transmit,
|
||||
int opt_timeout,
|
||||
LONG * opt_time_zone_offset,
|
||||
LONG * opt_dst_offset,
|
||||
BOOL opt_raw_smb,
|
||||
@@ -2628,8 +2727,6 @@ Setup(
|
||||
opt_password[i] = ToUpper(opt_password[i]);
|
||||
}
|
||||
|
||||
TranslateNames = FALSE;
|
||||
|
||||
/* Read the translation file, if possible. */
|
||||
if(translation_file != NULL)
|
||||
{
|
||||
@@ -2685,6 +2782,7 @@ Setup(
|
||||
opt_servername,
|
||||
opt_cachesize,
|
||||
opt_max_transmit,
|
||||
opt_timeout,
|
||||
opt_raw_smb,
|
||||
opt_write_behind,
|
||||
opt_prefer_write_raw,
|
||||
@@ -2877,7 +2975,7 @@ Setup(
|
||||
/****************************************************************************/
|
||||
|
||||
/* Convert a BCPL string into a standard NUL terminated 'C' string. */
|
||||
INLINE STATIC VOID
|
||||
STATIC VOID
|
||||
ConvertBString(LONG max_len,STRPTR cstring,const void * bstring)
|
||||
{
|
||||
const UBYTE * from = bstring;
|
||||
@@ -2893,7 +2991,7 @@ ConvertBString(LONG max_len,STRPTR cstring,const void * bstring)
|
||||
}
|
||||
|
||||
/* Convert a NUL terminated 'C' string into a BCPL string. */
|
||||
INLINE STATIC VOID
|
||||
STATIC VOID
|
||||
ConvertCString(void * bstring,LONG max_len,const UBYTE * cstring,LONG len)
|
||||
{
|
||||
UBYTE * to = bstring;
|
||||
@@ -3290,7 +3388,11 @@ Action_DeleteObject(
|
||||
/* Translate the Amiga file name using a translation table? */
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_name,&full_name_size);
|
||||
@@ -3484,7 +3586,11 @@ Action_CreateDir(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_name,&full_name_size);
|
||||
@@ -3652,7 +3758,11 @@ Action_LocateObject(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsReservedName(FilePart(name)))
|
||||
@@ -3957,7 +4067,11 @@ Action_SetProtect(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_name,&full_name_size);
|
||||
@@ -4094,7 +4208,11 @@ Action_RenameObject(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_source_name,&full_source_name_size);
|
||||
@@ -4140,7 +4258,11 @@ Action_RenameObject(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_destination_name,&full_destination_name_size);
|
||||
@@ -4447,7 +4569,13 @@ Action_ExamineObject(
|
||||
|
||||
/* If necessary, translate the name to Amiga format using a mapping table. */
|
||||
if(TranslateNames)
|
||||
TranslateBName(fib->fib_FileName,M2A);
|
||||
{
|
||||
if(!TranslateBName(fib->fib_FileName,M2A))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fib->fib_DirEntryType = st.is_dir ? ST_USERDIR : ST_FILE;
|
||||
@@ -4577,7 +4705,10 @@ dir_scan_callback_func_exnext(
|
||||
ConvertCString(fib->fib_FileName,sizeof(fib->fib_FileName),name,name_len);
|
||||
|
||||
if(TranslateNames)
|
||||
TranslateBName(fib->fib_FileName,M2A);
|
||||
{
|
||||
if(!TranslateBName(fib->fib_FileName,M2A))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
fib->fib_DirEntryType = st->is_dir ? ST_USERDIR : ST_FILE;
|
||||
@@ -4772,10 +4903,10 @@ dir_scan_callback_func_exall(
|
||||
*/
|
||||
if(!ignore_this_entry && NameIsAcceptable((STRPTR)name,MAX_FILENAME_LEN) && NOT (st->is_hidden && OmitHidden))
|
||||
{
|
||||
struct ExAllData * ed;
|
||||
ULONG size;
|
||||
ULONG type = ec->ec_Type;
|
||||
BOOL take_it;
|
||||
struct ExAllData * ed;
|
||||
BOOL take_it = TRUE;
|
||||
ULONG size;
|
||||
|
||||
size = (ec->ec_MinSize + strlen(name)+1 + 3) & ~3UL;
|
||||
SHOWVALUE(size);
|
||||
@@ -4810,7 +4941,10 @@ dir_scan_callback_func_exall(
|
||||
strcpy(ed->ed_Name,name);
|
||||
|
||||
if(!TranslateUTF8 && TranslateNames)
|
||||
TranslateCName(ed->ed_Name,M2A);
|
||||
{
|
||||
if(!TranslateCName(ed->ed_Name,M2A))
|
||||
take_it = FALSE;
|
||||
}
|
||||
|
||||
if(type >= ED_TYPE)
|
||||
ed->ed_Type = st->is_dir ? ST_USERDIR : ST_FILE;
|
||||
@@ -4856,8 +4990,6 @@ dir_scan_callback_func_exall(
|
||||
if(type >= ED_OWNER)
|
||||
ed->ed_OwnerUID = ed->ed_OwnerGID = 0;
|
||||
|
||||
take_it = TRUE;
|
||||
|
||||
if(ec->ec_Control->eac_MatchString != NULL)
|
||||
{
|
||||
SHOWMSG("checking against match string");
|
||||
@@ -5193,7 +5325,11 @@ Action_Find(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsReservedName(FilePart(name)))
|
||||
@@ -5784,7 +5920,11 @@ Action_SetDate(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_name,&full_name_size);
|
||||
@@ -5912,7 +6052,13 @@ Action_ExamineFH(
|
||||
ConvertCString(fib->fib_FileName,sizeof(fib->fib_FileName),name,name_len);
|
||||
|
||||
if(TranslateNames)
|
||||
TranslateBName(fib->fib_FileName,M2A);
|
||||
{
|
||||
if(!TranslateBName(fib->fib_FileName,M2A))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fib->fib_DirEntryType = ST_FILE;
|
||||
@@ -6490,7 +6636,11 @@ Action_SetComment(
|
||||
}
|
||||
else if (TranslateNames)
|
||||
{
|
||||
TranslateCName(name,A2M);
|
||||
if(!TranslateCName(name,A2M))
|
||||
{
|
||||
error = ERROR_INVALID_COMPONENT_NAME;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = BuildFullName(parent_name,name,&full_name,&full_name_size);
|
||||
|
||||
@@ -74,7 +74,7 @@ LFLAGS = \
|
||||
|
||||
OBJS = \
|
||||
main.o proc.o smb_abstraction.o sock.o crypt.o quad_math.o dump_smb.o \
|
||||
utf-8-iso-8859-1-conversion.o swap_stack_and_call.o
|
||||
utf-8-iso-8859-1-conversion.o cp437.o cp850.o swap_stack_and_call.o
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -102,8 +102,10 @@ system_headers.gst: system_headers.h system_headers.c
|
||||
###############################################################################
|
||||
|
||||
assert.o : assert.c
|
||||
cp437.o : cp437.c cp437.h
|
||||
cp850.o : cp850.c cp850.h
|
||||
crypt.o : crypt.c system_headers.h assert.h smbfs.h
|
||||
main.o : main.c system_headers.h assert.h smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h utf-8-iso-8859-1-conversion.h
|
||||
main.o : main.c system_headers.h assert.h smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h utf-8-iso-8859-1-conversion.h cp437.h cp850.h
|
||||
proc.o : proc.c system_headers.h assert.h smbfs.h quad_math.h
|
||||
quad_math.o : quad_math.c quad_math.h
|
||||
smb_abstraction.o : smb_abstraction.c system_headers.h assert.h smbfs.h smb_abstraction.h
|
||||
|
||||
@@ -97,6 +97,7 @@ smba_connect (
|
||||
char * workgroup_name,
|
||||
int cache_size,
|
||||
int max_transmit,
|
||||
int timeout,
|
||||
int opt_raw_smb,
|
||||
int opt_write_behind,
|
||||
int opt_prefer_write_raw,
|
||||
@@ -148,6 +149,9 @@ smba_connect (
|
||||
if(opt_disable_read_raw)
|
||||
res->server.disable_read_raw = 1;
|
||||
|
||||
/* olsen (2018-05-09): Timeout for send/receive operations in seconds. */
|
||||
res->server.timeout = timeout;
|
||||
|
||||
errnum = smba_setup_dircache (res,cache_size);
|
||||
if(errnum < 0)
|
||||
{
|
||||
@@ -164,8 +168,8 @@ smba_connect (
|
||||
if ((s = strchr (hostname, '.')) != NULL)
|
||||
(*s) = '\0';
|
||||
|
||||
data.addr.sin_family = AF_INET;
|
||||
data.addr.sin_addr.s_addr = ip_addr;
|
||||
data.addr.sin_family = AF_INET;
|
||||
data.addr.sin_addr.s_addr = ip_addr;
|
||||
|
||||
#if DEBUG
|
||||
{
|
||||
@@ -1487,6 +1491,7 @@ smba_start(
|
||||
char * opt_servername,
|
||||
int opt_cachesize,
|
||||
int opt_max_transmit,
|
||||
int opt_timeout,
|
||||
int opt_raw_smb,
|
||||
int opt_write_behind,
|
||||
int opt_prefer_write_raw,
|
||||
@@ -1643,6 +1648,7 @@ smba_start(
|
||||
workgroup,
|
||||
opt_cachesize,
|
||||
opt_max_transmit,
|
||||
opt_timeout,
|
||||
opt_raw_smb,
|
||||
opt_write_behind,
|
||||
opt_prefer_write_raw,
|
||||
|
||||
@@ -73,7 +73,7 @@ int smba_rmdir(smba_server_t *s, char *path);
|
||||
int smba_rename(smba_server_t *s, char *from, char *to);
|
||||
int smba_statfs(smba_server_t *s, long *bsize, long *blocks, long *bfree);
|
||||
void smb_invalidate_all_inodes(struct smb_server *server);
|
||||
int smba_start(char *service, char *opt_workgroup, char *opt_username, char *opt_password, char *opt_clientname, char *opt_servername, int opt_cachesize, int opt_max_transmit, int opt_raw_smb, int opt_write_behind, int opt_prefer_write_raw, int opt_disable_write_raw, int opt_disable_read_raw, smba_server_t **result);
|
||||
int smba_start(char *service, char *opt_workgroup, char *opt_username, char *opt_password, char *opt_clientname, char *opt_servername, int opt_cachesize, int opt_max_transmit, int opt_timeout, int opt_raw_smb, int opt_write_behind, int opt_prefer_write_raw, int opt_disable_write_raw, int opt_disable_read_raw, smba_server_t **result);
|
||||
void smba_disconnect(smba_server_t *server);
|
||||
int smba_get_dircache_size(struct smba_server * server);
|
||||
int smba_change_dircache_size(struct smba_server * server,int cache_size);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 125
|
||||
#define DATE "8.5.2018"
|
||||
#define VERS "smbfs 1.125"
|
||||
#define VSTRING "smbfs 1.125 (8.5.2018)\r\n"
|
||||
#define VERSTAG "\0$VER: smbfs 1.125 (8.5.2018)"
|
||||
#define REVISION 128
|
||||
#define DATE "10.5.2018"
|
||||
#define VERS "smbfs 1.128"
|
||||
#define VSTRING "smbfs 1.128 (10.5.2018)\r\n"
|
||||
#define VERSTAG "\0$VER: smbfs 1.128 (10.5.2018)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
125
|
||||
128
|
||||
|
||||
+162
-116
@@ -55,6 +55,40 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Attempt to receive all the incoming data, even if recv() returns only
|
||||
* parts of the total number of bytes requested. Returns the number of bytes
|
||||
* read or, in case of error a negative number. A negative result is the
|
||||
* value of -errno.
|
||||
*/
|
||||
static int
|
||||
receive_all(int fd, void * _data, int len)
|
||||
{
|
||||
int num_bytes_received;
|
||||
char * data = _data;
|
||||
int result;
|
||||
|
||||
for(num_bytes_received = 0 ; num_bytes_received < len ; num_bytes_received += result)
|
||||
{
|
||||
result = recv(fd, &data[num_bytes_received], len - num_bytes_received, 0);
|
||||
if(result == 0)
|
||||
break;
|
||||
|
||||
if(result < 0)
|
||||
{
|
||||
result = -errno;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
result = num_bytes_received;
|
||||
|
||||
out:
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* smb_receive_raw: The NetBIOS header is only stored if want_header != 0. */
|
||||
static int
|
||||
smb_receive_raw (
|
||||
@@ -66,33 +100,24 @@ smb_receive_raw (
|
||||
int input_payload_size,
|
||||
int want_header)
|
||||
{
|
||||
int len, result;
|
||||
int num_bytes_received;
|
||||
unsigned char netbios_session_buf[256];
|
||||
int netbios_session_payload_size;
|
||||
int len, result;
|
||||
|
||||
re_recv:
|
||||
|
||||
/* Read the NetBIOS session header (rfc-1002, section 4.3.1) */
|
||||
result = recv (sock_fd, netbios_session_buf, NETBIOS_HEADER_SIZE, 0);
|
||||
if(result == 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
|
||||
/* End of file */
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = receive_all (sock_fd, netbios_session_buf, NETBIOS_HEADER_SIZE);
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", errno));
|
||||
result = (-errno);
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", -result));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (result < NETBIOS_HEADER_SIZE)
|
||||
{
|
||||
LOG (("smb_receive_raw: got less than %ld bytes\n", NETBIOS_HEADER_SIZE));
|
||||
|
||||
result = -EIO;
|
||||
goto out;
|
||||
}
|
||||
@@ -104,15 +129,20 @@ smb_receive_raw (
|
||||
{
|
||||
if(netbios_session_buf[0] != 0x00 && netbios_session_payload_size > 0)
|
||||
{
|
||||
/* We only want to show what's in the first few
|
||||
* bytes of a session packet. Since we only support
|
||||
* two session packet types (session message and
|
||||
* session keep alive) we will abort processing
|
||||
* anyway so it doesn't matter if we ignore any
|
||||
* data beyond the first 256 bytes.
|
||||
*/
|
||||
if(netbios_session_payload_size > 256 - NETBIOS_HEADER_SIZE)
|
||||
netbios_session_payload_size = 256 - NETBIOS_HEADER_SIZE;
|
||||
|
||||
result = recv (sock_fd, &netbios_session_buf[NETBIOS_HEADER_SIZE], netbios_session_payload_size - NETBIOS_HEADER_SIZE, 0);
|
||||
result = receive_all (sock_fd, &netbios_session_buf[NETBIOS_HEADER_SIZE], netbios_session_payload_size - NETBIOS_HEADER_SIZE);
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", errno));
|
||||
|
||||
result = (-errno);
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", -result));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -195,6 +225,9 @@ smb_receive_raw (
|
||||
*/
|
||||
if(input_payload != NULL)
|
||||
{
|
||||
int count_of_bytes_returned;
|
||||
int count_of_bytes_to_read;
|
||||
int num_bytes_received = 0;
|
||||
int buffer_format;
|
||||
|
||||
LOG(("input_payload=0x%08lx, payload_size=%ld\n", input_payload, input_payload_size));
|
||||
@@ -214,32 +247,24 @@ smb_receive_raw (
|
||||
|
||||
LOG(("reading the first %ld bytes\n", 48));
|
||||
|
||||
for(num_bytes_received = 0 ; num_bytes_received < 48 && num_bytes_received < len ; num_bytes_received += result)
|
||||
result = receive_all (sock_fd, target, 48);
|
||||
if (result < 0)
|
||||
{
|
||||
result = recv (sock_fd, (void *)&target[num_bytes_received], 48 - num_bytes_received, 0);
|
||||
if(result == 0)
|
||||
{
|
||||
/* End of file */
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recvfrom error = %ld\n", errno));
|
||||
|
||||
result = (-errno);
|
||||
|
||||
goto out;
|
||||
}
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", -result));
|
||||
goto out;
|
||||
}
|
||||
|
||||
num_bytes_received += result;
|
||||
|
||||
ASSERT( num_bytes_received == 48 );
|
||||
|
||||
/* End of file reached? */
|
||||
if(num_bytes_received < 48)
|
||||
{
|
||||
result = 0;
|
||||
/* End of file */
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
|
||||
result = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -253,52 +278,48 @@ smb_receive_raw (
|
||||
|
||||
LOG(("buffer format = %ld, should be %ld\n", buffer_format, 1));
|
||||
|
||||
if(buffer_format == 1)
|
||||
if(buffer_format != 1)
|
||||
{
|
||||
int count_of_bytes_returned;
|
||||
int count_of_bytes_to_read;
|
||||
int num_data_bytes_received;
|
||||
LOG(("buffer format %ld not supported\n", buffer_format));
|
||||
result = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
count_of_bytes_returned = WVAL(target, 33);
|
||||
count_of_bytes_to_read = WVAL(target, 46);
|
||||
count_of_bytes_returned = WVAL(target, 33);
|
||||
count_of_bytes_to_read = WVAL(target, 46);
|
||||
|
||||
/* That should never be more data than the read buffer may hold. */
|
||||
ASSERT( count_of_bytes_to_read <= input_payload_size );
|
||||
ASSERT( count_of_bytes_to_read <= count_of_bytes_returned );
|
||||
ASSERT( count_of_bytes_returned <= input_payload_size );
|
||||
/* That should never be more data than the read buffer may hold. */
|
||||
ASSERT( count_of_bytes_to_read <= input_payload_size );
|
||||
ASSERT( count_of_bytes_to_read <= count_of_bytes_returned );
|
||||
ASSERT( count_of_bytes_returned <= input_payload_size );
|
||||
|
||||
LOG(("count of bytes to read = %ld, should be <= %ld\n", count_of_bytes_to_read, input_payload_size));
|
||||
LOG(("count of bytes to read = %ld, should be <= %ld\n", count_of_bytes_to_read, input_payload_size));
|
||||
|
||||
for(num_data_bytes_received = 0 ;
|
||||
num_data_bytes_received < count_of_bytes_to_read && num_bytes_received < len ;
|
||||
num_data_bytes_received += result, num_bytes_received += result)
|
||||
{
|
||||
result = recv (sock_fd, (void *)&input_payload[num_data_bytes_received], count_of_bytes_to_read - num_data_bytes_received, 0);
|
||||
if(result == 0)
|
||||
{
|
||||
/* End of file */
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
break;
|
||||
}
|
||||
result = receive_all (sock_fd, input_payload, count_of_bytes_to_read);
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", -result));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recvfrom error = %ld\n", errno));
|
||||
if(result < count_of_bytes_to_read)
|
||||
{
|
||||
/* End of file */
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
|
||||
result = (-errno);
|
||||
result = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
num_bytes_received += result;
|
||||
|
||||
ASSERT( count_of_bytes_to_read == count_of_bytes_returned );
|
||||
ASSERT( count_of_bytes_to_read == count_of_bytes_returned );
|
||||
|
||||
if(count_of_bytes_to_read < count_of_bytes_returned)
|
||||
{
|
||||
LOG(("fewer data available than should be delivered; setting the remainder (%ld bytes) to 0.\n", count_of_bytes_returned - count_of_bytes_to_read));
|
||||
if(count_of_bytes_to_read < count_of_bytes_returned)
|
||||
{
|
||||
LOG(("fewer data available than should be delivered; setting the remainder (%ld bytes) to 0.\n", count_of_bytes_returned - count_of_bytes_to_read));
|
||||
|
||||
memset(&input_payload[count_of_bytes_to_read],0,count_of_bytes_returned - count_of_bytes_to_read);
|
||||
}
|
||||
memset(&input_payload[count_of_bytes_to_read],0,count_of_bytes_returned - count_of_bytes_to_read);
|
||||
}
|
||||
|
||||
/* This should never happen, but then we better make sure to
|
||||
@@ -308,59 +329,63 @@ smb_receive_raw (
|
||||
{
|
||||
LOG(("reading the remaining %ld bytes; this should never happen\n", len - num_bytes_received ));
|
||||
|
||||
for( ; num_bytes_received < len ; num_bytes_received += result)
|
||||
result = receive_all (sock_fd, &target[num_bytes_received], len - num_bytes_received);
|
||||
if (result < 0)
|
||||
{
|
||||
result = recv (sock_fd, (void *)&target[num_bytes_received], len - num_bytes_received, 0);
|
||||
if(result == 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
|
||||
/* End of file */
|
||||
break;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recvfrom error = %ld\n", errno));
|
||||
|
||||
result = (-errno);
|
||||
|
||||
goto out;
|
||||
}
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", -result));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(num_bytes_received = 0 ; num_bytes_received < len ; num_bytes_received += result)
|
||||
{
|
||||
result = recv (sock_fd, (void *)&target[num_bytes_received], len - num_bytes_received, 0);
|
||||
if(result == 0)
|
||||
|
||||
if(result < len - num_bytes_received)
|
||||
{
|
||||
/* End of file */
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recvfrom error = %ld\n", errno));
|
||||
|
||||
result = (-errno);
|
||||
|
||||
result = -EIO;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DUMP_SMB)
|
||||
#if defined(DUMP_SMB)
|
||||
{
|
||||
/* If want_header==0 then this is the data returned by SMB_COM_READ_RAW. */
|
||||
dump_smb(__FILE__,__LINE__,!want_header,target,48,smb_packet_to_consumer,server->max_recv);
|
||||
|
||||
if(buffer_format == 1)
|
||||
dump_smb(__FILE__,__LINE__,!want_header,input_payload,num_bytes_received - 48,smb_packet_to_consumer,server->max_recv);
|
||||
|
||||
if(num_bytes_received < len && result > 0)
|
||||
dump_smb(__FILE__,__LINE__,!want_header,&target[num_bytes_received],result,smb_packet_to_consumer,server->max_recv);
|
||||
}
|
||||
#endif /* defined(DUMP_SMB) */
|
||||
|
||||
result = num_bytes_received;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If want_header==0 then this is the data returned by SMB_COM_READ_RAW. */
|
||||
dump_smb(__FILE__,__LINE__,!want_header,target,num_bytes_received,smb_packet_to_consumer,server->max_recv);
|
||||
}
|
||||
#endif /* defined(DUMP_SMB) */
|
||||
result = receive_all (sock_fd, target, len);
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive_raw: recv error = %ld\n", -result));
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = num_bytes_received;
|
||||
if(result < len)
|
||||
{
|
||||
/* End of file */
|
||||
LOG (("smb_receive_raw: EOF\n"));
|
||||
|
||||
result = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
#if defined(DUMP_SMB)
|
||||
{
|
||||
/* If want_header==0 then this is the data returned by SMB_COM_READ_RAW. */
|
||||
dump_smb(__FILE__,__LINE__,!want_header,target,result,smb_packet_to_consumer,server->max_recv);
|
||||
}
|
||||
#endif /* defined(DUMP_SMB) */
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
@@ -378,16 +403,19 @@ smb_receive (struct smb_server *server, int sock_fd, void * input_payload, int p
|
||||
result = smb_receive_raw (server, sock_fd, packet,
|
||||
server->max_recv,
|
||||
input_payload, payload_size,
|
||||
TRUE); /* We want the NetBIOS frame header */
|
||||
TRUE); /* We want the NetBIOS session service header */
|
||||
if (result < 0)
|
||||
{
|
||||
LOG (("smb_receive: receive error: %ld\n", result));
|
||||
goto out;
|
||||
}
|
||||
|
||||
server->rcls = BVAL (packet, 9);
|
||||
server->err = WVAL (packet, 11);
|
||||
server->rcls = BVAL (packet, 9);
|
||||
server->err = WVAL (packet, 11);
|
||||
|
||||
/* The caller is responsible for dealing with the error
|
||||
* information.
|
||||
*/
|
||||
if (server->rcls != 0)
|
||||
LOG (("smb_receive: error class=%ld, error=%ld\n", server->rcls, server->err));
|
||||
|
||||
@@ -438,7 +466,9 @@ smb_receive_trans2 (
|
||||
if (result < 0)
|
||||
goto fail;
|
||||
|
||||
/* Is an error condition set? */
|
||||
/* Is an error condition set? The caller is responsible
|
||||
* for dealing with the error.
|
||||
*/
|
||||
if (server->rcls != 0)
|
||||
goto fail;
|
||||
|
||||
@@ -489,7 +519,7 @@ smb_receive_trans2 (
|
||||
param_len = 0;
|
||||
data_len = 0;
|
||||
|
||||
while (1)
|
||||
while (TRUE)
|
||||
{
|
||||
parameter_displacement = WVAL (inbuf, smb_prdisp);
|
||||
parameter_count = WVAL (inbuf, smb_prcnt);
|
||||
@@ -607,7 +637,23 @@ smb_connect (struct smb_server *server)
|
||||
|
||||
result = connect (server->mount_data.fd, (struct sockaddr *)&server->mount_data.addr, sizeof(struct sockaddr_in));
|
||||
if(result < 0)
|
||||
{
|
||||
result = (-errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Configure the send/receive timeout (in seconds)? */
|
||||
if(server->timeout > 0)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
memset(&tv,0,sizeof(tv));
|
||||
|
||||
tv.tv_secs = server->timeout;
|
||||
|
||||
setsockopt(server->mount_data.fd,SOL_SOCKET,SO_SNDTIMEO,&tv,sizeof(tv));
|
||||
setsockopt(server->mount_data.fd,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof(tv));
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user