From 49f384231d23180351782a09bc885b94cf3d0d58 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 22 Jul 1999 04:39:31 +0000 Subject: Moved a whole bunch of macros out of smb.h and into their own #include file. (This used to be commit bf61fdace8cdf71dc3ab40795498a8bfd0d3b9a0) --- source3/include/smb_macros.h | 153 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 source3/include/smb_macros.h (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h new file mode 100644 index 0000000000..6a2d18ce83 --- /dev/null +++ b/source3/include/smb_macros.h @@ -0,0 +1,153 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + SMB parameters and setup + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) John H Terpstra 1996-1998 + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 + Copyright (C) Paul Ashton 1998 + + 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. +*/ + +#ifndef _SMB_MACROS_H +#define _SMB_MACROS_H + +/* Misc bit macros */ +#define BOOLSTR(b) ((b) ? "Yes" : "No") +#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) +#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) + +#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) +#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) +#define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) + +/* for readability... */ +#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) +#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) +#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0) +#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) +#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) + +/* zero a structure */ +#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) + +/* zero a structure given a pointer to the structure */ +#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } + +/* zero an array - note that sizeof(array) must work - ie. it must not be a + pointer */ +#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) + +/* pointer difference macro */ +#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) + +/* assert macros */ +#define SMB_ASSERT(b) ((b)?(void)0: \ + (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ + __FILE__, __LINE__)), smb_panic("assert failed"))) +#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) + +/* these are useful macros for checking validity of handles */ +#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory) +#define OPEN_CONN(conn) ((conn) && (conn)->open) +#define IS_IPC(conn) ((conn) && (conn)->ipc) +#define IS_PRINT(conn) ((conn) && (conn)->printer) +#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) + +#define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ + return(ERROR(ERRDOS,ERRbadfid)) +#define CHECK_READ(fsp) if (!(fsp)->can_read) \ + return(ERROR(ERRDOS,ERRbadaccess)) +#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ + return(ERROR(ERRDOS,ERRbadaccess)) +#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ + return(CACHED_ERROR(fsp)) + +/* translates a connection number into a service number */ +#define SNUM(conn) ((conn)?(conn)->service:-1) + +/* access various service details */ +#define SERVICE(snum) (lp_servicename(snum)) +#define PRINTCAP (lp_printcapname()) +#define PRINTCOMMAND(snum) (lp_printcommand(snum)) +#define PRINTERNAME(snum) (lp_printername(snum)) +#define CAN_WRITE(conn) (!conn->read_only) +#define VALID_SNUM(snum) (lp_snum_ok(snum)) +#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum)) +#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum)) +#define CAN_SETDIR(snum) (!lp_no_set_dir(snum)) +#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service)) +#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service)) +#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service)) +#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service)) +#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list)) +#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list)) +#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list)) + +/* + * Used by the stat cache code to check if a returned + * stat structure is valid. + */ + +#define VALID_STAT(st) (st.st_nlink != 0) +#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR(st.st_mode)) + +#define SMBENCRYPT() (lp_encrypted_passwords()) + +#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 + on different machines/compilers. */ + +#define SMB_LPID_OFFSET(indx) (10 * (indx)) +#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx))) +#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx))) +#define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx))) +#define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx))) +#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) +#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) + +/* Macro to cache an error in a write_bmpx_struct */ +#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ + w->wr_discard = True, -1) +/* Macro to test if an error has been cached for this fnum */ +#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ + (fsp)->wbmpx_ptr->wr_discard) +/* Macro to turn the cached error into an error packet */ +#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) + +/* these are the datagram types */ +#define DGRAM_DIRECT_UNIQUE 0x10 + +#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__) + +/* this is how errors are generated */ +#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__) + +#define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) + +#endif /* _SMB_MACROS_H */ -- cgit From d9cc4c39504534da0f4cd2569c724de4909ebd79 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 1 Dec 1999 18:47:29 +0000 Subject: improving createuser account command to be able to add workstations and then set a default random password. (This used to be commit 7846818432a93295651c8c67445a2d6a0f3b21d8) --- source3/include/smb_macros.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 6a2d18ce83..979aec1d2c 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -2,10 +2,10 @@ Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1998 - Copyright (C) John H Terpstra 1996-1998 - Copyright (C) Luke Kenneth Casson Leighton 1996-1998 - Copyright (C) Paul Ashton 1998 + Copyright (C) Andrew Tridgell 1992-1999 + Copyright (C) John H Terpstra 1996-1999 + Copyright (C) Luke Kenneth Casson Leighton 1996-1999 + Copyright (C) Paul Ashton 1998 - 1999 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 @@ -33,6 +33,7 @@ #define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) #define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) #define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) +#define IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit)) /* for readability... */ #define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) -- cgit From 32a965e09ce4befe971855e11e1fb5ceb51a9ed1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:35:20 +0000 Subject: 2nd phase of head branch sync with SAMBA_2_0 - this delets all the files that were in the head branch but weren't in SAMBA_2_0 (This used to be commit d7b208786590b5a28618590172b8d523627dda09) --- source3/include/smb_macros.h | 154 ------------------------------------------- 1 file changed, 154 deletions(-) delete mode 100644 source3/include/smb_macros.h (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h deleted file mode 100644 index 979aec1d2c..0000000000 --- a/source3/include/smb_macros.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1999 - Copyright (C) John H Terpstra 1996-1999 - Copyright (C) Luke Kenneth Casson Leighton 1996-1999 - Copyright (C) Paul Ashton 1998 - 1999 - - 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. -*/ - -#ifndef _SMB_MACROS_H -#define _SMB_MACROS_H - -/* Misc bit macros */ -#define BOOLSTR(b) ((b) ? "Yes" : "No") -#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) -#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) - -#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) -#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) -#define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) -#define IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit)) - -/* for readability... */ -#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) -#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) -#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0) -#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) -#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) - -/* zero a structure */ -#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) - -/* zero a structure given a pointer to the structure */ -#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } - -/* zero an array - note that sizeof(array) must work - ie. it must not be a - pointer */ -#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) - -/* pointer difference macro */ -#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) - -/* assert macros */ -#define SMB_ASSERT(b) ((b)?(void)0: \ - (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ - __FILE__, __LINE__)), smb_panic("assert failed"))) -#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) - -/* these are useful macros for checking validity of handles */ -#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory) -#define OPEN_CONN(conn) ((conn) && (conn)->open) -#define IS_IPC(conn) ((conn) && (conn)->ipc) -#define IS_PRINT(conn) ((conn) && (conn)->printer) -#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) - -#define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ - return(ERROR(ERRDOS,ERRbadfid)) -#define CHECK_READ(fsp) if (!(fsp)->can_read) \ - return(ERROR(ERRDOS,ERRbadaccess)) -#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ - return(ERROR(ERRDOS,ERRbadaccess)) -#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ - return(CACHED_ERROR(fsp)) - -/* translates a connection number into a service number */ -#define SNUM(conn) ((conn)?(conn)->service:-1) - -/* access various service details */ -#define SERVICE(snum) (lp_servicename(snum)) -#define PRINTCAP (lp_printcapname()) -#define PRINTCOMMAND(snum) (lp_printcommand(snum)) -#define PRINTERNAME(snum) (lp_printername(snum)) -#define CAN_WRITE(conn) (!conn->read_only) -#define VALID_SNUM(snum) (lp_snum_ok(snum)) -#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum)) -#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum)) -#define CAN_SETDIR(snum) (!lp_no_set_dir(snum)) -#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service)) -#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service)) -#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service)) -#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service)) -#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list)) -#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list)) -#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list)) - -/* - * Used by the stat cache code to check if a returned - * stat structure is valid. - */ - -#define VALID_STAT(st) (st.st_nlink != 0) -#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR(st.st_mode)) - -#define SMBENCRYPT() (lp_encrypted_passwords()) - -#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 - on different machines/compilers. */ - -#define SMB_LPID_OFFSET(indx) (10 * (indx)) -#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx))) -#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx))) -#define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx))) -#define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx))) -#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) -#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) - -/* Macro to cache an error in a write_bmpx_struct */ -#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ - w->wr_discard = True, -1) -/* Macro to test if an error has been cached for this fnum */ -#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ - (fsp)->wbmpx_ptr->wr_discard) -/* Macro to turn the cached error into an error packet */ -#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) - -/* these are the datagram types */ -#define DGRAM_DIRECT_UNIQUE 0x10 - -#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__) - -/* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__) - -#define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) - -#endif /* _SMB_MACROS_H */ -- cgit From 04f7d80ac358520c0d6e351f790f59208853130a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 3 Feb 2000 04:47:50 +0000 Subject: Busting up of source/include/smb.h into smaller pieces which can be #included by VFS modules without bringing in too much other junk. (This used to be commit 13a2cf80f65156e725a5716e62a4c44e70f5340f) --- source3/include/smb_macros.h | 236 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 source3/include/smb_macros.h (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h new file mode 100644 index 0000000000..8fb1fdbb71 --- /dev/null +++ b/source3/include/smb_macros.h @@ -0,0 +1,236 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + SMB parameters and setup + Copyright (C) Andrew Tridgell 1992-1999 + Copyright (C) John H Terpstra 1996-1999 + Copyright (C) Luke Kenneth Casson Leighton 1996-1999 + Copyright (C) Paul Ashton 1998 - 1999 + + 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. +*/ + +#ifndef _SMB_MACROS_H +#define _SMB_MACROS_H + +/* Misc bit macros */ +#define BOOLSTR(b) ((b) ? "Yes" : "No") +#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) +#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) + +#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) +#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) +#define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) +#define IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit)) + +/* for readability... */ +#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) +#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) +#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0) +#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) +#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) + +/* memory-allocation-helpers (idea and names from glib) */ +#define g_new(type, count) \ + ((type *) malloc(sizeof(type) * (count))) +#define g_new0(type, count) \ + ((type *) calloc((count), sizeof(type))) +#define g_renew(type, mem, count) \ + ((type *) Realloc(mem, sizeof(type) * (count))) + +/* zero a structure */ +#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) + +/* zero a structure given a pointer to the structure */ +#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } + +/* zero a structure given a pointer to the structure - no zero check */ +#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) + +/* zero an array - note that sizeof(array) must work - ie. it must not be a + pointer */ +#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) + +/* pointer difference macro */ +#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) + +/* assert macros */ +#define SMB_ASSERT(b) ((b)?(void)0: \ + (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ + __FILE__, __LINE__)), smb_panic("assert failed"))) +#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) + +/* these are useful macros for checking validity of handles */ +#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory) +#define OPEN_CONN(conn) ((conn) && (conn)->open) +#define IS_IPC(conn) ((conn) && (conn)->ipc) +#define IS_PRINT(conn) ((conn) && (conn)->printer) +#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) + +#define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ + return(ERROR(ERRDOS,ERRbadfid)) +#define CHECK_READ(fsp) if (!(fsp)->can_read) \ + return(ERROR(ERRDOS,ERRbadaccess)) +#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ + return(ERROR(ERRDOS,ERRbadaccess)) +#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ + return(CACHED_ERROR(fsp)) + +/* translates a connection number into a service number */ +#define SNUM(conn) ((conn)?(conn)->service:-1) + +/* access various service details */ +#define SERVICE(snum) (lp_servicename(snum)) +#define PRINTCAP (lp_printcapname()) +#define PRINTCOMMAND(snum) (lp_printcommand(snum)) +#define PRINTERNAME(snum) (lp_printername(snum)) +#define CAN_WRITE(conn) (!conn->read_only) +#define VALID_SNUM(snum) (lp_snum_ok(snum)) +#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum)) +#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum)) +#define CAN_SETDIR(snum) (!lp_no_set_dir(snum)) +#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service)) +#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service)) +#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service)) +#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service)) +#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list)) +#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list)) +#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list)) + +/* + * Used by the stat cache code to check if a returned + * stat structure is valid. + */ + +#define VALID_STAT(st) (st.st_nlink != 0) +#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR(st.st_mode)) + +#define SMBENCRYPT() (lp_encrypted_passwords()) + +#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 + on different machines/compilers. */ + +#define SMB_LPID_OFFSET(indx) (10 * (indx)) +#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx))) +#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx))) +#define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx))) +#define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx))) +#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) +#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) + +/* Macro to cache an error in a write_bmpx_struct */ +#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ + w->wr_discard = True, -1) +/* Macro to test if an error has been cached for this fnum */ +#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ + (fsp)->wbmpx_ptr->wr_discard) +/* Macro to turn the cached error into an error packet */ +#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) + +/* these are the datagram types */ +#define DGRAM_DIRECT_UNIQUE 0x10 + +#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__) + +/* this is how errors are generated */ +#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__) + +#define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) + +/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ +#define smb_buf(buf) (buf + smb_size + CVAL(buf,smb_wct)*2) +#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) + +/* Note that chain_size must be available as an extern int to this macro. */ +#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size) + +#define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16)) +#define _smb_setlen(buf,len) buf[0] = 0; buf[1] = (len&0x10000)>>16; \ + buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; + +/********************************************************* +* Routine to check if a given string matches exactly. +* Case can be significant or not. +**********************************************************/ + +#define exact_match(str, regexp, case_sig) \ + ((case_sig?strcmp(str,regexp):strcasecmp(str,regexp)) == 0) + +/******************************************************************* +find the difference in milliseconds between two struct timeval +values +********************************************************************/ + +#define TvalDiff(tvalold,tvalnew) \ + (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 + \ + ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000) + +/**************************************************************************** +true if two IP addresses are equal +****************************************************************************/ + +#define ip_equal(ip1,ip2) ((ip1).s_addr == (ip2).s_addr) + +/***************************************************************** + splits out the last subkey of a key + *****************************************************************/ + +#define reg_get_subkey(full_keyname, key_name, subkey_name) \ + split_at_last_component(full_keyname, key_name, '\\', subkey_name) + +/**************************************************************************** + Used by dptr_zero. +****************************************************************************/ + +#define DPTR_MASK ((uint32)(((uint32)1)<<31)) + +/**************************************************************************** + Return True if the offset is at zero. +****************************************************************************/ + +#define dptr_zero(buf) ((IVAL(buf,1)&~DPTR_MASK) == 0) + +/******************************************************************* +copy an IP address from one buffer to another +********************************************************************/ + +#define putip(dest,src) memcpy(dest,src,4) + +/**************************************************************************** + Make a filename into unix format. +****************************************************************************/ + +#define unix_format(fname) string_replace(fname,'\\','/') + +/**************************************************************************** + Make a file into DOS format. +****************************************************************************/ + +#define dos_format(fname) string_replace(fname,'/','\\') + +#endif /* _SMB_MACROS_H */ -- cgit From 952799d9afe028d822181831715b85521c89a7ef Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Wed, 8 Mar 2000 22:14:30 +0000 Subject: dded Microsoft Dfs services. * added a new msdfs/ directory under source/ * added msdfs sources under this directory. * modified configure setup to add a --with-msdfs configure time option Modified Files: Makefile.in acconfig.h configure configure.in include/config.h.in include/includes.h include/proto.h include/smb.h include/smb_macros.h param/loadparm.c smbd/negprot.c smbd/nttrans.c smbd/process.c smbd/reply.c smbd/server.c smbd/trans2.c Added Files: include/msdfs.h msdfs/README msdfs/msdfs.c msdfs/msdfs_tdb.c msdfs/parse_dfs_map.c ---------------------------------------------------------------------- (This used to be commit 4684b4a188b54493dbe7f0de2909a8d3c5c3ebf9) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 8fb1fdbb71..496787ee13 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -233,4 +233,5 @@ copy an IP address from one buffer to another #define dos_format(fname) string_replace(fname,'/','\\') + #endif /* _SMB_MACROS_H */ -- cgit From afd40c8cde7da44757b6d2e2b27e010aacda5c9e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Apr 2000 01:25:10 +0000 Subject: Ensure that CHECK_FNUM rejects fd == -1 correctly. Jeremy. (This used to be commit d2fff2596ad1585fc6a5e033fe8410fe5438a57b) --- source3/include/smb_macros.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 496787ee13..cc9f158af8 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -80,7 +80,10 @@ #define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) #define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ - return(ERROR(ERRDOS,ERRbadfid)) + return(ERROR(ERRDOS,ERRbadfid)); \ + else if((fsp)->fd == -1) \ + return(ERROR(ERRDOS,ERRbadaccess)) + #define CHECK_READ(fsp) if (!(fsp)->can_read) \ return(ERROR(ERRDOS,ERRbadaccess)) #define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ -- cgit From e82dbfcbe97c79b1c81915ae949bb2b1763970ba Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 24 Apr 2000 19:23:51 +0000 Subject: Now that fsp's are created on successful file open, the structure member fsp->open is no longer needed (if an fsp pointer is valid, then it's open :-). NB for Luke, this patch also did not apply to TNG. TNG is not yet identical w.r.t file serving with HEAD. This makes it impossible for me to help maintain TNG. Please fix asap. lib/substitute.c: Removed unused variable (pidstr). Jeremy. (This used to be commit 389b700a26e8a308a0dff6fc038c38068aa0119a) --- source3/include/smb_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index cc9f158af8..e7d05189cd 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -73,7 +73,7 @@ #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) /* these are useful macros for checking validity of handles */ -#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory) +#define OPEN_FSP(fsp) ((fsp) && !(fsp)->is_directory) #define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) @@ -150,7 +150,7 @@ #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ w->wr_discard = True, -1) /* Macro to test if an error has been cached for this fnum */ -#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ +#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ (fsp)->wbmpx_ptr->wr_discard) /* Macro to turn the cached error into an error packet */ #define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) -- cgit From 700f72453ed8dfd356a5591b9447127b5066ac4b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Apr 2000 11:04:28 +0000 Subject: - removed all our old wildcard matching code and replaced it with a call to ms_fnmatch(). This also removes all the Win9X semantics stuff and a bunch of other associated cruft. - moved the stat cache code into statcache.c - fixed the uint16 alignment requirements of ascii_to_unistr() and unistr_to_ascii() - trans2 SMB_FIND_FILE_BOTH_DIRECTORY_INFO returns the short name as unicode always (at least thats what NT4 does) - fixed some errors in the in-memory tdb code. Still ugly, but doesn't crash as much (This used to be commit 03e9cea004bbba72161a5323cf3b4556c94aed8e) --- source3/include/smb_macros.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index e7d05189cd..267b061f65 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -176,14 +176,6 @@ #define _smb_setlen(buf,len) buf[0] = 0; buf[1] = (len&0x10000)>>16; \ buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; -/********************************************************* -* Routine to check if a given string matches exactly. -* Case can be significant or not. -**********************************************************/ - -#define exact_match(str, regexp, case_sig) \ - ((case_sig?strcmp(str,regexp):strcasecmp(str,regexp)) == 0) - /******************************************************************* find the difference in milliseconds between two struct timeval values -- cgit From f0080e5a3979fac94d6668cf6ee9d9f61302839c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 17:01:34 +0000 Subject: Getting back to a compilable state (not there yet but close). Added patches for random -> sys_random. Added set_effective_xxx patches for AFS code. Memory allocation changes in spoolss code. Jeremy. (This used to be commit c2099cfb033c2cdb6035f4f7f50ce21b98e1584d) --- source3/include/smb_macros.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 267b061f65..51c7c1c638 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -42,14 +42,6 @@ #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) -/* memory-allocation-helpers (idea and names from glib) */ -#define g_new(type, count) \ - ((type *) malloc(sizeof(type) * (count))) -#define g_new0(type, count) \ - ((type *) calloc((count), sizeof(type))) -#define g_renew(type, mem, count) \ - ((type *) Realloc(mem, sizeof(type) * (count))) - /* zero a structure */ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -- cgit From ad98207f54a7e3d88108d34c4cf365d5f8bc23ef Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 9 Jun 2000 03:00:34 +0000 Subject: dynamic allocation of NET_USER_INFO_3 gids. jeremy, the intent is to call se_access_check() with usr-sid, grp-sid, array-of-group-rids (but array-of-group-sids would do). please do look at smbd/lanman.c's api_NetWkstaGetInfo, it will show you that we really do need to store the entire NET_USER_INFO_3 structure. then again, api_NetWkstaGetInfo is only used by win9x so who cares :) (This used to be commit bd34f652390adc32c4959d164c628687f526d977) --- source3/include/smb_macros.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 51c7c1c638..267b061f65 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -42,6 +42,14 @@ #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) +/* memory-allocation-helpers (idea and names from glib) */ +#define g_new(type, count) \ + ((type *) malloc(sizeof(type) * (count))) +#define g_new0(type, count) \ + ((type *) calloc((count), sizeof(type))) +#define g_renew(type, mem, count) \ + ((type *) Realloc(mem, sizeof(type) * (count))) + /* zero a structure */ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -- cgit From 03e0164270ffd7ceeb8df6f3cc3917c111dc05f8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Jun 2000 18:45:31 +0000 Subject: Luke, I am moving the code back into passdb/passdb.c, this the correct place to do this, not in smbd/passwd.c Please don't change this without asking first, I have run this past Andrew so talk to him (I'm on vacation next week). I also removed the g_newXXX macros. There are essentially a private C extension, not used anywhere else in the code, and add no functionality over malloc(XX) and make the code harder to understand (everyone knows what malloc does). Jeremy. (This used to be commit e1b1b6fb6794ba02e1fea510a981fa0ce0d12b58) --- source3/include/smb_macros.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 267b061f65..51c7c1c638 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -42,14 +42,6 @@ #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) -/* memory-allocation-helpers (idea and names from glib) */ -#define g_new(type, count) \ - ((type *) malloc(sizeof(type) * (count))) -#define g_new0(type, count) \ - ((type *) calloc((count), sizeof(type))) -#define g_renew(type, mem, count) \ - ((type *) Realloc(mem, sizeof(type) * (count))) - /* zero a structure */ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -- cgit From 7f36df301e28dc8ca0e5bfadc109d6e907d9ba2b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Aug 2000 18:32:34 +0000 Subject: Tidyup removing many of the 0xC0000000 | NT_STATUS_XXX stuff (only need NT_STATUS_XXX). Removed IS_BITS_xxx macros as they were just reproducing "C" syntax in a more obscure way. Jeremy. (This used to be commit c55bcec817f47d6162466b193d533c877194124a) --- source3/include/smb_macros.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 51c7c1c638..fe0d15149b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -30,11 +30,6 @@ #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) -#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) -#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) -#define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) -#define IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit)) - /* for readability... */ #define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) #define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) -- cgit From 50cef4fa0d5ee9ac9ae6d5f41f88320bf02e9fb8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 12 Aug 2000 14:10:27 +0000 Subject: removed (void) typecast from SMB_ASSERT jerry (This used to be commit f806881e6c2c94c03fb7e70d92cd0a5a3fc30fbd) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index fe0d15149b..9fe7f26cb3 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -54,7 +54,7 @@ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) /* assert macros */ -#define SMB_ASSERT(b) ((b)?(void)0: \ +#define SMB_ASSERT(b) ((b)?0: \ (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ __FILE__, __LINE__)), smb_panic("assert failed"))) #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) -- cgit From 83424f676e56bf7a5a83a64c841a04a12655d00c Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 14 Aug 2000 11:03:30 +0000 Subject: restored IS_BITS_SET_xxx macros. (This used to be commit bc065f9597654666e2f26ec046e058e44247d6e3) --- source3/include/smb_macros.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 9fe7f26cb3..007f88edba 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -30,6 +30,11 @@ #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) +#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) +#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) +#define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) +#define IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit)) + /* for readability... */ #define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) #define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) -- cgit From d8464d49c6356d742208dedeec9bea47068ae14c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 14 Aug 2000 23:48:07 +0000 Subject: Reverted the change Luke made. Removed IS_BITS_SET_XX macros. Do not re-add them. These macros are unsafe as they are not understood. Change all TNG code using them to correct '&' and '|' please. IS_BITS_SET_ALL was being used in cmd_interp.c when IS_BITS_SET_SOME should have been used. Jeremy. (This used to be commit be4e5eeb4f808c1d8ac4030e8886a83a37914c57) --- source3/include/smb_macros.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 007f88edba..9fe7f26cb3 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -30,11 +30,6 @@ #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) -#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit)) -#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0) -#define IS_BITS_CLR_ALL(var,bit) (((var)&(bit))==0) -#define IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit)) - /* for readability... */ #define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) #define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) -- cgit From ad81f44cdb77aa952db6f11b6e1e12ded616302d Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 26 Sep 2000 14:48:52 +0000 Subject: fixed IRIX compiller error message (This used to be commit 908da12d5f24ea076db6627ef0d4407e1cdcd014) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 9fe7f26cb3..fe0d15149b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -54,7 +54,7 @@ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) /* assert macros */ -#define SMB_ASSERT(b) ((b)?0: \ +#define SMB_ASSERT(b) ((b)?(void)0: \ (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ __FILE__, __LINE__)), smb_panic("assert failed"))) #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) -- cgit From 14a8906e8ca491f3c7aa413daab1eaff29dad576 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Oct 2000 03:41:48 +0000 Subject: Inlined many of the vfs_XXX calls as macros for speed. Jeremy. (This used to be commit 0811d080abd374f47c7c3c8a1ef007e443e5b79c) --- source3/include/smb_macros.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index fe0d15149b..a65b7048e9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -215,5 +215,46 @@ copy an IP address from one buffer to another #define dos_format(fname) string_replace(fname,'/','\\') +/******************************************************************* + vfs stat wrapper that calls dos_to_unix. +********************************************************************/ + +#define vfs_stat(conn, fname, st) ((conn)->vfs_ops.stat((conn), dos_to_unix((fname),False),(st))) + +/******************************************************************* + vfs fstat wrapper that calls dos_to_unix. +********************************************************************/ + +#define vfs_fstat(fsp, fd, st) ((fsp)->conn->vfs_ops.fstat((fsp),(fd),(st))) + +/******************************************************************* + vfs rmdir wrapper that calls dos_to_unix. +********************************************************************/ + +#define vfs_rmdir(conn,fname) ((conn)->vfs_ops.rmdir((conn),dos_to_unix((fname),False))) + +/******************************************************************* + vfs Unlink wrapper that calls dos_to_unix. +********************************************************************/ + +#define vfs_unlink(conn, fname) ((conn)->vfs_ops.unlink((conn),dos_to_unix((fname),False))) + +/******************************************************************* + vfs chmod wrapper that calls dos_to_unix. +********************************************************************/ + +#define vfs_chmod(conn,fname,mode) ((conn)->vfs_ops.chmod((conn),dos_to_unix((fname),False),(mode))) + +/******************************************************************* + vfs chown wrapper that calls dos_to_unix. +********************************************************************/ + +#define vfs_chown(conn,fname,uid,gid) ((conn)->vfs_ops.chown((conn),dos_to_unix((fname),False),(uid),(gid))) + +/******************************************************************* + A wrapper for vfs_chdir(). +********************************************************************/ + +#define vfs_chdir(conn,fname) ((conn)->vfs_ops.chdir((conn),dos_to_unix((fname),False))) #endif /* _SMB_MACROS_H */ -- cgit From abf055046fe70842badc2a1904f2cd6966bafbf4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Oct 2000 02:58:24 +0000 Subject: Ok - this is a big patch - and it may break smbd a bit (although I hope not). If you encounter strange file-serving behavior after this patch then back it out. I analysed our stat() usage and realised we were doing approx. 3 stat calls per open, and 2 per getattr/setattr. This patch should fix all that. It causes the stat struct returned from unix_convert() (which now *must* be passed a valid SMB_STRUCT_STAT pointer) to be passed through into the open code. This should prevent the multiple stats that were being done so as not to violate layer encapsulation in the API's. Herb - if you could run a NetBench test with this code and do a padc/par syscall test and also run with the current 2.2.0 code and test the padc/par syscalls I'd appreciate it - you should find the number of stat calls reduced - not sure by how much. The patch depends on unix_convert() actually finding the file and returning a stat struct, or returning a zero'd out stat struct if the file didn't exist. I believe we can guarentee this to be the case - I just wasn't confident enough to make this an assertion before. Ok ok - I did write this whilst at the Miami conference..... sometimes you get a little free time at these things :-). Jeremy. (This used to be commit 66a5c05ec46b641224fbe01b30bd7e83571a2a1b) --- source3/include/smb_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index a65b7048e9..2e74d7e69f 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -104,8 +104,8 @@ * stat structure is valid. */ -#define VALID_STAT(st) (st.st_nlink != 0) -#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR(st.st_mode)) +#define VALID_STAT(st) ((st).st_nlink != 0) +#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_mode)) #define SMBENCRYPT() (lp_encrypted_passwords()) -- cgit From 5b69009b25886bfa8b07e3ac885064ffa730f9bf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 2 Jul 2001 02:42:41 +0000 Subject: Fixed the nastiest locking bug to track down.... smb_pids are sent in the lockingX calls - use that instead of smb_pid in the packet. Jeremy. (This used to be commit a3925cb9c6303ce24e5fecad6c8f3a0ba78b9ee0) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 2e74d7e69f..cad6229f1a 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -128,6 +128,7 @@ #define SMB_LPID_OFFSET(indx) (10 * (indx)) #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx))) #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx))) +#define SMB_LARGE__LPID_OFFSET(indx) (20 * (indx)) #define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx))) #define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/include/smb_macros.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index cad6229f1a..b168d68862 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -217,45 +217,45 @@ copy an IP address from one buffer to another #define dos_format(fname) string_replace(fname,'/','\\') /******************************************************************* - vfs stat wrapper that calls dos_to_unix. + vfs stat wrapper that calls internal2unix. ********************************************************************/ -#define vfs_stat(conn, fname, st) ((conn)->vfs_ops.stat((conn), dos_to_unix((fname),False),(st))) +#define vfs_stat(conn, fname, st) ((conn)->vfs_ops.stat((conn), fname,(st))) /******************************************************************* - vfs fstat wrapper that calls dos_to_unix. + vfs fstat wrapper ********************************************************************/ #define vfs_fstat(fsp, fd, st) ((fsp)->conn->vfs_ops.fstat((fsp),(fd),(st))) /******************************************************************* - vfs rmdir wrapper that calls dos_to_unix. + vfs rmdir wrapper that calls internal2unix. ********************************************************************/ -#define vfs_rmdir(conn,fname) ((conn)->vfs_ops.rmdir((conn),dos_to_unix((fname),False))) +#define vfs_rmdir(conn,fname) ((conn)->vfs_ops.rmdir((conn),fname)) /******************************************************************* - vfs Unlink wrapper that calls dos_to_unix. + vfs Unlink wrapper that calls internal2unix. ********************************************************************/ -#define vfs_unlink(conn, fname) ((conn)->vfs_ops.unlink((conn),dos_to_unix((fname),False))) +#define vfs_unlink(conn, fname) ((conn)->vfs_ops.unlink((conn),fname)) /******************************************************************* - vfs chmod wrapper that calls dos_to_unix. + vfs chmod wrapper that calls internal2unix. ********************************************************************/ -#define vfs_chmod(conn,fname,mode) ((conn)->vfs_ops.chmod((conn),dos_to_unix((fname),False),(mode))) +#define vfs_chmod(conn,fname,mode) ((conn)->vfs_ops.chmod((conn),fname,(mode))) /******************************************************************* - vfs chown wrapper that calls dos_to_unix. + vfs chown wrapper that calls internal2unix. ********************************************************************/ -#define vfs_chown(conn,fname,uid,gid) ((conn)->vfs_ops.chown((conn),dos_to_unix((fname),False),(uid),(gid))) +#define vfs_chown(conn,fname,uid,gid) ((conn)->vfs_ops.chown((conn),fname,(uid),(gid))) /******************************************************************* A wrapper for vfs_chdir(). ********************************************************************/ -#define vfs_chdir(conn,fname) ((conn)->vfs_ops.chdir((conn),dos_to_unix((fname),False))) +#define vfs_chdir(conn,fname) ((conn)->vfs_ops.chdir((conn),fname)) #endif /* _SMB_MACROS_H */ -- cgit From 996719cce26700c68ff0e456e6a25d20085d091f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Jul 2001 22:21:31 +0000 Subject: Added "use mmap" for HPUX. Jeremy. (This used to be commit 840802f10677cb0009cb4df4c37c7d01aa5edacd) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b168d68862..e1deaf58ea 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -258,4 +258,5 @@ copy an IP address from one buffer to another #define vfs_chdir(conn,fname) ((conn)->vfs_ops.chdir((conn),fname)) +#define USE_TDB_MMAP_FLAG (!lp_use_mmap() ? TDB_NOMMAP : TDB_DEFAULT) #endif /* _SMB_MACROS_H */ -- cgit From e8e98c9ea0690e3acf1126b50882e59e1056c7b3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 08:19:43 +0000 Subject: converted smbd to use NTSTATUS by default major changes include: - added NSTATUS type - added automatic mapping between dos and nt error codes - changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT() these calls auto-translate to the client error code system - got rid of the cached error code and the writebmpx code We eventually will need to also: - get rid of BOOL, so we don't lose error info - replace all ERROR_DOS() calls with ERROR_NT() calls but that is too much for one night (This used to be commit 83d9896c1ea8be796192b51a4678c2a3b87f7518) --- source3/include/smb_macros.h | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index e1deaf58ea..0c66a8e7a9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -67,16 +67,14 @@ #define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) #define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ - return(ERROR(ERRDOS,ERRbadfid)); \ + return(ERROR_DOS(ERRDOS,ERRbadfid)); \ else if((fsp)->fd == -1) \ - return(ERROR(ERRDOS,ERRbadaccess)) + return(ERROR_DOS(ERRDOS,ERRbadaccess)) #define CHECK_READ(fsp) if (!(fsp)->can_read) \ - return(ERROR(ERRDOS,ERRbadaccess)) + return(ERROR_DOS(ERRDOS,ERRbadaccess)) #define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ - return(ERROR(ERRDOS,ERRbadaccess)) -#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ - return(CACHED_ERROR(fsp)) + return(ERROR_DOS(ERRDOS,ERRbadaccess)) /* translates a connection number into a service number */ #define SNUM(conn) ((conn)?(conn)->service:-1) @@ -134,22 +132,15 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) -/* Macro to cache an error in a write_bmpx_struct */ -#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ - w->wr_discard = True, -1) -/* Macro to test if an error has been cached for this fnum */ -#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ - (fsp)->wbmpx_ptr->wr_discard) -/* Macro to turn the cached error into an error packet */ -#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) - /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 -#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__) +#define ERROR_DOS(class,code) error_packet(outbuf,0,class,code,__LINE__) +#define ERROR_NT(status) error_packet(outbuf,status,0,0,__LINE__) +#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,__LINE__) /* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__) +#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__) #define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) -- cgit From ee5f7237decfe446f4fdb08422beb2e6cb43af7f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 17:52:23 +0000 Subject: started converting NTSTATUS to be a structure on systems with gcc in order to make it type incompatible with BOOL so we catch errors sooner. This has already found a number of bugs (This used to be commit 1b778bc7d22efff3f90dc450eb12baa1241cf68f) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 0c66a8e7a9..4e8868be74 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -135,7 +135,7 @@ /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 -#define ERROR_DOS(class,code) error_packet(outbuf,0,class,code,__LINE__) +#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,__LINE__) #define ERROR_NT(status) error_packet(outbuf,status,0,0,__LINE__) #define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,__LINE__) -- cgit From 851a06e1fd6ac0d921f96fe9e9529129b4b4c01d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Sep 2001 10:18:58 +0000 Subject: added filename to error_packet() (This used to be commit 2c424788dec2fd6e44c243ea115d66689dfae6c0) --- source3/include/smb_macros.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 4e8868be74..d28ef6f068 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -135,12 +135,12 @@ /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 -#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,__LINE__) -#define ERROR_NT(status) error_packet(outbuf,status,0,0,__LINE__) -#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,__LINE__) +#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(outbuf,status,0,0,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,__LINE__,__FILE__) /* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__) +#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) #define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) -- cgit From fc07eb5eefe30336c4feb2dfa9923f19303a85f6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Sep 2001 10:37:21 +0000 Subject: - fixed proto.h build on systems using a parallel make - changed DENY1 and DENY2 tests to only report errors (This used to be commit 9341e5534d0786e6ad7980e5fd1a0b35d77a2806) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index d28ef6f068..f6d547ea53 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -53,6 +53,9 @@ /* pointer difference macro */ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) +/* work out how many elements there are in a static array */ +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) + /* assert macros */ #define SMB_ASSERT(b) ((b)?(void)0: \ (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ -- cgit From 9a9ac2739bbdc993ecdfa78298bdd9c059328378 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Sep 2001 22:08:19 +0000 Subject: got rid of USE_TDB_MMAP_FLAG as its not needed any more (This used to be commit c26e0d3f27a05ecc8bd2390f9aab7f9451524e47) --- source3/include/smb_macros.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index f6d547ea53..315cb5e5ee 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -252,5 +252,4 @@ copy an IP address from one buffer to another #define vfs_chdir(conn,fname) ((conn)->vfs_ops.chdir((conn),fname)) -#define USE_TDB_MMAP_FLAG (!lp_use_mmap() ? TDB_NOMMAP : TDB_DEFAULT) #endif /* _SMB_MACROS_H */ -- cgit From b30e75692d68233448b3ad3d7ddd4b4ac423d3ab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Sep 2001 11:08:57 +0000 Subject: replaced stdio in many parts of samba with a XFILE. XFILE is a cut-down replacemnt of stdio that doesn't suffer from the 8-bit filedescriptor limit that we hit with nasty consequences on some systems I would eventually prefer us to have a configure test to see if we need to replace stdio, but for now this code needs to be tested widely so I'm enabling it by default. (This used to be commit 1af8bf34f1caa3e7ec312d8109c07d32a945a448) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 315cb5e5ee..52649ffc39 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -41,7 +41,7 @@ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) /* zero a structure given a pointer to the structure */ -#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } +#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) /* zero a structure given a pointer to the structure - no zero check */ #define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) -- cgit From e2d393bd24e5b8ae3588828113993399bb105b32 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 00:47:40 +0000 Subject: introduce SAFE_FREE() macro as suggested by andreas moroder. (This used to be commit b7edd55885791f9aded11a0b0a131e02a819f374) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 52649ffc39..bf6e3c9fb9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -37,6 +37,9 @@ #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) +/* free memory if the pointer is valid and zero the pointer */ +#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) + /* zero a structure */ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -- cgit From 73f8da3a87864695ff6a2baca429f424cf50c661 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 30 Sep 2001 01:39:47 +0000 Subject: Finally kill off the SMBENCRYPT() macro. (This used to be commit 05910483351e9ef6375e4c49403ebe21b56315a9) --- source3/include/smb_macros.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index bf6e3c9fb9..b4264937cf 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -111,8 +111,6 @@ #define VALID_STAT(st) ((st).st_nlink != 0) #define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_mode)) -#define SMBENCRYPT() (lp_encrypted_passwords()) - #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif -- cgit From 6cc3953196e3feb340f7b9b7bb823575414c5683 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 19 Oct 2001 00:56:03 +0000 Subject: Restored old Bmpx code - actually used by OS/2. Jeremy. (This used to be commit 7c1688fd67c1bda1477aaf870371c825280db870) --- source3/include/smb_macros.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b4264937cf..05a358573d 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -82,6 +82,9 @@ #define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ return(ERROR_DOS(ERRDOS,ERRbadaccess)) +#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ + return(CACHED_ERROR(fsp)) + /* translates a connection number into a service number */ #define SNUM(conn) ((conn)?(conn)->service:-1) @@ -136,6 +139,15 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) +/* Macro to cache an error in a write_bmpx_struct */ +#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ + w->wr_discard = True, -1) +/* Macro to test if an error has been cached for this fnum */ +#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ + (fsp)->wbmpx_ptr->wr_discard) +/* Macro to turn the cached error into an error packet */ +#define CACHED_ERROR(fsp) cached_error_packet(outbuf,fsp,__LINE__,__FILE__) + /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 -- cgit From 740d6f5dd60bef72037ed5fcd7b2192af22c2e41 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 4 Nov 2001 18:26:53 +0000 Subject: a big one: - old mangle code has gone, the new one based on tdb seem resonably ok probably the valid.dat table need to be updated to treat wild chars as invalid ones (work ok without it) - a LOT of new string manipulation function for unicode, they are somewhat tested but a review would not be bad - some new function I will need for the new unix_convert function I'm writing, this will be renamed filename_convert and use only unicode strings. - charconv, I attached a comment, if someone wnat to look if I'm right or just was hacking to late in the night to make a sane one :) of course any bug is my responsibility an will be pleased to see patches if you find any. :-) Simo. (This used to be commit ee19f7efb6ea9216fc91cf112ac1afa691983e9d) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 05a358573d..9978a0faa0 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -216,6 +216,7 @@ copy an IP address from one buffer to another ****************************************************************************/ #define unix_format(fname) string_replace(fname,'\\','/') +#define unix_format_w(fname) string_replace_w(fname, UCS2_CHAR('\\'), UCS2_CHAR('/')) /**************************************************************************** Make a file into DOS format. -- cgit From 67f5bea4849dd51df0b9467d033fd000a129ce3f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Nov 2001 20:34:12 +0000 Subject: Fixup __LPID -> _LPID. Jeremy. (This used to be commit ab607cdf153d9187fe50af3377ece5a9fafde1b1) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 9978a0faa0..42d66b676a 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -133,7 +133,7 @@ #define SMB_LPID_OFFSET(indx) (10 * (indx)) #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx))) #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx))) -#define SMB_LARGE__LPID_OFFSET(indx) (20 * (indx)) +#define SMB_LARGE_LPID_OFFSET(indx) (20 * (indx)) #define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx))) #define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) -- cgit From 22afba62c9add7efa0de76defd8abb9b352473e2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Nov 2001 01:00:54 +0000 Subject: Fixed allocation bug in database prog. Some format fixes. Jeremy. (This used to be commit 9ff6b0c20cc88ef0bcd62a596fcb96f898b5b29d) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 42d66b676a..44b8c26da9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -159,6 +159,7 @@ #define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) #define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) +#define SMB_ROUNDUP_ALLOCATION(s) (SMB_ROUNDUP((SMB_OFF_T)((s)+1), ((SMB_OFF_T)SMB_ROUNDUP_ALLOCATION_SIZE))) /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ #define smb_buf(buf) (buf + smb_size + CVAL(buf,smb_wct)*2) -- cgit From ba1b5383cc282b95e6dabbc4174c9084383dbd31 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 3 Jan 2002 03:07:51 +0000 Subject: Welcome to preprocessor hell. Had to put a #ifndef around SAFE_FREE to stop smb_macros.h and tdb.h from fighting with each other. I tried to rearrange the #include file order but that breaks other stuff. Aargh! (This used to be commit aae8cc6e450a6a0b33045ed1e6d49f8eebeb48b2) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 44b8c26da9..de6f1dc3ba 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -38,7 +38,10 @@ #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) /* free memory if the pointer is valid and zero the pointer */ + +#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */ #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) +#endif /* zero a structure */ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -- cgit From 092f962b9ca33c932b2dc852938d2233b0eff4ca Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Thu, 3 Jan 2002 07:49:07 +0000 Subject: Clarify doc for SAFE_FREE. (This used to be commit 269a7d3c9ba8ca1444653c1aa56b843b8b1df08b) --- source3/include/smb_macros.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index de6f1dc3ba..2b5be96e7f 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -1,6 +1,5 @@ /* Unix SMB/Netbios implementation. - Version 1.9. SMB parameters and setup Copyright (C) Andrew Tridgell 1992-1999 Copyright (C) John H Terpstra 1996-1999 @@ -37,9 +36,14 @@ #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) -/* free memory if the pointer is valid and zero the pointer */ - #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 -- cgit From a36c10bd1e801228a002b2cdbecfe1fb6c3181a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Jan 2002 02:41:15 +0000 Subject: First part of UNIX extensions (#ifdefed out) more to follow. Jeremy. (This used to be commit 02b18f2cca6d6d046d2d8fd7375b207d44031ddc) --- source3/include/smb_macros.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 2b5be96e7f..83ee12936c 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -238,6 +238,12 @@ copy an IP address from one buffer to another #define vfs_stat(conn, fname, st) ((conn)->vfs_ops.stat((conn), fname,(st))) +/******************************************************************* + vfs lstat wrapper that calls internal2unix. +********************************************************************/ + +#define vfs_lstat(conn, fname, st) ((conn)->vfs_ops.lstat((conn), fname,(st))) + /******************************************************************* vfs fstat wrapper ********************************************************************/ -- cgit From 0173911b46412b520e37b090cf65382f2f5fca38 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Jan 2002 20:13:28 +0000 Subject: Added CIFS UNIX extension code to client. Jeremy. (This used to be commit 794c3e2c76aae57d054e46b185def104ca02977c) --- source3/include/smb_macros.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 83ee12936c..15a10f0104 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -219,6 +219,12 @@ copy an IP address from one buffer to another #define putip(dest,src) memcpy(dest,src,4) +/******************************************************************* + Return True if a server has CIFS UNIX capabilities. +********************************************************************/ + +#define SERVER_HAS_UNIX_CIFS(c) ((c)->capabilities & CAP_UNIX) + /**************************************************************************** Make a filename into unix format. ****************************************************************************/ -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 15a10f0104..3fdd90f510 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -1,5 +1,5 @@ /* - Unix SMB/Netbios implementation. + Unix SMB/CIFS implementation. SMB parameters and setup Copyright (C) Andrew Tridgell 1992-1999 Copyright (C) John H Terpstra 1996-1999 -- cgit From 5e3b923124e82b1d19875746676df13cfdb0f918 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 13 Mar 2002 20:28:19 +0000 Subject: include/smb_macros.h: Don't round up an allocation if the size is zero. "One of these locks is not like the others... One of these locks is not quite the same" :-). When is a zero timeout lock not zero ? When it's being processed by Windows 2000 of course.. This code change, ugly though it is - completely fixes the foxpro/access multi-user file system database problems that people have been having. I used a *wonderful* test program donated by "Gerald Drouillard" which allowed me to completely reproduce this problem, and to finally determine the correct fix. This also explains why Windows 2000 is *so slow* when responding to the smbtorture lock tests. I *love* it when all these things come together and finally make sense :-). Jeremy. (This used to be commit 8aa9860ea2ea7f5aed4b6aa12794fffdfa81b0d0) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 3fdd90f510..c19be784a1 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -166,7 +166,7 @@ #define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) #define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) -#define SMB_ROUNDUP_ALLOCATION(s) (SMB_ROUNDUP((SMB_OFF_T)((s)+1), ((SMB_OFF_T)SMB_ROUNDUP_ALLOCATION_SIZE))) +#define SMB_ROUNDUP_ALLOCATION(s) ((s) ? (SMB_ROUNDUP((SMB_OFF_T)((s)+1), ((SMB_OFF_T)SMB_ROUNDUP_ALLOCATION_SIZE))) : 0 ) /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ #define smb_buf(buf) (buf + smb_size + CVAL(buf,smb_wct)*2) -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/include/smb_macros.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index c19be784a1..a2351c705e 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -169,9 +169,12 @@ #define SMB_ROUNDUP_ALLOCATION(s) ((s) ? (SMB_ROUNDUP((SMB_OFF_T)((s)+1), ((SMB_OFF_T)SMB_ROUNDUP_ALLOCATION_SIZE))) : 0 ) /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ -#define smb_buf(buf) (buf + smb_size + CVAL(buf,smb_wct)*2) +#define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2) #define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) +/* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */ +#define smb_bufrem(buf, p) (smb_buflen(buf)-PTR_DIFF(p, smb_buf(buf))) + /* Note that chain_size must be available as an extern int to this macro. */ #define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size) -- cgit From a834a73e341059be154426390304a42e4a011f72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 15:19:00 +0000 Subject: sync'ing up for 3.0alpha20 release (This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139) --- source3/include/smb_macros.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index a2351c705e..71d4bac795 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -80,17 +80,20 @@ #define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) #define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ - return(ERROR_DOS(ERRDOS,ERRbadfid)); \ - else if((fsp)->fd == -1) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess)) + return(ERROR_DOS(ERRDOS,ERRbadfid)); \ + else if((fsp)->fd == -1) \ + return(ERROR_DOS(ERRDOS,ERRbadaccess)) #define CHECK_READ(fsp) if (!(fsp)->can_read) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess)) + return(ERROR_DOS(ERRDOS,ERRbadaccess)) #define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess)) + return(ERROR_DOS(ERRDOS,ERRbadaccess)) #define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ - return(CACHED_ERROR(fsp)) + return(CACHED_ERROR(fsp)) + +#define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \ + NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) ) /* translates a connection number into a service number */ #define SNUM(conn) ((conn)?(conn)->service:-1) @@ -165,8 +168,7 @@ /* this is how errors are generated */ #define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) -#define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) -#define SMB_ROUNDUP_ALLOCATION(s) ((s) ? (SMB_ROUNDUP((SMB_OFF_T)((s)+1), ((SMB_OFF_T)SMB_ROUNDUP_ALLOCATION_SIZE))) : 0 ) +#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x)) /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ #define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2) -- cgit From 99cdb462083381c88689a4e698ca48b6ed4cf5ac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jan 2003 18:57:41 +0000 Subject: *lots of small merges form HEAD *sync up configure.in *don't build torture tools in make all *make sure to remove torture tools as part of make clean (This used to be commit 0fb724b3216eeeb97e61ff12755ca3a31bcad6ef) --- source3/include/smb_macros.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 71d4bac795..999850b8eb 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -100,8 +100,6 @@ /* access various service details */ #define SERVICE(snum) (lp_servicename(snum)) -#define PRINTCAP (lp_printcapname()) -#define PRINTCOMMAND(snum) (lp_printcommand(snum)) #define PRINTERNAME(snum) (lp_printername(snum)) #define CAN_WRITE(conn) (!conn->read_only) #define VALID_SNUM(snum) (lp_snum_ok(snum)) -- cgit From 045db5d0458b331e987d82d6e9a61a0b85957d17 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Apr 2003 22:31:37 +0000 Subject: Ensure we have WinXP-like semantics for checking TIDs and FIDs. Jeremy. (This used to be commit 52e44dde4ef9717eae7cf454f56d309fdd4b7d1f) --- source3/include/smb_macros.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 999850b8eb..45fa23b87d 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -77,12 +77,15 @@ #define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) -#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) +#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) -#define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ +#define CHECK_FSP(fsp,conn) do {\ + extern struct current_user current_user;\ + if (!FNUM_OK(fsp,conn)) \ return(ERROR_DOS(ERRDOS,ERRbadfid)); \ else if((fsp)->fd == -1) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess)) + return(ERROR_DOS(ERRDOS,ERRbadaccess));\ + } while(0) #define CHECK_READ(fsp) if (!(fsp)->can_read) \ return(ERROR_DOS(ERRDOS,ERRbadaccess)) -- cgit From 245397cc0df08755a2fa931bac7c47b6de64d24e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 14 Apr 2003 10:30:38 +0000 Subject: Fix _smb_setlen to be non {} safe. Jeremy. (This used to be commit 35d1e3a5e08d075e7e7d9f7f62d36730853f648a) --- source3/include/smb_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 45fa23b87d..8efb966d0b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -182,8 +182,8 @@ #define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size) #define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16)) -#define _smb_setlen(buf,len) buf[0] = 0; buf[1] = (len&0x10000)>>16; \ - buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; +#define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = (len&0x10000)>>16; \ + buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0) /******************************************************************* find the difference in milliseconds between two struct timeval -- cgit From 1f008c1203b082039a9824c186fa2eda730c6f46 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 24 Apr 2003 03:46:17 +0000 Subject: Patch from Stephan Metzmacher to add default arguments to lp_parm() smb.conf parameters. Does not break binary compatibility with older modules. (This used to be commit 147c4d56d873a20a49194c5b036a3694299b1b48) --- source3/include/smb_macros.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 8efb966d0b..b39c7a0ebc 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -98,8 +98,11 @@ #define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \ NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) ) +/* the service number for the [globals] defaults */ +#define GLOBAL_SECTION_SNUM (-1) /* translates a connection number into a service number */ -#define SNUM(conn) ((conn)?(conn)->service:-1) +#define SNUM(conn) ((conn)?(conn)->service:GLOBAL_SECTION_SNUM) + /* access various service details */ #define SERVICE(snum) (lp_servicename(snum)) -- cgit From e7c8c15888454043c73967635deb4d3419a489e9 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Sun, 11 May 2003 23:34:18 +0000 Subject: Fix VFS layer: 1. Finally work with cascaded modules with private data storage per module 2. Convert VFS API to macro calls to simplify cascading 3. Add quota support to VFS layer (prepare to NT quota support) Patch by Stefan (metze) Metzemacher, with review of Jelmer and me Tested in past few weeks. Documentation to new VFS API for third-party developers to follow (This used to be commit 91984ef5caa2d13c5d52e1f535bd3bbbae1ec978) --- source3/include/smb_macros.h | 48 -------------------------------------------- 1 file changed, 48 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b39c7a0ebc..aae3b46f7a 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -247,52 +247,4 @@ copy an IP address from one buffer to another #define dos_format(fname) string_replace(fname,'/','\\') -/******************************************************************* - vfs stat wrapper that calls internal2unix. -********************************************************************/ - -#define vfs_stat(conn, fname, st) ((conn)->vfs_ops.stat((conn), fname,(st))) - -/******************************************************************* - vfs lstat wrapper that calls internal2unix. -********************************************************************/ - -#define vfs_lstat(conn, fname, st) ((conn)->vfs_ops.lstat((conn), fname,(st))) - -/******************************************************************* - vfs fstat wrapper -********************************************************************/ - -#define vfs_fstat(fsp, fd, st) ((fsp)->conn->vfs_ops.fstat((fsp),(fd),(st))) - -/******************************************************************* - vfs rmdir wrapper that calls internal2unix. -********************************************************************/ - -#define vfs_rmdir(conn,fname) ((conn)->vfs_ops.rmdir((conn),fname)) - -/******************************************************************* - vfs Unlink wrapper that calls internal2unix. -********************************************************************/ - -#define vfs_unlink(conn, fname) ((conn)->vfs_ops.unlink((conn),fname)) - -/******************************************************************* - vfs chmod wrapper that calls internal2unix. -********************************************************************/ - -#define vfs_chmod(conn,fname,mode) ((conn)->vfs_ops.chmod((conn),fname,(mode))) - -/******************************************************************* - vfs chown wrapper that calls internal2unix. -********************************************************************/ - -#define vfs_chown(conn,fname,uid,gid) ((conn)->vfs_ops.chown((conn),fname,(uid),(gid))) - -/******************************************************************* - A wrapper for vfs_chdir(). -********************************************************************/ - -#define vfs_chdir(conn,fname) ((conn)->vfs_ops.chdir((conn),fname)) - #endif /* _SMB_MACROS_H */ -- cgit From f51d769dd303027a3dbf46fc89a482933988e866 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Jun 2003 17:41:05 +0000 Subject: large change: *) consolidates the dc location routines again (dns and netbios) get_dc_list() or get_sorted_dc_list() is the authoritative means of locating DC's again. (also inludes a flag to get_dc_list() to define if this should be a DNS only lookup or not) (however, if you set "name resolve order = hosts wins" you could still get DNS queries for domain name IFF ldap_domain2hostlist() fails. The answer? Fix your DNS setup) *) enabled DOMAIN<0x1c> lookups to be funneled through resolve_hosts resulting in a call to ldap_domain2hostlist() if lp_security() == SEC_ADS *) enables name cache for winbind ADS backend *) enable the negative connection cache for winbind ADS backend *) removes some old dead code *) consolidates some duplicate code *) moves the internal_name_resolve() to use an IP/port pair to deal with SRV RR dns replies. The namecache code also supports the IP:port syntax now as well. *) removes 'ads server' and moves the functionality back into 'password server' (which can support "hostname:port" syntax now but works fine with defaults depending on the value of lp_security()) (This used to be commit d7f7fcda425bef380441509734eca33da943c091) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index aae3b46f7a..7fcf872b60 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -202,6 +202,7 @@ true if two IP addresses are equal ****************************************************************************/ #define ip_equal(ip1,ip2) ((ip1).s_addr == (ip2).s_addr) +#define ip_service_equal(ip1,ip2) ( ((ip1).ip.s_addr == (ip2).ip.s_addr) && ((ip1).port == (ip2).port) ) /***************************************************************** splits out the last subkey of a key -- cgit From f2659351017a8b2ec12548a3967cdf2767738e08 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 30 Jun 2003 17:24:59 +0000 Subject: * rename samstrict auth method to sam * rename original sam auth method to sam_ignoredomain * remove samstrict_dc auth method (now covered by 'sam') * fix wbinfo -a '...' and getent passwd bugs when running winbindd on a samba PDC (reported by Volker) (This used to be commit 52166faee793d337e045d64f7cb27ea7ac895f60) --- source3/include/smb_macros.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 7fcf872b60..40b114a6b9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -248,4 +248,11 @@ copy an IP address from one buffer to another #define dos_format(fname) string_replace(fname,'/','\\') +/***************************************************************************** + Check to see if we are a DO for this domain +*****************************************************************************/ + +#define IS_DC_FOR_DOMAIN(x) ( (lp_server_role()==ROLE_DOMAIN_PDC || lp_server_role()==ROLE_DOMAIN_BDC) \ + && strequal((x), lp_workgroup()) ) + #endif /* _SMB_MACROS_H */ -- cgit From 0b18acb841f6a372b3aa285d4734875e5e35fe3b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 7 Jul 2003 05:11:10 +0000 Subject: and so it begins.... * remove idmap_XX_to_XX calls from smbd. Move back to the the winbind_XXX and local_XXX calls used in 2.2 * all uid/gid allocation must involve winbindd now * move flags field around in winbindd_request struct * add WBFLAG_QUERY_ONLY option to winbindd_sid_to_[ug]id() to prevent automatic allocation for unknown SIDs * add 'winbind trusted domains only' parameter to force a domain member server to use matching users names from /etc/passwd for its domain (needed for domain member of a Samba domain) * rename 'idmap only' to 'enable rid algorithm' for better clarity (defaults to "yes") code has been tested on * domain member of native mode 2k domain * ads domain member of native mode 2k domain * domain member of NT4 domain * domain member of Samba domain * Samba PDC running winbindd with trusts Logons tested using 2k clients and smbclient as domain users and trusted users. Tested both 'winbind trusted domains only = [yes|no]' This will be a long week of changes. The next item on the list is winbindd_passdb.c & machine trust accounts not in /etc/passwd (done via winbindd_passdb) (This used to be commit 8266dffab4aedba12a33289ff32880037ce950a8) --- source3/include/smb_macros.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 40b114a6b9..21ccdf295c 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -252,7 +252,6 @@ copy an IP address from one buffer to another Check to see if we are a DO for this domain *****************************************************************************/ -#define IS_DC_FOR_DOMAIN(x) ( (lp_server_role()==ROLE_DOMAIN_PDC || lp_server_role()==ROLE_DOMAIN_BDC) \ - && strequal((x), lp_workgroup()) ) +#define IS_DC (lp_server_role()==ROLE_DOMAIN_PDC || lp_server_role()==ROLE_DOMAIN_BDC) #endif /* _SMB_MACROS_H */ -- cgit From a83bac7571d067b672a181942c8fea6ffbfcc33f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Aug 2003 21:47:46 +0000 Subject: Shadow copy API - Original work by "Ken Cross" , adapted into a patch by "Stefan (metze) Metzmacher" . Jeremy. (This used to be commit ce5c91d35dabc5ff6fb3df2b259ed186d6a7e0da) --- source3/include/smb_macros.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 21ccdf295c..178fd9c358 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -77,6 +77,12 @@ #define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) +#define FSP_BELONGS_CONN(fsp,conn) do {\ + extern struct current_user current_user;\ + if (!((fsp) && (conn) && ((conn)==(fsp)->conn) && (current_user.vuid==(fsp)->vuid))) \ + return(ERROR_DOS(ERRDOS,ERRbadfid));\ + } while(0) + #define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) #define CHECK_FSP(fsp,conn) do {\ -- cgit From fba5a722497c1e4577aa463921a0fec5f6d5fe55 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 3 Mar 2004 20:55:59 +0000 Subject: Use a common function to parse all pathnames from the wire. This allows much closer emulation of Win2k3 error return codes. Jeremy. (This used to be commit c9f31fafeda6ad79e590276f36e03ecd2e93f818) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 178fd9c358..c3bdba30b1 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -245,6 +245,7 @@ copy an IP address from one buffer to another Make a filename into unix format. ****************************************************************************/ +#define IS_DIRECTORY_SEP(c) ((c) == '\\' || (c) == '/') #define unix_format(fname) string_replace(fname,'\\','/') #define unix_format_w(fname) string_replace_w(fname, UCS2_CHAR('\\'), UCS2_CHAR('/')) -- cgit From 1843f6905caf30de6493de07316a416696394d3e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 4 May 2004 23:01:00 +0000 Subject: r478: Added Volkers fix to be able to force DOS errors when needed. Jeremy. (This used to be commit a9d1738ebab42ab9bab73f18341d79e086e290b3) --- source3/include/smb_macros.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index c3bdba30b1..e847714443 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -171,9 +171,10 @@ /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 -#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,__LINE__,__FILE__) -#define ERROR_NT(status) error_packet(outbuf,status,0,0,__LINE__,__FILE__) -#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,__LINE__,__FILE__) +#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,False,__LINE__,__FILE__) +#define ERROR_FORCE_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,True,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(outbuf,status,0,0,False,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,False,__LINE__,__FILE__) /* this is how errors are generated */ #define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) -- cgit From e0da56a84808c522bc7324b5d636f1cbd317a2c5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 May 2004 18:37:47 +0000 Subject: r570: Remove lots of globals to handle case issues - move them to connection struct entries (as they should have been from the start). Jerry, once you've cut over to 3.0.4 release branch I'll add this to 3.0 also. - Jerry cut over :-). Jeremy. (This used to be commit 578a508509d21226ad3332fc54c3ab54cd8ae452) --- source3/include/smb_macros.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index e847714443..bcbaa64f86 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -122,9 +122,9 @@ #define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service)) #define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service)) #define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service)) -#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list)) -#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list)) -#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list)) +#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list,(conn)->case_sensitive)) +#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list,(conn)->case_sensitive)) +#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list,(conn)->case_sensitive)) /* * Used by the stat cache code to check if a returned -- cgit From db2ffe10f9283c86f95ae76d38c21916065a4b87 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Aug 2004 23:20:47 +0000 Subject: r2076: Removed old dir caching code - not being used now we have the statcache anyway. New dir caching will be done on nanosecond timestamps. Jeremy. (This used to be commit ba473a580245430009245a4c8b8dcaf9fc4b6406) --- source3/include/smb_macros.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index bcbaa64f86..a9e911c066 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -26,7 +26,6 @@ /* Misc bit macros */ #define BOOLSTR(b) ((b) ? "Yes" : "No") -#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0) #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) /* for readability... */ -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/include/smb_macros.h | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index a9e911c066..4fa9ffa5ac 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -261,4 +261,92 @@ copy an IP address from one buffer to another #define IS_DC (lp_server_role()==ROLE_DOMAIN_PDC || lp_server_role()==ROLE_DOMAIN_BDC) +/***************************************************************************** + Safe allocation macros. +*****************************************************************************/ + +#define SMB_MALLOC_ARRAY(type,count) (type *)malloc_array(sizeof(type),(count)) +#define SMB_REALLOC(p,s) Realloc((p),(s)) +#define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count)) +#define SMB_CALLOC_ARRAY(type,count) (type *)calloc_array(sizeof(type),(count)) +#define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1) +#define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count)) + +/* limiting size of ipc replies */ +#define SMB_REALLOC_LIMIT(ptr,size) SMB_REALLOC(ptr,MAX((size),4*1024)) + +/* #define PARANOID_MALLOC_CHECKER 1 */ + +#if defined(PARANOID_MALLOC_CHECKER) + +#define TALLOC(ctx, size) talloc_((ctx),(size)) +#define TALLOC_P(ctx, type) (type *)talloc_((ctx),sizeof(type)) +#define TALLOC_ARRAY(ctx, type, count) (type *)talloc_array_((ctx),sizeof(type),(count)) +#define TALLOC_MEMDUP(ctx, ptr, size) talloc_memdup_((ctx),(ptr),(size)) +#define TALLOC_ZERO(ctx, size) talloc_zero_((ctx),(size)) +#define TALLOC_ZERO_P(ctx, type) (type *)talloc_zero_((ctx),sizeof(type)) +#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)talloc_zero_array_((ctx),sizeof(type),(count)) +#define TALLOC_REALLOC(ctx, ptr, count) talloc_realloc_((ctx),(ptr),(count)) +#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)talloc_realloc_array_((ctx),(ptr),sizeof(type),(count)) + +#define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem_((ps),sizeof(type),(count)) + +/* Get medieval on our ass about malloc.... */ + +/* Restrictions on malloc/realloc/calloc. */ +#ifdef malloc +#undef malloc +#endif +#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY + +#ifdef realloc +#undef realloc +#endif +#define realloc(p,s) __ERROR_DONT_USE_REALLOC_DIRECTLY + +#ifdef calloc +#undef calloc +#endif +#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY + +#ifdef strndup +#undef strndup +#endif +#define strndup(s,n) __ERROR_DONT_USE_STRNDUP_DIRECTLY + +#ifdef strdup +#undef strdup +#endif +#define strdup(s) __ERROR_DONT_USE_STRDUP_DIRECTLY + +#define SMB_MALLOC(s) malloc_(s) +#define SMB_MALLOC_P(type) (type *)malloc_(sizeof(type)) + +#define SMB_STRDUP(s) smb_xstrdup(s) +#define SMB_STRNDUP(s,n) smb_xstrndup(s,n) + +#else + +#define TALLOC(ctx, size) talloc((ctx),(size)) +#define TALLOC_P(ctx, type) (type *)talloc((ctx),sizeof(type)) +#define TALLOC_ARRAY(ctx, type, count) (type *)talloc_array((ctx),sizeof(type),(count)) +#define TALLOC_MEMDUP(ctx, ptr, size) talloc_memdup((ctx),(ptr),(size)) +#define TALLOC_ZERO(ctx, size) talloc_zero((ctx),(size)) +#define TALLOC_ZERO_P(ctx, type) (type *)talloc_zero((ctx),sizeof(type)) +#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)talloc_zero_array((ctx),sizeof(type),(count)) +#define TALLOC_REALLOC(ctx, ptr, count) talloc_realloc((ctx),(ptr),(count)) +#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)talloc_realloc_array((ctx),(ptr),sizeof(type),(count)) + +#define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem((ps),sizeof(type),(count)) + +/* Regular malloc code. */ + +#define SMB_MALLOC(s) malloc(s) +#define SMB_MALLOC_P(type) (type *)malloc(sizeof(type)) + +#define SMB_STRDUP(s) strdup(s) +#define SMB_STRNDUP(s,n) strndup(s,n) + +#endif + #endif /* _SMB_MACROS_H */ -- cgit From f95e9fc45b1d34c55b04318b79928adabd8f09e2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 25 Feb 2005 02:22:44 +0000 Subject: r5548: Stop lying about allocation sizes to Windows clients. It was a nice idea, and aparently improved performance in some circumstances, but it breaks the VC++ compiler :-(. Not cool. Fix bug #2146. Jeremy. (This used to be commit b9f147634df0126320ffe3b9a23068e76f6c1681) --- source3/include/smb_macros.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 4fa9ffa5ac..b1ac617f5c 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -178,8 +178,6 @@ /* this is how errors are generated */ #define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) -#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x)) - /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ #define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2) #define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) -- cgit From 02fdabc2a7f0199bc5f42afb2c744f3c740122e4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 3 Mar 2005 03:43:57 +0000 Subject: r5636: Re-add the allocation size - parameterized by share as "allocation roundup size", by default set as 1Mb. From advice by BlueArc about Windows client behaviour. VC++ people can set this to zero to turn it off. Jeremy. (This used to be commit 833ca101772bfab65dbd79eb64f63464177f144e) --- source3/include/smb_macros.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b1ac617f5c..4fa9ffa5ac 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -178,6 +178,8 @@ /* this is how errors are generated */ #define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) +#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x)) + /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ #define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2) #define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) -- cgit From 5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 23 Mar 2005 23:26:33 +0000 Subject: r6014: rather large change set.... pulling back all recent rpc changes from trunk into 3.0. I've tested a compile and so don't think I've missed any files. But if so, just mail me and I'll clean backup in a couple of hours. Changes include \winreg, \eventlog, \svcctl, and general parse_misc.c updates. I am planning on bracketing the event code with an #ifdef ENABLE_EVENTLOG until I finish merging Marcin's changes (very soon). (This used to be commit 4e0ac63c36527cd8c52ef720cae17e84f67e7221) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 4fa9ffa5ac..68a80ec402 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -290,6 +290,8 @@ copy an IP address from one buffer to another #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)talloc_realloc_array_((ctx),(ptr),sizeof(type),(count)) #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem_((ps),sizeof(type),(count)) +#define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem_((ps),(size),1) + /* Get medieval on our ass about malloc.... */ @@ -338,6 +340,7 @@ copy an IP address from one buffer to another #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)talloc_realloc_array((ctx),(ptr),sizeof(type),(count)) #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem((ps),sizeof(type),(count)) +#define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem((ps),(size),1) /* Regular malloc code. */ -- cgit From 934d41d23956c663406ff9d68e5a8ba9d81b5096 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 30 Mar 2005 04:40:24 +0000 Subject: r6127: Eliminated all compiler warnings pertaining to mismatched "qualifiers". The whole of samba comiles warning-free with the default compiler flags. Temporarily defined -Wall to locate other potential problems. Found an unused static function (#ifdefed out rather than deleted, in case it's needed for something in progress). There are also a number of uses of undeclared functions, mostly krb5_*. Files with these problems need to have appropriate header files included, but they are not fixed in this update. oplock_linux.c.c has undefined functions capget() and capset(), which need to have "#undef _POSIX_SOURCE" specified before including , but that could potentially have other side effects, so that remains uncorrected as well. The flag -Wall should be added permanently to CFLAGS, and all warnings then generated should be eliminated. (This used to be commit 5b19ede88ed80318e392f8017f4573fbb2ecbe0f) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 68a80ec402..9a78718605 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -43,7 +43,7 @@ * @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) +#define SAFE_FREE(x) do { if ((x) != NULL) {free((void *) (x)); x=NULL;} } while(0) #endif /* zero a structure */ -- cgit From 9840db418bad5a39edc4a32a1786f5e2d2c9dff8 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 31 Mar 2005 05:06:04 +0000 Subject: r6149: Fixes bugs #2498 and 2484. 1. using smbc_getxattr() et al, one may now request all access control entities in the ACL without getting all other NT attributes. 2. added the ability to exclude specified attributes from the result set provided by smbc_getxattr() et al, when requesting all attributes, all NT attributes, or all DOS attributes. 3. eliminated all compiler warnings, including when --enable-developer compiler flags are in use. removed -Wcast-qual flag from list, as that is specifically to force warnings in the case of casting away qualifiers. Note: In the process of eliminating compiler warnings, a few nasties were discovered. In the file libads/sasl.c, PRIVATE kerberos interfaces are being used; and in libsmb/clikrb5.c, both PRIAVE and DEPRECATED kerberos interfaces are being used. Someone who knows kerberos should look at these and determine if there is an alternate method of accomplishing the task. (This used to be commit 994694f7f26da5099f071e1381271a70407f33bb) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 9a78718605..2b3140783b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -43,7 +43,7 @@ * @note You are explicitly allowed to pass NULL pointers -- they will * always be ignored. **/ -#define SAFE_FREE(x) do { if ((x) != NULL) {free((void *) (x)); x=NULL;} } while(0) +#define SAFE_FREE(x) do { if ((x) != NULL) {free(CONST_DISCARD(void *, (x))); x=NULL;} } while(0) #endif /* zero a structure */ -- cgit From 0557c6cba2a21c9df547fbc8ff4db2899bc1c171 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 1 Apr 2005 23:11:28 +0000 Subject: r6172: Tidy up error processing significantly. Remove unix_ERR_XXX global nastyness. Jeremy. (This used to be commit d3379fe61bb934082b51a37adac232a96bafcf46) --- source3/include/smb_macros.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 2b3140783b..e19c51884f 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -97,9 +97,6 @@ #define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ return(ERROR_DOS(ERRDOS,ERRbadaccess)) -#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ - return(CACHED_ERROR(fsp)) - #define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \ NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) ) @@ -158,25 +155,23 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) -/* Macro to cache an error in a write_bmpx_struct */ -#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ - w->wr_discard = True, -1) /* Macro to test if an error has been cached for this fnum */ #define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ (fsp)->wbmpx_ptr->wr_discard) /* Macro to turn the cached error into an error packet */ #define CACHED_ERROR(fsp) cached_error_packet(outbuf,fsp,__LINE__,__FILE__) -/* these are the datagram types */ -#define DGRAM_DIRECT_UNIQUE 0x10 - -#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,False,__LINE__,__FILE__) -#define ERROR_FORCE_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,True,__LINE__,__FILE__) -#define ERROR_NT(status) error_packet(outbuf,status,0,0,False,__LINE__,__FILE__) -#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,False,__LINE__,__FILE__) +#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) +#define ERROR_FORCE_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_INVALID,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__) +#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__) /* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__) +#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) + +/* these are the datagram types */ +#define DGRAM_DIRECT_UNIQUE 0x10 #define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x)) -- cgit From 978ca8486031e43754a3c23757f361bf3a85f335 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 6 Apr 2005 16:28:04 +0000 Subject: r6225: get rid of warnings from my compiler about nested externs (This used to be commit efea76ac71412f8622cd233912309e91b9ea52da) --- source3/include/smb_macros.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index e19c51884f..1076bd53e8 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -76,16 +76,20 @@ #define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) +/* you must add the following extern declaration to files using this macro + * extern struct current_user current_user; + */ #define FSP_BELONGS_CONN(fsp,conn) do {\ - extern struct current_user current_user;\ if (!((fsp) && (conn) && ((conn)==(fsp)->conn) && (current_user.vuid==(fsp)->vuid))) \ return(ERROR_DOS(ERRDOS,ERRbadfid));\ } while(0) #define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) +/* you must add the following extern declaration to files using this macro + * extern struct current_user current_user; + */ #define CHECK_FSP(fsp,conn) do {\ - extern struct current_user current_user;\ if (!FNUM_OK(fsp,conn)) \ return(ERROR_DOS(ERRDOS,ERRbadfid)); \ else if((fsp)->fd == -1) \ -- cgit From 9f4c0afa0a3e359dfe9ac5dd8df0849b450a3fe1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 10 Apr 2005 15:26:37 +0000 Subject: r6277: This implements a new caching API for enumerating the pdb elements. It is modeled after query_displayinfo and should hide the differences between users, groups and aliases while allowing a cache analog load_sampw_entries: struct pdb_search *pdb_search_users(uint16 acct_flags); struct pdb_search *pdb_search_groups(void); struct pdb_search *pdb_search_aliases(const DOM_SID *sid); uint32 pdb_search_entries(struct pdb_search *search, uint32 start_idx, uint32 max_entries, struct samr_displayentry **result); void pdb_search_destroy(struct pdb_search *search); Why this API? Eventually we will need to apply the work gd has started on enumerating users with paged ldap searches to groups and aliases. Before doing that I want to clean up the search routines we have. The sample application (more to follow) is 'net maxrid'. Volker (This used to be commit 8b4f67a1e9d459145cde10b1064781d58d62b805) --- source3/include/smb_macros.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 1076bd53e8..ab4ee5ee73 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -351,4 +351,14 @@ copy an IP address from one buffer to another #endif +#define ADD_TO_ARRAY(mem_ctx, type, elem, array, num) \ +do { \ + *(array) = ((mem_ctx) != NULL) ? \ + TALLOC_REALLOC_ARRAY(mem_ctx, (*(array)), type, (*(num))+1) : \ + SMB_REALLOC_ARRAY((*(array)), type, (*(num))+1); \ + SMB_ASSERT((*(array)) != NULL); \ + (*(array))[*(num)] = (elem); \ + (*(num)) += 1; \ +} while (0) + #endif /* _SMB_MACROS_H */ -- cgit From f60ad8ded6e614f3c0abb2679d3a75096fc595d3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Apr 2005 23:32:56 +0000 Subject: r6346: Add a counter for the number of SMB operations per connection/file. You will need to do a make clean after SVN updating this. Next will come a smbcontrol message to dump this info. This should be interesting to profile client activity. Jeremy. (This used to be commit 743174da86ac724fc9ee3d4b7bd9a2a97a234bd8) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index ab4ee5ee73..b7a3a68bec 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -94,6 +94,7 @@ return(ERROR_DOS(ERRDOS,ERRbadfid)); \ else if((fsp)->fd == -1) \ return(ERROR_DOS(ERRDOS,ERRbadaccess));\ + (fsp)->num_smb_operations++;\ } while(0) #define CHECK_READ(fsp) if (!(fsp)->can_read) \ -- cgit From d3d6126d94d55a69c45b2f7a63a7fa9b561baf48 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 15 Apr 2005 13:41:49 +0000 Subject: r6351: This is quite a large and intrusive patch, but there are not many pieces that can be taken out of it, so I decided to commit this in one lump. It changes the passdb enumerating functions to use ldap paged results where possible. In particular the samr calls querydispinfo, enumdomusers and friends have undergone significant internal changes. I have tested this extensively with rpcclient and a bit with usrmgr.exe. More tests and the merge to trunk will follow later. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code is based on a first implementation by Günther Deschner, but has evolved quite a bit since then. Volker (This used to be commit f0bb44ac58e190e19eb4e92928979b0446e611c9) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b7a3a68bec..04616eb8ab 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -362,4 +362,7 @@ do { \ (*(num)) += 1; \ } while (0) +#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)); + #endif /* _SMB_MACROS_H */ -- cgit From b49c586de46396018bf26828d78e591e67de3c0f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 16 Apr 2005 20:48:04 +0000 Subject: r6358: merging SMB_ASSERT() changes from the release branch (This used to be commit 70178d5d27900d56ad1da3c99f3a63d863fb324c) --- source3/include/smb_macros.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 04616eb8ab..6d1e382bb8 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -66,9 +66,16 @@ #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) /* assert macros */ -#define SMB_ASSERT(b) ((b)?(void)0: \ +#ifdef DEVELOPER +#define SMB_ASSERT(b) ( (b) ? (void)0 : \ (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ __FILE__, __LINE__)), smb_panic("assert failed"))) +#else +/* redefine the assert macro for non-developer builds */ +#define SMB_ASSERT(b) ( (b) ? (void)0 : \ + (DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)))) +#endif + #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) /* these are useful macros for checking validity of handles */ -- cgit From 431a28a3151f6cb8f9e1de769da11a22c379d9d8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 1 May 2005 09:30:18 +0000 Subject: r6548: Fix bug #2622 - remove DPTR_MASK as it makes no sense. Jeremy. (This used to be commit 927681c8c4458c77de2622557f1465fd5ca1c28b) --- source3/include/smb_macros.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 6d1e382bb8..37e5a897cb 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -224,17 +224,11 @@ true if two IP addresses are equal #define reg_get_subkey(full_keyname, key_name, subkey_name) \ split_at_last_component(full_keyname, key_name, '\\', subkey_name) -/**************************************************************************** - Used by dptr_zero. -****************************************************************************/ - -#define DPTR_MASK ((uint32)(((uint32)1)<<31)) - /**************************************************************************** Return True if the offset is at zero. ****************************************************************************/ -#define dptr_zero(buf) ((IVAL(buf,1)&~DPTR_MASK) == 0) +#define dptr_zero(buf) (IVAL(buf,1) == 0) /******************************************************************* copy an IP address from one buffer to another -- cgit From 7b9d6ac23e1a7d8136fffd2e3977b09a815da65a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 May 2005 07:33:49 +0000 Subject: r6595: This is Volkers new-talloc patch. Just got the go-ahead from Volker to commit. Woo Hoo ! Jeremy. (This used to be commit 316df944a456f150944761dab34add5e8c4ab699) --- source3/include/smb_macros.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 37e5a897cb..53c4ad046d 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -276,24 +276,26 @@ copy an IP address from one buffer to another /* limiting size of ipc replies */ #define SMB_REALLOC_LIMIT(ptr,size) SMB_REALLOC(ptr,MAX((size),4*1024)) -/* #define PARANOID_MALLOC_CHECKER 1 */ +/* The new talloc is paranoid malloc checker safe. */ -#if defined(PARANOID_MALLOC_CHECKER) +#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__) +#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) +#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__) +#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__) +#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +#define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__) +#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) +#define talloc_destroy(ctx) talloc_free(ctx) + +#define PARANOID_MALLOC_CHECKER 1 -#define TALLOC(ctx, size) talloc_((ctx),(size)) -#define TALLOC_P(ctx, type) (type *)talloc_((ctx),sizeof(type)) -#define TALLOC_ARRAY(ctx, type, count) (type *)talloc_array_((ctx),sizeof(type),(count)) -#define TALLOC_MEMDUP(ctx, ptr, size) talloc_memdup_((ctx),(ptr),(size)) -#define TALLOC_ZERO(ctx, size) talloc_zero_((ctx),(size)) -#define TALLOC_ZERO_P(ctx, type) (type *)talloc_zero_((ctx),sizeof(type)) -#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)talloc_zero_array_((ctx),sizeof(type),(count)) -#define TALLOC_REALLOC(ctx, ptr, count) talloc_realloc_((ctx),(ptr),(count)) -#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)talloc_realloc_array_((ctx),(ptr),sizeof(type),(count)) +#if defined(PARANOID_MALLOC_CHECKER) #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem_((ps),sizeof(type),(count)) #define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem_((ps),(size),1) - /* Get medieval on our ass about malloc.... */ /* Restrictions on malloc/realloc/calloc. */ @@ -330,15 +332,10 @@ copy an IP address from one buffer to another #else -#define TALLOC(ctx, size) talloc((ctx),(size)) -#define TALLOC_P(ctx, type) (type *)talloc((ctx),sizeof(type)) -#define TALLOC_ARRAY(ctx, type, count) (type *)talloc_array((ctx),sizeof(type),(count)) -#define TALLOC_MEMDUP(ctx, ptr, size) talloc_memdup((ctx),(ptr),(size)) -#define TALLOC_ZERO(ctx, size) talloc_zero((ctx),(size)) -#define TALLOC_ZERO_P(ctx, type) (type *)talloc_zero((ctx),sizeof(type)) -#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)talloc_zero_array((ctx),sizeof(type),(count)) -#define TALLOC_REALLOC(ctx, ptr, count) talloc_realloc((ctx),(ptr),(count)) -#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)talloc_realloc_array((ctx),(ptr),sizeof(type),(count)) +#define _STRING_LINE_(s) #s +#define _STRING_LINE2_(s) _STRING_LINE_(s) +#define __LINESTR__ _STRING_LINE2_(__LINE__) +#define __location__ __FILE__ ":" __LINESTR__ #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem((ps),sizeof(type),(count)) #define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem((ps),(size),1) -- cgit From 526351bed9fff47797f8baeb512207a924757716 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 May 2005 16:19:23 +0000 Subject: r6613: Merge back fix for PARANOID_MALLOC checker. Jeremy. (This used to be commit 9c8d0efbfdcf9f4558ef3c7d5623558e7142d7ad) --- source3/include/smb_macros.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 53c4ad046d..7e90f01b5f 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -289,7 +289,9 @@ copy an IP address from one buffer to another #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) -#define PARANOID_MALLOC_CHECKER 1 +#if defined(DEVELOPER) && !defined(SMBMOUNT_MALLOC) +# define PARANOID_MALLOC_CHECKER 1 +#endif #if defined(PARANOID_MALLOC_CHECKER) -- cgit From f24d88cf9da46680d52b42b92bd484e7b09ce99b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 31 May 2005 13:46:45 +0000 Subject: r7139: trying to reduce the number of diffs between trunk and 3.0; changing version to 3.0.20pre1 (This used to be commit 9727d05241574042dd3aa8844ae5c701d22e2da1) --- source3/include/smb_macros.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 7e90f01b5f..d798d4395e 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -43,7 +43,7 @@ * @note You are explicitly allowed to pass NULL pointers -- they will * always be ignored. **/ -#define SAFE_FREE(x) do { if ((x) != NULL) {free(CONST_DISCARD(void *, (x))); x=NULL;} } while(0) +#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) #endif /* zero a structure */ @@ -87,6 +87,7 @@ * extern struct current_user current_user; */ #define FSP_BELONGS_CONN(fsp,conn) do {\ + extern struct current_user current_user;\ if (!((fsp) && (conn) && ((conn)==(fsp)->conn) && (current_user.vuid==(fsp)->vuid))) \ return(ERROR_DOS(ERRDOS,ERRbadfid));\ } while(0) @@ -97,6 +98,7 @@ * extern struct current_user current_user; */ #define CHECK_FSP(fsp,conn) do {\ + extern struct current_user current_user;\ if (!FNUM_OK(fsp,conn)) \ return(ERROR_DOS(ERRDOS,ERRbadfid)); \ else if((fsp)->fd == -1) \ @@ -289,6 +291,9 @@ copy an IP address from one buffer to another #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) +/* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling + the smbmount utils */ + #if defined(DEVELOPER) && !defined(SMBMOUNT_MALLOC) # define PARANOID_MALLOC_CHECKER 1 #endif -- cgit From ed5e7ff9f184fd36b4344c958f145cc4a4987c71 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Jun 2005 23:18:52 +0000 Subject: r7200: Don't use memset, use SET_STAT_INVALID (has the same effect). Jeremy. (This used to be commit 0b6f87d5e14da461bd2b1c3a4e6f47a69d2cd1c4) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index d798d4395e..b7e27d2266 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -143,6 +143,7 @@ #define VALID_STAT(st) ((st).st_nlink != 0) #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)) -- cgit From af8a691db11a5072865f8b03fd1cbd3aab5cb6d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Jul 2005 04:51:27 +0000 Subject: r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb) --- source3/include/smb_macros.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index b7e27d2266..7a0afdfc19 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -101,15 +101,16 @@ extern struct current_user current_user;\ if (!FNUM_OK(fsp,conn)) \ return(ERROR_DOS(ERRDOS,ERRbadfid)); \ - else if((fsp)->fd == -1) \ + else if((fsp)->fh->fd == -1) \ return(ERROR_DOS(ERRDOS,ERRbadaccess));\ (fsp)->num_smb_operations++;\ } while(0) -#define CHECK_READ(fsp) if (!(fsp)->can_read) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess)) -#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess)) +#define CHECK_READ(fsp,inbuf) (((fsp)->fh->fd != -1) && ((fsp)->can_read || \ + ((SVAL((inbuf),smb_flg2) & FLAGS2_READ_PERMIT_EXECUTE) && \ + (fsp->access_mask & FILE_EXECUTE)))) + +#define CHECK_WRITE(fsp) ((fsp)->can_write && ((fsp)->fh->fd != -1)) #define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \ NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) ) -- cgit From 44707ad2e00a91f459e80efbe8f362b5853b0a62 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Aug 2005 14:55:40 +0000 Subject: r9739: conver the reg_objects (REGSUBKEY_CTR & REGVAL_CTR) to use the new talloc() features: Note that the REGSUB_CTR and REGVAL_CTR objects *must* be talloc()'d since the methods use the object pointer as the talloc context for internal private data. There is no longer a regXXX_ctr_intit() and regXXX_ctr_destroy() pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the object. Also had to convert the printer_info_2->NT_PRINTER_DATA field to be talloc()'d as well. This is just a stop on the road to cleaning up the printer memory management. (This used to be commit ef721333ab9639cb5346067497e99fbd0d4425dd) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 7a0afdfc19..47dff7702b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -292,6 +292,7 @@ copy an IP address from one buffer to another #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__) #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) +#define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) /* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling the smbmount utils */ -- cgit From 513e81458f89b6c32262d7e9645be4750f299393 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 2 Sep 2005 09:10:42 +0000 Subject: r9945: fix typos. Guenther (This used to be commit 12029e902277053a4066eae1b3ae311fae5e6422) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 47dff7702b..41eac7e994 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -261,7 +261,7 @@ copy an IP address from one buffer to another #define dos_format(fname) string_replace(fname,'/','\\') /***************************************************************************** - Check to see if we are a DO for this domain + Check to see if we are a DC for this domain *****************************************************************************/ #define IS_DC (lp_server_role()==ROLE_DOMAIN_PDC || lp_server_role()==ROLE_DOMAIN_BDC) -- cgit From 894358a8f3e338b339b6c37233edef794b312087 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Mar 2006 06:31:04 +0000 Subject: r13915: Fixed a very interesting class of realloc() bugs found by Coverity. realloc can return NULL in one of two cases - (1) the realloc failed, (2) realloc succeeded but the new size requested was zero, in which case this is identical to a free() call. The error paths dealing with these two cases should be different, but mostly weren't. Secondly the standard idiom for dealing with realloc when you know the new size is non-zero is the following : tmp = realloc(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } However, there were *many* *many* places in Samba where we were using the old (broken) idiom of : p = realloc(p, size) if (!p) { return error; } which will leak the memory pointed to by p on realloc fail. This commit (hopefully) fixes all these cases by moving to a standard idiom of : p = SMB_REALLOC(p, size) if (!p) { return error; } Where if the realloc returns null due to the realloc failing or size == 0 we *guarentee* that the storage pointed to by p has been freed. This allows me to remove a lot of code that was dealing with the standard (more verbose) method that required a tmp pointer. This is almost always what you want. When a realloc fails you never usually want the old memory, you want to free it and get into your error processing asap. For the 11 remaining cases where we really do need to keep the old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR, which can be used as follows : tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the pointer p, even on size == 0 or realloc fail. All this is done by a hidden extra argument to Realloc(), BOOL free_old_on_error which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR macros (and their array counterparts). It remains to be seen what this will do to our Coverity bug count :-). Jeremy. (This used to be commit 1d710d06a214f3f1740e80e0bffd6aab44aac2b0) --- source3/include/smb_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 41eac7e994..6c9ab017ba 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -271,8 +271,10 @@ copy an IP address from one buffer to another *****************************************************************************/ #define SMB_MALLOC_ARRAY(type,count) (type *)malloc_array(sizeof(type),(count)) -#define SMB_REALLOC(p,s) Realloc((p),(s)) -#define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count)) +#define SMB_REALLOC(p,s) Realloc((p),(s),True) /* Always frees p on error or s == 0 */ +#define SMB_REALLOC_KEEP_OLD_ON_ERROR(p,s) Realloc((p),(s),False) /* Never frees p on error or s == 0 */ +#define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count),True) /* Always frees p on error or s == 0 */ +#define SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(p,type,count) (type *)realloc_array((p),sizeof(type),(count),False) /* Always frees p on error or s == 0 */ #define SMB_CALLOC_ARRAY(type,count) (type *)calloc_array(sizeof(type),(count)) #define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1) #define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count)) -- cgit From 71272fc441d7930f7ae810ee3c8f5a58385cb55c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Mar 2006 18:52:48 +0000 Subject: r13975: Re-fix Coverity #156 - I had left the hidden arg. inconsistent between Realloc and realloc_array. Jeremy. (This used to be commit 841c9b1847ae12656b827e3d35b8bf0c3f68b8b4) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 6c9ab017ba..3ae8814cfd 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -274,7 +274,7 @@ copy an IP address from one buffer to another #define SMB_REALLOC(p,s) Realloc((p),(s),True) /* Always frees p on error or s == 0 */ #define SMB_REALLOC_KEEP_OLD_ON_ERROR(p,s) Realloc((p),(s),False) /* Never frees p on error or s == 0 */ #define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count),True) /* Always frees p on error or s == 0 */ -#define SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(p,type,count) (type *)realloc_array((p),sizeof(type),(count),False) /* Always frees p on error or s == 0 */ +#define SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(p,type,count) (type *)realloc_array((p),sizeof(type),(count),False) /* Never frees p on error or s == 0 */ #define SMB_CALLOC_ARRAY(type,count) (type *)calloc_array(sizeof(type),(count)) #define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1) #define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count)) -- cgit From 40d0707827ee154bcb03013abe6f72f1026a70c9 Mon Sep 17 00:00:00 2001 From: James Peach Date: Wed, 22 Mar 2006 23:49:09 +0000 Subject: r14668: Set the FILE_STATUS_OFFLINE bit by observing the events a DMAPI-based HSM is interested in. Tested on both IRIX and SLES9. (This used to be commit 514a767c57f8194547e5b708ad2573ab9a0719c6) --- source3/include/smb_macros.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 3ae8814cfd..554dbbc087 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -76,6 +76,10 @@ (DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)))) #endif +#define SMB_WARN(condition, message) \ + ((condition) ? (void)0 : \ + DEBUG(0, ("WARNING: %s: %s\n", #condition, message))) + #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) /* these are useful macros for checking validity of handles */ -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/include/smb_macros.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 554dbbc087..e296ddd140 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -83,8 +83,6 @@ #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) /* these are useful macros for checking validity of handles */ -#define OPEN_FSP(fsp) ((fsp) && !(fsp)->is_directory) -#define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) /* you must add the following extern declaration to files using this macro @@ -93,20 +91,24 @@ #define FSP_BELONGS_CONN(fsp,conn) do {\ extern struct current_user current_user;\ if (!((fsp) && (conn) && ((conn)==(fsp)->conn) && (current_user.vuid==(fsp)->vuid))) \ - return(ERROR_DOS(ERRDOS,ERRbadfid));\ + return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ } while(0) -#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) +#define FNUM_OK(fsp,c) ((fsp) && !(fsp)->is_directory && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) /* you must add the following extern declaration to files using this macro * extern struct current_user current_user; */ #define CHECK_FSP(fsp,conn) do {\ extern struct current_user current_user;\ - if (!FNUM_OK(fsp,conn)) \ - return(ERROR_DOS(ERRDOS,ERRbadfid)); \ - else if((fsp)->fh->fd == -1) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess));\ + if (!(fsp) || !(conn)) \ + return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ + else if (((conn) != (fsp)->conn) || current_user.vuid != (fsp)->vuid) \ + return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ + else if ((fsp)->is_directory) \ + return ERROR_NT(NT_STATUS_INVALID_DEVICE_REQUEST); \ + else if ((fsp)->fh->fd == -1) \ + return ERROR_NT(NT_STATUS_ACCESS_DENIED); \ (fsp)->num_smb_operations++;\ } while(0) @@ -122,7 +124,7 @@ /* the service number for the [globals] defaults */ #define GLOBAL_SECTION_SNUM (-1) /* translates a connection number into a service number */ -#define SNUM(conn) ((conn)?(conn)->service:GLOBAL_SECTION_SNUM) +#define SNUM(conn) ((conn)?(conn)->params->service:GLOBAL_SECTION_SNUM) /* access various service details */ @@ -133,10 +135,10 @@ #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum)) #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum)) #define CAN_SETDIR(snum) (!lp_no_set_dir(snum)) -#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service)) -#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service)) -#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service)) -#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service)) +#define CAN_PRINT(conn) ((conn) && lp_print_ok(SNUM(conn))) +#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden(SNUM(conn))) +#define MAP_SYSTEM(conn) ((conn) && lp_map_system(SNUM(conn))) +#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive(SNUM(conn))) #define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list,(conn)->case_sensitive)) #define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list,(conn)->case_sensitive)) #define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list,(conn)->case_sensitive)) @@ -182,7 +184,6 @@ #define CACHED_ERROR(fsp) cached_error_packet(outbuf,fsp,__LINE__,__FILE__) #define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) -#define ERROR_FORCE_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_INVALID,__LINE__,__FILE__) #define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__) #define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__) #define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__) @@ -377,6 +378,6 @@ do { \ } while (0) #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)); + add_to_large_array((mem_ctx), sizeof(type), &(elem), (void *)(array), (num), (size)); #endif /* _SMB_MACROS_H */ -- cgit From e23781b3b304d1e69ad80af5ae9c0ed8d02cf996 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 30 Jul 2006 16:36:56 +0000 Subject: r17316: More C++ warnings -- 456 left (This used to be commit 1e4ee728df7eeafc1b4d533240acb032f73b4f5c) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index e296ddd140..44f15734d9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -285,7 +285,7 @@ copy an IP address from one buffer to another #define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count)) /* limiting size of ipc replies */ -#define SMB_REALLOC_LIMIT(ptr,size) SMB_REALLOC(ptr,MAX((size),4*1024)) +#define SMB_REALLOC_LIMIT(ptr,size) (char *)SMB_REALLOC(ptr,MAX((size),4*1024)) /* The new talloc is paranoid malloc checker safe. */ -- cgit From 791f48f167de339c8ae371e5c80706511fd10018 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 12 Dec 2006 17:38:42 +0000 Subject: r20124: clean up nested extern declaration warnings (This used to be commit ac3eb7813e33b9a2e78c9158433f7ed62c3b62bb) --- source3/include/smb_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 44f15734d9..4b4351347f 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -86,10 +86,10 @@ #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) /* you must add the following extern declaration to files using this macro + * (do not add it to the macro as that causes nested extern declaration warnings) * extern struct current_user current_user; */ #define FSP_BELONGS_CONN(fsp,conn) do {\ - extern struct current_user current_user;\ if (!((fsp) && (conn) && ((conn)==(fsp)->conn) && (current_user.vuid==(fsp)->vuid))) \ return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ } while(0) @@ -97,10 +97,10 @@ #define FNUM_OK(fsp,c) ((fsp) && !(fsp)->is_directory && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) /* you must add the following extern declaration to files using this macro + * (do not add it to the macro as that causes nested extern declaration warnings) * extern struct current_user current_user; */ #define CHECK_FSP(fsp,conn) do {\ - extern struct current_user current_user;\ if (!(fsp) || !(conn)) \ return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ else if (((conn) != (fsp)->conn) || current_user.vuid != (fsp)->vuid) \ -- cgit From 56c1d7e5078ca6b79bb286f458956b5f49c83e81 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 24 Feb 2007 12:40:43 +0000 Subject: r21525: Go ahead and checkin the mlock() & memalign() fixes so others don't get stuck with the winbindd hang. Still waiting on additional confirmation from Guenther that this fixes thes issues he was observing as well. But it's been running in my local tree for a day without problems. (This used to be commit 0d2b80c6c4a744b05a0efdec352cddccc430e0c4) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 4b4351347f..4ca227c21e 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -276,6 +276,7 @@ copy an IP address from one buffer to another *****************************************************************************/ #define SMB_MALLOC_ARRAY(type,count) (type *)malloc_array(sizeof(type),(count)) +#define SMB_MEMALIGN_ARRAY(type,align,count) (type *)memalign_array(sizeof(type),align,(count)) #define SMB_REALLOC(p,s) Realloc((p),(s),True) /* Always frees p on error or s == 0 */ #define SMB_REALLOC_KEEP_OLD_ON_ERROR(p,s) Realloc((p),(s),False) /* Never frees p on error or s == 0 */ #define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count),True) /* Always frees p on error or s == 0 */ -- cgit From e9623ecb2459fa39c5dd1bca06a1d9962b8dc31a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 19:51:30 +0000 Subject: r22277: __location__ is defined in libreplace now metze (This used to be commit 9b45075a265d00847cf77b549759ad9373a16615) --- source3/include/smb_macros.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 4ca227c21e..d696db3d3a 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -350,11 +350,6 @@ copy an IP address from one buffer to another #else -#define _STRING_LINE_(s) #s -#define _STRING_LINE2_(s) _STRING_LINE_(s) -#define __LINESTR__ _STRING_LINE2_(__LINE__) -#define __location__ __FILE__ ":" __LINESTR__ - #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem((ps),sizeof(type),(count)) #define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem((ps),(size),1) -- cgit From a8c62502741fe287091cc9001b69fbd7496e3562 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Apr 2007 08:03:29 +0000 Subject: r22298: move ZERO_*, ARRAY_SIZE and PTR_DIFF macros into libreplace metze (This used to be commit 8a7d2e633b98aa9c73cf1f7d1369015b294cf2e1) --- source3/include/smb_macros.h | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index d696db3d3a..2b596d3c6b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -46,25 +46,6 @@ #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) #endif -/* zero a structure */ -#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) - -/* zero a structure given a pointer to the structure */ -#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) - -/* zero a structure given a pointer to the structure - no zero check */ -#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) - -/* zero an array - note that sizeof(array) must work - ie. it must not be a - pointer */ -#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) - -/* pointer difference macro */ -#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) - -/* work out how many elements there are in a static array */ -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) - /* assert macros */ #ifdef DEVELOPER #define SMB_ASSERT(b) ( (b) ? (void)0 : \ -- cgit From 0829e1ad1c3646efecf50729f493b9ee72ef0517 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Apr 2007 22:40:32 +0000 Subject: r22391: Looks bigger than it is. Make "inbuf" available to all callers of smb_setlen (via set_message() calls). This will allow the server to reflect back the correct encryption context. Jeremy. (This used to be commit 2d80a96120a5fe2fe726f00746d36d85044c4bdb) --- source3/include/smb_macros.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 2b596d3c6b..4a49ef3ed4 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -162,15 +162,15 @@ #define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ (fsp)->wbmpx_ptr->wr_discard) /* Macro to turn the cached error into an error packet */ -#define CACHED_ERROR(fsp) cached_error_packet(outbuf,fsp,__LINE__,__FILE__) +#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__,__FILE__) -#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) -#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__) -#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__) -#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__) +#define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__) +#define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__) /* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) +#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 -- cgit From 12ba88574bf91bdcc4447bfc3d429b799064bfd9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 23:18:41 +0000 Subject: r22542: Move over to using the _strict varients of the talloc calls. No functional changes. Looks bigger than it is :-). Jeremy. (This used to be commit f6fa3080fee1b20df9f1968500840a88cf0ee592) --- source3/include/smb_macros.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 4a49ef3ed4..f93ed912ee 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -271,17 +271,19 @@ copy an IP address from one buffer to another /* The new talloc is paranoid malloc checker safe. */ -#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__) -#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) -#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__) -#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__) -#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +#define TALLOC(ctx, size) talloc_strict(ctx, size, __location__) +#define TALLOC_P(ctx, type) (type *)talloc_strict(ctx, sizeof(type), #type) +#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_strict(ctx, sizeof(type), count, #type) +#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup_strict(ctx, ptr, size, __location__) +#define TALLOC_ZERO(ctx, size) _talloc_zero_strict(ctx, size, __location__) +#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_strict(ctx, sizeof(type), #type) +#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_strict(ctx, sizeof(type), count, #type) #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__) #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) +#define TALLOC_SIZE(ctx, size) talloc_strict(ctx, size) +#define TALLOC_ZERO_SIZE(ctx, size) talloc_zero_size_strict(ctx, size) /* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling the smbmount utils */ -- cgit From 0fbbf8440aa45a90f5b913815122fa127793a72d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 28 Apr 2007 02:51:55 +0000 Subject: r22543: Fix bad call to talloc_strict (too few args). Should fix build farm breakage. Jeremy. (This used to be commit efb43432b01f0b55df409225c7526ff232c00171) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index f93ed912ee..08766a1d78 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -282,7 +282,7 @@ copy an IP address from one buffer to another #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) -#define TALLOC_SIZE(ctx, size) talloc_strict(ctx, size) +#define TALLOC_SIZE(ctx, size) talloc_strict(ctx, size, __location__) #define TALLOC_ZERO_SIZE(ctx, size) talloc_zero_size_strict(ctx, size) /* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling -- cgit From 4ab6a8ebb70bbd5d69ad1dc6196c936f01f5aaf7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 29 Apr 2007 00:09:22 +0000 Subject: r22564: Move the _strict -> _zeronull functions into lib/util.c and out of talloc at tridge's request. Jeremy. (This used to be commit da78488b86c464b6861d36398cca7524ad5906fe) --- source3/include/smb_macros.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 08766a1d78..afe7c1a477 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -271,19 +271,19 @@ copy an IP address from one buffer to another /* The new talloc is paranoid malloc checker safe. */ -#define TALLOC(ctx, size) talloc_strict(ctx, size, __location__) -#define TALLOC_P(ctx, type) (type *)talloc_strict(ctx, sizeof(type), #type) -#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_strict(ctx, sizeof(type), count, #type) -#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup_strict(ctx, ptr, size, __location__) -#define TALLOC_ZERO(ctx, size) _talloc_zero_strict(ctx, size, __location__) -#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_strict(ctx, sizeof(type), #type) -#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_strict(ctx, sizeof(type), count, #type) +#define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__) +#define TALLOC_P(ctx, type) (type *)talloc_zeronull(ctx, sizeof(type), #type) +#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_zeronull(ctx, sizeof(type), count, #type) +#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup_zeronull(ctx, ptr, size, __location__) +#define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) +#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, sizeof(type), #type) +#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_zeronull(ctx, sizeof(type), count, #type) #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__) #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) -#define TALLOC_SIZE(ctx, size) talloc_strict(ctx, size, __location__) -#define TALLOC_ZERO_SIZE(ctx, size) talloc_zero_size_strict(ctx, size) +#define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__) +#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) /* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling the smbmount utils */ -- cgit From d34f6bb969092166c961e328229b1b05a30f6930 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 14 May 2007 14:23:51 +0000 Subject: r22852: merge fixes for CVE-2007-2446 and CVE-2007-2447 to all branches (This used to be commit f65214be68c1a59d9598bfb9f3b19e71cc3fa07b) --- source3/include/smb_macros.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index afe7c1a477..bfed27c167 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -295,7 +295,6 @@ copy an IP address from one buffer to another #if defined(PARANOID_MALLOC_CHECKER) #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem_((ps),sizeof(type),(count)) -#define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem_((ps),(size),1) /* Get medieval on our ass about malloc.... */ @@ -334,7 +333,6 @@ copy an IP address from one buffer to another #else #define PRS_ALLOC_MEM(ps, type, count) (type *)prs_alloc_mem((ps),sizeof(type),(count)) -#define PRS_ALLOC_MEM_VOID(ps, size) prs_alloc_mem((ps),(size),1) /* Regular malloc code. */ -- cgit From 32106b23951e01fb17f814584ebbcc8d7288cb75 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 May 2007 00:07:38 +0000 Subject: r22920: Add in the UNIX capability for 24-bit readX, as discussed with the Apple guys and Linux kernel guys. Still looking at how to do writeX as there's no recvfile(). Jeremy. (This used to be commit a53268fb2082de586e2df250d8ddfcff53379102) --- source3/include/smb_macros.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index bfed27c167..646c6bdce0 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -191,6 +191,10 @@ #define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = (len&0x10000)>>16; \ buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0) +#define smb_len_large(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|(PVAL(buf,1)<<16)) +#define _smb_setlen_large(buf,len) do { buf[0] = 0; buf[1] = (len&0xFF0000)>>16; \ + buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0) + /******************************************************************* find the difference in milliseconds between two struct timeval values -- cgit From b1ce226af8b61ad7e3c37860a59c6715012e738b Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 15 Jun 2007 21:58:49 +0000 Subject: r23510: Tidy calls to smb_panic by removing trailing newlines. Print the failed expression in SMB_ASSERT. (This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713) --- source3/include/smb_macros.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 646c6bdce0..81d4dc0666 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -49,12 +49,13 @@ /* assert macros */ #ifdef DEVELOPER #define SMB_ASSERT(b) ( (b) ? (void)0 : \ - (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \ - __FILE__, __LINE__)), smb_panic("assert failed"))) + (DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ + __FILE__, __LINE__, #b)), smb_panic("assert failed: " #b))) #else /* redefine the assert macro for non-developer builds */ #define SMB_ASSERT(b) ( (b) ? (void)0 : \ - (DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)))) + (DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ + __FILE__, __LINE__, #b)))) #endif #define SMB_WARN(condition, message) \ -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 81d4dc0666..51db8ea178 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -8,7 +8,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/include/smb_macros.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 51db8ea178..3221d2f951 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -17,8 +17,7 @@ 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. + along with this program. If not, see . */ #ifndef _SMB_MACROS_H -- cgit From cc6a41017c577742af73b4bc60993d8d415ea580 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jul 2007 09:36:09 +0000 Subject: r23997: Check in the infrastructure for getting rid of the global InBuffer/OutBuffer The complete history of this patch can be found under http://www.samba.org/~vlendec/inbuf-checkin/. Jeremy, Jerry: If possible I would like to see this in 3.2.0. I'm only checking into 3_2 at the moment, as it currently will slow down operations for all non-converted (i.e. all at this moment) operations, as it will copy the talloc'ed inbuf over the global InBuffer. It will need quite a bit of effort to convert everything necessary for the normal operations an XP box does. I have patches for negprot, session setup, tcon_and_X, open_and_X, close. More to come, but I would appreciate some help here. Volker (This used to be commit 5594af2b208c860d3f4b453af6a649d9e4295d1c) --- source3/include/smb_macros.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 3221d2f951..a47eff2f64 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -169,6 +169,10 @@ #define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__) #define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__) +#define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__) +#define reply_doserror(req,eclass,ecode) reply_dos_error(req,eclass,ecode,__LINE__,__FILE__) +#define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__) + /* this is how errors are generated */ #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) -- cgit From 4392d47b34720d2dcd8ee47bd14a71bf1eab2c86 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 30 Jul 2007 10:23:26 +0000 Subject: r24078: Add reply_unixerror (This used to be commit 10ac991750e9476299d39ac6f763d1638ff8c619) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index a47eff2f64..15789a938a 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -172,6 +172,7 @@ #define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__) #define reply_doserror(req,eclass,ecode) reply_dos_error(req,eclass,ecode,__LINE__,__FILE__) #define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__) +#define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) /* this is how errors are generated */ #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) -- cgit From a5f412f305ea2bdb0ee0efd5a38385525d4671c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Aug 2007 10:28:09 +0000 Subject: r24311: add a reply_force_nterror() macro metze (This used to be commit b9ae00f4980c305f2f7334b139f9bc72fd9afbd6) --- source3/include/smb_macros.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 15789a938a..7c786b03c8 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -170,6 +170,7 @@ #define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__) #define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__) +#define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__) #define reply_doserror(req,eclass,ecode) reply_dos_error(req,eclass,ecode,__LINE__,__FILE__) #define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__) #define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) -- cgit From 3dd3c4cd013dadd1a1f57ac3e0750018dc5a0698 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 15 Aug 2007 16:58:29 +0000 Subject: r24464: Now Volker removed the readbmpx we don't need cached errors any more. Jeremy. (This used to be commit 9256ec0a20f532c7dd7ddc2d3534336a47e6c2d2) --- source3/include/smb_macros.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 7c786b03c8..85b623af01 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -158,12 +158,6 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) -/* Macro to test if an error has been cached for this fnum */ -#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ - (fsp)->wbmpx_ptr->wr_discard) -/* Macro to turn the cached error into an error packet */ -#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__,__FILE__) - #define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) #define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__) #define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__) -- cgit From 7b24eb65a0c4189796fc74319a400c6bfb85fdb7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Aug 2007 01:23:31 +0000 Subject: r24759: Comment out the _nonnull calls for 3.2.x, as agreed with tridge. Leaving the commented out code for now, in case I need to re-test some stuff. Jeremy (This used to be commit 343be0464342aac14a9592fd73a71b7589ba34d5) --- source3/include/smb_macros.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 85b623af01..c85e6e0ea0 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -275,6 +275,11 @@ copy an IP address from one buffer to another /* The new talloc is paranoid malloc checker safe. */ +#if 0 + +Disable these now we've checked all code paths and ensured +NULL returns on zero request. JRA. + #define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__) #define TALLOC_P(ctx, type) (type *)talloc_zeronull(ctx, sizeof(type), #type) #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_zeronull(ctx, sizeof(type), count, #type) @@ -282,12 +287,27 @@ copy an IP address from one buffer to another #define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, sizeof(type), #type) #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_zeronull(ctx, sizeof(type), count, #type) +#define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__) +#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) + +#else + +#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__) +#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) +#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__) +#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__) +#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__) +#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__) + +#endif + #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__) #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) #define talloc_destroy(ctx) talloc_free(ctx) #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) -#define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__) -#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) /* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling the smbmount utils */ -- cgit From d17f87e2830844aaef14fffe60c5ae0dbc73c997 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Aug 2007 01:48:46 +0000 Subject: r24762: Fix the build, missed TALLOC_SIZE -> talloc_named_const. Jeremy. (This used to be commit e2d924248ef4c8158e80bfffa5d734b9723112ce) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index c85e6e0ea0..fb3d394d0d 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -299,7 +299,7 @@ NULL returns on zero request. JRA. #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__) #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) -#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__) +#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__) #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__) #endif -- cgit From 941a783f1a01c355e4da114760ad14abab4c8f89 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 30 Aug 2007 14:55:32 +0000 Subject: r24803: For some funny reason us4/gcc seems to fall over the ' (This used to be commit 08e309e955eea58df1eb88f848386eb2acbd31ba) --- source3/include/smb_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index fb3d394d0d..c44f245d2b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -277,7 +277,7 @@ copy an IP address from one buffer to another #if 0 -Disable these now we've checked all code paths and ensured +Disable these now we have checked all code paths and ensured NULL returns on zero request. JRA. #define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__) -- cgit From 327ca9167ed28d2207444a93424cadef79d166b5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Sep 2007 19:27:34 +0000 Subject: r25103: Ensure we don't return unwritten memory (valgrind caught). Jeremy. (This used to be commit b3f0d39d11fa18b7bfef6cec88efaf4a2be2d6e0) --- source3/include/smb_macros.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index c44f245d2b..d53d6c3418 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -270,9 +270,6 @@ copy an IP address from one buffer to another #define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1) #define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count)) -/* limiting size of ipc replies */ -#define SMB_REALLOC_LIMIT(ptr,size) (char *)SMB_REALLOC(ptr,MAX((size),4*1024)) - /* The new talloc is paranoid malloc checker safe. */ #if 0 -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/include/smb_macros.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index d53d6c3418..aea429d2ea 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -158,10 +158,11 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) -#define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) -#define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__) -#define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__) -#define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__) +#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__) +#define ERROR_OPEN(status) error_open(outbuf,status,__LINE__,__FILE__) +#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__) #define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__) #define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__) @@ -170,7 +171,7 @@ #define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) /* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) +#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 @@ -378,4 +379,12 @@ 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 */ + #endif /* _SMB_MACROS_H */ -- cgit From f88b7a076be74a29a3bf876b4e2705f4a1ecf42b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 24 Oct 2007 14:16:54 -0700 Subject: This is a large patch (sorry). Migrate from struct in_addr to struct sockaddr_storage in most places that matter (ie. not the nmbd and NetBIOS lookups). This passes make test on an IPv4 box, but I'll have to do more work/testing on IPv6 enabled boxes. This should now give us a framework for testing and finishing the IPv6 migration. It's at the state where someone with a working IPv6 setup should (theorecically) be able to type : smbclient //ipv6-address/share and have it work. Jeremy. (This used to be commit 98e154c3125d5732c37a72d74b0eb5cd7b6155fd) --- source3/include/smb_macros.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index aea429d2ea..9af63451b0 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -206,11 +206,10 @@ values ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000) /**************************************************************************** -true if two IP addresses are equal +true if two IPv4 addresses are equal ****************************************************************************/ -#define ip_equal(ip1,ip2) ((ip1).s_addr == (ip2).s_addr) -#define ip_service_equal(ip1,ip2) ( ((ip1).ip.s_addr == (ip2).ip.s_addr) && ((ip1).port == (ip2).port) ) +#define ip_equal_v4(ip1,ip2) ((ip1).s_addr == (ip2).s_addr) /***************************************************************** splits out the last subkey of a key -- cgit From 329365684bca99bf9020b6638a1357df65c1d938 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Nov 2007 12:21:34 -0700 Subject: Change the client library to write directly out of the incoming buffer in the non-signed case. Speeds up writes by over 10% or so. Complete the server recvfile implementation. Jeremy. (This used to be commit 81ca5853b2475f123faab3b550f0a7b24ae3c208) --- source3/include/smb_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 9af63451b0..0dfb596994 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -193,8 +193,8 @@ buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0) #define smb_len_large(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|(PVAL(buf,1)<<16)) -#define _smb_setlen_large(buf,len) do { buf[0] = 0; buf[1] = (len&0xFF0000)>>16; \ - buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0) +#define _smb_setlen_large(buf,len) do { buf[0] = 0; buf[1] = ((len)&0xFF0000)>>16; \ + buf[2] = ((len)&0xFF00)>>8; buf[3] = (len)&0xFF; } while (0) /******************************************************************* find the difference in milliseconds between two struct timeval -- cgit From afc93255d183eefb68e45b8ec6275f6a62cf9795 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Dec 2007 17:12:36 -0800 Subject: Add SMB encryption. Still fixing client decrypt but negotiation works. Jeremy. (This used to be commit d78045601af787731f0737b8627450018902b104) --- source3/include/smb_macros.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 0dfb596994..9bacdce1db 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -158,11 +158,10 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) -#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) -#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__) -#define ERROR_OPEN(status) error_open(outbuf,status,__LINE__,__FILE__) -#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__) -#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__) +#define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__) +#define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__) #define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__) #define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__) @@ -170,9 +169,6 @@ #define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__) #define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) -/* this is how errors are generated */ -#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) - /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 @@ -189,8 +185,8 @@ #define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size) #define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16)) -#define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = (len&0x10000)>>16; \ - buf[2] = (len&0xFF00)>>8; buf[3] = len&0xFF; } while (0) +#define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \ + buf[2] = ((len)&0xFF00)>>8; buf[3] = (len)&0xFF; } while (0) #define smb_len_large(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|(PVAL(buf,1)<<16)) #define _smb_setlen_large(buf,len) do { buf[0] = 0; buf[1] = ((len)&0xFF0000)>>16; \ -- cgit From 9254bb4ef1c3c3a52ea8e935edb0e7a86ec3ea7a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Jan 2008 12:56:23 -0800 Subject: Refactor the crypto code after a very helpful conversation with Volker. Mostly making sure we have data on the incoming packet type, not stored in the smb header. Jeremy. (This used to be commit c4e5a505043965eec77b5bb9bc60957e8f3b97c8) --- source3/include/smb_macros.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 9bacdce1db..3324f3fc02 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -158,10 +158,10 @@ #define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx))) #define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx))) -#define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) -#define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__) -#define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__) -#define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__) +#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__) +#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__) +#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__) +#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__) #define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__) #define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__) @@ -192,6 +192,9 @@ #define _smb_setlen_large(buf,len) do { buf[0] = 0; buf[1] = ((len)&0xFF0000)>>16; \ buf[2] = ((len)&0xFF00)>>8; buf[3] = (len)&0xFF; } while (0) +#define ENCRYPTION_REQUIRED(conn) ((conn) ? ((conn)->encrypt_level == Required) : false) +#define IS_CONN_ENCRYPTED(conn) ((conn) ? (conn)->encrypted_tid : false) + /******************************************************************* find the difference in milliseconds between two struct timeval values -- cgit From 980ac0984905d8c3f29dd62ed75fc9c7cb22cdd8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Jan 2008 17:32:26 -0800 Subject: Fixup hot paths - add macro for toupper (c < 0x80). This now matches 3.0.x on my micro-tests. Jeremy. (This used to be commit 329b924cba8225002ca40db26c45b31d141a0925) --- source3/include/smb_macros.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 3324f3fc02..463a2bdb0b 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -385,4 +385,12 @@ do { \ #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. + */ +extern char toupper_ascii_fast_table[]; +#define toupper_ascii_fast(c) toupper_ascii_fast_table[(unsigned int)(c)]; +#endif + #endif /* _SMB_MACROS_H */ -- cgit From e1b32594c70ee57f16c84adb7910aa5c84a560f8 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Thu, 28 Feb 2008 15:49:57 +0100 Subject: Remove smbmount. Karolin (This used to be commit 5fbd98f7065268ae134108310119078ad8f62322) --- source3/include/smb_macros.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 463a2bdb0b..c98c4244de 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -305,10 +305,9 @@ NULL returns on zero request. JRA. #define talloc_destroy(ctx) talloc_free(ctx) #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) -/* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling - the smbmount utils */ +/* only define PARANOID_MALLOC_CHECKER with --enable-developer */ -#if defined(DEVELOPER) && !defined(SMBMOUNT_MALLOC) +#if defined(DEVELOPER) # define PARANOID_MALLOC_CHECKER 1 #endif -- cgit From 6c6c89cde0808ad2c485064d7bbdbfc57a77d2d4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Apr 2008 23:23:24 +0200 Subject: IDL: build generated nbt code. Guenther (This used to be commit 554dcfdab03f9d06f319a3234d56cf44dc38c9da) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index c98c4244de..0e21431226 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -169,8 +169,11 @@ #define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__) #define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__) +#if 0 +/* defined in IDL */ /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 +#endif #define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x)) -- cgit From 52664f62ba84719a9ea6eb8f9c01f1f3a9bd1b24 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 19 Jun 2008 18:46:57 +0200 Subject: Remove current_user references from trans2.c This involved replacing the CHECK_NTQUOTA_HANDLE_OK macro by a function. (This used to be commit 5595cdf837edb82db69a3e57bcf3108be7feeeb8) --- source3/include/smb_macros.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 0e21431226..20e2a9a443 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -75,8 +75,6 @@ return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ } while(0) -#define FNUM_OK(fsp,c) ((fsp) && !(fsp)->is_directory && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) - /* you must add the following extern declaration to files using this macro * (do not add it to the macro as that causes nested extern declaration warnings) * extern struct current_user current_user; -- cgit