summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-06-07 12:41:04 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-06-07 12:41:04 +0000
commitd5154cb241e38106994a76806f7968619b5ec270 (patch)
tree231a1c77f5f7705bb5546e118ca086a83b2ce0c0 /source3/libsmb
parent19c0588ea1613ae251e83c7064747fb4d0f61f04 (diff)
downloadsamba-d5154cb241e38106994a76806f7968619b5ec270.tar.gz
samba-d5154cb241e38106994a76806f7968619b5ec270.tar.bz2
samba-d5154cb241e38106994a76806f7968619b5ec270.zip
A couple of updates for the SmbEncrypt code, and some of its users.
(const, takes unix string as arg) Also update cli_full_connection to take NULL pointers as 'undefined' correctly, and therefore do its own lookup etc. This what was intended, but previously you needed to supply a 0.0.0.0 IP address. Andrew Bartlett (This used to be commit 8fb1a9c6ba07dbf04a6aa1e30fa7bbd4c676ed28)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/cliconnect.c44
-rw-r--r--source3/libsmb/smbencrypt.c2
2 files changed, 32 insertions, 14 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 86daafc50b..ebd25627c1 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -659,7 +659,7 @@ BOOL cli_ulogoff(struct cli_state *cli)
BOOL cli_send_tconX(struct cli_state *cli,
const char *share, const char *dev, const char *pass, int passlen)
{
- fstring fullshare, pword, dos_pword;
+ fstring fullshare, pword;
char *p;
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
@@ -677,8 +677,7 @@ BOOL cli_send_tconX(struct cli_state *cli,
* Non-encrypted passwords - convert to DOS codepage before encryption.
*/
passlen = 24;
- clistr_push(cli, dos_pword, pass, -1, STR_TERMINATE);
- SMBencrypt((uchar *)dos_pword,cli->secblob.data,(uchar *)pword);
+ SMBencrypt(pass,cli->secblob.data,(uchar *)pword);
} else {
if((cli->sec_mode & (NEGOTIATE_SECURITY_USER_LEVEL|NEGOTIATE_SECURITY_CHALLENGE_RESPONSE)) == 0) {
/*
@@ -1062,9 +1061,18 @@ static void init_creds(struct ntuser_creds *creds, char* username,
}
}
-/****************************************************************************
- Establishes a connection right up to doing tconX, password specified.
-****************************************************************************/
+/**
+ establishes a connection right up to doing tconX, password specified.
+ @param output_cli A fully initialised cli structure, non-null only on success
+ @param dest_host The netbios name of the remote host
+ @param dest_ip (optional) The the destination IP, NULL for name based lookup
+ @param port (optional) The destination port (0 for default)
+ @param service The share to make the connection to. Should be 'unqualified' in any way.
+ @param service_type The 'type' of serivice.
+ @param user Username, unix string
+ @param domain User's domain
+ @param password User's password, unencrypted unix string.
+*/
NTSTATUS cli_full_connection(struct cli_state **output_cli,
const char *my_name, const char *dest_host,
@@ -1079,17 +1087,21 @@ NTSTATUS cli_full_connection(struct cli_state **output_cli,
struct nmb_name called;
struct cli_state *cli;
struct in_addr ip;
-
- if (!output_cli)
+ extern pstring global_myname;
+
+ if (!output_cli) {
DEBUG(0, ("output_cli is NULL!?!"));
+ SMB_ASSERT("output_cli for cli_full_connection was NULL.\n");
+ }
*output_cli = NULL;
+
+ if (!my_name)
+ my_name = global_myname;
make_nmb_name(&calling, my_name, 0x0);
make_nmb_name(&called , dest_host, 0x20);
-again:
-
if (!(cli = cli_initialise(NULL)))
return NT_STATUS_NO_MEMORY;
@@ -1098,13 +1110,19 @@ again:
return NT_STATUS_UNSUCCESSFUL;
}
- ip = *dest_ip;
-
+ if (dest_ip) {
+ ip = *dest_ip;
+ } else {
+ ZERO_STRUCT(ip);
+ }
+
+again:
+
DEBUG(3,("Connecting to host=%s share=%s\n", dest_host, service));
if (!cli_connect(cli, dest_host, &ip)) {
DEBUG(1,("cli_full_connection: failed to connect to %s (%s)\n",
- nmb_namestr(&called), inet_ntoa(*dest_ip)));
+ nmb_namestr(&called), inet_ntoa(ip)));
cli_shutdown(cli);
return NT_STATUS_UNSUCCESSFUL;
}
diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c
index c298616220..fa1eaedb5a 100644
--- a/source3/libsmb/smbencrypt.c
+++ b/source3/libsmb/smbencrypt.c
@@ -28,7 +28,7 @@
This implements the X/Open SMB password encryption
It takes a password ('unix' string), a 8 byte "crypt key"
and puts 24 bytes of encrypted password into p24 */
-void SMBencrypt(const uchar *passwd, const uchar *c8, uchar *p24)
+void SMBencrypt(const char *passwd, const uchar *c8, uchar *p24)
{
uchar p21[21];