From 1394248a101b058ed860abe9826be5f71bfe421d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 29 Jan 2003 02:54:36 +0000 Subject: Quieten debug about gencache.tdb not being able to be opened. Perhaps we should try to open O_RDONLY if O_RDWR fails? (This used to be commit 1e7236371d2b766b161acbb0c950cd3bb4a6ede7) --- source3/lib/gencache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index a844d8c014..2c356d24e8 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -67,7 +67,7 @@ BOOL gencache_init(void) SAFE_FREE(cache_fname); if (!cache) { - DEBUG(0, ("Attempt to open the cache file has failed.\n")); + DEBUG(5, ("Attempt to open gencache.tdb has failed.\n")); return False; } return True; -- cgit From 308efc0337edfe6f7eff1d087ee09819497ca7ad Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 29 Jan 2003 02:55:39 +0000 Subject: Return 0 instead of crashing when a NULL source string is passed to rpcstr_pull() (This used to be commit b9c4cc119588d6a564f0aaf12fd2ef867a42aeb8) --- source3/lib/util_unistr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib') diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 8e41581f75..5c9b4c783b 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -169,6 +169,7 @@ char *skip_unibuf(char *src, size_t len) */ int rpcstr_pull(char* dest, void *src, int dest_len, int src_len, int flags) { + if (!src) return 0; if(dest_len==-1) dest_len=MAXUNI-3; return pull_ucs2(NULL, dest, src, dest_len, src_len, flags|STR_UNICODE|STR_NOALIGN); } -- cgit From ffaaa7a5af9c772f460dc4995df5269b62290831 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 29 Jan 2003 05:16:16 +0000 Subject: Removed duplicate fn to avoid compiler warning. (This used to be commit 55d268fdd67e42244128dae8614d0e4aa2eb2da2) --- source3/lib/debug.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 83a470872a..223bf8ebc2 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -467,25 +467,6 @@ void debug_message_send(pid_t pid, const char *params_str) False); } - -/**************************************************************************** - Return current debug level. -****************************************************************************/ - -static void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len) -{ - char *debug_level_classes; - DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %u\n",(unsigned int)src)); - - if ((debug_level_classes = debug_list_class_names_and_levels())) { - /*{ debug_level_classes = "test:1000";*/ - message_send_pid(src, MSG_DEBUGLEVEL, debug_level_classes, strlen(debug_level_classes) + 1, True); - SAFE_FREE(debug_level_classes); - } else { - DEBUG(0, ("debuglevel_message: error retrieving class levels!\n")); - } -} - /**************************************************************************** Init debugging (one time stuff) ****************************************************************************/ -- cgit From 0310697963dd248504d1bf4c0bd4d98a5086bb14 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 30 Jan 2003 04:00:28 +0000 Subject: Move debug level message handling into debug.c from messages.c Removed duplicate message_register() for REQ_DEBUGLEVEL message. (This used to be commit 6fee7196d695ca813a301b1e6d7da687b7e7bda5) --- source3/lib/debug.c | 14 ++++++++++++++ source3/lib/messages.c | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 223bf8ebc2..dc675037a0 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -467,6 +467,20 @@ void debug_message_send(pid_t pid, const char *params_str) False); } +/**************************************************************************** + Return current debug level. +****************************************************************************/ + +static void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len) +{ + char *message = debug_list_class_names_and_levels(); + + DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %u\n",(unsigned int)src)); + message_send_pid(src, MSG_DEBUGLEVEL, message, strlen(message) + 1, True); + + SAFE_FREE(message); +} + /**************************************************************************** Init debugging (one time stuff) ****************************************************************************/ diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 38c3c411d4..53c9e3d2bc 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -90,16 +90,6 @@ static void ping_message(int msg_type, pid_t src, void *buf, size_t len) message_send_pid(src, MSG_PONG, buf, len, True); } -/**************************************************************************** - Return current debug level. -****************************************************************************/ - -void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len) -{ - DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %u\n",(unsigned int)src)); - message_send_pid(src, MSG_DEBUGLEVEL, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS), True); -} - /**************************************************************************** Initialise the messaging functions. ****************************************************************************/ @@ -120,7 +110,6 @@ BOOL message_init(void) CatchSignal(SIGUSR1, SIGNAL_CAST sig_usr1); message_register(MSG_PING, ping_message); - message_register(MSG_REQ_DEBUGLEVEL, debuglevel_message); return True; } -- cgit From b102e79e751ad2d658d0681061b6d56f1027be66 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 30 Jan 2003 23:55:13 +0000 Subject: Add 3 second timeout when terminating server and sending print notify messages. Stops build-up of large numbers of smbd's waiting to terminate on large print throughput. Jeremy. (This used to be commit 4ae130bfa82be60de6a6f357f65207fcb24f45fb) --- source3/lib/messages.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 53c9e3d2bc..3603758e9f 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -160,8 +160,8 @@ static BOOL message_notify(pid_t pid) Send a message to a particular pid. ****************************************************************************/ -BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, - BOOL duplicates_allowed) +static BOOL message_send_pid_internal(pid_t pid, int msg_type, const void *buf, size_t len, + BOOL duplicates_allowed, unsigned int timeout) { TDB_DATA kbuf; TDB_DATA dbuf; @@ -200,7 +200,17 @@ BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, /* If duplicates are allowed we can just append the message and return. */ /* lock the record for the destination */ - tdb_chainlock(tdb, kbuf); + if (timeout) { + if (tdb_chainlock_with_timeout(tdb, kbuf, timeout) == -1) { + DEBUG(0,("message_send_pid_internal: failed to get chainlock with timeout %ul.\n", timeout)); + return False; + } + } else { + if (tdb_chainlock(tdb, kbuf) == -1) { + DEBUG(0,("message_send_pid_internal: failed to get chainlock.\n")); + return False; + } + } tdb_append(tdb, kbuf, dbuf); tdb_chainunlock(tdb, kbuf); @@ -210,7 +220,18 @@ BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, } /* lock the record for the destination */ - tdb_chainlock(tdb, kbuf); + if (timeout) { + if (tdb_chainlock_with_timeout(tdb, kbuf, timeout) == -1) { + DEBUG(0,("message_send_pid_internal: failed to get chainlock with timeout %ul.\n", timeout)); + return False; + } + } else { + if (tdb_chainlock(tdb, kbuf) == -1) { + DEBUG(0,("message_send_pid_internal: failed to get chainlock.\n")); + return False; + } + } + old_dbuf = tdb_fetch(tdb, kbuf); if (!old_dbuf.dptr) { @@ -236,7 +257,7 @@ BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, if (!memcmp(ptr, &rec, sizeof(rec))) { if (!len || (len && !memcmp( ptr + sizeof(rec), buf, len))) { tdb_chainunlock(tdb, kbuf); - DEBUG(10,("message_send_pid: discarding duplicate message.\n")); + DEBUG(10,("message_send_pid_internal: discarding duplicate message.\n")); SAFE_FREE(dbuf.dptr); SAFE_FREE(old_dbuf.dptr); return True; @@ -258,6 +279,25 @@ BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, return message_notify(pid); } +/**************************************************************************** + Send a message to a particular pid - no timeout. +****************************************************************************/ + +BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, BOOL duplicates_allowed) +{ + return message_send_pid_internal(pid, msg_type, buf, len, duplicates_allowed, 0); +} + +/**************************************************************************** + Send a message to a particular pid, with timeout in seconds. +****************************************************************************/ + +BOOL message_send_pid_with_timeout(pid_t pid, int msg_type, const void *buf, size_t len, + BOOL duplicates_allowed, unsigned int timeout) +{ + return message_send_pid_internal(pid, msg_type, buf, len, duplicates_allowed, timeout); +} + /**************************************************************************** Retrieve all messages for the current process. ****************************************************************************/ -- cgit From cf4e0982fdf9ca549eba68791c670a442755f713 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 1 Feb 2003 04:40:00 +0000 Subject: Make it clear that the magic value is (size_t)-1. Andrew Bartlett (This used to be commit 0676b4e35f2ab5b58c44df9fe2eef112425d6013) --- source3/lib/charcnv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 3428377d95..6dd3cd52d9 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -139,7 +139,7 @@ size_t convert_string(charset_t from, charset_t to, i_len=srclen; o_len=destlen; retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len); - if(retval==-1) { + if(retval==(size_t)-1) { const char *reason="unknown error"; switch(errno) { case EINVAL: @@ -214,7 +214,7 @@ convert: retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len); - if(retval == -1) { + if(retval == (size_t)-1) { const char *reason="unknown error"; switch(errno) { case EINVAL: -- cgit From c2b134cc3b67d48961226cbfac6ea3a2fc7cc1a6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 1 Feb 2003 05:20:11 +0000 Subject: Always escape ldap filter strings. Escaping code was from pam_ldap, but I'm to blame for the realloc() stuff. Plus a couple of minor updates to libads. Andrew Bartlett (This used to be commit 34b2e558a4b3cfd753339bb228a9799e27ed8170) --- source3/lib/ldap_escape.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 source3/lib/ldap_escape.c (limited to 'source3/lib') diff --git a/source3/lib/ldap_escape.c b/source3/lib/ldap_escape.c new file mode 100644 index 0000000000..9e88b4999c --- /dev/null +++ b/source3/lib/ldap_escape.c @@ -0,0 +1,90 @@ +/* + Unix SMB/CIFS implementation. + ldap filter argument escaping + + Copyright (C) 1998, 1999, 2000 Luke Howard , + Copyright (C) 2003 Andrew Bartlett + + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/** + * Escape a parameter to an LDAP filter string, so they cannot contain + * embeded ( ) * or \ chars which may cause it not to parse correctly. + * + * @param s The input string + * + * @return A string allocated with malloc(), containing the escaped string, + * and to be free()ed by the caller. + **/ + +char *escape_ldap_string_alloc(const char *s) +{ + size_t len = strlen(s)+1; + char *output = malloc(len); + char *output_tmp; + const char *sub; + int i = 0; + char *p = output; + + while (*s) + { + switch (*s) + { + case '*': + sub = "\\2a"; + break; + case '(': + sub = "\\28"; + break; + case ')': + sub = "\\29"; + break; + case '\\': + sub = "\\5c"; + break; + default: + sub = NULL; + break; + } + + if (sub) { + len = len + 3; + output_tmp = realloc(output, len); + if (!output_tmp) { + SAFE_FREE(output); + return NULL; + } + output = output_tmp; + + p = &output[i]; + strncpy (p, sub, 3); + p += 3; + i += 3; + + } else { + *p = *s; + p++; + i++; + } + s++; + } + + *p = '\0'; + return output; +} -- cgit