mirror of
https://github.com/obarthel/amiga-smbfs.git
synced 2025-12-08 14:58:35 +00:00
Updated to version 2.3
Added the ADDVOLUME option, which defaults to "yes". If no volume name is provided, smbfs will use the service name as the template, e.g. if you connect to //server-name/pictures then the default volume name will be "pictures". The idea is that if the file server allows this, you should not need to start the smbfs program with any parameter other than the service/share name and it should work out of the box. Preparations for showing error messages when running as a Workbench program would corrupt memory once the message was ready for display, but this only happened in the AmigaOS4 build. As far as I can tell this never worked correctly on AmigaOS4. Thanks go to Matthew Kille who reported the problem! Simplified the icon parameter processing used when running smbfs as a Workbench program. The reworked code is now basically limited to processing and setting up the same configuration data which the shell command use employs. Both paths share the same configuration data checking and handling. Turns out that the ACTION_CURRENT_VOLUME function does need to return the volume node, not the device node. Note to self: a 'struct DeviceList' refers to a volume (DLT_VOLUME), whereas a 'struct DeviceNode' refers to a device (DLT_DEVICE). See? This could have been easily been avoided :-/ Added more code documentation, especially for the various constants and data structures defined and used in "main.c". Reading from the file name translation file now performs better error detection and reporting. If read errors should crop up, the error message will now say so. If the file is shorter than required the error message will reflect this. Reworked the smb_proc_reconnect() function so that it does not end up truncating the password before it is encrypted. This means that up to 63 characters of the password can be used to produce the encrypted form, resolving problems with longer server passwords not quite matching what you entered. However, since this long encrypted password is still accompanied by the legacy encrypted form which truncates the password to 14 characters (which are converted to all-upper-case letters) there is no actual gain in terms of security...
This commit is contained in:
@@ -35,9 +35,9 @@ WARNINGS = \
|
||||
-Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion
|
||||
|
||||
CPU = -m68020-60
|
||||
OPTIONS = -DNDEBUG -fno-builtin -Inetinclude -Iinclude
|
||||
OPTIONS = -fno-builtin -Inetinclude -Iinclude
|
||||
OPTIMIZE = -O2 -fomit-frame-pointer
|
||||
DEBUG = -g
|
||||
DEBUG = -DNDEBUG -g
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ WARNINGS = \
|
||||
-Wall -W -Wshadow -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
|
||||
-Wundef -Wbad-function-cast -Wmissing-declarations
|
||||
|
||||
#OPTIONS = -DNDEBUG
|
||||
OPTIONS = -DDEBUG=1 -DDUMP_SMB=1
|
||||
OPTIONS = -DNDEBUG
|
||||
#OPTIONS = -DDEBUG=1 -DDUMP_SMB=1
|
||||
OPTIMIZE = -O3
|
||||
DEBUG = -ggdb
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ static void __asm putch(register __d0 UBYTE c)
|
||||
|
||||
#elif defined(__GNUC__) && defined(__amigaos4__)
|
||||
|
||||
static void putch(UBYTE c)
|
||||
static void putch(UBYTE c, APTR unused)
|
||||
{
|
||||
if(c != '\0')
|
||||
kputc(c);
|
||||
|
||||
+14
-14
@@ -46,13 +46,13 @@ static void concat (char *out, char *in1, char *in2, int l1, int l2);
|
||||
static void xor (char *out, char *in1, char *in2, int n);
|
||||
static void dohash (char *out, char *in, char *key, int forw);
|
||||
static void str_to_key (unsigned char *str, unsigned char *key);
|
||||
static void smbhash (unsigned char *out, unsigned char *in, unsigned char *key, int forw);
|
||||
static void smbhash (unsigned char *out, const unsigned char *in, unsigned char *key, int forw);
|
||||
static void E_P16 (unsigned char *p14, unsigned char *p16);
|
||||
static void E_P24 (unsigned char *p21, unsigned char *c8, unsigned char *p24);
|
||||
static void E_P24 (unsigned char *p21, const unsigned char *c8, unsigned char *p24);
|
||||
static int local_wcslen (short *str);
|
||||
static int local_mbstowcs (short *dst, unsigned char *src, int len);
|
||||
static void E_md4hash (unsigned char *passwd, unsigned char *p16);
|
||||
static void smb_owf_encrypt (unsigned char *passwd, unsigned char *c8, unsigned char *p24);
|
||||
static int local_mbstowcs (short *dst, const unsigned char *src, int len);
|
||||
static void E_md4hash (const unsigned char *passwd, unsigned char *p16);
|
||||
static void smb_owf_encrypt (unsigned char *passwd, const unsigned char *c8, unsigned char *p24);
|
||||
static unsigned long F (unsigned long X, unsigned long Y, unsigned long Z);
|
||||
static unsigned long G (unsigned long X, unsigned long Y, unsigned long Z);
|
||||
static unsigned long H (unsigned long X, unsigned long Y, unsigned long Z);
|
||||
@@ -375,7 +375,7 @@ str_to_key (unsigned char *str, unsigned char *key)
|
||||
}
|
||||
|
||||
static void
|
||||
smbhash (unsigned char *out, unsigned char *in, unsigned char *key, int forw)
|
||||
smbhash (unsigned char *out, const unsigned char *in, unsigned char *key, int forw)
|
||||
{
|
||||
int i;
|
||||
char outb[64];
|
||||
@@ -407,7 +407,7 @@ smbhash (unsigned char *out, unsigned char *in, unsigned char *key, int forw)
|
||||
static void
|
||||
E_P16 (unsigned char *p14, unsigned char *p16)
|
||||
{
|
||||
unsigned char sp8[8] =
|
||||
const unsigned char sp8[8] =
|
||||
{
|
||||
0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25
|
||||
};
|
||||
@@ -417,7 +417,7 @@ E_P16 (unsigned char *p14, unsigned char *p16)
|
||||
}
|
||||
|
||||
static void
|
||||
E_P24 (unsigned char *p21, unsigned char *c8, unsigned char *p24)
|
||||
E_P24 (unsigned char *p21, const unsigned char *c8, unsigned char *p24)
|
||||
{
|
||||
smbhash (p24, c8, p21, 1);
|
||||
smbhash (p24 + 8, c8, p21 + 7, 1);
|
||||
@@ -430,7 +430,7 @@ E_P24 (unsigned char *p21, unsigned char *c8, unsigned char *p24)
|
||||
It takes a password, a 8 byte "crypt key" and puts 24 bytes of
|
||||
encrypted password into p24 */
|
||||
void
|
||||
smb_encrypt (unsigned char *passwd, unsigned char *c8, unsigned char *p24)
|
||||
smb_encrypt (unsigned char *passwd, const unsigned char *c8, unsigned char *p24)
|
||||
{
|
||||
unsigned char p14[15], p21[21];
|
||||
int len;
|
||||
@@ -469,7 +469,7 @@ local_wcslen (short *str)
|
||||
this must be in intel (little-endian)
|
||||
format. */
|
||||
static int
|
||||
local_mbstowcs (short *dst, unsigned char *src, int len)
|
||||
local_mbstowcs (short *dst, const unsigned char *src, int len)
|
||||
{
|
||||
int i;
|
||||
short val;
|
||||
@@ -489,7 +489,7 @@ local_mbstowcs (short *dst, unsigned char *src, int len)
|
||||
|
||||
/* Creates the MD4 Hash of the users password in NT UNICODE. */
|
||||
static void
|
||||
E_md4hash (unsigned char *passwd, unsigned char *p16)
|
||||
E_md4hash (const unsigned char *passwd, unsigned char *p16)
|
||||
{
|
||||
short wpwd[129];
|
||||
int len;
|
||||
@@ -511,7 +511,7 @@ E_md4hash (unsigned char *passwd, unsigned char *p16)
|
||||
|
||||
/* Does the des encryption from the NT or LM MD4 hash. */
|
||||
static void
|
||||
smb_owf_encrypt (unsigned char *passwd, unsigned char *c8, unsigned char *p24)
|
||||
smb_owf_encrypt (unsigned char *passwd, const unsigned char *c8, unsigned char *p24)
|
||||
{
|
||||
unsigned char p21[21];
|
||||
|
||||
@@ -523,9 +523,9 @@ smb_owf_encrypt (unsigned char *passwd, unsigned char *c8, unsigned char *p24)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* Does the NT MD4 hash then des encryption. */
|
||||
/* Does the NT MD4 hash then DES encryption. */
|
||||
void
|
||||
smb_nt_encrypt (unsigned char *passwd, unsigned char *c8, unsigned char *p24)
|
||||
smb_nt_encrypt (const unsigned char *passwd, const unsigned char *c8, unsigned char *p24)
|
||||
{
|
||||
unsigned char p21[21];
|
||||
|
||||
|
||||
+565
-362
File diff suppressed because it is too large
Load Diff
+17
-31
@@ -4373,43 +4373,26 @@ smb_proc_reconnect (struct smb_server *server, int * error_ptr)
|
||||
|
||||
if(server->security_mode & NEGOTIATE_ENCRYPT_PASSWORDS)
|
||||
{
|
||||
char smb_password[15];
|
||||
|
||||
SHOWMSG("encrypted passwords required");
|
||||
|
||||
memset(oem_password,0,sizeof(oem_password));
|
||||
strlcpy(oem_password,server->mount_data.password,sizeof(oem_password));
|
||||
/* Maximum password length for smb_encrypt() is 14 characters, which
|
||||
* does not include the terminating NUL byte. The password will be
|
||||
* converted to all-upper-case characters prior to encryption which
|
||||
* is why we make a copy first.
|
||||
*/
|
||||
strlcpy(smb_password,server->mount_data.password,sizeof(smb_password));
|
||||
|
||||
smb_encrypt(oem_password,server->crypt_key,oem_password);
|
||||
oem_password_len = 24;
|
||||
|
||||
/*
|
||||
PRINTHEADER();
|
||||
PRINTF(("password: "));
|
||||
for(i = 0 ; i < 24 ; i++)
|
||||
PRINTF(("%02lx ",oem_password[i]));
|
||||
PRINTF(("\n"));
|
||||
*/
|
||||
|
||||
memset(unicode_password,0,sizeof(unicode_password));
|
||||
strlcpy(unicode_password,server->mount_data.password,sizeof(unicode_password));
|
||||
|
||||
smb_nt_encrypt(unicode_password,server->crypt_key,unicode_password);
|
||||
/* Maximum password length for smb_nt_encrypt() is 128 characters, which
|
||||
* does not include the terminating NUL byte. The password provided
|
||||
* will not be changed prior to encryption.
|
||||
*/
|
||||
smb_nt_encrypt(server->mount_data.password,server->crypt_key,unicode_password);
|
||||
unicode_password_len = 24;
|
||||
|
||||
/*
|
||||
PRINTHEADER();
|
||||
PRINTF(("unicode_password: "));
|
||||
for(i = 0 ; i < 24 ; i++)
|
||||
PRINTF(("%02lx ",unicode_password[i]));
|
||||
PRINTF(("\n"));
|
||||
*/
|
||||
|
||||
/*
|
||||
PRINTHEADER();
|
||||
PRINTF(("crypt_key: "));
|
||||
for(i = 0 ; i < server->crypt_key_length ; i++)
|
||||
PRINTF(("%02lx ",server->crypt_key[i]));
|
||||
PRINTF(("\n"));
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4644,7 +4627,10 @@ smb_proc_reconnect (struct smb_server *server, int * error_ptr)
|
||||
p += oem_password_len;
|
||||
|
||||
/* User name must be NUL-terminated. */
|
||||
memcpy (p, server->mount_data.username, user_len+1);
|
||||
if(user_len > 0)
|
||||
memcpy (p, server->mount_data.username, user_len+1);
|
||||
else
|
||||
(*p) = 0;
|
||||
}
|
||||
|
||||
result = smb_request_ok (server, SMBsesssetupX, 3, 0, error_ptr);
|
||||
|
||||
@@ -56,8 +56,8 @@ VERSION = 2
|
||||
OPTIMIZE = optimize opttime optinline optinlocal
|
||||
CPU = any
|
||||
#CPU = 060 optschedule
|
||||
#DEBUG = line
|
||||
DEBUG = symbolflush noopt define=DEBUG define=DUMP_SMB
|
||||
DEBUG = line
|
||||
#DEBUG = symbolflush noopt define=DEBUG define=DUMP_SMB
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
@@ -1805,6 +1805,8 @@ smba_start(
|
||||
int * error_ptr,
|
||||
int * smb_error_class_ptr,
|
||||
int * smb_error_ptr,
|
||||
smba_connect_parameters_t *
|
||||
smba_connect_par,
|
||||
smba_server_t ** smba_server_ptr)
|
||||
{
|
||||
smba_connect_parameters_t par;
|
||||
@@ -2073,6 +2075,9 @@ smba_start(
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(smba_connect_par != NULL)
|
||||
(*smba_connect_par) = par;
|
||||
|
||||
(*smba_server_ptr) = the_server;
|
||||
|
||||
result = 0;
|
||||
|
||||
@@ -133,7 +133,7 @@ int smba_rmdir(smba_server_t *s, const char *path, int *error_ptr);
|
||||
int smba_rename(smba_server_t *s, const char *from, const char *to, int *error_ptr);
|
||||
int smba_statfs(smba_server_t *s, long *bsize, long *blocks, long *bfree, int *error_ptr);
|
||||
void smb_invalidate_all_inodes(struct smb_server *server);
|
||||
int smba_start(const char *service, const char *opt_workgroup, const char *opt_username, const char *opt_password, const char *opt_clientname, const char *opt_servername, int opt_cachesize, int opt_max_transmit, int opt_timeout, int opt_raw_smb, int opt_unicode, int opt_prefer_core_protocol, int opt_case_sensitive, int opt_session_setup_delay_unicode, int opt_write_behind, int *error_ptr, int *smb_error_class_ptr, int *smb_error_ptr, smba_server_t **smba_server_ptr);
|
||||
int smba_start(const char *service, const char *opt_workgroup, const char *opt_username, const char *opt_password, const char *opt_clientname, const char *opt_servername, int opt_cachesize, int opt_max_transmit, int opt_timeout, int opt_raw_smb, int opt_unicode, int opt_prefer_core_protocol, int opt_case_sensitive, int opt_session_setup_delay_unicode, int opt_write_behind, int *error_ptr, int *smb_error_class_ptr, int *smb_error_ptr, smba_connect_parameters_t *smba_connect_par, smba_server_t **smba_server_ptr);
|
||||
int smba_get_dircache_size(struct smba_server *server);
|
||||
int smba_change_dircache_size(struct smba_server *server, int cache_size);
|
||||
|
||||
|
||||
+2
-2
@@ -159,8 +159,8 @@ size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern void smb_encrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
|
||||
extern void smb_nt_encrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
|
||||
extern void smb_encrypt(unsigned char *passwd, const unsigned char *c8, unsigned char *p24);
|
||||
extern void smb_nt_encrypt(const unsigned char *passwd, const unsigned char *c8, unsigned char *p24);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 2
|
||||
#define REVISION 2
|
||||
#define DATE "1.12.2018"
|
||||
#define VERS "smbfs 2.2"
|
||||
#define VSTRING "smbfs 2.2 (1.12.2018)\r\n"
|
||||
#define VERSTAG "\0$VER: smbfs 2.2 (1.12.2018)"
|
||||
#define REVISION 3
|
||||
#define DATE "8.12.2018"
|
||||
#define VERS "smbfs 2.3"
|
||||
#define VSTRING "smbfs 2.3 (8.12.2018)\r\n"
|
||||
#define VERSTAG "\0$VER: smbfs 2.3 (8.12.2018)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
2
|
||||
3
|
||||
|
||||
Reference in New Issue
Block a user