From 7f66ebde2e2975b079f6c135b131d064dab38624 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 11:36:14 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_READONLY intead of aRONLY This means we use just one constant for this file attribute. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 0bb46db05f6..b71be79f06a 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -309,7 +309,7 @@ char *attrib_string(uint16 mode) if (mode & aARCH) fstrcat(attrstr,"A"); if (mode & aHIDDEN) fstrcat(attrstr,"H"); if (mode & aSYSTEM) fstrcat(attrstr,"S"); - if (mode & aRONLY) fstrcat(attrstr,"R"); + if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R"); return talloc_strdup(talloc_tos(), attrstr); } -- cgit From 317e19aeb3fbdb21573b6ef1bc8c2af646a7e61e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 11:43:35 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_HIDDEN intead of aHIDDEN This means we use just one constant for this file attribute. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index b71be79f06a..5a191ca24e0 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -307,7 +307,7 @@ char *attrib_string(uint16 mode) if (mode & aVOLID) fstrcat(attrstr,"V"); if (mode & aDIR) fstrcat(attrstr,"D"); if (mode & aARCH) fstrcat(attrstr,"A"); - if (mode & aHIDDEN) fstrcat(attrstr,"H"); + if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H"); if (mode & aSYSTEM) fstrcat(attrstr,"S"); if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R"); -- cgit From 0a3c84b554f3862b3e558f62e67ceb8311b248ce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 13:23:14 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_SYSTEM intead of aSYSTEM This means we use just one constant for this file attribute. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 5a191ca24e0..1cd0059dd74 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -308,7 +308,7 @@ char *attrib_string(uint16 mode) if (mode & aDIR) fstrcat(attrstr,"D"); if (mode & aARCH) fstrcat(attrstr,"A"); if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H"); - if (mode & aSYSTEM) fstrcat(attrstr,"S"); + if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S"); if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R"); return talloc_strdup(talloc_tos(), attrstr); -- cgit From 08c90d6f2df85499f43c5766a62839e80437290f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 11:52:48 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_VOLUME intead of aVOLID This means we use just one constant for this file attribute. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 1cd0059dd74..ac79b994c97 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -304,7 +304,7 @@ char *attrib_string(uint16 mode) attrstr[0] = 0; - if (mode & aVOLID) fstrcat(attrstr,"V"); + if (mode & FILE_ATTRIBUTE_VOLUME) fstrcat(attrstr,"V"); if (mode & aDIR) fstrcat(attrstr,"D"); if (mode & aARCH) fstrcat(attrstr,"A"); if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H"); -- cgit From 0eca33bbf620678759bbe39efaa74f33f96efb74 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 11:57:02 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_DIRECTORY intead of aDIR This means we use just one constant for this file attribute. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index ac79b994c97..bec279e3bd7 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -305,7 +305,7 @@ char *attrib_string(uint16 mode) attrstr[0] = 0; if (mode & FILE_ATTRIBUTE_VOLUME) fstrcat(attrstr,"V"); - if (mode & aDIR) fstrcat(attrstr,"D"); + if (mode & FILE_ATTRIBUTE_DIRECTORY) fstrcat(attrstr,"D"); if (mode & aARCH) fstrcat(attrstr,"A"); if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H"); if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S"); -- cgit From 0520da2bbe246c45d89bfdec0d399862ecb867ba Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 12:00:57 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_ARCHIVE intead of aARCH This means we use just one constant for this file attribute. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index bec279e3bd7..f592a0f778e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -306,7 +306,7 @@ char *attrib_string(uint16 mode) if (mode & FILE_ATTRIBUTE_VOLUME) fstrcat(attrstr,"V"); if (mode & FILE_ATTRIBUTE_DIRECTORY) fstrcat(attrstr,"D"); - if (mode & aARCH) fstrcat(attrstr,"A"); + if (mode & FILE_ATTRIBUTE_ARCHIVE) fstrcat(attrstr,"A"); if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H"); if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S"); if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R"); -- cgit From 724915f721819705c7cf5c850a24b32f815c07e3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 12:05:07 +1000 Subject: s3-client Add TALLOC_CTX argument to attrib_string(). This ensures the caller knows where the memory was allocated. Andrew Bartlett --- source3/lib/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index f592a0f778e..d908ea86f05 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -298,7 +298,7 @@ SMB_OFF_T get_file_size(char *file_name) Return a string representing an attribute for a file. ********************************************************************/ -char *attrib_string(uint16 mode) +char *attrib_string(TALLOC_CTX *mem_ctx, uint16 mode) { fstring attrstr; @@ -311,7 +311,7 @@ char *attrib_string(uint16 mode) if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S"); if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R"); - return talloc_strdup(talloc_tos(), attrstr); + return talloc_strdup(mem_ctx, attrstr); } /******************************************************************* -- cgit From 6021af4fd38d2a712dca42a3cacf8537007fd160 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 12:41:27 +1000 Subject: libcli/smb Move attrib_string in common --- source3/lib/util.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index d908ea86f05..8805197f2d8 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -294,26 +294,6 @@ SMB_OFF_T get_file_size(char *file_name) return get_file_size_stat(&buf); } -/******************************************************************* - Return a string representing an attribute for a file. -********************************************************************/ - -char *attrib_string(TALLOC_CTX *mem_ctx, uint16 mode) -{ - fstring attrstr; - - attrstr[0] = 0; - - if (mode & FILE_ATTRIBUTE_VOLUME) fstrcat(attrstr,"V"); - if (mode & FILE_ATTRIBUTE_DIRECTORY) fstrcat(attrstr,"D"); - if (mode & FILE_ATTRIBUTE_ARCHIVE) fstrcat(attrstr,"A"); - if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H"); - if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S"); - if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R"); - - return talloc_strdup(mem_ctx, attrstr); -} - /******************************************************************* Show a smb message structure. ********************************************************************/ -- cgit From c1f3ff734043082a9488c787324e76a37702f94d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Apr 2011 22:34:56 +0200 Subject: s3-util: move valid_share_pathname() to lib/util.c Guenther --- source3/lib/util.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 8805197f2d8..718500a684f 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2652,3 +2652,37 @@ int timeval_to_msec(struct timeval t) { return t.tv_sec * 1000 + (t.tv_usec+999) / 1000; } + +/******************************************************************* + Check a given DOS pathname is valid for a share. +********************************************************************/ + +char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) +{ + char *ptr = NULL; + + if (!dos_pathname) { + return NULL; + } + + ptr = talloc_strdup(ctx, dos_pathname); + if (!ptr) { + return NULL; + } + /* Convert any '\' paths to '/' */ + unix_format(ptr); + ptr = unix_clean_name(ctx, ptr); + if (!ptr) { + return NULL; + } + + /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ + if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/') + ptr += 2; + + /* Only absolute paths allowed. */ + if (*ptr != '/') + return NULL; + + return ptr; +} -- cgit From 4f41be356a4e6b311d30de3b2e36e4c33aa72ca3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 May 2011 10:41:59 -0700 Subject: Fix many const compiler warnings. --- source3/lib/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 718500a684f..cd856ee3556 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -298,7 +298,7 @@ SMB_OFF_T get_file_size(char *file_name) Show a smb message structure. ********************************************************************/ -void show_msg(char *buf) +void show_msg(const char *buf) { int i; int bcc=0; @@ -335,7 +335,7 @@ void show_msg(char *buf) if (DEBUGLEVEL < 50) bcc = MIN(bcc, 512); - dump_data(10, (uint8 *)smb_buf(buf), bcc); + dump_data(10, (const uint8 *)smb_buf(buf), bcc); } /******************************************************************* -- cgit From e131c94ac1b06cc49b1c25717d3496dba8b0b3df Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 May 2011 13:42:05 -0700 Subject: More const fixes for compiler warnings from the waf build. --- source3/lib/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index cd856ee3556..b0b63770878 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -335,7 +335,7 @@ void show_msg(const char *buf) if (DEBUGLEVEL < 50) bcc = MIN(bcc, 512); - dump_data(10, (const uint8 *)smb_buf(buf), bcc); + dump_data(10, (const uint8 *)smb_buf_const(buf), bcc); } /******************************************************************* @@ -1321,10 +1321,10 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit if possible. ********************************************************************/ -void set_namearray(name_compare_entry **ppname_array, const char *namelist) +void set_namearray(name_compare_entry **ppname_array, char *namelist) { char *name_end; - char *nameptr = (char *)namelist; + char *nameptr = namelist; int num_entries = 0; int i; @@ -1367,7 +1367,7 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist) } /* Now copy out the names */ - nameptr = (char *)namelist; + nameptr = namelist; i = 0; while(*nameptr) { if ( *nameptr == '/' ) { -- cgit From a5a84415e238a861aa9a574f0b486f4ba417aaa6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 May 2011 16:32:01 -0700 Subject: Fix broken interface to set_namearray() - don't modify incoming string. --- source3/lib/util.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index b0b63770878..db92f3c0d7a 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1314,25 +1314,31 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit passing to is_in_path(). We do this for speed so we can pre-parse all the names in the list and don't do it for each call to is_in_path(). - namelist is modified here and is assumed to be - a copy owned by the caller. We also check if the entry contains a wildcard to remove a potentially expensive call to mask_match if possible. ********************************************************************/ -void set_namearray(name_compare_entry **ppname_array, char *namelist) +void set_namearray(name_compare_entry **ppname_array, const char *namelist_in) { char *name_end; - char *nameptr = namelist; + char *namelist; + char *nameptr; int num_entries = 0; int i; (*ppname_array) = NULL; - if((nameptr == NULL ) || ((nameptr != NULL) && (*nameptr == '\0'))) + if((namelist_in == NULL ) || ((namelist_in != NULL) && (*namelist_in == '\0'))) return; + namelist = talloc_strdup(talloc_tos(), namelist_in); + if (namelist == NULL) { + DEBUG(0,("set_namearray: talloc fail\n")); + return; + } + nameptr = namelist; + /* We need to make two passes over the string. The first to count the number of elements, the second to split it. @@ -1358,11 +1364,14 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist) num_entries++; } - if(num_entries == 0) + if(num_entries == 0) { + talloc_free(namelist); return; + } if(( (*ppname_array) = SMB_MALLOC_ARRAY(name_compare_entry, num_entries + 1)) == NULL) { DEBUG(0,("set_namearray: malloc fail\n")); + talloc_free(namelist); return; } @@ -1389,6 +1398,7 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist) (*ppname_array)[i].is_wild = ms_has_wild(nameptr); if(((*ppname_array)[i].name = SMB_STRDUP(nameptr)) == NULL) { DEBUG(0,("set_namearray: malloc fail (1)\n")); + talloc_free(namelist); return; } @@ -1399,6 +1409,7 @@ void set_namearray(name_compare_entry **ppname_array, char *namelist) (*ppname_array)[i].name = NULL; + talloc_free(namelist); return; } -- cgit From d8cfca3a9bd2b6b6c562fd202377d95a98eb5472 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 May 2011 11:25:29 +0200 Subject: s3: only include tdb headers where needed. Guenther --- source3/lib/util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index db92f3c0d7a..8d90569863f 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -24,6 +24,7 @@ #include "includes.h" #include "system/passwd.h" #include "system/filesys.h" +#include "util_tdb.h" #include "ctdbd_conn.h" #include "../lib/util/util_pw.h" #include "messages.h" -- cgit From c615ebed6e3d273a682806b952d543e834e5630d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 13 May 2011 20:21:30 +0200 Subject: s3-lib Replace StrCaseCmp() with strcasecmp_m() strcasecmp_m() never needs to call to talloc, and via next_codepoint() still has an ASCII fast-path bypassing iconv() calls. Andrew Bartlett --- source3/lib/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 8d90569863f..ee696461c6b 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1299,7 +1299,7 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit } } else { if((case_sensitive && (strcmp(last_component, namelist->name) == 0))|| - (!case_sensitive && (StrCaseCmp(last_component, namelist->name) == 0))) { + (!case_sensitive && (strcasecmp_m(last_component, namelist->name) == 0))) { DEBUG(8,("is_in_path: match succeeded\n")); return True; } @@ -2203,7 +2203,7 @@ bool name_to_fqdn(fstring fqdn, const char *name) } } } - if (full && (StrCaseCmp(full, "localhost.localdomain") == 0)) { + if (full && (strcasecmp_m(full, "localhost.localdomain") == 0)) { DEBUG(1, ("WARNING: your /etc/hosts file may be broken!\n")); DEBUGADD(1, (" Specifing the machine hostname for address 127.0.0.1 may lead\n")); DEBUGADD(1, (" to Kerberos authentication problems as localhost.localdomain\n")); -- cgit From 702d8d5f87f36a6b62a8ad35af62fd0e7cb20384 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 30 May 2011 16:18:51 +1000 Subject: s3-lib Move free_namearray() into it's own file This makes it easier to have conn_smbd strictly depend on all it's dependencies. Andrew Bartlett --- source3/lib/util.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index ee696461c6b..e8a360fd3ae 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1414,22 +1414,6 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist_in) return; } -/**************************************************************************** - Routine to free a namearray. -****************************************************************************/ - -void free_namearray(name_compare_entry *name_array) -{ - int i; - - if(name_array == NULL) - return; - - for(i=0; name_array[i].name!=NULL; i++) - SAFE_FREE(name_array[i].name); - SAFE_FREE(name_array); -} - #undef DBGC_CLASS #define DBGC_CLASS DBGC_LOCKING -- cgit From caf0df2dde2f39c3b271a79fab9358475de6a6e4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 30 May 2011 18:39:27 +1000 Subject: s3-build Specify more of the smbconf dependencies This brings more functions into util_names.c, and util_names.c into PARAM_WITHOUT_REG_SRC. This is not yet a full list, that would formalise the implicit dependency loop. Andrew Bartlett Autobuild-User: Andrew Bartlett Autobuild-Date: Tue May 31 01:43:37 CEST 2011 on sn-devel-104 --- source3/lib/util.c | 162 ----------------------------------------------------- 1 file changed, 162 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index e8a360fd3ae..f86f51790fc 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -72,87 +72,6 @@ void set_Protocol(enum protocol_types p) static enum remote_arch_types ra_type = RA_UNKNOWN; -/*********************************************************************** - Definitions for all names. -***********************************************************************/ - -static char *smb_scope; -static int smb_num_netbios_names; -static char **smb_my_netbios_names; - -/*********************************************************************** - Allocate and set scope. Ensure upper case. -***********************************************************************/ - -bool set_global_scope(const char *scope) -{ - SAFE_FREE(smb_scope); - smb_scope = SMB_STRDUP(scope); - if (!smb_scope) - return False; - strupper_m(smb_scope); - return True; -} - -/********************************************************************* - Ensure scope is never null string. -*********************************************************************/ - -const char *global_scope(void) -{ - if (!smb_scope) - set_global_scope(""); - return smb_scope; -} - -static void free_netbios_names_array(void) -{ - int i; - - for (i = 0; i < smb_num_netbios_names; i++) - SAFE_FREE(smb_my_netbios_names[i]); - - SAFE_FREE(smb_my_netbios_names); - smb_num_netbios_names = 0; -} - -static bool allocate_my_netbios_names_array(size_t number) -{ - free_netbios_names_array(); - - smb_num_netbios_names = number + 1; - smb_my_netbios_names = SMB_MALLOC_ARRAY( char *, smb_num_netbios_names ); - - if (!smb_my_netbios_names) - return False; - - memset(smb_my_netbios_names, '\0', sizeof(char *) * smb_num_netbios_names); - return True; -} - -static bool set_my_netbios_names(const char *name, int i) -{ - SAFE_FREE(smb_my_netbios_names[i]); - - smb_my_netbios_names[i] = SMB_STRDUP(name); - if (!smb_my_netbios_names[i]) - return False; - strupper_m(smb_my_netbios_names[i]); - return True; -} - -/*********************************************************************** - Free memory allocated to global objects -***********************************************************************/ - -void gfree_names(void) -{ - gfree_netbios_names(); - SAFE_FREE( smb_scope ); - free_netbios_names_array(); - free_local_machine_name(); -} - void gfree_all( void ) { gfree_names(); @@ -162,87 +81,6 @@ void gfree_all( void ) gfree_debugsyms(); } -const char *my_netbios_names(int i) -{ - return smb_my_netbios_names[i]; -} - -bool set_netbios_aliases(const char **str_array) -{ - size_t namecount; - - /* Work out the max number of netbios aliases that we have */ - for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ ) - ; - - if ( global_myname() && *global_myname()) - namecount++; - - /* Allocate space for the netbios aliases */ - if (!allocate_my_netbios_names_array(namecount)) - return False; - - /* Use the global_myname string first */ - namecount=0; - if ( global_myname() && *global_myname()) { - set_my_netbios_names( global_myname(), namecount ); - namecount++; - } - - if (str_array) { - size_t i; - for ( i = 0; str_array[i] != NULL; i++) { - size_t n; - bool duplicate = False; - - /* Look for duplicates */ - for( n=0; n Date: Tue, 31 May 2011 10:42:30 +1000 Subject: s3-lib Move source3-specific malloc replacements into a seperate file This will make it easier to create a dep tree for otherwise simple libraries. Andrew Bartlett --- source3/lib/util.c | 143 ----------------------------------------------------- 1 file changed, 143 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index f86f51790fc..173e9067cc2 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -430,149 +430,6 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, return status; } -#if defined(PARANOID_MALLOC_CHECKER) - -/**************************************************************************** - Internal malloc wrapper. Externally visible. -****************************************************************************/ - -void *malloc_(size_t size) -{ - if (size == 0) { - return NULL; - } -#undef malloc - return malloc(size); -#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY -} - -/**************************************************************************** - Internal calloc wrapper. Not externally visible. -****************************************************************************/ - -static void *calloc_(size_t count, size_t size) -{ - if (size == 0 || count == 0) { - return NULL; - } -#undef calloc - return calloc(count, size); -#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY -} - -/**************************************************************************** - Internal realloc wrapper. Not externally visible. -****************************************************************************/ - -static void *realloc_(void *ptr, size_t size) -{ -#undef realloc - return realloc(ptr, size); -#define realloc(p,s) __ERROR_DONT_USE_RELLOC_DIRECTLY -} - -#endif /* PARANOID_MALLOC_CHECKER */ - -/**************************************************************************** - Type-safe memalign -****************************************************************************/ - -void *memalign_array(size_t el_size, size_t align, unsigned int count) -{ - if (count >= MAX_ALLOC_SIZE/el_size) { - return NULL; - } - - return sys_memalign(align, el_size*count); -} - -/**************************************************************************** - Type-safe calloc. -****************************************************************************/ - -void *calloc_array(size_t size, size_t nmemb) -{ - if (nmemb >= MAX_ALLOC_SIZE/size) { - return NULL; - } - if (size == 0 || nmemb == 0) { - return NULL; - } -#if defined(PARANOID_MALLOC_CHECKER) - return calloc_(nmemb, size); -#else - return calloc(nmemb, size); -#endif -} - -/**************************************************************************** - Expand a pointer to be a particular size. - Note that this version of Realloc has an extra parameter that decides - whether to free the passed in storage on allocation failure or if the - new size is zero. - - This is designed for use in the typical idiom of : - - p = SMB_REALLOC(p, size) - if (!p) { - return error; - } - - and not to have to keep track of the old 'p' contents to free later, nor - to worry if the size parameter was zero. In the case where NULL is returned - we guarentee that p has been freed. - - If free later semantics are desired, then pass 'free_old_on_error' as False which - guarentees that the old contents are not freed on error, even if size == 0. To use - this idiom use : - - tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size); - if (!tmp) { - SAFE_FREE(p); - return error; - } else { - p = tmp; - } - - Changes were instigated by Coverity error checking. JRA. -****************************************************************************/ - -void *Realloc(void *p, size_t size, bool free_old_on_error) -{ - void *ret=NULL; - - if (size == 0) { - if (free_old_on_error) { - SAFE_FREE(p); - } - DEBUG(2,("Realloc asked for 0 bytes\n")); - return NULL; - } - -#if defined(PARANOID_MALLOC_CHECKER) - if (!p) { - ret = (void *)malloc_(size); - } else { - ret = (void *)realloc_(p,size); - } -#else - if (!p) { - ret = (void *)malloc(size); - } else { - ret = (void *)realloc(p,size); - } -#endif - - if (!ret) { - if (free_old_on_error && p) { - SAFE_FREE(p); - } - DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size)); - } - - return(ret); -} - /**************************************************************************** (Hopefully) efficient array append. ****************************************************************************/ -- cgit From 876b1b3d198e2306c36423bfb1449870c74181fd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 6 Jun 2011 14:22:12 +1000 Subject: s3-lib Remove unused lib_path() --- source3/lib/util.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 173e9067cc2..dc91fa06a15 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1513,19 +1513,6 @@ char *pid_path(const char *name) return xx_path(name, lp_piddir()); } -/** - * @brief Returns an absolute path to a file in the Samba lib directory. - * - * @param name File to find, relative to LIBDIR. - * - * @retval Pointer to a string containing the full path. - **/ - -char *lib_path(const char *name) -{ - return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_LIBDIR(), name); -} - /** * @brief Returns an absolute path to a file in the Samba modules directory. * -- cgit From de46ad9084aff4384f33660acf91da3b81554a88 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 6 Jun 2011 14:37:06 +1000 Subject: lib/util use modules_path(), data_path() and shlib_ext() from source3 This brings these helpful utility functions in common, as they are not based on either loadparm system. (The 'modules dir' parameter from Samba4 will shortly be removed, so there is no loss in functionality) Andrew Bartlett --- source3/lib/util.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index dc91fa06a15..a596385bfb3 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1513,32 +1513,6 @@ char *pid_path(const char *name) return xx_path(name, lp_piddir()); } -/** - * @brief Returns an absolute path to a file in the Samba modules directory. - * - * @param name File to find, relative to MODULESDIR. - * - * @retval Pointer to a string containing the full path. - **/ - -char *modules_path(const char *name) -{ - return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_MODULESDIR(), name); -} - -/** - * @brief Returns an absolute path to a file in the Samba data directory. - * - * @param name File to find, relative to CODEPAGEDIR. - * - * @retval Pointer to a talloc'ed string containing the full path. - **/ - -char *data_path(const char *name) -{ - return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_CODEPAGEDIR(), name); -} - /** * @brief Returns an absolute path to a file in the Samba state directory. * @@ -1565,17 +1539,6 @@ char *cache_path(const char *name) return xx_path(name, lp_cachedir()); } -/** - * @brief Returns the platform specific shared library extension. - * - * @retval Pointer to a const char * containing the extension. - **/ - -const char *shlib_ext(void) -{ - return get_dyn_SHLIBEXT(); -} - /******************************************************************* Given a filename - get its directory name ********************************************************************/ -- cgit From 8459391e31079066745a65c5f3c07f3899afdc0c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:03:16 +1000 Subject: s3-talloc Remove unused TALLOC zeronull functions and macro definitions These have been under #if 0 for a long time now. Andrew Bartlett --- source3/lib/util.c | 105 ----------------------------------------------------- 1 file changed, 105 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index a596385bfb3..5aad2435932 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2140,111 +2140,6 @@ void split_domain_user(TALLOC_CTX *mem_ctx, } } -#if 0 - -Disable these now we have checked all code paths and ensured -NULL returns on zero request. JRA. - -/**************************************************************** - talloc wrapper functions that guarentee a null pointer return - if size == 0. -****************************************************************/ - -#ifndef MAX_TALLOC_SIZE -#define MAX_TALLOC_SIZE 0x10000000 -#endif - -/* - * talloc and zero memory. - * - returns NULL if size is zero. - */ - -void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name) -{ - void *p; - - if (size == 0) { - return NULL; - } - - p = talloc_named_const(ctx, size, name); - - if (p) { - memset(p, '\0', size); - } - - return p; -} - -/* - * memdup with a talloc. - * - returns NULL if size is zero. - */ - -void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name) -{ - void *newp; - - if (size == 0) { - return NULL; - } - - newp = talloc_named_const(t, size, name); - if (newp) { - memcpy(newp, p, size); - } - - return newp; -} - -/* - * alloc an array, checking for integer overflow in the array size. - * - returns NULL if count or el_size are zero. - */ - -void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name) -{ - if (count >= MAX_TALLOC_SIZE/el_size) { - return NULL; - } - - if (el_size == 0 || count == 0) { - return NULL; - } - - return talloc_named_const(ctx, el_size * count, name); -} - -/* - * alloc an zero array, checking for integer overflow in the array size - * - returns NULL if count or el_size are zero. - */ - -void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name) -{ - if (count >= MAX_TALLOC_SIZE/el_size) { - return NULL; - } - - if (el_size == 0 || count == 0) { - return NULL; - } - - return _talloc_zero(ctx, el_size * count, name); -} - -/* - * Talloc wrapper that returns NULL if size == 0. - */ -void *talloc_zeronull(const void *context, size_t size, const char *name) -{ - if (size == 0) { - return NULL; - } - return talloc_named_const(context, size, name); -} -#endif - /**************************************************************** strip off leading '\\' from a hostname ****************************************************************/ -- cgit From 73b377432c5efb8451f09f6d25d8aa1b28c239c9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:10:15 +1000 Subject: s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc() Using the standard macro makes it easier to move code into common, as TALLOC_REALLOC_ARRAY isn't standard talloc. Andrew Bartlett --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 5aad2435932..b4af9fbc0e1 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -226,7 +226,7 @@ ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob) size_t newlen = smb_len(*outbuf) + 4 + blob.length; uint8 *tmp; - if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, *outbuf, uint8, newlen))) { + if (!(tmp = talloc_realloc(NULL, *outbuf, uint8, newlen))) { DEBUG(0, ("talloc failed\n")); return -1; } -- cgit From 8d4a8389bb2df77ff8923dda8368aa2915652c1a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 12:13:26 +1000 Subject: s3-talloc Change TALLOC_MEMDUP() to talloc_memdup() Using the standard macro makes it easier to move code into common, as TALLOC_MEMDUP isn't standard talloc. --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index b4af9fbc0e1..af5f63995b4 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1563,7 +1563,7 @@ bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent, len = p-dir; - if (!(*parent = (char *)TALLOC_MEMDUP(mem_ctx, dir, len+1))) { + if (!(*parent = (char *)talloc_memdup(mem_ctx, dir, len+1))) { return False; } (*parent)[len] = '\0'; -- cgit From cc3b75b807c6dd63b6dde3b449054f6640826f7c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 May 2011 10:27:36 +1000 Subject: s3-server_id Add task_id to server_id to match Samba4 This will allow this structure to be shared, and allow us to create a common messaging system between all Samba processes. Samba4 uses the task_id to indicate the different tasks within a single unix process. Andrew Bartlett Signed-off-by: Andrew Tridgell --- source3/lib/util.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index af5f63995b4..a0b6d9f55d8 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1924,6 +1924,7 @@ struct server_id pid_to_procid(pid_t pid) { struct server_id result; result.pid = pid; + result.task_id = 0; result.unique_id = my_unique_id; result.vnn = my_vnn; return result; @@ -1938,6 +1939,8 @@ bool procid_equal(const struct server_id *p1, const struct server_id *p2) { if (p1->pid != p2->pid) return False; + if (p1->task_id != p2->task_id) + return False; if (p1->vnn != p2->vnn) return False; return True; @@ -1953,6 +1956,8 @@ bool procid_is_me(const struct server_id *pid) { if (pid->pid != sys_getpid()) return False; + if (pid->task_id != 0) + return False; if (pid->vnn != my_vnn) return False; return True; -- cgit From d01dbd6c3fd9ca2595d65991b56db4400a35ece0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Jun 2011 12:47:59 +1000 Subject: s3-lib Read and write the full struct server_id (except the unique_id) This is in preperation for making this code the common, only reader and writer of this structure. Andrew Bartlett --- source3/lib/util.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index a0b6d9f55d8..ca308589141 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1966,41 +1966,40 @@ bool procid_is_me(const struct server_id *pid) struct server_id interpret_pid(const char *pid_string) { struct server_id result; - int pid; - unsigned int vnn; - if (sscanf(pid_string, "%u:%d", &vnn, &pid) == 2) { + unsigned long long pid; + unsigned int vnn, task_id = 0; + + ZERO_STRUCT(result); + + /* We accept either the 2 or 3 componet form for backwards compatability in the smbstatus command line tool */ + if (sscanf(pid_string, "%u:%llu:%u", &vnn, &pid, &task_id) >= 2) { result.vnn = vnn; result.pid = pid; - } - else if (sscanf(pid_string, "%d", &pid) == 1) { + result.task_id = task_id; + } else if (sscanf(pid_string, "%d", &pid) == 1) { result.vnn = get_my_vnn(); result.pid = pid; } else { result.vnn = NONCLUSTER_VNN; - result.pid = -1; - } - /* Assigning to result.pid may have overflowed - Map negative pid to -1: i.e. error */ - if (result.pid < 0) { - result.pid = -1; + result.pid = (uint64_t)-1; } - result.unique_id = 0; return result; } char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid) { - if (pid->vnn == NONCLUSTER_VNN) { + if (pid->vnn == NONCLUSTER_VNN && pid->task_id == 0) { return talloc_asprintf(mem_ctx, - "%d", - (int)pid->pid); + "%llu", + (unsigned long long)pid->pid); } else { return talloc_asprintf(mem_ctx, - "%u:%d", - (unsigned)pid->vnn, - (int)pid->pid); + "%u:%llu:%u", + (unsigned)pid->vnn, + (unsigned long long)pid->pid, + (unsigned)pid->task_id); } } @@ -2011,7 +2010,7 @@ char *procid_str_static(const struct server_id *pid) bool procid_valid(const struct server_id *pid) { - return (pid->pid != -1); + return (pid->pid != (uint64_t)-1); } bool procid_is_local(const struct server_id *pid) -- cgit From 16b1c77644217796f70a3a0bf1d95c245f9ee2d9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Jun 2011 14:05:55 +1000 Subject: lib/util Bring procid_str() into lib/util as server_id_string() This is needed for OpenChange, which prints Samba struct server_id values in debug messages. Andrew Bartlett --- source3/lib/util.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index ca308589141..5fb8a41dae1 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1987,25 +1987,9 @@ struct server_id interpret_pid(const char *pid_string) return result; } -char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid) -{ - if (pid->vnn == NONCLUSTER_VNN && pid->task_id == 0) { - return talloc_asprintf(mem_ctx, - "%llu", - (unsigned long long)pid->pid); - } - else { - return talloc_asprintf(mem_ctx, - "%u:%llu:%u", - (unsigned)pid->vnn, - (unsigned long long)pid->pid, - (unsigned)pid->task_id); - } -} - char *procid_str_static(const struct server_id *pid) { - return procid_str(talloc_tos(), pid); + return server_id_str(talloc_tos(), pid); } bool procid_valid(const struct server_id *pid) -- cgit From daf79e33c7e8873345fb4a251f1e880fd767df19 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 9 Jun 2011 11:18:15 +1000 Subject: server_id: Change format to vnn:pid.task_id, pid.task_id or pid This helps ensure the string cannot be ambiguous, while also ensuring that it remains simple in the non-cluster case. The asymmetry of reading get_my_vnn() but writing based on NONCLUSTER_VNN is acceptable because in the non-clustered case, they are equal, and in the clustered case we will print the full string. Andrew Bartlett --- source3/lib/util.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 5fb8a41dae1..499f5f7f6b0 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1971,16 +1971,26 @@ struct server_id interpret_pid(const char *pid_string) ZERO_STRUCT(result); - /* We accept either the 2 or 3 componet form for backwards compatability in the smbstatus command line tool */ - if (sscanf(pid_string, "%u:%llu:%u", &vnn, &pid, &task_id) >= 2) { + /* We accept various forms with 1, 2 or 3 component forms + * because the server_id_str() can print different forms, and + * we want backwards compatibility for scripts that may call + * smbclient. */ + if (sscanf(pid_string, "%u:%llu.%u", &vnn, &pid, &task_id) == 3) { result.vnn = vnn; result.pid = pid; result.task_id = task_id; + } else if (sscanf(pid_string, "%u:%llu", &vnn, &pid) == 2) { + result.vnn = vnn; + result.pid = pid; + result.task_id = 0; + } else if (sscanf(pid_string, "%llu.%u", &pid, &task_id) == 2) { + result.vnn = get_my_vnn(); + result.pid = pid; + result.task_id = task_id; } else if (sscanf(pid_string, "%d", &pid) == 1) { result.vnn = get_my_vnn(); result.pid = pid; - } - else { + } else { result.vnn = NONCLUSTER_VNN; result.pid = (uint64_t)-1; } -- cgit From 0e95311c235929e07fdcfd7153b91ae795a979b9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 9 Jun 2011 15:27:53 +1000 Subject: s3-lib Add myhostname_upper() This varient always upper cases the hostname, which is needed for the netbios name. Andrew Bartlett --- source3/lib/util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 499f5f7f6b0..51ad7bd3bd9 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1456,6 +1456,22 @@ char *myhostname(void) return ret; } +/***************************************************************** + Get local hostname and cache result. +*****************************************************************/ + +char *myhostname_upper(void) +{ + char *name; + static char *ret; + if (ret == NULL) { + name = get_myname(talloc_tos()); + ret = strupper_talloc(NULL, name); + talloc_free(name); + } + return ret; +} + /** * @brief Returns an absolute path to a file concatenating the provided * @a rootpath and @a basename -- cgit From e3396cffecafe7ece91bed2185ed89bf8df12d79 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 9 Jun 2011 14:24:03 +0200 Subject: s3:lib/util: use %llu consitently (instead of %d) in interpret_pid() to parse the pid metze --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 51ad7bd3bd9..d04887c854c 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2003,7 +2003,7 @@ struct server_id interpret_pid(const char *pid_string) result.vnn = get_my_vnn(); result.pid = pid; result.task_id = task_id; - } else if (sscanf(pid_string, "%d", &pid) == 1) { + } else if (sscanf(pid_string, "%llu", &pid) == 1) { result.vnn = get_my_vnn(); result.pid = pid; } else { -- cgit From f72dd0cf0f5f4b9082d022e26b1d4117b3a04d52 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 16:56:15 +0930 Subject: source3/lib/util.c: str_checksum to use Jenkins hash from CCAN. Rather than tdb's internal one. --- source3/lib/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index d04887c854c..b25c15c7a3e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -28,6 +28,7 @@ #include "ctdbd_conn.h" #include "../lib/util/util_pw.h" #include "messages.h" +#include /* Max allowable allococation - 256mb - 0x10000000 */ #define MAX_ALLOC_SIZE (1024*1024*256) @@ -1306,8 +1307,9 @@ const char *tab_depth(int level, int depth) int str_checksum(const char *s) { - TDB_DATA key = string_tdb_data(s); - return tdb_jenkins_hash(&key); + if (s == NULL) + return 0; + return hash(s, strlen(s), 0); } /***************************************************************** -- cgit From d925b327f4703cc141c0a7f3eec912dba8440880 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:33 +0930 Subject: tdb_compat: Higher level API fixes. My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell --- source3/lib/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index b25c15c7a3e..b8fc319a6ff 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -406,7 +406,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, set_need_random_reseed(); /* tdb needs special fork handling */ - if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) { + if (tdb_reopen_all(parent_longlived ? 1 : 0) != 0) { DEBUG(0,("tdb_reopen_all failed.\n")); status = NT_STATUS_OPEN_FAILED; goto done; -- cgit