[SCM] Samba Shared Repository - branch master updated -
57a60f0920e77e26a3ce7f5d43540904ee4cbd8e
Jelmer Vernooij
jelmer at samba.org
Sat Nov 1 21:24:20 GMT 2008
The branch, master has been updated
via 57a60f0920e77e26a3ce7f5d43540904ee4cbd8e (commit)
via 3a6b88f9f91c74785444741e8a002bc901055f66 (commit)
via fa7bb8ac533e69c3f66541dedbb3e9708e15fa3e (commit)
via 4b74b22c4d034c8c5c018ea3bca4bb3dc364524e (commit)
via e5081d6dad3924ac0a816878a6af5266f87bbfb7 (commit)
from 7bdb571ec4eea6689fa08f40be8b4c0133504f50 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 57a60f0920e77e26a3ce7f5d43540904ee4cbd8e
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Nov 1 22:13:47 2008 +0100
Move lp_*() calls a bit higher up the calls tack.
commit 3a6b88f9f91c74785444741e8a002bc901055f66
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Nov 1 20:58:41 2008 +0100
Remove unused argument iconv_convenience.
commit fa7bb8ac533e69c3f66541dedbb3e9708e15fa3e
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Nov 1 20:56:27 2008 +0100
Remove convert_string_talloc_descriptor, add iconv_talloc().
commit 4b74b22c4d034c8c5c018ea3bca4bb3dc364524e
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Nov 1 20:46:04 2008 +0100
Remove IS_DOT and IS_DOTDOT macros, already provided by libreplace or
the system.
commit e5081d6dad3924ac0a816878a6af5266f87bbfb7
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Nov 1 20:44:12 2008 +0100
Move ABS() to libutil.
-----------------------------------------------------------------------
Summary of changes:
lib/util/charset/charcnv.c | 130 ++++++++++++++++++--------------
lib/util/charset/charset.h | 6 +-
lib/util/dprintf.c | 2 +-
lib/util/util.h | 4 +
source3/include/smb_macros.h | 32 --------
source4/auth/ntlmssp/ntlmssp.c | 1 -
source4/auth/ntlmssp/ntlmssp_client.c | 2 -
source4/auth/ntlmssp/ntlmssp_parse.c | 3 +-
source4/auth/ntlmssp/ntlmssp_server.c | 3 -
source4/client/client.c | 9 ++-
source4/libcli/cliconnect.c | 6 +-
source4/libcli/raw/clisocket.c | 14 ++-
source4/libcli/raw/libcliraw.h | 3 +-
source4/libcli/smb2/connect.c | 3 +-
source4/libcli/smb_composite/connect.c | 4 +-
source4/libcli/swig/libcli_smb.i | 3 +-
source4/libcli/swig/libcli_smb_wrap.c | 20 ++++-
source4/torture/basic/base.c | 3 +-
18 files changed, 129 insertions(+), 119 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c
index 9dd68f0..1f3b1ac 100644
--- a/lib/util/charset/charcnv.c
+++ b/lib/util/charset/charcnv.c
@@ -155,71 +155,21 @@ static smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic,
return ic->conv_handles[from][to];
}
-
/**
* Convert string from one encoding to another, making error checking etc
*
+ * @param mem_ctx Memory context
+ * @param cd Iconv handle
* @param src pointer to source string (multibyte or singlebyte)
* @param srclen length of the source string in bytes
* @param dest pointer to destination string (multibyte or singlebyte)
* @param destlen maximal length allowed for string
* @returns the number of bytes occupied in the destination
**/
-_PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
- charset_t from, charset_t to,
- void const *src, size_t srclen,
- void *dest, size_t destlen)
-{
- size_t i_len, o_len;
- size_t retval;
- const char* inbuf = (const char*)src;
- char* outbuf = (char*)dest;
- smb_iconv_t descriptor;
-
- if (srclen == (size_t)-1)
- srclen = strlen(inbuf)+1;
-
- descriptor = get_conv_handle(ic, from, to);
-
- if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
- /* conversion not supported, use as is */
- size_t len = MIN(srclen,destlen);
- memcpy(dest,src,len);
- return len;
- }
-
- i_len=srclen;
- o_len=destlen;
- retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len);
- if(retval==(size_t)-1) {
- const char *reason;
- switch(errno) {
- case EINVAL:
- reason="Incomplete multibyte sequence";
- return -1;
- case E2BIG:
- reason="No more room";
- if (from == CH_UNIX) {
- DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d - '%s'\n",
- charset_name(ic, from), charset_name(ic, to),
- (int)srclen, (int)destlen,
- (const char *)src));
- } else {
- DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d\n",
- charset_name(ic, from), charset_name(ic, to),
- (int)srclen, (int)destlen));
- }
- return -1;
- case EILSEQ:
- reason="Illegal multibyte sequence";
- return -1;
- }
- /* smb_panic(reason); */
- }
- return destlen-o_len;
-}
-
-_PUBLIC_ ssize_t convert_string_talloc_descriptor(TALLOC_CTX *ctx, smb_iconv_t descriptor, void const *src, size_t srclen, void **dest)
+_PUBLIC_ ssize_t iconv_talloc(TALLOC_CTX *ctx,
+ smb_iconv_t cd,
+ void const *src, size_t srclen,
+ void **dest)
{
size_t i_len, o_len, destlen;
size_t retval;
@@ -247,7 +197,7 @@ convert:
end */
i_len = srclen;
o_len = destlen-2;
- retval = smb_iconv(descriptor,
+ retval = smb_iconv(cd,
&inbuf, &i_len,
&outbuf, &o_len);
if(retval == (size_t)-1) {
@@ -275,9 +225,73 @@ convert:
*dest = ob;
return destlen;
+
}
/**
+ * Convert string from one encoding to another, making error checking etc
+ *
+ * @param src pointer to source string (multibyte or singlebyte)
+ * @param srclen length of the source string in bytes
+ * @param dest pointer to destination string (multibyte or singlebyte)
+ * @param destlen maximal length allowed for string
+ * @returns the number of bytes occupied in the destination
+ **/
+_PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
+ charset_t from, charset_t to,
+ void const *src, size_t srclen,
+ void *dest, size_t destlen)
+{
+ size_t i_len, o_len;
+ size_t retval;
+ const char* inbuf = (const char*)src;
+ char* outbuf = (char*)dest;
+ smb_iconv_t descriptor;
+
+ if (srclen == (size_t)-1)
+ srclen = strlen(inbuf)+1;
+
+ descriptor = get_conv_handle(ic, from, to);
+
+ if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
+ /* conversion not supported, use as is */
+ size_t len = MIN(srclen,destlen);
+ memcpy(dest,src,len);
+ return len;
+ }
+
+ i_len=srclen;
+ o_len=destlen;
+ retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len);
+ if(retval==(size_t)-1) {
+ const char *reason;
+ switch(errno) {
+ case EINVAL:
+ reason="Incomplete multibyte sequence";
+ return -1;
+ case E2BIG:
+ reason="No more room";
+ if (from == CH_UNIX) {
+ DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d - '%s'\n",
+ charset_name(ic, from), charset_name(ic, to),
+ (int)srclen, (int)destlen,
+ (const char *)src));
+ } else {
+ DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d\n",
+ charset_name(ic, from), charset_name(ic, to),
+ (int)srclen, (int)destlen));
+ }
+ return -1;
+ case EILSEQ:
+ reason="Illegal multibyte sequence";
+ return -1;
+ }
+ /* smb_panic(reason); */
+ }
+ return destlen-o_len;
+}
+
+/**
* Convert between character sets, allocating a new buffer using talloc for the result.
*
* @param srclen length of source buffer.
@@ -310,7 +324,7 @@ _PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
return -1;
}
- return convert_string_talloc_descriptor(ctx, descriptor, src, srclen, dest);
+ return iconv_talloc(ctx, descriptor, src, srclen, dest);
}
/*
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index cace79f..b69bef2 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -122,6 +122,11 @@ ssize_t convert_string(charset_t from, charset_t to,
void const *src, size_t srclen,
void *dest, size_t destlen);
+ssize_t iconv_talloc(TALLOC_CTX *mem_ctx,
+ smb_iconv_t cd,
+ void const *src, size_t srclen,
+ void **dest);
+
extern struct smb_iconv_convenience *global_iconv_convenience;
codepoint_t next_codepoint(const char *str, size_t *size);
@@ -145,7 +150,6 @@ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
void const *src, size_t srclen,
void *dest, size_t destlen);
-ssize_t convert_string_talloc_descriptor(TALLOC_CTX *ctx, smb_iconv_t descriptor, void const *src, size_t srclen, void **dest);
ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
diff --git a/lib/util/dprintf.c b/lib/util/dprintf.c
index e4f0275..3e6d0e8 100644
--- a/lib/util/dprintf.c
+++ b/lib/util/dprintf.c
@@ -60,7 +60,7 @@ _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap)
if (ret <= 0) return ret;
- clen = convert_string_talloc_descriptor(NULL, display_cd, p, ret, (void **)&p2);
+ clen = iconv_talloc(NULL, display_cd, p, ret, (void **)&p2);
if (clen == -1) {
/* the string can't be converted - do the best we can,
filling in non-printing chars with '?' */
diff --git a/lib/util/util.h b/lib/util/util.h
index 0f09747..ec1cfef 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -67,6 +67,10 @@ size_t valgrind_strlen(const char *s);
#endif
#endif
+#ifndef ABS
+#define ABS(a) ((a)>0?(a):(-(a)))
+#endif
+
#include "../lib/util/memory.h"
/**
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 668dc18..89d8994 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -34,19 +34,6 @@
#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0)
#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0)
-#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */
-
-/**
- * Free memory if the pointer and zero the pointer.
- *
- * @note You are explicitly allowed to pass NULL pointers -- they will
- * always be ignored.
- **/
-#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
-#endif
-
-
-
#define SMB_WARN(condition, message) \
((condition) ? (void)0 : \
DEBUG(0, ("WARNING: %s: %s\n", #condition, message)))
@@ -105,17 +92,6 @@
#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_mode))
#define SET_STAT_INVALID(st) ((st).st_nlink = 0)
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-#ifndef MAX
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#endif
-
-#ifndef ABS
-#define ABS(a) ((a)>0?(a):(-(a)))
-#endif
-
/* Macros to get at offsets within smb_lkrng and smb_unlkrng
structures. We cannot define these as actual structures
due to possible differences in structure packing
@@ -351,14 +327,6 @@ do { \
#define ADD_TO_LARGE_ARRAY(mem_ctx, type, elem, array, num, size) \
add_to_large_array((mem_ctx), sizeof(type), &(elem), (void *)(array), (num), (size));
-#ifndef ISDOT
-#define ISDOT(p) (*(p) == '.' && *((p) + 1) == '\0')
-#endif /* ISDOT */
-
-#ifndef ISDOTDOT
-#define ISDOTDOT(p) (*(p) == '.' && *((p) + 1) == '.' && *((p) + 2) == '\0')
-#endif /* ISDOTDOT */
-
#ifndef toupper_ascii_fast
/* Warning - this must only be called with 0 <= c < 128. IT WILL
* GIVE GARBAGE if c > 128 or c < 0. JRA.
diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c
index cea18c4..1b14e46 100644
--- a/source4/auth/ntlmssp/ntlmssp.c
+++ b/source4/auth/ntlmssp/ntlmssp.c
@@ -159,7 +159,6 @@ 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 0ef4020..31da9fc 100644
--- a/source4/auth/ntlmssp/ntlmssp_client.c
+++ b/source4/auth/ntlmssp/ntlmssp_client.c
@@ -122,7 +122,6 @@ 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,
@@ -160,7 +159,6 @@ 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,
diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c
index 24f3ad2..d606b8d 100644
--- a/source4/auth/ntlmssp/ntlmssp_parse.c
+++ b/source4/auth/ntlmssp/ntlmssp_parse.c
@@ -186,7 +186,7 @@ if ((head_ofs + amount) > blob->length) { \
return false; \
}
-/*
+/**
this is a tiny msrpc packet parser. This the the partner of msrpc_gen
format specifiers are:
@@ -200,7 +200,6 @@ if ((head_ofs + amount) > blob->length) { \
*/
bool msrpc_parse(TALLOC_CTX *mem_ctx,
- struct smb_iconv_convenience *iconv_convenience,
const DATA_BLOB *blob,
const char *format, ...)
{
diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c
index 38973f6..cb336d5 100644
--- a/source4/auth/ntlmssp/ntlmssp_server.c
+++ b/source4/auth/ntlmssp/ntlmssp_server.c
@@ -136,7 +136,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
if (in.length) {
if ((in.length < 16) || !msrpc_parse(out_mem_ctx,
- lp_iconv_convenience(gensec_security->lp_ctx),
&in, "Cdd",
"NTLMSSP",
&ntlmssp_command,
@@ -282,7 +281,6 @@ 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,
@@ -309,7 +307,6 @@ 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/client/client.c b/source4/client/client.c
index 02f4685..8936a3c 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -3102,7 +3102,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options,
- struct smb_iconv_convenience *iconv_convenience)
+ struct smb_iconv_convenience *iconv_convenience,
+ const char *socket_options)
{
struct nbt_name called, calling;
const char *server_name;
@@ -3117,7 +3118,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
if (!(cli = smbcli_state_init(NULL)) ||
!smbcli_socket_connect(cli, server_name, destports,
ev_ctx, resolve_ctx, options,
- iconv_convenience)) {
+ iconv_convenience,
+ socket_options)) {
d_printf("Connection to %s failed\n", server_name);
return 1;
}
@@ -3270,7 +3272,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
lp_smb_ports(cmdline_lp_ctx), dest_ip,
name_type, ev_ctx,
lp_resolve_context(cmdline_lp_ctx),
- &smb_options, lp_iconv_convenience(cmdline_lp_ctx));
+ &smb_options, lp_iconv_convenience(cmdline_lp_ctx),
+ lp_socket_options(cmdline_lp_ctx));
return rc;
}
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index e1f5e9a..6f58cfa 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -35,12 +35,14 @@ bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options,
- struct smb_iconv_convenience *iconv_convenience)
+ struct smb_iconv_convenience *iconv_convenience,
+ const char *socket_options)
{
struct smbcli_socket *sock;
sock = smbcli_sock_connect_byname(server, ports, NULL,
- resolve_ctx, ev_ctx);
+ resolve_ctx, ev_ctx,
+ socket_options);
if (sock == NULL) return false;
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index d51ffba..1fbbfe3 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -50,7 +50,8 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
const char **ports,
const char *host_name,
struct resolve_context *resolve_ctx,
- struct event_context *event_ctx)
+ struct event_context *event_ctx,
+ const char *socket_options)
{
struct composite_context *result, *ctx;
struct sock_connect_state *state;
@@ -77,7 +78,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
for (i=0;ports[i];i++) {
state->ports[i] = atoi(ports[i]);
}
- state->socket_options = lp_socket_options(global_loadparm);
+ state->socket_options = talloc_reference(state, socket_options);
ctx = socket_connect_multi_send(state, host_addr,
state->num_ports, state->ports,
@@ -153,12 +154,13 @@ NTSTATUS smbcli_sock_connect(TALLOC_CTX *mem_ctx,
const char *host_name,
struct resolve_context *resolve_ctx,
struct event_context *event_ctx,
+ const char *socket_options,
struct smbcli_socket **result)
{
struct composite_context *c =
smbcli_sock_connect_send(mem_ctx, host_addr, ports, host_name,
resolve_ctx,
- event_ctx);
+ event_ctx, socket_options);
return smbcli_sock_connect_recv(c, mem_ctx, result);
}
@@ -188,7 +190,8 @@ resolve a hostname and connect
_PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
TALLOC_CTX *mem_ctx,
struct resolve_context *resolve_ctx,
- struct event_context *event_ctx)
+ struct event_context *event_ctx,
+ const char *socket_options)
{
int name_type = NBT_NAME_SERVER;
const char *address;
@@ -230,7 +233,8 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
}
status = smbcli_sock_connect(mem_ctx, address, ports, name, resolve_ctx,
- event_ctx, &result);
+ event_ctx,
+ socket_options, &result);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(9, ("smbcli_sock_connect failed: %s\n",
diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h
index 98f18b1..ccd8681 100644
--- a/source4/libcli/raw/libcliraw.h
+++ b/source4/libcli/raw/libcliraw.h
@@ -376,7 +376,8 @@ NTSTATUS smb_raw_trans(struct smbcli_tree *tree,
struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
TALLOC_CTX *mem_ctx,
struct resolve_context *resolve_ctx,
- struct event_context *event_ctx);
+ struct event_context *event_ctx,
+ const char *socket_options);
void smbcli_sock_dead(struct smbcli_socket *sock);
#endif /* __LIBCLI_RAW__H__ */
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index bbfcf01..67d98cf 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -137,7 +137,6 @@ static void continue_negprot(struct smb2_request *req)
}
break;
}
-
--
Samba Shared Repository
More information about the samba-cvs
mailing list