summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-08 15:43:11 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-01-08 15:43:11 +0100
commitbfab6ab14bd2ba69fde8bbe32f56f308010c8ea7 (patch)
tree4edbacab40c67bb5d9d6bebe66a22949349cbf9a /source3/lib
parent8dbeca6e9d06d573adebe8d9c5114b24d8782e43 (diff)
parent62c91987d902d4dfe27023ff2ec2fb73e602105b (diff)
downloadsamba-bfab6ab14bd2ba69fde8bbe32f56f308010c8ea7.tar.gz
samba-bfab6ab14bd2ba69fde8bbe32f56f308010c8ea7.tar.bz2
samba-bfab6ab14bd2ba69fde8bbe32f56f308010c8ea7.zip
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit ea36c3add588061cf338deabb2d8952f2213a8bd)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap_tdb.c132
-rw-r--r--source3/lib/debug.c2
-rw-r--r--source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c19
-rw-r--r--source3/lib/netapi/examples/netdomjoin/netdomjoin.c7
-rw-r--r--source3/lib/netapi/joindomain.c18
-rw-r--r--source3/lib/netapi/netapi.c104
-rw-r--r--source3/lib/netapi/netapi.h25
-rw-r--r--source3/lib/substitute.c5
-rw-r--r--source3/lib/sysacls.c54
-rw-r--r--source3/lib/talloc_stack.c18
-rw-r--r--source3/lib/util.c1
11 files changed, 269 insertions, 116 deletions
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index b24fd0618a..83a0d111aa 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -43,33 +43,50 @@ static int db_tdb_record_destr(struct db_record* data)
return 0;
}
-static struct db_record *db_tdb_fetch_locked(struct db_context *db,
- TALLOC_CTX *mem_ctx, TDB_DATA key)
-{
- struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data,
- struct db_tdb_ctx);
+struct tdb_fetch_locked_state {
+ TALLOC_CTX *mem_ctx;
struct db_record *result;
- TDB_DATA value;
+};
- result = TALLOC_P(mem_ctx, struct db_record);
- if (result == NULL) {
- DEBUG(0, ("talloc failed\n"));
- return NULL;
+static int db_tdb_fetchlock_parse(TDB_DATA key, TDB_DATA data,
+ void *private_data)
+{
+ struct tdb_fetch_locked_state *state =
+ (struct tdb_fetch_locked_state *)private_data;
+
+ state->result = (struct db_record *)talloc_size(
+ state->mem_ctx,
+ sizeof(struct db_record) + key.dsize + data.dsize);
+
+ if (state->result == NULL) {
+ return 0;
}
- result->key.dsize = key.dsize;
- result->key.dptr = (uint8 *)talloc_memdup(result, key.dptr, key.dsize);
- if (result->key.dptr == NULL) {
- DEBUG(0, ("talloc failed\n"));
- TALLOC_FREE(result);
- return NULL;
+ state->result->key.dsize = key.dsize;
+ state->result->key.dptr = ((uint8 *)state->result)
+ + sizeof(struct db_record);
+ memcpy(state->result->key.dptr, key.dptr, key.dsize);
+
+ state->result->value.dsize = data.dsize;
+
+ if (data.dsize > 0) {
+ state->result->value.dptr = state->result->key.dptr+key.dsize;
+ memcpy(state->result->value.dptr, data.dptr, data.dsize);
}
+ else {
+ state->result->value.dptr = NULL;
+ }
+
+ return 0;
+}
- result->value.dptr = NULL;
- result->value.dsize = 0;
- result->private_data = talloc_reference(result, ctx);
- result->store = db_tdb_store;
- result->delete_rec = db_tdb_delete;
+static struct db_record *db_tdb_fetch_locked(struct db_context *db,
+ TALLOC_CTX *mem_ctx, TDB_DATA key)
+{
+ struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data,
+ struct db_tdb_ctx);
+ struct tdb_fetch_locked_state state;
+ int res;
if (DEBUGLEVEL >= 10) {
char *keystr = hex_encode(NULL, key.dptr, key.dsize);
@@ -81,32 +98,56 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db,
if (tdb_chainlock(ctx->wtdb->tdb, key) != 0) {
DEBUG(3, ("tdb_chainlock failed\n"));
- TALLOC_FREE(result);
return NULL;
}
- talloc_set_destructor(result, db_tdb_record_destr);
+ state.mem_ctx = mem_ctx;
+ state.result = NULL;
- value = tdb_fetch(ctx->wtdb->tdb, key);
+ res = tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse,
+ &state);
- if (value.dptr == NULL) {
- return result;
+ if (state.result == NULL) {
+ db_tdb_fetchlock_parse(key, tdb_null, &state);
}
- result->value.dsize = value.dsize;
- result->value.dptr = (uint8 *)talloc_memdup(result, value.dptr,
- value.dsize);
- if (result->value.dptr == NULL) {
- DEBUG(3, ("talloc failed\n"));
- TALLOC_FREE(result);
+ if (state.result == NULL) {
+ tdb_chainunlock(ctx->wtdb->tdb, key);
return NULL;
}
- SAFE_FREE(value.dptr);
+ talloc_set_destructor(state.result, db_tdb_record_destr);
- DEBUG(10, ("Allocated locked data 0x%p\n", result));
+ state.result->private_data = talloc_reference(state.result, ctx);
+ state.result->store = db_tdb_store;
+ state.result->delete_rec = db_tdb_delete;
- return result;
+ DEBUG(10, ("Allocated locked data 0x%p\n", state.result));
+
+ return state.result;
+}
+
+struct tdb_fetch_state {
+ TALLOC_CTX *mem_ctx;
+ int result;
+ TDB_DATA data;
+};
+
+static int db_tdb_fetch_parse(TDB_DATA key, TDB_DATA data,
+ void *private_data)
+{
+ struct tdb_fetch_state *state =
+ (struct tdb_fetch_state *)private_data;
+
+ state->data.dptr = (uint8 *)talloc_memdup(state->mem_ctx, data.dptr,
+ data.dsize);
+ if (state->data.dptr == NULL) {
+ state->result = -1;
+ return 0;
+ }
+
+ state->data.dsize = data.dsize;
+ return 0;
}
static int db_tdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
@@ -115,23 +156,20 @@ static int db_tdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
struct db_tdb_ctx *ctx = talloc_get_type_abort(
db->private_data, struct db_tdb_ctx);
- TDB_DATA data;
-
- data = tdb_fetch(ctx->wtdb->tdb, key);
+ struct tdb_fetch_state state;
- if (data.dptr == NULL) {
- pdata->dptr = NULL;
- pdata->dsize = 0;
- return 0;
- }
+ state.mem_ctx = mem_ctx;
+ state.result = 0;
+ state.data.dptr = NULL;
+ state.data.dsize = 0;
- pdata->dptr = (uint8 *)talloc_memdup(mem_ctx, data.dptr, data.dsize);
- SAFE_FREE(data.dptr);
+ tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetch_parse, &state);
- if (pdata->dptr == NULL) {
+ if (state.result == -1) {
return -1;
}
- pdata->dsize = data.dsize;
+
+ *pdata = state.data;
return 0;
}
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 9ea2dc151a..6c1bfea04f 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -199,6 +199,8 @@ void gfree_debugsyms(void)
if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack )
SAFE_FREE( DEBUGLEVEL_CLASS_ISSET );
+
+ SAFE_FREE(format_bufr);
}
/****************************************************************************
diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
index d12e66bb26..4a3588e9ab 100644
--- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
+++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
@@ -249,6 +249,8 @@ static void callback_do_reboot(GtkWidget *widget,
SAFE_FREE(buffer);
state->name_type_new = type;
#endif
+ NetApiBufferFree((void *)buffer);
+
gtk_label_set_text(GTK_LABEL(state->label_current_name_buffer),
state->name_buffer_new);
if (state->name_type_new == NetSetupDomainName) {
@@ -449,14 +451,8 @@ static void callback_do_join(GtkWidget *widget,
initial_workgroup_type,
state->name_buffer_initial,
err_str);
-
- g_signal_connect_swapped(dialog, "response",
- G_CALLBACK(gtk_widget_destroy),
- dialog);
-
- gtk_widget_show(dialog);
-
- return;
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
}
@@ -1298,8 +1294,12 @@ static int initialize_join_state(struct join_state *state,
if (status) {
return status;
}
- state->name_buffer_initial = (char *)buffer;
+ state->name_buffer_initial = strdup(buffer);
+ if (!state->name_buffer_initial) {
+ return -1;
+ }
state->name_type_initial = type;
+ NetApiBufferFree((void *)buffer);
}
{
@@ -1317,6 +1317,7 @@ static int initialize_join_state(struct join_state *state,
if (!state->comment) {
return -1;
}
+ NetApiBufferFree(buffer);
}
#if 0
{
diff --git a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c
index 634d265597..a0ac0b1e56 100644
--- a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c
+++ b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c
@@ -104,7 +104,12 @@ int main(int argc, char **argv)
password,
join_flags);
if (status != 0) {
- printf("Join failed with: %s\n", libnetapi_errstr(ctx, status));
+ const char *errstr = NULL;
+ errstr = libnetapi_get_error_string(ctx);
+ if (!errstr) {
+ errstr = libnetapi_errstr(ctx, status);
+ }
+ printf("Join failed with: %s\n", errstr);
} else {
printf("Successfully joined\n");
}
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c
index c7849c952f..e4fb63eebb 100644
--- a/source3/lib/netapi/joindomain.c
+++ b/source3/lib/netapi/joindomain.c
@@ -33,13 +33,13 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
struct libnet_JoinCtx *r = NULL;
WERROR werr;
- werr = libnet_init_JoinCtx(mem_ctx, &r);
- W_ERROR_NOT_OK_RETURN(werr);
-
if (!domain_name) {
return WERR_INVALID_PARAM;
}
+ werr = libnet_init_JoinCtx(mem_ctx, &r);
+ W_ERROR_NOT_OK_RETURN(werr);
+
r->in.domain_name = talloc_strdup(mem_ctx, domain_name);
W_ERROR_HAVE_NO_MEMORY(r->in.domain_name);
@@ -77,7 +77,13 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
r->in.join_flags = join_flags;
r->in.modify_config = true;
- return libnet_Join(mem_ctx, r);
+ werr = libnet_Join(mem_ctx, r);
+ if (!W_ERROR_IS_OK(werr) && r->out.error_string) {
+ libnetapi_set_error_string(mem_ctx, r->out.error_string);
+ }
+ TALLOC_FREE(r);
+
+ return werr;
}
static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx,
@@ -431,9 +437,9 @@ static WERROR NetGetJoinInformationLocal(struct libnetapi_ctx *ctx,
uint16_t *name_type)
{
if ((lp_security() == SEC_ADS) && lp_realm()) {
- *name_buffer = SMB_STRDUP(lp_realm());
+ *name_buffer = talloc_strdup(ctx, lp_realm());
} else {
- *name_buffer = SMB_STRDUP(lp_workgroup());
+ *name_buffer = talloc_strdup(ctx, lp_workgroup());
}
if (!*name_buffer) {
return WERR_NOMEM;
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index 032798d0f9..d4cb3a9fe2 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -1,7 +1,7 @@
/*
* Unix SMB/CIFS implementation.
* NetApi Support
- * Copyright (C) Guenther Deschner 2007
+ * Copyright (C) Guenther Deschner 2007-2008
*
* 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
@@ -26,15 +26,22 @@ struct libnetapi_ctx *stat_ctx = NULL;
TALLOC_CTX *frame = NULL;
static bool libnetapi_initialized = false;
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
{
struct libnetapi_ctx *ctx = NULL;
+ char *krb5_cc_env = NULL;
if (stat_ctx && libnetapi_initialized) {
*context = stat_ctx;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+#ifdef DEVELOPER
+ talloc_enable_leak_report();
+#endif
frame = talloc_stackframe();
ctx = talloc_zero(frame, struct libnetapi_ctx);
@@ -65,57 +72,90 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
BlockSignals(True, SIGPIPE);
+ krb5_cc_env = getenv(KRB5_ENV_CCNAME);
+ if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
+ ctx->krb5_cc_env = talloc_strdup(frame, "MEMORY:libnetapi");
+ setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
+ }
+
libnetapi_initialized = true;
*context = stat_ctx = ctx;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
{
if (stat_ctx) {
*ctx = stat_ctx;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
return libnetapi_init(ctx);
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
{
+
+ if (ctx->krb5_cc_env) {
+ char *env = getenv(KRB5_ENV_CCNAME);
+ if (env && (strequal(ctx->krb5_cc_env, env))) {
+ unsetenv(KRB5_ENV_CCNAME);
+ }
+ }
+
gfree_names();
gfree_loadparm();
gfree_case_tables();
gfree_charcnv();
gfree_interfaces();
+ gencache_shutdown();
+ secrets_shutdown();
+ regdb_close();
+
TALLOC_FREE(ctx);
TALLOC_FREE(frame);
gfree_debugsyms();
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
const char *debuglevel)
{
AllowDebugChange = true;
- ctx->debuglevel = debuglevel;
+ ctx->debuglevel = talloc_strdup(ctx, debuglevel);
if (!debug_parse_levels(debuglevel)) {
return W_ERROR_V(WERR_GENERAL_FAILURE);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
- const char **debuglevel)
+ char **debuglevel)
{
*debuglevel = ctx->debuglevel;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
const char *username)
{
@@ -124,7 +164,7 @@ NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
if (!ctx->username) {
return W_ERROR_V(WERR_NOMEM);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
@@ -135,7 +175,7 @@ NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
if (!ctx->password) {
return W_ERROR_V(WERR_NOMEM);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
@@ -146,9 +186,12 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
if (!ctx->workgroup) {
return W_ERROR_V(WERR_NOMEM);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
NET_API_STATUS status)
{
@@ -158,3 +201,40 @@ const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
return get_friendly_werror_msg(W_ERROR(status));
}
+
+/****************************************************************
+****************************************************************/
+
+NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
+ const char *error_string)
+{
+ TALLOC_FREE(ctx->error_string);
+ ctx->error_string = talloc_strdup(ctx, error_string);
+ if (!ctx->error_string) {
+ return W_ERROR_V(WERR_NOMEM);
+ }
+ return NET_API_STATUS_SUCCESS;
+
+}
+
+/****************************************************************
+****************************************************************/
+
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx)
+{
+ return ctx->error_string;
+}
+
+/****************************************************************
+****************************************************************/
+
+NET_API_STATUS NetApiBufferFree(void *buffer)
+{
+ if (!buffer) {
+ return W_ERROR_V(WERR_INSUFFICIENT_BUFFER);
+ }
+
+ talloc_free(buffer);
+
+ return NET_API_STATUS_SUCCESS;
+}
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 0dd6d95ceb..4a40b32fc9 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -1,7 +1,7 @@
/*
* Unix SMB/CIFS implementation.
* NetApi Support
- * Copyright (C) Guenther Deschner 2007
+ * Copyright (C) Guenther Deschner 2007-2008
*
* 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
@@ -21,23 +21,42 @@
#define __LIB_NETAPI_H__
#define NET_API_STATUS uint32_t
+#define NET_API_STATUS_SUCCESS 0
+
+/****************************************************************
+****************************************************************/
struct libnetapi_ctx {
- const char *debuglevel;
+ char *debuglevel;
+ char *error_string;
char *username;
char *workgroup;
char *password;
+ char *krb5_cc_env;
};
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel);
-NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, const char **debuglevel);
+NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, char **debuglevel);
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username);
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password);
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup);
const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string);
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx);
+
+/****************************************************************
+****************************************************************/
+
+NET_API_STATUS NetApiBufferFree(void *buffer);
+
+/****************************************************************
+****************************************************************/
/* wkssvc */
NET_API_STATUS NetJoinDomain(const char *server,
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 80feee9579..59b54c4dff 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -34,6 +34,11 @@ fstring remote_proto="UNKNOWN";
static char *local_machine;
+void free_local_machine_name(void)
+{
+ SAFE_FREE(local_machine);
+}
+
bool set_local_machine_name(const char *local_name, bool perm)
{
static bool already_perm = false;
diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c
index 3e61f42aa5..9c1256ed65 100644
--- a/source3/lib/sysacls.c
+++ b/source3/lib/sysacls.c
@@ -3,7 +3,7 @@
Samba system utilities for ACL support.
Copyright (C) Jeremy Allison 2000.
Copyright (C) Volker Lendecke 2006
- Copyright (C) Michael Adam 2006
+ Copyright (C) Michael Adam 2006,2008
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
@@ -364,9 +364,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return posixacl_sys_acl_get_file(handle, path_p, type);
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return posixacl_sys_acl_get_fd(handle, fsp, fd);
+ return posixacl_sys_acl_get_fd(handle, fsp);
}
int sys_acl_set_file(vfs_handle_struct *handle,
@@ -376,9 +376,9 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
- return posixacl_sys_acl_set_fd(handle, fsp, fd, acl_d);
+ return posixacl_sys_acl_set_fd(handle, fsp, acl_d);
}
int sys_acl_delete_def_file(vfs_handle_struct *handle,
@@ -395,9 +395,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return aixacl_sys_acl_get_file(handle, path_p, type);
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return aixacl_sys_acl_get_fd(handle, fsp, fd);
+ return aixacl_sys_acl_get_fd(handle, fsp);
}
int sys_acl_set_file(vfs_handle_struct *handle,
@@ -407,9 +407,9 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
- return aixacl_sys_acl_set_fd(handle, fsp, fd, acl_d);
+ return aixacl_sys_acl_set_fd(handle, fsp, acl_d);
}
int sys_acl_delete_def_file(vfs_handle_struct *handle,
@@ -426,9 +426,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return tru64acl_sys_acl_get_file(handle, path_p, type);
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return tru64acl_sys_acl_get_fd(handle, fsp, fd);
+ return tru64acl_sys_acl_get_fd(handle, fsp);
}
int sys_acl_set_file(vfs_handle_struct *handle,
@@ -438,9 +438,9 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
- return tru64acl_sys_acl_set_fd(handle, fsp, fd, acl_d);
+ return tru64acl_sys_acl_set_fd(handle, fsp, acl_d);
}
int sys_acl_delete_def_file(vfs_handle_struct *handle,
@@ -457,9 +457,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return solarisacl_sys_acl_get_file(handle, path_p, type);
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return solarisacl_sys_acl_get_fd(handle, fsp, fd);
+ return solarisacl_sys_acl_get_fd(handle, fsp);
}
int sys_acl_set_file(vfs_handle_struct *handle,
@@ -469,9 +469,9 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
- return solarisacl_sys_acl_set_fd(handle, fsp, fd, acl_d);
+ return solarisacl_sys_acl_set_fd(handle, fsp, acl_d);
}
int sys_acl_delete_def_file(vfs_handle_struct *handle,
@@ -488,9 +488,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return hpuxacl_sys_acl_get_file(handle, path_p, type);
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return hpuxacl_sys_acl_get_fd(handle, fsp, fd);
+ return hpuxacl_sys_acl_get_fd(handle, fsp);
}
int sys_acl_set_file(vfs_handle_struct *handle,
@@ -500,9 +500,9 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
- return hpuxacl_sys_acl_set_fd(handle, fsp, fd, acl_d);
+ return hpuxacl_sys_acl_set_fd(handle, fsp, acl_d);
}
int sys_acl_delete_def_file(vfs_handle_struct *handle,
@@ -519,9 +519,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return irixacl_sys_acl_get_file(handle, path_p, type);
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return irixacl_sys_acl_get_fd(handle, fsp, fd);
+ return irixacl_sys_acl_get_fd(handle, fsp);
}
int sys_acl_set_file(vfs_handle_struct *handle,
@@ -531,9 +531,9 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
- return irixacl_sys_acl_set_fd(handle, fsp, fd, acl_d);
+ return irixacl_sys_acl_set_fd(handle, fsp, acl_d);
}
int sys_acl_delete_def_file(vfs_handle_struct *handle,
@@ -555,7 +555,7 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
return NULL;
}
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
#ifdef ENOTSUP
errno = ENOTSUP;
@@ -577,7 +577,7 @@ int sys_acl_set_file(vfs_handle_struct *handle,
}
int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- int fd, SMB_ACL_T acl_d)
+ SMB_ACL_T acl_d)
{
#ifdef ENOTSUP
errno = ENOTSUP;
diff --git a/source3/lib/talloc_stack.c b/source3/lib/talloc_stack.c
index e6e4ed321a..cc7ce3a518 100644
--- a/source3/lib/talloc_stack.c
+++ b/source3/lib/talloc_stack.c
@@ -41,16 +41,18 @@
static int talloc_stacksize;
static TALLOC_CTX **talloc_stack;
-static int talloc_pop(int *ptr)
+static int talloc_pop(TALLOC_CTX *frame)
{
- int tos = *ptr;
int i;
- for (i=talloc_stacksize-1; i>=tos; i--) {
+ for (i=talloc_stacksize-1; i>0; i--) {
+ if (frame == talloc_stack[i]) {
+ break;
+ }
talloc_free(talloc_stack[i]);
}
- talloc_stacksize = tos;
+ talloc_stacksize = i;
return 0;
}
@@ -64,7 +66,6 @@ static int talloc_pop(int *ptr)
TALLOC_CTX *talloc_stackframe(void)
{
TALLOC_CTX **tmp, *top;
- int *cleanup;
if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *,
talloc_stacksize + 1))) {
@@ -77,12 +78,7 @@ TALLOC_CTX *talloc_stackframe(void)
goto fail;
}
- if (!(cleanup = talloc(top, int))) {
- goto fail;
- }
-
- *cleanup = talloc_stacksize;
- talloc_set_destructor(cleanup, talloc_pop);
+ talloc_set_destructor(top, talloc_pop);
talloc_stack[talloc_stacksize++] = top;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index c69a1450a0..25b2700ae3 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -183,6 +183,7 @@ void gfree_names(void)
SAFE_FREE( smb_myworkgroup );
SAFE_FREE( smb_scope );
free_netbios_names_array();
+ free_local_machine_name();
}
void gfree_all( void )