summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-01-23 13:08:14 +1100
committerAndrew Tridgell <tridge@samba.org>2008-01-23 13:08:14 +1100
commit39d172bf34d0cbb3bf3e3a04d534876097cdccb5 (patch)
tree3a32fd867e34c9a86c3a2f01308445b76bf2d50c /source3/lib
parent2caa0e82f5ff2f45a5c912c624e54c4a43f0c3cc (diff)
parent9051199e40dec27d3532fbec7f5744033def1874 (diff)
downloadsamba-39d172bf34d0cbb3bf3e3a04d534876097cdccb5.tar.gz
samba-39d172bf34d0cbb3bf3e3a04d534876097cdccb5.tar.bz2
samba-39d172bf34d0cbb3bf3e3a04d534876097cdccb5.zip
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit bc2973df8504850a40cb0a1172689dc0bdafa323)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/afs.c23
-rw-r--r--source3/lib/dbwrap_tdb.c4
-rw-r--r--source3/lib/errmap_unix.c3
-rw-r--r--source3/lib/netapi/joindomain.c4
-rw-r--r--source3/lib/netapi/netapi.h11
-rw-r--r--source3/lib/replace/libreplace.m420
-rw-r--r--source3/lib/replace/libreplace_cc.m48
-rw-r--r--source3/lib/replace/libreplace_ld.m42
-rw-r--r--source3/lib/replace/libreplace_macros.m430
-rw-r--r--source3/lib/replace/system/config.m425
-rw-r--r--source3/lib/replace/system/network.h7
-rw-r--r--source3/lib/replace/system/printing.h50
-rw-r--r--source3/lib/replace/test/testsuite.c1
-rw-r--r--source3/lib/system.c5
-rw-r--r--source3/lib/util.c90
-rw-r--r--source3/lib/util_reg_smbconf.c97
-rw-r--r--source3/lib/util_sock.c7
-rw-r--r--source3/lib/util_str.c6
-rw-r--r--source3/lib/version.c2
19 files changed, 201 insertions, 194 deletions
diff --git a/source3/lib/afs.c b/source3/lib/afs.c
index a7d6f6c9f7..9f5d81f442 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_stackframe();
+ 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/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);
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 }
};
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
}
/****************************************************************
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
@@ -96,6 +96,17 @@ NET_API_STATUS NetGetJoinInformation(const char *server_name,
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
****************************************************************/
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 <netinet/in.h>
])
+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 <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+ ])
+
+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 <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+ ])
+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/libreplace_cc.m4 b/source3/lib/replace/libreplace_cc.m4
index a01bf1b290..bf5056838d 100644
--- a/source3/lib/replace/libreplace_cc.m4
+++ b/source3/lib/replace/libreplace_cc.m4
@@ -48,8 +48,7 @@ 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_SYS_LARGEFILE
@@ -77,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.
#
diff --git a/source3/lib/replace/libreplace_ld.m4 b/source3/lib/replace/libreplace_ld.m4
index cb8e21434e..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="-expect_unresolved '*'"
+ LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\""
;;
*darwin*)
LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup"
diff --git a/source3/lib/replace/libreplace_macros.m4 b/source3/lib/replace/libreplace_macros.m4
index 92fecd3db8..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)
@@ -248,11 +235,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
])
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 <unistd.h>
#include <pwd.h>
])
+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 <unistd.h>
+ #include <pwd.h>
+ ])
AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r)
AC_HAVE_DECL(getgrent_r, [
#include <unistd.h>
@@ -91,6 +103,19 @@ AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, in
#include <grp.h>
])
+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 <unistd.h>
+ #include <grp.h>
+ ])
+
# locale
AC_CHECK_HEADERS(ctype.h locale.h)
diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h
index b6ae3c7c6f..fe6e46817f 100644
--- a/source3/lib/replace/system/network.h
+++ b/source3/lib/replace/system/network.h
@@ -227,14 +227,19 @@ 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
-#ifdef HAVE_AIX_SOCKADDR_STORAGE
+#ifndef HAVE_SS_FAMILY
+#ifdef HAVE___SS_FAMILY
#define ss_family __ss_family
+#define HAVE_SS_FAMILY 1
+#endif
#endif
#ifndef HAVE_STRUCT_ADDRINFO
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 <http://www.gnu.org/licenses/>.
-
-*/
-
-#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"
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)
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;
+}
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 <http://www.gnu.org/licenses/>.
- */
-
-#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;
-}
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 10428113ae..a3975f6c1f 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -2080,14 +2080,15 @@ 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_talloc(talloc_tos(), res->ai_canonname,
+ strlen(res->ai_canonname) + 1);
}
+ freeaddrinfo(res);
+
return (const char *)tmp.data;
}
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) {
diff --git a/source3/lib/version.c b/source3/lib/version.c
index 204c2044a8..3cae02ad2e 100644
--- a/source3/lib/version.c
+++ b/source3/lib/version.c
@@ -51,6 +51,8 @@ const char *samba_version_string(void)
*/
assert(res != -1);
+ SAFE_FREE(samba_version);
+
samba_version = tmp_version;
#endif