From 9dd8940e5f4d89da67b66fb1932a95cc6fda63a5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 03:14:08 +0100 Subject: Add header for NetGetJoinableOUs to libnetapi. Guenther (This used to be commit f297ea259d58f7a12924b7111ab79818188cff46) --- source3/lib/netapi/netapi.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 67bb8a8fca..c2f1b488db 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -95,6 +95,17 @@ NET_API_STATUS NetGetJoinInformation(const char *server_name, const char **name_buffer, uint16_t *name_type); +/**************************************************************** + NetGetJoinableOUs +****************************************************************/ + +NET_API_STATUS NetGetJoinableOUs(const char *server_name, + const char *domain, + const char *account, + const char *password, + uint32_t *ou_count, + const char ***ous); + /**************************************************************** NetServerGetInfo ****************************************************************/ -- cgit From db40120c73f4d4cbb132f94cd3c5859fbdad0f5a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 08:48:44 +0100 Subject: Fix the build w/o ADS. Guenther (This used to be commit 645f2376d40fabdc787902ac7506ad7234616619) --- source3/lib/netapi/joindomain.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index cbfc6c01e3..133aff3dd8 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -558,6 +558,7 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, uint32_t *ou_count, const char ***ous) { +#ifdef WITH_ADS NTSTATUS status; ADS_STATUS ads_status; ADS_STRUCT *ads = NULL; @@ -608,6 +609,9 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, ads_destroy(&ads); return WERR_OK; +#else + return WERR_NOT_SUPPORTED; +#endif } /**************************************************************** -- cgit From 928f899948d25a133c9622a2ac8208e4499ba260 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 14:46:47 +0100 Subject: r25970: libreplace: fix AC_N_DEFINE() so that some appears in config.h metze (cherry picked from commit a07c983fde52607806745914bb41039afb5618cc) (This used to be commit 3db37038b3e5a59a9baa85f6bcd32ac6e5ec2da1) --- source3/lib/replace/libreplace_macros.m4 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace_macros.m4 b/source3/lib/replace/libreplace_macros.m4 index 92fecd3db8..54e6b7ac75 100644 --- a/source3/lib/replace/libreplace_macros.m4 +++ b/source3/lib/replace/libreplace_macros.m4 @@ -248,11 +248,18 @@ m4_define([AH_CHECK_FUNC_EXT], dnl Define an AC_DEFINE with ifndef guard. dnl AC_N_DEFINE(VARIABLE [, VALUE]) -define(AC_N_DEFINE, -[cat >> confdefs.h <<\EOF -[#ifndef] $1 -[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1) -[#endif] +AC_DEFUN([AC_N_DEFINE], +[ +AH_VERBATIM([$1], [ +#ifndef $1 +# undef $1 +#endif +]) + + cat >>confdefs.h <<\EOF +#ifndef $1 +[#define] $1 m4_if($#, 1, 1, [$2]) +#endif EOF ]) -- cgit From 2e0dc77bdad8e6c88920cfb8624a8dac981dd4c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 14:55:48 +0100 Subject: r25971: libreplace: remove AC_EXTENSION_FLAG as it's the same as AC_N_DEFINE metze (cherry picked from commit 05b4619c5beff474488d1abe5e647acd94a3e20c) (This used to be commit 58932ca791024bd9a543ff5e21bc26970ceed477) --- source3/lib/replace/libreplace_cc.m4 | 4 ++-- source3/lib/replace/libreplace_macros.m4 | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace_cc.m4 b/source3/lib/replace/libreplace_cc.m4 index a01bf1b290..a0722b2fcf 100644 --- a/source3/lib/replace/libreplace_cc.m4 +++ b/source3/lib/replace/libreplace_cc.m4 @@ -48,8 +48,8 @@ LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not su AC_PROG_INSTALL AC_ISC_POSIX -AC_EXTENSION_FLAG(_XOPEN_SOURCE_EXTENDED) -AC_EXTENSION_FLAG(_OSF_SOURCE) +AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) +AC_N_DEFINE(_OSF_SOURCE) AC_SYS_LARGEFILE diff --git a/source3/lib/replace/libreplace_macros.m4 b/source3/lib/replace/libreplace_macros.m4 index 54e6b7ac75..1856eacf66 100644 --- a/source3/lib/replace/libreplace_macros.m4 +++ b/source3/lib/replace/libreplace_macros.m4 @@ -87,19 +87,6 @@ fi rm -f conftest* ])]) -AC_DEFUN([AC_EXTENSION_FLAG], -[ - cat >>confdefs.h <<\EOF -#ifndef $1 -# define $1 1 -#endif -EOF -AH_VERBATIM([$1], [#ifndef $1 -# define $1 1 -#endif]) -]) - - dnl see if a declaration exists for a function or variable dnl defines HAVE_function_DECL if it exists dnl AC_HAVE_DECL(var, includes) -- cgit From f75898d5b5712bcd8cb45cd54893932c1d0e5b36 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 15:43:14 +0100 Subject: r25974: libreplace: see what the build-farm says if we use _XOPEN_SOURCE=600 On Tru64 this brings in socklen_t and some other socket stuff metze (cherry picked from commit d42f2e5759332f1f0c6c1269bd29ac62ddb11016) (This used to be commit af3772e22f5e6e0158783086e9791ffc95ee5368) --- source3/lib/replace/libreplace_cc.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace_cc.m4 b/source3/lib/replace/libreplace_cc.m4 index a0722b2fcf..3f0a337083 100644 --- a/source3/lib/replace/libreplace_cc.m4 +++ b/source3/lib/replace/libreplace_cc.m4 @@ -49,6 +49,7 @@ AC_PROG_INSTALL AC_ISC_POSIX AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) +AC_N_DEFINE(_XOPEN_SOURCE,600) AC_N_DEFINE(_OSF_SOURCE) AC_SYS_LARGEFILE -- cgit From 0e1348869e50715f889a97a375abc7ae1af13d69 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 16:40:32 +0100 Subject: r25976: libreplace: not all platforms like _XOPEN_SOURCE=600 - Only use _XOPEN_SOURCE=600 on Tru64 - _OSF_SOURCE is also Tru64 specific metze (cherry picked from commit d19ab62081ce4ee4273ff752ad0443782a994826) (This used to be commit dbff70b2ebe7cc09f7fbe5a0319f978dfcfa1da9) --- source3/lib/replace/libreplace_cc.m4 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace_cc.m4 b/source3/lib/replace/libreplace_cc.m4 index 3f0a337083..bf5056838d 100644 --- a/source3/lib/replace/libreplace_cc.m4 +++ b/source3/lib/replace/libreplace_cc.m4 @@ -49,8 +49,6 @@ AC_PROG_INSTALL AC_ISC_POSIX AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) -AC_N_DEFINE(_XOPEN_SOURCE,600) -AC_N_DEFINE(_OSF_SOURCE) AC_SYS_LARGEFILE @@ -78,6 +76,11 @@ case "$host_os" in CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" fi ;; + *osf*) + # this brings in socklen_t + AC_N_DEFINE(_XOPEN_SOURCE,600) + AC_N_DEFINE(_OSF_SOURCE) + ;; # # VOS may need to have POSIX support and System V compatibility enabled. # -- cgit From a2bfb1749ca7bc0c713d3508c1324799245c7d1a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Nov 2007 14:42:14 +0100 Subject: r26102: libreplace: remove system/printing.h as it only contains samba3 stuff metze (cherry picked from commit 1ecb4ec01b0506c95a5f90a62040329e7a39ee93) (This used to be commit ff8a001f0d3f2655efafed41f2f0b14552a5c7e7) --- source3/lib/replace/system/printing.h | 50 ----------------------------------- source3/lib/replace/test/testsuite.c | 1 - 2 files changed, 51 deletions(-) delete mode 100644 source3/lib/replace/system/printing.h (limited to 'source3/lib') diff --git a/source3/lib/replace/system/printing.h b/source3/lib/replace/system/printing.h deleted file mode 100644 index 7eb02d004a..0000000000 --- a/source3/lib/replace/system/printing.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _system_printing_h -#define _system_printing_h - -/* - Unix SMB/CIFS implementation. - - printing system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef AIX -#define DEFAULT_PRINTING PRINT_AIX -#define PRINTCAP_NAME "/etc/qconfig" -#endif - -#ifdef HPUX -#define DEFAULT_PRINTING PRINT_HPUX -#endif - -#ifdef QNX -#define DEFAULT_PRINTING PRINT_QNX -#endif - -#ifndef DEFAULT_PRINTING -#define DEFAULT_PRINTING PRINT_BSD -#endif -#ifndef PRINTCAP_NAME -#define PRINTCAP_NAME "/etc/printcap" -#endif - -#endif diff --git a/source3/lib/replace/test/testsuite.c b/source3/lib/replace/test/testsuite.c index 269a2ff5d6..5b95ae395c 100644 --- a/source3/lib/replace/test/testsuite.c +++ b/source3/lib/replace/test/testsuite.c @@ -37,7 +37,6 @@ #include "system/locale.h" #include "system/network.h" #include "system/passwd.h" -#include "system/printing.h" #include "system/readline.h" #include "system/select.h" #include "system/shmem.h" -- cgit From 1e5418edbc370e87293c324eae54372a495bb932 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 20 Dec 2007 15:59:39 +0100 Subject: r26550: libreplace: fallback to __ss_family of struct sockaddr_storage metze (cherry picked from commit 11bdc9bed80b9842ac1ab8f22509a5d191cddc91) (This used to be commit c11122afda52ce787dd1d3357bd85b6ce36b8ca4) --- source3/lib/replace/libreplace.m4 | 20 ++++++++++++++++++++ source3/lib/replace/system/network.h | 9 +++++++++ 2 files changed, 29 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace.m4 b/source3/lib/replace/libreplace.m4 index 7a5283a4d6..f866b3648f 100644 --- a/source3/lib/replace/libreplace.m4 +++ b/source3/lib/replace/libreplace.m4 @@ -153,6 +153,26 @@ AC_HAVE_TYPE([struct sockaddr_in6], [ #include ]) +if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, + AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, + [ +#include +#include +#include + ]) + +if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, + AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, + [ +#include +#include +#include + ]) +fi +fi + AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index b6ae3c7c6f..2f387de5cf 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -227,9 +227,18 @@ typedef unsigned short int sa_family_t; #ifdef HAVE_STRUCT_SOCKADDR_IN6 #define sockaddr_storage sockaddr_in6 #define ss_family sin6_family +#define HAVE_SS_FAMILY 1 #else #define sockaddr_storage sockaddr_in #define ss_family sin_family +#define HAVE_SS_FAMILY 1 +#endif +#endif + +#ifndef HAVE_SS_FAMILY +#ifdef HAVE___SS_FAMILY +#define ss_family __ss_family +#define HAVE_SS_FAMILY 1 #endif #endif -- cgit From f8ad02305fca3357e924c9c0e462b05b1452ae16 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 04:46:11 +0100 Subject: Try to fix the build on Tru64; avoid single quotes because they get expanded by perl in the build system. (cherry picked from commit bba8914af56cb161c275fbbdea2479d6f8bd703c) (This used to be commit a0e663ff2c6548e48c9710e3fb314f3bbabb59d0) --- source3/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace_ld.m4 b/source3/lib/replace/libreplace_ld.m4 index cb8e21434e..0ca6f7a34d 100644 --- a/source3/lib/replace/libreplace_ld.m4 +++ b/source3/lib/replace/libreplace_ld.m4 @@ -265,7 +265,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-expect_unresolved '*'" + LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,*" ;; *darwin*) LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" -- cgit From a0e04a94170ffb54e8a809ed869a08af898fb723 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 22:24:07 +0100 Subject: libreplace: Escape asterisk. (cherry picked from commit df36c78549b40ee5e47d5cc79de2eb79f58c567a) (This used to be commit 174a45ec18fff064d89f6a12b044973ab3c10c54) --- source3/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/libreplace_ld.m4 b/source3/lib/replace/libreplace_ld.m4 index 0ca6f7a34d..2aec698967 100644 --- a/source3/lib/replace/libreplace_ld.m4 +++ b/source3/lib/replace/libreplace_ld.m4 @@ -265,7 +265,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,*" + LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\"" ;; *darwin*) LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" -- cgit From db449a4c5f807b11ec723b11a2db32d09162e163 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Jan 2008 16:34:06 +0100 Subject: Revert "Host SerNet-AIX has __ss_family instead of ss_family in sockaddr_storage" This reverts commit e33286f4a68352e55df081d06307f64f190773b3. 393bab185e0e9f02aac5740becc2aba2762133c8 is the v4-0-test fix for the same problem. metze (This used to be commit b8a57a24c390355c4950ca499c1d96aff80abad7) --- source3/lib/replace/system/network.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index 2f387de5cf..fe6e46817f 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -242,10 +242,6 @@ typedef unsigned short int sa_family_t; #endif #endif -#ifdef HAVE_AIX_SOCKADDR_STORAGE -#define ss_family __ss_family -#endif - #ifndef HAVE_STRUCT_ADDRINFO #define HAVE_STRUCT_ADDRINFO struct addrinfo { -- cgit From 805caafd44cbc5fff49711b1a15fb64cc99f3ad3 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 19 Jan 2008 02:12:35 +0100 Subject: util_str: Don't return memory from talloc_tos(), use mem_ctx instead. (This used to be commit ab0ee6e9a6a9eee317228f0c2bde254ad9a59b85) --- source3/lib/afs.c | 23 +++++++++++++---------- source3/lib/util_str.c | 6 +++--- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/afs.c b/source3/lib/afs.c index a7d6f6c9f7..b3d590bf24 100644 --- a/source3/lib/afs.c +++ b/source3/lib/afs.c @@ -42,20 +42,23 @@ static char *afs_encode_token(const char *cell, const DATA_BLOB ticket, const struct ClearToken *ct) { char *base64_ticket; - char *result; + char *result = NULL; DATA_BLOB key = data_blob(ct->HandShakeKey, 8); char *base64_key; + TALLOC_CTX *mem_ctx; + + mem_ctx = talloc_init("afs_encode_token"); + if (mem_ctx == NULL) + goto done; - base64_ticket = base64_encode_data_blob(ticket); + base64_ticket = base64_encode_data_blob(mem_ctx, ticket); if (base64_ticket == NULL) - return NULL; + goto done; - base64_key = base64_encode_data_blob(key); - if (base64_key == NULL) { - TALLOC_FREE(base64_ticket); - return NULL; - } + base64_key = base64_encode_data_blob(mem_ctx, key); + if (base64_key == NULL) + goto done; asprintf(&result, "%s\n%u\n%s\n%u\n%u\n%u\n%s\n", cell, ct->AuthHandle, base64_key, ct->ViceId, ct->BeginTimestamp, @@ -63,8 +66,8 @@ static char *afs_encode_token(const char *cell, const DATA_BLOB ticket, DEBUG(10, ("Got ticket string:\n%s\n", result)); - TALLOC_FREE(base64_ticket); - TALLOC_FREE(base64_key); +done: + TALLOC_FREE(mem_ctx); return result; } diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 3e3268104c..bcb9197141 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -2415,13 +2415,13 @@ void base64_decode_inplace(char *s) } /** - * Encode a base64 string into a malloc()ed string caller to free. + * Encode a base64 string into a talloc()ed string caller to free. * * From SQUID: adopted from http://ftp.sunet.se/pub2/gnu/vm/base64-encode.c * with adjustments **/ -char *base64_encode_data_blob(DATA_BLOB data) +char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data) { int bits = 0; int char_count = 0; @@ -2434,7 +2434,7 @@ char *base64_encode_data_blob(DATA_BLOB data) out_cnt = 0; len = data.length; output_len = data.length * 2; - result = TALLOC_ARRAY(talloc_tos(), char, output_len); /* get us plenty of space */ + result = TALLOC_ARRAY(mem_ctx, char, output_len); /* get us plenty of space */ SMB_ASSERT(result != NULL); while (len-- && out_cnt < (data.length * 2) - 5) { -- cgit From 398c323f7544e815cfeb2b750f9ff28061c294f3 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 19 Jan 2008 12:27:31 +0100 Subject: afs: Use talloc_stackframe() instead of talloc_init() Thanks to vl for pointing this out. (This used to be commit 76cf5a979bf3014b1de660520e538546b3676b23) --- source3/lib/afs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/afs.c b/source3/lib/afs.c index b3d590bf24..9f5d81f442 100644 --- a/source3/lib/afs.c +++ b/source3/lib/afs.c @@ -48,7 +48,7 @@ static char *afs_encode_token(const char *cell, const DATA_BLOB ticket, char *base64_key; TALLOC_CTX *mem_ctx; - mem_ctx = talloc_init("afs_encode_token"); + mem_ctx = talloc_stackframe(); if (mem_ctx == NULL) goto done; -- cgit From a0bd9d97a3a701fdb1f9a48ce925f63b786a8070 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 19 Jan 2008 15:14:45 +0100 Subject: Tiny memory leak in lib/version.c Hi, while implementing the extra_info version stuff, it occured to me that samba_version_string() potentially allocates memory which is unused but never free'd. If SAMBA_VERSION_VENDOR_PATCH is defined, a second call to asprintf takes place. The result is stored in tmp_version. Afterwards, samba_version is set to tmp_version without free'ing samba_version first. Looks like a simple free(samba_version) is missing. Patch against 3.2-test below. Ok, this only happens once over the lifetime of the application, so it's no big deal, but I though it doesn't hurt to mention it. Corinna * lib/version.c (samba_version_string): Free samba_version before setting to tmp_version. (This used to be commit 373a23d48f2dd24e65dbf814ea58b4add2322128) --- source3/lib/version.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib') diff --git a/source3/lib/version.c b/source3/lib/version.c index 204c2044a8..cbb70ae8a6 100644 --- a/source3/lib/version.c +++ b/source3/lib/version.c @@ -51,6 +51,7 @@ const char *samba_version_string(void) */ assert(res != -1); + free(samba_version); samba_version = tmp_version; #endif -- cgit From 07e07f696ad10f3a5d7a0d9de656ff13600ac97d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 19:31:02 +0100 Subject: Use SAFE_FREE instead of free (This used to be commit 999647329028147d7c29a3348202641b3e03430e) --- source3/lib/version.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/version.c b/source3/lib/version.c index cbb70ae8a6..3cae02ad2e 100644 --- a/source3/lib/version.c +++ b/source3/lib/version.c @@ -51,7 +51,8 @@ const char *samba_version_string(void) */ assert(res != -1); - free(samba_version); + SAFE_FREE(samba_version); + samba_version = tmp_version; #endif -- cgit From 14e7c292bc76b0edb8cafcaa728a612fa806fa6d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 22:44:55 +0100 Subject: Add an error mapping for ENOATTR (This used to be commit 9f0d778490415b05224f36287df999672ee16928) --- source3/lib/errmap_unix.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c index 885a1c55b2..8194cf80cc 100644 --- a/source3/lib/errmap_unix.c +++ b/source3/lib/errmap_unix.c @@ -92,6 +92,9 @@ const struct unix_error_map unix_dos_nt_errmap[] = { #ifdef EWOULDBLOCK { EWOULDBLOCK, ERRDOS, 111, NT_STATUS_NETWORK_BUSY }, #endif +#ifdef ENOATTR + { ENOATTR, ERRDOS, ERRbadfile, NT_STATUS_NOT_FOUND }, +#endif { 0, 0, 0, NT_STATUS_OK } }; -- cgit From 2411c6cb90e485bd289b8b654db1c632556bfb2d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 23:10:09 +0100 Subject: Add "split_ntfs_stream_name()" together with a torture test (This used to be commit d813bd9e02d9baf916eb96c478be89f0c435e07c) --- source3/lib/util.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index bc3eaa8d5e..11f3660df8 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3273,3 +3273,93 @@ void *talloc_zeronull(const void *context, size_t size, const char *name) return talloc_named_const(context, size, name); } #endif + +/* Split a path name into filename and stream name components. Canonicalise + * such that an implicit $DATA token is always explicit. + * + * The "specification" of this function can be found in the + * run_local_stream_name() function in torture.c, I've tried those + * combinations against a W2k3 server. + */ + +NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname, + char **pbase, char **pstream) +{ + char *base = NULL; + char *stream = NULL; + char *sname; /* stream name */ + const char *stype; /* stream type */ + + DEBUG(10, ("split_ntfs_stream_name called for [%s]\n", fname)); + + sname = strchr_m(fname, ':'); + + if (lp_posix_pathnames() || (sname == NULL)) { + if (pbase != NULL) { + base = talloc_strdup(mem_ctx, fname); + NT_STATUS_HAVE_NO_MEMORY(base); + } + goto done; + } + + if (pbase != NULL) { + base = talloc_strndup(mem_ctx, fname, PTR_DIFF(sname, fname)); + NT_STATUS_HAVE_NO_MEMORY(base); + } + + sname += 1; + + stype = strchr_m(sname, ':'); + + if (stype == NULL) { + sname = talloc_strdup(mem_ctx, sname); + stype = "$DATA"; + } + else { + if (StrCaseCmp(stype, ":$DATA") != 0) { + /* + * If there is an explicit stream type, so far we only + * allow $DATA. Is there anything else allowed? -- vl + */ + DEBUG(10, ("[%s] is an invalid stream type\n", stype)); + TALLOC_FREE(base); + return NT_STATUS_OBJECT_NAME_INVALID; + } + sname = talloc_strndup(mem_ctx, sname, PTR_DIFF(stype, sname)); + stype += 1; + } + + if (sname == NULL) { + TALLOC_FREE(base); + return NT_STATUS_NO_MEMORY; + } + + if (sname[0] == '\0') { + /* + * no stream name, so no stream + */ + goto done; + } + + if (pstream != NULL) { + stream = talloc_asprintf(mem_ctx, "%s:%s", sname, stype); + if (stream == NULL) { + TALLOC_FREE(sname); + TALLOC_FREE(base); + return NT_STATUS_NO_MEMORY; + } + /* + * upper-case the type field + */ + strupper_m(strchr_m(stream, ':')+1); + } + + done: + if (pbase != NULL) { + *pbase = base; + } + if (pstream != NULL) { + *pstream = stream; + } + return NT_STATUS_OK; +} -- cgit From 014bfd35f8c57370b27a1d07c335e2d9813a1333 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 00:44:14 +0100 Subject: Some systems do not have XATTR_ defined (This used to be commit 2cac1d3919a96c480f34c93d8b9b07782d46ed23) --- source3/lib/system.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/system.c b/source3/lib/system.c index eb6dcae6fb..fa50955ef6 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -1917,11 +1917,6 @@ int sys_fremovexattr (int filedes, const char *name) #endif } -#if !defined(HAVE_SETXATTR) -#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ -#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ -#endif - int sys_setxattr (const char *path, const char *name, const void *value, size_t size, int flags) { #if defined(HAVE_SETXATTR) -- cgit From 33f3eeaa00974860dfc45962d5fd34cf05396c76 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 17:35:25 +0100 Subject: Fix some "set but never used" warnings (This used to be commit 4a6dadc5178f4861e9c032321939db3b639734b5) --- source3/lib/dbwrap_tdb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c index e87ceb428f..18f9495931 100644 --- a/source3/lib/dbwrap_tdb.c +++ b/source3/lib/dbwrap_tdb.c @@ -91,7 +91,6 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db, struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data, struct db_tdb_ctx); struct tdb_fetch_locked_state state; - int res; /* Do not accidently allocate/deallocate w/o need when debug level is lower than needed */ if(DEBUGLEVEL >= 10) { @@ -110,8 +109,7 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db, state.mem_ctx = mem_ctx; state.result = NULL; - res = tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse, - &state); + tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse, &state); if (state.result == NULL) { db_tdb_fetchlock_parse(key, tdb_null, &state); -- cgit From 99dfd664881f92dd1972f872c7471c5665869b86 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 00:40:10 +0100 Subject: Rename lib/util_reg_smbconf.c to registry/reg_init_smbconf.c This actually is a counterpart to reg_init_full, in that is does open and initialize the registry too, but only registeres the backends necessary to access the SMBCONF key. Michael (This used to be commit 01bda3ab359fb3868c1dc849044f613bf2bc563e) --- source3/lib/util_reg_smbconf.c | 97 ------------------------------------------ 1 file changed, 97 deletions(-) delete mode 100644 source3/lib/util_reg_smbconf.c (limited to 'source3/lib') diff --git a/source3/lib/util_reg_smbconf.c b/source3/lib/util_reg_smbconf.c deleted file mode 100644 index 6452b0b15b..0000000000 --- a/source3/lib/util_reg_smbconf.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Registry helper routines - * Copyright (C) Michael Adam 2007 - * - * 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 3 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, see . - */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_REGISTRY - -extern REGISTRY_OPS smbconf_reg_ops; - -/* - * create a fake token just with enough rights to - * locally access the registry: - * - * - builtin administrators sid - * - disk operators privilege - */ -NTSTATUS registry_create_admin_token(TALLOC_CTX *mem_ctx, - NT_USER_TOKEN **ptoken) -{ - NTSTATUS status; - NT_USER_TOKEN *token = NULL; - - if (ptoken == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - token = TALLOC_ZERO_P(mem_ctx, NT_USER_TOKEN); - if (token == NULL) { - DEBUG(1, ("talloc failed\n")); - status = NT_STATUS_NO_MEMORY; - goto done; - } - token->privileges = se_disk_operators; - status = add_sid_to_array(token, &global_sid_Builtin_Administrators, - &token->user_sids, &token->num_sids); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Error adding builtin administrators sid " - "to fake token.\n")); - goto done; - } - - *ptoken = token; - -done: - return status; -} - -/* - * init the smbconf portion of the registry. - * for use in places where not the whole registry is needed, - * e.g. utils/net_conf.c and loadparm.c - */ -bool registry_init_regdb(void) -{ - bool ret = false; - int saved_errno = 0; - static REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops}; - - DEBUG(10, ("registry_init_regdb called\n")); - - if (!regdb_init()) { - saved_errno = errno; - DEBUG(1, ("Can't open the registry")); - if (saved_errno) { - DEBUGADD(1, (": %s", strerror(saved_errno))); - } - DEBUGADD(1, (".\n")); - goto done; - } - reghook_cache_init(); - if (!reghook_cache_add(&smbconf_reg_hook)) { - DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n")); - goto done; - } - - ret = true; - -done: - return ret; -} -- cgit From 7b6a439efe8a077bf333a9badde021eb9a54b227 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 21 Jan 2008 13:18:38 +0100 Subject: util_sock: Fix memcache bug in get_mydnsfullname. get_mydnsfullname relied on memcache_add(); memcache_lookup() working. When run from ntlm_auth, the global_cache variable in memcache is NULL, so the add and lookup both fail. In that case, just return the result of the getaddrinfo call. Jeremy, please check. (This used to be commit 1db41ff52565e9f336a22fb9ffd80d51677e023b) --- source3/lib/util_sock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 10428113ae..f524d0d826 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -2080,14 +2080,14 @@ const char *get_mydnsfullname(void) data_blob_string_const("get_mydnsfullname"), data_blob_string_const(res->ai_canonname)); - freeaddrinfo(res); - if (!memcache_lookup(NULL, SINGLETON_CACHE, data_blob_string_const("get_mydnsfullname"), &tmp)) { - return NULL; + tmp = data_blob_string_const(res->ai_canonname); } + freeaddrinfo(res); + return (const char *)tmp.data; } -- cgit From 36e3e75e0683eb9fd14d8a282d9a2324f01fddf7 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 21 Jan 2008 18:01:55 +0100 Subject: util_sock: Don't return a pointer to freed memory. Fix a bug in my bugfix. Thanks to vl for spotting that one. (This used to be commit 24f68b90cca111256a7b03f7062cb57c2b08a0d6) --- source3/lib/util_sock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index f524d0d826..a3975f6c1f 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -2083,7 +2083,8 @@ const char *get_mydnsfullname(void) if (!memcache_lookup(NULL, SINGLETON_CACHE, data_blob_string_const("get_mydnsfullname"), &tmp)) { - tmp = data_blob_string_const(res->ai_canonname); + tmp = data_blob_talloc(talloc_tos(), res->ai_canonname, + strlen(res->ai_canonname) + 1); } freeaddrinfo(res); -- cgit From f5df4a100accd163dcd4f41e3bbcd17bb655d1fe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 Jan 2008 12:21:55 +0100 Subject: libreplace: getpwent_r/getgrent_r on IRIX are similar to solaris but use size_t metze (This used to be commit 2f460915111066d79f5dc9b4ae4d003918d06852) --- source3/lib/replace/system/config.m4 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/replace/system/config.m4 b/source3/lib/replace/system/config.m4 index 799187af7d..1c05733126 100644 --- a/source3/lib/replace/system/config.m4 +++ b/source3/lib/replace/system/config.m4 @@ -73,6 +73,18 @@ AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, #include #include ]) +AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, size_t buflen)], + [ + #ifndef HAVE_GETPWENT_R_DECL + #error missing getpwent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r irix (similar to solaris) function prototype]) + ],[],[ + #include + #include + ]) AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r) AC_HAVE_DECL(getgrent_r, [ #include @@ -91,6 +103,19 @@ AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, in #include ]) +AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, size_t buflen)], + [ + #ifndef HAVE_GETGRENT_R_DECL + #error missing getgrent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r irix (similar to solaris) function prototype]) + ],[],[ + #include + #include + ]) + # locale AC_CHECK_HEADERS(ctype.h locale.h) -- cgit From 559603ad693ede382c566cb8bbd8e6bd8d5750a6 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 22 Jan 2008 11:33:17 +0100 Subject: Get Samba version or capability information from Windows On Jan 21 16:18, Danilo Almeida wrote: > Corina wrote: > > > + time_t samba_gitcommitdate; > > And: > > > + SIVAL(pdata,28,extended_info.samba_gitcommitdate); > > + memcpy(pdata+32,extended_info.samba_version_string,32); > > Note that you are dropping bits on a system w/64-bit time_t, and that this has the 2038 problem. Right. I changed samba_gitcommitdate from time_t to NTTIME and shortened samba_version_string to 28 bytes. New patch below. Thanks, Corinna (This used to be commit 28aa1c199d3a22cda34afcaab49c0561eeb0abcb) --- source3/lib/version.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/version.c b/source3/lib/version.c index 3cae02ad2e..38c4f45ac6 100644 --- a/source3/lib/version.c +++ b/source3/lib/version.c @@ -59,3 +59,32 @@ const char *samba_version_string(void) return samba_version; #endif } + +void samba_extended_info_version(struct smb_extended_info *extended_info) +{ + assert(extended_info != NULL); + + extended_info->samba_magic = SAMBA_EXTENDED_INFO_MAGIC; + extended_info->samba_version = ((SAMBA_VERSION_MAJOR & 0xff) << 24) + | ((SAMBA_VERSION_MINOR & 0xff) << 16) + | ((SAMBA_VERSION_RELEASE & 0xff) << 8); +#ifdef SAMBA_VERSION_REVISION + extended_info->samba_version |= (tolower(*SAMBA_VERSION_REVISION) - 'a' + 1) & 0xff; +#endif +#ifdef SAMBA_VERSION_RC_RELEASE + extended_info->samba_subversion |= (SAMBA_VERSION_RC_RELEASE & 0xff) << 24; +#else +#ifdef SAMBA_VERSION_PRE_RELEASE + extended_info->samba_subversion |= (SAMBA_VERSION_PRE_RELEASE & 0xff) << 16; +#endif +#endif +#ifdef SAMBA_VERSION_VENDOR_PATCH + extended_info->samba_subversion |= (SAMBA_VERSION_VENDOR_PATCH & 0xffff); +#endif + /* FIXME: samba_gitcommitdate should contain the git commit date. */ + unix_to_nt_time(&extended_info->samba_gitcommitdate, time(NULL)); + + snprintf (extended_info->samba_version_string, + SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH, + "%s", samba_version_string()); +} -- cgit From 1d99598ca3f21dd863c8d63698f8af2b3b77759b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 22 Jan 2008 12:46:51 +0100 Subject: Avoid use of uninitialized memory (This used to be commit 85123aacdb13e97c3f44aeded1c80e13af53d83d) --- source3/lib/version.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/version.c b/source3/lib/version.c index 38c4f45ac6..dff45f6259 100644 --- a/source3/lib/version.c +++ b/source3/lib/version.c @@ -84,7 +84,10 @@ void samba_extended_info_version(struct smb_extended_info *extended_info) /* FIXME: samba_gitcommitdate should contain the git commit date. */ unix_to_nt_time(&extended_info->samba_gitcommitdate, time(NULL)); + memset(extended_info->samba_version_string, 0, + sizeof(extended_info->samba_version_string)); + snprintf (extended_info->samba_version_string, - SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH, + sizeof(extended_info->samba_version_string), "%s", samba_version_string()); } -- cgit From d4d962f691d13f36226157c38f706ee4d10b9150 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 22 Jan 2008 13:00:22 +0100 Subject: Move samba_extended_info_version to smbd/trans2.c This is right now only used there, and in version.c it gave linker errors because some binaries (e.g. smbmnt) don't link in time.o (This used to be commit 1f0eaaa5911f893c822465a26fe49ab65afb0730) --- source3/lib/version.c | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/version.c b/source3/lib/version.c index dff45f6259..3cae02ad2e 100644 --- a/source3/lib/version.c +++ b/source3/lib/version.c @@ -59,35 +59,3 @@ const char *samba_version_string(void) return samba_version; #endif } - -void samba_extended_info_version(struct smb_extended_info *extended_info) -{ - assert(extended_info != NULL); - - extended_info->samba_magic = SAMBA_EXTENDED_INFO_MAGIC; - extended_info->samba_version = ((SAMBA_VERSION_MAJOR & 0xff) << 24) - | ((SAMBA_VERSION_MINOR & 0xff) << 16) - | ((SAMBA_VERSION_RELEASE & 0xff) << 8); -#ifdef SAMBA_VERSION_REVISION - extended_info->samba_version |= (tolower(*SAMBA_VERSION_REVISION) - 'a' + 1) & 0xff; -#endif -#ifdef SAMBA_VERSION_RC_RELEASE - extended_info->samba_subversion |= (SAMBA_VERSION_RC_RELEASE & 0xff) << 24; -#else -#ifdef SAMBA_VERSION_PRE_RELEASE - extended_info->samba_subversion |= (SAMBA_VERSION_PRE_RELEASE & 0xff) << 16; -#endif -#endif -#ifdef SAMBA_VERSION_VENDOR_PATCH - extended_info->samba_subversion |= (SAMBA_VERSION_VENDOR_PATCH & 0xffff); -#endif - /* FIXME: samba_gitcommitdate should contain the git commit date. */ - unix_to_nt_time(&extended_info->samba_gitcommitdate, time(NULL)); - - memset(extended_info->samba_version_string, 0, - sizeof(extended_info->samba_version_string)); - - snprintf (extended_info->samba_version_string, - sizeof(extended_info->samba_version_string), - "%s", samba_version_string()); -} -- cgit