summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-03 17:22:04 -0600
committerStefan Metzmacher <metze@samba.org>2008-01-03 12:33:36 -0600
commit6f79af9d13cb400506e05f20fb68c7f97daccf38 (patch)
tree97855c54cc65fc5af21c210f43aeb6d773886e94
parent425732f688865ebe2bfe568c8278edec50cbdedf (diff)
downloadsamba-6f79af9d13cb400506e05f20fb68c7f97daccf38.tar.gz
samba-6f79af9d13cb400506e05f20fb68c7f97daccf38.tar.bz2
samba-6f79af9d13cb400506e05f20fb68c7f97daccf38.zip
r26652: msrpc_parse/msrpc_gen: Add iconv_convenience argument.
(This used to be commit e886f1bc0dc694971979716d1991535c7d2e08de)
-rw-r--r--source4/auth/ntlmssp/ntlmssp.c1
-rw-r--r--source4/auth/ntlmssp/ntlmssp_client.c4
-rw-r--r--source4/auth/ntlmssp/ntlmssp_parse.c20
-rw-r--r--source4/auth/ntlmssp/ntlmssp_server.c8
-rw-r--r--source4/auth/ntlmssp/ntlmssp_sign.c9
-rw-r--r--source4/libcli/auth/smbencrypt.c5
6 files changed, 34 insertions, 13 deletions
diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c
index efb1e63047..4f5822567a 100644
--- a/source4/auth/ntlmssp/ntlmssp.c
+++ b/source4/auth/ntlmssp/ntlmssp.c
@@ -157,6 +157,7 @@ static NTSTATUS gensec_ntlmssp_update_find(struct gensec_ntlmssp_state *gensec_n
}
} else {
if (!msrpc_parse(gensec_ntlmssp_state,
+ lp_iconv_convenience(gensec_security->lp_ctx),
&input, "Cd",
"NTLMSSP",
&ntlmssp_command)) {
diff --git a/source4/auth/ntlmssp/ntlmssp_client.c b/source4/auth/ntlmssp/ntlmssp_client.c
index 53b52ae701..e07c64befb 100644
--- a/source4/auth/ntlmssp/ntlmssp_client.c
+++ b/source4/auth/ntlmssp/ntlmssp_client.c
@@ -62,6 +62,7 @@ NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
/* generate the ntlmssp negotiate packet */
msrpc_gen(out_mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
out, "CddAA",
"NTLMSSP",
NTLMSSP_NEGOTIATE,
@@ -111,6 +112,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
}
if (!msrpc_parse(mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
&in, "CdBd",
"NTLMSSP",
&ntlmssp_command,
@@ -148,6 +150,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
}
if (!msrpc_parse(mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
&in, chal_parse_string,
"NTLMSSP",
&ntlmssp_command,
@@ -244,6 +247,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
/* this generates the actual auth packet */
if (!msrpc_gen(mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
out, auth_gen_string,
"NTLMSSP",
NTLMSSP_AUTH,
diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c
index bb2d7a14a8..8e31d814d0 100644
--- a/source4/auth/ntlmssp/ntlmssp_parse.c
+++ b/source4/auth/ntlmssp/ntlmssp_parse.c
@@ -41,7 +41,9 @@
d = word (4 bytes)
C = constant ascii string
*/
-bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
+bool msrpc_gen(TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ DATA_BLOB *blob,
const char *format, ...)
{
int i;
@@ -65,7 +67,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
case 'U':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ucs2_talloc(pointers, lp_iconv_convenience(global_loadparm), (void **)&pointers[i].data, s);
+ n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
if (n == -1) {
return false;
}
@@ -76,7 +78,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
case 'A':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ascii_talloc(pointers, lp_iconv_convenience(global_loadparm), (char **)&pointers[i].data, s);
+ n = push_ascii_talloc(pointers, iconv_convenience, (char **)&pointers[i].data, s);
if (n == -1) {
return false;
}
@@ -88,7 +90,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
n = va_arg(ap, int);
intargs[i] = n;
s = va_arg(ap, char *);
- n = push_ucs2_talloc(pointers, lp_iconv_convenience(global_loadparm), (void **)&pointers[i].data, s);
+ n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
if (n == -1) {
return false;
}
@@ -199,7 +201,9 @@ if ((head_ofs + amount) > blob->length) { \
C = constant ascii string
*/
-bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
+bool msrpc_parse(TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ const DATA_BLOB *blob,
const char *format, ...)
{
int i;
@@ -244,7 +248,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
}
if (0 < len1) {
- pull_string(lp_iconv_convenience(global_loadparm), p, blob->data + ptr, p_len,
+ pull_string(iconv_convenience, p, blob->data + ptr, p_len,
len1, STR_UNICODE|STR_NOALIGN);
(*ps) = talloc_strdup(mem_ctx, p);
if (!(*ps)) {
@@ -279,7 +283,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
}
if (0 < len1) {
- pull_string(lp_iconv_convenience(global_loadparm), p, blob->data + ptr, p_len,
+ pull_string(iconv_convenience, p, blob->data + ptr, p_len,
len1, STR_ASCII|STR_NOALIGN);
(*ps) = talloc_strdup(mem_ctx, p);
if (!(*ps)) {
@@ -344,7 +348,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
goto cleanup;
}
- head_ofs += pull_string(lp_iconv_convenience(global_loadparm), p,
+ head_ofs += pull_string(iconv_convenience, p,
blob->data+head_ofs, p_len,
blob->length - head_ofs,
STR_ASCII|STR_TERMINATE);
diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c
index 1ee05cf66a..eb6dbc5bca 100644
--- a/source4/auth/ntlmssp/ntlmssp_server.c
+++ b/source4/auth/ntlmssp/ntlmssp_server.c
@@ -136,7 +136,9 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
#endif
if (in.length) {
- if ((in.length < 16) || !msrpc_parse(out_mem_ctx, &in, "Cdd",
+ if ((in.length < 16) || !msrpc_parse(out_mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
+ &in, "Cdd",
"NTLMSSP",
&ntlmssp_command,
&neg_flags)) {
@@ -201,6 +203,7 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
}
msrpc_gen(out_mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
&struct_blob, "aaaaa",
NTLMSSP_NAME_TYPE_DOMAIN, target_name,
NTLMSSP_NAME_TYPE_SERVER, gensec_ntlmssp_state->server_name,
@@ -221,6 +224,7 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
}
msrpc_gen(out_mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
out, gen_string,
"NTLMSSP",
NTLMSSP_CHALLENGE,
@@ -278,6 +282,7 @@ static NTSTATUS ntlmssp_server_preauth(struct gensec_ntlmssp_state *gensec_ntlms
/* now the NTLMSSP encoded auth hashes */
if (!msrpc_parse(gensec_ntlmssp_state,
+ lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
&request, parse_string,
"NTLMSSP",
&ntlmssp_command,
@@ -304,6 +309,7 @@ static NTSTATUS ntlmssp_server_preauth(struct gensec_ntlmssp_state *gensec_ntlms
/* now the NTLMSSP encoded auth hashes */
if (!msrpc_parse(gensec_ntlmssp_state,
+ lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
&request, parse_string,
"NTLMSSP",
&ntlmssp_command,
diff --git a/source4/auth/ntlmssp/ntlmssp_sign.c b/source4/auth/ntlmssp/ntlmssp_sign.c
index dd8dd450c8..b003dc865f 100644
--- a/source4/auth/ntlmssp/ntlmssp_sign.c
+++ b/source4/auth/ntlmssp/ntlmssp_sign.c
@@ -26,6 +26,7 @@
#include "lib/crypto/crypto.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
#define CLI_SIGN "session key to client-to-server signing key magic constant"
#define CLI_SEAL "session key to client-to-server sealing key magic constant"
@@ -117,7 +118,9 @@ static NTSTATUS ntlmssp_make_packet_signature(struct gensec_ntlmssp_state *gense
} else {
uint32_t crc;
crc = crc32_calc_buffer(data, length);
- if (!msrpc_gen(sig_mem_ctx, sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
+ if (!msrpc_gen(sig_mem_ctx,
+ lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
+ sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
return NT_STATUS_NO_MEMORY;
}
gensec_ntlmssp_state->crypt.ntlm.seq_num++;
@@ -244,7 +247,9 @@ NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
} else {
uint32_t crc;
crc = crc32_calc_buffer(data, length);
- if (!msrpc_gen(sig_mem_ctx, sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
+ if (!msrpc_gen(sig_mem_ctx,
+ lp_iconv_convenience(gensec_security->lp_ctx),
+ sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c
index 26b78d25ef..4ccf568d8c 100644
--- a/source4/libcli/auth/smbencrypt.c
+++ b/source4/libcli/auth/smbencrypt.c
@@ -299,7 +299,8 @@ DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx,
{
DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0);
- msrpc_gen(mem_ctx, &names_blob, "aaa",
+ msrpc_gen(mem_ctx, lp_iconv_convenience(global_loadparm), &names_blob,
+ "aaa",
NTLMSSP_NAME_TYPE_DOMAIN, domain,
NTLMSSP_NAME_TYPE_SERVER, hostname,
0, "");
@@ -321,7 +322,7 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO
/* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */
- msrpc_gen(mem_ctx, &response, "ddbbdb",
+ msrpc_gen(mem_ctx, NULL, &response, "ddbbdb",
0x00000101, /* Header */
0, /* 'Reserved' */
long_date, 8, /* Timestamp */