diff options
Diffstat (limited to 'source4')
298 files changed, 3802 insertions, 3725 deletions
diff --git a/source4/Makefile b/source4/Makefile index 7d4540ae6a..267e302c9f 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -98,6 +98,7 @@ ntvfssrcdir := ntvfs ntptrsrcdir := ntptr librpcsrcdir := librpc libclisrcdir := libcli +libclicommonsrcdir := ../libcli libclinbtsrcdir := ../libcli/nbt pyscriptsrcdir := $(srcdir)/scripting/python kdcsrcdir := kdc @@ -145,12 +146,11 @@ endif clean:: @find ../lib ../libcli ../librpc ../nsswitch -name '*.o' -o -name '*.ho' | xargs rm -f -DEFAULT_HEADERS = $(srcdir)/../lib/util/dlinklist.h \ - $(srcdir)/version.h +PUBLIC_HEADES += $(srcdir)/version.h libraries:: $(STATIC_LIBS) $(SHARED_LIBS) modules:: $(PLUGINS) -headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS) +headers:: $(PUBLIC_HEADERS) manpages:: $(MANPAGES) all:: showflags $(ALL_PREDEP) binaries modules pythonmods libraries headers everything:: all @@ -233,7 +233,7 @@ installlib:: $(SHARED_LIBS) $(STATIC_LIBS) installdirs #@$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(STLIBEXT)" $(STATIC_LIBS) installheader:: headers installdirs - @srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(includedir) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS) + @srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(includedir) $(PUBLIC_HEADERS) installdat:: installdirs @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(datadir) $(srcdir) diff --git a/source4/auth/config.mk b/source4/auth/config.mk index b238caa2e5..baf4346b4a 100644 --- a/source4/auth/config.mk +++ b/source4/auth/config.mk @@ -36,11 +36,10 @@ auth_sam_reply_OBJ_FILES = $(addprefix $(authsrcdir)/, auth_sam_reply.o) $(eval $(call proto_header_template,$(authsrcdir)/auth_sam_reply.h,$(auth_sam_reply_OBJ_FILES:.o=.c))) -[PYTHON::swig_auth] +[PYTHON::pyauth] LIBRARY_REALNAME = samba/auth.$(SHLIBEXT) PUBLIC_DEPENDENCIES = auth_system_session PRIVATE_DEPENDENCIES = SAMDB PYTALLOC param -swig_auth_OBJ_FILES = $(authsrcdir)/pyauth.o +pyauth_OBJ_FILES = $(authsrcdir)/pyauth.o -$(swig_auth_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) diff --git a/source4/auth/credentials/config.mk b/source4/auth/credentials/config.mk index e4d14dde58..2402c732b3 100644 --- a/source4/auth/credentials/config.mk +++ b/source4/auth/credentials/config.mk @@ -13,10 +13,8 @@ $(eval $(call proto_header_template,$(authsrcdir)/credentials/credentials_proto. PUBLIC_HEADERS += $(authsrcdir)/credentials/credentials.h -[PYTHON::swig_credentials] +[PYTHON::pycredentials] LIBRARY_REALNAME = samba/credentials.$(SHLIBEXT) PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS PYTALLOC param -swig_credentials_OBJ_FILES = $(authsrcdir)/credentials/pycredentials.o - -$(swig_credentials_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) +pycredentials_OBJ_FILES = $(authsrcdir)/credentials/pycredentials.o diff --git a/source4/auth/gensec/config.mk b/source4/auth/gensec/config.mk index 3c2fa51f78..3d13ce7f6d 100644 --- a/source4/auth/gensec/config.mk +++ b/source4/auth/gensec/config.mk @@ -78,7 +78,7 @@ $(eval $(call proto_header_template,$(gensecsrcdir)/schannel_proto.h,$(gensec_sc ################################################ # Start SUBSYSTEM SCHANNELDB [SUBSYSTEM::SCHANNELDB] -PRIVATE_DEPENDENCIES = LDB_WRAP SAMDB +PRIVATE_DEPENDENCIES = LDB_WRAP # End SUBSYSTEM SCHANNELDB ################################################ diff --git a/source4/auth/gensec/schannel_state.c b/source4/auth/gensec/schannel_state.c index d86b1f2b9c..ca8537cac9 100644 --- a/source4/auth/gensec/schannel_state.c +++ b/source4/auth/gensec/schannel_state.c @@ -20,10 +20,8 @@ */ #include "includes.h" -#include "lib/events/events.h" #include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "dsdb/samdb/samdb.h" +#include "librpc/gen_ndr/ndr_security.h" #include "ldb_wrap.h" #include "../lib/util/util_ldb.h" #include "libcli/auth/libcli_auth.h" @@ -31,6 +29,45 @@ #include "param/param.h" #include "auth/gensec/schannel_state.h" +static struct ldb_val *schannel_dom_sid_ldb_val(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *smbiconv, + struct dom_sid *sid) +{ + enum ndr_err_code ndr_err; + struct ldb_val *v; + + v = talloc(mem_ctx, struct ldb_val); + if (!v) return NULL; + + ndr_err = ndr_push_struct_blob(v, mem_ctx, smbiconv, sid, + (ndr_push_flags_fn_t)ndr_push_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(v); + return NULL; + } + + return v; +} + +static struct dom_sid *schannel_ldb_val_dom_sid(TALLOC_CTX *mem_ctx, + const struct ldb_val *v) +{ + enum ndr_err_code ndr_err; + struct dom_sid *sid; + + sid = talloc(mem_ctx, struct dom_sid); + if (!sid) return NULL; + + ndr_err = ndr_pull_struct_blob(v, sid, NULL, sid, + (ndr_pull_flags_fn_t)ndr_pull_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(sid); + return NULL; + } + return sid; +} + + /** connect to the schannel ldb */ @@ -77,6 +114,8 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx, { struct ldb_message *msg; struct ldb_val val, seed, client_state, server_state; + struct smb_iconv_convenience *smbiconv; + struct ldb_val *sid_val; char *f; char *sct; int ret; @@ -103,6 +142,12 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } + smbiconv = lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")); + sid_val = schannel_dom_sid_ldb_val(msg, smbiconv, creds->sid); + if (sid_val == NULL) { + return NT_STATUS_NO_MEMORY; + } + val.data = creds->session_key; val.length = sizeof(creds->session_key); @@ -124,7 +169,7 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx, ldb_msg_add_string(msg, "accountName", creds->account_name); ldb_msg_add_string(msg, "computerName", creds->computer_name); ldb_msg_add_string(msg, "flatname", creds->domain); - samdb_msg_add_dom_sid(ldb, mem_ctx, msg, "objectSid", creds->sid); + ldb_msg_add_value(msg, "objectSid", sid_val, NULL); ldb_delete(ldb, msg->dn); @@ -265,7 +310,17 @@ NTSTATUS schannel_fetch_session_key_ldb(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - (*creds)->sid = samdb_result_dom_sid(*creds, res->msgs[0], "objectSid"); + val = ldb_msg_find_ldb_val(res->msgs[0], "objectSid"); + if (val == NULL) { + DEBUG(1,("schannel: missing ObjectSid for client: %s\n", computer_name)); + talloc_free(res); + return NT_STATUS_INTERNAL_ERROR; + } + (*creds)->sid = schannel_ldb_val_dom_sid(*creds, val); + if ((*creds)->sid == NULL) { + talloc_free(res); + return NT_STATUS_INTERNAL_ERROR; + } talloc_free(res); return NT_STATUS_OK; diff --git a/source4/auth/gensec/socket.c b/source4/auth/gensec/socket.c index a338797ecf..6a03f0bcec 100644 --- a/source4/auth/gensec/socket.c +++ b/source4/auth/gensec/socket.c @@ -158,9 +158,9 @@ NTSTATUS gensec_packet_full_request(struct gensec_security *gensec_security, return packet_full_request_u32(NULL, blob, size); } -static NTSTATUS gensec_socket_full_request(void *private, DATA_BLOB blob, size_t *size) +static NTSTATUS gensec_socket_full_request(void *private_data, DATA_BLOB blob, size_t *size) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); struct gensec_security *gensec_security = gensec_socket->gensec_security; return gensec_packet_full_request(gensec_security, blob, size); } @@ -187,9 +187,9 @@ static NTSTATUS gensec_socket_pending(struct socket_context *sock, size_t *npend } /* Note if an error occours, so we can return it up the stack */ -static void gensec_socket_error_handler(void *private, NTSTATUS status) +static void gensec_socket_error_handler(void *private_data, NTSTATUS status) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { gensec_socket->eof = true; } else { @@ -199,9 +199,9 @@ static void gensec_socket_error_handler(void *private, NTSTATUS status) static void gensec_socket_trigger_read(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); gensec_socket->in_extra_read++; gensec_socket->recv_handler(gensec_socket->recv_private, EVENT_FD_READ); @@ -287,9 +287,9 @@ static NTSTATUS gensec_socket_recv(struct socket_context *sock, void *buf, * * This function (and anything under it) MUST NOT call the event system */ -static NTSTATUS gensec_socket_unwrap(void *private, DATA_BLOB blob) +static NTSTATUS gensec_socket_unwrap(void *private_data, DATA_BLOB blob) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); DATA_BLOB unwrapped; NTSTATUS nt_status; TALLOC_CTX *mem_ctx; @@ -329,9 +329,9 @@ static NTSTATUS gensec_socket_unwrap(void *private, DATA_BLOB blob) } /* when the data is sent, we know we have not been interrupted */ -static void send_callback(void *private) +static void send_callback(void *private_data) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); gensec_socket->interrupted = false; } diff --git a/source4/auth/kerberos/krb5_init_context.c b/source4/auth/kerberos/krb5_init_context.c index 6e885842f3..04f0718a62 100644 --- a/source4/auth/kerberos/krb5_init_context.c +++ b/source4/auth/kerberos/krb5_init_context.c @@ -65,11 +65,11 @@ static krb5_error_code smb_krb5_context_destroy_2(struct smb_krb5_context *ctx) } /* We never close down the DEBUG system, and no need to unreference the use */ -static void smb_krb5_debug_close(void *private) { +static void smb_krb5_debug_close(void *private_data) { return; } -static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *private) +static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *private_data) { DEBUG(2, ("Kerberos: %s\n", msg)); } @@ -117,9 +117,9 @@ static void smb_krb5_socket_recv(struct smb_krb5_socket *smb_krb5) talloc_free(tmp_ctx); } -static NTSTATUS smb_krb5_full_packet(void *private, DATA_BLOB data) +static NTSTATUS smb_krb5_full_packet(void *private_data, DATA_BLOB data) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); talloc_steal(smb_krb5, data.data); smb_krb5->reply = data; smb_krb5->reply.length -= 4; @@ -132,16 +132,16 @@ static NTSTATUS smb_krb5_full_packet(void *private, DATA_BLOB data) */ static void smb_krb5_request_timeout(struct tevent_context *event_ctx, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); DEBUG(5,("Timed out smb_krb5 packet\n")); smb_krb5->status = NT_STATUS_IO_TIMEOUT; } -static void smb_krb5_error_handler(void *private, NTSTATUS status) +static void smb_krb5_error_handler(void *private_data, NTSTATUS status) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); smb_krb5->status = status; } @@ -170,9 +170,9 @@ static void smb_krb5_socket_send(struct smb_krb5_socket *smb_krb5) handle fd events on a smb_krb5_socket */ static void smb_krb5_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); switch (smb_krb5->hi->proto) { case KRB5_KRBHST_UDP: if (flags & TEVENT_FD_READ) { diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c index 37cc5f318f..30bf159df1 100644 --- a/source4/auth/ntlmssp/ntlmssp_server.c +++ b/source4/auth/ntlmssp/ntlmssp_server.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "system/network.h" #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" #include "../lib/crypto/crypto.h" diff --git a/source4/build/m4/check_cc.m4 b/source4/build/m4/check_cc.m4 index 1683cb028a..55802850b0 100644 --- a/source4/build/m4/check_cc.m4 +++ b/source4/build/m4/check_cc.m4 @@ -112,10 +112,6 @@ if test x$developer = xyes; then AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS) AX_CFLAGS_GCC_OPTION(-Wdeclaration-after-statement, DEVELOPER_CFLAGS) AX_CFLAGS_GCC_OPTION(-Wunused-macros, DEVELOPER_CFLAGS) - AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS) - AC_SUBST(CFLAG_NO_CAST_QUAL) - AC_SUBST(CFLAG_NO_UNUSED_MACROS) - AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL) # AX_CFLAGS_GCC_OPTION(-Wextra, DEVELOPER_CFLAGS) # AX_CFLAGS_GCC_OPTION(-Wc++-compat, DEVELOPER_CFLAGS) # AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes, DEVELOPER_CFLAGS) @@ -126,6 +122,13 @@ if test x$developer = xyes; then # AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS) AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter, DEVELOPER_CFLAGS) + # + # warnings we don't want just for some files e.g. swig bindings + # + AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL) + AC_SUBST(CFLAG_NO_CAST_QUAL) + AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS) + AC_SUBST(CFLAG_NO_UNUSED_MACROS) else AX_CFLAGS_IRIX_OPTION(-fullwarn, DEVELOPER_CFLAGS) fi diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4 index f7266e6e44..1751a89e5f 100644 --- a/source4/build/m4/check_path.m4 +++ b/source4/build/m4/check_path.m4 @@ -43,7 +43,7 @@ if test x$fhs = xyes; then winbindd_privileged_socket_dir="${localstatedir}/lib/samba/winbindd_privileged" else # Check to prevent installing directly under /usr without the FHS - AS_IF([test $prefix == /usr || test $prefix == /usr/local],[ + AS_IF([test $prefix = /usr || test $prefix = /usr/local],[ AC_MSG_ERROR([Don't install directly under "/usr" or "/usr/local" without using the FHS option (--enable-fhs). This could lead to file loss!]) ]) fi diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4 index ffd112f5f1..1823f1ba97 100644 --- a/source4/build/m4/public.m4 +++ b/source4/build/m4/public.m4 @@ -201,11 +201,9 @@ CEOF for ac_var in $ac_subst_vars do - eval ac_val=\$$ac_var - if test "$ac_var" != "ECHO_C" - then - echo "$ac_var => '$ac_val'," >> $1 - fi + eval ac_val=\$$ac_var + # quote ' (\x27) inside '...' and make sure \ isn't eaten by shells, so use perl: + QAC_VAL=$ac_val QAC_VAR=$ac_var perl -e '$myval="$ENV{QAC_VAL}"; $myval =~ s/\x27/\\\x27/g ; print $ENV{QAC_VAR}." => \x27$myval\x27,\n"' >> $1 done cat >>$1<<CEOF diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c index 3c12954c31..0df35be6fd 100644 --- a/source4/cldap_server/netlogon.c +++ b/source4/cldap_server/netlogon.c @@ -407,7 +407,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap, struct ldb_parse_tree *tree, struct socket_address *src) { - struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server); + struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private_data, struct cldapd_server); int i; const char *domain = NULL; const char *host = NULL; diff --git a/source4/cldap_server/rootdse.c b/source4/cldap_server/rootdse.c index 65786e6708..daa5060d07 100644 --- a/source4/cldap_server/rootdse.c +++ b/source4/cldap_server/rootdse.c @@ -155,7 +155,7 @@ void cldapd_rootdse_request(struct cldap_socket *cldap, struct ldap_SearchRequest *search, struct socket_address *src) { - struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server); + struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private_data, struct cldapd_server); NTSTATUS status; struct cldap_reply reply; struct ldap_Result result; diff --git a/source4/client/tests/test_cifsdd.sh b/source4/client/tests/test_cifsdd.sh index 08bfb25e80..2268b6a091 100755 --- a/source4/client/tests/test_cifsdd.sh +++ b/source4/client/tests/test_cifsdd.sh @@ -16,8 +16,8 @@ DOMAIN=$4 . `dirname $0`/../../../testprogs/blackbox/subunit.sh -samba4bindir=`dirname $0`/../../bin -DD=$samba4bindir/cifsdd +samba4bindir="$BUILDDIR/bin" +DD="$samba4bindir/cifsdd$EXEEXT" SHARE=tmp DEBUGLEVEL=1 diff --git a/source4/client/tests/test_smbclient.sh b/source4/client/tests/test_smbclient.sh index 7ff03ba6e2..7775422e33 100755 --- a/source4/client/tests/test_smbclient.sh +++ b/source4/client/tests/test_smbclient.sh @@ -18,8 +18,8 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../bin -smbclient=$samba4bindir/smbclient +samba4bindir="$BUILDDIR/bin" +smbclient="$samba4bindir/smbclient$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/cluster/cluster_private.h b/source4/cluster/cluster_private.h index 79394b46db..e57c983ed0 100644 --- a/source4/cluster/cluster_private.h +++ b/source4/cluster/cluster_private.h @@ -36,7 +36,7 @@ struct cluster_ops { cluster_message_fn_t handler); NTSTATUS (*message_send)(struct cluster_ops *ops, struct server_id server, DATA_BLOB *data); - void *private; /* backend state */ + void *private_data; /* backend state */ }; void cluster_set_ops(struct cluster_ops *new_ops); diff --git a/source4/cluster/local.c b/source4/cluster/local.c index f36a06c9b6..96d1d53d4a 100644 --- a/source4/cluster/local.c +++ b/source4/cluster/local.c @@ -103,7 +103,7 @@ static struct cluster_ops cluster_local_ops = { .backend_handle = local_backend_handle, .message_init = local_message_init, .message_send = local_message_send, - .private = NULL + .private_data = NULL }; void cluster_local_init(void) diff --git a/source4/configure.ac b/source4/configure.ac index ef3bfd73f6..32778790e5 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -66,7 +66,7 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTEVENT, tevent >= 0.9.2, SMB_INCLUDE_MK(../lib/tevent/python.mk) -SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.1, +SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.3, [ SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk) SMB_INCLUDE_MK(lib/ldb/tools/config.mk) diff --git a/source4/dsdb/repl/drepl_periodic.c b/source4/dsdb/repl/drepl_periodic.c index 4a6de8d700..b88d2cee1e 100644 --- a/source4/dsdb/repl/drepl_periodic.c +++ b/source4/dsdb/repl/drepl_periodic.c @@ -20,10 +20,10 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "smbd/service.h" -#include "lib/events/events.h" #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c index 98d1c1b06c..152bbec4d5 100644 --- a/source4/dsdb/repl/drepl_service.c +++ b/source4/dsdb/repl/drepl_service.c @@ -140,7 +140,7 @@ static void dreplsrv_task_init(struct task_server *task) } service->task = task; service->startup_time = timeval_current(); - task->private = service; + task->private_data = service; status = dreplsrv_init_creds(service); if (!W_ERROR_IS_OK(status)) { diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index 49e453ffa1..a04f5ebfa6 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -30,7 +30,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" /** @@ -40,11 +40,14 @@ static struct ldb_parse_tree *make_parse_list(struct ldb_module *module, TALLOC_CTX *mem_ctx, enum ldb_parse_op op, struct ldb_parse_tree *first_arm, struct ldb_parse_tree *second_arm) { + struct ldb_context *ldb; struct ldb_parse_tree *list; + ldb = ldb_module_get_ctx(module); + list = talloc(mem_ctx, struct ldb_parse_tree); if (list == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } list->operation = op; @@ -52,7 +55,7 @@ static struct ldb_parse_tree *make_parse_list(struct ldb_module *module, list->u.list.num_elements = 2; list->u.list.elements = talloc_array(list, struct ldb_parse_tree *, 2); if (!list->u.list.elements) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } list->u.list.elements[0] = talloc_steal(list, first_arm); @@ -67,8 +70,11 @@ static struct ldb_parse_tree *make_match_tree(struct ldb_module *module, TALLOC_CTX *mem_ctx, enum ldb_parse_op op, const char *attr, const DATA_BLOB *match) { + struct ldb_context *ldb; struct ldb_parse_tree *match_tree; + ldb = ldb_module_get_ctx(module); + match_tree = talloc(mem_ctx, struct ldb_parse_tree); /* Depending on what type of match was selected, fill in the right part of the union */ @@ -83,7 +89,7 @@ static struct ldb_parse_tree *make_match_tree(struct ldb_module *module, match_tree->u.substring.chunks = talloc_array(match_tree, struct ldb_val *, 2); if (match_tree->u.substring.chunks == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } match_tree->u.substring.chunks[0] = match; @@ -120,12 +126,16 @@ static int anr_replace_value(struct anr_context *ac, struct ldb_module *module = ac->module; struct ldb_parse_tree *match_tree; struct dsdb_attribute *cur; - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + const struct dsdb_schema *schema; + struct ldb_context *ldb; uint8_t *p; enum ldb_parse_op op; + ldb = ldb_module_get_ctx(module); + + schema = dsdb_get_schema(ldb); if (!schema) { - ldb_asprintf_errstring(module->ldb, "no schema with which to construct anr filter"); + ldb_asprintf_errstring(ldb, "no schema with which to construct anr filter"); return LDB_ERR_OPERATIONS_ERROR; } @@ -135,7 +145,7 @@ static int anr_replace_value(struct anr_context *ac, DATA_BLOB *match2 = talloc(mem_ctx, DATA_BLOB); *match2 = data_blob_const(match->data+1, match->length - 1); if (match2 == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } match = match2; @@ -151,7 +161,7 @@ static int anr_replace_value(struct anr_context *ac, /* Inject an 'or' with the current tree */ tree = make_parse_list(module, mem_ctx, LDB_OP_OR, tree, match_tree); if (tree == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } } else { @@ -170,7 +180,7 @@ static int anr_replace_value(struct anr_context *ac, DATA_BLOB *first_match = talloc(tree, DATA_BLOB); DATA_BLOB *second_match = talloc(tree, DATA_BLOB); if (!first_match || !second_match) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } *first_match = data_blob_const(match->data, p-match->data); @@ -183,7 +193,7 @@ static int anr_replace_value(struct anr_context *ac, first_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (first_split_filter == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -192,14 +202,14 @@ static int anr_replace_value(struct anr_context *ac, second_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (second_split_filter == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } split_filters = make_parse_list(module, mem_ctx, LDB_OP_OR, first_split_filter, second_split_filter); if (split_filters == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -305,14 +315,17 @@ static int anr_search_callback(struct ldb_request *req, struct ldb_reply *ares) /* search */ static int anr_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_parse_tree *anr_tree; struct ldb_request *down_req; struct anr_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + ac = talloc(req, struct anr_context); if (!ac) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -335,7 +348,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) } ret = ldb_build_search_req_ex(&down_req, - module->ldb, ac, + ldb, ac, req->op.search.base, req->op.search.scope, anr_tree, diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk index 1c50923eba..01f5188b6f 100644 --- a/source4/dsdb/samdb/ldb_modules/config.mk +++ b/source4/dsdb/samdb/ldb_modules/config.mk @@ -2,7 +2,7 @@ # Start MODULE ldb_objectguid [MODULE::ldb_objectguid] SUBSYSTEM = LIBLDB -PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR +PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS LIBNDR INIT_FUNCTION = LDB_MODULE(objectguid) # End MODULE ldb_objectguid ################################################ diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c index 058c51bdb8..f8526faf3b 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c @@ -59,42 +59,42 @@ static bool is_attr_in_list(const char * const * attrs, const char *attr) static char **copy_attrs(void *mem_ctx, const char * const * attrs) { - char **new; + char **nattrs; int i, num; for (num = 0; attrs[num]; num++); - new = talloc_array(mem_ctx, char *, num + 1); - if (!new) return NULL; + nattrs = talloc_array(mem_ctx, char *, num + 1); + if (!nattrs) return NULL; for(i = 0; i < num; i++) { - new[i] = talloc_strdup(new, attrs[i]); - if (!new[i]) { - talloc_free(new); + nattrs[i] = talloc_strdup(nattrs, attrs[i]); + if (!nattrs[i]) { + talloc_free(nattrs); return NULL; } } - new[i] = NULL; + nattrs[i] = NULL; - return new; + return nattrs; } static bool add_attrs(void *mem_ctx, char ***attrs, const char *attr) { - char **new; + char **nattrs; int num; for (num = 0; (*attrs)[num]; num++); - new = talloc_realloc(mem_ctx, *attrs, char *, num + 2); - if (!new) return false; + nattrs = talloc_realloc(mem_ctx, *attrs, char *, num + 2); + if (!nattrs) return false; - *attrs = new; + *attrs = nattrs; - new[num] = talloc_strdup(new, attr); - if (!new[num]) return false; + nattrs[num] = talloc_strdup(nattrs, attr); + if (!nattrs[num]) return false; - new[num + 1] = NULL; + nattrs[num + 1] = NULL; return true; } @@ -246,10 +246,10 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) struct dsdb_openldap_dereference_result_control *dereference_control = NULL; int ret, i, j; struct ldb_message *msg = ares->message; - struct extended_dn_out_private *private; + struct extended_dn_out_private *p; ac = talloc_get_type(req->context, struct extended_search_context); - private = talloc_get_type(ac->module->private_data, struct extended_dn_out_private); + p = talloc_get_type(ac->module->private_data, struct extended_dn_out_private); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -271,7 +271,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) break; } - if (private && private->normalise) { + if (p && p->normalise) { ret = fix_dn(ares->message->dn); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -289,7 +289,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) } } - if ((private && private->normalise) || ac->inject) { + if ((p && p->normalise) || ac->inject) { const struct ldb_val *val = ldb_msg_find_ldb_val(ares->message, "distinguishedName"); if (val) { ldb_msg_remove_attr(ares->message, "distinguishedName"); @@ -307,7 +307,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) } } - if (private && private->dereference) { + if (p && p->dereference) { control = ldb_reply_get_control(ares, DSDB_OPENLDAP_DEREFERENCE_CONTROL); if (control && control->data) { @@ -323,7 +323,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) continue; } - if (private->normalise) { + if (p->normalise) { /* If we are also in 'normalise' mode, then * fix the attribute names to be in the * correct case */ @@ -351,7 +351,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_INVALID_DN_SYNTAX); } - if (private->normalise) { + if (p->normalise) { ret = fix_dn(dn); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -408,7 +408,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request const char * const *const_attrs; int ret; - struct extended_dn_out_private *private = talloc_get_type(module->private_data, struct extended_dn_out_private); + struct extended_dn_out_private *p = talloc_get_type(module->private_data, struct extended_dn_out_private); /* check if there's an extended dn control */ control = ldb_request_get_control(req, LDB_CONTROL_EXTENDED_DN_OID); @@ -450,7 +450,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request * the extended DN, or we are 'store DN+GUID+SID' * (!dereference) mode. (This is the normal mode for LDB on * tdb). */ - if (control || (storage_format_control && private && !private->dereference)) { + if (control || (storage_format_control && p && !p->dereference)) { ac->inject = true; if (extended_ctrl) { ac->extended_type = extended_ctrl->type; @@ -522,10 +522,10 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request /* Add in dereference control, if we were asked to, we are * using the 'dereference' mode (such as with an OpenLDAP * backend) and have the control prepared */ - if (control && private && private->dereference && private->dereference_control) { + if (control && p && p->dereference && p->dereference_control) { ret = ldb_request_add_control(down_req, DSDB_OPENLDAP_DEREFERENCE_CONTROL, - false, private->dereference_control); + false, p->dereference_control); if (ret != LDB_SUCCESS) { return ret; } @@ -539,17 +539,17 @@ static int extended_dn_out_ldb_init(struct ldb_module *module) { int ret; - struct extended_dn_out_private *private = talloc(module, struct extended_dn_out_private); + struct extended_dn_out_private *p = talloc(module, struct extended_dn_out_private); - module->private_data = private; + module->private_data = p; - if (!private) { + if (!p) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - private->dereference = false; - private->normalise = false; + p->dereference = false; + p->normalise = false; ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID); if (ret != LDB_SUCCESS) { @@ -564,24 +564,24 @@ static int extended_dn_out_ldb_init(struct ldb_module *module) static int extended_dn_out_dereference_init(struct ldb_module *module) { int ret, i = 0; - struct extended_dn_out_private *private; + struct extended_dn_out_private *p; struct dsdb_openldap_dereference_control *dereference_control; struct dsdb_attribute *cur; struct dsdb_schema *schema; - module->private_data = private = talloc_zero(module, struct extended_dn_out_private); + module->private_data = p = talloc_zero(module, struct extended_dn_out_private); - if (!private) { + if (!p) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - private->dereference = true; + p->dereference = true; /* At the moment, servers that need dereference also need the * DN and attribute names to be normalised */ - private->normalise = true; + p->normalise = true; ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID); if (ret != LDB_SUCCESS) { @@ -602,10 +602,10 @@ static int extended_dn_out_dereference_init(struct ldb_module *module) return LDB_SUCCESS; } - private->dereference_control = dereference_control - = talloc_zero(private, struct dsdb_openldap_dereference_control); + p->dereference_control = dereference_control + = talloc_zero(p, struct dsdb_openldap_dereference_control); - if (!private->dereference_control) { + if (!p->dereference_control) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -621,7 +621,7 @@ static int extended_dn_out_dereference_init(struct ldb_module *module) continue; } dereference_control->dereference - = talloc_realloc(private, dereference_control->dereference, + = talloc_realloc(p, dereference_control->dereference, struct dsdb_openldap_dereference *, i + 2); if (!dereference_control) { ldb_oom(module->ldb); diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c index a8c45dee4c..8d648d6d82 100644 --- a/source4/dsdb/samdb/ldb_modules/instancetype.c +++ b/source4/dsdb/samdb/ldb_modules/instancetype.c @@ -35,7 +35,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_module.h" #include "librpc/gen_ndr/ndr_misc.h" #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" @@ -47,10 +47,11 @@ struct it_context { static int it_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct it_context *ac; ac = talloc_get_type(req->context, struct it_context); - + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -62,7 +63,7 @@ static int it_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -74,6 +75,7 @@ static int it_callback(struct ldb_request *req, struct ldb_reply *ares) /* add_record: add instancetype attribute */ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct ldb_message *msg; struct it_context *ac; @@ -81,9 +83,10 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) int ret; const struct ldb_control *partition_ctrl; const struct dsdb_control_current_partition *partition; - - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -92,7 +95,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID); if (!partition_ctrl) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "instancetype_add: no current partition control found"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -111,7 +114,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -121,18 +124,18 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) instance_type = INSTANCE_TYPE_WRITE; if (ldb_dn_compare(partition->dn, msg->dn) == 0) { instance_type |= INSTANCE_TYPE_IS_NC_HEAD; - if (ldb_dn_compare(msg->dn, samdb_base_dn(module->ldb)) != 0) { + if (ldb_dn_compare(msg->dn, samdb_base_dn(ldb)) != 0) { instance_type |= INSTANCE_TYPE_NC_ABOVE; } } ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, req->controls, ac, it_callback, diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index bb95c7ee5a..0b5994bb88 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -31,9 +31,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "auth/auth.h" #include "libcli/security/security.h" #include "dsdb/samdb/samdb.h" @@ -52,15 +50,17 @@ struct kludge_private_data { static enum security_user_level what_is_user(struct ldb_module *module) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct auth_session_info *session_info - = (struct auth_session_info *)ldb_get_opaque(module->ldb, "sessionInfo"); + = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo"); return security_session_user_level(session_info); } static const char *user_name(TALLOC_CTX *mem_ctx, struct ldb_module *module) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct auth_session_info *session_info - = (struct auth_session_info *)ldb_get_opaque(module->ldb, "sessionInfo"); + = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo"); if (!session_info) { return "UNKNOWN (NULL)"; } @@ -152,7 +152,7 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * struct ldb_message_element *oc_el; struct ldb_message_element *allowedClasses; const struct dsdb_schema *schema = dsdb_get_schema(ldb); - const struct dsdb_class *class; + const struct dsdb_class *sclass; int i, j, ret; /* If we don't have a schema yet, we can't do anything... */ @@ -172,14 +172,14 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * oc_el = ldb_msg_find_element(msg, "objectClass"); for (i=0; oc_el && i < oc_el->num_values; i++) { - class = dsdb_class_by_lDAPDisplayName(schema, (const char *)oc_el->values[i].data); - if (!class) { + sclass = dsdb_class_by_lDAPDisplayName(schema, (const char *)oc_el->values[i].data); + if (!sclass) { /* We don't know this class? what is going on? */ continue; } - for (j=0; class->possibleInferiors && class->possibleInferiors[j]; j++) { - ldb_msg_add_string(msg, attrName, class->possibleInferiors[j]); + for (j=0; sclass->possibleInferiors && sclass->possibleInferiors[j]; j++) { + ldb_msg_add_string(msg, attrName, sclass->possibleInferiors[j]); } } @@ -209,12 +209,14 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct kludge_acl_context *ac; struct kludge_private_data *data; int i, ret; ac = talloc_get_type(req->context, struct kludge_acl_context); - data = talloc_get_type(ac->module->private_data, struct kludge_private_data); + data = talloc_get_type(ldb_module_get_private(ac->module), struct kludge_private_data); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -228,7 +230,7 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->allowedAttributes) { - ret = kludge_acl_allowedAttributes(ac->module->ldb, + ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributes"); if (ret != LDB_SUCCESS) { @@ -236,7 +238,7 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) } } if (ac->allowedChildClasses) { - ret = kludge_acl_childClasses(ac->module->ldb, + ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClasses"); if (ret != LDB_SUCCESS) { @@ -249,14 +251,14 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) switch (ac->user_type) { case SECURITY_SYSTEM: if (ac->allowedAttributesEffective) { - ret = kludge_acl_allowedAttributes(ac->module->ldb, ares->message, + ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); } } if (ac->allowedChildClassesEffective) { - ret = kludge_acl_childClasses(ac->module->ldb, ares->message, + ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClassesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -266,14 +268,14 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) case SECURITY_ADMINISTRATOR: if (ac->allowedAttributesEffective) { - ret = kludge_acl_allowedAttributes(ac->module->ldb, ares->message, + ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); } } if (ac->allowedChildClassesEffective) { - ret = kludge_acl_childClasses(ac->module->ldb, ares->message, + ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClassesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -316,6 +318,7 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct kludge_acl_context *ac; struct ldb_request *down_req; struct kludge_private_data *data; @@ -324,13 +327,15 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) struct ldb_control *sd_control; struct ldb_control **sd_saved_controls; + ldb = ldb_module_get_ctx(module); + ac = talloc(req, struct kludge_acl_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - data = talloc_get_type(module->private_data, struct kludge_private_data); + data = talloc_get_type(ldb_module_get_private(module), struct kludge_private_data); ac->module = module; ac->req = req; @@ -372,7 +377,7 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) } ret = ldb_build_search_req_ex(&down_req, - module->ldb, ac, + ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -402,13 +407,14 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) /* ANY change type */ static int kludge_acl_change(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); enum security_user_level user_type = what_is_user(module); switch (user_type) { case SECURITY_SYSTEM: case SECURITY_ADMINISTRATOR: return ldb_next_request(module, req); default: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "kludge_acl_change: " "attempted database modify not permitted. " "User %s is not SYSTEM or an administrator", @@ -419,6 +425,7 @@ static int kludge_acl_change(struct ldb_module *module, struct ldb_request *req) static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); enum security_user_level user_type; /* allow everybody to read the sequence number */ @@ -434,7 +441,7 @@ static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *re case SECURITY_ADMINISTRATOR: return ldb_next_request(module, req); default: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "kludge_acl_change: " "attempted database modify not permitted. " "User %s is not SYSTEM or an administrator", @@ -445,6 +452,7 @@ static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *re static int kludge_acl_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret, i; TALLOC_CTX *mem_ctx = talloc_new(module); static const char *attrs[] = { "passwordAttribute", NULL }; @@ -454,22 +462,24 @@ static int kludge_acl_init(struct ldb_module *module) struct kludge_private_data *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct kludge_private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } data->password_attrs = NULL; - module->private_data = data; + ldb_module_set_private(module, data); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, mem_ctx, &res, - ldb_dn_new(mem_ctx, module->ldb, "@KLUDGEACL"), + ret = ldb_search(ldb, mem_ctx, &res, + ldb_dn_new(mem_ctx, ldb, "@KLUDGEACL"), LDB_SCOPE_BASE, attrs, NULL); if (ret != LDB_SUCCESS) { goto done; @@ -492,7 +502,7 @@ static int kludge_acl_init(struct ldb_module *module) data->password_attrs = talloc_array(data, const char *, password_attributes->num_values + 1); if (!data->password_attrs) { talloc_free(mem_ctx); - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } for (i=0; i < password_attributes->num_values; i++) { @@ -503,7 +513,7 @@ static int kludge_acl_init(struct ldb_module *module) ret = ldb_mod_register_control(module, LDB_CONTROL_SD_FLAGS_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "partition: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index a3318ccabd..2365a58f78 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -29,10 +29,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" -#include "ldb/include/dlinklist.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" struct la_op_store { @@ -65,15 +62,18 @@ struct la_context { static struct la_context *linked_attributes_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct la_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct la_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } - ac->schema = dsdb_get_schema(module->ldb); + ac->schema = dsdb_get_schema(ldb); ac->module = module; ac->req = req; @@ -86,19 +86,22 @@ static int la_store_op(struct la_context *ac, enum la_op op, struct ldb_val *dn, const char *name) { + struct ldb_context *ldb; struct la_op_store *os; struct ldb_dn *op_dn; - op_dn = ldb_dn_from_ldb_val(ac, ac->module->ldb, dn); + ldb = ldb_module_get_ctx(ac->module); + + op_dn = ldb_dn_from_ldb_val(ac, ldb, dn); if (!op_dn) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "could not parse attribute as a DN"); return LDB_ERR_INVALID_DN_SYNTAX; } os = talloc_zero(ac, struct la_op_store); if (!os) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -108,7 +111,7 @@ static int la_store_op(struct la_context *ac, os->name = talloc_strdup(os, name); if (!os->name) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -136,12 +139,15 @@ static int la_down_req(struct la_context *ac); /* add */ static int linked_attributes_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; const struct dsdb_attribute *target_attr; struct la_context *ac; const char *attr_name; int ret; int i, j; + ldb = ldb_module_get_ctx(module); + if (ldb_dn_is_special(req->op.add.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -164,7 +170,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * const struct dsdb_attribute *schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", el->name); return LDB_ERR_OBJECT_CLASS_VIOLATION; } @@ -175,7 +181,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * if ((schema_attr->linkID & 1) == 1) { /* Odd is for the target. Illigal to modify */ - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s must not be modified directly, it is a linked attribute", el->name); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -222,6 +228,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; const struct dsdb_attribute *schema_attr; const struct dsdb_attribute *target_attr; struct ldb_message_element *search_el; @@ -232,6 +239,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are int ret = LDB_SUCCESS; ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); rc = ac->rc; if (!ares) { @@ -248,7 +256,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are case LDB_REPLY_ENTRY: if (ldb_dn_compare(ares->message->dn, ac->req->op.mod.message->dn) != 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "linked_attributes: %s is not the DN we were looking for", ldb_dn_get_linearized(ares->message->dn)); /* Guh? We only asked for this DN */ talloc_free(ares); @@ -263,7 +271,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, rc->el[i].name); if (!schema_attr) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", rc->el[i].name); talloc_free(ares); @@ -348,6 +356,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques /* Determine the effect of the modification */ /* Apply the modify to the linked entry */ + struct ldb_context *ldb; int i, j; struct la_context *ac; struct ldb_request *search_req; @@ -355,6 +364,8 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques int ret; + ldb = ldb_module_get_ctx(module); + if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -372,7 +383,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques ac->rc = talloc_zero(ac, struct replace_context); if (!ac->rc) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -384,7 +395,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques const struct dsdb_attribute *schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", el->name); return LDB_ERR_OBJECT_CLASS_VIOLATION; } @@ -395,7 +406,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques if ((schema_attr->linkID & 1) == 1) { /* Odd is for the target. Illegal to modify */ - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s must not be modified directly, it is a linked attribute", el->name); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -466,7 +477,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques struct ldb_message_element, ac->rc->num_elements +1); if (!search_el) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ac->rc->el = search_el; @@ -482,7 +493,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques attrs = talloc_array(ac->rc, const char *, ac->rc->num_elements + 1); if (!attrs) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } for (i = 0; ac->rc && i < ac->rc->num_elements; i++) { @@ -491,7 +502,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques attrs[i] = NULL; /* The callback does all the hard work here */ - ret = ldb_build_search_req(&search_req, module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, @@ -523,6 +534,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques /* delete, rename */ static int linked_attributes_del(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *search_req; struct la_context *ac; const char **attrs; @@ -538,6 +550,8 @@ static int linked_attributes_del(struct ldb_module *module, struct ldb_request * - Regain our sainity */ + ldb = ldb_module_get_ctx(module); + ac = linked_attributes_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; @@ -553,7 +567,7 @@ static int linked_attributes_del(struct ldb_module *module, struct ldb_request * return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, module->ldb, req, + ret = ldb_build_search_req(&search_req, ldb, req, req->op.del.dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -601,6 +615,7 @@ static int linked_attributes_rename(struct ldb_module *module, struct ldb_reques static int la_op_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct la_context *ac; const struct dsdb_attribute *schema_attr; const struct dsdb_attribute *target_attr; @@ -610,6 +625,7 @@ static int la_op_search_callback(struct ldb_request *req, int ret; ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -647,7 +663,7 @@ static int la_op_search_callback(struct ldb_request *req, break; default: talloc_free(ares); - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "operations must be delete or rename"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -658,7 +674,7 @@ static int la_op_search_callback(struct ldb_request *req, schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute" " in schema", el->name); talloc_free(ares); @@ -737,7 +753,7 @@ static int la_op_search_callback(struct ldb_request *req, default: talloc_free(ares); - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "operations must be delete or rename"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -764,7 +780,7 @@ static int la_do_mod_request(struct la_context *ac) ac->op_response, LDB_SUCCESS); } - ldb = ac->module->ldb; + ldb = ldb_module_get_ctx(ac->module); /* Create the modify request */ new_msg = ldb_msg_new(ac); @@ -797,7 +813,7 @@ static int la_do_mod_request(struct la_context *ac) } #if 0 - ldb_debug(ac->module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "link on %s %s: %s %s\n", ldb_dn_get_linearized(new_msg->dn), ret_el->name, ret_el->values[0].data, ac->ops->op == LA_OP_ADD ? "added" : "deleted"); @@ -822,9 +838,11 @@ static int la_do_mod_request(struct la_context *ac) static int la_mod_callback(struct ldb_request *req, struct ldb_reply *ares) { struct la_context *ac; + struct ldb_context *ldb; struct la_op_store *os; ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -836,7 +854,7 @@ static int la_mod_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -860,7 +878,10 @@ static int la_mod_del_callback(struct ldb_request *req, struct ldb_reply *ares) { int ret; struct la_context *ac; + struct ldb_context *ldb; + ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -872,7 +893,7 @@ static int la_mod_del_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -903,7 +924,10 @@ static int la_rename_callback(struct ldb_request *req, struct ldb_reply *ares) struct ldb_request *search_req; const char **attrs; WERROR werr; + struct ldb_context *ldb; + ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -915,7 +939,7 @@ static int la_rename_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -927,7 +951,7 @@ static int la_rename_callback(struct ldb_request *req, struct ldb_reply *ares) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, ac->module->ldb, req, + ret = ldb_build_search_req(&search_req, ldb, req, ac->req->op.rename.newdn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -964,7 +988,10 @@ static int la_add_callback(struct ldb_request *req, struct ldb_reply *ares) { int ret; struct la_context *ac; + struct ldb_context *ldb; + ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -976,7 +1003,7 @@ static int la_add_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -989,7 +1016,7 @@ static int la_add_callback(struct ldb_request *req, struct ldb_reply *ares) /* The callback does all the hard work here - we need * the objectGUID and SID of the added record */ - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.add.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, @@ -1023,31 +1050,34 @@ static int la_down_req(struct la_context *ac) { struct ldb_request *down_req; int ret; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(ac->module); switch (ac->req->operation) { case LDB_ADD: - ret = ldb_build_add_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, ac->req->op.add.message, ac->req->controls, ac, la_add_callback, ac->req); break; case LDB_MODIFY: - ret = ldb_build_mod_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, ac->req->op.mod.message, ac->req->controls, ac, la_mod_del_callback, ac->req); break; case LDB_DELETE: - ret = ldb_build_del_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_del_req(&down_req, ldb, ac, ac->req->op.del.dn, ac->req->controls, ac, la_mod_del_callback, ac->req); break; case LDB_RENAME: - ret = ldb_build_rename_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_rename_req(&down_req, ldb, ac, ac->req->op.rename.olddn, ac->req->op.rename.newdn, ac->req->controls, diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c index 55d895791a..58c0f1f0d5 100644 --- a/source4/dsdb/samdb/ldb_modules/local_password.c +++ b/source4/dsdb/samdb/ldb_modules/local_password.c @@ -31,8 +31,7 @@ #include "includes.h" #include "libcli/ldap/ldap.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/ndr/libndr.h" #include "dsdb/samdb/ldb_modules/password_modules.h" @@ -89,11 +88,14 @@ struct lpdb_context { static struct lpdb_context *lpdb_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct lpdb_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct lpdb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -105,9 +107,11 @@ static struct lpdb_context *lpdb_init_context(struct ldb_module *module, static int lpdb_local_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct lpdb_context *ac; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -119,7 +123,7 @@ static int lpdb_local_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -141,6 +145,7 @@ static int lpdb_add_callback(struct ldb_request *req, static int local_password_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_message *remote_message; struct ldb_request *remote_req; struct lpdb_context *ac; @@ -148,14 +153,15 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req int ret; int i; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_add\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_add\n"); if (ldb_dn_is_special(req->op.add.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.add.message->dn) == 0) { return ldb_next_request(module, req); } @@ -173,7 +179,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req /* TODO: remove this when userPassword will be in schema */ if (!ldb_msg_check_string_attribute(req->op.add.message, "objectClass", "person")) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Cannot relocate a password on entry: %s, does not have objectClass 'person'", ldb_dn_get_linearized(req->op.add.message->dn)); return LDB_ERR_OBJECT_CLASS_VIOLATION; @@ -213,7 +219,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req * to add the password. This may be changed to an 'add and * search', to allow the directory to create the objectGUID */ if (ldb_msg_find_ldb_val(req->op.add.message, "objectGUID") == NULL) { - ldb_set_errstring(module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: " "local_password module must be " "onfigured below objectGUID module!\n"); @@ -221,7 +227,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req } ac->local_message->dn = ldb_dn_new(ac->local_message, - module->ldb, LOCAL_BASE); + ldb, LOCAL_BASE); if ((ac->local_message->dn == NULL) || ( ! ldb_dn_add_child_fmt(ac->local_message->dn, PASSWORD_GUID_ATTR "=%s", @@ -230,7 +236,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_add_req(&remote_req, module->ldb, ac, + ret = ldb_build_add_req(&remote_req, ldb, ac, remote_message, req->controls, ac, lpdb_add_callback, @@ -247,11 +253,13 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req static int lpdb_add_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ldb_request *local_req; struct lpdb_context *ac; int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -263,7 +271,7 @@ static int lpdb_add_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -271,7 +279,7 @@ static int lpdb_add_callback(struct ldb_request *req, ac->remote_done = talloc_steal(ac, ares); - ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&local_req, ldb, ac, ac->local_message, NULL, ac, lpdb_local_callback, @@ -298,20 +306,22 @@ static int lpdb_mod_search_callback(struct ldb_request *req, static int local_password_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct lpdb_context *ac; struct ldb_message *remote_message; struct ldb_request *remote_req; int ret; int i; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_modify\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_modify\n"); if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.mod.message->dn) == 0) { return ldb_next_request(module, req); } @@ -354,7 +364,7 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * ldb_msg_remove_attr(ac->local_message, remote_message->elements[i].name); } - ret = ldb_build_mod_req(&remote_req, module->ldb, ac, + ret = ldb_build_mod_req(&remote_req, ldb, ac, remote_message, req->controls, ac, lpdb_modify_callabck, @@ -371,12 +381,14 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * static int lpdb_modify_callabck(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; struct ldb_request *search_req; struct lpdb_context *ac; int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -388,7 +400,7 @@ static int lpdb_modify_callabck(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -397,7 +409,7 @@ static int lpdb_modify_callabck(struct ldb_request *req, ac->remote_done = talloc_steal(ac, ares); /* prepare the search operation */ - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectclass=*)", attrs, NULL, @@ -421,6 +433,7 @@ static int lpdb_modify_callabck(struct ldb_request *req, static int lpdb_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ldb_request *local_req; struct lpdb_context *ac; struct ldb_dn *local_dn; @@ -428,6 +441,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, int ret = LDB_SUCCESS; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -441,7 +455,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->remote != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -465,7 +479,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, /* if it is not an entry of type person this is an error */ /* TODO: remove this when sambaPassword will be in schema */ if (ac->remote == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "entry just modified (%s) not found!", ldb_dn_get_linearized(req->op.search.base)); return ldb_module_done(ac->req, NULL, NULL, @@ -482,7 +496,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, if (ldb_msg_find_ldb_val(ac->remote->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: " "local_password module must be " "configured below objectGUID " @@ -494,7 +508,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, objectGUID = samdb_result_guid(ac->remote->message, "objectGUID"); - local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + local_dn = ldb_dn_new(ac, ldb, LOCAL_BASE); if ((local_dn == NULL) || ( ! ldb_dn_add_child_fmt(local_dn, PASSWORD_GUID_ATTR "=%s", @@ -504,7 +518,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, } ac->local_message->dn = local_dn; - ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&local_req, ldb, ac, ac->local_message, NULL, ac, lpdb_local_callback, @@ -535,11 +549,13 @@ static int lpdb_del_search_callback(struct ldb_request *req, static int local_password_delete(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *remote_req; struct lpdb_context *ac; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_delete\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_delete\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.mod.message->dn)) { @@ -548,7 +564,7 @@ static int local_password_delete(struct ldb_module *module, /* If the caller is manipulating the local passwords directly, * let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.del.dn) == 0) { return ldb_next_request(module, req); } @@ -559,7 +575,7 @@ static int local_password_delete(struct ldb_module *module, return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_del_req(&remote_req, module->ldb, ac, + ret = ldb_build_del_req(&remote_req, ldb, ac, req->op.del.dn, req->controls, ac, lpdb_delete_callabck, @@ -576,12 +592,14 @@ static int local_password_delete(struct ldb_module *module, static int lpdb_delete_callabck(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; struct ldb_request *search_req; struct lpdb_context *ac; int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -593,7 +611,7 @@ static int lpdb_delete_callabck(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -602,7 +620,7 @@ static int lpdb_delete_callabck(struct ldb_request *req, ac->remote_done = talloc_steal(ac, ares); /* prepare the search operation */ - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.del.dn, LDB_SCOPE_BASE, "(objectclass=*)", attrs, NULL, @@ -626,6 +644,7 @@ static int lpdb_delete_callabck(struct ldb_request *req, static int lpdb_del_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ldb_request *local_req; struct lpdb_context *ac; struct ldb_dn *local_dn; @@ -633,6 +652,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, int ret = LDB_SUCCESS; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -646,7 +666,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->remote != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -686,7 +706,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, if (ldb_msg_find_ldb_val(ac->remote->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: " "local_password module must be " "configured below objectGUID " @@ -698,7 +718,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, objectGUID = samdb_result_guid(ac->remote->message, "objectGUID"); - local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + local_dn = ldb_dn_new(ac, ldb, LOCAL_BASE); if ((local_dn == NULL) || ( ! ldb_dn_add_child_fmt(local_dn, PASSWORD_GUID_ATTR "=%s", @@ -707,7 +727,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, LDB_ERR_OPERATIONS_ERROR); } - ret = ldb_build_del_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_del_req(&local_req, ldb, ac, local_dn, NULL, ac, lpdb_local_callback, @@ -736,10 +756,13 @@ static int lpdb_local_search_callback(struct ldb_request *req, static int lpdb_local_search(struct lpdb_context *ac) { + struct ldb_context *ldb; struct ldb_request *local_req; int ret; - ret = ldb_build_search_req(&local_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_search_req(&local_req, ldb, ac, ac->current->local_dn, LDB_SCOPE_BASE, "(objectclass=*)", @@ -757,6 +780,7 @@ static int lpdb_local_search(struct lpdb_context *ac) static int lpdb_local_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct lpdb_context *ac; struct ldb_reply *merge; struct lpdb_reply *lr; @@ -764,6 +788,7 @@ static int lpdb_local_search_callback(struct ldb_request *req, int i; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -781,7 +806,7 @@ static int lpdb_local_search_callback(struct ldb_request *req, case LDB_REPLY_ENTRY: if (lr->remote == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Too many results for password entry search!"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -868,6 +893,7 @@ static int lpdb_local_search_callback(struct ldb_request *req, static int lpdb_remote_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct lpdb_context *ac; struct ldb_dn *local_dn; struct GUID objectGUID; @@ -875,6 +901,7 @@ static int lpdb_remote_search_callback(struct ldb_request *req, int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -903,7 +930,7 @@ static int lpdb_remote_search_callback(struct ldb_request *req, } if (ldb_msg_find_ldb_val(ares->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -919,7 +946,7 @@ static int lpdb_remote_search_callback(struct ldb_request *req, ldb_msg_remove_attr(ares->message, "objectClass"); } - local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + local_dn = ldb_dn_new(ac, ldb, LOCAL_BASE); if ((local_dn == NULL) || (! ldb_dn_add_child_fmt(local_dn, PASSWORD_GUID_ATTR "=%s", @@ -984,13 +1011,15 @@ static int lpdb_remote_search_callback(struct ldb_request *req, static int local_password_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *remote_req; struct lpdb_context *ac; int i; int ret; const char * const *search_attrs = NULL; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_search\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_search\n"); if (ldb_dn_is_special(req->op.search.base)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -999,7 +1028,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = NULL; /* If the caller is searching for the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.search.base) == 0) { return ldb_next_request(module, req); } @@ -1044,7 +1073,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = req->op.search.attrs; } - ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&remote_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c index d90c2547a6..607bf054d2 100644 --- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c @@ -22,9 +22,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" @@ -33,6 +31,7 @@ static int naming_fsmo_init(struct ldb_module *module) { + struct ldb_context *ldb; TALLOC_CTX *mem_ctx; struct ldb_dn *naming_dn; struct dsdb_naming_fsmo *naming_fsmo; @@ -43,15 +42,17 @@ static int naming_fsmo_init(struct ldb_module *module) NULL }; + ldb = ldb_module_get_ctx(module); + mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - naming_dn = samdb_partitions_dn(module->ldb, mem_ctx); + naming_dn = samdb_partitions_dn(ldb, mem_ctx); if (!naming_dn) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); @@ -59,55 +60,55 @@ static int naming_fsmo_init(struct ldb_module *module) naming_fsmo = talloc_zero(mem_ctx, struct dsdb_naming_fsmo); if (!naming_fsmo) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = naming_fsmo; + ldb_module_set_private(module, naming_fsmo); - ret = ldb_search(module->ldb, mem_ctx, &naming_res, + ret = ldb_search(ldb, mem_ctx, &naming_res, naming_dn, LDB_SCOPE_BASE, naming_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "naming_fsmo_init: failed to search the cross-ref container: %s: %s", - ldb_strerror(ret), ldb_errstring(module->ldb)); + ldb_strerror(ret), ldb_errstring(ldb)); talloc_free(mem_ctx); return ret; } if (naming_res->count == 0) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no cross-ref container present: (skip loading of naming contexts details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } else if (naming_res->count > 1) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "naming_fsmo_init: [%u] cross-ref containers found on a base search", naming_res->count); talloc_free(mem_ctx); return LDB_ERR_CONSTRAINT_VIOLATION; } - naming_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, naming_fsmo, naming_res->msgs[0], "fSMORoleOwner"); - if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), naming_fsmo->master_dn) == 0) { + naming_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, naming_fsmo, naming_res->msgs[0], "fSMORoleOwner"); + if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), naming_fsmo->master_dn) == 0) { naming_fsmo->we_are_master = true; } else { naming_fsmo->we_are_master = false; } - if (ldb_set_opaque(module->ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) { - ldb_oom(module->ldb); + if (ldb_set_opaque(ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } talloc_steal(module, naming_fsmo); - ldb_debug(module->ldb, LDB_DEBUG_TRACE, + ldb_debug(ldb, LDB_DEBUG_TRACE, "naming_fsmo_init: we are master: %s\n", (naming_fsmo->we_are_master?"yes":"no")); diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index 1d240a33fe..0261bb32e9 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -34,11 +34,8 @@ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" -#include "../lib/util/dlinklist.h" #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_security.h" #include "libcli/security/security.h" @@ -63,11 +60,14 @@ struct class_list { static struct oc_context *oc_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct oc_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct oc_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -89,11 +89,14 @@ static int objectclass_sort(struct ldb_module *module, struct ldb_message_element *objectclass_element, struct class_list **sorted_out) { + struct ldb_context *ldb; int i; int layer; struct class_list *sorted = NULL, *parent_class = NULL, *subclass = NULL, *unsorted = NULL, *current, *poss_subclass, *poss_parent, *new_parent; + ldb = ldb_module_get_ctx(module); + /* DESIGN: * * We work on 4 different 'bins' (implemented here as linked lists): @@ -127,12 +130,12 @@ static int objectclass_sort(struct ldb_module *module, for (i=0; i < objectclass_element->num_values; i++) { current = talloc(mem_ctx, struct class_list); if (!current) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } current->objectclass = dsdb_class_by_lDAPDisplayName(schema, (const char *)objectclass_element->values[i].data); if (!current->objectclass) { - ldb_asprintf_errstring(module->ldb, "objectclass %s is not a valid objectClass in schema", (const char *)objectclass_element->values[i].data); + ldb_asprintf_errstring(ldb, "objectclass %s is not a valid objectClass in schema", (const char *)objectclass_element->values[i].data); return LDB_ERR_OBJECT_CLASS_VIOLATION; } @@ -222,19 +225,20 @@ static int objectclass_sort(struct ldb_module *module, * was no 'top', a conflict in the objectClasses or some other * schema error? */ - ldb_asprintf_errstring(module->ldb, "objectclass %s is not a valid objectClass in objectClass chain", unsorted->objectclass->lDAPDisplayName); + ldb_asprintf_errstring(ldb, "objectclass %s is not a valid objectClass in objectClass chain", unsorted->objectclass->lDAPDisplayName); return LDB_ERR_OBJECT_CLASS_VIOLATION; } static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, const struct dsdb_class *objectclass) { + struct ldb_context *ldb = ldb_module_get_ctx(module); enum ndr_err_code ndr_err; DATA_BLOB *linear_sd; struct auth_session_info *session_info - = ldb_get_opaque(module->ldb, "sessionInfo"); + = ldb_get_opaque(ldb, "sessionInfo"); struct security_descriptor *sd; - const struct dom_sid *domain_sid = samdb_domain_sid(module->ldb); + const struct dom_sid *domain_sid = samdb_domain_sid(ldb); if (!objectclass->defaultSecurityDescriptor || !domain_sid) { return NULL; @@ -257,7 +261,7 @@ static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, } ndr_err = ndr_push_struct_blob(linear_sd, mem_ctx, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), sd, (ndr_push_flags_fn_t)ndr_push_security_descriptor); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -270,10 +274,12 @@ static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, static int get_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct oc_context *ac; int ret; ac = talloc_get_type(req->context, struct oc_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -288,7 +294,7 @@ static int get_search_callback(struct ldb_request *req, struct ldb_reply *ares) switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->search_res != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -402,12 +408,15 @@ static int objectclass_do_add(struct oc_context *ac); static int objectclass_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *search_req; struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_add\n"); + + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectclass_add\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -433,11 +442,11 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) /* get copy of parent DN */ parent_dn = ldb_dn_get_parent(ac, ac->req->op.add.message->dn); if (parent_dn == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, module->ldb, + ret = ldb_build_search_req(&search_req, ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", NULL, NULL, @@ -455,6 +464,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) static int objectclass_do_add(struct oc_context *ac) { + struct ldb_context *ldb; const struct dsdb_schema *schema; struct ldb_request *add_req; char *value; @@ -464,7 +474,8 @@ static int objectclass_do_add(struct oc_context *ac) struct class_list *sorted, *current; int ret; - schema = dsdb_get_schema(ac->module->ldb); + ldb = ldb_module_get_ctx(ac->module); + schema = dsdb_get_schema(ldb); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { @@ -475,14 +486,14 @@ static int objectclass_do_add(struct oc_context *ac) /* Check we have a valid parent */ if (ac->search_res == NULL) { - if (ldb_dn_compare(ldb_get_root_basedn(ac->module->ldb), + if (ldb_dn_compare(ldb_get_root_basedn(ldb), msg->dn) == 0) { /* Allow the tree to be started */ /* but don't keep any error string, it's meaningless */ - ldb_set_errstring(ac->module->ldb, NULL); + ldb_set_errstring(ldb, NULL); } else { - ldb_asprintf_errstring(ac->module->ldb, "objectclass: Cannot add %s, parent does not exist!", + ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, parent does not exist!", ldb_dn_get_linearized(msg->dn)); talloc_free(mem_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -496,7 +507,7 @@ static int objectclass_do_add(struct oc_context *ac) &msg->dn); if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(ac->module->ldb, "Could not munge DN %s into normal form", + ldb_asprintf_errstring(ldb, "Could not munge DN %s into normal form", ldb_dn_get_linearized(ac->req->op.add.message->dn)); talloc_free(mem_ctx); return ret; @@ -509,7 +520,7 @@ static int objectclass_do_add(struct oc_context *ac) } if (schema) { - ret = fix_attributes(ac->module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; @@ -544,13 +555,13 @@ static int objectclass_do_add(struct oc_context *ac) for (current = sorted; current; current = current->next) { value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "objectclass: could not re-add sorted " "objectclass to modify msg"); talloc_free(mem_ctx); @@ -563,7 +574,7 @@ static int objectclass_do_add(struct oc_context *ac) if (!ldb_msg_find_element(msg, "objectCategory")) { value = talloc_strdup(msg, current->objectclass->defaultObjectCategory); if (value == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -612,21 +623,21 @@ static int objectclass_do_add(struct oc_context *ac) /* TODO: If parent object is site or subnet, also add (SYSTEM_FLAG_CONFIG_ALLOW_RENAME) */ if (el || systemFlags != 0) { - samdb_msg_add_int(ac->module->ldb, msg, msg, "systemFlags", systemFlags); + samdb_msg_add_int(ldb, msg, msg, "systemFlags", systemFlags); } } } } talloc_free(mem_ctx); - ret = ldb_msg_sanity_check(ac->module->ldb, msg); + ret = ldb_msg_sanity_check(ldb, msg); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_add_req(&add_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&add_req, ldb, ac, msg, ac->req->controls, ac, oc_op_callback, @@ -645,9 +656,10 @@ static int objectclass_do_mod(struct oc_context *ac); static int objectclass_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_message_element *objectclass_element; struct ldb_message *msg; - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + const struct dsdb_schema *schema = dsdb_get_schema(ldb); struct class_list *sorted, *current; struct ldb_request *down_req; struct oc_context *ac; @@ -655,7 +667,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req char *value; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_modify\n"); + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectclass_modify\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.mod.message->dn)) { @@ -684,12 +696,12 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - ret = fix_attributes(module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, oc_op_callback, @@ -721,7 +733,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - ret = fix_attributes(module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; @@ -752,13 +764,13 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, + ldb_set_errstring(ldb, "objectclass: could not re-add sorted " "objectclass to modify msg"); talloc_free(mem_ctx); @@ -768,12 +780,12 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req talloc_free(mem_ctx); - ret = ldb_msg_sanity_check(module->ldb, msg); + ret = ldb_msg_sanity_check(ldb, msg); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, oc_op_callback, @@ -793,17 +805,17 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = fix_attributes(module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ret; } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, oc_modify_callback, @@ -817,12 +829,14 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; static const char * const attrs[] = { "objectClass", NULL }; struct ldb_request *search_req; struct oc_context *ac; int ret; ac = talloc_get_type(req->context, struct oc_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -839,7 +853,7 @@ static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) LDB_ERR_OPERATIONS_ERROR); } - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -860,7 +874,7 @@ static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int objectclass_do_mod(struct oc_context *ac) { - + struct ldb_context *ldb; const struct dsdb_schema *schema; struct ldb_request *mod_req; char *value; @@ -870,10 +884,12 @@ static int objectclass_do_mod(struct oc_context *ac) struct class_list *sorted, *current; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->search_res == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - schema = dsdb_get_schema(ac->module->ldb); + schema = dsdb_get_schema(ldb); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { @@ -883,7 +899,7 @@ static int objectclass_do_mod(struct oc_context *ac) /* use a new message structure */ msg = ldb_msg_new(ac); if (msg == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "objectclass: could not create new modify msg"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; @@ -912,7 +928,7 @@ static int objectclass_do_mod(struct oc_context *ac) ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE, NULL); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, "objectclass: could not clear objectclass in modify msg"); + ldb_set_errstring(ldb, "objectclass: could not clear objectclass in modify msg"); talloc_free(mem_ctx); return ret; } @@ -921,24 +937,24 @@ static int objectclass_do_mod(struct oc_context *ac) for (current = sorted; current; current = current->next) { value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); + ldb_set_errstring(ldb, "objectclass: could not re-add sorted objectclass to modify msg"); talloc_free(mem_ctx); return ret; } } - ret = ldb_msg_sanity_check(ac->module->ldb, msg); + ret = ldb_msg_sanity_check(ldb, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; } - ret = ldb_build_mod_req(&mod_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, ac->req->controls, ac, oc_op_callback, @@ -958,13 +974,15 @@ static int objectclass_do_rename(struct oc_context *ac); static int objectclass_rename(struct ldb_module *module, struct ldb_request *req) { static const char * const attrs[] = { NULL }; - + struct ldb_context *ldb; struct ldb_request *search_req; struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_rename\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectclass_rename\n"); if (ldb_dn_is_special(req->op.rename.newdn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -973,7 +991,7 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req /* Firstly ensure we are not trying to rename it to be a child of itself */ if ((ldb_dn_compare_base(req->op.rename.olddn, req->op.rename.newdn) == 0) && (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) != 0)) { - ldb_asprintf_errstring(module->ldb, "Cannot rename %s to be a child of itself", + ldb_asprintf_errstring(ldb, "Cannot rename %s to be a child of itself", ldb_dn_get_linearized(req->op.rename.olddn)); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -985,10 +1003,10 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req parent_dn = ldb_dn_get_parent(ac, req->op.rename.newdn); if (parent_dn == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, module->ldb, + ret = ldb_build_search_req(&search_req, ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -1005,13 +1023,16 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req static int objectclass_do_rename(struct oc_context *ac) { + struct ldb_context *ldb; struct ldb_request *rename_req; struct ldb_dn *fixed_dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* Check we have a valid parent */ if (ac->search_res == NULL) { - ldb_asprintf_errstring(ac->module->ldb, "objectclass: Cannot rename %s, parent does not exist!", + ldb_asprintf_errstring(ldb, "objectclass: Cannot rename %s, parent does not exist!", ldb_dn_get_linearized(ac->req->op.rename.newdn)); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -1030,7 +1051,7 @@ static int objectclass_do_rename(struct oc_context *ac) * by reading the allowedChildClasses and * allowedChildClasssesEffective attributes */ - ret = ldb_build_rename_req(&rename_req, ac->module->ldb, ac, + ret = ldb_build_rename_req(&rename_req, ldb, ac, ac->req->op.rename.olddn, fixed_dn, ac->req->controls, ac, oc_op_callback, diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index 3d725686e7..46ba8ebdb3 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_module.h" #include "librpc/gen_ndr/ndr_misc.h" #include "param/param.h" @@ -136,6 +136,7 @@ static int og_op_callback(struct ldb_request *req, struct ldb_reply *ares) /* add_record: add objectGUID attribute */ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct ldb_message_element *attribute; struct ldb_message *msg; @@ -147,7 +148,9 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) time_t t = time(NULL); struct og_context *ac; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -176,7 +179,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) guid = GUID_random(); ndr_err = ndr_push_struct_blob(&v, msg, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -196,7 +199,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) /* Get a sequence number from the backend */ /* FIXME: ldb_sequence_number is a semi-async call, * make sure this function is split and a callback is used */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 || add_uint64_element(msg, "uSNChanged", seq_num) != 0) { @@ -204,7 +207,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) } } - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, req->controls, ac, og_op_callback, @@ -220,6 +223,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) /* modify_record: update timestamps */ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct ldb_message *msg; int ret; @@ -227,7 +231,9 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) uint64_t seq_num; struct og_context *ac; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -252,14 +258,14 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) } /* Get a sequence number from the backend */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) { return LDB_ERR_OPERATIONS_ERROR; } } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, og_op_callback, diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index 0000c87f72..71a1b8e942 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_private.h" #include "dsdb/samdb/samdb.h" struct partition_private_data { diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 1707baba58..2c07fa1be6 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -33,9 +33,7 @@ #include "includes.h" #include "libcli/ldap/ldap_ndr.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "librpc/gen_ndr/misc.h" #include "librpc/gen_ndr/samr.h" #include "libcli/auth/libcli_auth.h" @@ -150,9 +148,11 @@ struct setup_password_fields_io { static int setup_nt_fields(struct setup_password_fields_io *io) { + struct ldb_context *ldb; uint32_t i; io->g.nt_hash = io->n.nt_hash; + ldb = ldb_module_get_ctx(io->ac->module); if (io->domain->pwdHistoryLength == 0) { return LDB_SUCCESS; @@ -163,7 +163,7 @@ static int setup_nt_fields(struct setup_password_fields_io *io) struct samr_Password, io->domain->pwdHistoryLength); if (!io->g.nt_history) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -190,9 +190,11 @@ static int setup_nt_fields(struct setup_password_fields_io *io) static int setup_lm_fields(struct setup_password_fields_io *io) { + struct ldb_context *ldb; uint32_t i; io->g.lm_hash = io->n.lm_hash; + ldb = ldb_module_get_ctx(io->ac->module); if (io->domain->pwdHistoryLength == 0) { return LDB_SUCCESS; @@ -203,7 +205,7 @@ static int setup_lm_fields(struct setup_password_fields_io *io) struct samr_Password, io->domain->pwdHistoryLength); if (!io->g.lm_history) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -223,12 +225,14 @@ static int setup_lm_fields(struct setup_password_fields_io *io) static int setup_kerberos_keys(struct setup_password_fields_io *io) { + struct ldb_context *ldb; krb5_error_code krb5_ret; Principal *salt_principal; krb5_salt salt; krb5_keyblock key; krb5_data cleartext_data; + ldb = ldb_module_get_ctx(io->ac->module); cleartext_data.data = io->n.cleartext_utf8->data; cleartext_data.length = io->n.cleartext_utf8->length; @@ -245,7 +249,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) name = talloc_strdup(io->ac, io->u.sAMAccountName); if (!name) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -255,7 +259,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) saltbody = talloc_asprintf(io->ac, "%s.%s", name, io->domain->dns_domain); if (!saltbody) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -269,7 +273,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) user_principal_name = talloc_strdup(io->ac, io->u.user_principal_name); if (!user_principal_name) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -289,7 +293,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) NULL); } if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a salting principal failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -303,7 +307,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt_principal, &salt); krb5_free_principal(io->smb_krb5_context->krb5_context, salt_principal); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of krb5_salt failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -315,7 +319,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt.saltvalue.length); krb5_free_salt(io->smb_krb5_context->krb5_context, salt); if (!io->g.salt) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } salt.saltvalue.data = discard_const(io->g.salt); @@ -331,7 +335,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a aes256-cts-hmac-sha1-96 key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -342,7 +346,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.aes_256.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -356,7 +360,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a aes128-cts-hmac-sha1-96 key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -367,7 +371,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.aes_128.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -381,7 +385,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a des-cbc-md5 key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -392,7 +396,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.des_md5.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -406,7 +410,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a des-cbc-crc key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -417,7 +421,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.des_crc.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -428,6 +432,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, const struct supplementalCredentialsBlob *old_scb, struct package_PrimaryKerberosBlob *pkb) { + struct ldb_context *ldb; struct package_PrimaryKerberosCtr3 *pkb3 = &pkb->ctr.ctr3; struct supplementalCredentialsPackage *old_scp = NULL; struct package_PrimaryKerberosBlob _old_pkb; @@ -435,6 +440,8 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, uint32_t i; enum ndr_err_code ndr_err; + ldb = ldb_module_get_ctx(io->ac->module); + /* * prepare generation of keys * @@ -448,7 +455,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, struct package_PrimaryKerberosKey3, pkb3->num_keys); if (!pkb3->keys) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -484,16 +491,16 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ - ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), &_old_pkb, + ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &_old_pkb, (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos: " "failed to pull old package_PrimaryKerberosBlob: %s", nt_errstr(status)); @@ -501,7 +508,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, } if (_old_pkb.version != 3) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos: " "package_PrimaryKerberosBlob version[%u] expected[3]", _old_pkb.version); @@ -527,6 +534,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, const struct supplementalCredentialsBlob *old_scb, struct package_PrimaryKerberosBlob *pkb) { + struct ldb_context *ldb; struct package_PrimaryKerberosCtr4 *pkb4 = &pkb->ctr.ctr4; struct supplementalCredentialsPackage *old_scp = NULL; struct package_PrimaryKerberosBlob _old_pkb; @@ -534,6 +542,8 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, uint32_t i; enum ndr_err_code ndr_err; + ldb = ldb_module_get_ctx(io->ac->module); + /* * prepare generation of keys * @@ -551,7 +561,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, struct package_PrimaryKerberosKey4, pkb4->num_keys); if (!pkb4->keys) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -597,18 +607,18 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ ndr_err = ndr_pull_struct_blob(&blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &_old_pkb, (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos_newer: " "failed to pull old package_PrimaryKerberosBlob: %s", nt_errstr(status)); @@ -616,7 +626,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, } if (_old_pkb.version != 4) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos_newer: " "package_PrimaryKerberosBlob version[%u] expected[4]", _old_pkb.version); @@ -644,6 +654,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, const struct supplementalCredentialsBlob *old_scb, struct package_PrimaryWDigestBlob *pdb) { + struct ldb_context *ldb = ldb_module_get_ctx(io->ac->module); DATA_BLOB sAMAccountName; DATA_BLOB sAMAccountName_l; DATA_BLOB sAMAccountName_u; @@ -890,12 +901,12 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, sAMAccountName = data_blob_string_const(io->u.sAMAccountName); sAMAccountName_l = data_blob_string_const(strlower_talloc(io->ac, io->u.sAMAccountName)); if (!sAMAccountName_l.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } sAMAccountName_u = data_blob_string_const(strupper_talloc(io->ac, io->u.sAMAccountName)); if (!sAMAccountName_u.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -905,31 +916,31 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, io->u.sAMAccountName, io->domain->dns_domain); if (!user_principal_name) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } } userPrincipalName = data_blob_string_const(user_principal_name); userPrincipalName_l = data_blob_string_const(strlower_talloc(io->ac, user_principal_name)); if (!userPrincipalName_l.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } userPrincipalName_u = data_blob_string_const(strupper_talloc(io->ac, user_principal_name)); if (!userPrincipalName_u.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } netbios_domain = data_blob_string_const(io->domain->netbios_domain); netbios_domain_l = data_blob_string_const(strlower_talloc(io->ac, io->domain->netbios_domain)); if (!netbios_domain_l.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } netbios_domain_u = data_blob_string_const(strupper_talloc(io->ac, io->domain->netbios_domain)); if (!netbios_domain_u.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -945,7 +956,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, pdb->num_hashes = ARRAY_SIZE(wdigest); pdb->hashes = talloc_array(io->ac, struct package_PrimaryWDigestHash, pdb->num_hashes); if (!pdb->hashes) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -971,6 +982,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, static int setup_supplemental_field(struct setup_password_fields_io *io) { + struct ldb_context *ldb; struct supplementalCredentialsBlob scb; struct supplementalCredentialsBlob _old_scb; struct supplementalCredentialsBlob *old_scb = NULL; @@ -1017,6 +1029,8 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) ZERO_STRUCT(zero16); ZERO_STRUCT(names); + ldb = ldb_module_get_ctx(io->ac->module); + if (!io->n.cleartext_utf8) { /* * when we don't have a cleartext password @@ -1028,12 +1042,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) /* if there's an old supplementaCredentials blob then parse it */ if (io->o.supplemental) { ndr_err = ndr_pull_struct_blob_all(io->o.supplemental, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &_old_scb, (ndr_pull_flags_fn_t)ndr_pull_supplementalCredentialsBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to pull old supplementalCredentialsBlob: %s", nt_errstr(status)); @@ -1043,7 +1057,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) if (_old_scb.sub.signature == SUPPLEMENTAL_CREDENTIALS_SIGNATURE) { old_scb = &_old_scb; } else { - ldb_debug(io->ac->module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "setup_supplemental_field: " "supplementalCredentialsBlob signature[0x%04X] expected[0x%04X]", _old_scb.sub.signature, SUPPLEMENTAL_CREDENTIALS_SIGNATURE); @@ -1051,7 +1065,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } /* TODO: do the correct check for this, it maybe depends on the functional level? */ - do_newer_keys = lp_parm_bool(ldb_get_opaque(io->ac->module->ldb, "loadparm"), + do_newer_keys = lp_parm_bool(ldb_get_opaque(ldb, "loadparm"), NULL, "password_hash", "create_aes_key", false); if (io->domain->store_cleartext && @@ -1110,12 +1124,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } ndr_err = ndr_push_struct_blob(&pknb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pknb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryKerberosNeverBlob: %s", nt_errstr(status)); @@ -1123,7 +1137,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pknb_hexstr = data_blob_hex_string(io->ac, &pknb_blob); if (!pknb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pkn->name = "Primary:Kerberos-Newer-Keys"; @@ -1142,12 +1156,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } ndr_err = ndr_push_struct_blob(&pkb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pkb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryKerberosBlob: %s", nt_errstr(status)); @@ -1155,7 +1169,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pkb_hexstr = data_blob_hex_string(io->ac, &pkb_blob); if (!pkb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pk->name = "Primary:Kerberos"; @@ -1173,12 +1187,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } ndr_err = ndr_push_struct_blob(&pdb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pdb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryWDigestBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryWDigestBlob: %s", nt_errstr(status)); @@ -1186,7 +1200,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pdb_hexstr = data_blob_hex_string(io->ac, &pdb_blob); if (!pdb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pd->name = "Primary:WDigest"; @@ -1202,12 +1216,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) pcb.cleartext = *io->n.cleartext_utf16; ndr_err = ndr_push_struct_blob(&pcb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pcb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryCLEARTEXTBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryCLEARTEXTBlob: %s", nt_errstr(status)); @@ -1215,7 +1229,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pcb_hexstr = data_blob_hex_string(io->ac, &pcb_blob); if (!pcb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pc->name = "Primary:CLEARTEXT"; @@ -1228,12 +1242,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) */ pb.names = names; ndr_err = ndr_push_struct_blob(&pb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pb, (ndr_push_flags_fn_t)ndr_push_package_PackagesBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PackagesBlob: %s", nt_errstr(status)); @@ -1241,7 +1255,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pb_hexstr = data_blob_hex_string(io->ac, &pb_blob); if (!pb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pp->name = "Packages"; @@ -1256,12 +1270,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) scb.sub.packages = packages; ndr_err = ndr_push_struct_blob(&io->g.supplemental, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &scb, (ndr_push_flags_fn_t)ndr_push_supplementalCredentialsBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push supplementalCredentialsBlob: %s", nt_errstr(status)); @@ -1289,23 +1303,26 @@ static int setup_kvno_field(struct setup_password_fields_io *io) static int setup_password_fields(struct setup_password_fields_io *io) { + struct ldb_context *ldb; bool ok; int ret; ssize_t converted_pw_len; - + + ldb = ldb_module_get_ctx(io->ac->module); + /* * refuse the change if someone want to change the cleartext * and supply his own hashes at the same time... */ if ((io->n.cleartext_utf8 || io->n.cleartext_utf16) && (io->n.nt_hash || io->n.lm_hash)) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_password_fields: " "it's only allowed to set the cleartext password or the password hashes"); return LDB_ERR_UNWILLING_TO_PERFORM; } if (io->n.cleartext_utf8 && io->n.cleartext_utf16) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_password_fields: " "it's only allowed to set the cleartext password as userPassword or clearTextPasssword, not both at once"); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -1316,14 +1333,14 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct ldb_val *cleartext_utf16_blob; io->n.cleartext_utf16 = cleartext_utf16_blob = talloc(io->ac, struct ldb_val); if (!io->n.cleartext_utf16) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF8, CH_UTF16, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, (void **)&cleartext_utf16_str); if (converted_pw_len == -1) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_password_fields: " "failed to generate UTF16 password from cleartext UTF8 password"); return LDB_ERR_OPERATIONS_ERROR; @@ -1334,10 +1351,10 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct ldb_val *cleartext_utf8_blob; io->n.cleartext_utf8 = cleartext_utf8_blob = talloc(io->ac, struct ldb_val); if (!io->n.cleartext_utf8) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF16MUNGED, CH_UTF8, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length, (void **)&cleartext_utf8_str); if (converted_pw_len == -1) { @@ -1351,7 +1368,7 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct samr_Password *nt_hash; nt_hash = talloc(io->ac, struct samr_Password); if (!nt_hash) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } io->n.nt_hash = nt_hash; @@ -1363,13 +1380,13 @@ static int setup_password_fields(struct setup_password_fields_io *io) if (io->n.cleartext_utf8) { struct samr_Password *lm_hash; char *cleartext_unix; - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF8, CH_UNIX, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, (void **)&cleartext_unix); if (converted_pw_len != -1) { lm_hash = talloc(io->ac, struct samr_Password); if (!lm_hash) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -1419,11 +1436,14 @@ static int setup_password_fields(struct setup_password_fields_io *io) static struct ph_context *ph_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ph_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct ph_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -1467,6 +1487,7 @@ static int password_hash_mod_do_mod(struct ph_context *ac); static int get_domain_data_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct domain_data *data; struct ph_context *ac; int ret; @@ -1474,6 +1495,7 @@ static int get_domain_data_callback(struct ldb_request *req, char *p; ac = talloc_get_type(req->context, struct ph_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -1487,7 +1509,7 @@ static int get_domain_data_callback(struct ldb_request *req, switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->domain != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1521,13 +1543,13 @@ static int get_domain_data_callback(struct ldb_request *req, data->dns_domain = strlower_talloc(data, tmp); if (data->dns_domain == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } data->realm = strupper_talloc(data, tmp); if (data->realm == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1538,7 +1560,7 @@ static int get_domain_data_callback(struct ldb_request *req, } data->netbios_domain = strupper_talloc(data, tmp); if (data->netbios_domain == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1581,19 +1603,22 @@ static int build_domain_data_request(struct ph_context *ac) /* attrs[] is returned from this function in ac->dom_req->op.search.attrs, so it must be static, as otherwise the compiler can put it on the stack */ + struct ldb_context *ldb; static const char * const attrs[] = { "pwdProperties", "pwdHistoryLength", NULL }; char *filter; + ldb = ldb_module_get_ctx(ac->module); + filter = talloc_asprintf(ac, "(&(objectSid=%s)(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain)))", ldap_encode_ndr_dom_sid(ac, ac->domain_sid)); if (filter == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - return ldb_build_search_req(&ac->dom_req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + return ldb_build_search_req(&ac->dom_req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -1603,6 +1628,7 @@ static int build_domain_data_request(struct ph_context *ac) static int password_hash_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ph_context *ac; struct ldb_message_element *sambaAttr; struct ldb_message_element *clearTextPasswordAttr; @@ -1610,14 +1636,16 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) struct ldb_message_element *lmAttr; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "password_hash_add\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "password_hash_add\n"); if (ldb_dn_is_special(req->op.add.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.add.message->dn) == 0) { return ldb_next_request(module, req); } @@ -1648,46 +1676,46 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) /* if it is not an entry of type person its an error */ /* TODO: remove this when userPassword will be in schema */ if (!ldb_msg_check_string_attribute(req->op.add.message, "objectClass", "person")) { - ldb_set_errstring(module->ldb, "Cannot set a password on entry that does not have objectClass 'person'"); + ldb_set_errstring(ldb, "Cannot set a password on entry that does not have objectClass 'person'"); return LDB_ERR_OBJECT_CLASS_VIOLATION; } /* check userPassword is single valued here */ /* TODO: remove this when userPassword will be single valued in schema */ if (sambaAttr && sambaAttr->num_values > 1) { - ldb_set_errstring(module->ldb, "mupltiple values for userPassword not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for userPassword not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (clearTextPasswordAttr && clearTextPasswordAttr->num_values > 1) { - ldb_set_errstring(module->ldb, "mupltiple values for clearTextPassword not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for clearTextPassword not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (ntAttr && (ntAttr->num_values > 1)) { - ldb_set_errstring(module->ldb, "mupltiple values for unicodePwd not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for unicodePwd not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (lmAttr && (lmAttr->num_values > 1)) { - ldb_set_errstring(module->ldb, "mupltiple values for dBCSPwd not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for dBCSPwd not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (sambaAttr && sambaAttr->num_values == 0) { - ldb_set_errstring(module->ldb, "userPassword must have a value!\n"); + ldb_set_errstring(ldb, "userPassword must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (clearTextPasswordAttr && clearTextPasswordAttr->num_values == 0) { - ldb_set_errstring(module->ldb, "clearTextPassword must have a value!\n"); + ldb_set_errstring(ldb, "clearTextPassword must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (ntAttr && (ntAttr->num_values == 0)) { - ldb_set_errstring(module->ldb, "unicodePwd must have a value!\n"); + ldb_set_errstring(ldb, "unicodePwd must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (lmAttr && (lmAttr->num_values == 0)) { - ldb_set_errstring(module->ldb, "dBCSPwd must have a value!\n"); + ldb_set_errstring(ldb, "dBCSPwd must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -1699,7 +1727,7 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) /* get user domain data */ ac->domain_sid = samdb_result_sid_prefix(ac, req->op.add.message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "can't handle entry with missing objectSid!\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -1712,14 +1740,17 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, ac->dom_req); } -static int password_hash_add_do_add(struct ph_context *ac) { - +static int password_hash_add_do_add(struct ph_context *ac) +{ + struct ldb_context *ldb; struct ldb_request *down_req; struct smb_krb5_context *smb_krb5_context; struct ldb_message *msg; struct setup_password_fields_io io; int ret; + ldb = ldb_module_get_ctx(ac->module); + msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -1727,8 +1758,8 @@ static int password_hash_add_do_add(struct ph_context *ac) { /* Some operations below require kerberos contexts */ if (smb_krb5_init_context(ac, - ldb_get_event_context(ac->module->ldb), - (struct loadparm_context *)ldb_get_opaque(ac->module->ldb, "loadparm"), + ldb_get_event_context(ldb), + (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"), &smb_krb5_context) != 0) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1763,14 +1794,14 @@ static int password_hash_add_do_add(struct ph_context *ac) { } if (io.g.nt_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "unicodePwd", io.g.nt_hash); if (ret != LDB_SUCCESS) { return ret; } } if (io.g.lm_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "dBCSPwd", io.g.lm_hash); if (ret != LDB_SUCCESS) { return ret; @@ -1801,20 +1832,20 @@ static int password_hash_add_do_add(struct ph_context *ac) { return ret; } } - ret = samdb_msg_add_uint64(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint64(ldb, ac, msg, "pwdLastSet", io.g.last_set); if (ret != LDB_SUCCESS) { return ret; } - ret = samdb_msg_add_uint(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint(ldb, ac, msg, "msDs-KeyVersionNumber", io.g.kvno); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_add_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, ac->req->controls, ac, ph_op_callback, @@ -1828,6 +1859,7 @@ static int password_hash_add_do_add(struct ph_context *ac) { static int password_hash_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ph_context *ac; struct ldb_message_element *sambaAttr; struct ldb_message_element *clearTextAttr; @@ -1837,14 +1869,16 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r struct ldb_request *down_req; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "password_hash_modify\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "password_hash_modify\n"); if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.mod.message->dn) == 0) { return ldb_next_request(module, req); } @@ -1897,7 +1931,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r /* use a new message structure so that we can modify it */ msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -1913,7 +1947,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r return password_hash_mod_search_self(ac); } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, ph_modify_callback, @@ -1958,10 +1992,12 @@ static int ph_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ph_context *ac; int ret; ac = talloc_get_type(req->context, struct ph_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -1977,7 +2013,7 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are case LDB_REPLY_ENTRY: if (ac->search_res != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -1986,7 +2022,7 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are /* if it is not an entry of type person this is an error */ /* TODO: remove this when sambaPassword will be in schema */ if (!ldb_msg_check_string_attribute(ares->message, "objectClass", "person")) { - ldb_set_errstring(ac->module->ldb, "Object class violation"); + ldb_set_errstring(ldb, "Object class violation"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OBJECT_CLASS_VIOLATION); @@ -2002,7 +2038,7 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are ac->search_res->message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "can't handle entry without objectSid!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -2025,8 +2061,9 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are return LDB_SUCCESS; } -static int password_hash_mod_search_self(struct ph_context *ac) { - +static int password_hash_mod_search_self(struct ph_context *ac) +{ + struct ldb_context *ldb; static const char * const attrs[] = { "userAccountControl", "lmPwdHistory", "ntPwdHistory", "objectSid", "msDS-KeyVersionNumber", @@ -2038,7 +2075,9 @@ static int password_hash_mod_search_self(struct ph_context *ac) { struct ldb_request *search_req; int ret; - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectclass=*)", @@ -2054,8 +2093,9 @@ static int password_hash_mod_search_self(struct ph_context *ac) { return ldb_next_request(ac->module, search_req); } -static int password_hash_mod_do_mod(struct ph_context *ac) { - +static int password_hash_mod_do_mod(struct ph_context *ac) +{ + struct ldb_context *ldb; struct ldb_request *mod_req; struct smb_krb5_context *smb_krb5_context; struct ldb_message *msg; @@ -2064,6 +2104,8 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { struct setup_password_fields_io io; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* use a new message structure so that we can modify it */ msg = ldb_msg_new(ac); if (msg == NULL) { @@ -2075,8 +2117,8 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { /* Some operations below require kerberos contexts */ if (smb_krb5_init_context(ac, - ldb_get_event_context(ac->module->ldb), - (struct loadparm_context *)ldb_get_opaque(ac->module->ldb, "loadparm"), + ldb_get_event_context(ldb), + (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"), &smb_krb5_context) != 0) { return LDB_ERR_OPERATIONS_ERROR; } @@ -2119,14 +2161,14 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { ret = ldb_msg_add_empty(msg, "msDs-KeyVersionNumber", LDB_FLAG_MOD_REPLACE, NULL); if (io.g.nt_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "unicodePwd", io.g.nt_hash); if (ret != LDB_SUCCESS) { return ret; } } if (io.g.lm_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "dBCSPwd", io.g.lm_hash); if (ret != LDB_SUCCESS) { return ret; @@ -2157,20 +2199,20 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { return ret; } } - ret = samdb_msg_add_uint64(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint64(ldb, ac, msg, "pwdLastSet", io.g.last_set); if (ret != LDB_SUCCESS) { return ret; } - ret = samdb_msg_add_uint(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint(ldb, ac, msg, "msDs-KeyVersionNumber", io.g.kvno); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_mod_req(&mod_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, ac->req->controls, ac, ph_op_callback, diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c index 198b667358..fefaef4755 100644 --- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c @@ -21,9 +21,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" @@ -32,6 +30,7 @@ static int pdc_fsmo_init(struct ldb_module *module) { + struct ldb_context *ldb; TALLOC_CTX *mem_ctx; struct ldb_dn *pdc_dn; struct dsdb_pdc_fsmo *pdc_fsmo; @@ -42,15 +41,17 @@ static int pdc_fsmo_init(struct ldb_module *module) NULL }; + ldb = ldb_module_get_ctx(module); + mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - pdc_dn = samdb_base_dn(module->ldb); + pdc_dn = samdb_base_dn(ldb); if (!pdc_dn) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain dn present: (skip loading of domain details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); @@ -58,54 +59,54 @@ static int pdc_fsmo_init(struct ldb_module *module) pdc_fsmo = talloc_zero(mem_ctx, struct dsdb_pdc_fsmo); if (!pdc_fsmo) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = pdc_fsmo; + ldb_module_set_private(module, pdc_fsmo); - ret = ldb_search(module->ldb, mem_ctx, &pdc_res, + ret = ldb_search(ldb, mem_ctx, &pdc_res, pdc_dn, LDB_SCOPE_BASE, pdc_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } else if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "pdc_fsmo_init: failed to search the domain object: %d:%s", ret, ldb_strerror(ret)); talloc_free(mem_ctx); return ret; } if (pdc_res->count == 0) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } else if (pdc_res->count > 1) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "pdc_fsmo_init: [%u] domain objects found on a base search", pdc_res->count); talloc_free(mem_ctx); return LDB_ERR_CONSTRAINT_VIOLATION; } - pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner"); - if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), pdc_fsmo->master_dn) == 0) { + pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner"); + if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), pdc_fsmo->master_dn) == 0) { pdc_fsmo->we_are_master = true; } else { pdc_fsmo->we_are_master = false; } - if (ldb_set_opaque(module->ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) { - ldb_oom(module->ldb); + if (ldb_set_opaque(ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } talloc_steal(module, pdc_fsmo); - ldb_debug(module->ldb, LDB_DEBUG_TRACE, + ldb_debug(ldb, LDB_DEBUG_TRACE, "pdc_fsmo_init: we are master: %s\n", (pdc_fsmo->we_are_master?"yes":"no")); diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 23116be9ac..72b47c308d 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -37,9 +37,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "auth/credentials/credentials.h" struct proxy_data { @@ -64,7 +62,8 @@ struct proxy_ctx { */ static int load_proxy_info(struct ldb_module *module) { - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct proxy_data *proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); struct ldb_dn *dn; struct ldb_result *res = NULL; int ret; @@ -76,14 +75,14 @@ static int load_proxy_info(struct ldb_module *module) return LDB_SUCCESS; } - dn = ldb_dn_new(proxy, module->ldb, "@PROXYINFO"); + dn = ldb_dn_new(proxy, ldb, "@PROXYINFO"); if (dn == NULL) { goto failed; } - ret = ldb_search(module->ldb, proxy, &res, dn, LDB_SCOPE_BASE, NULL, NULL); + ret = ldb_search(ldb, proxy, &res, dn, LDB_SCOPE_BASE, NULL, NULL); talloc_free(dn); if (ret != LDB_SUCCESS || res->count != 1) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Can't find @PROXYINFO\n"); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Can't find @PROXYINFO\n"); goto failed; } @@ -96,47 +95,47 @@ static int load_proxy_info(struct ldb_module *module) newstr = ldb_msg_find_attr_as_string(res->msgs[0], "newstr", NULL); if (url == NULL || olddn == NULL || newdn == NULL || username == NULL || password == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Need url, olddn, newdn, oldstr, newstr, username and password in @PROXYINFO\n"); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Need url, olddn, newdn, oldstr, newstr, username and password in @PROXYINFO\n"); goto failed; } - proxy->olddn = ldb_dn_new(proxy, module->ldb, olddn); + proxy->olddn = ldb_dn_new(proxy, ldb, olddn); if (proxy->olddn == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Failed to explode olddn '%s'\n", olddn); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Failed to explode olddn '%s'\n", olddn); goto failed; } - proxy->newdn = ldb_dn_new(proxy, module->ldb, newdn); + proxy->newdn = ldb_dn_new(proxy, ldb, newdn); if (proxy->newdn == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Failed to explode newdn '%s'\n", newdn); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Failed to explode newdn '%s'\n", newdn); goto failed; } proxy->upstream = ldb_init(proxy, ldb_get_event_context(ldb)); if (proxy->upstream == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } proxy->oldstr = str_list_make(proxy, oldstr, ", "); if (proxy->oldstr == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } proxy->newstr = str_list_make(proxy, newstr, ", "); if (proxy->newstr == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } /* setup credentials for connection */ creds = cli_credentials_init(proxy->upstream); if (creds == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } - cli_credentials_guess(creds, ldb_get_opaque(module->ldb, "loadparm")); + cli_credentials_guess(creds, ldb_get_opaque(ldb, "loadparm")); cli_credentials_set_username(creds, username, CRED_SPECIFIED); cli_credentials_set_password(creds, password, CRED_SPECIFIED); @@ -144,11 +143,11 @@ static int load_proxy_info(struct ldb_module *module) ret = ldb_connect(proxy->upstream, url, 0, NULL); if (ret != 0) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "proxy failed to connect to %s\n", url); + ldb_debug(ldb, LDB_DEBUG_FATAL, "proxy failed to connect to %s\n", url); goto failed; } - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "proxy connected to %s\n", url); + ldb_debug(ldb, LDB_DEBUG_TRACE, "proxy connected to %s\n", url); talloc_free(res); @@ -256,12 +255,14 @@ static void proxy_convert_record(struct ldb_context *ldb, static int proxy_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct proxy_data *proxy; struct proxy_ctx *ac; int ret; ac = talloc_get_type(req->context, struct proxy_ctx); - proxy = talloc_get_type(ac->module->private_data, struct proxy_data); + ldb = ldb_module_get_ctx(ac->module); + proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -279,7 +280,7 @@ static int proxy_search_callback(struct ldb_request *req, #ifdef DEBUG_PROXY ac->count++; #endif - proxy_convert_record(ac->module->ldb, proxy, ares->message); + proxy_convert_record(ldb, proxy, ares->message); ret = ldb_module_send_entry(ac->req, ares->message, ares->controls); break; @@ -304,13 +305,16 @@ static int proxy_search_callback(struct ldb_request *req, /* search */ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct proxy_ctx *ac; struct ldb_parse_tree *newtree; - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); + struct proxy_data *proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); struct ldb_request *newreq; struct ldb_dn *base; int ret, i; + ldb = ldb_module_get_ctx(module); + if (req->op.search.base == NULL || (req->op.search.base->comp_num == 1 && req->op.search.base->components[0].name[0] == '@')) { @@ -347,13 +351,13 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re ldb_dn_remove_base_components(base, ldb_dn_get_comp_num(proxy->newdn)); ldb_dn_add_base(base, proxy->olddn); - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "proxying: '%s' with dn '%s' \n", + ldb_debug(ldb, LDB_DEBUG_FATAL, "proxying: '%s' with dn '%s' \n", ldb_filter_from_tree(ac, newreq->op.search.tree), ldb_dn_get_linearized(newreq->op.search.base)); for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "attr: '%s'\n", req->op.search.attrs[i]); + ldb_debug(ldb, LDB_DEBUG_FATAL, "attr: '%s'\n", req->op.search.attrs[i]); } - ret = ldb_build_search_req_ex(&newreq, module->ldb, ac, + ret = ldb_build_search_req_ex(&newreq, ldb, ac, base, req->op.search.scope, newtree, req->op.search.attrs, req->controls, @@ -364,16 +368,16 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re * for now this makes the module *not* ASYNC */ ret = ldb_request(proxy->upstream, newreq); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); + ldb_set_errstring(ldb, ldb_errstring(proxy->upstream)); } ret = ldb_wait(newreq->handle, LDB_WAIT_ALL); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); + ldb_set_errstring(ldb, ldb_errstring(proxy->upstream)); } return ret; failed: - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "proxy failed for %s\n", + ldb_debug(ldb, LDB_DEBUG_TRACE, "proxy failed for %s\n", ldb_dn_get_linearized(req->op.search.base)); passthru: diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c index eeb161bdde..8f36baa7d6 100644 --- a/source4/dsdb/samdb/ldb_modules/ranged_results.c +++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c @@ -29,7 +29,7 @@ * Author: Andrew Bartlett */ -#include "ldb_includes.h" +#include "ldb_module.h" struct rr_context { struct ldb_module *module; @@ -43,7 +43,7 @@ static struct rr_context *rr_init_context(struct ldb_module *module, ac = talloc_zero(req, struct rr_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb_module_get_ctx(module), "Out of Memory"); return NULL; } @@ -55,10 +55,12 @@ static struct rr_context *rr_init_context(struct ldb_module *module, static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct rr_context *ac; int i, j; ac = talloc_get_type(req->context, struct rr_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -106,7 +108,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) (size_t)(p - ac->req->op.search.attrs[i])); if (!new_attr) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -123,7 +125,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) } else { end_str = talloc_asprintf(el, "%u", end); if (!end_str) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -137,7 +139,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) orig_num_values = el->num_values; if ((start + end < start) || (start + end < end)) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "range request error: start or end would overflow!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_UNWILLING_TO_PERFORM); @@ -147,7 +149,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) el->values = talloc_array(el, struct ldb_val, (end - start) + 1); if (!el->values) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -158,7 +160,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) } el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str); if (!el->name) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -170,6 +172,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) /* search */ static int rr_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; int i; unsigned int start, end; const char **new_attrs = NULL; @@ -178,6 +181,8 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) struct rr_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Strip the range request from the attribute */ for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { char *p; @@ -194,14 +199,14 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) end = (unsigned int)-1; if (sscanf(p, ";range=%u-*", &start) != 1) { if (sscanf(p, ";range=%u-%u", &start, &end) != 2) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "range request error: " "range request malformed"); return LDB_ERR_UNWILLING_TO_PERFORM; } } if (start > end) { - ldb_asprintf_errstring(module->ldb, "range request error: start must not be greater than end"); + ldb_asprintf_errstring(ldb, "range request error: start must not be greater than end"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -210,7 +215,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) (size_t)(p - new_attrs[i])); if (!new_attrs[i]) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } } @@ -221,7 +226,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&down_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index f30748c85c..41f4e8e7d5 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -39,9 +39,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" #include "librpc/gen_ndr/ndr_misc.h" @@ -68,11 +66,14 @@ struct replmd_replicated_request { static struct replmd_replicated_request *replmd_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct replmd_replicated_request); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -204,9 +205,11 @@ static void replmd_ldb_message_sort(struct ldb_message *msg, static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; ac = talloc_get_type(req->context, struct replmd_replicated_request); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -218,7 +221,7 @@ static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -231,6 +234,7 @@ static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) static int replmd_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; const struct dsdb_schema *schema; enum ndr_err_code ndr_err; @@ -254,11 +258,13 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_add\n"); - schema = dsdb_get_schema(module->ldb); + schema = dsdb_get_schema(ldb); if (!schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_modify: no dsdb_schema loaded"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -271,13 +277,13 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) ac->schema = schema; if (ldb_msg_find_element(req->op.add.message, "objectGUID") != NULL) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "replmd_add: it's not allowed to add an object with objectGUID\n"); return LDB_ERR_UNWILLING_TO_PERFORM; } /* Get a sequence number from the backend */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return ret; } @@ -286,9 +292,9 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) guid = GUID_random(); /* get our invicationId */ - our_invocation_id = samdb_ntds_invocation_id(module->ldb); + our_invocation_id = samdb_ntds_invocation_id(ldb); if (!our_invocation_id) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "replmd_add: unable to find invocationId\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -296,7 +302,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -321,7 +327,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) */ ret = ldb_msg_add_string(msg, "whenCreated", time_str); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -333,7 +339,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) struct replPropertyMetaData1, nmd.ctr.ctr1.count); if (!nmd.ctr.ctr1.array) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -346,7 +352,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) sa = dsdb_attribute_by_lDAPDisplayName(schema, e->name); if (!sa) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "replmd_add: attribute '%s' not defined in schema\n", e->name); return LDB_ERR_NO_SUCH_ATTRIBUTE; @@ -386,15 +392,15 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) &guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ndr_err = ndr_push_struct_blob(&nmd_value, msg, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nmd, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -403,27 +409,27 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) */ ret = ldb_msg_add_value(msg, "objectGUID", &guid_value, NULL); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "whenChanged", time_str); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = samdb_msg_add_uint64(module->ldb, msg, msg, "uSNCreated", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNCreated", seq_num); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = samdb_msg_add_uint64(module->ldb, msg, msg, "uSNChanged", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_value(msg, "replPropertyMetaData", &nmd_value, NULL); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -432,7 +438,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) */ replmd_ldb_message_sort(msg, schema); - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, req->controls, ac, replmd_op_callback, @@ -447,6 +453,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) static int replmd_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; const struct dsdb_schema *schema; struct ldb_request *down_req; @@ -460,11 +467,13 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); - schema = dsdb_get_schema(module->ldb); + schema = dsdb_get_schema(ldb); if (!schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_modify: no dsdb_schema loaded"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -501,7 +510,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) } /* Get a sequence number from the backend */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNChanged", seq_num) != LDB_SUCCESS) { talloc_free(ac); @@ -514,7 +523,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) * - replace the old object with the newly constructed one */ - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, replmd_op_callback, @@ -545,10 +554,12 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar); static int replmd_replicated_apply_add_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); int ret; + ldb = ldb_module_get_ctx(ar->module); if (!ares) { return ldb_module_done(ar->req, NULL, NULL, @@ -560,7 +571,7 @@ static int replmd_replicated_apply_add_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + ldb_set_errstring(ldb, "Invalid reply type\n!"); return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -578,6 +589,7 @@ static int replmd_replicated_apply_add_callback(struct ldb_request *req, static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; @@ -596,10 +608,11 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) * same name exist */ + ldb = ldb_module_get_ctx(ar->module); msg = ar->objs->objects[ar->index_current].msg; md = ar->objs->objects[ar->index_current].meta_data; - ret = ldb_sequence_number(ar->module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -614,12 +627,12 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) return replmd_replicated_request_error(ar, ret); } - ret = samdb_msg_add_uint64(ar->module->ldb, msg, msg, "uSNCreated", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNCreated", seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } - ret = samdb_msg_add_uint64(ar->module->ldb, msg, msg, "uSNChanged", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -631,7 +644,7 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) md->ctr.ctr1.array[i].local_usn = seq_num; } ndr_err = ndr_push_struct_blob(&md_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), md, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -646,7 +659,7 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) replmd_ldb_message_sort(msg, ar->schema); ret = ldb_build_add_req(&change_req, - ar->module->ldb, + ldb, ar, msg, ar->controls, @@ -682,10 +695,13 @@ static int replmd_replPropertyMetaData1_conflict_compare(struct replPropertyMeta static int replmd_replicated_apply_merge_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); int ret; + ldb = ldb_module_get_ctx(ar->module); + if (!ares) { return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -696,7 +712,7 @@ static int replmd_replicated_apply_merge_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + ldb_set_errstring(ldb, "Invalid reply type\n!"); return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -714,6 +730,7 @@ static int replmd_replicated_apply_merge_callback(struct ldb_request *req, static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; @@ -727,6 +744,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) uint64_t seq_num; int ret; + ldb = ldb_module_get_ctx(ar->module); msg = ar->objs->objects[ar->index_current].msg; rmd = ar->objs->objects[ar->index_current].meta_data; ZERO_STRUCT(omd); @@ -736,15 +754,15 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) * TODO: add rename conflict handling */ if (ldb_dn_compare(msg->dn, ar->search_msg->dn) != 0) { - ldb_debug_set(ar->module->ldb, LDB_DEBUG_FATAL, "replmd_replicated_apply_merge[%u]: rename not supported", + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_replicated_apply_merge[%u]: rename not supported", ar->index_current); - ldb_debug(ar->module->ldb, LDB_DEBUG_FATAL, "%s => %s\n", + ldb_debug(ldb, LDB_DEBUG_FATAL, "%s => %s\n", ldb_dn_get_linearized(ar->search_msg->dn), ldb_dn_get_linearized(msg->dn)); return replmd_replicated_request_werror(ar, WERR_NOT_SUPPORTED); } - ret = ldb_sequence_number(ar->module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -753,7 +771,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) omd_value = ldb_msg_find_ldb_val(ar->search_msg, "replPropertyMetaData"); if (omd_value) { ndr_err = ndr_pull_struct_blob(omd_value, ar, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), &omd, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &omd, (ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -837,7 +855,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) /* create the meta data value */ ndr_err = ndr_push_struct_blob(&nmd_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nmd, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -849,14 +867,14 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) * check if some replicated attributes left, otherwise skip the ldb_modify() call */ if (msg->num_elements == 0) { - ldb_debug(ar->module->ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: skip replace\n", + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: skip replace\n", ar->index_current); ar->index_current++; return replmd_replicated_apply_next(ar); } - ldb_debug(ar->module->ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: replace %u attributes\n", + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: replace %u attributes\n", ar->index_current, msg->num_elements); /* @@ -867,7 +885,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } - ret = samdb_msg_add_uint64(ar->module->ldb, msg, msg, "uSNChanged", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -884,7 +902,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) } ret = ldb_build_mod_req(&change_req, - ar->module->ldb, + ldb, ar, msg, ar->controls, @@ -941,6 +959,7 @@ static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *a static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; int ret; char *tmp_str; char *filter; @@ -951,6 +970,7 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) return replmd_replicated_uptodate_vector(ar); } + ldb = ldb_module_get_ctx(ar->module); ar->search_msg = NULL; tmp_str = ldb_binary_encode(ar, ar->objs->objects[ar->index_current].guid_value); @@ -961,7 +981,7 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) talloc_free(tmp_str); ret = ldb_build_search_req(&search_req, - ar->module->ldb, + ldb, ar, ar->objs->partition_dn, LDB_SCOPE_SUBTREE, @@ -979,8 +999,10 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) static int replmd_replicated_uptodate_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); + ldb = ldb_module_get_ctx(ar->module); if (!ares) { return ldb_module_done(ar->req, NULL, NULL, @@ -992,7 +1014,7 @@ static int replmd_replicated_uptodate_modify_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + ldb_set_errstring(ldb, "Invalid reply type\n!"); return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1010,6 +1032,7 @@ static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplic static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; @@ -1031,6 +1054,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a NTTIME now; int ret; + ldb = ldb_module_get_ctx(ar->module); ruv = ar->objs->uptodateness_vector; ZERO_STRUCT(ouv); ouv.version = 2; @@ -1044,7 +1068,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a * because we will do a modify request and this will increment * our highest_usn */ - ret = ldb_sequence_number(ar->module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -1055,7 +1079,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a ouv_value = ldb_msg_find_ldb_val(ar->search_msg, "replUpToDateVector"); if (ouv_value) { ndr_err = ndr_pull_struct_blob(ouv_value, ar, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), &ouv, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &ouv, (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -1087,7 +1111,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a } /* get our invocation_id if we have one already attached to the ldb */ - our_invocation_id = samdb_ntds_invocation_id(ar->module->ldb); + our_invocation_id = samdb_ntds_invocation_id(ldb); /* merge in the source_dsa vector is available */ for (i=0; (ruv && i < ruv->count); i++) { @@ -1181,7 +1205,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a msg->dn = ar->search_msg->dn; ndr_err = ndr_push_struct_blob(&nuv_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nuv, (ndr_push_flags_fn_t)ndr_push_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -1219,7 +1243,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a trf = talloc(ar, struct repsFromToBlob); if (!trf) return replmd_replicated_request_werror(ar, WERR_NOMEM); - ndr_err = ndr_pull_struct_blob(&orf_el->values[i], trf, lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), trf, + ndr_err = ndr_pull_struct_blob(&orf_el->values[i], trf, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), trf, (ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -1270,7 +1294,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a /* we now fill the value which is already attached to ldb_message */ ndr_err = ndr_push_struct_blob(nrf_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nrf, (ndr_push_flags_fn_t)ndr_push_repsFromToBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -1286,7 +1310,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a /* prepare the ldb_modify() request */ ret = ldb_build_mod_req(&change_req, - ar->module->ldb, + ldb, ar, msg, ar->controls, @@ -1342,6 +1366,7 @@ static int replmd_replicated_uptodate_search_callback(struct ldb_request *req, static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; int ret; static const char *attrs[] = { "replUpToDateVector", @@ -1350,10 +1375,11 @@ static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *a }; struct ldb_request *search_req; + ldb = ldb_module_get_ctx(ar->module); ar->search_msg = NULL; ret = ldb_build_search_req(&search_req, - ar->module->ldb, + ldb, ar, ar->objs->partition_dn, LDB_SCOPE_BASE, @@ -1370,21 +1396,24 @@ static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *a static int replmd_extended_replicated_objects(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct dsdb_extended_replicated_objects *objs; struct replmd_replicated_request *ar; struct ldb_control **ctrls; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_extended_replicated_objects\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_extended_replicated_objects\n"); objs = talloc_get_type(req->op.extended.data, struct dsdb_extended_replicated_objects); if (!objs) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: invalid extended data\n"); + ldb_debug(ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: invalid extended data\n"); return LDB_ERR_PROTOCOL_ERROR; } if (objs->version != DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: extended data invalid version [%u != %u]\n", + ldb_debug(ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: extended data invalid version [%u != %u]\n", objs->version, DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION); return LDB_ERR_PROTOCOL_ERROR; } @@ -1394,9 +1423,9 @@ static int replmd_extended_replicated_objects(struct ldb_module *module, struct return LDB_ERR_OPERATIONS_ERROR; ar->objs = objs; - ar->schema = dsdb_get_schema(module->ldb); + ar->schema = dsdb_get_schema(ldb); if (!ar->schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "replmd_ctx_init: no loaded schema found\n"); + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_ctx_init: no loaded schema found\n"); talloc_free(ar); return LDB_ERR_CONSTRAINT_VIOLATION; } diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 461a554ec0..9ae894d55f 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -21,9 +21,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_private.h" #include "system/time.h" #include "dsdb/samdb/samdb.h" #include "version.h" @@ -56,13 +54,15 @@ static int do_attribute_explicit(const char * const *attrs, const char *name) */ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *msg, const char * const *attrs) { - struct private_data *priv = talloc_get_type(module->private_data, struct private_data); + struct ldb_context *ldb; + struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data); char **server_sasl; const struct dsdb_schema *schema; - schema = dsdb_get_schema(module->ldb); + ldb = ldb_module_get_ctx(module); + schema = dsdb_get_schema(ldb); - msg->dn = ldb_dn_new(msg, module->ldb, NULL); + msg->dn = ldb_dn_new(msg, ldb, NULL); /* don't return the distinduishedName, cn and name attributes */ ldb_msg_remove_attr(msg, "distinguishedName"); @@ -101,7 +101,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms } } - server_sasl = talloc_get_type(ldb_get_opaque(module->ldb, "supportedSASLMechanims"), + server_sasl = talloc_get_type(ldb_get_opaque(ldb, "supportedSASLMechanims"), char *); if (server_sasl && do_attribute(attrs, "supportedSASLMechanisms")) { int i; @@ -119,7 +119,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms if (do_attribute(attrs, "highestCommittedUSN")) { uint64_t seq_num; - int ret = ldb_sequence_number(module->ldb, LDB_SEQ_HIGHEST_SEQ, &seq_num); + int ret = ldb_sequence_number(ldb, LDB_SEQ_HIGHEST_SEQ, &seq_num); if (ret == LDB_SUCCESS) { if (ldb_msg_add_fmt(msg, "highestCommittedUSN", "%llu", (unsigned long long)seq_num) != 0) { @@ -169,7 +169,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms const char *dn_str; if (schema && schema->fsmo.we_are_master) { - dn_str = ldb_dn_get_linearized(samdb_schema_dn(module->ldb)); + dn_str = ldb_dn_get_linearized(samdb_schema_dn(ldb)); if (dn_str && dn_str[0]) { if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) { goto failed; @@ -177,10 +177,10 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms } } - naming_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_naming_fsmo"), + naming_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_naming_fsmo"), struct dsdb_naming_fsmo); if (naming_fsmo && naming_fsmo->we_are_master) { - dn_str = ldb_dn_get_linearized(samdb_partitions_dn(module->ldb, msg)); + dn_str = ldb_dn_get_linearized(samdb_partitions_dn(ldb, msg)); if (dn_str && dn_str[0]) { if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) { goto failed; @@ -188,10 +188,10 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms } } - pdc_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_pdc_fsmo"), + pdc_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_pdc_fsmo"), struct dsdb_pdc_fsmo); if (pdc_fsmo && pdc_fsmo->we_are_master) { - dn_str = ldb_dn_get_linearized(samdb_base_dn(module->ldb)); + dn_str = ldb_dn_get_linearized(samdb_base_dn(ldb)); if (dn_str && dn_str[0]) { if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) { goto failed; @@ -227,11 +227,14 @@ struct rootdse_context { static struct rootdse_context *rootdse_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct rootdse_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct rootdse_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -296,10 +299,13 @@ static int rootdse_callback(struct ldb_request *req, struct ldb_reply *ares) static int rootdse_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct rootdse_context *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + /* see if its for the rootDSE - only a base search on the "" DN qualifies */ if (!(req->op.search.scope == LDB_SCOPE_BASE && ldb_dn_is_null(req->op.search.base))) { /* Otherwise, pass down to the rest of the stack */ @@ -312,8 +318,8 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req) } /* in our db we store the rootDSE with a DN of @ROOTDSE */ - ret = ldb_build_search_req(&down_req, module->ldb, ac, - ldb_dn_new(ac, module->ldb, "@ROOTDSE"), + ret = ldb_build_search_req(&down_req, ldb, ac, + ldb_dn_new(ac, ldb, "@ROOTDSE"), LDB_SCOPE_BASE, NULL, req->op.search.attrs, @@ -329,7 +335,7 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req) static int rootdse_register_control(struct ldb_module *module, struct ldb_request *req) { - struct private_data *priv = talloc_get_type(module->private_data, struct private_data); + struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data); char **list; list = talloc_realloc(priv, priv->controls, char *, priv->num_controls + 1); @@ -350,7 +356,7 @@ static int rootdse_register_control(struct ldb_module *module, struct ldb_reques static int rootdse_register_partition(struct ldb_module *module, struct ldb_request *req) { - struct private_data *priv = talloc_get_type(module->private_data, struct private_data); + struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data); struct ldb_dn **list; list = talloc_realloc(priv, priv->partitions, struct ldb_dn *, priv->num_partitions + 1); @@ -387,8 +393,11 @@ static int rootdse_request(struct ldb_module *module, struct ldb_request *req) static int rootdse_init(struct ldb_module *module) { + struct ldb_context *ldb; struct private_data *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { return -1; @@ -398,15 +407,16 @@ static int rootdse_init(struct ldb_module *module) data->controls = NULL; data->num_partitions = 0; data->partitions = NULL; - module->private_data = data; + ldb_module_set_private(module, data); - ldb_set_default_dns(module->ldb); + ldb_set_default_dns(ldb); return ldb_next_init(module); } static int rootdse_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_result *ext_res; int ret; struct ldb_dn *schema_dn; @@ -418,7 +428,9 @@ static int rootdse_modify(struct ldb_module *module, struct ldb_request *req) if (!ldb_dn_is_null(req->op.mod.message->dn)) { return ldb_next_request(module, req); } - + + ldb = ldb_module_get_ctx(module); + /* dn is empty so check for schemaUpdateNow attribute "The type of modification and values specified in the LDAP modify operation do not matter." MSDN @@ -428,15 +440,15 @@ static int rootdse_modify(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - schema_dn = samdb_schema_dn(module->ldb); + schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "rootdse_modify: no schema dn present: (skip ldb_extended call)\n"); return ldb_next_request(module, req); } - ret = ldb_extended(module->ldb, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, schema_dn, &ext_res); + ret = ldb_extended(ldb, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, schema_dn, &ext_res); if (ret != LDB_SUCCESS) { return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c index 7a123c818f..3f10748085 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sam.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c @@ -6,9 +6,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" -#include "ldb/include/ldb_errors.h" +#include "ldb/include/ldb_module.h" #include "ldb/ldb_map/ldb_map.h" #include "system/passwd.h" @@ -118,20 +116,23 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char static struct ldb_val convert_uid_samaccount(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { struct ldb_val out = data_blob(NULL, 0); - ldb_handler_copy(module->ldb, ctx, val, &out); + out = ldb_val_dup(ctx, val); return out; } static struct ldb_val lookup_homedir(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { + struct ldb_context *ldb; struct passwd *pwd; struct ldb_val retval; - + + ldb = ldb_module_get_ctx(module); + pwd = getpwnam((char *)val->data); if (!pwd) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data); + ldb_debug(ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data); return *talloc_zero(ctx, struct ldb_val); } @@ -145,7 +146,7 @@ static struct ldb_val lookup_gid(struct ldb_module *module, TALLOC_CTX *ctx, con { struct passwd *pwd; struct ldb_val retval; - + pwd = getpwnam((char *)val->data); if (!pwd) { diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 5ab577c33d..65e36416f1 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -34,10 +34,7 @@ #include "includes.h" #include "libcli/ldap/ldap_ndr.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_private.h" -#include "lib/events/events.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_security.h" @@ -83,11 +80,14 @@ struct samldb_ctx { static struct samldb_ctx *samldb_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct samldb_ctx *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct samldb_ctx); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -144,10 +144,12 @@ static int samldb_next_step(struct samldb_ctx *ac) static int samldb_search_template_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -163,7 +165,7 @@ static int samldb_search_template_callback(struct ldb_request *req, /* save entry */ if (ac->ares != NULL) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for template objects"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -197,6 +199,7 @@ done: static int samldb_search_template(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct tevent_context *ev; struct loadparm_context *lparm_ctx; struct ldb_context *templates_ldb; @@ -206,31 +209,33 @@ static int samldb_search_template(struct samldb_ctx *ac) void *opaque; int ret; - opaque = ldb_get_opaque(ac->module->ldb, "loadparm"); + ldb = ldb_module_get_ctx(ac->module); + + opaque = ldb_get_opaque(ldb, "loadparm"); lparm_ctx = talloc_get_type(opaque, struct loadparm_context); if (lparm_ctx == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Unable to find loadparm context\n"); return LDB_ERR_OPERATIONS_ERROR; } - opaque = ldb_get_opaque(ac->module->ldb, "templates_ldb"); + opaque = ldb_get_opaque(ldb, "templates_ldb"); templates_ldb = talloc_get_type(opaque, struct ldb_context); /* make sure we have the templates ldb */ if (!templates_ldb) { - templates_ldb_path = samdb_relative_path(ac->module->ldb, ac, + templates_ldb_path = samdb_relative_path(ldb, ac, "templates.ldb"); if (!templates_ldb_path) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "samldb_init_template: ERROR: Failed " "to contruct path for template db"); return LDB_ERR_OPERATIONS_ERROR; } - ev = ldb_get_event_context(ac->module->ldb); + ev = ldb_get_event_context(ldb); - templates_ldb = ldb_wrap_connect(ac->module->ldb, ev, + templates_ldb = ldb_wrap_connect(ldb, ev, lparm_ctx, templates_ldb_path, NULL, NULL, 0, NULL); talloc_free(templates_ldb_path); @@ -243,7 +248,7 @@ static int samldb_search_template(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_set_opaque(ac->module->ldb, + ret = ldb_set_opaque(ldb, "templates_ldb", templates_ldb); if (ret != LDB_SUCCESS) { return ret; @@ -254,7 +259,7 @@ static int samldb_search_template(struct samldb_ctx *ac) basedn = ldb_dn_new_fmt(ac, templates_ldb, "cn=Template%s,cn=Templates", ac->type); if (basedn == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "samldb_init_template: ERROR: Failed " "to contruct DN for template"); return LDB_ERR_OPERATIONS_ERROR; @@ -279,11 +284,13 @@ static int samldb_search_template(struct samldb_ctx *ac) static int samldb_apply_template(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct ldb_message_element *el; struct ldb_message *msg; int i, j; int ret; + ldb = ldb_module_get_ctx(ac->module); msg = ac->ares->message; for (i = 0; i < msg->num_elements; i++) { @@ -300,10 +307,10 @@ static int samldb_apply_template(struct samldb_ctx *ac) } for (j = 0; j < el->num_values; j++) { ret = samdb_find_or_add_attribute( - ac->module->ldb, ac->msg, el->name, + ldb, ac->msg, el->name, (char *)el->values[j].data); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Failed adding template attribute\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -318,11 +325,13 @@ static int samldb_get_parent_domain(struct samldb_ctx *ac); static int samldb_get_parent_domain_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; const char *nextRid; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -338,7 +347,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, /* save entry */ if (ac->domain_dn != NULL) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for domain object"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -348,7 +357,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, nextRid = ldb_msg_find_attr_as_string(ares->message, "nextRid", NULL); if (nextRid == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "while looking for domain above %s attribute nextRid not found in %s\n", ldb_dn_get_linearized(ac->req->op.add.message->dn), ldb_dn_get_linearized(ares->message->dn)); @@ -361,7 +370,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, ac->domain_sid = samdb_result_dom_sid(ac, ares->message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "error retrieving parent domain domain sid!\n"); ret = LDB_ERR_CONSTRAINT_VIOLATION; break; @@ -370,7 +379,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, talloc_free(ares); ret = LDB_SUCCESS; - ldb_reset_err_string(ac->module->ldb); + ldb_reset_err_string(ldb); break; case LDB_REPLY_REFERRAL: @@ -403,25 +412,28 @@ done: /* Find a domain object in the parents of a particular DN. */ static int samldb_get_parent_domain(struct samldb_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[3] = { "objectSid", "nextRid", NULL }; struct ldb_request *req; struct ldb_dn *dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->check_dn == NULL) { return LDB_ERR_OPERATIONS_ERROR; } dn = ldb_dn_get_parent(ac, ac->check_dn); if (dn == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Unable to find parent domain object"); return LDB_ERR_CONSTRAINT_VIOLATION; } ac->check_dn = dn; - ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ret = ldb_build_search_req(&req, ldb, ac, dn, LDB_SCOPE_BASE, "(|(objectClass=domain)" "(objectClass=builtinDomain)" @@ -503,11 +515,14 @@ done: static int samldb_check_samAccountName(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct ldb_request *req; const char *name; char *filter; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ldb_msg_find_element(ac->msg, "samAccountName") == NULL) { ret = samldb_generate_samAccountName(ac->msg); if (ret != LDB_SUCCESS) { @@ -524,7 +539,7 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ret = ldb_build_search_req(&req, ldb, ac, ac->domain_dn, LDB_SCOPE_SUBTREE, filter, NULL, NULL, @@ -540,14 +555,17 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac) static int samldb_check_samAccountType(struct samldb_ctx *ac) { + struct ldb_context *ldb; unsigned int account_type; unsigned int group_type; unsigned int uac; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* make sure sAMAccountType is not specified */ if (ldb_msg_find_element(ac->msg, "sAMAccountType") != NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "sAMAccountType must not be specified"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -555,12 +573,12 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) if (strcmp("user", ac->type) == 0) { uac = samdb_result_uint(ac->msg, "userAccountControl", 0); if (uac == 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "userAccountControl invalid"); return LDB_ERR_UNWILLING_TO_PERFORM; } else { account_type = samdb_uf2atype(uac); - ret = samdb_msg_add_uint(ac->module->ldb, + ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "sAMAccountType", account_type); @@ -573,12 +591,12 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) group_type = samdb_result_uint(ac->msg, "groupType", 0); if (group_type == 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "groupType invalid"); return LDB_ERR_UNWILLING_TO_PERFORM; } else { account_type = samdb_gtype2atype(group_type); - ret = samdb_msg_add_uint(ac->module->ldb, + ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "sAMAccountType", account_type); @@ -594,11 +612,13 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) static int samldb_get_sid_domain_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; const char *nextRid; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -614,7 +634,7 @@ static int samldb_get_sid_domain_callback(struct ldb_request *req, /* save entry */ if (ac->next_rid != 0) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for domain object"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -624,7 +644,7 @@ static int samldb_get_sid_domain_callback(struct ldb_request *req, nextRid = ldb_msg_find_attr_as_string(ares->message, "nextRid", NULL); if (nextRid == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "attribute nextRid not found in %s\n", ldb_dn_get_linearized(ares->message->dn)); ret = LDB_ERR_OPERATIONS_ERROR; @@ -648,7 +668,7 @@ static int samldb_get_sid_domain_callback(struct ldb_request *req, case LDB_REPLY_DONE: if (ac->next_rid == 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "Unable to get nextRid from domain entry\n"); ret = LDB_ERR_OPERATIONS_ERROR; break; @@ -670,11 +690,14 @@ done: /* Find a domain object in the parents of a particular DN. */ static int samldb_get_sid_domain(struct samldb_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[2] = { "nextRid", NULL }; struct ldb_request *req; char *filter; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->sid == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -695,8 +718,8 @@ static int samldb_get_sid_domain(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + ret = ldb_build_search_req(&req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -793,6 +816,7 @@ done: static int samldb_check_sid(struct samldb_ctx *ac) { + struct ldb_context *ldb; const char *const attrs[2] = { "objectSid", NULL }; struct ldb_request *req; char *filter; @@ -802,14 +826,16 @@ static int samldb_check_sid(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } + ldb = ldb_module_get_ctx(ac->module); + filter = talloc_asprintf(ac, "(objectSid=%s)", ldap_encode_ndr_dom_sid(ac, ac->sid)); if (filter == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + ret = ldb_build_search_req(&req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -826,10 +852,12 @@ static int samldb_check_sid(struct samldb_ctx *ac) static int samldb_notice_sid_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -840,7 +868,7 @@ static int samldb_notice_sid_callback(struct ldb_request *req, ares->response, ares->error); } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid reply type!\n"); ret = LDB_ERR_OPERATIONS_ERROR; goto done; @@ -861,6 +889,7 @@ done: *atomically. */ static int samldb_notice_sid(struct samldb_ctx *ac) { + struct ldb_context *ldb; uint32_t old_id, new_id; struct ldb_request *req; struct ldb_message *msg; @@ -868,6 +897,7 @@ static int samldb_notice_sid(struct samldb_ctx *ac) struct ldb_val *vals; int ret; + ldb = ldb_module_get_ctx(ac->module); old_id = ac->next_rid; new_id = ac->sid->sub_auths[ac->sid->num_auths - 1]; @@ -880,17 +910,17 @@ static int samldb_notice_sid(struct samldb_ctx *ac) a race, in case we are not actually on a transaction db */ msg = talloc_zero(ac, struct ldb_message); if (msg == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } els = talloc_array(msg, struct ldb_message_element, 2); if (els == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } vals = talloc_array(msg, struct ldb_val, 2); if (vals == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } msg->dn = ac->domain_dn; @@ -902,7 +932,7 @@ static int samldb_notice_sid(struct samldb_ctx *ac) els[0].flags = LDB_FLAG_MOD_DELETE; els[0].name = talloc_strdup(msg, "nextRid"); if (!els[0].name) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -913,19 +943,19 @@ static int samldb_notice_sid(struct samldb_ctx *ac) vals[0].data = (uint8_t *)talloc_asprintf(vals, "%u", old_id); if (!vals[0].data) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } vals[0].length = strlen((char *)vals[0].data); vals[1].data = (uint8_t *)talloc_asprintf(vals, "%u", new_id); if (!vals[1].data) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } vals[1].length = strlen((char *)vals[1].data); - ret = ldb_build_mod_req(&req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&req, ldb, ac, msg, NULL, ac, samldb_notice_sid_callback, ac->req); @@ -939,9 +969,11 @@ static int samldb_notice_sid(struct samldb_ctx *ac) static int samldb_add_entry_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -952,7 +984,7 @@ static int samldb_add_entry_callback(struct ldb_request *req, ares->response, ares->error); } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid reply type!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -965,10 +997,13 @@ static int samldb_add_entry_callback(struct ldb_request *req, static int samldb_add_entry(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct ldb_request *req; int ret; - ret = ldb_build_add_req(&req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_add_req(&req, ldb, ac, ac->msg, ac->req->controls, ac, samldb_add_entry_callback, @@ -1037,12 +1072,14 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type) static int samldb_foreign_notice_sid_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; const char *nextRid; const char *name; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -1058,7 +1095,7 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req, /* save entry */ if (ac->next_rid != 0) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for domain object"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -1068,7 +1105,7 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req, nextRid = ldb_msg_find_attr_as_string(ares->message, "nextRid", NULL); if (nextRid == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "while looking for forign sid %s attribute nextRid not found in %s\n", dom_sid_string(ares, ac->sid), ldb_dn_get_linearized(ares->message->dn)); ret = LDB_ERR_OPERATIONS_ERROR; @@ -1080,7 +1117,7 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req, ac->domain_dn = talloc_steal(ac, ares->message->dn); name = samdb_result_string(ares->message, "name", NULL); - ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, + ldb_debug(ldb, LDB_DEBUG_TRACE, "NOTE (strange but valid): Adding foreign SID " "record with SID %s, but this domain (%s) is " "not foreign in the database", @@ -1118,12 +1155,15 @@ done: /* Find a domain object in the parents of a particular DN. */ static int samldb_foreign_notice_sid(struct samldb_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[3] = { "nextRid", "name", NULL }; struct ldb_request *req; NTSTATUS status; char *filter; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->sid == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1139,8 +1179,8 @@ static int samldb_foreign_notice_sid(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + ret = ldb_build_search_req(&req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -1157,14 +1197,17 @@ static int samldb_foreign_notice_sid(struct samldb_ctx *ac) static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + ac->sid = samdb_result_dom_sid(ac->msg, ac->msg, "objectSid"); if (ac->sid == NULL) { ac->sid = dom_sid_parse_talloc(ac->msg, (const char *)ldb_dn_get_rdn_val(ac->msg->dn)->data); if (!ac->sid) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "No valid found SID in " "ForeignSecurityPrincipal CN!"); talloc_free(ac); @@ -1202,12 +1245,14 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac) static int samldb_check_rdn(struct ldb_module *module, struct ldb_dn *dn) { + struct ldb_context *ldb; const char *rdn_name; + ldb = ldb_module_get_ctx(module); rdn_name = ldb_dn_get_rdn_name(dn); if (strcasecmp(rdn_name, "cn") != 0) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Bad RDN (%s=) for samldb object, " "should be CN=!\n", rdn_name); return LDB_ERR_CONSTRAINT_VIOLATION; @@ -1219,10 +1264,12 @@ static int samldb_check_rdn(struct ldb_module *module, struct ldb_dn *dn) /* add_record */ static int samldb_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct samldb_ctx *ac; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_add_record\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "samldb_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -1238,17 +1285,17 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) ac->msg = ldb_msg_copy(ac, ac->req->op.add.message); if (!ac->msg) { talloc_free(ac); - ldb_debug(ac->module->ldb, LDB_DEBUG_FATAL, + ldb_debug(ldb, LDB_DEBUG_FATAL, "samldb_add: ldb_msg_copy failed!\n"); return LDB_ERR_OPERATIONS_ERROR; } - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "computer") != NULL) { /* make sure the computer object also has the 'user' * objectclass so it will be handled by the next call */ - ret = samdb_find_or_add_value(module->ldb, ac->msg, + ret = samdb_find_or_add_value(ldb, ac->msg, "objectclass", "user"); if (ret != LDB_SUCCESS) { talloc_free(ac); @@ -1256,7 +1303,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) } } - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "user") != NULL) { ret = samldb_check_rdn(module, ac->req->op.add.message->dn); @@ -1268,7 +1315,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) return samldb_fill_object(ac, "user"); } - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "group") != NULL) { ret = samldb_check_rdn(module, ac->req->op.add.message->dn); @@ -1281,7 +1328,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) } /* perhaps a foreignSecurityPrincipal? */ - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "foreignSecurityPrincipal") != NULL) { @@ -1303,6 +1350,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) /* modify */ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_message *msg; struct ldb_message_element *el, *el2; int ret; @@ -1311,8 +1359,10 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + ldb = ldb_module_get_ctx(module); + if (ldb_msg_find_element(req->op.mod.message, "sAMAccountType") != NULL) { - ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified"); + ldb_asprintf_errstring(ldb, "sAMAccountType must not be specified"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -1324,7 +1374,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) group_type = strtoul((const char *)el->values[0].data, NULL, 0); account_type = samdb_gtype2atype(group_type); - ret = samdb_msg_add_uint(module->ldb, msg, msg, + ret = samdb_msg_add_uint(ldb, msg, msg, "sAMAccountType", account_type); if (ret != LDB_SUCCESS) { @@ -1340,7 +1390,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) user_account_control = strtoul((const char *)el->values[0].data, NULL, 0); account_type = samdb_uf2atype(user_account_control); - ret = samdb_msg_add_uint(module->ldb, msg, msg, + ret = samdb_msg_add_uint(ldb, msg, msg, "sAMAccountType", account_type); if (ret != LDB_SUCCESS) { diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index bfcf239f3a..edd451255e 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -22,14 +22,11 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "../lib/util/dlinklist.h" #include "param/param.h" static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg, @@ -82,6 +79,7 @@ struct schema_fsmo_search_data { static int schema_fsmo_init(struct ldb_module *module) { + struct ldb_context *ldb; TALLOC_CTX *mem_ctx; struct ldb_dn *schema_dn; struct dsdb_schema *schema; @@ -89,53 +87,54 @@ static int schema_fsmo_init(struct ldb_module *module) int ret; struct schema_fsmo_private_data *data; - schema_dn = samdb_schema_dn(module->ldb); + ldb = ldb_module_get_ctx(module); + schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_init: no schema dn present: (skip schema loading)\n"); return ldb_next_init(module); } data = talloc(module, struct schema_fsmo_private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } /* Check to see if this is a result on the CN=Aggregate schema */ data->aggregate_dn = ldb_dn_copy(data, schema_dn); if (!ldb_dn_add_child_fmt(data->aggregate_dn, "CN=Aggregate")) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; + ldb_module_set_private(module, data); - if (dsdb_get_schema(module->ldb)) { + if (dsdb_get_schema(ldb)) { return ldb_next_init(module); } mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = dsdb_schema_from_schema_dn(mem_ctx, module->ldb, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + ret = dsdb_schema_from_schema_dn(mem_ctx, ldb, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), schema_dn, &schema, &error_string); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_init: no schema head present: (skip schema loading)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "schema_fsmo_init: dsdb_schema load failed: %s", error_string); talloc_free(mem_ctx); @@ -143,9 +142,9 @@ static int schema_fsmo_init(struct ldb_module *module) } /* dsdb_set_schema() steal schema into the ldb_context */ - ret = dsdb_set_schema(module->ldb, schema); + ret = dsdb_set_schema(ldb, schema); if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "schema_fsmo_init: dsdb_set_schema() failed: %d:%s", ret, ldb_strerror(ret)); talloc_free(mem_ctx); @@ -158,6 +157,7 @@ static int schema_fsmo_init(struct ldb_module *module) static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct dsdb_schema *schema; const char *attributeID = NULL; const char *governsID = NULL; @@ -166,6 +166,8 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) uint32_t id32; WERROR status; + ldb = ldb_module_get_ctx(module); + /* special objects should always go through */ if (ldb_dn_is_special(req->op.add.message->dn)) { return ldb_next_request(module, req); @@ -176,13 +178,13 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - schema = dsdb_get_schema(module->ldb); + schema = dsdb_get_schema(ldb); if (!schema) { return ldb_next_request(module, req); } if (!schema->fsmo.we_are_master) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "schema_fsmo_add: we are not master: reject request\n"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -206,15 +208,15 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) if (W_ERROR_IS_OK(status)) { return ldb_next_request(module, req); } else if (!W_ERROR_EQUAL(WERR_DS_NO_MSDS_INTID, status)) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "schema_fsmo_add: failed to map %s[%s]: %s\n", oid_attr, oid, win_errstr(status)); return LDB_ERR_UNWILLING_TO_PERFORM; } - status = dsdb_create_prefix_mapping(module->ldb, schema, oid); + status = dsdb_create_prefix_mapping(ldb, schema, oid); if (!W_ERROR_IS_OK(status)) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "schema_fsmo_add: failed to create prefix mapping for %s[%s]: %s\n", oid_attr, oid, win_errstr(status)); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -225,44 +227,47 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_dn *schema_dn; struct dsdb_schema *schema; char *error_string = NULL; int ret; TALLOC_CTX *mem_ctx; - + + ldb = ldb_module_get_ctx(module); + if (strcmp(req->op.extended.oid, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID) != 0) { return ldb_next_request(module, req); } - schema_dn = samdb_schema_dn(module->ldb); + schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_extended: no schema dn present: (skip schema loading)\n"); return ldb_next_request(module, req); } mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = dsdb_schema_from_schema_dn(mem_ctx, module->ldb, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + ret = dsdb_schema_from_schema_dn(mem_ctx, ldb, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), schema_dn, &schema, &error_string); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_extended: no schema head present: (skip schema loading)\n"); talloc_free(mem_ctx); return ldb_next_request(module, req); } if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "schema_fsmo_extended: dsdb_schema load failed: %s", error_string); talloc_free(mem_ctx); @@ -270,9 +275,9 @@ static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *r } /* Replace the old schema*/ - ret = dsdb_set_schema(module->ldb, schema); + ret = dsdb_set_schema(ldb, schema); if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "schema_fsmo_extended: dsdb_set_schema() failed: %d:%s", ret, ldb_strerror(ret)); talloc_free(mem_ctx); @@ -286,11 +291,11 @@ static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *r static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg, const struct dsdb_schema *schema) { - const struct dsdb_class *class; + const struct dsdb_class *sclass; int ret; - for (class = schema->classes; class; class = class->next) { - ret = ldb_msg_add_string(msg, "objectClasses", schema_class_to_description(msg, class)); + for (sclass = schema->classes; sclass; sclass = sclass->next) { + ret = ldb_msg_add_string(msg, "objectClasses", schema_class_to_description(msg, sclass)); if (ret != LDB_SUCCESS) { return ret; } @@ -315,12 +320,12 @@ static int generate_attributeTypes(struct ldb_context *ldb, struct ldb_message * static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message *msg, const struct dsdb_schema *schema) { - const struct dsdb_class *class; + const struct dsdb_class *sclass; int ret; - for (class = schema->classes; class; class = class->next) { - if (class->auxiliaryClass || class->systemAuxiliaryClass) { - char *ditcontentrule = schema_class_to_dITContentRule(msg, class, schema); + for (sclass = schema->classes; sclass; sclass = sclass->next) { + if (sclass->auxiliaryClass || sclass->systemAuxiliaryClass) { + char *ditcontentrule = schema_class_to_dITContentRule(msg, sclass, schema); if (!ditcontentrule) { ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; @@ -385,12 +390,14 @@ static int generate_extendedClassInfo(struct ldb_context *ldb, */ static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct schema_fsmo_search_data *ac; struct schema_fsmo_private_data *mc; int i, ret; ac = talloc_get_type(req->context, struct schema_fsmo_search_data); - mc = talloc_get_type(ac->module->private_data, struct schema_fsmo_private_data); + mc = talloc_get_type(ldb_module_get_private(ac->module), struct schema_fsmo_private_data); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -411,7 +418,7 @@ static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply for (i=0; i < ARRAY_SIZE(generated_attrs); i++) { if (ldb_attr_in_list(ac->req->op.search.attrs, generated_attrs[i].attr)) { - ret = generated_attrs[i].fn(ac->module->ldb, ares->message, ac->schema); + ret = generated_attrs[i].fn(ldb, ares->message, ac->schema); if (ret != LDB_SUCCESS) { return ret; } @@ -436,12 +443,13 @@ static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply /* search */ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); int i, ret; struct schema_fsmo_search_data *search_context; struct ldb_request *down_req; - struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + struct dsdb_schema *schema = dsdb_get_schema(ldb); - if (!schema || !module->private_data) { + if (!schema || !ldb_module_get_private(module)) { /* If there is no schema, there is little we can do */ return ldb_next_request(module, req); } @@ -458,7 +466,7 @@ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req search_context = talloc(req, struct schema_fsmo_search_data); if (!search_context) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -466,7 +474,7 @@ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req search_context->req = req; search_context->schema = schema; - ret = ldb_build_search_req_ex(&down_req, module->ldb, search_context, + ret = ldb_build_search_req_ex(&down_req, ldb, search_context, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c index 0914e51ebe..d619558c21 100644 --- a/source4/dsdb/samdb/ldb_modules/show_deleted.c +++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c @@ -33,9 +33,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb/include/ldb_module.h" #include "dsdb/samdb/samdb.h" /* search */ @@ -79,6 +77,7 @@ static int show_deleted_search_callback(struct ldb_request *req, static int show_deleted_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_control *control; struct ldb_control **saved_controls; struct show_deleted_search_request *ar; @@ -87,6 +86,8 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re char *new_filter; int ret; + ldb = ldb_module_get_ctx(module); + ar = talloc_zero(req, struct show_deleted_search_request); if (ar == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -102,7 +103,7 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re new_filter = talloc_asprintf(ar, "(&(!(isDeleted=TRUE))%s)", old_filter); - ret = ldb_build_search_req(&down_req, module->ldb, ar, + ret = ldb_build_search_req(&down_req, ldb, ar, req->op.search.base, req->op.search.scope, new_filter, @@ -112,7 +113,7 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re req); } else { - ret = ldb_build_search_req_ex(&down_req, module->ldb, ar, + ret = ldb_build_search_req_ex(&down_req, ldb, ar, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -136,11 +137,14 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re static int show_deleted_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + ret = ldb_mod_register_control(module, LDB_CONTROL_SHOW_DELETED_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index 0e42f7869a..948241b094 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -27,9 +27,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" -#include "ldb/include/ldb_errors.h" +#include "ldb/include/ldb_module.h" #include "ldb/ldb_map/ldb_map.h" #include "librpc/gen_ndr/ndr_misc.h" @@ -105,7 +103,7 @@ static struct ldb_val guid_ns_string(struct ldb_module *module, TALLOC_CTX *ctx, static struct ldb_val val_copy(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { struct ldb_val out = data_blob(NULL, 0); - ldb_handler_copy(module->ldb, ctx, val, &out); + out = ldb_val_dup(ctx, val); return out; } @@ -113,10 +111,11 @@ static struct ldb_val val_copy(struct ldb_module *module, TALLOC_CTX *ctx, const /* Ensure we always convert sids into binary, so the backend doesn't have to know about both forms */ static struct ldb_val sid_always_binary(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_val out = data_blob(NULL, 0); - const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, "objectSid"); + const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(ldb, "objectSid"); - if (a->syntax->canonicalise_fn(module->ldb, ctx, val, &out) != LDB_SUCCESS) { + if (a->syntax->canonicalise_fn(ldb, ctx, val, &out) != LDB_SUCCESS) { return data_blob(NULL, 0); } @@ -126,18 +125,19 @@ static struct ldb_val sid_always_binary(struct ldb_module *module, TALLOC_CTX *c /* Ensure we always convert objectCategory into a DN */ static struct ldb_val objectCategory_always_dn(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_dn *dn; struct ldb_val out = data_blob(NULL, 0); - const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, "objectCategory"); + const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(ldb, "objectCategory"); - dn = ldb_dn_from_ldb_val(ctx, module->ldb, val); + dn = ldb_dn_from_ldb_val(ctx, ldb, val); if (dn && ldb_dn_validate(dn)) { talloc_free(dn); return val_copy(module, ctx, val); } talloc_free(dn); - if (a->syntax->canonicalise_fn(module->ldb, ctx, val, &out) != LDB_SUCCESS) { + if (a->syntax->canonicalise_fn(ldb, ctx, val, &out) != LDB_SUCCESS) { return data_blob(NULL, 0); } @@ -603,6 +603,7 @@ static int get_seq_callback(struct ldb_request *req, static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; int ret; struct map_private *map_private; struct entryuuid_private *entryuuid_private; @@ -620,16 +621,18 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque struct ldb_seqnum_result *seqr; struct ldb_extended *ext; + ldb = ldb_module_get_ctx(module); + seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request); - map_private = talloc_get_type(module->private_data, struct map_private); + map_private = talloc_get_type(ldb_module_get_private(module), struct map_private); entryuuid_private = talloc_get_type(map_private->caller_private, struct entryuuid_private); /* All this to get the DN of the parition, so we can search the right thing */ partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID); if (!partition_ctrl) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "entryuuid_sequence_number: no current partition control found"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -638,7 +641,7 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque struct dsdb_control_current_partition); SMB_ASSERT(partition && partition->version == DSDB_CONTROL_CURRENT_PARTITION_VERSION); - ret = ldb_build_search_req(&search_req, module->ldb, req, + ret = ldb_build_search_req(&search_req, ldb, req, partition->dn, LDB_SCOPE_BASE, NULL, contextCSN_attr, NULL, &seq_num, get_seq_callback, diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c index 10e2dc25ce..55a24549dd 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c @@ -29,7 +29,7 @@ * Author: Andrew Bartlett */ -#include "ldb_includes.h" +#include "ldb_module.h" struct subtree_delete_context { struct ldb_module *module; @@ -41,11 +41,14 @@ struct subtree_delete_context { static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct subtree_delete_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct subtree_delete_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -58,10 +61,12 @@ static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module, static int subtree_delete_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct subtree_delete_context *ac; int ret; ac = talloc_get_type(req->context, struct subtree_delete_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -89,7 +94,7 @@ static int subtree_delete_search_callback(struct ldb_request *req, if (ac->num_children > 0) { talloc_free(ares); - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "Cannot delete %s, not a leaf node " "(has %d children)\n", ldb_dn_get_linearized(ac->req->op.del.dn), @@ -112,6 +117,7 @@ static int subtree_delete_search_callback(struct ldb_request *req, static int subtree_delete(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; static const char * const attrs[2] = { "distinguishedName", NULL }; struct ldb_request *search_req; struct subtree_delete_context *ac; @@ -120,6 +126,8 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + ldb = ldb_module_get_ctx(module); + /* This gets complex: We need to: - Do a search for all entires under this entry - Wait for these results to appear @@ -135,7 +143,7 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req) /* we do not really need to find all descendents, * if there is even one single direct child, that's * enough to bail out */ - ret = ldb_build_search_req(&search_req, module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, req->op.del.dn, LDB_SCOPE_ONELEVEL, "(objectClass=*)", attrs, req->controls, diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c index d3ceb8ad97..e2f6b1d059 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c @@ -28,7 +28,7 @@ * Author: Andrew Bartlett */ -#include "ldb_includes.h" +#include "ldb_module.h" struct subren_msg_store { struct subren_msg_store *next; @@ -47,11 +47,14 @@ struct subtree_rename_context { static struct subtree_rename_context *subren_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct subtree_rename_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct subtree_rename_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -66,10 +69,12 @@ static int subtree_rename_next_request(struct subtree_rename_context *ac); static int subtree_rename_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct subtree_rename_context *ac; int ret; ac = talloc_get_type(req->context, struct subtree_rename_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -82,7 +87,7 @@ static int subtree_rename_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Invalid reply type!\n"); + ldb_set_errstring(ldb, "Invalid reply type!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -104,14 +109,17 @@ static int subtree_rename_callback(struct ldb_request *req, static int subtree_rename_next_request(struct subtree_rename_context *ac) { + struct ldb_context *ldb; struct ldb_request *req; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->current == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_rename_req(&req, ac->module->ldb, ac->current, + ret = ldb_build_rename_req(&req, ldb, ac->current, ac->current->olddn, ac->current->newdn, ac->req->controls, @@ -204,6 +212,7 @@ static int subtree_rename_search_callback(struct ldb_request *req, /* rename */ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; static const char *attrs[2] = { "distinguishedName", NULL }; struct ldb_request *search_req; struct subtree_rename_context *ac; @@ -212,6 +221,8 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + ldb = ldb_module_get_ctx(module); + /* This gets complex: We need to: - Do a search for all entires under this entry - Wait for these results to appear @@ -235,7 +246,7 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) ac->current->newdn = req->op.rename.newdn; ac->list = ac->current; - ret = ldb_build_search_req(&search_req, module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, req->op.rename.olddn, LDB_SCOPE_SUBTREE, "(objectClass=*)", diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index 7b82763403..8920afee71 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -28,7 +28,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_module.h" #include "auth/credentials/credentials.h" #include "auth/credentials/credentials_krb5.h" #include "system/kerberos.h" @@ -47,7 +47,7 @@ struct update_kt_ctx { struct ldb_request *req; struct ldb_dn *dn; - bool delete; + bool do_delete; struct ldb_reply *op_reply; bool found; @@ -60,7 +60,7 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module, ac = talloc_zero(req, struct update_kt_ctx); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb_module_get_ctx(module)); return NULL; } @@ -75,8 +75,9 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module, * Just hope we are lucky and nothing breaks (using the tdb backend masks a lot * of async issues). -SSS */ -static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) { - struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); +static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_delete) { + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); struct dn_list *item; char *filter; struct ldb_result *res; @@ -87,11 +88,11 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet filter = talloc_asprintf(data, "(&(dn=%s)(&(objectClass=kerberosSecret)(privateKeytab=*)))", ldb_dn_get_linearized(dn)); if (!filter) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, data, &res, + ret = ldb_search(ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, "%s", filter); if (ret != LDB_SUCCESS) { talloc_free(filter); @@ -109,7 +110,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet item = talloc(data->changed_dns? (void *)data->changed_dns: (void *)data, struct dn_list); if (!item) { talloc_free(filter); - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -117,15 +118,15 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet if (!item->creds) { DEBUG(1, ("cli_credentials_init failed!")); talloc_free(filter); - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm")); - status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter); + cli_credentials_set_conf(item->creds, ldb_get_opaque(ldb, "loadparm")); + status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"), ldb, NULL, filter); talloc_free(filter); if (NT_STATUS_IS_OK(status)) { - if (delete) { + if (do_delete) { /* Ensure we don't helpfully keep an old keytab entry */ cli_credentials_set_kvno(item->creds, cli_credentials_get_kvno(item->creds)+2); /* Wipe passwords */ @@ -142,10 +143,12 @@ static int ukt_search_modified(struct update_kt_ctx *ac); static int update_kt_op_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct update_kt_ctx *ac; int ret; ac = talloc_get_type(req->context, struct update_kt_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -157,12 +160,12 @@ static int update_kt_op_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Invalid request type!\n"); + ldb_set_errstring(ldb, "Invalid request type!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } - if (ac->delete) { + if (ac->do_delete) { return ldb_module_done(ac->req, ares->controls, ares->response, LDB_SUCCESS); } @@ -179,10 +182,13 @@ static int update_kt_op_callback(struct ldb_request *req, static int ukt_del_op(struct update_kt_ctx *ac) { + struct ldb_context *ldb; struct ldb_request *down_req; int ret; - ret = ldb_build_del_req(&down_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_del_req(&down_req, ldb, ac, ac->dn, ac->req->controls, ac, update_kt_op_callback, @@ -224,10 +230,10 @@ static int ukt_search_modified_callback(struct ldb_request *req, if (ac->found) { /* do the dirty sync job here :/ */ - ret = add_modified(ac->module, ac->dn, ac->delete); + ret = add_modified(ac->module, ac->dn, ac->do_delete); } - if (ac->delete) { + if (ac->do_delete) { ret = ukt_del_op(ac); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, @@ -246,11 +252,14 @@ static int ukt_search_modified_callback(struct ldb_request *req, static int ukt_search_modified(struct update_kt_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[] = { "distinguishedName", NULL }; struct ldb_request *search_req; int ret; - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_search_req(&search_req, ldb, ac, ac->dn, LDB_SCOPE_BASE, "(&(objectClass=kerberosSecret)" "(privateKeytab=*))", attrs, @@ -267,10 +276,13 @@ static int ukt_search_modified(struct update_kt_ctx *ac) /* add */ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct update_kt_ctx *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + ac = update_kt_ctx_init(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -278,7 +290,7 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) ac->dn = req->op.add.message->dn; - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, req->op.add.message, req->controls, ac, update_kt_op_callback, @@ -293,10 +305,13 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) /* modify */ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct update_kt_ctx *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + ac = update_kt_ctx_init(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -304,7 +319,7 @@ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req) ac->dn = req->op.mod.message->dn; - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, req->op.mod.message, req->controls, ac, update_kt_op_callback, @@ -327,7 +342,7 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req) } ac->dn = req->op.del.dn; - ac->delete = true; + ac->do_delete = true; return ukt_search_modified(ac); } @@ -335,10 +350,13 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req) /* rename */ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct update_kt_ctx *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + ac = update_kt_ctx_init(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -346,7 +364,7 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) ac->dn = req->op.rename.newdn; - ret = ldb_build_rename_req(&down_req, module->ldb, ac, + ret = ldb_build_rename_req(&down_req, ldb, ac, req->op.rename.olddn, req->op.rename.newdn, req->controls, @@ -362,16 +380,19 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) /* end a transaction */ static int update_kt_end_trans(struct ldb_module *module) { - struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); + struct ldb_context *ldb; + struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); struct dn_list *p; + ldb = ldb_module_get_ctx(module); + for (p=data->changed_dns; p; p = p->next) { int kret; - kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm")); + kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm")); if (kret != 0) { talloc_free(data->changed_dns); data->changed_dns = NULL; - ldb_asprintf_errstring(module->ldb, "Failed to update keytab: %s", error_message(kret)); + ldb_asprintf_errstring(ldb, "Failed to update keytab: %s", error_message(kret)); return LDB_ERR_OPERATIONS_ERROR; } } @@ -385,7 +406,7 @@ static int update_kt_end_trans(struct ldb_module *module) /* end a transaction */ static int update_kt_del_trans(struct ldb_module *module) { - struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); + struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); talloc_free(data->changed_dns); data->changed_dns = NULL; @@ -395,17 +416,21 @@ static int update_kt_del_trans(struct ldb_module *module) static int update_kt_init(struct ldb_module *module) { + struct ldb_context *ldb; struct update_kt_private *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct update_kt_private); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; data->changed_dns = NULL; + ldb_module_set_private(module, data); + return ldb_next_init(module); } diff --git a/source4/dsdb/schema/schema_description.c b/source4/dsdb/schema/schema_description.c index d616f3bb9b..0ff8a72bcd 100644 --- a/source4/dsdb/schema/schema_description.c +++ b/source4/dsdb/schema/schema_description.c @@ -313,7 +313,7 @@ char *schema_class_description(TALLOC_CTX *mem_ctx, return schema_entry; } -char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class *class) +char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass) { char *schema_description; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); @@ -325,21 +325,22 @@ char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class * = schema_class_description(mem_ctx, TARGET_AD_SCHEMA_SUBENTRY, " ", - class->governsID_oid, - class->lDAPDisplayName, + sclass->governsID_oid, + sclass->lDAPDisplayName, NULL, - class->subClassOf, - class->objectClassCategory, + sclass->subClassOf, + sclass->objectClassCategory, dsdb_attribute_list(tmp_ctx, - class, DSDB_SCHEMA_ALL_MUST), + sclass, DSDB_SCHEMA_ALL_MUST), dsdb_attribute_list(tmp_ctx, - class, DSDB_SCHEMA_ALL_MAY), + sclass, DSDB_SCHEMA_ALL_MAY), NULL); talloc_free(tmp_ctx); return schema_description; } -char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_class *class, - const struct dsdb_schema *schema) + +char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass, + const struct dsdb_schema *schema) { int i; char *schema_description; @@ -353,8 +354,8 @@ char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_clas return NULL; } - aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, class->systemAuxiliaryClass); - aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, class->auxiliaryClass); + aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, sclass->systemAuxiliaryClass); + aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, sclass->auxiliaryClass); for (i=0; aux_class_list && aux_class_list[i]; i++) { aux_class = dsdb_class_by_lDAPDisplayName(schema, aux_class_list[i]); @@ -370,8 +371,8 @@ char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_clas = schema_class_description(mem_ctx, TARGET_AD_SCHEMA_SUBENTRY, " ", - class->governsID_oid, - class->lDAPDisplayName, + sclass->governsID_oid, + sclass->lDAPDisplayName, (const char **)aux_class_list, NULL, /* Must not specify a * SUP (subclass) in diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c index f848fee365..00de0f8983 100644 --- a/source4/dsdb/schema/schema_query.c +++ b/source4/dsdb/schema/schema_query.c @@ -241,41 +241,41 @@ const char **merge_attr_list(TALLOC_CTX *mem_ctx, considering subclasses, auxillary classes etc) */ -const char **dsdb_attribute_list(TALLOC_CTX *mem_ctx, const struct dsdb_class *class, enum dsdb_attr_list_query query) +const char **dsdb_attribute_list(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass, enum dsdb_attr_list_query query) { const char **attr_list = NULL; switch (query) { case DSDB_SCHEMA_ALL_MAY: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mayContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMayContain); break; case DSDB_SCHEMA_ALL_MUST: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mustContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMustContain); break; case DSDB_SCHEMA_SYS_MAY: - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMayContain); break; case DSDB_SCHEMA_SYS_MUST: - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMustContain); break; case DSDB_SCHEMA_MAY: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mayContain); break; case DSDB_SCHEMA_MUST: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mustContain); break; case DSDB_SCHEMA_ALL: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mayContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMayContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->mustContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMustContain); break; } return attr_list; @@ -287,26 +287,26 @@ static const char **dsdb_full_attribute_list_internal(TALLOC_CTX *mem_ctx, enum dsdb_attr_list_query query) { int i; - const struct dsdb_class *class; + const struct dsdb_class *sclass; const char **attr_list = NULL; const char **this_class_list; const char **recursive_list; for (i=0; class_list && class_list[i]; i++) { - class = dsdb_class_by_lDAPDisplayName(schema, class_list[i]); + sclass = dsdb_class_by_lDAPDisplayName(schema, class_list[i]); - this_class_list = dsdb_attribute_list(mem_ctx, class, query); + this_class_list = dsdb_attribute_list(mem_ctx, sclass, query); attr_list = merge_attr_list(mem_ctx, attr_list, this_class_list); recursive_list = dsdb_full_attribute_list_internal(mem_ctx, schema, - class->systemAuxiliaryClass, + sclass->systemAuxiliaryClass, query); attr_list = merge_attr_list(mem_ctx, attr_list, recursive_list); recursive_list = dsdb_full_attribute_list_internal(mem_ctx, schema, - class->auxiliaryClass, + sclass->auxiliaryClass, query); attr_list = merge_attr_list(mem_ctx, attr_list, recursive_list); diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index d0aae4e221..d6b3e40e1a 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -22,9 +22,7 @@ #include "includes.h" #include "dsdb/samdb/samdb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" -#include "../lib/util/dlinklist.h" +#include "lib/ldb/include/ldb_module.h" #include "param/param.h" diff --git a/source4/headermap.txt b/source4/headermap.txt index c27ec2f2de..8f3749a3b5 100644 --- a/source4/headermap.txt +++ b/source4/headermap.txt @@ -50,7 +50,6 @@ param/share.h: share.h ../lib/util/util_ldb.h: util_ldb.h ../lib/util/wrap_xattr.h: wrap_xattr.h libcli/ldap/ldap_ndr.h: ldap_ndr.h -lib/events/events.h: events.h ../lib/tevent/tevent.h: tevent.h ../lib/tevent/tevent_internal.h: tevent_internal.h auth/session.h: samba/session.h diff --git a/source4/heimdal/lib/hcrypto/camellia-ntt.c b/source4/heimdal/lib/hcrypto/camellia-ntt.c index 70b0268833..358221162f 100644 --- a/source4/heimdal/lib/hcrypto/camellia-ntt.c +++ b/source4/heimdal/lib/hcrypto/camellia-ntt.c @@ -23,6 +23,11 @@ * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <roken.h> #include <string.h> #include <stdlib.h> diff --git a/source4/heimdal/lib/hcrypto/camellia.c b/source4/heimdal/lib/hcrypto/camellia.c index 00635c9fed..d78bbd4c0e 100644 --- a/source4/heimdal/lib/hcrypto/camellia.c +++ b/source4/heimdal/lib/hcrypto/camellia.c @@ -37,6 +37,8 @@ RCSID("$Id: aes.c 20466 2007-04-20 08:29:05Z lha $"); #endif +#include <roken.h> + #ifdef KRB5 #include <krb5-types.h> #endif diff --git a/source4/heimdal/lib/hdb/hdb.c b/source4/heimdal/lib/hdb/hdb.c index 15a1024267..ad2c35a43a 100644 --- a/source4/heimdal/lib/hdb/hdb.c +++ b/source4/heimdal/lib/hdb/hdb.c @@ -31,6 +31,10 @@ * SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "krb5.h" #include "krb5_locl.h" #include "hdb_locl.h" diff --git a/source4/heimdal/lib/krb5/error_string.c b/source4/heimdal/lib/krb5/error_string.c index db2df4798c..6374fa17ae 100644 --- a/source4/heimdal/lib/krb5/error_string.c +++ b/source4/heimdal/lib/krb5/error_string.c @@ -271,7 +271,7 @@ void KRB5_LIB_FUNCTION krb5_clear_error_string(krb5_context context) __attribute__((deprecated)) { - return krb5_clear_error_message(context); + krb5_clear_error_message(context); } #endif /* !HEIMDAL_SMALLER */ diff --git a/source4/heimdal/lib/krb5/get_addrs.c b/source4/heimdal/lib/krb5/get_addrs.c index fb45d08d29..ce16785319 100644 --- a/source4/heimdal/lib/krb5/get_addrs.c +++ b/source4/heimdal/lib/krb5/get_addrs.c @@ -43,7 +43,9 @@ struct mbuf; #ifdef HAVE_NET_IF_H #include <net/if.h> #endif +#ifdef HAVE_IFADDR_H #include <ifaddrs.h> +#endif static krb5_error_code gethostname_fallback (krb5_context context, krb5_addresses *res) diff --git a/source4/heimdal/lib/roken/getarg.c b/source4/heimdal/lib/roken/getarg.c index 3884fa83d6..3168ccc53d 100644 --- a/source4/heimdal/lib/roken/getarg.c +++ b/source4/heimdal/lib/roken/getarg.c @@ -216,8 +216,8 @@ arg_printusage (struct getargs *args, const char *progname, const char *extra_string) { - return arg_printusage_i18n(args, num_args, "Usage", - progname, extra_string, builtin_i18n); + arg_printusage_i18n(args, num_args, "Usage", + progname, extra_string, builtin_i18n); } void ROKEN_LIB_FUNCTION @@ -478,6 +478,9 @@ arg_match_long(struct getargs *args, size_t num_args, default: abort (); } + + /* not reached */ + return ARG_ERR_NO_MATCH; } static int diff --git a/source4/heimdal/lib/roken/vis.hin b/source4/heimdal/lib/roken/vis.hin index 64274526e4..06a250c6d8 100644 --- a/source4/heimdal/lib/roken/vis.hin +++ b/source4/heimdal/lib/roken/vis.hin @@ -80,7 +80,9 @@ */ #define UNVIS_END 1 /* no more characters */ +#ifdef HAVE_SYS_CDEFS_H #include <sys/cdefs.h> +#endif __BEGIN_DECLS char * ROKEN_LIB_FUNCTION diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h index e15c6effa8..6a82637b2d 100644 --- a/source4/heimdal_build/config.h +++ b/source4/heimdal_build/config.h @@ -9,6 +9,10 @@ #include "include/config.h" #include "../replace/replace.h" +#if !defined(HAVE_DIRFD) && !defined(HAVE_DIRFD_DECL) && !defined(dirfd) +#define dirfd(d) (-1) +#endif + #define RCSID(msg) struct __rcsid { int __rcsdi; } #define KRB5 diff --git a/source4/heimdal_build/internal.m4 b/source4/heimdal_build/internal.m4 index 06e798ce27..b2f64a6825 100644 --- a/source4/heimdal_build/internal.m4 +++ b/source4/heimdal_build/internal.m4 @@ -33,6 +33,9 @@ esac ]) +AC_CHECK_TYPE(u_char, uint8_t) +AC_CHECK_TYPE(u_int32_t, uint32_t) + dnl Not all systems have err.h, so we provide a replacement. Heimdal dnl unconditionally #includes <err.h>, so we need to create an err.h, dnl but we can't just have a static one because we don't want to use diff --git a/source4/heimdal_build/internal.mk b/source4/heimdal_build/internal.mk index 92bef089e4..9e32898a07 100644 --- a/source4/heimdal_build/internal.mk +++ b/source4/heimdal_build/internal.mk @@ -656,7 +656,7 @@ HEIMDAL_COM_ERR_OBJ_FILES = \ # Start BINARY asn1_compile [BINARY::asn1_compile] USE_HOSTCC = YES -PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN LIBREPLACE_NETWORK +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN ASN1C = $(builddir)/bin/asn1_compile @@ -682,7 +682,6 @@ asn1_compile_OBJ_FILES = \ $(asn1_compile_ASN1_OBJ_FILES) \ $(heimdalsrcdir)/lib/vers/print_version.ho \ $(socketwrappersrcdir)/socket_wrapper.ho \ - $(heimdalbuildsrcdir)/replace.ho $(asn1_compile_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir) @@ -700,7 +699,7 @@ $(eval $(call heimdal_proto_header_template, \ # Start BINARY compile_et [BINARY::compile_et] USE_HOSTCC = YES -PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN LIBREPLACE_NETWORK +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN # End BINARY compile_et ####################### @@ -711,7 +710,6 @@ compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \ $(heimdalsrcdir)/lib/com_err/lex.ho \ $(heimdalsrcdir)/lib/com_err/compile_et.ho \ $(socketwrappersrcdir)/socket_wrapper.ho \ - $(heimdalbuildsrcdir)/replace.ho $(compile_et_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/com_err -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir) diff --git a/source4/heimdal_build/vis.h b/source4/heimdal_build/vis.h index 13b39aa184..4389993ebd 100644 --- a/source4/heimdal_build/vis.h +++ b/source4/heimdal_build/vis.h @@ -1,4 +1,15 @@ #ifndef _HEIMDAL_BUILD_VIS_H #define _HEIMDAL_BUILD_VIS_H + +#include "system/locale.h" + +#ifndef __BEGIN_DECLS +#define __BEGIN_DECLS +#endif + +#ifndef __END_DECLS +#define __END_DECLS +#endif + #include "heimdal/lib/roken/vis.hin" #endif diff --git a/source4/include/includes.h b/source4/include/includes.h index f925e836c5..d9b7759e7e 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -33,9 +33,23 @@ #include "system/time.h" #include "system/wait.h" +/* only do the C++ reserved word check when we compile + to include --with-developer since too many systems + still have comflicts with their header files (e.g. IRIX 6.4) */ + +#if !defined(__cplusplus) && defined(DEVELOPER) +#define class #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define private #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define public #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define protected #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define template #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define this #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define new #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define delete #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define friend #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#endif + /* Lists, trees, caching, database... */ -#include <stdlib.h> -#include <stdbool.h> #include <talloc.h> #ifndef _PRINTF_ATTRIBUTE #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) diff --git a/source4/kdc/hdb-samba4.c b/source4/kdc/hdb-samba4.c index 937839d67d..daeed77975 100644 --- a/source4/kdc/hdb-samba4.c +++ b/source4/kdc/hdb-samba4.c @@ -186,9 +186,9 @@ static HDBFlags uf2HDBFlags(krb5_context context, int userAccountControl, enum h return flags; } -static int hdb_ldb_destructor(struct hdb_ldb_private *private) +static int hdb_ldb_destructor(struct hdb_ldb_private *p) { - hdb_entry_ex *entry_ex = private->entry_ex; + hdb_entry_ex *entry_ex = p->entry_ex; free_hdb_entry(&entry_ex->entry); return 0; } @@ -509,7 +509,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, "nCName", ldb_dn_new(mem_ctx, (struct ldb_context *)db->hdb_db, NULL)); - struct hdb_ldb_private *private; + struct hdb_ldb_private *p; NTTIME acct_expiry; struct ldb_message_element *objectclasses; @@ -531,19 +531,19 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, goto out; } - private = talloc(mem_ctx, struct hdb_ldb_private); - if (!private) { + p = talloc(mem_ctx, struct hdb_ldb_private); + if (!p) { ret = ENOMEM; goto out; } - private->entry_ex = entry_ex; - private->iconv_convenience = lp_iconv_convenience(lp_ctx); - private->netbios_name = lp_netbios_name(lp_ctx); + p->entry_ex = entry_ex; + p->iconv_convenience = lp_iconv_convenience(lp_ctx); + p->netbios_name = lp_netbios_name(lp_ctx); - talloc_set_destructor(private, hdb_ldb_destructor); + talloc_set_destructor(p, hdb_ldb_destructor); - entry_ex->ctx = private; + entry_ex->ctx = p; entry_ex->free_entry = hdb_ldb_free_entry; userAccountControl = ldb_msg_find_attr_as_uint(msg, "userAccountControl", 0); @@ -655,7 +655,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.generation = NULL; /* Get keys from the db */ - ret = LDB_message2entry_keys(context, private->iconv_convenience, private, msg, userAccountControl, entry_ex); + ret = LDB_message2entry_keys(context, p->iconv_convenience, p, msg, userAccountControl, entry_ex); if (ret) { /* Could be bougus data in the entry, or out of memory */ goto out; @@ -679,9 +679,9 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, } - private->msg = talloc_steal(private, msg); - private->realm_ref_msg = talloc_steal(private, realm_ref_msg); - private->samdb = (struct ldb_context *)db->hdb_db; + p->msg = talloc_steal(p, msg); + p->realm_ref_msg = talloc_steal(p, realm_ref_msg); + p->samdb = (struct ldb_context *)db->hdb_db; out: if (ret != 0) { @@ -712,24 +712,24 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, struct samr_Password password_hash; const struct ldb_val *password_val; struct trustAuthInOutBlob password_blob; - struct hdb_ldb_private *private; + struct hdb_ldb_private *p; enum ndr_err_code ndr_err; int i, ret, trust_direction_flags; - private = talloc(mem_ctx, struct hdb_ldb_private); - if (!private) { + p = talloc(mem_ctx, struct hdb_ldb_private); + if (!p) { ret = ENOMEM; goto out; } - private->entry_ex = entry_ex; - private->iconv_convenience = lp_iconv_convenience(lp_ctx); - private->netbios_name = lp_netbios_name(lp_ctx); + p->entry_ex = entry_ex; + p->iconv_convenience = lp_iconv_convenience(lp_ctx); + p->netbios_name = lp_netbios_name(lp_ctx); - talloc_set_destructor(private, hdb_ldb_destructor); + talloc_set_destructor(p, hdb_ldb_destructor); - entry_ex->ctx = private; + entry_ex->ctx = p; entry_ex->free_entry = hdb_ldb_free_entry; /* use 'whenCreated' */ @@ -756,7 +756,7 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, goto out; } - ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, private->iconv_convenience, &password_blob, + ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, p->iconv_convenience, &password_blob, (ndr_pull_flags_fn_t)ndr_pull_trustAuthInOutBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { ret = EINVAL; @@ -868,9 +868,9 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, } - private->msg = talloc_steal(private, msg); - private->realm_ref_msg = NULL; - private->samdb = (struct ldb_context *)db->hdb_db; + p->msg = talloc_steal(p, msg); + p->realm_ref_msg = NULL; + p->samdb = (struct ldb_context *)db->hdb_db; out: if (ret != 0) { diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index c11c4a6eee..1cfe9852f0 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -200,9 +200,9 @@ static void kdc_recv_handler(struct kdc_socket *kdc_socket) handle fd events on a KDC socket */ static void kdc_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct kdc_socket *kdc_socket = talloc_get_type(private, struct kdc_socket); + struct kdc_socket *kdc_socket = talloc_get_type(private_data, struct kdc_socket); if (flags & EVENT_FD_WRITE) { kdc_send_handler(kdc_socket); } @@ -219,9 +219,9 @@ static void kdc_tcp_terminate_connection(struct kdc_tcp_connection *kdcconn, con /* receive a full packet on a KDC connection */ -static NTSTATUS kdc_tcp_recv(void *private, DATA_BLOB blob) +static NTSTATUS kdc_tcp_recv(void *private_data, DATA_BLOB blob) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(private, + struct kdc_tcp_connection *kdcconn = talloc_get_type(private_data, struct kdc_tcp_connection); NTSTATUS status = NT_STATUS_UNSUCCESSFUL; TALLOC_CTX *tmp_ctx = talloc_new(kdcconn); @@ -285,7 +285,7 @@ static NTSTATUS kdc_tcp_recv(void *private, DATA_BLOB blob) */ static void kdc_tcp_recv_handler(struct stream_connection *conn, uint16_t flags) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private, + struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private_data, struct kdc_tcp_connection); packet_recv(kdcconn->packet); } @@ -293,9 +293,10 @@ static void kdc_tcp_recv_handler(struct stream_connection *conn, uint16_t flags) /* called on a tcp recv error */ -static void kdc_tcp_recv_error(void *private, NTSTATUS status) +static void kdc_tcp_recv_error(void *private_data, NTSTATUS status) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(private, struct kdc_tcp_connection); + struct kdc_tcp_connection *kdcconn = talloc_get_type(private_data, + struct kdc_tcp_connection); kdc_tcp_terminate_connection(kdcconn, nt_errstr(status)); } @@ -304,7 +305,7 @@ static void kdc_tcp_recv_error(void *private, NTSTATUS status) */ static void kdc_tcp_send(struct stream_connection *conn, uint16_t flags) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private, + struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private_data, struct kdc_tcp_connection); packet_queue_run(kdcconn->packet); } @@ -356,7 +357,7 @@ static bool kdc_process(struct kdc_server *kdc, */ static void kdc_tcp_generic_accept(struct stream_connection *conn, kdc_process_fn_t process_fn) { - struct kdc_server *kdc = talloc_get_type(conn->private, struct kdc_server); + struct kdc_server *kdc = talloc_get_type(conn->private_data, struct kdc_server); struct kdc_tcp_connection *kdcconn; kdcconn = talloc_zero(conn, struct kdc_tcp_connection); @@ -367,7 +368,7 @@ static void kdc_tcp_generic_accept(struct stream_connection *conn, kdc_process_f kdcconn->conn = conn; kdcconn->kdc = kdc; kdcconn->process = process_fn; - conn->private = kdcconn; + conn->private_data = kdcconn; kdcconn->packet = packet_init(kdcconn); if (kdcconn->packet == NULL) { @@ -565,7 +566,7 @@ static NTSTATUS kdc_check_generic_kerberos(struct irpc_message *msg, struct PAC_Validate pac_validate; DATA_BLOB srv_sig; struct PAC_SIGNATURE_DATA kdc_sig; - struct kdc_server *kdc = talloc_get_type(msg->private, struct kdc_server); + struct kdc_server *kdc = talloc_get_type(msg->private_data, struct kdc_server); enum ndr_err_code ndr_err; krb5_enctype etype; int ret; diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c index 74bec85d02..1a0df8e4a1 100644 --- a/source4/kdc/pac-glue.c +++ b/source4/kdc/pac-glue.c @@ -111,8 +111,8 @@ krb5_error_code samba_kdc_get_pac(void *priv, krb5_error_code ret; NTSTATUS nt_status; struct auth_serversupplied_info *server_info; - struct hdb_ldb_private *private = talloc_get_type(client->ctx, struct hdb_ldb_private); - TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); + struct hdb_ldb_private *p = talloc_get_type(client->ctx, struct hdb_ldb_private); + TALLOC_CTX *mem_ctx = talloc_named(p, 0, "samba_get_pac context"); unsigned int userAccountControl; if (!mem_ctx) { @@ -120,16 +120,16 @@ krb5_error_code samba_kdc_get_pac(void *priv, } /* The user account may be set not to want the PAC */ - userAccountControl = ldb_msg_find_attr_as_uint(private->msg, "userAccountControl", 0); + userAccountControl = ldb_msg_find_attr_as_uint(p->msg, "userAccountControl", 0); if (userAccountControl & UF_NO_AUTH_DATA_REQUIRED) { *pac = NULL; return 0; } - nt_status = authsam_make_server_info(mem_ctx, private->samdb, - private->netbios_name, - private->msg, - private->realm_ref_msg, + nt_status = authsam_make_server_info(mem_ctx, p->samdb, + p->netbios_name, + p->msg, + p->realm_ref_msg, data_blob(NULL, 0), data_blob(NULL, 0), &server_info); @@ -139,7 +139,7 @@ krb5_error_code samba_kdc_get_pac(void *priv, return ENOMEM; } - ret = make_pac(context, mem_ctx, private->iconv_convenience, server_info, pac); + ret = make_pac(context, mem_ctx, p->iconv_convenience, server_info, pac); talloc_free(mem_ctx); return ret; @@ -156,25 +156,25 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, unsigned int userAccountControl; - struct hdb_ldb_private *private = talloc_get_type(server->ctx, struct hdb_ldb_private); + struct hdb_ldb_private *p = talloc_get_type(server->ctx, struct hdb_ldb_private); struct auth_serversupplied_info *server_info_out; - TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); + TALLOC_CTX *mem_ctx = talloc_named(p, 0, "samba_get_pac context"); if (!mem_ctx) { return ENOMEM; } /* The service account may be set not to want the PAC */ - userAccountControl = ldb_msg_find_attr_as_uint(private->msg, "userAccountControl", 0); + userAccountControl = ldb_msg_find_attr_as_uint(p->msg, "userAccountControl", 0); if (userAccountControl & UF_NO_AUTH_DATA_REQUIRED) { talloc_free(mem_ctx); *pac = NULL; return 0; } - ret = kerberos_pac_to_server_info(mem_ctx, private->iconv_convenience, + ret = kerberos_pac_to_server_info(mem_ctx, p->iconv_convenience, *pac, context, &server_info_out); /* We will compleatly regenerate this pac */ @@ -185,7 +185,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, return ret; } - ret = make_pac(context, mem_ctx, private->iconv_convenience, server_info_out, pac); + ret = make_pac(context, mem_ctx, p->iconv_convenience, server_info_out, pac); talloc_free(mem_ctx); return ret; @@ -236,7 +236,7 @@ krb5_error_code samba_kdc_check_client_access(void *priv, krb5_error_code ret; NTSTATUS nt_status; TALLOC_CTX *tmp_ctx = talloc_new(entry_ex->ctx); - struct hdb_ldb_private *private = talloc_get_type(entry_ex->ctx, struct hdb_ldb_private); + struct hdb_ldb_private *p = talloc_get_type(entry_ex->ctx, struct hdb_ldb_private); char *name, *workstation = NULL; HostAddresses *addresses = req->req_body.addresses; int i; @@ -272,10 +272,10 @@ krb5_error_code samba_kdc_check_client_access(void *priv, /* we allow all kinds of trusts here */ nt_status = authsam_account_ok(tmp_ctx, - private->samdb, + p->samdb, MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT | MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT, - private->msg, - private->realm_ref_msg, + p->msg, + p->realm_ref_msg, workstation, name, true); free(name); diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c index 0fe6fcce90..f3f843b920 100644 --- a/source4/ldap_server/ldap_bind.c +++ b/source4/ldap_server/ldap_bind.c @@ -100,9 +100,9 @@ struct ldapsrv_sasl_context { struct socket_context *sasl_socket; }; -static void ldapsrv_set_sasl(void *private) +static void ldapsrv_set_sasl(void *private_data) { - struct ldapsrv_sasl_context *ctx = talloc_get_type(private, struct ldapsrv_sasl_context); + struct ldapsrv_sasl_context *ctx = talloc_get_type(private_data, struct ldapsrv_sasl_context); talloc_steal(ctx->conn->connection, ctx->sasl_socket); talloc_unlink(ctx->conn->connection, ctx->conn->connection->socket); diff --git a/source4/ldap_server/ldap_extended.c b/source4/ldap_server/ldap_extended.c index 334e427d79..4479eab560 100644 --- a/source4/ldap_server/ldap_extended.c +++ b/source4/ldap_server/ldap_extended.c @@ -29,9 +29,9 @@ struct ldapsrv_starttls_context { struct socket_context *tls_socket; }; -static void ldapsrv_start_tls(void *private) +static void ldapsrv_start_tls(void *private_data) { - struct ldapsrv_starttls_context *ctx = talloc_get_type(private, struct ldapsrv_starttls_context); + struct ldapsrv_starttls_context *ctx = talloc_get_type(private_data, struct ldapsrv_starttls_context); talloc_steal(ctx->conn->connection, ctx->tls_socket); talloc_unlink(ctx->conn->connection, ctx->conn->connection->socket); diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index ed8e6d3a2c..61ff387152 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -55,9 +55,9 @@ void ldapsrv_terminate_connection(struct ldapsrv_connection *conn, /* handle packet errors */ -static void ldapsrv_error_handler(void *private, NTSTATUS status) +static void ldapsrv_error_handler(void *private_data, NTSTATUS status) { - struct ldapsrv_connection *conn = talloc_get_type(private, + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); ldapsrv_terminate_connection(conn, nt_errstr(status)); } @@ -132,10 +132,10 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn, /* decode/process data */ -static NTSTATUS ldapsrv_decode(void *private, DATA_BLOB blob) +static NTSTATUS ldapsrv_decode(void *private_data, DATA_BLOB blob) { NTSTATUS status; - struct ldapsrv_connection *conn = talloc_get_type(private, + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); struct asn1_data *asn1 = asn1_init(conn); struct ldap_message *msg = talloc(conn, struct ldap_message); @@ -170,9 +170,9 @@ static NTSTATUS ldapsrv_decode(void *private, DATA_BLOB blob) static void ldapsrv_conn_idle_timeout(struct tevent_context *ev, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct ldapsrv_connection *conn = talloc_get_type(private, struct ldapsrv_connection); + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); ldapsrv_terminate_connection(conn, "Timeout. No requests after bind"); } @@ -183,7 +183,7 @@ static void ldapsrv_conn_idle_timeout(struct tevent_context *ev, void ldapsrv_recv(struct stream_connection *c, uint16_t flags) { struct ldapsrv_connection *conn = - talloc_get_type(c->private, struct ldapsrv_connection); + talloc_get_type(c->private_data, struct ldapsrv_connection); if (conn->limits.ite) { /* clean initial timeout if any */ talloc_free(conn->limits.ite); @@ -209,7 +209,7 @@ void ldapsrv_recv(struct stream_connection *c, uint16_t flags) static void ldapsrv_send(struct stream_connection *c, uint16_t flags) { struct ldapsrv_connection *conn = - talloc_get_type(c->private, struct ldapsrv_connection); + talloc_get_type(c->private_data, struct ldapsrv_connection); packet_queue_run(conn->packet); } @@ -217,9 +217,9 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags) static void ldapsrv_conn_init_timeout(struct tevent_context *ev, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct ldapsrv_connection *conn = talloc_get_type(private, struct ldapsrv_connection); + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); ldapsrv_terminate_connection(conn, "Timeout. No requests after initial connection"); } @@ -328,7 +328,7 @@ failed: static void ldapsrv_accept(struct stream_connection *c) { struct ldapsrv_service *ldapsrv_service = - talloc_get_type(c->private, struct ldapsrv_service); + talloc_get_type(c->private_data, struct ldapsrv_service); struct ldapsrv_connection *conn; struct cli_credentials *server_credentials; struct socket_address *socket_address; @@ -347,7 +347,7 @@ static void ldapsrv_accept(struct stream_connection *c) conn->sockets.raw = c->socket; conn->lp_ctx = ldapsrv_service->task->lp_ctx; - c->private = conn; + c->private_data = conn; socket_address = socket_get_my_addr(c->socket, conn); if (!socket_address) { diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index c07a21bc75..5c7e1b7210 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -3,5 +3,3 @@ PUBLIC_DEPENDENCIES = LIBTEVENT CFLAGS = -Ilib/events LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, tevent_s4.o) - -PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h) diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c index 5ab31d771b..fc87e6ca7a 100644 --- a/source4/lib/ldb-samba/ldif_handlers.c +++ b/source4/lib/ldb-samba/ldif_handlers.c @@ -22,7 +22,8 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb_includes.h" +#include "ldb_private.h" +#include "ldb_handlers.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_misc.h" @@ -365,7 +366,7 @@ static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_c { struct ldb_dn *dn1 = NULL; const struct dsdb_schema *schema = dsdb_get_schema(ldb); - const struct dsdb_class *class; + const struct dsdb_class *sclass; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); if (!tmp_ctx) { return LDB_ERR_OPERATIONS_ERROR; @@ -381,10 +382,10 @@ static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_c dn1 = ldb_dn_from_ldb_val(tmp_ctx, ldb, in); if ( ! ldb_dn_validate(dn1)) { const char *lDAPDisplayName = talloc_strndup(tmp_ctx, (char *)in->data, in->length); - class = dsdb_class_by_lDAPDisplayName(schema, lDAPDisplayName); - if (class) { + sclass = dsdb_class_by_lDAPDisplayName(schema, lDAPDisplayName); + if (sclass) { struct ldb_dn *dn = ldb_dn_new(mem_ctx, ldb, - class->defaultObjectCategory); + sclass->defaultObjectCategory); *out = data_blob_string_const(ldb_dn_alloc_casefold(mem_ctx, dn)); talloc_free(tmp_ctx); diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 6313fc1622..7f00e8ebee 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -67,7 +67,7 @@ MDLD_FLAGS = @MDLD_FLAGS@ OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TEVENT_OBJ) $(TALLOC_OBJ) $(POPT_OBJ) $(LDB_MAP_OBJ) @LIBREPLACEOBJ@ $(EXTRA_OBJ) -headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h +headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h $(srcdir)/include/ldb_includes.h $(srcdir)/include/ldb_module.h BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest diff --git a/source4/lib/ldb/build_macros.m4 b/source4/lib/ldb/build_macros.m4 index c036668cd1..bb7fad8f7a 100644 --- a/source4/lib/ldb/build_macros.m4 +++ b/source4/lib/ldb/build_macros.m4 @@ -7,6 +7,7 @@ AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, if test x"$with_shared_build_dir" != x; then sharedbuilddir=$with_shared_build_dir CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + CPPFLAGS="$CPPFLAGS -I$with_shared_build_dir/include" LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" fi AC_SUBST(sharedbuilddir) diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c index 5ec86b5b8f..80725ec04f 100644 --- a/source4/lib/ldb/common/attrib_handlers.c +++ b/source4/lib/ldb/common/attrib_handlers.c @@ -25,7 +25,7 @@ see rfc2252 */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" #include "ldb_handlers.h" diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index fe55d1499a..2fb5a8f9be 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -32,7 +32,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* initialise a ldb context @@ -481,6 +481,11 @@ void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms) ldb->create_perms = perms; } +unsigned int ldb_get_create_perms(struct ldb_context *ldb) +{ + return ldb->create_perms; +} + void ldb_set_event_context(struct ldb_context *ldb, struct tevent_context *ev) { ldb->ev_ctx = ev; @@ -491,6 +496,16 @@ struct tevent_context * ldb_get_event_context(struct ldb_context *ldb) return ldb->ev_ctx; } +void ldb_request_set_state(struct ldb_request *req, int state) +{ + req->handle->state = state; +} + +int ldb_request_get_status(struct ldb_request *req) +{ + return req->handle->status; +} + /* start an ldb request NOTE: the request must be a talloc context. diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index 001bc45ee1..9fa0fb2ccd 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -28,7 +28,8 @@ message matching logic generic */ -#include "ldb_includes.h" +#include "ldb_private.h" +#include "ldb_handlers.h" /* add a attribute to the ldb_schema diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index 6fad5012b6..0c587e0905 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_private.h" /* check if a control with the specified "oid" exist and return it */ /* returns NULL if not found */ diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c index 0f78e37c1c..f8009eb8a3 100644 --- a/source4/lib/ldb/common/ldb_debug.c +++ b/source4/lib/ldb/common/ldb_debug.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* this allows the user to choose their own debug function diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index 02e21a2b25..402d629501 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -33,7 +33,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_private.h" #include <ctype.h> #define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 619c10e11e..400fb352ff 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -35,7 +35,7 @@ see RFC2849 for the LDIF format definition */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" /* diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c index 4cde739d67..c622701d30 100644 --- a/source4/lib/ldb/common/ldb_match.c +++ b/source4/lib/ldb/common/ldb_match.c @@ -32,7 +32,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* check if the scope matches in a search result diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 8db28d262c..99a47767e1 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_private.h" #if (_SAMBA_BUILD_ >= 4) #include "includes.h" @@ -486,6 +486,46 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) } while (0) +struct ldb_module *ldb_module_new(TALLOC_CTX *memctx, + struct ldb_context *ldb, + const char *module_name, + const struct ldb_module_ops *ops) +{ + struct ldb_module *module; + + module = talloc(memctx, struct ldb_module); + if (!module) { + ldb_oom(ldb); + return NULL; + } + talloc_set_name_const(module, module_name); + module->ldb = ldb; + module->prev = module->next = NULL; + module->ops = ops; + + return module; +} + +const char * ldb_module_get_name(struct ldb_module *module) +{ + return module->ops->name; +} + +struct ldb_context *ldb_module_get_ctx(struct ldb_module *module) +{ + return module->ldb; +} + +void *ldb_module_get_private(struct ldb_module *module) +{ + return module->private_data; +} + +void ldb_module_set_private(struct ldb_module *module, void *private_data) +{ + module->private_data = private_data; +} + /* helper functions to call the next module in chain */ diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 2f5fe1d18c..ad53a3d29d 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* create a new ldb_message in a given memory context (NULL for top level) diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index b233975220..654a635abf 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -40,7 +40,7 @@ */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" /* diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 69ee2b6964..0a8a89ac1d 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" diff --git a/source4/lib/ldb/common/qsort.c b/source4/lib/ldb/common/qsort.c index 0fa76d3b47..1a0b886b8c 100644 --- a/source4/lib/ldb/common/qsort.c +++ b/source4/lib/ldb/common/qsort.c @@ -23,7 +23,7 @@ * Simo Sorce <idra@samba.org> 2005 */ -#include "ldb_includes.h" +#include "ldb_private.h" /* Byte-wise swap two items of size SIZE. */ #define SWAP(a, b, size) \ diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac index 7bc081cfe5..d61b31afd4 100644 --- a/source4/lib/ldb/configure.ac +++ b/source4/lib/ldb/configure.ac @@ -11,7 +11,7 @@ AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) AC_DEFUN([SMB_EXT_LIB], [echo -n ""]) AC_DEFUN([SMB_ENABLE], [echo -n ""]) -AC_INIT(ldb, 0.9.2) +AC_INIT(ldb, 0.9.3) AC_CONFIG_SRCDIR([common/ldb.c]) AC_LIBREPLACE_ALL_CHECKS diff --git a/source4/lib/ldb/examples/ldbreader.c b/source4/lib/ldb/examples/ldbreader.c index e48b3d338a..3496baf4ce 100644 --- a/source4/lib/ldb/examples/ldbreader.c +++ b/source4/lib/ldb/examples/ldbreader.c @@ -29,9 +29,7 @@ It lists / dumps the records in a LDB database to standard output. */ -#include "ldb_includes.h" #include "ldb.h" -#include "ldb_errors.h" /* ldb_ldif_write takes a function pointer to a custom output diff --git a/source4/lib/ldb/examples/ldifreader.c b/source4/lib/ldb/examples/ldifreader.c index 12e7a1a6fd..dcd9daf812 100644 --- a/source4/lib/ldb/examples/ldifreader.c +++ b/source4/lib/ldb/examples/ldifreader.c @@ -29,9 +29,7 @@ It lists / dumps the entries in an LDIF file to standard output. */ -#include "ldb_includes.h" #include "ldb.h" -#include "ldb_errors.h" /* ldb_ldif_write takes a function pointer to a custom output diff --git a/source4/lib/ldb/external/libevents.m4 b/source4/lib/ldb/external/libevents.m4 index 24534f2c21..6a0e36af8b 100644 --- a/source4/lib/ldb/external/libevents.m4 +++ b/source4/lib/ldb/external/libevents.m4 @@ -3,5 +3,5 @@ AC_SUBST(TEVENT_CFLAGS) AC_SUBST(TEVENT_LIBS) AC_CHECK_HEADER(tevent.h, - [AC_CHECK_LIB(tevent, event_context_init, [TEVENT_LIBS="-ltevent"]) ], + [AC_CHECK_LIB(tevent, tevent_context_init, [TEVENT_LIBS="-ltevent"]) ], [PKG_CHECK_MODULES(TEVENT, tevent)]) diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h index d3252751db..acab9fa043 100644 --- a/source4/lib/ldb/include/dlinklist.h +++ b/source4/lib/ldb/include/dlinklist.h @@ -20,6 +20,8 @@ /* To use these macros you must have a structure containing a next and prev pointer */ +#ifndef _DLINKLIST_H +#define _DLINKLIST_H /* hook into the front of the list */ #define DLIST_ADD(list, p) \ @@ -108,3 +110,5 @@ do { \ } \ } \ } while (0) + +#endif /* _DLINKLIST_H */ diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 28c54f5a3c..6990397a74 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -46,18 +46,18 @@ #define _LDB_H_ 1 /*! \endcond */ +#include "ldb_includes.h" + /* major restrictions as compared to normal LDAP: - - no async calls. - each record must have a unique key field - the key must be representable as a NULL terminated C string and may not contain a comma or braces major restrictions as compared to tdb: - - no explicit locking calls - UPDATE: we have transactions now, better than locking --SSS. + - no explicit locking calls, but we have transactions when using ldb_tdb */ @@ -695,6 +695,9 @@ enum ldb_sequence_type { LDB_SEQ_NEXT }; +#define LDB_SEQ_GLOBAL_SEQUENCE 0x01 +#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 + struct ldb_seqnum_request { enum ldb_sequence_type type; }; @@ -1233,6 +1236,11 @@ int ldb_extended(struct ldb_context *ldb, struct ldb_result **res); /** + Obtain current/next database sequence number +*/ +int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); + +/** start a transaction */ int ldb_transaction_start(struct ldb_context *ldb); @@ -1633,6 +1641,8 @@ int ldb_msg_add_fmt(struct ldb_message *msg, */ int ldb_msg_element_compare(struct ldb_message_element *el1, struct ldb_message_element *el2); +int ldb_msg_element_compare_name(struct ldb_message_element *el1, + struct ldb_message_element *el2); /** Find elements in a message. @@ -1746,14 +1756,16 @@ const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); const char **ldb_attr_list_copy_add(TALLOC_CTX *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); +int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); +int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); +void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); +void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); + void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, const char *attr, const char *replace); -int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); -int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); -void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); /** Convert a time structure to a string diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h index 8356404409..a2927139c8 100644 --- a/source4/lib/ldb/include/ldb_includes.h +++ b/source4/lib/ldb/include/ldb_includes.h @@ -21,9 +21,7 @@ #include "system/time.h" #include <talloc.h> #include <tevent.h> -#include "ldb.h" #include "ldb_errors.h" -#include "ldb_private.h" #include "dlinklist.h" #endif /*_LDB_PRIVATE_INCLUDES_H_*/ diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h new file mode 100644 index 0000000000..4e1019184d --- /dev/null +++ b/source4/lib/ldb/include/ldb_module.h @@ -0,0 +1,161 @@ +/* + ldb database library + + Copyright (C) Simo Sorce 2008 + + ** NOTE! The following LGPL license applies to the ldb + ** 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/>. +*/ + +/* + * Name: ldb + * + * Component: ldb module header + * + * Description: defines ldb modules structures and helpers + * + */ + +#ifndef _LDB_MODULE_H_ +#define _LDB_MODULE_H_ + +#include "ldb.h" + +struct ldb_context; +struct ldb_module; + +/* + these function pointers define the operations that a ldb module can intercept +*/ +struct ldb_module_ops { + const char *name; + int (*init_context) (struct ldb_module *); + int (*search)(struct ldb_module *, struct ldb_request *); /* search */ + int (*add)(struct ldb_module *, struct ldb_request *); /* add */ + int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */ + int (*del)(struct ldb_module *, struct ldb_request *); /* delete */ + int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */ + int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */ + int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */ + int (*start_transaction)(struct ldb_module *); + int (*end_transaction)(struct ldb_module *); + int (*del_transaction)(struct ldb_module *); + int (*sequence_number)(struct ldb_module *, struct ldb_request *); + void *private_data; +}; + + +/* The following definitions come from lib/ldb/common/ldb_debug.c */ +void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); +void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, + const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + +#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) + +/* The following definitions come from lib/ldb/common/ldb.c */ + +void ldb_request_set_state(struct ldb_request *req, int state); +int ldb_request_get_status(struct ldb_request *req); + +unsigned int ldb_get_create_perms(struct ldb_context *ldb); + +const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb, + const char *syntax); + +/* The following definitions come from lib/ldb/common/ldb_attributes.c */ + +int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, + const char *name, + unsigned flags, + const struct ldb_schema_syntax *syntax); +int ldb_schema_attribute_add(struct ldb_context *ldb, + const char *name, + unsigned flags, + const char *syntax); +void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name); + +/* The following definitions come from lib/ldb/common/ldb_controls.c */ +struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); +int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); +int check_critical_controls(struct ldb_control **controls); + +/* The following definitions come from lib/ldb/common/ldb_ldif.c */ +int ldb_should_b64_encode(const struct ldb_val *val); + +/* The following definitions come from lib/ldb/common/ldb_match.c */ +int ldb_match_msg(struct ldb_context *ldb, + const struct ldb_message *msg, + const struct ldb_parse_tree *tree, + struct ldb_dn *base, + enum ldb_scope scope); + +/* The following definitions come from lib/ldb/common/ldb_modules.c */ + +struct ldb_module *ldb_module_new(TALLOC_CTX *memctx, + struct ldb_context *ldb, + const char *module_name, + const struct ldb_module_ops *ops); + +const char * ldb_module_get_name(struct ldb_module *module); +struct ldb_context *ldb_module_get_ctx(struct ldb_module *module); +void *ldb_module_get_private(struct ldb_module *module); +void ldb_module_set_private(struct ldb_module *module, void *private_data); + +int ldb_next_request(struct ldb_module *module, struct ldb_request *request); +int ldb_next_start_trans(struct ldb_module *module); +int ldb_next_end_trans(struct ldb_module *module); +int ldb_next_del_trans(struct ldb_module *module); +int ldb_next_init(struct ldb_module *module); + +void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); +void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); +void ldb_reset_err_string(struct ldb_context *ldb); + +const char *ldb_default_modules_dir(void); + +int ldb_register_module(const struct ldb_module_ops *); + +typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url, + unsigned int flags, const char *options[], + struct ldb_module **module); + +struct ldb_backend_ops { + const char *name; + ldb_connect_fn connect_fn; +}; + +const char *ldb_default_modules_dir(void); + +int ldb_register_backend(const char *url_prefix, ldb_connect_fn); + +struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); + +int ldb_module_send_entry(struct ldb_request *req, + struct ldb_message *msg, + struct ldb_control **ctrls); + +int ldb_module_send_referral(struct ldb_request *req, + char *ref); + +int ldb_module_done(struct ldb_request *req, + struct ldb_control **ctrls, + struct ldb_extended *response, + int error); + +int ldb_mod_register_control(struct ldb_module *module, const char *oid); + +#endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index cf4017ef14..1ce9e9ecfd 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -37,6 +37,9 @@ #ifndef _LDB_PRIVATE_H_ #define _LDB_PRIVATE_H_ 1 +#include "ldb.h" +#include "ldb_module.h" + struct ldb_context; struct ldb_module_ops; @@ -58,26 +61,6 @@ struct ldb_module { }; /* - these function pointers define the operations that a ldb module can intercept -*/ -struct ldb_module_ops { - const char *name; - int (*init_context) (struct ldb_module *); - int (*search)(struct ldb_module *, struct ldb_request *); /* search */ - int (*add)(struct ldb_module *, struct ldb_request *); /* add */ - int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */ - int (*del)(struct ldb_module *, struct ldb_request *); /* delete */ - int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */ - int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */ - int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */ - int (*start_transaction)(struct ldb_module *); - int (*end_transaction)(struct ldb_module *); - int (*del_transaction)(struct ldb_module *); - int (*sequence_number)(struct ldb_module *, struct ldb_request *); - void *private_data; -}; - -/* schema related information needed for matching rules */ struct ldb_schema { @@ -130,24 +113,12 @@ struct ldb_context { #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) #endif -/* - simplify out of memory handling -*/ -#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) - /* The following definitions come from lib/ldb/common/ldb.c */ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[], struct ldb_module **backend_module); void ldb_set_default_dns(struct ldb_context *ldb); -/* The following definitions come from lib/ldb/common/ldb_debug.c */ -void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, - const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); - -/* The following definitions come from lib/ldb/common/ldb_ldif.c */ -int ldb_should_b64_encode(const struct ldb_val *val); extern const struct ldb_module_ops ldb_objectclass_module_ops; extern const struct ldb_module_ops ldb_operational_module_ops; @@ -173,61 +144,17 @@ extern const struct ldb_backend_ops ldb_ldap_backend_ops; extern const struct ldb_backend_ops ldb_ldapi_backend_ops; extern const struct ldb_backend_ops ldb_ldaps_backend_ops; -int ldb_match_msg(struct ldb_context *ldb, - const struct ldb_message *msg, - const struct ldb_parse_tree *tree, - struct ldb_dn *base, - enum ldb_scope scope); - -const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb, - const char *syntax); - -/* The following definitions come from lib/ldb/common/ldb_attributes.c */ - -int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, - const char *name, - unsigned flags, - const struct ldb_schema_syntax *syntax); -int ldb_schema_attribute_add(struct ldb_context *ldb, - const char *name, - unsigned flags, - const char *syntax); -void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name); int ldb_setup_wellknown_attributes(struct ldb_context *ldb); const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname); void ldb_subclass_remove(struct ldb_context *ldb, const char *classname); int ldb_subclass_add(struct ldb_context *ldb, const char *classname, const char *subclass); -int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, - const struct ldb_val *in, struct ldb_val *out); -int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, - const struct ldb_val *v1, const struct ldb_val *v2); - -/* The following definitions come from lib/ldb/common/ldb_controls.c */ -struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); -int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); -int check_critical_controls(struct ldb_control **controls); - /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n); -void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); - -int ldb_msg_element_compare_name(struct ldb_message_element *el1, - struct ldb_message_element *el2); void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f); -/** - Obtain current/next database sequence number -*/ -int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); - -#define LDB_SEQ_GLOBAL_SEQUENCE 0x01 -#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 - - -/* MODULES specific headers -- SSS */ /* The following definitions come from lib/ldb/common/ldb_modules.c */ @@ -235,49 +162,6 @@ const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *m int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out); int ldb_load_modules(struct ldb_context *ldb, const char *options[]); int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module); -int ldb_next_request(struct ldb_module *module, struct ldb_request *request); -int ldb_next_start_trans(struct ldb_module *module); -int ldb_next_end_trans(struct ldb_module *module); -int ldb_next_del_trans(struct ldb_module *module); -int ldb_next_init(struct ldb_module *module); - -void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); -void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); -void ldb_reset_err_string(struct ldb_context *ldb); - -const char *ldb_default_modules_dir(void); - -int ldb_register_module(const struct ldb_module_ops *); - -typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url, - unsigned int flags, const char *options[], - struct ldb_module **module); - -struct ldb_backend_ops { - const char *name; - ldb_connect_fn connect_fn; -}; - -const char *ldb_default_modules_dir(void); - -int ldb_register_backend(const char *url_prefix, ldb_connect_fn); - -struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); - -int ldb_module_send_entry(struct ldb_request *req, - struct ldb_message *msg, - struct ldb_control **ctrls); - -int ldb_module_send_referral(struct ldb_request *req, - char *ref); - -int ldb_module_done(struct ldb_request *req, - struct ldb_control **ctrls, - struct ldb_extended *response, - int error); - -int ldb_mod_register_control(struct ldb_module *module, const char *oid); - struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str); diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 791cc75dc1..3901b9b436 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -42,7 +42,7 @@ #include "includes.h" -#include "ldb_includes.h" +#include "ldb_module.h" #include "tevent.h" #include "libcli/ldap/ldap.h" @@ -70,8 +70,11 @@ struct ildb_context { static void ildb_request_done(struct ildb_context *ctx, struct ldb_control **ctrls, int error) { + struct ldb_context *ldb; struct ldb_reply *ares; + ldb = ldb_module_get_ctx(ctx->module); + ctx->done = true; if (ctx->req == NULL) { @@ -81,7 +84,7 @@ static void ildb_request_done(struct ildb_context *ctx, ares = talloc_zero(ctx->req, struct ldb_reply); if (!ares) { - ldb_oom(ctx->req->handle->ldb); + ldb_oom(ldb); ctx->req->callback(ctx->req, NULL); return; } @@ -163,17 +166,21 @@ failed: */ static int ildb_map_error(struct ldb_module *module, NTSTATUS status) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ildb_private *ildb; + struct ldb_context *ldb; + + ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private); + ldb = ldb_module_get_ctx(module); TALLOC_CTX *mem_ctx = talloc_new(ildb); if (NT_STATUS_IS_OK(status)) { return LDB_SUCCESS; } if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ldb_set_errstring(module->ldb, + ldb_set_errstring(ldb, ldap_errstr(ildb->ldap, mem_ctx, status)); talloc_free(mem_ctx); if (NT_STATUS_IS_LDAP(status)) { @@ -196,6 +203,7 @@ static void ildb_request_timeout(struct tevent_context *ev, struct tevent_timer static void ildb_callback(struct ldap_request *req) { + struct ldb_context *ldb; struct ildb_context *ac; NTSTATUS status; struct ldap_SearchResEntry *search; @@ -209,6 +217,7 @@ static void ildb_callback(struct ldap_request *req) int i; ac = talloc_get_type(req->async.private_data, struct ildb_context); + ldb = ldb_module_get_ctx(ac->module); callback_failed = false; request_done = false; controls = NULL; @@ -285,7 +294,7 @@ static void ildb_callback(struct ldap_request *req) controls = talloc_steal(ac, msg->controls); if (msg->r.SearchResultDone.resultcode) { if (msg->r.SearchResultDone.errormessage) { - ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage); + ldb_set_errstring(ldb, msg->r.SearchResultDone.errormessage); } } @@ -303,7 +312,7 @@ static void ildb_callback(struct ldap_request *req) search = &(msg->r.SearchResultEntry); - ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, search->dn); + ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, search->dn); if ( ! ldb_dn_validate(ldbmsg->dn)) { ret = LDB_ERR_OPERATIONS_ERROR; break; @@ -368,21 +377,24 @@ static void ildb_callback(struct ldap_request *req) static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg) { + struct ldb_context *ldb; struct ldap_request *req; if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } + ldb = ldb_module_get_ctx(ac->module); + req = ldap_request_send(ac->ildb->ldap, msg); if (req == NULL) { - ldb_set_errstring(ac->module->ldb, "async send request failed"); + ldb_set_errstring(ldb, "async send request failed"); return LDB_ERR_OPERATIONS_ERROR; } ac->ireq = talloc_steal(ac, req); if (!ac->ireq->conn) { - ldb_set_errstring(ac->module->ldb, "connection to remote LDAP server dropped?"); + ldb_set_errstring(ldb, "connection to remote LDAP server dropped?"); return LDB_ERR_OPERATIONS_ERROR; } @@ -405,23 +417,26 @@ static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg) */ static int ildb_search(struct ildb_context *ac) { + struct ldb_context *ldb; struct ldb_request *req = ac->req; struct ldap_message *msg; int n; + ldb = ldb_module_get_ctx(ac->module); + if (!req->callback || !req->context) { - ldb_set_errstring(ac->module->ldb, "Async interface called with NULL callback function or NULL context"); + ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } if (req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, "Invalid expression parse tree"); + ldb_set_errstring(ldb, "Invalid expression parse tree"); return LDB_ERR_OPERATIONS_ERROR; } msg = new_ldap_message(req); if (msg == NULL) { - ldb_set_errstring(ac->module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -433,7 +448,7 @@ static int ildb_search(struct ildb_context *ac) msg->r.SearchRequest.basedn = ldb_dn_get_extended_linearized(msg, req->op.search.base, 0); } if (msg->r.SearchRequest.basedn == NULL) { - ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN"); + ldb_set_errstring(ldb, "Unable to determine baseDN"); talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } @@ -659,21 +674,23 @@ static bool ildb_dn_is_special(struct ldb_request *req) static int ildb_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ildb_private *ildb; struct ildb_context *ac; struct tevent_timer *te; int ret; - ildb = talloc_get_type(module->private_data, struct ildb_private); + ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private); + ldb = ldb_module_get_ctx(module); if (req->starttime == 0 || req->timeout == 0) { - ldb_set_errstring(module->ldb, "Invalid timeout settings"); + ldb_set_errstring(ldb, "Invalid timeout settings"); return LDB_ERR_TIME_LIMIT_EXCEEDED; } ac = talloc_zero(req, struct ildb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -743,22 +760,15 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, NTSTATUS status; struct cli_credentials *creds; - module = talloc(ldb, struct ldb_module); - if (!module) { - ldb_oom(ldb); - return -1; - } - talloc_set_name_const(module, "ldb_ildap backend"); - module->ldb = ldb; - module->prev = module->next = NULL; - module->ops = &ildb_ops; + module = ldb_module_new(ldb, ldb, "ldb_ildap backend", &ildb_ops); + if (!module) return -1; ildb = talloc(module, struct ildb_private); if (!ildb) { ldb_oom(ldb); goto failed; } - module->private_data = ildb; + ldb_module_set_private(module, ildb); ildb->event_ctx = ldb_get_event_context(ldb); diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 8e053818e5..e1fcdb1353 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -38,7 +38,7 @@ * author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" #define LDAP_DEPRECATED 1 #include <ldap.h> @@ -195,6 +195,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, */ static int lldb_search(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -204,21 +205,23 @@ static int lldb_search(struct lldb_context *lldb_ac) char *expression; int ret; + ldb = ldb_module_get_ctx(module); + if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context"); + ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } if (req->op.search.tree == NULL) { - ldb_set_errstring(module->ldb, "Invalid expression parse tree"); + ldb_set_errstring(ldb, "Invalid expression parse tree"); return LDB_ERR_OPERATIONS_ERROR; } if (req->controls != NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n"); + ldb_debug(ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n"); } - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base); if (req->op.search.base == NULL) { @@ -259,7 +262,7 @@ static int lldb_search(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -270,6 +273,7 @@ static int lldb_search(struct lldb_context *lldb_ac) */ static int lldb_add(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -277,7 +281,9 @@ static int lldb_add(struct lldb_context *lldb_ac) char *dn; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0); if (mods == NULL) { @@ -295,7 +301,7 @@ static int lldb_add(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -306,6 +312,7 @@ static int lldb_add(struct lldb_context *lldb_ac) */ static int lldb_modify(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -313,7 +320,9 @@ static int lldb_modify(struct lldb_context *lldb_ac) char *dn; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1); if (mods == NULL) { @@ -331,7 +340,7 @@ static int lldb_modify(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -342,13 +351,16 @@ static int lldb_modify(struct lldb_context *lldb_ac) */ static int lldb_delete(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; char *dnstr; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn); @@ -358,7 +370,7 @@ static int lldb_delete(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -369,6 +381,7 @@ static int lldb_delete(struct lldb_context *lldb_ac) */ static int lldb_rename(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -377,7 +390,9 @@ static int lldb_rename(struct lldb_context *lldb_ac) char *parentdn; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn); if (old_dn == NULL) { @@ -401,7 +416,7 @@ static int lldb_rename(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -428,14 +443,17 @@ static int lldb_del_trans(struct ldb_module *module) return LDB_SUCCESS; } -void lldb_request_done(struct ldb_request *req, +void lldb_request_done(struct lldb_context *ac, struct ldb_control **ctrls, int error) { + struct ldb_request *req; struct ldb_reply *ares; + req = ac->req; + ares = talloc_zero(req, struct ldb_reply); if (!ares) { - ldb_oom(req->handle->ldb); + ldb_oom(ldb_module_get_ctx(ac->module)); req->callback(req, NULL); return; } @@ -451,6 +469,7 @@ void lldb_request_done(struct ldb_request *req, */ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) { + struct ldb_context *ldb; struct lldb_private *lldb = ac->lldb; LDAPControl **serverctrlsp = NULL; char **referralsp = NULL; @@ -466,6 +485,8 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) int ret; int i; + ldb = ldb_module_get_ctx(ac->module); + type = ldap_msgtype(result); callback_failed = false; request_done = false; @@ -490,7 +511,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) ret = LDB_ERR_OPERATIONS_ERROR; break; } - ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, dn); + ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, dn); if ( ! ldb_dn_validate(ldbmsg->dn)) { talloc_free(ldbmsg); ret = LDB_ERR_OPERATIONS_ERROR; @@ -509,7 +530,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) bval = ldap_get_values_len(lldb->ldap, msg, attr); if (bval) { - lldb_add_msg_attr(ac->module->ldb, ldbmsg, attr, bval); + lldb_add_msg_attr(ldb, ldbmsg, attr, bval); ldap_value_free_len(bval); } } @@ -595,7 +616,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) } if (request_done) { - lldb_request_done(ac->req, ac->controls, ret); + lldb_request_done(ac, ac->controls, ret); lret = true; goto free_and_return; } @@ -606,7 +627,7 @@ free_and_return: if (matcheddnp) ldap_memfree(matcheddnp); if (errmsgp && *errmsgp) { - ldb_set_errstring(ac->module->ldb, errmsgp); + ldb_set_errstring(ldb, errmsgp); } if (errmsgp) { ldap_memfree(errmsgp); @@ -627,7 +648,7 @@ static void lldb_timeout(struct tevent_context *ev, struct lldb_context *ac; ac = talloc_get_type(private_data, struct lldb_context); - lldb_request_done(ac->req, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED); + lldb_request_done(ac, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED); } static void lldb_callback(struct tevent_context *ev, @@ -644,7 +665,7 @@ static void lldb_callback(struct tevent_context *ev, ac = talloc_get_type(private_data, struct lldb_context); if (!ac->msgid) { - lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR); return; } @@ -655,7 +676,7 @@ static void lldb_callback(struct tevent_context *ev, goto respin; } if (lret == -1) { - lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR); return; } @@ -668,9 +689,9 @@ static void lldb_callback(struct tevent_context *ev, respin: tv.tv_sec = 0; tv.tv_usec = 100; - lte = event_add_timed(ev, ac, tv, lldb_callback, ac); + lte = tevent_add_timer(ev, ac, tv, lldb_callback, ac); if (NULL == lte) { - lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR); } } @@ -709,11 +730,12 @@ static void lldb_auto_done_callback(struct tevent_context *ev, struct lldb_context *ac; ac = talloc_get_type(private_data, struct lldb_context); - lldb_request_done(ac->req, NULL, LDB_SUCCESS); + lldb_request_done(ac, NULL, LDB_SUCCESS); } static int lldb_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct lldb_private *lldb; struct lldb_context *ac; struct tevent_context *ev; @@ -721,21 +743,22 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re struct timeval tv; int ret; - lldb = talloc_get_type(module->private_data, struct lldb_private); + lldb = talloc_get_type(ldb_module_get_private(module), struct lldb_private); + ldb = ldb_module_get_ctx(module); if (req->starttime == 0 || req->timeout == 0) { - ldb_set_errstring(module->ldb, "Invalid timeout settings"); + ldb_set_errstring(ldb, "Invalid timeout settings"); return LDB_ERR_TIME_LIMIT_EXCEEDED; } - ev = ldb_get_event_context(module->ldb); + ev = ldb_get_event_context(ldb); if (NULL == ev) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_zero(module->ldb, struct lldb_context); + ac = talloc_zero(ldb, struct lldb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -747,7 +770,7 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re if (lldb_dn_is_special(req)) { tv.tv_sec = 0; tv.tv_usec = 0; - te = event_add_timed(ev, ac, tv, + te = tevent_add_timer(ev, ac, tv, lldb_auto_done_callback, ac); if (NULL == te) { return LDB_ERR_OPERATIONS_ERROR; @@ -779,13 +802,13 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re } if (ret != LDB_SUCCESS) { - lldb_request_done(req, NULL, ret); + lldb_request_done(ac, NULL, ret); return ret; } tv.tv_sec = 0; tv.tv_usec = 0; - te = event_add_timed(ev, ac, tv, lldb_callback, ac); + te = tevent_add_timer(ev, ac, tv, lldb_callback, ac); if (NULL == te) { return LDB_ERR_OPERATIONS_ERROR; } @@ -793,7 +816,7 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re tv.tv_sec = req->starttime + req->timeout; tv.tv_usec = 0; - te = event_add_timed(ev, ac, tv, lldb_timeout, ac); + te = tevent_add_timer(ev, ac, tv, lldb_timeout, ac); if (NULL == te) { return LDB_ERR_OPERATIONS_ERROR; } @@ -835,24 +858,15 @@ static int lldb_connect(struct ldb_context *ldb, int version = 3; int ret; - module = talloc(ldb, struct ldb_module); - if (module == NULL) { - ldb_oom(ldb); - talloc_free(lldb); - return -1; - } - talloc_set_name_const(module, "ldb_ldap backend"); - module->ldb = ldb; - module->prev = module->next = NULL; - module->ops = &lldb_ops; + module = ldb_module_new(ldb, ldb, "ldb_ldap backend", &lldb_ops); + if (!module) return -1; - lldb = talloc(module, struct lldb_private); + lldb = talloc_zero(module, struct lldb_private); if (!lldb) { ldb_oom(ldb); goto failed; } - module->private_data = lldb; - lldb->ldap = NULL; + ldb_module_set_private(module, lldb); ret = ldap_initialize(&lldb->ldap, url); if (ret != LDAP_SUCCESS) { diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c index 72d8378a07..ea2bfd1dc1 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.c +++ b/source4/lib/ldb/ldb_map/ldb_map.c @@ -35,7 +35,7 @@ * Author: Jelmer Vernooij, Martin Kuehl */ -#include "ldb_includes.h" +#include "ldb_module.h" #include "ldb_map.h" #include "ldb_map_private.h" @@ -102,7 +102,7 @@ /* Extract mappings from private data. */ const struct ldb_map_context *map_get_context(struct ldb_module *module) { - const struct map_private *data = talloc_get_type(module->private_data, struct map_private); + const struct map_private *data = talloc_get_type(ldb_module_get_private(module), struct map_private); return data->context; } @@ -110,11 +110,14 @@ const struct ldb_map_context *map_get_context(struct ldb_module *module) struct map_context *map_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct map_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct map_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -202,8 +205,11 @@ static struct ldb_dn *ldb_dn_rebase_remote(void *mem_ctx, const struct ldb_map_c int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_message *msg; + ldb = ldb_module_get_ctx(module); + switch (request->operation) { case LDB_SEARCH: if (request->op.search.base) { @@ -236,7 +242,7 @@ int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *reque break; default: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Invalid remote request!\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -462,6 +468,7 @@ bool ldb_dn_check_local(struct ldb_module *module, struct ldb_dn *dn) struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_dn *newdn; const struct ldb_map_attribute *map; enum ldb_map_attr_type map_type; @@ -473,6 +480,8 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct return NULL; } + ldb = ldb_module_get_ctx(module); + newdn = ldb_dn_copy(mem_ctx, dn); if (newdn == NULL) { map_oom(module); @@ -493,14 +502,14 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct switch (map_type) { case MAP_IGNORE: case MAP_GENERATE: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "MAP_IGNORE/MAP_GENERATE attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; case MAP_CONVERT: if (map->u.convert.convert_local == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "'convert_local' not set for attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; @@ -534,6 +543,7 @@ failed: struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_dn *newdn; const struct ldb_map_attribute *map; enum ldb_map_attr_type map_type; @@ -545,6 +555,8 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc return NULL; } + ldb = ldb_module_get_ctx(module); + newdn = ldb_dn_copy(mem_ctx, dn); if (newdn == NULL) { map_oom(module); @@ -565,14 +577,14 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc switch (map_type) { case MAP_IGNORE: case MAP_GENERATE: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "MAP_IGNORE/MAP_GENERATE attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; case MAP_CONVERT: if (map->u.convert.convert_remote == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "'convert_remote' not set for attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; @@ -623,10 +635,13 @@ struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx /* Map a DN contained in an ldb value into the remote partition. */ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val) { + struct ldb_context *ldb; struct ldb_dn *dn, *newdn; struct ldb_val newval; - dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val); if (! ldb_dn_validate(dn)) { newval.length = 0; newval.data = NULL; @@ -649,10 +664,13 @@ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ /* Map a DN contained in an ldb value into the local partition. */ static struct ldb_val ldb_dn_convert_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val) { + struct ldb_context *ldb; struct ldb_dn *dn, *newdn; struct ldb_val newval; - dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val); if (! ldb_dn_validate(dn)) { newval.length = 0; newval.data = NULL; @@ -693,11 +711,14 @@ static struct ldb_val map_objectclass_convert_local(struct ldb_module *module, v static void map_objectclass_generate_remote(struct ldb_module *module, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_message_element *el, *oc; struct ldb_val val; bool found_extensibleObject = false; int i; + ldb = ldb_module_get_ctx(module); + /* Find old local objectClass */ oc = ldb_msg_find_element(old, "objectClass"); if (oc == NULL) { @@ -707,7 +728,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha /* Prepare new element */ el = talloc_zero(remote, struct ldb_message_element); if (el == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return; /* TODO: fail? */ } @@ -716,7 +737,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha el->values = talloc_array(el, struct ldb_val, el->num_values); if (el->values == NULL) { talloc_free(el); - ldb_oom(module->ldb); + ldb_oom(ldb); return; /* TODO: fail? */ } @@ -766,10 +787,13 @@ static struct ldb_val map_objectclass_convert_remote(struct ldb_module *module, static struct ldb_message_element *map_objectclass_generate_local(struct ldb_module *module, void *mem_ctx, const char *local_attr, const struct ldb_message *remote) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_message_element *el, *oc; struct ldb_val val; int i; + ldb = ldb_module_get_ctx(module); + /* Find old remote objectClass */ oc = ldb_msg_find_element(remote, "objectClass"); if (oc == NULL) { @@ -779,7 +803,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod /* Prepare new element */ el = talloc_zero(mem_ctx, struct ldb_message_element); if (el == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -788,7 +812,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod el->values = talloc_array(el, struct ldb_val, el->num_values); if (el->values == NULL) { talloc_free(el); - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -809,7 +833,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod el->values = talloc_realloc(el, el->values, struct ldb_val, el->num_values); if (el->values == NULL) { talloc_free(el); - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } } @@ -847,9 +871,12 @@ static int map_objectclass_convert_operator(struct ldb_module *module, void *mem struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_map_callback_t callback) { const struct ldb_parse_tree *search_tree; + struct ldb_context *ldb; struct ldb_request *req; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (tree) { search_tree = tree; } else { @@ -859,7 +886,7 @@ struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *d } } - ret = ldb_build_search_req_ex(&req, ac->module->ldb, ac, + ret = ldb_build_search_req_ex(&req, ldb, ac, dn, LDB_SCOPE_BASE, search_tree, attrs, NULL, @@ -879,11 +906,14 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, void *context, ldb_map_callback_t callback) { + struct ldb_context *ldb; struct ldb_request *req; struct ldb_message *msg; const char *dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* Prepare message */ msg = ldb_msg_new(ac); if (msg == NULL) { @@ -905,7 +935,7 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, } /* Prepare request */ - ret = ldb_build_mod_req(&req, ac->module->ldb, + ret = ldb_build_mod_req(&req, ldb, ac, msg, NULL, context, callback, ac->req); @@ -961,6 +991,7 @@ static const struct ldb_map_attribute objectclass_attribute_map = { static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, const char *name) { static const char * const attrs[] = { MAP_DN_FROM, MAP_DN_TO, NULL }; + struct ldb_context *ldb; struct ldb_dn *dn; struct ldb_message *msg; struct ldb_result *res; @@ -972,34 +1003,36 @@ static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, return LDB_SUCCESS; } - dn = ldb_dn_new_fmt(data, module->ldb, "%s=%s", MAP_DN_NAME, name); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_new_fmt(data, ldb, "%s=%s", MAP_DN_NAME, name); if ( ! ldb_dn_validate(dn)) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Failed to construct '%s' DN!\n", MAP_DN_NAME); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL); + ret = ldb_search(ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL); talloc_free(dn); if (ret != LDB_SUCCESS) { return ret; } if (res->count == 0) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "No results for '%s=%s'!\n", MAP_DN_NAME, name); talloc_free(res); return LDB_ERR_CONSTRAINT_VIOLATION; } if (res->count > 1) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Too many results for '%s=%s'!\n", MAP_DN_NAME, name); talloc_free(res); return LDB_ERR_CONSTRAINT_VIOLATION; } msg = res->msgs[0]; - data->local_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_FROM); - data->remote_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_TO); + data->local_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_FROM); + data->remote_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_TO); talloc_free(res); return LDB_SUCCESS; @@ -1075,7 +1108,7 @@ _PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attrib return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; + ldb_module_set_private(module, data); data->context = talloc_zero(data, struct ldb_map_context); if (!data->context) { diff --git a/source4/lib/ldb/ldb_map/ldb_map.h b/source4/lib/ldb/ldb_map/ldb_map.h index 7f92c15b98..872208174e 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.h +++ b/source4/lib/ldb/ldb_map/ldb_map.h @@ -67,7 +67,7 @@ struct ldb_map_attribute { } type; /* if set, will be called for search expressions that contain this attribute */ - int (*convert_operator)(struct ldb_module *, TALLOC_CTX *ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *); + int (*convert_operator)(struct ldb_module *, TALLOC_CTX *ctx, struct ldb_parse_tree **ntree, const struct ldb_parse_tree *otree); union { struct { diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c index 96605f23eb..e915a5f46a 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c @@ -24,7 +24,7 @@ */ -#include "ldb_includes.h" +#include "ldb_module.h" #include "ldb_map.h" #include "ldb_map_private.h" @@ -69,10 +69,11 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l const struct ldb_map_context *data = map_get_context(module); const struct ldb_map_attribute *map = map_attr_find_local(data, attr_name); struct ldb_message_element *el=NULL; + struct ldb_context *ldb = ldb_module_get_ctx(module); /* Unknown attribute: ignore */ if (map == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Not mapping attribute '%s': no mapping found\n", old->name); goto local; @@ -84,7 +85,7 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l case MAP_CONVERT: if (map->u.convert.convert_local == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Not mapping attribute '%s': " "'convert_local' not set\n", map->local_name); @@ -98,7 +99,7 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l case MAP_GENERATE: if (map->u.generate.generate_remote == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Not mapping attribute '%s': " "'generate_remote' not set\n", map->local_name); @@ -158,12 +159,15 @@ static bool ldb_msg_check_remote(struct ldb_module *module, const struct ldb_mes static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg) { /* const char * const names[]; */ + struct ldb_context *ldb; int i, ret; + ldb = ldb_module_get_ctx(module); + for (i = 0; i < msg->num_elements; i++) { /* Skip 'IS_MAPPED' */ if (ldb_attr_cmp(msg->elements[i].name, IS_MAPPED) == 0) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Skipping attribute '%s'\n", msg->elements[i].name); continue; @@ -195,10 +199,12 @@ static int map_rename_local_callback(struct ldb_request *req, /* Store the DN of a single search result in context. */ static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -214,7 +220,7 @@ static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *a case LDB_REPLY_ENTRY: /* We have already found a remote DN */ if (ac->local_dn) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Too many results!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -284,10 +290,12 @@ static int map_search_self_req(struct ldb_request **req, static int map_op_local_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -299,7 +307,7 @@ static int map_op_local_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -317,9 +325,11 @@ static int map_op_local_callback(struct ldb_request *req, static int map_op_remote_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -331,7 +341,7 @@ static int map_op_remote_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -350,11 +360,14 @@ static int map_op_remote_callback(struct ldb_request *req, int map_add(struct ldb_module *module, struct ldb_request *req) { const struct ldb_message *msg = req->op.add.message; + struct ldb_context *ldb; struct map_context *ac; struct ldb_message *remote_msg; const char *dn; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { return ldb_next_request(module, req); @@ -397,7 +410,7 @@ int map_add(struct ldb_module *module, struct ldb_request *req) ldb_msg_partition(module, ac->local_msg, remote_msg, msg); /* Prepare the remote operation */ - ret = ldb_build_add_req(&ac->remote_req, module->ldb, + ret = ldb_build_add_req(&ac->remote_req, ldb, ac, remote_msg, req->controls, ac, map_op_remote_callback, @@ -426,10 +439,13 @@ int map_add(struct ldb_module *module, struct ldb_request *req) static int map_add_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* Prepare the local operation */ - ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&local_req, ldb, ac, ac->local_msg, ac->req->controls, ac, @@ -451,9 +467,12 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) const struct ldb_message *msg = req->op.mod.message; struct ldb_request *search_req; struct ldb_message *remote_msg; + struct ldb_context *ldb; struct map_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { return ldb_next_request(module, req); @@ -498,7 +517,7 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) ldb_msg_partition(module, ac->local_msg, remote_msg, msg); /* Prepare the remote operation */ - ret = ldb_build_mod_req(&ac->remote_req, module->ldb, + ret = ldb_build_mod_req(&ac->remote_req, ldb, ac, remote_msg, req->controls, ac, map_op_remote_callback, @@ -526,9 +545,12 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) static int map_modify_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; char *dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->local_dn == NULL) { /* No local record present, add it instead */ /* Add local 'IS_MAPPED' */ @@ -544,7 +566,7 @@ static int map_modify_do_local(struct map_context *ac) } /* Prepare the local operation */ - ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&local_req, ldb, ac, ac->local_msg, ac->req->controls, ac, @@ -555,7 +577,7 @@ static int map_modify_do_local(struct map_context *ac) } } else { /* Prepare the local operation */ - ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&local_req, ldb, ac, ac->local_msg, ac->req->controls, ac, @@ -577,9 +599,12 @@ static int map_modify_do_local(struct map_context *ac) int map_delete(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *search_req; + struct ldb_context *ldb; struct map_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.del.dn)) { return ldb_next_request(module, req); @@ -598,7 +623,7 @@ int map_delete(struct ldb_module *module, struct ldb_request *req) } /* Prepare the remote operation */ - ret = ldb_build_del_req(&ac->remote_req, module->ldb, ac, + ret = ldb_build_del_req(&ac->remote_req, ldb, ac, ldb_dn_map_local(module, ac, req->op.del.dn), req->controls, ac, @@ -628,8 +653,11 @@ int map_delete(struct ldb_module *module, struct ldb_request *req) static int map_delete_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* No local record, continue remotely */ if (ac->local_dn == NULL) { /* Do the remote request. */ @@ -637,7 +665,7 @@ static int map_delete_do_local(struct map_context *ac) } /* Prepare the local operation */ - ret = ldb_build_del_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_del_req(&local_req, ldb, ac, ac->req->op.del.dn, ac->req->controls, ac, @@ -657,9 +685,12 @@ static int map_delete_do_local(struct map_context *ac) int map_rename(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *search_req; + struct ldb_context *ldb; struct map_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.rename.olddn)) { return ldb_next_request(module, req); @@ -685,7 +716,7 @@ int map_rename(struct ldb_module *module, struct ldb_request *req) } /* Prepare the remote operation */ - ret = ldb_build_rename_req(&ac->remote_req, module->ldb, ac, + ret = ldb_build_rename_req(&ac->remote_req, ldb, ac, ldb_dn_map_local(module, ac, req->op.rename.olddn), ldb_dn_map_local(module, ac, req->op.rename.newdn), req->controls, @@ -715,8 +746,11 @@ int map_rename(struct ldb_module *module, struct ldb_request *req) static int map_rename_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* No local record, continue remotely */ if (ac->local_dn == NULL) { /* Do the remote request. */ @@ -724,7 +758,7 @@ static int map_rename_do_local(struct map_context *ac) } /* Prepare the local operation */ - ret = ldb_build_rename_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_rename_req(&local_req, ldb, ac, ac->req->op.rename.olddn, ac->req->op.rename.newdn, ac->req->controls, @@ -741,10 +775,12 @@ static int map_rename_do_local(struct map_context *ac) static int map_rename_local_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -756,7 +792,7 @@ static int map_rename_local_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c index 5588eaaf46..327fa92f8d 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c @@ -25,7 +25,7 @@ */ -#include "ldb_includes.h" +#include "ldb_module.h" #include "ldb_map.h" #include "ldb_map_private.h" @@ -264,6 +264,9 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local const struct ldb_map_attribute *map; struct ldb_message_element *old, *el=NULL; const char *remote_name = NULL; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(module); /* We handle wildcards in ldb_msg_el_merge_wildcard */ if (ldb_attr_cmp(attr_name, "*") == 0) { @@ -300,7 +303,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local case MAP_CONVERT: if (map->u.convert.convert_remote == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Skipping attribute '%s': " "'convert_remote' not set\n", attr_name); @@ -319,7 +322,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local case MAP_GENERATE: if (map->u.generate.generate_local == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Skipping attribute '%s': " "'generate_local' not set\n", attr_name); @@ -869,6 +872,9 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx, { const struct ldb_map_context *data = map_get_context(module); const struct ldb_map_attribute *map; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(module); if (tree == NULL) { return 0; @@ -893,7 +899,7 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx, } if (map->type == MAP_GENERATE) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Skipping attribute '%s': " "'convert_operator' not set\n", tree->u.equality.attr); @@ -1045,14 +1051,17 @@ int map_return_entry(struct map_context *ac, struct ldb_reply *ares) { struct ldb_message_element *el; const char * const *attrs; + struct ldb_context *ldb; int i; + ldb = ldb_module_get_ctx(ac->module); + /* Merged result doesn't match original query, skip */ - if (!ldb_match_msg(ac->module->ldb, ares->message, + if (!ldb_match_msg(ldb, ares->message, ac->req->op.search.tree, ac->req->op.search.base, ac->req->op.search.scope)) { - ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: " "Skipping record '%s': " "doesn't match original search\n", ldb_dn_get_linearized(ares->message->dn)); @@ -1086,13 +1095,17 @@ int map_search(struct ldb_module *module, struct ldb_request *req) struct ldb_parse_tree *remote_tree; struct ldb_parse_tree *local_tree; struct ldb_request *remote_req; + struct ldb_context *ldb; struct map_context *ac; int ret; const char *wildcard[] = { "*", NULL }; const char * const *attrs; - if (!module->private_data) /* if we're not yet initialized, go to the next module */ + ldb = ldb_module_get_ctx(module); + + /* if we're not yet initialized, go to the next module */ + if (!ldb_module_get_private(module)) return ldb_next_request(module, req); /* Do not manipulate our control entries */ @@ -1165,7 +1178,7 @@ int map_search(struct ldb_module *module, struct ldb_request *req) ac->local_tree = local_tree; /* Prepare the remote operation */ - ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&remote_req, ldb, ac, req->op.search.base, req->op.search.scope, remote_tree, @@ -1282,10 +1295,12 @@ static int map_search_local(struct map_context *ac) /* Merge the remote and local parts of a search result. */ int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -1301,7 +1316,7 @@ int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares) /* We have already found a local record */ if (ac->r_current->local) { talloc_free(ares); - ldb_set_errstring(ac->module->ldb, "ldb_map: Too many results!"); + ldb_set_errstring(ldb, "ldb_map: Too many results!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h index 0543ba71b9..0c46443253 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_private.h +++ b/source4/lib/ldb/ldb_map/ldb_map_private.h @@ -1,6 +1,6 @@ /* A handy macro to report Out of Memory conditions */ -#define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); +#define map_oom(module) ldb_set_errstring(ldb_module_get_ctx(module), talloc_asprintf(module, "Out of Memory")); /* The type of search callback functions */ typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *); diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index be99c29d1e..8acbac4cc3 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -1,23 +1,23 @@ -/* +/* ldb database library - + Copyright (C) Derrell Lipman 2005 - Copyright (C) Simo Sorce 2005-2006 - + Copyright (C) Simo Sorce 2005-2009 + ** NOTE! The following LGPL license applies to the ldb ** 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/>. */ @@ -32,7 +32,7 @@ * Author: Derrell Lipman (based on Andrew Tridgell's LDAP backend) */ -#include "ldb_includes.h" +#include "ldb_module.h" #include <sqlite3.h> @@ -50,6 +50,9 @@ struct lsql_context { long long current_eid; const char * const * attrs; struct ldb_reply *ares; + + bool callback_failed; + struct tevent_timer *timeout_event; }; /* @@ -63,7 +66,8 @@ struct lsql_context { #define RESULT_ATTR_TABLE "temp_result_attrs" -//#define TEMPTAB /* for testing, create non-temporary table */ + +/* for testing, define to nothing, (create non-temporary table) */ #define TEMPTAB "TEMPORARY" /* @@ -144,7 +148,7 @@ base160_sql(sqlite3_context * hContext, val = sqlite3_value_int64(argv[0]); for (i = 3; i >= 0; i--) { - + result[i] = base160tab[val % 160]; val /= 160; } @@ -244,6 +248,7 @@ static char *parsetree_to_sql(struct ldb_module *module, void *mem_ctx, const struct ldb_parse_tree *t) { + struct ldb_context *ldb; const struct ldb_schema_attribute *a; struct ldb_val value, subval; char *wild_card_string; @@ -252,6 +257,7 @@ static char *parsetree_to_sql(struct ldb_module *module, char *attr; int i; + ldb = ldb_module_get_ctx(module); switch(t->operation) { case LDB_OP_AND: @@ -271,7 +277,7 @@ static char *parsetree_to_sql(struct ldb_module *module, ret = talloc_asprintf(mem_ctx, "SELECT * FROM ( %s )\n", tmp); return ret; - + case LDB_OP_OR: tmp = parsetree_to_sql(module, mem_ctx, t->u.list.elements[0]); @@ -304,10 +310,10 @@ static char *parsetree_to_sql(struct ldb_module *module, */ attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -315,7 +321,7 @@ static char *parsetree_to_sql(struct ldb_module *module, if (strcasecmp(t->u.equality.attr, "dn") == 0) { /* DN query is a special ldb case */ const char *cdn = ldb_dn_get_casefold( - ldb_dn_new(mem_ctx, module->ldb, + ldb_dn_new(mem_ctx, ldb, (const char *)value.data)); return lsqlite3_tprintf(mem_ctx, @@ -352,13 +358,13 @@ static char *parsetree_to_sql(struct ldb_module *module, attr = ldb_attr_casefold(mem_ctx, t->u.substring.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); subval.data = (void *)wild_card_string; subval.length = strlen(wild_card_string) + 1; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(subval), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(subval), &value); if (value.data == NULL) { return NULL; } @@ -373,10 +379,10 @@ static char *parsetree_to_sql(struct ldb_module *module, case LDB_OP_GREATER: attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -392,10 +398,10 @@ static char *parsetree_to_sql(struct ldb_module *module, case LDB_OP_LESS: attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -424,10 +430,10 @@ static char *parsetree_to_sql(struct ldb_module *module, case LDB_OP_APPROX: attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -439,7 +445,7 @@ static char *parsetree_to_sql(struct ldb_module *module, attr, value.data, attr); - + case LDB_OP_EXTENDED: #warning "work out how to handle bitops" return NULL; @@ -473,22 +479,22 @@ query_int(const struct lsqlite3_private * lsqlite3, char * p; sqlite3_stmt * pStmt; va_list args; - + /* Begin access to variable argument list */ va_start(args, pSql); - + /* Format the query */ if ((p = sqlite3_vmprintf(pSql, args)) == NULL) { return SQLITE_NOMEM; } - + /* * Prepare and execute the SQL statement. Loop allows retrying on * certain errors, e.g. SQLITE_SCHEMA occurs if the schema changes, * requiring retrying the operation. */ for (bLoop = TRUE; bLoop; ) { - + /* Compile the SQL statement into sqlite virtual machine */ if ((ret = sqlite3_prepare(lsqlite3->sqlite, p, @@ -503,7 +509,7 @@ query_int(const struct lsqlite3_private * lsqlite3, } else if (ret != SQLITE_OK) { break; } - + /* One row expected */ if ((ret = sqlite3_step(pStmt)) == SQLITE_SCHEMA) { if (stmtGetEID != NULL) { @@ -516,10 +522,10 @@ query_int(const struct lsqlite3_private * lsqlite3, (void) sqlite3_finalize(pStmt); break; } - + /* Get the value to be returned */ *pRet = sqlite3_column_int64(pStmt, 0); - + /* Free the virtual machine */ if ((ret = sqlite3_finalize(pStmt)) == SQLITE_SCHEMA) { if (stmtGetEID != NULL) { @@ -531,21 +537,21 @@ query_int(const struct lsqlite3_private * lsqlite3, (void) sqlite3_finalize(pStmt); break; } - + /* * Normal condition is only one time through loop. Loop is * rerun in error conditions, via "continue", above. */ bLoop = FALSE; } - + /* All done with variable argument list */ va_end(args); - + /* Free the memory we allocated for our query string */ sqlite3_free(p); - + return ret; } @@ -574,9 +580,9 @@ static void lsqlite3_compare(sqlite3_context *ctx, int argc, /* greater */ case '>': /* >= */ a = ldb_schema_attribute_by_name(ldb, attr); - valX.data = (void *)cmp; + valX.data = (uint8_t *)cmp; valX.length = strlen(cmp); - valY.data = (void *)val; + valY.data = (uint8_t *)val; valY.length = strlen(val); ret = a->syntax->comparison_fn(ldb, ldb, &valY, &valX); if (ret >= 0) @@ -588,9 +594,9 @@ static void lsqlite3_compare(sqlite3_context *ctx, int argc, /* lesser */ case '<': /* <= */ a = ldb_schema_attribute_by_name(ldb, attr); - valX.data = (void *)cmp; + valX.data = (uint8_t *)cmp; valX.length = strlen(cmp); - valY.data = (void *)val; + valY.data = (uint8_t *)val; valY.length = strlen(val); ret = a->syntax->comparison_fn(ldb, ldb, &valY, &valX); if (ret <= 0) @@ -656,49 +662,52 @@ static int lsqlite3_eid_callback(void *result, int col_num, char **cols, char ** */ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char **names) { - struct ldb_handle *handle = talloc_get_type(result, struct ldb_handle); - struct lsql_context *ac = talloc_get_type(handle->private_data, struct lsql_context); + struct ldb_context *ldb; + struct lsql_context *ac; struct ldb_message *msg; long long eid; - int i; + int i, ret; + + ac = talloc_get_type(result, struct lsql_context); + ldb = ldb_module_get_ctx(ac->module); /* eid, dn, attr_name, attr_value */ - if (col_num != 4) - return SQLITE_ABORT; + if (col_num != 4) return SQLITE_ABORT; eid = atoll(cols[0]); + if (ac->ares) { + msg = ac->ares->message; + } + if (eid != ac->current_eid) { /* here begin a new entry */ /* call the async callback for the last entry * except the first time */ if (ac->current_eid != 0) { - ac->ares->message = ldb_msg_canonicalize(ac->module->ldb, ac->ares->message); - if (ac->ares->message == NULL) - return SQLITE_ABORT; - - handle->status = ac->callback(ac->module->ldb, ac->context, ac->ares); - if (handle->status != LDB_SUCCESS) + msg = ldb_msg_canonicalize(ldb, msg); + if (!msg) return SQLITE_ABORT; + + ret = ldb_module_send_entry(ac->req, msg, NULL); + if (ret != LDB_SUCCESS) { + ac->callback_failed = true; return SQLITE_ABORT; + } } /* start over */ ac->ares = talloc_zero(ac, struct ldb_reply); - if (!ac->ares) - return SQLITE_ABORT; + if (!ac->ares) return SQLITE_ABORT; - ac->ares->message = ldb_msg_new(ac->ares); - if (!ac->ares->message) - return SQLITE_ABORT; + msg = ldb_msg_new(ac->ares); + if (!msg) return SQLITE_ABORT; ac->ares->type = LDB_REPLY_ENTRY; ac->current_eid = eid; } - msg = ac->ares->message; - if (msg->dn == NULL) { - msg->dn = ldb_dn_new(msg, ac->module->ldb, cols[1]); + msg->dn = ldb_dn_new(msg, ldb, cols[1]); if (msg->dn == NULL) return SQLITE_ABORT; } @@ -711,13 +720,15 @@ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char break; } } - if (!found) return SQLITE_OK; + if (!found) goto done; } if (ldb_msg_add_string(msg, cols[2], cols[3]) != 0) { return SQLITE_ABORT; } +done: + ac->ares->message = msg; return SQLITE_OK; } @@ -755,10 +766,10 @@ static long long lsqlite3_get_eid_ndn(sqlite3 *sqlite, void *mem_ctx, const char return eid; } -static long long lsqlite3_get_eid(struct ldb_module *module, struct ldb_dn *dn) +static long long lsqlite3_get_eid(struct lsqlite3_private *lsqlite3, + struct ldb_dn *dn) { TALLOC_CTX *local_ctx; - struct lsqlite3_private *lsqlite3 = module->private_data; long long eid = -1; char *cdn; @@ -788,38 +799,44 @@ done: */ /* search for matching records, by tree */ -int lsql_search(struct ldb_module *module, struct ldb_request *req) +int lsql_search(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; char *norm_basedn; char *sqlfilter; char *errmsg; char *query = NULL; int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); - if ((( ! ldb_dn_is_valid(req->op.search.base)) || ldb_dn_is_null(req->op.search.base)) && - (req->op.search.scope == LDB_SCOPE_BASE || req->op.search.scope == LDB_SCOPE_ONELEVEL)) + if ((( ! ldb_dn_is_valid(req->op.search.base)) || + ldb_dn_is_null(req->op.search.base)) && + (req->op.search.scope == LDB_SCOPE_BASE || + req->op.search.scope == LDB_SCOPE_ONELEVEL)) { return LDB_ERR_OPERATIONS_ERROR; + } if (req->op.search.base) { - norm_basedn = ldb_dn_alloc_casefold(lsql_ac, req->op.search.base); + norm_basedn = ldb_dn_alloc_casefold(ctx, req->op.search.base); if (norm_basedn == NULL) { - ret = LDB_ERR_INVALID_DN_SYNTAX; - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } - } else norm_basedn = talloc_strdup(lsql_ac, ""); + } else norm_basedn = talloc_strdup(ctx, ""); /* Convert filter into a series of SQL conditions (constraints) */ - sqlfilter = parsetree_to_sql(module, lsql_ac, req->op.search.tree); - + sqlfilter = parsetree_to_sql(module, ctx, req->op.search.tree); + switch(req->op.search.scope) { case LDB_SCOPE_DEFAULT: case LDB_SCOPE_SUBTREE: if (*norm_basedn != '\0') { - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -843,7 +860,7 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) norm_basedn, sqlfilter); } else { - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -865,9 +882,9 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) } break; - + case LDB_SCOPE_BASE: - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -889,9 +906,9 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) norm_basedn, sqlfilter); break; - + case LDB_SCOPE_ONELEVEL: - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -917,113 +934,108 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) } if (query == NULL) { - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } /* * / printf ("%s\n", query); / * */ - lsql_ac->current_eid = 0; - lsql_ac->attrs = req->op.search.attrs; - lsql_ac->ares = NULL; + ctx->current_eid = 0; + ctx->attrs = req->op.search.attrs; + ctx->ares = NULL; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); - ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, req->handle, &errmsg); + ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, ctx, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } /* complete the last message if any */ - if (lsql_ac->ares) { - lsql_ac->ares->message = ldb_msg_canonicalize(module->ldb, lsql_ac->ares->message); - if (lsql_ac->ares->message == NULL) - goto failed; - - req->handle->status = lsql_ac->callback(module->ldb, lsql_ac->context, lsql_ac->ares); - if (req->handle->status != LDB_SUCCESS) - goto failed; + if (ctx->ares) { + ctx->ares->message = ldb_msg_canonicalize(ldb, ctx->ares->message); + if (ctx->ares->message == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_module_send_entry(req, ctx->ares->message, NULL); + if (ret != LDB_SUCCESS) { + return ret; + } } - req->handle->state = LDB_ASYNC_DONE; return LDB_SUCCESS; - -failed: - return LDB_ERR_OPERATIONS_ERROR; } /* add a record */ -static int lsql_add(struct ldb_module *module, struct ldb_request *req) +static int lsql_add(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; struct ldb_message *msg = req->op.add.message; long long eid; char *dn, *ndn; char *errmsg; char *query; int i; - int ret = LDB_SUCCESS; + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); /* See if this is an ltdb special */ if (ldb_dn_is_special(msg->dn)) { /* struct ldb_dn *c; - c = ldb_dn_new(local_ctx, module->ldb, "@INDEXLIST"); - if (ldb_dn_compare(module->ldb, msg->dn, c) == 0) { + c = ldb_dn_new(local_ctx, ldb, "@INDEXLIST"); + if (ldb_dn_compare(ldb, msg->dn, c) == 0) { #warning "should we handle indexes somehow ?" ret = LDB_ERR_UNWILLING_TO_PERFORM; goto done; } */ /* Others return an error */ - ret = LDB_ERR_UNWILLING_TO_PERFORM; - goto done; + return LDB_ERR_UNWILLING_TO_PERFORM; } /* create linearized and normalized dns */ - dn = ldb_dn_alloc_linearized(lsql_ac, msg->dn); - ndn = ldb_dn_alloc_casefold(lsql_ac, msg->dn); + dn = ldb_dn_alloc_linearized(ctx, msg->dn); + ndn = ldb_dn_alloc_casefold(ctx, msg->dn); if (dn == NULL || ndn == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, /* Add new entry */ "INSERT OR ABORT INTO ldb_entry " "('dn', 'norm_dn') " "VALUES ('%q', '%q');", dn, ndn); if (query == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, lsql_ac, ndn); + eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, ctx, ndn); if (eid == -1) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } for (i = 0; i < msg->num_elements; i++) { @@ -1033,13 +1045,12 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) int j; /* Get a case-folded copy of the attribute name */ - attr = ldb_attr_casefold(lsql_ac, el->name); + attr = ldb_attr_casefold(ctx, el->name); if (attr == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - a = ldb_schema_attribute_by_name(module->ldb, el->name); + a = ldb_schema_attribute_by_name(ldb, el->name); /* For each value of the specified attribute name... */ for (j = 0; j < el->num_values; j++) { @@ -1047,13 +1058,12 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) char *insert; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, lsql_ac, &(el->values[j]), &value); + a->syntax->canonicalise_fn(ldb, ctx, &(el->values[j]), &value); if (value.data == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - insert = lsqlite3_tprintf(lsql_ac, + insert = lsqlite3_tprintf(ctx, "INSERT OR ROLLBACK INTO ldb_attribute_values " "('eid', 'attr_name', 'norm_attr_name'," " 'attr_value', 'norm_attr_value') " @@ -1061,57 +1071,49 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) eid, el->name, attr, el->values[j].data, value.data); if (insert == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, insert, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } } - if (lsql_ac->callback) { - req->handle->status = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); - } - -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* modify a record */ -static int lsql_modify(struct ldb_module *module, struct ldb_request *req) +static int lsql_modify(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; struct ldb_message *msg = req->op.mod.message; long long eid; char *errmsg; int i; - int ret = LDB_SUCCESS; + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); /* See if this is an ltdb special */ if (ldb_dn_is_special(msg->dn)) { /* Others return an error */ - ret = LDB_ERR_UNWILLING_TO_PERFORM; - goto done; + return LDB_ERR_UNWILLING_TO_PERFORM; } - eid = lsqlite3_get_eid(module, msg->dn); + eid = lsqlite3_get_eid(lsqlite3, msg->dn); if (eid == -1) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } for (i = 0; i < msg->num_elements; i++) { @@ -1123,37 +1125,34 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) int j; /* Get a case-folded copy of the attribute name */ - attr = ldb_attr_casefold(lsql_ac, el->name); + attr = ldb_attr_casefold(ctx, el->name); if (attr == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - a = ldb_schema_attribute_by_name(module->ldb, el->name); + a = ldb_schema_attribute_by_name(ldb, el->name); switch (flags) { case LDB_FLAG_MOD_REPLACE: - + /* remove all attributes before adding the replacements */ - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "DELETE FROM ldb_attribute_values " "WHERE eid = '%lld' " "AND norm_attr_name = '%q';", eid, attr); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* MISSING break is INTENTIONAL */ @@ -1165,13 +1164,12 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) struct ldb_val value; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, lsql_ac, &(el->values[j]), &value); + a->syntax->canonicalise_fn(ldb, ctx, &(el->values[j]), &value); if (value.data == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "INSERT OR ROLLBACK INTO ldb_attribute_values " "('eid', 'attr_name', 'norm_attr_name'," " 'attr_value', 'norm_attr_value') " @@ -1180,18 +1178,16 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) el->values[j].data, value.data); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } @@ -1200,24 +1196,22 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) case LDB_FLAG_MOD_DELETE: #warning "We should throw an error if the attribute we are trying to delete does not exist!" if (el->num_values == 0) { - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "DELETE FROM ldb_attribute_values " "WHERE eid = '%lld' " "AND norm_attr_name = '%q';", eid, attr); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } @@ -1226,13 +1220,12 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) struct ldb_val value; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, lsql_ac, &(el->values[j]), &value); + a->syntax->canonicalise_fn(ldb, ctx, &(el->values[j]), &value); if (value.data == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "DELETE FROM ldb_attribute_values " "WHERE eid = '%lld' " "AND norm_attr_name = '%q' " @@ -1240,18 +1233,16 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) eid, attr, value.data); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } @@ -1259,121 +1250,106 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) } } - if (lsql_ac->callback) { - req->handle->status = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); - } - -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* delete a record */ -static int lsql_delete(struct ldb_module *module, struct ldb_request *req) +static int lsql_delete(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; long long eid; char *errmsg; char *query; - int ret = LDB_SUCCESS; - + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); - eid = lsqlite3_get_eid(module, req->op.del.dn); + eid = lsqlite3_get_eid(lsqlite3, req->op.del.dn); if (eid == -1) { - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, /* Delete entry */ "DELETE FROM ldb_entry WHERE eid = %lld; " /* Delete attributes */ "DELETE FROM ldb_attribute_values WHERE eid = %lld; ", eid, eid); if (query == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - req->handle->status = LDB_ERR_OPERATIONS_ERROR; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - if (lsql_ac->callback) { - ret = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); - } - -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* rename a record */ -static int lsql_rename(struct ldb_module *module, struct ldb_request *req) +static int lsql_rename(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; char *new_dn, *new_cdn, *old_cdn; char *errmsg; char *query; - int ret = LDB_SUCCESS; + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); /* create linearized and normalized dns */ - old_cdn = ldb_dn_alloc_casefold(lsql_ac, req->op.rename.olddn); - new_cdn = ldb_dn_alloc_casefold(lsql_ac, req->op.rename.newdn); - new_dn = ldb_dn_alloc_linearized(lsql_ac, req->op.rename.newdn); + old_cdn = ldb_dn_alloc_casefold(ctx, req->op.rename.olddn); + new_cdn = ldb_dn_alloc_casefold(ctx, req->op.rename.newdn); + new_dn = ldb_dn_alloc_linearized(ctx, req->op.rename.newdn); if (old_cdn == NULL || new_cdn == NULL || new_dn == NULL) { - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* build the SQL query */ - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "UPDATE ldb_entry SET dn = '%q', norm_dn = '%q' " "WHERE norm_dn = '%q';", new_dn, new_cdn, old_cdn); if (query == NULL) { - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* execute */ ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; - } - - if (lsql_ac->callback) { - ret = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); + return LDB_ERR_OPERATIONS_ERROR; } -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } static int lsql_start_trans(struct ldb_module * module) { int ret; char *errmsg; - struct lsqlite3_private * lsqlite3 = module->private_data; + struct lsqlite3_private *lsqlite3; + + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); if (lsqlite3->trans_count == 0) { ret = sqlite3_exec(lsqlite3->sqlite, "BEGIN IMMEDIATE;", NULL, NULL, &errmsg); @@ -1395,7 +1371,10 @@ static int lsql_end_trans(struct ldb_module *module) { int ret; char *errmsg; - struct lsqlite3_private *lsqlite3 = module->private_data; + struct lsqlite3_private *lsqlite3; + + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); if (lsqlite3->trans_count > 0) { lsqlite3->trans_count--; @@ -1417,7 +1396,10 @@ static int lsql_end_trans(struct ldb_module *module) static int lsql_del_trans(struct ldb_module *module) { - struct lsqlite3_private *lsqlite3 = module->private_data; + struct lsqlite3_private *lsqlite3; + + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); if (lsqlite3->trans_count > 0) { lsqlite3->trans_count--; @@ -1431,69 +1413,132 @@ static int lsql_del_trans(struct ldb_module *module) } static int destructor(struct lsqlite3_private *lsqlite3) -{ +{ if (lsqlite3->sqlite) { sqlite3_close(lsqlite3->sqlite); } return 0; } -static int lsql_request(struct ldb_module *module, struct ldb_request *req) +static void lsql_request_done(struct lsql_context *ctx, int error) { - return LDB_ERR_OPERATIONS_ERROR; + struct ldb_context *ldb; + struct ldb_request *req; + struct ldb_reply *ares; + + ldb = ldb_module_get_ctx(ctx->module); + req = ctx->req; + + /* if we already returned an error just return */ + if (ldb_request_get_status(req) != LDB_SUCCESS) { + return; + } + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(ldb); + req->callback(req, NULL); + return; + } + ares->type = LDB_REPLY_DONE; + ares->error = error; + + req->callback(req, ares); +} + +static void lsql_timeout(struct tevent_context *ev, + struct tevent_timer *te, + struct timeval t, + void *private_data) +{ + struct lsql_context *ctx; + ctx = talloc_get_type(private_data, struct lsql_context); + + lsql_request_done(ctx, LDB_ERR_TIME_LIMIT_EXCEEDED); } -static int lsql_run_request(struct ldb_module *module, struct ldb_request *req) +static void lsql_callback(struct tevent_context *ev, + struct tevent_timer *te, + struct timeval t, + void *private_data) { - switch (req->operation) { + struct lsql_context *ctx; + int ret; + + ctx = talloc_get_type(private_data, struct lsql_context); + + switch (ctx->req->operation) { case LDB_SEARCH: - return lsql_search(module, req); + ret = lsql_search(ctx); break; case LDB_ADD: - return lsql_add(module, req); + ret = lsql_add(ctx); break; case LDB_MODIFY: - return lsql_modify(module, req); + ret = lsql_modify(ctx); break; case LDB_DELETE: - return lsql_delete(module, req); + ret = lsql_delete(ctx); break; case LDB_RENAME: - return lsql_rename(module, req); + ret = lsql_rename(ctx); break; /* TODO: - case LDB_SEQUENCE_NUMBER: - return lsql_sequence_number(module, req); + case LDB_EXTENDED: + ret = lsql_extended(ctx); break; */ default: - return lsql_request(module, req); - break; + /* no other op supported */ + ret = LDB_ERR_UNWILLING_TO_PERFORM; } - return LDB_ERR_OPERATIONS_ERROR; + if (!ctx->callback_failed) { + /* Once we are done, we do not need timeout events */ + talloc_free(ctx->timeout_event); + lsql_request_done(ctx, ret); + } } static int lsql_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; + struct tevent_context *ev; struct lsql_context *ac; + struct tevent_timer *te; + struct timeval tv; if (check_critical_controls(req->controls)) { return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; } + if (req->starttime == 0 || req->timeout == 0) { + ldb_set_errstring(ldb, "Invalid timeout settings"); + return LDB_ERR_TIME_LIMIT_EXCEEDED; + } + + ldb = ldb_module_get_ctx(module); + ev = ldb_get_event_context(ldb); + ac = talloc_zero(req, struct lsql_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } ac->module = module; ac->req = req; - req->handle = ldb_handle_new(req, lsql_run_request, ac); - if (req->handle == NULL) { - talloc_free(ac); + tv.tv_sec = 0; + tv.tv_usec = 0; + te = tevent_add_timer(ev, ac, tv, lsql_callback, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; + } + + tv.tv_sec = req->starttime + req->timeout; + ac->timeout_event = tevent_add_timer(ev, ac, tv, lsql_timeout, ac); + if (NULL == ac->timeout_event) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1510,11 +1555,10 @@ static const struct ldb_module_ops lsqlite3_ops = { .modify = lsql_handle_request, .del = lsql_handle_request, .rename = lsql_handle_request, - .request = lsql_handle_request, + .extended = lsql_handle_request, .start_transaction = lsql_start_trans, .end_transaction = lsql_end_trans, .del_transaction = lsql_del_trans, - /* TODO: .sequence_number = lsql_handle_request */ }; /* @@ -1538,15 +1582,15 @@ static int initialize(struct lsqlite3_private *lsqlite3, } schema = lsqlite3_tprintf(local_ctx, - - + + "CREATE TABLE ldb_info AS " " SELECT 'LDB' AS database_type," " '1.0' AS version;" - + /* - * The entry table holds the information about an entry. - * This table is used to obtain the EID of the entry and to + * The entry table holds the information about an entry. + * This table is used to obtain the EID of the entry and to * support scope=one and scope=base. The parent and child * table is included in the entry table since all the other * attributes are dependent on EID. @@ -1557,7 +1601,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, " dn TEXT UNIQUE NOT NULL," " norm_dn TEXT UNIQUE NOT NULL" ");" - + "CREATE TABLE ldb_object_classes" "(" @@ -1566,7 +1610,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, " tree_key TEXT UNIQUE," " max_child_num INTEGER DEFAULT 0" ");" - + /* * We keep a full listing of attribute/value pairs here */ @@ -1578,23 +1622,23 @@ static int initialize(struct lsqlite3_private *lsqlite3, " attr_value TEXT," " norm_attr_value TEXT " ");" - - + + /* * Indexes */ "CREATE INDEX ldb_attribute_values_eid_idx " " ON ldb_attribute_values (eid);" - + "CREATE INDEX ldb_attribute_values_name_value_idx " " ON ldb_attribute_values (attr_name, norm_attr_value);" - - + + /* * Triggers */ - + "CREATE TRIGGER ldb_object_classes_insert_tr" " AFTER INSERT" " ON ldb_object_classes" @@ -1624,20 +1668,20 @@ static int initialize(struct lsqlite3_private *lsqlite3, " (class_name, tree_key) " " VALUES " " ('TOP', '0001');"); - + /* Skip protocol indicator of url */ if (strncmp(url, "sqlite3://", 10) != 0) { return SQLITE_MISUSE; } - + /* Update pointer to just after the protocol indicator */ url += 10; - + /* Try to open the (possibly empty/non-existent) database */ if ((ret = sqlite3_open(url, &lsqlite3->sqlite)) != SQLITE_OK) { return ret; } - + /* In case this is a new database, enable auto_vacuum */ ret = sqlite3_exec(lsqlite3->sqlite, "PRAGMA auto_vacuum = 1;", NULL, NULL, &errmsg); if (ret != SQLITE_OK) { @@ -1647,7 +1691,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, } goto failed; } - + if (flags & LDB_FLG_NOSYNC) { /* DANGEROUS */ ret = sqlite3_exec(lsqlite3->sqlite, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg); @@ -1659,9 +1703,9 @@ static int initialize(struct lsqlite3_private *lsqlite3, goto failed; } } - + /* */ - + /* Establish a busy timeout of 30 seconds */ if ((ret = sqlite3_busy_timeout(lsqlite3->sqlite, 30000)) != SQLITE_OK) { @@ -1720,7 +1764,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, goto failed; } rollback = 1; - + /* Determine if this is a new database. No tables means it is. */ if (query_int(lsqlite3, &queryInt, @@ -1729,7 +1773,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, " WHERE type = 'table';") != 0) { goto failed; } - + if (queryInt == 0) { /* * Create the database schema @@ -1765,12 +1809,12 @@ static int initialize(struct lsqlite3_private *lsqlite3, " AND version = '1.0'" " );") != 0 || queryInt != 1) { - + /* It's not one that we created. See ya! */ goto failed; } } - + /* Commit the transaction */ ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg); if (ret != SQLITE_OK) { @@ -1780,11 +1824,11 @@ static int initialize(struct lsqlite3_private *lsqlite3, } goto failed; } - + return SQLITE_OK; failed: - if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); + if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); sqlite3_close(lsqlite3->sqlite); return -1; } @@ -1793,43 +1837,35 @@ failed: * connect to the database */ static int lsqlite3_connect(struct ldb_context *ldb, - const char *url, - unsigned int flags, + const char *url, + unsigned int flags, const char *options[], - struct ldb_module **module) + struct ldb_module **_module) { - int i; - int ret; - struct lsqlite3_private * lsqlite3 = NULL; - - lsqlite3 = talloc(ldb, struct lsqlite3_private); + struct ldb_module *module; + struct lsqlite3_private *lsqlite3; + int i, ret; + + module = ldb_module_new(ldb, ldb, "ldb_sqlite3 backend", &lsqlite3_ops); + if (!module) return -1; + + lsqlite3 = talloc(module, struct lsqlite3_private); if (!lsqlite3) { goto failed; } - + lsqlite3->sqlite = NULL; lsqlite3->options = NULL; lsqlite3->trans_count = 0; - + ret = initialize(lsqlite3, ldb, url, flags); if (ret != SQLITE_OK) { goto failed; } - - talloc_set_destructor(lsqlite3, destructor); - + talloc_set_destructor(lsqlite3, destructor); - *module = talloc(ldb, struct ldb_module); - if (!module) { - ldb_oom(ldb); - goto failed; - } - talloc_set_name_const(*module, "ldb_sqlite3 backend"); - (*module)->ldb = ldb; - (*module)->prev = (*module)->next = NULL; - (*module)->private_data = lsqlite3; - (*module)->ops = &lsqlite3_ops; + ldb_module_set_private(module, lsqlite3); if (options) { /* @@ -1837,14 +1873,14 @@ static int lsqlite3_connect(struct ldb_context *ldb, * on the caller keeping it around (it might be dynamic) */ for (i=0;options[i];i++) ; - + lsqlite3->options = talloc_array(lsqlite3, char *, i+1); if (!lsqlite3->options) { goto failed; } - + for (i=0;options[i];i++) { - + lsqlite3->options[i+1] = NULL; lsqlite3->options[i] = talloc_strdup(lsqlite3->options, options[i]); @@ -1853,11 +1889,12 @@ static int lsqlite3_connect(struct ldb_context *ldb, } } } - + + *_module = module; return 0; - + failed: - if (lsqlite3->sqlite != NULL) { + if (lsqlite3 && lsqlite3->sqlite != NULL) { (void) sqlite3_close(lsqlite3->sqlite); } talloc_free(lsqlite3); diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index 2576e2c7bd..43b965f239 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -31,8 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" - #include "ldb_tdb.h" #define LTDB_FLAG_CASE_INSENSITIVE (1<<0) @@ -57,10 +55,14 @@ static const struct { */ static void ltdb_attributes_unload(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg; int i; + ldb = ldb_module_get_ctx(module); + if (ltdb->cache->attributes == NULL) { /* no previously loaded attributes */ return; @@ -68,7 +70,7 @@ static void ltdb_attributes_unload(struct ldb_module *module) msg = ltdb->cache->attributes; for (i=0;i<msg->num_elements;i++) { - ldb_schema_attribute_remove(module->ldb, msg->elements[i].name); + ldb_schema_attribute_remove(ldb, msg->elements[i].name); } talloc_free(ltdb->cache->attributes); @@ -104,12 +106,16 @@ static int ltdb_attributes_flags(struct ldb_message_element *el, unsigned *v) */ static int ltdb_attributes_load(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg = ltdb->cache->attributes; struct ldb_dn *dn; int i, r; - dn = ldb_dn_new(module, module->ldb, LTDB_ATTRIBUTES); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_new(module, ldb, LTDB_ATTRIBUTES); if (dn == NULL) goto failed; r = ltdb_search_dn1(module, dn, msg); @@ -128,7 +134,7 @@ static int ltdb_attributes_load(struct ldb_module *module) const struct ldb_schema_syntax *s; if (ltdb_attributes_flags(&msg->elements[i], &flags) != 0) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name); + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name); goto failed; } switch (flags & ~LTDB_FLAG_HIDDEN) { @@ -142,22 +148,22 @@ static int ltdb_attributes_load(struct ldb_module *module) syntax = LDB_SYNTAX_INTEGER; break; default: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid flag combination 0x%x for '%s' in @ATTRIBUTES\n", flags, msg->elements[i].name); goto failed; } - s = ldb_standard_syntax_by_name(module->ldb, syntax); + s = ldb_standard_syntax_by_name(ldb, syntax); if (s == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid attribute syntax '%s' for '%s' in @ATTRIBUTES\n", syntax, msg->elements[i].name); goto failed; } flags |= LDB_ATTR_FLAG_ALLOCATED; - if (ldb_schema_attribute_add_with_syntax(module->ldb, msg->elements[i].name, flags, s) != 0) { + if (ldb_schema_attribute_add_with_syntax(ldb, msg->elements[i].name, flags, s) != 0) { goto failed; } } @@ -173,7 +179,9 @@ failed: */ static int ltdb_baseinfo_init(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg; struct ldb_message_element el; struct ldb_val val; @@ -183,6 +191,8 @@ static int ltdb_baseinfo_init(struct ldb_module *module) out. */ const char *initial_sequence_number = "1"; + ldb = ldb_module_get_ctx(module); + ltdb->sequence_number = atof(initial_sequence_number); msg = talloc(ltdb, struct ldb_message); @@ -192,7 +202,7 @@ static int ltdb_baseinfo_init(struct ldb_module *module) msg->num_elements = 1; msg->elements = ⪙ - msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO); + msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO); if (!msg->dn) { goto failed; } @@ -226,7 +236,8 @@ failed: */ static void ltdb_cache_free(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->sequence_number = 0; talloc_free(ltdb->cache); @@ -248,13 +259,17 @@ int ltdb_cache_reload(struct ldb_module *module) */ int ltdb_cache_load(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL; struct ldb_dn *indexlist_dn = NULL; uint64_t seq; struct ldb_message *baseinfo = NULL, *options = NULL; int r; + ldb = ldb_module_get_ctx(module); + /* a very fast check to avoid extra database reads */ if (ltdb->cache != NULL && tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) { @@ -275,7 +290,7 @@ int ltdb_cache_load(struct ldb_module *module) baseinfo = talloc(ltdb->cache, struct ldb_message); if (baseinfo == NULL) goto failed; - baseinfo_dn = ldb_dn_new(module, module->ldb, LTDB_BASEINFO); + baseinfo_dn = ldb_dn_new(module, ldb, LTDB_BASEINFO); if (baseinfo_dn == NULL) goto failed; r= ltdb_search_dn1(module, baseinfo_dn, baseinfo); @@ -307,7 +322,7 @@ int ltdb_cache_load(struct ldb_module *module) options = talloc(ltdb->cache, struct ldb_message); if (options == NULL) goto failed; - options_dn = ldb_dn_new(options, module->ldb, LTDB_OPTIONS); + options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS); if (options_dn == NULL) goto failed; r= ltdb_search_dn1(module, options_dn, options); @@ -336,7 +351,7 @@ int ltdb_cache_load(struct ldb_module *module) goto failed; } - indexlist_dn = ldb_dn_new(module, module->ldb, LTDB_INDEXLIST); + indexlist_dn = ldb_dn_new(module, ldb, LTDB_INDEXLIST); if (indexlist_dn == NULL) goto failed; r = ltdb_search_dn1(module, indexlist_dn, ltdb->cache->indexlist); @@ -369,7 +384,9 @@ failed: */ int ltdb_increase_sequence_number(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg; struct ldb_message_element el[2]; struct ldb_val val; @@ -378,6 +395,8 @@ int ltdb_increase_sequence_number(struct ldb_module *module) char *s = NULL; int ret; + ldb = ldb_module_get_ctx(module); + msg = talloc(ltdb, struct ldb_message); if (msg == NULL) { errno = ENOMEM; @@ -392,7 +411,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module) msg->num_elements = ARRAY_SIZE(el); msg->elements = el; - msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO); + msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO); if (msg->dn == NULL) { talloc_free(msg); errno = ENOMEM; diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index c4c23022f8..cdbef3944b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -31,8 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" - #include "ldb_tdb.h" /* @@ -69,8 +67,8 @@ struct ltdb_idxptr { */ static int ltdb_idxptr_add(struct ldb_module *module, const struct ldb_message *msg) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->idxptr->dn_list = talloc_realloc(ltdb->idxptr, ltdb->idxptr->dn_list, const char *, ltdb->idxptr->num_dns+1); if (ltdb->idxptr->dn_list == NULL) { @@ -177,8 +175,8 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_ struct ldb_index_pointer *ptr, *tmp; int i; struct ldb_val *val2; - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ptr = NULL; @@ -216,8 +214,8 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_ /* enable the idxptr mode when transactions start */ int ltdb_index_transaction_start(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->idxptr = talloc_zero(module, struct ltdb_idxptr); return LDB_SUCCESS; } @@ -260,11 +258,14 @@ static int ltdb_search_dn1_index(struct ldb_module *module, */ static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn) { + struct ldb_context *ldb; struct ldb_dn *dn; struct ldb_message *msg = ldb_msg_new(module); int ret; - dn = ldb_dn_new(msg, module->ldb, strdn); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_new(msg, ldb, strdn); if (ltdb_search_dn1_index(module, dn, msg) == LDB_SUCCESS) { ret = ltdb_store(module, msg, TDB_REPLACE); } @@ -276,8 +277,8 @@ static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn) int ltdb_index_transaction_commit(struct ldb_module *module) { int i; - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); /* fix all the DNs that we have modified */ if (ltdb->idxptr) { @@ -298,8 +299,8 @@ int ltdb_index_transaction_commit(struct ldb_module *module) /* cleanup the idxptr mode when transaction cancels */ int ltdb_index_transaction_cancel(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); talloc_free(ltdb->idxptr); ltdb->idxptr = NULL; return LDB_SUCCESS; @@ -314,8 +315,8 @@ int ltdb_index_transaction_cancel(struct ldb_module *module) */ int ltdb_store_idxptr(struct ldb_module *module, const struct ldb_message *msg, int flgs) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; if (ltdb->idxptr) { @@ -510,12 +511,14 @@ static int ltdb_index_dn_simple(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct ldb_dn *dn; int ret; unsigned int i, j; struct ldb_message *msg; + ldb = ldb_module_get_ctx(module); + list->count = 0; list->dn = NULL; @@ -587,15 +590,18 @@ static int ltdb_index_dn_leaf(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { + struct ldb_context *ldb; + ldb = ldb_module_get_ctx(module); + if (ldb_attr_dn(tree->u.equality.attr) == 0) { list->dn = talloc_array(list, char *, 1); if (list->dn == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } list->dn[0] = talloc_strdup(list->dn, (char *)tree->u.equality.value.data); if (list->dn[0] == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } list->count = 1; @@ -707,10 +713,12 @@ static int ltdb_index_dn_or(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i; int ret; + ldb = ldb_module_get_ctx(module); + ret = LDB_ERR_OPERATIONS_ERROR; list->dn = NULL; list->count = 0; @@ -791,10 +799,12 @@ static int ltdb_index_dn_and(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i; int ret; + ldb = ldb_module_get_ctx(module); + ret = LDB_ERR_OPERATIONS_ERROR; list->dn = NULL; list->count = 0; @@ -852,7 +862,7 @@ static int ltdb_index_dn_one(struct ldb_module *module, struct ldb_dn *parent_dn, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct dn_list *list2; struct ldb_message *msg; struct ldb_dn *key; @@ -860,6 +870,8 @@ static int ltdb_index_dn_one(struct ldb_module *module, unsigned int i, j; int ret; + ldb = ldb_module_get_ctx(module); + list2 = talloc_zero(module, struct dn_list); if (list2 == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -991,9 +1003,12 @@ static int ltdb_index_dn(struct ldb_module *module, static int ltdb_index_filter(const struct dn_list *dn_list, struct ltdb_context *ac) { + struct ldb_context *ldb; struct ldb_message *msg; unsigned int i; + ldb = ldb_module_get_ctx(ac->module); + for (i = 0; i < dn_list->count; i++) { struct ldb_dn *dn; int ret; @@ -1003,7 +1018,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list, return LDB_ERR_OPERATIONS_ERROR; } - dn = ldb_dn_new(msg, ac->module->ldb, dn_list->dn[i]); + dn = ldb_dn_new(msg, ldb, dn_list->dn[i]); if (dn == NULL) { talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; @@ -1023,7 +1038,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list, return LDB_ERR_OPERATIONS_ERROR; } - if (!ldb_match_msg(ac->module->ldb, msg, + if (!ldb_match_msg(ldb, msg, ac->tree, ac->base, ac->scope)) { talloc_free(msg); continue; @@ -1054,10 +1069,14 @@ static int ltdb_index_filter(const struct dn_list *dn_list, */ int ltdb_search_indexed(struct ltdb_context *ac) { - struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private); + struct ldb_context *ldb; + void *data = ldb_module_get_private(ac->module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct dn_list *dn_list; int ret, idxattr, idxone; + ldb = ldb_module_get_ctx(ac->module); + idxattr = idxone = 0; ret = ldb_msg_find_idx(ltdb->cache->indexlist, NULL, NULL, LTDB_IDXATTR); if (ret == 0 ) { @@ -1087,12 +1106,12 @@ int ltdb_search_indexed(struct ltdb_context *ac) /* with BASE searches only one DN can match */ dn_list->dn = talloc_array(dn_list, char *, 1); if (dn_list->dn == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } dn_list->dn[0] = ldb_dn_alloc_linearized(dn_list, ac->base); if (dn_list->dn[0] == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } dn_list->count = 1; @@ -1198,12 +1217,14 @@ static int ltdb_index_add1_add(struct ldb_context *ldb, static int ltdb_index_add1(struct ldb_module *module, const char *dn, struct ldb_message_element *el, int v_idx) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct ldb_message *msg; struct ldb_dn *dn_key; int ret; unsigned int i; + ldb = ldb_module_get_ctx(module); + msg = talloc(module, struct ldb_message); if (msg == NULL) { errno = ENOMEM; @@ -1253,7 +1274,8 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn, static int ltdb_index_add0(struct ldb_module *module, const char *dn, struct ldb_message_element *elements, int num_el) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; unsigned int i, j; @@ -1308,12 +1330,14 @@ int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg) int ltdb_index_del_value(struct ldb_module *module, const char *dn, struct ldb_message_element *el, int v_idx) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct ldb_message *msg; struct ldb_dn *dn_key; int ret, i; unsigned int j; + ldb = ldb_module_get_ctx(module); + if (dn[0] == '@') { return LDB_SUCCESS; } @@ -1351,7 +1375,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn, ldb_dn_get_linearized(dn_key)); ldif.changetype = LDB_CHANGETYPE_NONE; ldif.msg = msg; - ldb_ldif_write_file(module->ldb, stdout, &ldif); + ldb_ldif_write_file(ldb, stdout, &ldif); sleep(100); /* it ain't there. hmmm */ talloc_free(dn_key); @@ -1383,7 +1407,8 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn, */ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; const char *dn; unsigned int i, j; @@ -1425,7 +1450,8 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg) */ int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message_element el; struct ldb_val val; struct ldb_dn *pdn; @@ -1489,12 +1515,15 @@ static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, vo */ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { + struct ldb_context *ldb; struct ldb_module *module = (struct ldb_module *)state; struct ldb_message *msg; const char *dn = NULL; int ret; TDB_DATA key2; + ldb = ldb_module_get_ctx(module); + if (strncmp((char *)key.dptr, "DN=@", 4) == 0 || strncmp((char *)key.dptr, "DN=", 3) != 0) { return 0; @@ -1516,7 +1545,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * key2 = ltdb_key(module, msg->dn); if (key2.dptr == NULL) { /* probably a corrupt record ... darn */ - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n", + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n", ldb_dn_get_linearized(msg->dn)); talloc_free(msg); return 0; @@ -1537,7 +1566,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * if (ret == LDB_SUCCESS) { ret = ltdb_index_add0(module, dn, msg->elements, msg->num_elements); } else { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "Adding special ONE LEVEL index failed (%s)!\n", ldb_dn_get_linearized(msg->dn)); } @@ -1554,7 +1583,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * */ int ltdb_reindex(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; if (ltdb_cache_reload(module) != 0) { diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index afb07dcbca..1995606f88 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -31,7 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" #include "ldb_tdb.h" /* change this if the data format ever changes */ @@ -79,13 +78,15 @@ int ltdb_pack_data(struct ldb_module *module, const struct ldb_message *message, struct TDB_DATA *data) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i, j, real_elements=0; size_t size; const char *dn; uint8_t *p; size_t len; + ldb = ldb_module_get_ctx(module); + dn = ldb_dn_get_linearized(message->dn); if (dn == NULL) { errno = ENOMEM; @@ -159,13 +160,14 @@ int ltdb_unpack_data(struct ldb_module *module, const struct TDB_DATA *data, struct ldb_message *message) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; uint8_t *p; unsigned int remaining; unsigned int i, j; unsigned format; size_t len; + ldb = ldb_module_get_ctx(module); message->elements = NULL; p = data->dptr; diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 35149c4b77..0f595267fc 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -31,8 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" - #include "ldb_tdb.h" /* @@ -112,10 +110,12 @@ static int msg_add_distinguished_name(struct ldb_message *msg) static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *ret, const struct ldb_message *msg) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i; int check_duplicates = (ret->num_elements != 0); + ldb = ldb_module_get_ctx(module); + if (msg_add_distinguished_name(ret) != 0) { return -1; } @@ -207,7 +207,8 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module, */ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key, tdb_data; if (ldb_dn_is_null(dn)) { @@ -239,7 +240,8 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn) */ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; TDB_DATA tdb_key, tdb_data; @@ -371,11 +373,13 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) */ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { + struct ldb_context *ldb; struct ltdb_context *ac; struct ldb_message *msg; int ret; ac = talloc_get_type(state, struct ltdb_context); + ldb = ldb_module_get_ctx(ac->module); if (key.dsize < 4 || strncmp((char *)key.dptr, "DN=", 3) != 0) { @@ -395,7 +399,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } if (!msg->dn) { - msg->dn = ldb_dn_new(msg, ac->module->ldb, + msg->dn = ldb_dn_new(msg, ldb, (char *)key.dptr + 3); if (msg->dn == NULL) { talloc_free(msg); @@ -404,7 +408,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } /* see if it matches the given expression */ - if (!ldb_match_msg(ac->module->ldb, msg, + if (!ldb_match_msg(ldb, msg, ac->tree, ac->base, ac->scope)) { talloc_free(msg); return 0; @@ -435,7 +439,8 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi */ static int ltdb_search_full(struct ltdb_context *ctx) { - struct ltdb_private *ltdb = talloc_get_type(ctx->module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(ctx->module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; if (ltdb->in_transaction != 0) { @@ -457,12 +462,16 @@ static int ltdb_search_full(struct ltdb_context *ctx) */ int ltdb_search(struct ltdb_context *ctx) { + struct ldb_context *ldb; struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; - struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb = ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -483,12 +492,12 @@ int ltdb_search(struct ltdb_context *ctx) /* Check what we should do with a NULL dn */ switch (req->op.search.scope) { case LDB_SCOPE_BASE: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "NULL Base DN invalid for a base search"); ret = LDB_ERR_INVALID_DN_SYNTAX; break; case LDB_SCOPE_ONELEVEL: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "NULL Base DN invalid for a one-level search"); ret = LDB_ERR_INVALID_DN_SYNTAX; break; @@ -500,7 +509,7 @@ int ltdb_search(struct ltdb_context *ctx) } else if (ldb_dn_is_valid(req->op.search.base) == false) { /* We don't want invalid base DNs here */ - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Invalid Base DN: %s", ldb_dn_get_linearized(req->op.search.base)); ret = LDB_ERR_INVALID_DN_SYNTAX; @@ -510,7 +519,7 @@ int ltdb_search(struct ltdb_context *ctx) ret = ltdb_search_base(module, req->op.search.base); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "No such Base DN: %s", ldb_dn_get_linearized(req->op.search.base)); } @@ -539,7 +548,7 @@ int ltdb_search(struct ltdb_context *ctx) /* Not indexed, so we need to do a full scan */ ret = ltdb_search_full(ctx); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n"); + ldb_set_errstring(ldb, "Indexed and full searches both failed!\n"); } } } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 9528f5a662..d6276c4b86 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -45,8 +45,6 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" - #include "ldb_tdb.h" @@ -84,7 +82,8 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code) */ int ltdb_lock_read(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); if (ltdb->in_transaction == 0) { return tdb_lockall_read(ltdb->tdb); } @@ -96,7 +95,8 @@ int ltdb_lock_read(struct ldb_module *module) */ int ltdb_unlock_read(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); if (ltdb->in_transaction == 0) { return tdb_unlockall_read(ltdb->tdb); } @@ -113,7 +113,7 @@ int ltdb_unlock_read(struct ldb_module *module) */ struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb = ldb_module_get_ctx(module); TDB_DATA key; char *key_str = NULL; const char *dn_folded = NULL; @@ -164,6 +164,7 @@ failed: static int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *msg) { + struct ldb_context *ldb = ldb_module_get_ctx(module); int i, j; if (! ldb_dn_is_special(msg->dn) || @@ -176,7 +177,7 @@ static int ltdb_check_special_dn(struct ldb_module *module, for (i = 0; i < msg->num_elements; i++) { for (j = 0; j < msg->elements[i].num_values; j++) { if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) { - ldb_set_errstring(module->ldb, "Invalid attribute value in an @ATTRIBUTES entry"); + ldb_set_errstring(ldb, "Invalid attribute value in an @ATTRIBUTES entry"); return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; } } @@ -214,8 +215,8 @@ static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn) */ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key, tdb_data; int ret; @@ -252,6 +253,7 @@ done: static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message *msg) { + struct ldb_context *ldb = ldb_module_get_ctx(module); int ret; ret = ltdb_check_special_dn(module, msg); @@ -266,7 +268,7 @@ static int ltdb_add_internal(struct ldb_module *module, ret = ltdb_store(module, msg, TDB_INSERT); if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Entry %s already exists", ldb_dn_get_linearized(msg->dn)); return ret; @@ -296,7 +298,7 @@ static int ltdb_add(struct ltdb_context *ctx) struct ldb_request *req = ctx->req; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); tret = ltdb_add_internal(module, req->op.add.message); if (tret != LDB_SUCCESS) { @@ -312,8 +314,8 @@ static int ltdb_add(struct ltdb_context *ctx) */ int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key; int ret; @@ -386,7 +388,7 @@ static int ltdb_delete(struct ltdb_context *ctx) struct ldb_request *req = ctx->req; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_cache_load(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -514,7 +516,7 @@ static int msg_delete_element(struct ldb_module *module, const char *name, const struct ldb_val *val) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb = ldb_module_get_ctx(module); unsigned int i; int found; struct ldb_message_element *el; @@ -560,9 +562,9 @@ static int msg_delete_element(struct ldb_module *module, int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg) { - struct ldb_context *ldb = module->ldb; - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + struct ldb_context *ldb = ldb_module_get_ctx(module); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key, tdb_data; struct ldb_message *msg2; unsigned i, j; @@ -625,12 +627,12 @@ int ltdb_modify_internal(struct ldb_module *module, for (j=0;j<el->num_values;j++) { if (ldb_msg_find_val(el2, &el->values[j])) { - ldb_asprintf_errstring(module->ldb, "%s: value #%d already exists", el->name, j); + ldb_asprintf_errstring(ldb, "%s: value #%d already exists", el->name, j); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto failed; } if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j); + ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto failed; } @@ -661,7 +663,7 @@ int ltdb_modify_internal(struct ldb_module *module, for (j=0;j<el->num_values;j++) { if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j); + ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto failed; } @@ -688,7 +690,7 @@ int ltdb_modify_internal(struct ldb_module *module, if (msg->elements[i].num_values == 0) { if (msg_delete_attribute(module, ldb, msg2, msg->elements[i].name) != 0) { - ldb_asprintf_errstring(module->ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn); + ldb_asprintf_errstring(ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn); ret = LDB_ERR_NO_SUCH_ATTRIBUTE; goto failed; } @@ -699,7 +701,7 @@ int ltdb_modify_internal(struct ldb_module *module, msg2, msg->elements[i].name, &msg->elements[i].values[j]) != 0) { - ldb_asprintf_errstring(module->ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn); + ldb_asprintf_errstring(ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn); ret = LDB_ERR_NO_SUCH_ATTRIBUTE; goto failed; } @@ -710,7 +712,7 @@ int ltdb_modify_internal(struct ldb_module *module, } break; default: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Invalid ldb_modify flags on %s: 0x%x", msg->elements[i].name, msg->elements[i].flags & LDB_FLAG_MOD_MASK); @@ -750,7 +752,7 @@ static int ltdb_modify(struct ltdb_context *ctx) struct ldb_request *req = ctx->req; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); tret = ltdb_check_special_dn(module, req->op.mod.message); if (tret != LDB_SUCCESS) { @@ -779,7 +781,7 @@ static int ltdb_rename(struct ltdb_context *ctx) struct ldb_message *msg; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_cache_load(ctx->module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -841,8 +843,8 @@ static int ltdb_rename(struct ltdb_context *ctx) static int ltdb_start_trans(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); if (tdb_transaction_start(ltdb->tdb) != 0) { return ltdb_err_map(tdb_error(ltdb->tdb)); @@ -857,8 +859,8 @@ static int ltdb_start_trans(struct ldb_module *module) static int ltdb_end_trans(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->in_transaction--; @@ -875,8 +877,8 @@ static int ltdb_end_trans(struct ldb_module *module) static int ltdb_del_trans(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->in_transaction--; @@ -897,6 +899,7 @@ static int ltdb_del_trans(struct ldb_module *module) static int ltdb_sequence_number(struct ltdb_context *ctx, struct ldb_extended **ext) { + struct ldb_context *ldb; struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; TALLOC_CTX *tmp_ctx; @@ -907,13 +910,15 @@ static int ltdb_sequence_number(struct ltdb_context *ctx, const char *date; int ret; + ldb = ldb_module_get_ctx(module); + seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request); if (seq == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -930,7 +935,7 @@ static int ltdb_sequence_number(struct ltdb_context *ctx, goto done; } - dn = ldb_dn_new(tmp_ctx, module->ldb, LTDB_BASEINFO); + dn = ldb_dn_new(tmp_ctx, ldb, LTDB_BASEINFO); msg = talloc(tmp_ctx, struct ldb_message); if (msg == NULL) { @@ -978,18 +983,23 @@ done: return ret; } -static void ltdb_request_done(struct ldb_request *req, int error) +static void ltdb_request_done(struct ltdb_context *ctx, int error) { + struct ldb_context *ldb; + struct ldb_request *req; struct ldb_reply *ares; + ldb = ldb_module_get_ctx(ctx->module); + req = ctx->req; + /* if we already returned an error just return */ - if (req->handle->status != LDB_SUCCESS) { + if (ldb_request_get_status(req) != LDB_SUCCESS) { return; } ares = talloc_zero(req, struct ldb_reply); if (!ares) { - ldb_oom(req->handle->ldb); + ldb_oom(ldb); req->callback(req, NULL); return; } @@ -1007,23 +1017,28 @@ static void ltdb_timeout(struct tevent_context *ev, struct ltdb_context *ctx; ctx = talloc_get_type(private_data, struct ltdb_context); - ltdb_request_done(ctx->req, LDB_ERR_TIME_LIMIT_EXCEEDED); + ltdb_request_done(ctx, LDB_ERR_TIME_LIMIT_EXCEEDED); } -static void ltdb_request_extended_done(struct ldb_request *req, +static void ltdb_request_extended_done(struct ltdb_context *ctx, struct ldb_extended *ext, int error) { + struct ldb_context *ldb; + struct ldb_request *req; struct ldb_reply *ares; + ldb = ldb_module_get_ctx(ctx->module); + req = ctx->req; + /* if we already returned an error just return */ - if (req->handle->status != LDB_SUCCESS) { + if (ldb_request_get_status(req) != LDB_SUCCESS) { return; } ares = talloc_zero(req, struct ldb_reply); if (!ares) { - ldb_oom(req->handle->ldb); + ldb_oom(ldb); req->callback(req, NULL); return; } @@ -1048,7 +1063,7 @@ static void ltdb_handle_extended(struct ltdb_context *ctx) ret = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; } - ltdb_request_extended_done(ctx->req, ext, ret); + ltdb_request_extended_done(ctx, ext, ret); } static void ltdb_callback(struct tevent_context *ev, @@ -1088,13 +1103,14 @@ static void ltdb_callback(struct tevent_context *ev, if (!ctx->callback_failed) { /* Once we are done, we do not need timeout events */ talloc_free(ctx->timeout_event); - ltdb_request_done(ctx->req, ret); + ltdb_request_done(ctx, ret); } } static int ltdb_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct tevent_context *ev; struct ltdb_context *ac; struct tevent_timer *te; @@ -1104,16 +1120,18 @@ static int ltdb_handle_request(struct ldb_module *module, return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; } + ldb = ldb_module_get_ctx(module); + if (req->starttime == 0 || req->timeout == 0) { - ldb_set_errstring(module->ldb, "Invalid timeout settings"); + ldb_set_errstring(ldb, "Invalid timeout settings"); return LDB_ERR_TIME_LIMIT_EXCEEDED; } - ev = ldb_get_event_context(module->ldb); + ev = ldb_get_event_context(ldb); ac = talloc_zero(req, struct ltdb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -1154,8 +1172,9 @@ static const struct ldb_module_ops ltdb_ops = { */ static int ltdb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], - struct ldb_module **module) + struct ldb_module **_module) { + struct ldb_module *module; const char *path; int tdb_flags, open_flags; struct ltdb_private *ltdb; @@ -1199,7 +1218,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, /* note that we use quite a large default hash size */ ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, tdb_flags, open_flags, - ldb->create_perms, ldb); + ldb_get_create_perms(ldb), ldb); if (!ltdb->tdb) { ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path); @@ -1209,24 +1228,20 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, ltdb->sequence_number = 0; - *module = talloc(ldb, struct ldb_module); - if ((*module) == NULL) { - ldb_oom(ldb); + module = ldb_module_new(ldb, ldb, "ldb_tdb backend", <db_ops); + if (!module) { talloc_free(ltdb); return -1; } - talloc_set_name_const(*module, "ldb_tdb backend"); - (*module)->ldb = ldb; - (*module)->prev = (*module)->next = NULL; - (*module)->private_data = ltdb; - (*module)->ops = <db_ops; + ldb_module_set_private(module, ltdb); - if (ltdb_cache_load(*module) != 0) { - talloc_free(*module); + if (ltdb_cache_load(module) != 0) { + talloc_free(module); talloc_free(ltdb); return -1; } + *_module = module; return 0; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index b373d37b7e..7ebf199f6f 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -6,6 +6,8 @@ #include "tdb.h" #endif +#include "ldb_module.h" + /* this private structure is used by the ltdb backend in the ldb_context */ struct ltdb_private { diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c index 4fea43c8c8..6ee8417e25 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c @@ -21,8 +21,6 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "ldb_includes.h" - #include "ldb_tdb.h" /* diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index c650970af4..475b609e41 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -32,7 +32,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct asq_context { @@ -63,11 +63,14 @@ struct asq_context { static struct asq_context *asq_context_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct asq_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct asq_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -206,9 +209,12 @@ static int asq_reqs_callback(struct ldb_request *req, struct ldb_reply *ares) static int asq_build_first_request(struct asq_context *ac, struct ldb_request **base_req) { + struct ldb_context *ldb; const char **base_attrs; int ret; + ldb = ldb_module_get_ctx(ac->module); + ac->req_attrs = ac->req->op.search.attrs; ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute); if (ac->req_attribute == NULL) @@ -222,7 +228,7 @@ static int asq_build_first_request(struct asq_context *ac, struct ldb_request ** base_attrs[1] = NULL; - ret = ldb_build_search_req(base_req, ac->module->ldb, ac, + ret = ldb_build_search_req(base_req, ldb, ac, ac->req->op.search.base, LDB_SCOPE_BASE, NULL, @@ -239,6 +245,7 @@ static int asq_build_first_request(struct asq_context *ac, struct ldb_request ** static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) { + struct ldb_context *ldb; struct ldb_control **saved_controls; struct ldb_control *control; struct ldb_dn *dn; @@ -249,6 +256,8 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) return LDB_ERR_NO_SUCH_OBJECT; } + ldb = ldb_module_get_ctx(ac->module); + el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute); /* no values found */ if (el == NULL) { @@ -266,7 +275,7 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) for (i = 0; i < el->num_values; i++) { - dn = ldb_dn_new(ac, ac->module->ldb, + dn = ldb_dn_new(ac, ldb, (const char *)el->values[i].data); if ( ! ldb_dn_validate(dn)) { ac->asq_ret = ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX; @@ -275,7 +284,7 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) } ret = ldb_build_search_req_ex(&ac->reqs[i], - ac->module->ldb, ac, + ldb, ac, dn, LDB_SCOPE_BASE, ac->req->op.search.tree, ac->req_attrs, @@ -298,9 +307,12 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) static int asq_search_continue(struct asq_context *ac) { + struct ldb_context *ldb; bool terminated = false; int ret; + ldb = ldb_module_get_ctx(ac->module); + switch (ac->step) { case ASQ_SEARCH_BASE: @@ -312,7 +324,7 @@ static int asq_search_continue(struct asq_context *ac) ac->step = ASQ_SEARCH_MULTI; - return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); + return ldb_request(ldb, ac->reqs[ac->cur_req]); case ASQ_SEARCH_MULTI: @@ -323,7 +335,7 @@ static int asq_search_continue(struct asq_context *ac) return asq_search_terminate(ac); } - return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); + return ldb_request(ldb, ac->reqs[ac->cur_req]); } return LDB_ERR_OPERATIONS_ERROR; @@ -331,11 +343,14 @@ static int asq_search_continue(struct asq_context *ac) static int asq_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *base_req; struct ldb_control *control; struct asq_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_ASQ_OID); if (control == NULL) { @@ -366,16 +381,19 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) ac->step = ASQ_SEARCH_BASE; - return ldb_request(module->ldb, base_req); + return ldb_request(ldb, base_req); } static int asq_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + ret = ldb_mod_register_control(module, LDB_CONTROL_ASQ_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n"); + ldb_debug(ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n"); } return ldb_next_init(module); diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index 11c06c81bb..d862638389 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -73,7 +73,7 @@ modifiersName: not supported by w2k3? */ -#include "ldb_includes.h" +#include "ldb_module.h" /* construct a canonical name from a message @@ -126,8 +126,11 @@ static int operational_search_post_process(struct ldb_module *module, struct ldb_message *msg, const char * const *attrs) { + struct ldb_context *ldb; int i, a=0; + ldb = ldb_module_get_ctx(module); + for (a=0;attrs && attrs[a];a++) { for (i=0;i<ARRAY_SIZE(search_sub);i++) { if (ldb_attr_cmp(attrs[a], search_sub[i].attr) != 0) { @@ -161,7 +164,7 @@ static int operational_search_post_process(struct ldb_module *module, return 0; failed: - ldb_debug_set(module->ldb, LDB_DEBUG_WARNING, + ldb_debug_set(ldb, LDB_DEBUG_WARNING, "operational_search_post_process failed for attribute '%s'\n", attrs[a]); return -1; @@ -224,12 +227,15 @@ static int operational_callback(struct ldb_request *req, struct ldb_reply *ares) static int operational_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct operational_context *ac; struct ldb_request *down_req; const char **search_attrs = NULL; int i, a; int ret; + ldb = ldb_module_get_ctx(module); + ac = talloc(req, struct operational_context); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -268,7 +274,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req } } - ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&down_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index dfc565fef8..7d7cdf66a0 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -32,7 +32,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct message_store { /* keep the whole ldb_reply as an optimization @@ -290,6 +290,7 @@ static int paged_search_callback(struct ldb_request *req, struct ldb_reply *ares static int paged_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_control *control; struct private_data *private_data; struct ldb_paged_control *paged_ctrl; @@ -298,6 +299,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) struct paged_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID); if (control == NULL) { @@ -310,11 +313,12 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_PROTOCOL_ERROR; } - private_data = talloc_get_type(module->private_data, struct private_data); + private_data = talloc_get_type(ldb_module_get_private(module), + struct private_data); ac = talloc_zero(req, struct paged_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -333,7 +337,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req_ex(&search_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&search_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -385,9 +389,12 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) static int paged_request_init(struct ldb_module *module) { + struct ldb_context *ldb; struct private_data *data; int ret; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { return LDB_ERR_OTHER; @@ -395,11 +402,11 @@ static int paged_request_init(struct ldb_module *module) data->next_free_id = 1; data->store = NULL; - module->private_data = data; + ldb_module_set_private(module, data); ret = ldb_mod_register_control(module, LDB_CONTROL_PAGED_RESULTS_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "paged_request:" "Unable to register control with rootdse!\n"); } diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 56f9b1cac3..01e77cb22c 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -33,7 +33,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb_module.h" #define PS_DEFAULT_PAGE_SIZE 500 /* 500 objects per query seem to be a decent compromise @@ -211,10 +211,12 @@ static int ps_callback(struct ldb_request *req, struct ldb_reply *ares) static int ps_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct private_data *private_data; struct ps_context *ac; - private_data = talloc_get_type(module->private_data, struct private_data); + private_data = talloc_get_type(ldb_module_get_private(module), struct private_data); + ldb = ldb_module_get_ctx(module); /* check if paging is supported and if there is a any control */ if (!private_data || !private_data->paged_supported || req->controls) { @@ -226,7 +228,7 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req) ac = talloc_zero(req, struct ps_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -241,11 +243,14 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req) static int ps_next_request(struct ps_context *ac) { + struct ldb_context *ldb; struct ldb_paged_control *control; struct ldb_control **controls; struct ldb_request *new_req; int ret; + ldb = ldb_module_get_ctx(ac->module); + controls = talloc_array(ac, struct ldb_control *, 2); if (!controls) { return LDB_ERR_OPERATIONS_ERROR; @@ -270,7 +275,7 @@ static int ps_next_request(struct ps_context *ac) { controls[0]->data = control; controls[1] = NULL; - ret = ldb_build_search_req_ex(&new_req, ac->module->ldb, ac, + ret = ldb_build_search_req_ex(&new_req, ldb, ac, ac->req->op.search.base, ac->req->op.search.scope, ac->req->op.search.tree, @@ -324,26 +329,30 @@ static int check_supported_paged(struct ldb_request *req, static int ps_init(struct ldb_module *module) { + struct ldb_context *ldb; static const char *attrs[] = { "supportedControl", NULL }; struct private_data *data; struct ldb_dn *base; int ret; struct ldb_request *req; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; data->paged_supported = false; - base = ldb_dn_new(module, module->ldb, ""); + ldb_module_set_private(module, data); + + base = ldb_dn_new(module, ldb, ""); if (base == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, module->ldb, module, + ret = ldb_build_search_req(&req, ldb, module, base, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 62b8ce5112..a5ffcc034a 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -36,7 +36,7 @@ * Simo Sorce Mar 2006 */ -#include "ldb_includes.h" +#include "ldb_module.h" struct rename_context { @@ -86,6 +86,7 @@ static int rdn_name_add_callback(struct ldb_request *req, static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct rename_context *ac; struct ldb_message *msg; @@ -95,7 +96,8 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) struct ldb_val rdn_val; int i, ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -141,10 +143,10 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } } else { - a = ldb_schema_attribute_by_name(module->ldb, rdn_name); + a = ldb_schema_attribute_by_name(ldb, rdn_name); for (i = 0; i < attribute->num_values; i++) { - ret = a->syntax->comparison_fn(module->ldb, msg, + ret = a->syntax->comparison_fn(ldb, msg, &rdn_val, &attribute->values[i]); if (ret == 0) { /* overwrite so it matches in case */ @@ -153,7 +155,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) } } if (i == attribute->num_values) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "RDN mismatch on %s: %s (%s)", ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data); talloc_free(ac); @@ -162,7 +164,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) } } - ret = ldb_build_add_req(&down_req, module->ldb, req, + ret = ldb_build_add_req(&down_req, ldb, req, msg, req->controls, ac, rdn_name_add_callback, @@ -205,6 +207,7 @@ static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct rename_context *ac; struct ldb_request *mod_req; const char *rdn_name; @@ -213,6 +216,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) int ret; ac = talloc_get_type(req->context, struct rename_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { goto error; @@ -258,7 +262,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) goto error; } - ret = ldb_build_mod_req(&mod_req, ac->module->ldb, + ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, NULL, ac, rdn_modify_callback, req); @@ -268,7 +272,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) talloc_steal(mod_req, msg); /* do the mod call */ - return ldb_request(ac->module->ldb, mod_req); + return ldb_request(ldb, mod_req); error: return ldb_module_done(ac->req, NULL, NULL, @@ -277,11 +281,13 @@ error: static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct rename_context *ac; struct ldb_request *down_req; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.rename.newdn)) { @@ -297,7 +303,7 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) ac->req = req; ret = ldb_build_rename_req(&down_req, - module->ldb, + ldb, ac, req->op.rename.olddn, req->op.rename.newdn, diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c index 0cd29ac4b7..248f9b346b 100644 --- a/source4/lib/ldb/modules/skel.c +++ b/source4/lib/ldb/modules/skel.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct private_data { @@ -87,9 +87,13 @@ static int skel_del_trans(struct ldb_module *module) static int skel_destructor(struct ldb_module *ctx) { - struct private_data *data = talloc_get_type(ctx->private_data, struct private_data); + struct private_data *data; + + data = talloc_get_type(ldb_module_get_private(ctx), struct private_data); + /* put your clean-up functions here */ if (data->some_private_data) talloc_free(data->some_private_data); + return 0; } @@ -100,16 +104,19 @@ static int skel_request(struct ldb_module *module, struct ldb_request *req) static int skel_init(struct ldb_module *module) { + struct ldb_context *ldb; struct private_data *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } data->some_private_data = NULL; - module->private_data = data; + ldb_module_set_private(module, data); talloc_set_destructor (module, skel_destructor); diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 25e56b24c8..2b2a1ab1e3 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct opaque { struct ldb_context *ldb; @@ -104,6 +104,9 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo { struct sort_context *ac = talloc_get_type(opaque, struct sort_context); struct ldb_message_element *el1, *el2; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(ac->module); if (!ac || ac->sort_result != 0) { /* an error occurred previously, @@ -122,17 +125,20 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo } if (ac->reverse) - return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el2->values[0], &el1->values[0]); + return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]); - return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]); + return ac->a->syntax->comparison_fn(ldb, ac, &el1->values[0], &el2->values[0]); } static int server_sort_results(struct sort_context *ac) { + struct ldb_context *ldb; struct ldb_reply *ares; int i, ret; - ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName); + ldb = ldb_module_get_ctx(ac->module); + + ac->a = ldb_schema_attribute_by_name(ldb, ac->attributeName); ac->sort_result = 0; ldb_qsort(ac->msgs, ac->num_msgs, @@ -179,9 +185,11 @@ static int server_sort_results(struct sort_context *ac) static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply *ares) { struct sort_context *ac; + struct ldb_context *ldb; int ret; ac = talloc_get_type(req->context, struct sort_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -197,7 +205,7 @@ static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2); if (! ac->msgs) { talloc_free(ares); - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -212,7 +220,7 @@ static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply ac->referrals = talloc_realloc(ac, ac->referrals, char *, ac->num_refs + 2); if (! ac->referrals) { talloc_free(ares); - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -242,8 +250,11 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req struct ldb_control **controls; struct ldb_request *down_req; struct sort_context *ac; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_SERVER_SORT_OID); if (control == NULL) { @@ -253,7 +264,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req ac = talloc_zero(req, struct sort_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -291,7 +302,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req ac->orderingRule = sort_ctrls[0]->orderingRule; ac->reverse = sort_ctrls[0]->reverse; - ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&down_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -316,11 +327,14 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req static int server_sort_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + ret = ldb_mod_register_control(module, LDB_CONTROL_SERVER_SORT_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "server_sort:" "Unable to register control with rootdse!\n"); } diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 9e98363c6f..ef2af060f2 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -25,7 +25,8 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "ldb_includes.h" +#include "replace.h" +#include "ldb_private.h" #include <Python.h> #include "pyldb.h" diff --git a/source4/lib/ldb/python.mk b/source4/lib/ldb/python.mk index 6e73b7e33d..6cc6d2e90e 100644 --- a/source4/lib/ldb/python.mk +++ b/source4/lib/ldb/python.mk @@ -4,5 +4,3 @@ PUBLIC_DEPENDENCIES = LIBLDB PYTALLOC pyldb_OBJ_FILES = $(ldbsrcdir)/pyldb.o $(pyldb_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir)/include - -$(pyldb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c index 1a9e72c907..bbe4419b59 100644 --- a/source4/lib/ldb/tests/sample_module.c +++ b/source4/lib/ldb/tests/sample_module.c @@ -21,9 +21,7 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "ldb_includes.h" -#include "ldb.h" -#include "ldb_errors.h" +#include "ldb_module.h" int sample_add(struct ldb_module *mod, struct ldb_request *req) { diff --git a/source4/lib/ldb/tests/test-extended.sh b/source4/lib/ldb/tests/test-extended.sh index a84e3b78a3..14b988e3f9 100755 --- a/source4/lib/ldb/tests/test-extended.sh +++ b/source4/lib/ldb/tests/test-extended.sh @@ -4,7 +4,7 @@ echo "Running extended search tests" mv $LDB_URL $LDB_URL.1 -cat <<EOF | bin/ldbadd || exit 1 +cat <<EOF | $VALGRIND ldbadd$EXEEXT || exit 1 dn: cn=testrec1,cn=TEST i1: 1 i2: 0 @@ -38,10 +38,10 @@ EOF checkcount() { count=$1 expression="$2" - n=`bin/ldbsearch "$expression" | grep '^dn' | wc -l` + n=`$VALGRIND ldbsearch$EXEEXT "$expression" | grep '^dn' | wc -l` if [ $n != $count ]; then echo "Got $n but expected $count for $expression" - bin/ldbsearch "$expression" + $VALGRIND ldbsearch$EXEEXT "$expression" exit 1 fi echo "OK: $count $expression" diff --git a/source4/lib/ldb/tests/test-generic.sh b/source4/lib/ldb/tests/test-generic.sh index 50b5ff99a0..fec4b5b078 100755 --- a/source4/lib/ldb/tests/test-generic.sh +++ b/source4/lib/ldb/tests/test-generic.sh @@ -8,73 +8,73 @@ fi echo "LDB_URL: $LDB_URL" echo "Adding base elements" -$VALGRIND ldbadd $LDBDIR/tests/test.ldif || exit 1 +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test.ldif || exit 1 echo "Adding again - should fail" -ldbadd $LDBDIR/tests/test.ldif 2> /dev/null && { +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test.ldif 2> /dev/null && { echo "Should have failed to add again - gave $?" exit 1 } echo "Modifying elements" -$VALGRIND ldbmodify $LDBDIR/tests/test-modify.ldif || exit 1 +$VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/test-modify.ldif || exit 1 echo "Showing modified record" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1 echo "Rename entry" OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST" NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST" -$VALGRIND ldbrename "$OLDDN" "$NEWDN" || exit 1 +$VALGRIND ldbrename$EXEEXT "$OLDDN" "$NEWDN" || exit 1 echo "Showing renamed record" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1 echo "Starting ldbtest" -$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1 +$VALGRIND ldbtest$EXEEXT --num-records 100 --num-searches 10 || exit 1 if [ $LDB_SPECIALS = 1 ]; then echo "Adding index" - $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif || exit 1 + $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-index.ldif || exit 1 fi echo "Adding bad attributes - should fail" -$VALGRIND ldbadd $LDBDIR/tests/test-wrong_attributes.ldif && { +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-wrong_attributes.ldif && { echo "Should fhave failed - gave $?" exit 1 } echo "testing indexed search" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 -$VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1 -$VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1 -$VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1 -$VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1 +$VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uham))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(|(uid=uham)(uid=uham))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1 # note that the "((" is treated as an attribute not an expression # this matches the openldap ldapsearch behaviour of looking for a '=' # to see if the first argument is an expression or not -$VALGRIND ldbsearch '((' uid || exit 1 -$VALGRIND ldbsearch '(objectclass=)' uid || exit 1 -$VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1 +$VALGRIND ldbsearch$EXEEXT '((' uid || exit 1 +$VALGRIND ldbsearch$EXEEXT '(objectclass=)' uid || exit 1 +$VALGRIND ldbsearch$EXEEXT -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1 echo "Test wildcard match" -$VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif || exit 1 -$VALGRIND ldbsearch '(cn=test*multi)' || exit 1 -$VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1 -$VALGRIND ldbsearch '(cn=*test_multi)' || exit 1 -$VALGRIND ldbsearch '(cn=test_multi*)' || exit 1 -$VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1 -$VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1 +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-wildcard.ldif || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test*multi)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=*test*multi*)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=*test_multi)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test_multi*)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test*multi*test*multi)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test*multi*test*multi*multi_*)' || exit 1 echo "Starting ldbtest indexed" -$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1 +$VALGRIND ldbtest$EXEEXT --num-records 100 --num-searches 500 || exit 1 echo "Testing one level search" -count=`$VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l` +count=`$VALGRIND ldbsearch$EXEEXT -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l` if [ $count != 3 ]; then echo returned $count records - expected 3 exit 1 @@ -83,8 +83,8 @@ fi echo "Testing binary file attribute value" mkdir -p tests/tmp cp $LDBDIR/tests/samba4.png tests/tmp/samba4.png -$VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1 -count=`$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l` +$VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/photo.ldif || exit 1 +count=`$VALGRIND ldbsearch$EXEEXT '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l` if [ $count != 1 ]; then echo returned $count records - expected 1 exit 1 @@ -94,13 +94,13 @@ rm -f tests/tmp/samba4.png echo "*TODO* Testing UTF8 upper lower case searches !!" echo "Testing compare" -count=`$VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l` +count=`$VALGRIND ldbsearch$EXEEXT '(cn>=t)' cn | grep '^dn' | wc -l` if [ $count != 2 ]; then echo returned $count records - expected 2 echo "this fails on openLdap ..." fi -count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l` +count=`$VALGRIND ldbsearch$EXEEXT '(cn<=t)' cn | grep '^dn' | wc -l` if [ $count != 13 ]; then echo returned $count records - expected 13 echo "this fails on openLdap ..." @@ -111,7 +111,7 @@ checkcount() { scope=$2 basedn=$3 expression="$4" - n=`bin/ldbsearch -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l` + n=`$VALGRIND ldbsearch$EXEEXT -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l` if [ $n != $count ]; then echo "Got $n but expected $count for $expression" bin/ldbsearch "$expression" diff --git a/source4/lib/ldb/tests/test-tdb-features.sh b/source4/lib/ldb/tests/test-tdb-features.sh index fc0959c54a..d4248366ca 100644 --- a/source4/lib/ldb/tests/test-tdb-features.sh +++ b/source4/lib/ldb/tests/test-tdb-features.sh @@ -7,17 +7,17 @@ mv $LDB_URL $LDB_URL.2 checkcount() { count=$1 expression="$2" - n=`bin/ldbsearch "$expression" | grep '^dn' | wc -l` + n=`$VALGRIND ldbsearch$EXEEXT "$expression" | grep '^dn' | wc -l` if [ $n != $count ]; then echo "Got $n but expected $count for $expression" - $VALGRIND bin/ldbsearch "$expression" + $VALGRIND ldbsearch$EXEEXT "$expression" exit 1 fi echo "OK: $count $expression" } echo "Testing case sensitive search" -cat <<EOF | $VALGRIND bin/ldbadd || exit 1 +cat <<EOF | $VALGRIND ldbadd$EXEEXT || exit 1 dn: cn=t1,cn=TEST objectClass: testclass test: foo @@ -27,20 +27,20 @@ checkcount 0 '(test=FOO)' checkcount 0 '(test=FO*)' echo "Making case insensitive" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: @ATTRIBUTES changetype: add add: test test: CASE_INSENSITIVE EOF -echo $ldif | $VALGRIND bin/ldbmodify || exit 1 +echo $ldif | $VALGRIND ldbmodify$EXEEXT || exit 1 checkcount 1 '(test=foo)' checkcount 1 '(test=FOO)' checkcount 1 '(test=fo*)' echo "adding i" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: cn=t1,cn=TEST changetype: modify add: i @@ -50,7 +50,7 @@ checkcount 1 '(i=0x100)' checkcount 0 '(i=256)' echo "marking i as INTEGER" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: @ATTRIBUTES changetype: modify add: i @@ -60,7 +60,7 @@ checkcount 1 '(i=0x100)' checkcount 1 '(i=256)' echo "adding j" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: cn=t1,cn=TEST changetype: modify add: j @@ -70,7 +70,7 @@ checkcount 1 '(j=0x100)' checkcount 0 '(j=256)' echo "Adding wildcard attribute" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: @ATTRIBUTES changetype: modify add: * @@ -84,7 +84,7 @@ checkcount 0 '(objectClass=otherclass)' checkcount 1 '(objectClass=testclass)' echo "Adding index" -cat <<EOF | $VALGRIND bin/ldbadd || exit 1 +cat <<EOF | $VALGRIND ldbadd$EXEEXT || exit 1 dn: @INDEXLIST @IDXATTR: i @IDXATTR: test @@ -97,7 +97,7 @@ checkcount 1 '(test=FOO)' checkcount 1 '(test=*f*o)' echo "making test case sensitive" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: @ATTRIBUTES changetype: modify replace: test @@ -111,17 +111,17 @@ checkone() { count=$1 base="$2" expression="$3" - n=`bin/ldbsearch -s one -b "$base" "$expression" | grep '^dn' | wc -l` + n=`$VALGRIND ldbsearch$EXEEXT -s one -b "$base" "$expression" | grep '^dn' | wc -l` if [ $n != $count ]; then echo "Got $n but expected $count for $expression" - $VALGRIND bin/ldbsearch -s one -b "$base" "$expression" + $VALGRIND ldbsearch$EXEEXT -s one -b "$base" "$expression" exit 1 fi echo "OK: $count $expression" } echo "Removing wildcard attribute" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: @ATTRIBUTES changetype: modify delete: * @@ -129,7 +129,7 @@ delete: * EOF echo "Adding one level indexes" -cat <<EOF | $VALGRIND bin/ldbmodify || exit 1 +cat <<EOF | $VALGRIND ldbmodify$EXEEXT || exit 1 dn: @INDEXLIST changetype: modify add: @IDXONE @@ -137,14 +137,14 @@ add: @IDXONE EOF echo "Testing one level indexed search" -cat <<EOF | $VALGRIND bin/ldbadd || exit 1 +cat <<EOF | $VALGRIND ldbadd$EXEEXT || exit 1 dn: cn=one,cn=t1,cn=TEST objectClass: oneclass cn: one test: one EOF checkone 1 "cn=t1,cn=TEST" '(test=one)' -cat <<EOF | $VALGRIND bin/ldbadd || exit 1 +cat <<EOF | $VALGRIND ldbadd$EXEEXT || exit 1 dn: cn=two,cn=t1,cn=TEST objectClass: oneclass cn: two diff --git a/source4/lib/ldb/tests/test-tdb.sh b/source4/lib/ldb/tests/test-tdb.sh index 7c4f5205b4..1c35451962 100755 --- a/source4/lib/ldb/tests/test-tdb.sh +++ b/source4/lib/ldb/tests/test-tdb.sh @@ -17,12 +17,12 @@ if [ -z "$LDBDIR" ]; then export LDBDIR fi -cat <<EOF | $VALGRIND ldbadd || exit 1 +cat <<EOF | $VALGRIND ldbadd$EXEEXT || exit 1 dn: @MODULES @LIST: rdn_name EOF -$VALGRIND ldbadd $LDBDIR/tests/init.ldif || exit 1 +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/init.ldif || exit 1 . $LDBDIR/tests/test-generic.sh diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 765d8b9edf..3dce9b187b 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -21,7 +21,7 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" #if (_SAMBA_BUILD_ >= 4) @@ -91,7 +91,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, ret = talloc_zero(ldb, struct ldb_cmdline); if (ret == NULL) { - ldb_oom(ldb); + fprintf(stderr, "Out of memory!\n"); goto failed; } @@ -139,7 +139,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, options.options = talloc_realloc(ret, options.options, const char *, num_options+3); if (options.options == NULL) { - ldb_oom(ldb); + fprintf(stderr, "Out of memory!\n"); goto failed; } options.options[num_options] = poptGetOptArg(pc); @@ -156,7 +156,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, options.controls = talloc_array(ret, char *, cc + 1); if (options.controls == NULL) { - ldb_oom(ldb); + fprintf(stderr, "Out of memory!\n"); goto failed; } for (p = cs, cc = 0; p != NULL; cc++) { diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index f32a4fa9bc..be02334797 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static int failures; diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 22d4aa6976..232f51681a 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn) diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 1a684c5c2d..3a915f8bea 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static struct ldb_cmdline *options; diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index 6e355a10cf..c3f55c6096 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static int failures; diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c index a5feb7a091..01ed3d9835 100644 --- a/source4/lib/ldb/tools/ldbrename.c +++ b/source4/lib/ldb/tools/ldbrename.c @@ -33,7 +33,7 @@ * Author: Stefan Metzmacher */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static void usage(void) diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index ceabd5cd78..35d4ac7002 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static void usage(void) diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index f3d6d621a9..edaa9fb85c 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static struct timeval tp1,tp2; diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index fa91a147c6..3c518828ab 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -30,7 +30,7 @@ */ struct irpc_message { struct server_id from; - void *private; + void *private_data; struct irpc_header header; struct ndr_pull *ndr; bool defer_reply; @@ -48,10 +48,10 @@ struct irpc_message { typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r); /* register a server function with the irpc messaging system */ -#define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private) \ +#define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private_data) \ irpc_register(msg_ctx, &ndr_table_ ## pipename, \ NDR_ ## funcname, \ - (irpc_function_t)function, private) + (irpc_function_t)function, private_data) /* make a irpc call */ #define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr, ctx) \ @@ -76,22 +76,22 @@ struct irpc_request { TALLOC_CTX *mem_ctx; struct { void (*fn)(struct irpc_request *); - void *private; + void *private_data; } async; }; struct loadparm_context; -typedef void (*msg_callback_t)(struct messaging_context *msg, void *private, +typedef void (*msg_callback_t)(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server, uint32_t msg_type, DATA_BLOB *data); -NTSTATUS messaging_register(struct messaging_context *msg, void *private, +NTSTATUS messaging_register(struct messaging_context *msg, void *private_data, uint32_t msg_type, msg_callback_t fn); -NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, +NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type); struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, const char *dir, @@ -104,14 +104,14 @@ struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev); NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server, uint32_t msg_type, void *ptr); -void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private); +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data); NTSTATUS irpc_register(struct messaging_context *msg_ctx, const struct ndr_interface_table *table, - int call, irpc_function_t fn, void *private); + int call, irpc_function_t fn, void *private_data); struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx, struct server_id server_id, const struct ndr_interface_table *table, diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index decad7b5a8..cfceeffac7 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -64,7 +64,7 @@ struct messaging_context { struct dispatch_fn { struct dispatch_fn *next, *prev; uint32_t msg_type; - void *private; + void *private_data; msg_callback_t fn; }; @@ -94,7 +94,7 @@ static void irpc_handler(struct messaging_context *, void *, /* A useful function for testing the message system. */ -static void ping_message(struct messaging_context *msg, void *private, +static void ping_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { DEBUG(1,("INFO: Received PING message from server %u.%u [%.*s]\n", @@ -109,7 +109,7 @@ static void ping_message(struct messaging_context *msg, void *private, static NTSTATUS irpc_uptime(struct irpc_message *msg, struct irpc_uptime *r) { - struct messaging_context *ctx = talloc_get_type(msg->private, struct messaging_context); + struct messaging_context *ctx = talloc_get_type(msg->private_data, struct messaging_context); *r->out.start_time = timeval_to_nttime(&ctx->start_time); return NT_STATUS_OK; } @@ -149,7 +149,7 @@ static void messaging_dispatch(struct messaging_context *msg, struct messaging_r next = d->next; data.data = rec->packet.data + sizeof(*rec->header); data.length = rec->header->length; - d->fn(msg, d->private, d->msg_type, rec->header->from, &data); + d->fn(msg, d->private_data, d->msg_type, rec->header->from, &data); } rec->header->length = 0; } @@ -217,9 +217,9 @@ static NTSTATUS try_send(struct messaging_rec *rec) retry backed off messages */ static void msg_retry_timer(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct messaging_context *msg = talloc_get_type(private, + struct messaging_context *msg = talloc_get_type(private_data, struct messaging_context); msg->retry_te = NULL; @@ -339,9 +339,9 @@ static void messaging_recv_handler(struct messaging_context *msg) handle a socket event */ static void messaging_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct messaging_context *msg = talloc_get_type(private, + struct messaging_context *msg = talloc_get_type(private_data, struct messaging_context); if (flags & EVENT_FD_WRITE) { messaging_send_handler(msg); @@ -355,7 +355,7 @@ static void messaging_handler(struct tevent_context *ev, struct tevent_fd *fde, /* Register a dispatch function for a particular message type. */ -NTSTATUS messaging_register(struct messaging_context *msg, void *private, +NTSTATUS messaging_register(struct messaging_context *msg, void *private_data, uint32_t msg_type, msg_callback_t fn) { struct dispatch_fn *d; @@ -376,7 +376,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private, d = talloc_zero(msg->dispatch, struct dispatch_fn); NT_STATUS_HAVE_NO_MEMORY(d); d->msg_type = msg_type; - d->private = private; + d->private_data = private_data; d->fn = fn; DLIST_ADD(msg->dispatch[msg_type], d); @@ -388,7 +388,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private, register a temporary message handler. The msg_type is allocated above MSG_TMP_BASE */ -NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, +NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type) { struct dispatch_fn *d; @@ -396,7 +396,7 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, d = talloc_zero(msg->dispatch, struct dispatch_fn); NT_STATUS_HAVE_NO_MEMORY(d); - d->private = private; + d->private_data = private_data; d->fn = fn; id = idr_get_new_above(msg->dispatch_tree, d, MSG_TMP_BASE, UINT16_MAX); @@ -414,7 +414,7 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, /* De-register the function for a particular message type. */ -void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private) +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data) { struct dispatch_fn *d, *next; @@ -429,7 +429,7 @@ void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void for (d = msg->dispatch[msg_type]; d; d = next) { next = d->next; - if (d->private == private) { + if (d->private_data == private_data) { DLIST_REMOVE(msg->dispatch[msg_type], d); talloc_free(d); } @@ -631,7 +631,7 @@ struct irpc_list { const struct ndr_interface_table *table; int callnum; irpc_function_t fn; - void *private; + void *private_data; }; @@ -640,7 +640,7 @@ struct irpc_list { */ NTSTATUS irpc_register(struct messaging_context *msg_ctx, const struct ndr_interface_table *table, - int callnum, irpc_function_t fn, void *private) + int callnum, irpc_function_t fn, void *private_data) { struct irpc_list *irpc; @@ -659,7 +659,7 @@ NTSTATUS irpc_register(struct messaging_context *msg_ctx, irpc->table = table; irpc->callnum = callnum; irpc->fn = fn; - irpc->private = private; + irpc->private_data = private_data; irpc->uuid = irpc->table->syntax_id.uuid; return NT_STATUS_OK; @@ -768,7 +768,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; /* make the call */ - m->private = i->private; + m->private_data= i->private_data; m->defer_reply = false; m->msg_ctx = msg_ctx; m->irpc = i; @@ -793,7 +793,7 @@ failed: /* handle an incoming irpc message */ -static void irpc_handler(struct messaging_context *msg_ctx, void *private, +static void irpc_handler(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *packet) { struct irpc_message *m; @@ -844,9 +844,9 @@ static int irpc_destructor(struct irpc_request *irpc) timeout a irpc request */ static void irpc_timeout(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct irpc_request *irpc = talloc_get_type(private, struct irpc_request); + struct irpc_request *irpc = talloc_get_type(private_data, struct irpc_request); irpc->status = NT_STATUS_IO_TIMEOUT; irpc->done = true; if (irpc->async.fn) { diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 535da4526c..96981895b6 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -159,11 +159,11 @@ static PyObject *py_messaging_send(PyObject *self, PyObject *args, PyObject *kwa Py_RETURN_NONE; } -static void py_msg_callback_wrapper(struct messaging_context *msg, void *private, +static void py_msg_callback_wrapper(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { - PyObject *callback = (PyObject *)private; + PyObject *callback = (PyObject *)private_data; PyObject_CallFunction(callback, discard_const_p(char, "i(iii)s#"), msg_type, server_id.id, server_id.id2, server_id.node, diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index d45bcb6bf7..3eb23e0f7d 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -54,9 +54,9 @@ static NTSTATUS irpc_AddOne(struct irpc_message *irpc, struct echo_AddOne *r) a deferred reply to echodata */ static void deferred_echodata(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct irpc_message *irpc = talloc_get_type(private, struct irpc_message); + struct irpc_message *irpc = talloc_get_type(private_data, struct irpc_message); struct echo_EchoData *r = irpc->data; r->out.out_data = talloc_memdup(r, r->in.in_data, r->in.len); if (r->out.out_data == NULL) { @@ -87,7 +87,7 @@ static bool test_addone(struct torture_context *test, const void *_data, struct echo_AddOne r; NTSTATUS status; const struct irpc_test_data *data = (const struct irpc_test_data *)_data; - uint32_t value = (uint32_t)_value; + uint32_t value = *(const uint32_t *)_value; /* make the call */ r.in.in_data = value; @@ -145,7 +145,7 @@ static bool test_echodata(struct torture_context *tctx, static void irpc_callback(struct irpc_request *irpc) { struct echo_AddOne *r = (struct echo_AddOne *)irpc->r; - int *pong_count = (int *)irpc->async.private; + int *pong_count = (int *)irpc->async.private_data; NTSTATUS status = irpc_call_recv(irpc); if (!NT_STATUS_IS_OK(status)) { printf("irpc call failed - %s\n", nt_errstr(status)); @@ -186,7 +186,7 @@ static bool test_speed(struct torture_context *tctx, torture_assert(tctx, irpc != NULL, "AddOne send failed"); irpc->async.fn = irpc_callback; - irpc->async.private = &pong_count; + irpc->async.private_data = &pong_count; ping_count++; @@ -261,7 +261,7 @@ struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx) for (i = 0; i < 5; i++) { torture_tcase_add_test_const(tcase, "addone", test_addone, - (void *)values[i]); + (void *)&values[i]); } torture_tcase_add_test_const(tcase, "echodata", test_echodata, NULL); diff --git a/source4/lib/messaging/tests/messaging.c b/source4/lib/messaging/tests/messaging.c index 838de55d83..f61132caac 100644 --- a/source4/lib/messaging/tests/messaging.c +++ b/source4/lib/messaging/tests/messaging.c @@ -29,7 +29,7 @@ static uint32_t msg_pong; -static void ping_message(struct messaging_context *msg, void *private, +static void ping_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { NTSTATUS status; @@ -39,17 +39,17 @@ static void ping_message(struct messaging_context *msg, void *private, } } -static void pong_message(struct messaging_context *msg, void *private, +static void pong_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - int *count = private; + int *count = (int *)private_data; (*count)++; } -static void exit_message(struct messaging_context *msg, void *private, +static void exit_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - talloc_free(private); + talloc_free(private_data); exit(0); } diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index 6528127b0b..a566042cf2 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -105,6 +105,6 @@ $(eval $(call proto_header_template,$(libregistrysrcdir)/tests/proto.h,$(torture [PYTHON::py_registry] LIBRARY_REALNAME = samba/registry.$(SHLIBEXT) -PUBLIC_DEPENDENCIES = registry PYTALLOC swig_credentials param +PUBLIC_DEPENDENCIES = registry PYTALLOC pycredentials param py_registry_OBJ_FILES = $(libregistrysrcdir)/pyregistry.o diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8939f21269..0fc06d1219 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -159,12 +159,12 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) { - struct registry_key *new = NULL; + struct registry_key *nkey = NULL; WERROR error; if(argc == 2) { error = reg_open_key(ctx->registry, ctx->current, argv[1], - &new); + &nkey); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error opening specified key: %s\n", win_errstr(error))); @@ -172,7 +172,7 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) } ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); - ctx->current = new; + ctx->current = nkey; } printf("New path is: %s\n", ctx->path); diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4 index 9c0072dd8b..fa987a1f46 100644 --- a/source4/lib/socket/config.m4 +++ b/source4/lib/socket/config.m4 @@ -1,6 +1,5 @@ AC_CHECK_FUNCS(writev) AC_CHECK_FUNCS(readv) -AC_CHECK_FUNCS(gethostbyname2) ############################################ # check for unix domain sockets diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c index be15aa987b..b943de8c14 100644 --- a/source4/lib/socket/connect.c +++ b/source4/lib/socket/connect.c @@ -36,7 +36,7 @@ struct connect_state { static void socket_connect_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private); + uint16_t flags, void *private_data); /* call the real socket_connect() call, and setup event handler @@ -118,10 +118,10 @@ struct composite_context *socket_connect_send(struct socket_context *sock, */ static void socket_connect_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { struct composite_context *result = - talloc_get_type(private, struct composite_context); + talloc_get_type(private_data, struct composite_context); struct connect_state *state = talloc_get_type(result->private_data, struct connect_state); diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c index bca0aab924..cdb75fe021 100644 --- a/source4/lib/socket/socket_ip.c +++ b/source4/lib/socket/socket_ip.c @@ -549,19 +549,36 @@ _PUBLIC_ const struct socket_ops *socket_ipv4_ops(enum socket_type type) static struct in6_addr interpret_addr6(const char *name) { - struct hostent *he; - - if (name == NULL) return in6addr_any; + char addr[INET6_ADDRSTRLEN]; + struct in6_addr dest6; + const char *sp = name; + char *p = strchr_m(sp, '%'); + int ret; + + if (sp == NULL) return in6addr_any; - if (strcasecmp(name, "localhost") == 0) { - name = "::1"; + if (strcasecmp(sp, "localhost") == 0) { + sp = "::1"; } - he = gethostbyname2(name, PF_INET6); + /* + * Cope with link-local. + * This is IP:v6:addr%ifname. + */ + + if (p && (p > sp) && (if_nametoindex(p+1) != 0)) { + strlcpy(addr, sp, + MIN(PTR_DIFF(p,sp)+1, + sizeof(addr))); + sp = addr; + } - if (he == NULL) return in6addr_any; + ret = inet_pton(AF_INET6, sp, &dest6); + if (ret > 0) { + return dest6; + } - return *((struct in6_addr *)he->h_addr); + return in6addr_any; } static NTSTATUS ipv6_init(struct socket_context *sock) diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c index 7882059faf..f614e9490a 100644 --- a/source4/lib/stream/packet.c +++ b/source4/lib/stream/packet.c @@ -37,7 +37,7 @@ struct packet_context { struct socket_context *sock; struct tevent_context *ev; size_t packet_size; - void *private; + void *private_data; struct tevent_fd *fde; bool serialise; int processing; @@ -105,9 +105,9 @@ _PUBLIC_ void packet_set_error_handler(struct packet_context *pc, packet_error_h /* set the private pointer passed to the callback functions */ -_PUBLIC_ void packet_set_private(struct packet_context *pc, void *private) +_PUBLIC_ void packet_set_private(struct packet_context *pc, void *private_data) { - pc->private = private; + pc->private_data = private_data; } /* @@ -184,15 +184,15 @@ static void packet_error(struct packet_context *pc, NTSTATUS status) { pc->sock = NULL; if (pc->error_handler) { - pc->error_handler(pc->private, status); + pc->error_handler(pc->private_data, status); return; } /* default error handler is to free the callers private pointer */ if (!NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { DEBUG(0,("packet_error on %s - %s\n", - talloc_get_name(pc->private), nt_errstr(status))); + talloc_get_name(pc->private_data), nt_errstr(status))); } - talloc_free(pc->private); + talloc_free(pc->private_data); return; } @@ -210,9 +210,9 @@ static void packet_eof(struct packet_context *pc) used to put packets on event boundaries */ static void packet_next_event(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct packet_context *pc = talloc_get_type(private, struct packet_context); + struct packet_context *pc = talloc_get_type(private_data, struct packet_context); if (pc->num_read != 0 && pc->packet_size != 0 && pc->packet_size <= pc->num_read) { packet_recv(pc); @@ -330,7 +330,7 @@ next_partial: /* see if its a full request */ blob = pc->partial; blob.length = pc->num_read; - status = pc->full_request(pc->private, blob, &pc->packet_size); + status = pc->full_request(pc->private_data, blob, &pc->packet_size); if (NT_STATUS_IS_ERR(status)) { packet_error(pc, status); return; @@ -375,7 +375,7 @@ next_partial: pc->busy = true; - status = pc->callback(pc->private, blob); + status = pc->callback(pc->private_data, blob); pc->busy = false; @@ -409,7 +409,7 @@ next_partial: blob = pc->partial; blob.length = pc->num_read; - status = pc->full_request(pc->private, blob, &pc->packet_size); + status = pc->full_request(pc->private_data, blob, &pc->packet_size); if (NT_STATUS_IS_ERR(status)) { packet_error(pc, status); return; @@ -495,7 +495,7 @@ _PUBLIC_ void packet_queue_run(struct packet_context *pc) */ _PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob, packet_send_callback_fn_t send_callback, - void *private) + void *private_data) { struct send_element *el; el = talloc(pc, struct send_element); @@ -505,7 +505,7 @@ _PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob el->blob = blob; el->nsent = 0; el->send_callback = send_callback; - el->send_callback_private = private; + el->send_callback_private = private_data; /* if we aren't going to free the packet then we must reference it to ensure it doesn't disappear before going out */ @@ -517,7 +517,7 @@ _PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob talloc_steal(el, blob.data); } - if (private && !talloc_reference(el, private)) { + if (private_data && !talloc_reference(el, private_data)) { return NT_STATUS_NO_MEMORY; } @@ -538,7 +538,7 @@ _PUBLIC_ NTSTATUS packet_send(struct packet_context *pc, DATA_BLOB blob) /* a full request checker for NBT formatted packets (first 3 bytes are length) */ -_PUBLIC_ NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *size) +_PUBLIC_ NTSTATUS packet_full_request_nbt(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < 4) { return STATUS_MORE_ENTRIES; @@ -555,7 +555,7 @@ _PUBLIC_ NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t work out if a packet is complete for protocols that use a 32 bit network byte order length */ -_PUBLIC_ NTSTATUS packet_full_request_u32(void *private, DATA_BLOB blob, size_t *size) +_PUBLIC_ NTSTATUS packet_full_request_u32(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < 4) { return STATUS_MORE_ENTRIES; diff --git a/source4/lib/stream/packet.h b/source4/lib/stream/packet.h index c9bd9d4767..3c2fb0a683 100644 --- a/source4/lib/stream/packet.h +++ b/source4/lib/stream/packet.h @@ -24,20 +24,20 @@ struct packet_context; struct tevent_context; struct tevent_fd; -typedef NTSTATUS (*packet_full_request_fn_t)(void *private, +typedef NTSTATUS (*packet_full_request_fn_t)(void *private_data, DATA_BLOB blob, size_t *packet_size); -typedef NTSTATUS (*packet_callback_fn_t)(void *private, DATA_BLOB blob); +typedef NTSTATUS (*packet_callback_fn_t)(void *private_data, DATA_BLOB blob); /* Used to notify that a packet has been sent, and is on the wire */ -typedef void (*packet_send_callback_fn_t)(void *private); -typedef void (*packet_error_handler_fn_t)(void *private, NTSTATUS status); +typedef void (*packet_send_callback_fn_t)(void *private_data); +typedef void (*packet_error_handler_fn_t)(void *private_data, NTSTATUS status); struct packet_context *packet_init(TALLOC_CTX *mem_ctx); void packet_set_callback(struct packet_context *pc, packet_callback_fn_t callback); void packet_set_error_handler(struct packet_context *pc, packet_error_handler_fn_t handler); -void packet_set_private(struct packet_context *pc, void *private); +void packet_set_private(struct packet_context *pc, void *private_data); void packet_set_full_request(struct packet_context *pc, packet_full_request_fn_t callback); void packet_set_socket(struct packet_context *pc, struct socket_context *sock); void packet_set_event_context(struct packet_context *pc, struct tevent_context *ev); @@ -51,13 +51,13 @@ void packet_recv_enable(struct packet_context *pc); NTSTATUS packet_send(struct packet_context *pc, DATA_BLOB blob); NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob, packet_send_callback_fn_t send_callback, - void *private); + void *private_data); void packet_queue_run(struct packet_context *pc); /* pre-canned handlers */ -NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *size); -NTSTATUS packet_full_request_u32(void *private, DATA_BLOB blob, size_t *size); +NTSTATUS packet_full_request_nbt(void *private_data, DATA_BLOB blob, size_t *size); +NTSTATUS packet_full_request_u32(void *private_data, DATA_BLOB blob, size_t *size); diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c index 556f9bcec3..8d2e2e374c 100644 --- a/source4/libcli/cldap/cldap.c +++ b/source4/libcli/cldap/cldap.c @@ -146,9 +146,9 @@ static void cldap_socket_recv(struct cldap_socket *cldap) */ static void cldap_request_timeout(struct tevent_context *event_ctx, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct cldap_request *req = talloc_get_type(private, struct cldap_request); + struct cldap_request *req = talloc_get_type(private_data, struct cldap_request); /* possibly try again */ if (req->num_retries != 0) { @@ -224,9 +224,9 @@ static void cldap_socket_send(struct cldap_socket *cldap) handle fd events on a cldap_socket */ static void cldap_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct cldap_socket *cldap = talloc_get_type(private, struct cldap_socket); + struct cldap_socket *cldap = talloc_get_type(private_data, struct cldap_socket); if (flags & EVENT_FD_WRITE) { cldap_socket_send(cldap); } @@ -282,10 +282,10 @@ failed: NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap, void (*handler)(struct cldap_socket *, struct ldap_message *, struct socket_address *), - void *private) + void *private_data) { cldap->incoming.handler = handler; - cldap->incoming.private = private; + cldap->incoming.private_data = private_data; EVENT_FD_READABLE(cldap->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h index 17e88716c5..8951daa775 100644 --- a/source4/libcli/cldap/cldap.h +++ b/source4/libcli/cldap/cldap.h @@ -63,7 +63,7 @@ struct cldap_request { /* information on what to do on completion */ struct { void (*fn)(struct cldap_request *); - void *private; + void *private_data; } async; }; @@ -88,7 +88,7 @@ struct cldap_socket { struct { void (*handler)(struct cldap_socket *, struct ldap_message *, struct socket_address *); - void *private; + void *private_data; } incoming; }; @@ -117,7 +117,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx, NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap, void (*handler)(struct cldap_socket *, struct ldap_message *, struct socket_address *), - void *private); + void *private_data); struct cldap_request *cldap_search_send(struct cldap_socket *cldap, struct cldap_search *io); NTSTATUS cldap_search_recv(struct cldap_request *req, TALLOC_CTX *mem_ctx, diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c index 5d43606c61..65ee0a8303 100644 --- a/source4/libcli/clilist.c +++ b/source4/libcli/clilist.c @@ -73,9 +73,9 @@ static bool interpret_long_filename(enum smb_search_data_level level, } /* callback function used for trans2 search */ -static bool smbcli_list_new_callback(void *private, const union smb_search_data *file) +static bool smbcli_list_new_callback(void *private_data, const union smb_search_data *file) { - struct search_private *state = (struct search_private*) private; + struct search_private *state = (struct search_private*) private_data; struct clilist_file_info *tdl; /* add file info to the dirlist pool */ @@ -231,9 +231,9 @@ static bool interpret_short_filename(enum smb_search_data_level level, } /* callback function used for smb_search */ -static bool smbcli_list_old_callback(void *private, const union smb_search_data *file) +static bool smbcli_list_old_callback(void *private_data, const union smb_search_data *file) { - struct search_private *state = (struct search_private*) private; + struct search_private *state = (struct search_private*) private_data; struct clilist_file_info *tdl; /* add file info to the dirlist pool */ diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index aff8f79481..ab32175d00 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -86,7 +86,7 @@ _PUBLIC_ NTSTATUS composite_wait_free(struct composite_context *c) this is used to allow for a composite function to complete without going through any state transitions. When that happens the caller has had no opportunity to fill in the async callback fields - (ctx->async.fn and ctx->async.private) which means the usual way of + (ctx->async.fn and ctx->async.private_data) which means the usual way of dealing with composite functions doesn't work. To cope with this, we trigger a timer event that will happen then the event loop is re-entered. This gives the caller a chance to setup the callback, @@ -184,7 +184,7 @@ _PUBLIC_ void composite_continue_irpc(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, @@ -194,7 +194,7 @@ _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } _PUBLIC_ void composite_continue_smb2(struct composite_context *ctx, diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk index 60baf83c8e..dc3431ab9f 100644 --- a/source4/libcli/config.mk +++ b/source4/libcli/config.mk @@ -87,8 +87,6 @@ PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-HOSTCONFIG python_netbios_OBJ_FILES = $(libclinbtsrcdir)/pynbt.o -$(python_libcli_nbt_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) - [SUBSYSTEM::LIBCLI_DGRAM] PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE LIBCLI_NETLOGON diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index 5c878f19fa..751706d2c5 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -140,9 +140,9 @@ static void dgm_socket_send(struct nbt_dgram_socket *dgmsock) handle fd events on a nbt_dgram_socket */ static void dgm_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct nbt_dgram_socket *dgmsock = talloc_get_type(private, + struct nbt_dgram_socket *dgmsock = talloc_get_type(private_data, struct nbt_dgram_socket); if (flags & EVENT_FD_WRITE) { dgm_socket_send(dgmsock); @@ -200,10 +200,10 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, struct socket_address *), - void *private) + void *private_data) { dgmsock->incoming.handler = handler; - dgmsock->incoming.private = private; + dgmsock->incoming.private_data = private_data; EVENT_FD_READABLE(dgmsock->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index 8060d8cf53..a17a6042d9 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -55,7 +55,7 @@ struct nbt_dgram_socket { struct { void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, struct socket_address *src); - void *private; + void *private_data; } incoming; }; @@ -79,7 +79,7 @@ struct dgram_mailslot_handler { const char *mailslot_name; dgram_mailslot_handler_t handler; - void *private; + void *private_data; }; @@ -91,7 +91,7 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, struct socket_address *), - void *private); + void *private_data); struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, struct tevent_context *event_ctx, struct smb_iconv_convenience *); @@ -102,11 +102,11 @@ struct dgram_mailslot_handler *dgram_mailslot_find(struct nbt_dgram_socket *dgms struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private); + void *private_data); struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private); + void *private_data); DATA_BLOB dgram_mailslot_data(struct nbt_dgram_packet *dgram); diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c index 3bd587aa54..261946e458 100644 --- a/source4/libcli/dgram/mailslot.c +++ b/source4/libcli/dgram/mailslot.c @@ -52,7 +52,7 @@ static int dgram_mailslot_destructor(struct dgram_mailslot_handler *dgmslot) struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private) + void *private_data) { struct dgram_mailslot_handler *dgmslot; @@ -66,7 +66,7 @@ struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dg return NULL; } dgmslot->handler = handler; - dgmslot->private = private; + dgmslot->private_data = private_data; DLIST_ADD(dgmsock->mailslot_handlers, dgmslot); talloc_set_destructor(dgmslot, dgram_mailslot_destructor); @@ -115,7 +115,7 @@ const char *dgram_mailslot_name(struct nbt_dgram_packet *packet) struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private) + void *private_data) { char *name; int i; @@ -131,7 +131,7 @@ struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgms talloc_free(name); return NULL; } - dgmslot = dgram_mailslot_listen(dgmsock, name, handler, private); + dgmslot = dgram_mailslot_listen(dgmsock, name, handler, private_data); talloc_free(name); if (dgmslot != NULL) { return dgmslot; diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c index 6e531391a6..2e4fad9332 100644 --- a/source4/libcli/finddcs.c +++ b/source4/libcli/finddcs.c @@ -174,7 +174,7 @@ static void finddcs_name_resolved(struct composite_context *ctx) static void finddcs_getdc_replied(struct irpc_request *ireq) { struct finddcs_state *state = - talloc_get_type(ireq->async.private, struct finddcs_state); + talloc_get_type(ireq->async.private_data, struct finddcs_state); state->ctx->status = irpc_call_recv(ireq); if (!composite_is_ok(state->ctx)) return; diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk index 11157c5b63..2708c66b68 100644 --- a/source4/libcli/ldap/config.mk +++ b/source4/libcli/ldap/config.mk @@ -13,6 +13,6 @@ PUBLIC_HEADERS += $(libclisrcdir)/ldap/ldap.h $(libclisrcdir)/ldap/ldap_ndr.h $(eval $(call proto_header_template,$(libclisrcdir)/ldap/ldap_proto.h,$(LIBCLI_LDAP_OBJ_FILES:.o=.c))) [SUBSYSTEM::LDAP_ENCODE] -# FIXME PRIVATE_DEPENDENCIES = LIBLDB +PRIVATE_DEPENDENCIES = LIBLDB LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h index 5538c9dc06..abb4617c48 100644 --- a/source4/libcli/ldap/ldap.h +++ b/source4/libcli/ldap/ldap.h @@ -21,6 +21,7 @@ #ifndef _SMB_LDAP_H_ #define _SMB_LDAP_H_ +#include "libcli/ldap/ldap_errors.h" #include "lib/ldb/include/ldb.h" #include "librpc/gen_ndr/misc.h" @@ -52,48 +53,6 @@ enum ldap_auth_mechanism { LDAP_AUTH_MECH_SASL = 3 }; -enum ldap_result_code { - LDAP_SUCCESS = 0, - LDAP_OPERATIONS_ERROR = 1, - LDAP_PROTOCOL_ERROR = 2, - LDAP_TIME_LIMIT_EXCEEDED = 3, - LDAP_SIZE_LIMIT_EXCEEDED = 4, - LDAP_COMPARE_FALSE = 5, - LDAP_COMPARE_TRUE = 6, - LDAP_AUTH_METHOD_NOT_SUPPORTED = 7, - LDAP_STRONG_AUTH_REQUIRED = 8, - LDAP_REFERRAL = 10, - LDAP_ADMIN_LIMIT_EXCEEDED = 11, - LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12, - LDAP_CONFIDENTIALITY_REQUIRED = 13, - LDAP_SASL_BIND_IN_PROGRESS = 14, - LDAP_NO_SUCH_ATTRIBUTE = 16, - LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17, - LDAP_INAPPROPRIATE_MATCHING = 18, - LDAP_CONSTRAINT_VIOLATION = 19, - LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20, - LDAP_INVALID_ATTRIBUTE_SYNTAX = 21, - LDAP_NO_SUCH_OBJECT = 32, - LDAP_ALIAS_PROBLEM = 33, - LDAP_INVALID_DN_SYNTAX = 34, - LDAP_ALIAS_DEREFERENCING_PROBLEM = 36, - LDAP_INAPPROPRIATE_AUTHENTICATION = 48, - LDAP_INVALID_CREDENTIALS = 49, - LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50, - LDAP_BUSY = 51, - LDAP_UNAVAILABLE = 52, - LDAP_UNWILLING_TO_PERFORM = 53, - LDAP_LOOP_DETECT = 54, - LDAP_NAMING_VIOLATION = 64, - LDAP_OBJECT_CLASS_VIOLATION = 65, - LDAP_NOT_ALLOWED_ON_NON_LEAF = 66, - LDAP_NOT_ALLOWED_ON_RDN = 67, - LDAP_ENTRY_ALREADY_EXISTS = 68, - LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69, - LDAP_AFFECTS_MULTIPLE_DSAS = 71, - LDAP_OTHER = 80 -}; - struct ldap_Result { int resultcode; const char *dn; diff --git a/source4/libcli/ldap/ldap_errors.h b/source4/libcli/ldap/ldap_errors.h new file mode 100644 index 0000000000..17ac43814c --- /dev/null +++ b/source4/libcli/ldap/ldap_errors.h @@ -0,0 +1,66 @@ +/* + Unix SMB/CIFS Implementation. + LDAP protocol helper functions for SAMBA + Copyright (C) Volker Lendecke 2004 + + 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/>. + +*/ + +#ifndef _SMB_LDAP_ERRORS_H_ +#define _SMB_LDAP_ERRORS_H_ + +enum ldap_result_code { + LDAP_SUCCESS = 0, + LDAP_OPERATIONS_ERROR = 1, + LDAP_PROTOCOL_ERROR = 2, + LDAP_TIME_LIMIT_EXCEEDED = 3, + LDAP_SIZE_LIMIT_EXCEEDED = 4, + LDAP_COMPARE_FALSE = 5, + LDAP_COMPARE_TRUE = 6, + LDAP_AUTH_METHOD_NOT_SUPPORTED = 7, + LDAP_STRONG_AUTH_REQUIRED = 8, + LDAP_REFERRAL = 10, + LDAP_ADMIN_LIMIT_EXCEEDED = 11, + LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12, + LDAP_CONFIDENTIALITY_REQUIRED = 13, + LDAP_SASL_BIND_IN_PROGRESS = 14, + LDAP_NO_SUCH_ATTRIBUTE = 16, + LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17, + LDAP_INAPPROPRIATE_MATCHING = 18, + LDAP_CONSTRAINT_VIOLATION = 19, + LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20, + LDAP_INVALID_ATTRIBUTE_SYNTAX = 21, + LDAP_NO_SUCH_OBJECT = 32, + LDAP_ALIAS_PROBLEM = 33, + LDAP_INVALID_DN_SYNTAX = 34, + LDAP_ALIAS_DEREFERENCING_PROBLEM = 36, + LDAP_INAPPROPRIATE_AUTHENTICATION = 48, + LDAP_INVALID_CREDENTIALS = 49, + LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50, + LDAP_BUSY = 51, + LDAP_UNAVAILABLE = 52, + LDAP_UNWILLING_TO_PERFORM = 53, + LDAP_LOOP_DETECT = 54, + LDAP_NAMING_VIOLATION = 64, + LDAP_OBJECT_CLASS_VIOLATION = 65, + LDAP_NOT_ALLOWED_ON_NON_LEAF = 66, + LDAP_NOT_ALLOWED_ON_RDN = 67, + LDAP_ENTRY_ALREADY_EXISTS = 68, + LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69, + LDAP_AFFECTS_MULTIPLE_DSAS = 71, + LDAP_OTHER = 80 +}; + +#endif /* _SMB_LDAP_ERRORS_H_ */ diff --git a/source4/libcli/raw/clioplock.c b/source4/libcli/raw/clioplock.c index 47ffb6dd31..42ac6b517b 100644 --- a/source4/libcli/raw/clioplock.c +++ b/source4/libcli/raw/clioplock.c @@ -55,8 +55,8 @@ set the oplock handler for a connection ****************************************************************************/ _PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport, bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *), - void *private) + void *private_data) { transport->oplock.handler = handler; - transport->oplock.private = private; + transport->oplock.private_data = private_data; } diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 22e2552edc..5cf0272e88 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -35,9 +35,9 @@ */ static void smbcli_transport_event_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct smbcli_transport *transport = talloc_get_type(private, + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); if (flags & EVENT_FD_READ) { packet_recv(transport->packet); @@ -61,13 +61,13 @@ static int transport_destructor(struct smbcli_transport *transport) /* handle receive errors */ -static void smbcli_transport_error(void *private, NTSTATUS status) +static void smbcli_transport_error(void *private_data, NTSTATUS status) { - struct smbcli_transport *transport = talloc_get_type(private, struct smbcli_transport); + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); smbcli_transport_dead(transport, status); } -static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob); +static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob); /* create a transport structure based on an established socket @@ -308,16 +308,16 @@ again: } static void idle_handler(struct tevent_context *ev, - struct tevent_timer *te, struct timeval t, void *private) + struct tevent_timer *te, struct timeval t, void *private_data) { - struct smbcli_transport *transport = talloc_get_type(private, + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); struct timeval next = timeval_add(&t, 0, transport->idle.period); transport->socket->event.te = event_add_timed(transport->socket->event.ctx, transport, next, idle_handler, transport); - transport->idle.func(transport, transport->idle.private); + transport->idle.func(transport, transport->idle.private_data); } /* @@ -327,10 +327,10 @@ static void idle_handler(struct tevent_context *ev, _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, void (*idle_func)(struct smbcli_transport *, void *), uint64_t period, - void *private) + void *private_data) { transport->idle.func = idle_func; - transport->idle.private = private; + transport->idle.private_data = private_data; transport->idle.period = period; if (transport->socket->event.te != NULL) { @@ -347,9 +347,9 @@ _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, we have a full request in our receive buffer - match it to a pending request and process */ -static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob) +static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob) { - struct smbcli_transport *transport = talloc_get_type(private, + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); uint8_t *buffer, *hdr, *vwv; int len; @@ -450,12 +450,12 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob) smb_setup_bufinfo(req); if (!(req->flags2 & FLAGS2_32_BIT_ERROR_CODES)) { - int class = CVAL(req->in.hdr,HDR_RCLS); + int eclass = CVAL(req->in.hdr,HDR_RCLS); int code = SVAL(req->in.hdr,HDR_ERR); - if (class == 0 && code == 0) { + if (eclass == 0 && code == 0) { transport->error.e.nt_status = NT_STATUS_OK; } else { - transport->error.e.nt_status = NT_STATUS_DOS(class, code); + transport->error.e.nt_status = NT_STATUS_DOS(eclass, code); } } else { transport->error.e.nt_status = NT_STATUS(IVAL(req->in.hdr, HDR_RCLS)); @@ -542,9 +542,9 @@ _PUBLIC_ bool smbcli_transport_process(struct smbcli_transport *transport) handle timeouts of individual smb requests */ static void smbcli_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct smbcli_request *req = talloc_get_type(private, struct smbcli_request); + struct smbcli_request *req = talloc_get_type(private_data, struct smbcli_request); if (req->state == SMBCLI_REQUEST_RECV) { DLIST_REMOVE(req->transport->pending_recv, req); diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index c2269cbbc2..a0584c0aa4 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -2698,7 +2698,7 @@ union smb_search_data { }; /* Callback function passed to the raw search interface. */ -typedef bool (*smbcli_search_callback)(void *private, const union smb_search_data *file); +typedef bool (*smbcli_search_callback)(void *private_data, const union smb_search_data *file); enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE}; diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h index 0ab6f5650c..a9fcdab9cc 100644 --- a/source4/libcli/raw/libcliraw.h +++ b/source4/libcli/raw/libcliraw.h @@ -128,7 +128,7 @@ struct smbcli_transport { for a packet */ struct { void (*func)(struct smbcli_transport *, void *); - void *private; + void *private_data; uint_t period; } idle; @@ -149,9 +149,9 @@ struct smbcli_transport { struct { /* a oplock break request handler */ bool (*handler)(struct smbcli_transport *transport, - uint16_t tid, uint16_t fnum, uint8_t level, void *private); + uint16_t tid, uint16_t fnum, uint8_t level, void *private_data); /* private data passed to the oplock handler */ - void *private; + void *private_data; } oplock; /* a list of async requests that are pending for receive on this connection */ @@ -286,7 +286,7 @@ struct smbcli_request { */ struct { void (*fn)(struct smbcli_request *); - void *private; + void *private_data; } async; }; @@ -328,11 +328,11 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, TALLOC_CTX NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms); void smbcli_oplock_handler(struct smbcli_transport *transport, bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *), - void *private); + void *private_data); void smbcli_transport_idle_handler(struct smbcli_transport *transport, void (*idle_func)(struct smbcli_transport *, void *), uint64_t period, - void *private); + void *private_data); NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req); bool smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level); NTSTATUS smb_raw_open(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms); @@ -366,7 +366,7 @@ struct smbcli_request *smb_raw_echo_send(struct smbcli_transport *transport, struct smb_echo *p); NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_first *io, void *private, + union smb_search_first *io, void *private_data, smbcli_search_callback callback); NTSTATUS smb_raw_flush(struct smbcli_tree *tree, union smb_flush *parms); diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index a257e3d0f1..029d56428d 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -388,7 +388,7 @@ bool smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len, uint16_t tid = SVAL(hdr, HDR_TID); uint16_t fnum = SVAL(vwv,VWV(2)); uint8_t level = CVAL(vwv,VWV(3)+1); - transport->oplock.handler(transport, tid, fnum, level, transport->oplock.private); + transport->oplock.handler(transport, tid, fnum, level, transport->oplock.private_data); } return true; diff --git a/source4/libcli/raw/rawsearch.c b/source4/libcli/raw/rawsearch.c index 99141574e2..9c90d45492 100644 --- a/source4/libcli/raw/rawsearch.c +++ b/source4/libcli/raw/rawsearch.c @@ -28,7 +28,7 @@ static void smb_raw_search_backend(struct smbcli_request *req, TALLOC_CTX *mem_ctx, uint16_t count, - void *private, + void *private_data, smbcli_search_callback callback) { @@ -57,7 +57,7 @@ static void smb_raw_search_backend(struct smbcli_request *req, search_data.search.size = IVAL(p, 26); smbcli_req_pull_ascii(&req->in.bufinfo, mem_ctx, &name, p+30, 13, STR_ASCII); search_data.search.name = name; - if (!callback(private, &search_data)) { + if (!callback(private_data, &search_data)) { break; } p += 43; @@ -69,7 +69,7 @@ static void smb_raw_search_backend(struct smbcli_request *req, ****************************************************************************/ static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_first *io, void *private, + union smb_search_first *io, void *private_data, smbcli_search_callback callback) { @@ -99,7 +99,7 @@ static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, if (NT_STATUS_IS_OK(req->status)) { io->search_first.out.count = SVAL(req->in.vwv, VWV(0)); - smb_raw_search_backend(req, mem_ctx, io->search_first.out.count, private, callback); + smb_raw_search_backend(req, mem_ctx, io->search_first.out.count, private_data, callback); } return smbcli_request_destroy(req); @@ -110,7 +110,7 @@ static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, ****************************************************************************/ static NTSTATUS smb_raw_search_next_old(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_next *io, void *private, + union smb_search_next *io, void *private_data, smbcli_search_callback callback) { @@ -146,7 +146,7 @@ static NTSTATUS smb_raw_search_next_old(struct smbcli_tree *tree, if (NT_STATUS_IS_OK(req->status)) { io->search_next.out.count = SVAL(req->in.vwv, VWV(0)); - smb_raw_search_backend(req, mem_ctx, io->search_next.out.count, private, callback); + smb_raw_search_backend(req, mem_ctx, io->search_next.out.count, private_data, callback); } return smbcli_request_destroy(req); @@ -682,7 +682,7 @@ static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, uint16_t flags, int16_t count, DATA_BLOB *blob, - void *private, + void *private_data, smbcli_search_callback callback) { @@ -703,7 +703,7 @@ static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, /* the callback function can tell us that no more will fit - in that case we stop, but it isn't an error */ - if (!callback(private, &search_data)) { + if (!callback(private_data, &search_data)) { break; } @@ -721,7 +721,7 @@ static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, */ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_first *io, void *private, + union smb_search_first *io, void *private_data, smbcli_search_callback callback) { DATA_BLOB p_blob, d_blob; @@ -731,7 +731,7 @@ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, case RAW_SEARCH_SEARCH: case RAW_SEARCH_FFIRST: case RAW_SEARCH_FUNIQUE: - return smb_raw_search_first_old(tree, mem_ctx, io, private, callback); + return smb_raw_search_first_old(tree, mem_ctx, io, private_data, callback); case RAW_SEARCH_TRANS2: break; @@ -760,7 +760,7 @@ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, status = smb_raw_t2search_backend(tree, mem_ctx, io->generic.data_level, io->t2ffirst.in.flags, io->t2ffirst.out.count, - &d_blob, private, callback); + &d_blob, private_data, callback); return status; } @@ -769,7 +769,7 @@ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, */ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_next *io, void *private, + union smb_search_next *io, void *private_data, smbcli_search_callback callback) { DATA_BLOB p_blob, d_blob; @@ -778,7 +778,7 @@ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, switch (io->generic.level) { case RAW_SEARCH_SEARCH: case RAW_SEARCH_FFIRST: - return smb_raw_search_next_old(tree, mem_ctx, io, private, callback); + return smb_raw_search_next_old(tree, mem_ctx, io, private_data, callback); case RAW_SEARCH_FUNIQUE: return NT_STATUS_INVALID_LEVEL; @@ -809,7 +809,7 @@ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, status = smb_raw_t2search_backend(tree, mem_ctx, io->generic.data_level, io->t2fnext.in.flags, io->t2fnext.out.count, - &d_blob, private, callback); + &d_blob, private_data, callback); return status; } diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c index 2970681d59..ce41d0cea8 100644 --- a/source4/libcli/resolve/dns_ex.c +++ b/source4/libcli/resolve/dns_ex.c @@ -37,6 +37,11 @@ #include "libcli/composite/composite.h" #include "librpc/gen_ndr/ndr_nbt.h" #include "libcli/resolve/resolve.h" + +#ifdef class +#undef class +#endif + #include "heimdal/lib/roken/resolve.h" struct dns_ex_state { diff --git a/source4/libcli/security/config.mk b/source4/libcli/security/config.mk index 4b35841507..cd5b75bb81 100644 --- a/source4/libcli/security/config.mk +++ b/source4/libcli/security/config.mk @@ -1,8 +1,8 @@ [SUBSYSTEM::LIBSECURITY] -PUBLIC_DEPENDENCIES = LIBNDR +PUBLIC_DEPENDENCIES = LIBNDR LIBSECURITY_COMMON LIBSECURITY_OBJ_FILES = $(addprefix $(libclisrcdir)/security/, \ security_token.o security_descriptor.o \ - dom_sid.o access_check.o privilege.o sddl.o) + access_check.o privilege.o sddl.o) $(eval $(call proto_header_template,$(libclisrcdir)/security/proto.h,$(LIBSECURITY_OBJ_FILES:.o=.c))) diff --git a/source4/libcli/security/dom_sid.c b/source4/libcli/security/dom_sid.c deleted file mode 100644 index e1a6b8e8ee..0000000000 --- a/source4/libcli/security/dom_sid.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - - Copyright (C) Stefan (metze) Metzmacher 2002-2004 - Copyright (C) Andrew Tridgell 1992-2004 - Copyright (C) Jeremy Allison 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 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" -#include "librpc/gen_ndr/security.h" -#include "libcli/security/security.h" - -/***************************************************************** - Compare the auth portion of two sids. -*****************************************************************/ - -static int dom_sid_compare_auth(const struct dom_sid *sid1, const struct dom_sid *sid2) -{ - int i; - - if (sid1 == sid2) - return 0; - if (!sid1) - return -1; - if (!sid2) - return 1; - - if (sid1->sid_rev_num != sid2->sid_rev_num) - return sid1->sid_rev_num - sid2->sid_rev_num; - - for (i = 0; i < 6; i++) - if (sid1->id_auth[i] != sid2->id_auth[i]) - return sid1->id_auth[i] - sid2->id_auth[i]; - - return 0; -} - -/***************************************************************** - Compare two sids. -*****************************************************************/ - -int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2) -{ - int i; - - if (sid1 == sid2) - return 0; - if (!sid1) - return -1; - if (!sid2) - return 1; - - /* Compare most likely different rids, first: i.e start at end */ - if (sid1->num_auths != sid2->num_auths) - return sid1->num_auths - sid2->num_auths; - - for (i = sid1->num_auths-1; i >= 0; --i) - if (sid1->sub_auths[i] != sid2->sub_auths[i]) - return sid1->sub_auths[i] - sid2->sub_auths[i]; - - return dom_sid_compare_auth(sid1, sid2); -} - -/***************************************************************** - Compare two sids. -*****************************************************************/ - -bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2) -{ - return dom_sid_compare(sid1, sid2) == 0; -} - -bool dom_sid_parse(const char *sidstr, struct dom_sid *ret) -{ - uint_t rev, ia, num_sub_auths, i; - char *p; - - if (strncasecmp(sidstr, "S-", 2)) { - return false; - } - - sidstr += 2; - - rev = strtol(sidstr, &p, 10); - if (*p != '-') { - return false; - } - sidstr = p+1; - - ia = strtol(sidstr, &p, 10); - if (p == sidstr) { - return false; - } - sidstr = p; - - num_sub_auths = 0; - for (i=0;sidstr[i];i++) { - if (sidstr[i] == '-') num_sub_auths++; - } - - ret->sid_rev_num = rev; - ret->id_auth[0] = 0; - ret->id_auth[1] = 0; - ret->id_auth[2] = ia >> 24; - ret->id_auth[3] = ia >> 16; - ret->id_auth[4] = ia >> 8; - ret->id_auth[5] = ia; - ret->num_auths = num_sub_auths; - - for (i=0;i<num_sub_auths;i++) { - if (sidstr[0] != '-') { - return false; - } - sidstr++; - ret->sub_auths[i] = strtoul(sidstr, &p, 10); - if (p == sidstr) { - return false; - } - sidstr = p; - } - - return true; -} - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) -{ - struct dom_sid *ret; - ret = talloc(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - if (!dom_sid_parse(sidstr, ret)) { - talloc_free(ret); - return NULL; - } - - return ret; -} - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid) -{ - struct dom_sid *ret; - char *p = talloc_strndup(mem_ctx, (char *)sid->data, sid->length); - if (!p) { - return NULL; - } - ret = dom_sid_parse_talloc(mem_ctx, p); - talloc_free(p); - return ret; -} - -/* - copy a dom_sid structure -*/ -struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const struct dom_sid *dom_sid) -{ - struct dom_sid *ret; - int i; - - if (!dom_sid) { - return NULL; - } - - ret = talloc(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - - ret->sid_rev_num = dom_sid->sid_rev_num; - ret->id_auth[0] = dom_sid->id_auth[0]; - ret->id_auth[1] = dom_sid->id_auth[1]; - ret->id_auth[2] = dom_sid->id_auth[2]; - ret->id_auth[3] = dom_sid->id_auth[3]; - ret->id_auth[4] = dom_sid->id_auth[4]; - ret->id_auth[5] = dom_sid->id_auth[5]; - ret->num_auths = dom_sid->num_auths; - - for (i=0;i<dom_sid->num_auths;i++) { - ret->sub_auths[i] = dom_sid->sub_auths[i]; - } - - return ret; -} - -/* - add a rid to a domain dom_sid to make a full dom_sid. This function - returns a new sid in the supplied memory context -*/ -struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, - const struct dom_sid *domain_sid, - uint32_t rid) -{ - struct dom_sid *sid; - - sid = talloc(mem_ctx, struct dom_sid); - if (!sid) return NULL; - - *sid = *domain_sid; - - sid->sub_auths[sid->num_auths] = rid; - sid->num_auths++; - - return sid; -} - -/* - Split up a SID into its domain and RID part -*/ -NTSTATUS dom_sid_split_rid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid, - struct dom_sid **domain, uint32_t *rid) -{ - if (sid->num_auths == 0) { - return NT_STATUS_INVALID_PARAMETER; - } - - if (domain) { - if (!(*domain = dom_sid_dup(mem_ctx, sid))) { - return NT_STATUS_NO_MEMORY; - } - - (*domain)->num_auths -= 1; - } - - if (rid) { - *rid = sid->sub_auths[sid->num_auths - 1]; - } - - return NT_STATUS_OK; -} - -/* - return true if the 2nd sid is in the domain given by the first sid -*/ -bool dom_sid_in_domain(const struct dom_sid *domain_sid, - const struct dom_sid *sid) -{ - int i; - - if (!domain_sid || !sid) { - return false; - } - - if (domain_sid->num_auths > sid->num_auths) { - return false; - } - - for (i = domain_sid->num_auths-1; i >= 0; --i) { - if (domain_sid->sub_auths[i] != sid->sub_auths[i]) { - return false; - } - } - - return dom_sid_compare_auth(domain_sid, sid) == 0; -} - -/* - convert a dom_sid to a string -*/ -char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) -{ - int i, ofs, maxlen; - uint32_t ia; - char *ret; - - if (!sid) { - return talloc_strdup(mem_ctx, "(NULL SID)"); - } - - maxlen = sid->num_auths * 11 + 25; - ret = talloc_array(mem_ctx, char, maxlen); - if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)"); - - ia = (sid->id_auth[5]) + - (sid->id_auth[4] << 8 ) + - (sid->id_auth[3] << 16) + - (sid->id_auth[2] << 24); - - ofs = snprintf(ret, maxlen, "S-%u-%lu", - (unsigned int)sid->sid_rev_num, (unsigned long)ia); - - for (i = 0; i < sid->num_auths; i++) { - ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]); - } - - return ret; -} diff --git a/source4/libcli/security/security.h b/source4/libcli/security/security.h index 46ef6186b8..517f3e8ebe 100644 --- a/source4/libcli/security/security.h +++ b/source4/libcli/security/security.h @@ -28,4 +28,7 @@ enum security_user_level { struct auth_session_info; +/* Moved the dom_sid functions to the top level dir with manual proto header */ +#include "libcli/security/dom_sid.h" + #include "libcli/security/proto.h" diff --git a/source4/libcli/security/security_token.c b/source4/libcli/security/security_token.c index 0680c54258..e1349e06f8 100644 --- a/source4/libcli/security/security_token.c +++ b/source4/libcli/security/security_token.c @@ -21,7 +21,6 @@ */ #include "includes.h" -#include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "auth/session.h" diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index b462bab1de..14d911683e 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -95,18 +95,19 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, /* map a generic info level to a SMB2 info level */ -uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t class) +uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t info_class) { - if (class == SMB2_GETINFO_FILE && + if (info_class == SMB2_GETINFO_FILE && level == RAW_FILEINFO_SEC_DESC) { return SMB2_GETINFO_SECURITY; } - if ((level & 0xFF) == class) { + if ((level & 0xFF) == info_class) { return level; } else if (level > 1000) { - return ((level-1000)<<8) | class; + return ((level-1000)<<8) | info_class; } - DEBUG(0,("Unable to map SMB2 info level 0x%04x of class %d\n", level, class)); + DEBUG(0,("Unable to map SMB2 info level 0x%04x of class %d\n", + level, info_class)); return 0; } diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 9d63a4a95f..d1d5b842c3 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -59,7 +59,7 @@ struct smb2_transport { for a packet */ struct { void (*func)(struct smb2_transport *, void *); - void *private; + void *private_data; uint_t period; } idle; diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c index 94ea2586ef..e112544c62 100644 --- a/source4/libcli/smb2/transport.c +++ b/source4/libcli/smb2/transport.c @@ -35,9 +35,9 @@ */ static void smb2_transport_event_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); if (flags & EVENT_FD_READ) { packet_recv(transport->packet); @@ -61,14 +61,14 @@ static int transport_destructor(struct smb2_transport *transport) /* handle receive errors */ -static void smb2_transport_error(void *private, NTSTATUS status) +static void smb2_transport_error(void *private_data, NTSTATUS status) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); smb2_transport_dead(transport, status); } -static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob); +static NTSTATUS smb2_transport_finish_recv(void *private_data, DATA_BLOB blob); /* create a transport structure based on an established socket @@ -181,9 +181,9 @@ static NTSTATUS smb2_handle_oplock_break(struct smb2_transport *transport, we have a full request in our receive buffer - match it to a pending request and process */ -static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob) +static NTSTATUS smb2_transport_finish_recv(void *private_data, DATA_BLOB blob) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); uint8_t *buffer, *hdr; int len; @@ -302,9 +302,9 @@ error: handle timeouts of individual smb requests */ static void smb2_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct smb2_request *req = talloc_get_type(private, struct smb2_request); + struct smb2_request *req = talloc_get_type(private_data, struct smb2_request); if (req->state == SMB2_REQUEST_RECV) { DLIST_REMOVE(req->transport->pending_recv, req); @@ -381,16 +381,16 @@ void smb2_transport_send(struct smb2_request *req) } static void idle_handler(struct tevent_context *ev, - struct tevent_timer *te, struct timeval t, void *private) + struct tevent_timer *te, struct timeval t, void *private_data) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); struct timeval next = timeval_add(&t, 0, transport->idle.period); transport->socket->event.te = event_add_timed(transport->socket->event.ctx, transport, next, idle_handler, transport); - transport->idle.func(transport, transport->idle.private); + transport->idle.func(transport, transport->idle.private_data); } /* @@ -400,10 +400,10 @@ static void idle_handler(struct tevent_context *ev, void smb2_transport_idle_handler(struct smb2_transport *transport, void (*idle_func)(struct smb2_transport *, void *), uint64_t period, - void *private) + void *private_data) { transport->idle.func = idle_func; - transport->idle.private = private; + transport->idle.private_data = private_data; transport->idle.period = period; if (transport->socket->event.te != NULL) { diff --git a/source4/libcli/smb_composite/appendacl.c b/source4/libcli/smb_composite/appendacl.c index 1f06b96e75..69ed62a106 100644 --- a/source4/libcli/smb_composite/appendacl.c +++ b/source4/libcli/smb_composite/appendacl.c @@ -46,7 +46,7 @@ static NTSTATUS appendacl_open(struct composite_context *c, /* set the handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_GET; talloc_free (state->io_open); @@ -92,7 +92,7 @@ static NTSTATUS appendacl_get(struct composite_context *c, /* call handler when done setting new security descriptor on file */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_SET; talloc_free (state->io_fileinfo); @@ -124,7 +124,7 @@ static NTSTATUS appendacl_set(struct composite_context *c, /* set the handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_GETAGAIN; talloc_free (state->io_setfileinfo); @@ -159,7 +159,7 @@ static NTSTATUS appendacl_getagain(struct composite_context *c, /* call the handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_CLOSEPATH; talloc_free (state->io_fileinfo); @@ -188,7 +188,7 @@ static NTSTATUS appendacl_close(struct composite_context *c, */ static void appendacl_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct appendacl_state *state = talloc_get_type(c->private_data, struct appendacl_state); /* when this handler is called, the stage indicates what @@ -270,7 +270,7 @@ struct composite_context *smb_composite_appendacl_send(struct smbcli_tree *tree, /* setup the callback handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_OPENPATH; return c; diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index e0f4919f0b..3db777ddc8 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -129,7 +129,7 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c, } state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_TCON; return NT_STATUS_OK; @@ -215,7 +215,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c, } state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_TCON; return NT_STATUS_OK; @@ -285,7 +285,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_NEGPROT; return NT_STATUS_OK; @@ -354,7 +354,7 @@ static NTSTATUS connect_socket(struct composite_context *c, NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_SESSION_REQUEST; return NT_STATUS_OK; @@ -434,7 +434,7 @@ static void state_handler(struct composite_context *c) */ static void request_handler(struct smbcli_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); state_handler(c); } diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c index 7c9c7963f4..3bc93b62ab 100644 --- a/source4/libcli/smb_composite/fsinfo.c +++ b/source4/libcli/smb_composite/fsinfo.c @@ -47,7 +47,7 @@ static NTSTATUS fsinfo_connect(struct composite_context *c, state->fsinfo); NT_STATUS_HAVE_NO_MEMORY(state->req); - state->req->async.private = c; + state->req->async.private_data = c; state->req->async.fn = fsinfo_raw_handler; state->stage = FSINFO_QUERY; @@ -110,7 +110,7 @@ static void fsinfo_state_handler(struct composite_context *creq) */ static void fsinfo_raw_handler(struct smbcli_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); fsinfo_state_handler(c); } diff --git a/source4/libcli/smb_composite/loadfile.c b/source4/libcli/smb_composite/loadfile.c index 952f24b811..994c29c77d 100644 --- a/source4/libcli/smb_composite/loadfile.c +++ b/source4/libcli/smb_composite/loadfile.c @@ -61,7 +61,7 @@ static NTSTATUS setup_close(struct composite_context *c, /* call the handler again when the close is done */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = LOADFILE_CLOSE; return NT_STATUS_OK; @@ -113,7 +113,7 @@ static NTSTATUS loadfile_open(struct composite_context *c, /* call the handler again when the first read is done */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = LOADFILE_READ; talloc_free(state->io_open); @@ -152,7 +152,7 @@ static NTSTATUS loadfile_read(struct composite_context *c, /* call the handler again when the read is done */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; return NT_STATUS_OK; } @@ -180,7 +180,7 @@ static NTSTATUS loadfile_close(struct composite_context *c, */ static void loadfile_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct loadfile_state *state = talloc_get_type(c->private_data, struct loadfile_state); /* when this handler is called, the stage indicates what @@ -250,7 +250,7 @@ struct composite_context *smb_composite_loadfile_send(struct smbcli_tree *tree, /* setup the callback handler */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = LOADFILE_OPEN; return c; diff --git a/source4/libcli/smb_composite/savefile.c b/source4/libcli/smb_composite/savefile.c index f02ca46f06..25a35c01a9 100644 --- a/source4/libcli/smb_composite/savefile.c +++ b/source4/libcli/smb_composite/savefile.c @@ -64,7 +64,7 @@ static NTSTATUS setup_close(struct composite_context *c, /* call the handler again when the close is done */ state->stage = SAVEFILE_CLOSE; state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; return NT_STATUS_OK; } @@ -108,7 +108,7 @@ static NTSTATUS savefile_open(struct composite_context *c, /* call the handler again when the first write is done */ state->stage = SAVEFILE_WRITE; state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; talloc_free(state->io_open); return NT_STATUS_OK; @@ -149,7 +149,7 @@ static NTSTATUS savefile_write(struct composite_context *c, /* call the handler again when the write is done */ state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; return NT_STATUS_OK; } @@ -181,7 +181,7 @@ static NTSTATUS savefile_close(struct composite_context *c, */ static void savefile_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct savefile_state *state = talloc_get_type(c->private_data, struct savefile_state); /* when this handler is called, the stage indicates what @@ -254,7 +254,7 @@ struct composite_context *smb_composite_savefile_send(struct smbcli_tree *tree, /* setup the callback handler */ state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; c->private_data = state; return c; diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c index 7c9d1fb731..83d15e98eb 100644 --- a/source4/libcli/smb_composite/sesssetup.c +++ b/source4/libcli/smb_composite/sesssetup.c @@ -80,7 +80,7 @@ static void set_user_session_key(struct smbcli_session *session, */ static void request_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state); struct smbcli_session *session = req->session; DATA_BLOB session_key = data_blob(NULL, 0); diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index e94ed36d39..8371837dcb 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -20,7 +20,7 @@ /* NT error codes. please read nterr.h */ #include "includes.h" -#include "libcli/ldap/ldap.h" +#include "libcli/ldap/ldap_errors.h" #undef strcasecmp typedef struct diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c index b881e32f7b..da7d678da9 100644 --- a/source4/libcli/wbclient/wbclient.c +++ b/source4/libcli/wbclient/wbclient.c @@ -117,7 +117,7 @@ struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx, static void sids_to_xids_recv_ids(struct irpc_request *req) { struct wbc_idmap_state *state = talloc_get_type_abort( - req->async.private, + req->async.private_data, struct wbc_idmap_state); state->ctx->status = irpc_call_recv(state->irpc_req); @@ -183,7 +183,7 @@ struct composite_context *wbc_xids_to_sids_send(struct wbc_context *wbc_ctx, static void xids_to_sids_recv_ids(struct irpc_request *req) { struct wbc_idmap_state *state = talloc_get_type_abort( - req->async.private, + req->async.private_data, struct wbc_idmap_state); state->ctx->status = irpc_call_recv(state->irpc_req); diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 61bb10bf6a..48a6abba9d 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -81,9 +81,9 @@ static void wrepl_request_timeout_handler(struct tevent_context *ev, struct teve /* handle recv events */ -static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in) +static NTSTATUS wrepl_finish_recv(void *private_data, DATA_BLOB packet_blob_in) { - struct wrepl_socket *wrepl_socket = talloc_get_type(private, struct wrepl_socket); + struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); struct wrepl_request *req = wrepl_socket->recv_queue; DATA_BLOB blob; enum ndr_err_code ndr_err; @@ -123,9 +123,9 @@ static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in) handler for winrepl events */ static void wrepl_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct wrepl_socket *wrepl_socket = talloc_get_type(private, + struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); if (flags & EVENT_FD_READ) { packet_recv(wrepl_socket->packet); @@ -136,9 +136,9 @@ static void wrepl_handler(struct tevent_context *ev, struct tevent_fd *fde, } } -static void wrepl_error(void *private, NTSTATUS status) +static void wrepl_error(void *private_data, NTSTATUS status) { - struct wrepl_socket *wrepl_socket = talloc_get_type(private, + struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); wrepl_socket_dead(wrepl_socket, status); } diff --git a/source4/libcli/wrepl/winsrepl.h b/source4/libcli/wrepl/winsrepl.h index 738ba391eb..ec1fb6bb59 100644 --- a/source4/libcli/wrepl/winsrepl.h +++ b/source4/libcli/wrepl/winsrepl.h @@ -82,7 +82,7 @@ struct wrepl_request { struct { void (*fn)(struct wrepl_request *); - void *private; + void *private_data; } async; }; diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index 294ea4b79c..bf046745e6 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -756,14 +756,14 @@ static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s) req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io); if (composite_nomem(req, c)) return; req->async.fn = becomeDC_recv_cldap; - req->async.private = s; + req->async.private_data = s; } static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s); static void becomeDC_recv_cldap(struct cldap_request *req) { - struct libnet_BecomeDC_state *s = talloc_get_type(req->async.private, + struct libnet_BecomeDC_state *s = talloc_get_type(req->async.private_data, struct libnet_BecomeDC_state); struct composite_context *c = s->creq; diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index e259d4df40..b35fef2c16 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -75,13 +75,13 @@ static NTSTATUS vampire_samdump_handle_secret(TALLOC_CTX *mem_ctx, { struct netr_DELTA_SECRET *secret = delta->delta_union.secret; const char *name = delta->delta_id_union.name; - struct samdump_secret *new = talloc(samdump_state, struct samdump_secret); + struct samdump_secret *n = talloc(samdump_state, struct samdump_secret); - new->name = talloc_strdup(new, name); - new->secret = data_blob_talloc(new, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); - new->mtime = secret->current_cipher_set_time; + n->name = talloc_strdup(n, name); + n->secret = data_blob_talloc(n, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); + n->mtime = secret->current_cipher_set_time; - DLIST_ADD(samdump_state->secrets, new); + DLIST_ADD(samdump_state->secrets, n); return NT_STATUS_OK; } @@ -93,24 +93,24 @@ static NTSTATUS vampire_samdump_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain; struct dom_sid *dom_sid = delta->delta_id_union.sid; - struct samdump_trusted_domain *new = talloc(samdump_state, struct samdump_trusted_domain); + struct samdump_trusted_domain *n = talloc(samdump_state, struct samdump_trusted_domain); - new->name = talloc_strdup(new, trusted_domain->domain_name.string); - new->sid = talloc_steal(new, dom_sid); + n->name = talloc_strdup(n, trusted_domain->domain_name.string); + n->sid = talloc_steal(n, dom_sid); - DLIST_ADD(samdump_state->trusted_domains, new); + DLIST_ADD(samdump_state->trusted_domains, n); return NT_STATUS_OK; } -static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx, - void *private, +static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - struct samdump_state *samdump_state = (struct samdump_state *)private; + struct samdump_state *samdump_state = (struct samdump_state *)private_data; *error_string = NULL; switch (delta->delta_type) { diff --git a/source4/libnet/libnet_samdump_keytab.c b/source4/libnet/libnet_samdump_keytab.c index 2218d20f6b..a1846b81da 100644 --- a/source4/libnet/libnet_samdump_keytab.c +++ b/source4/libnet/libnet_samdump_keytab.c @@ -74,14 +74,14 @@ struct libnet_samdump_keytab_data { struct loadparm_context *lp_ctx; }; -static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, - void *private, +static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - struct libnet_samdump_keytab_data *data = private; + struct libnet_samdump_keytab_data *data = private_data; *error_string = NULL; switch (delta->delta_type) { case NETR_DELTA_USER: diff --git a/source4/libnet/libnet_samsync.h b/source4/libnet/libnet_samsync.h index d2ac30fe14..c2295f3957 100644 --- a/source4/libnet/libnet_samsync.h +++ b/source4/libnet/libnet_samsync.h @@ -34,11 +34,11 @@ struct libnet_SamSync { const char *binding_string; bool rid_crypt; NTSTATUS (*init_fn)(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, struct libnet_SamSync_state *samsync_state, char **error_string); NTSTATUS (*delta_fn)(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string); diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c index 160b4b3e19..e24c54a8c2 100644 --- a/source4/libnet/libnet_samsync_ldb.c +++ b/source4/libnet/libnet_samsync_ldb.c @@ -1052,13 +1052,13 @@ static NTSTATUS samsync_ldb_delete_account(TALLOC_CTX *mem_ctx, } static NTSTATUS libnet_samsync_ldb_fn(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - struct samsync_ldb_state *state = talloc_get_type(private, struct samsync_ldb_state); + struct samsync_ldb_state *state = talloc_get_type(private_data, struct samsync_ldb_state); *error_string = NULL; switch (delta->delta_type) { @@ -1172,11 +1172,11 @@ static NTSTATUS libnet_samsync_ldb_fn(TALLOC_CTX *mem_ctx, } static NTSTATUS libnet_samsync_ldb_init(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, struct libnet_SamSync_state *samsync_state, char **error_string) { - struct samsync_ldb_state *state = talloc_get_type(private, struct samsync_ldb_state); + struct samsync_ldb_state *state = talloc_get_type(private_data, struct samsync_ldb_state); const char *server = dcerpc_server_name(samsync_state->netlogon_pipe); char *ldap_url; diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c index 79c6dc0fc1..3f92daab28 100644 --- a/source4/libnet/libnet_unbecome_dc.c +++ b/source4/libnet/libnet_unbecome_dc.c @@ -275,14 +275,14 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s) req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io); if (composite_nomem(req, c)) return; req->async.fn = unbecomeDC_recv_cldap; - req->async.private = s; + req->async.private_data = s; } static void unbecomeDC_connect_ldap(struct libnet_UnbecomeDC_state *s); static void unbecomeDC_recv_cldap(struct cldap_request *req) { - struct libnet_UnbecomeDC_state *s = talloc_get_type(req->async.private, + struct libnet_UnbecomeDC_state *s = talloc_get_type(req->async.private_data, struct libnet_UnbecomeDC_state); struct composite_context *c = s->creq; diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 5bbdfaf4d8..3e6ea313e7 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -180,9 +180,7 @@ NDR_SPOOLSS_OBJ_FILES = ../librpc/gen_ndr/ndr_spoolss.o [SUBSYSTEM::NDR_SPOOLSS_BUF] -NDR_SPOOLSS_BUF_OBJ_FILES = $(ndrsrcdir)/ndr_spoolss_buf.o - -$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_spoolss_buf.h,$(NDR_SPOOLSS_BUF_OBJ_FILES:.o=.c))) +NDR_SPOOLSS_BUF_OBJ_FILES = ../librpc/ndr/ndr_spoolss_buf.o [SUBSYSTEM::NDR_WKSSVC] PUBLIC_DEPENDENCIES = LIBNDR NDR_SRVSVC NDR_SECURITY @@ -633,7 +631,7 @@ PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, rpc/dcerpc.h) \ [PYTHON::python_dcerpc] LIBRARY_REALNAME = samba/dcerpc/base.$(SHLIBEXT) -PUBLIC_DEPENDENCIES = LIBCLI_SMB LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG swig_credentials param +PUBLIC_DEPENDENCIES = LIBCLI_SMB LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG pycredentials param python_dcerpc_OBJ_FILES = $(dcerpcsrcdir)/pyrpc.o @@ -642,13 +640,13 @@ $(eval $(call python_py_module_template,samba/dcerpc/__init__.py,$(dcerpcsrcdir) [PYTHON::python_echo] LIBRARY_REALNAME = samba/dcerpc/echo.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param pycredentials python_dcerpc python_echo_OBJ_FILES = ../librpc/gen_ndr/py_echo.o [PYTHON::python_winreg] LIBRARY_REALNAME = samba/dcerpc/winreg.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_WINREG PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_WINREG PYTALLOC param pycredentials python_dcerpc python_winreg_OBJ_FILES = ../librpc/gen_ndr/py_winreg.o @@ -660,79 +658,79 @@ python_dcerpc_misc_OBJ_FILES = ../librpc/gen_ndr/py_misc.o [PYTHON::python_initshutdown] LIBRARY_REALNAME = samba/dcerpc/initshutdown.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param pycredentials python_dcerpc python_initshutdown_OBJ_FILES = ../librpc/gen_ndr/py_initshutdown.o [PYTHON::python_epmapper] LIBRARY_REALNAME = samba/dcerpc/epmapper.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param pycredentials python_dcerpc python_epmapper_OBJ_FILES = ../librpc/gen_ndr/py_epmapper.o [PYTHON::python_mgmt] LIBRARY_REALNAME = samba/dcerpc/mgmt.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials dcerpc python_dcerpc +PRIVATE_DEPENDENCIES = PYTALLOC param pycredentials dcerpc python_dcerpc python_mgmt_OBJ_FILES = ../librpc/gen_ndr/py_mgmt.o [PYTHON::python_atsvc] LIBRARY_REALNAME = samba/dcerpc/atsvc.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param pycredentials python_dcerpc python_atsvc_OBJ_FILES = ../librpc/gen_ndr/py_atsvc.o [PYTHON::python_dcerpc_nbt] LIBRARY_REALNAME = samba/dcerpc/nbt.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param pycredentials python_dcerpc python_dcerpc_nbt_OBJ_FILES = ../librpc/gen_ndr/py_nbt.o [PYTHON::python_samr] LIBRARY_REALNAME = samba/dcerpc/samr.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC swig_credentials param python_dcerpc +PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC pycredentials param python_dcerpc python_samr_OBJ_FILES = ../librpc/gen_ndr/py_samr.o [PYTHON::python_svcctl] LIBRARY_REALNAME = samba/dcerpc/svcctl.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param pycredentials python_dcerpc python_svcctl_OBJ_FILES = ../librpc/gen_ndr/py_svcctl.o [PYTHON::python_lsa] LIBRARY_REALNAME = samba/dcerpc/lsa.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param pycredentials python_dcerpc python_lsa_OBJ_FILES = ../librpc/gen_ndr/py_lsa.o [PYTHON::python_wkssvc] LIBRARY_REALNAME = samba/dcerpc/wkssvc.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param pycredentials python_dcerpc python_wkssvc_OBJ_FILES = ../librpc/gen_ndr/py_wkssvc.o [PYTHON::python_dfs] LIBRARY_REALNAME = samba/dcerpc/dfs.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param pycredentials python_dcerpc python_dfs_OBJ_FILES = ../librpc/gen_ndr/py_dfs.o [PYTHON::python_unixinfo] LIBRARY_REALNAME = samba/dcerpc/unixinfo.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param pycredentials python_dcerpc python_unixinfo_OBJ_FILES = ../librpc/gen_ndr/py_unixinfo.o [PYTHON::python_irpc] LIBRARY_REALNAME = samba/dcerpc/irpc.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_IRPC PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_IRPC PYTALLOC param pycredentials python_dcerpc python_irpc_OBJ_FILES = $(gen_ndrsrcdir)/py_irpc.o [PYTHON::python_drsuapi] LIBRARY_REALNAME = samba/dcerpc/drsuapi.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param pycredentials python_dcerpc python_drsuapi_OBJ_FILES = ../librpc/gen_ndr/py_drsuapi.o diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c deleted file mode 100644 index 335275f680..0000000000 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ /dev/null @@ -1,532 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for marshalling/unmarshalling spoolss subcontext buffer structures - - Copyright (C) Andrew Tridgell 2003 - Copyright (C) Tim Potter 2003 - - 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" -#include "librpc/gen_ndr/ndr_spoolss.h" -#include "param/param.h" - -#define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ - if (!r->in.buffer && r->in.offered != 0) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\ - (unsigned)r->in.offered);\ - } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\ - (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\ - }\ - _r.in.level = r->in.level;\ - _r.in.buffer = r->in.buffer;\ - _r.in.offered = r->in.offered;\ - NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ -} while(0) - -#define NDR_SPOOLSS_PUSH_ENUM_OUT(fn) do { \ - struct ndr_push *_ndr_info;\ - _r.in.level = r->in.level;\ - _r.in.buffer = r->in.buffer;\ - _r.in.offered = r->in.offered;\ - _r.out.info = NULL;\ - _r.out.needed = r->out.needed;\ - _r.out.count = r->out.count;\ - _r.out.result = r->out.result;\ - if (r->out.info && !r->in.buffer) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->out.info but there's no r->in.buffer");\ - }\ - if (r->in.buffer) {\ - DATA_BLOB _data_blob_info;\ - _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\ - NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ - _ndr_info->flags= ndr->flags;\ - if (r->out.info) {\ - struct __##fn __r;\ - __r.in.level = r->in.level;\ - __r.in.count = r->out.count;\ - __r.out.info = r->out.info;\ - NDR_CHECK(ndr_push___##fn(_ndr_info, flags, &__r)); \ - }\ - if (r->in.offered > _ndr_info->offset) {\ - uint32_t _padding_len = r->in.offered - _ndr_info->offset;\ - NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));\ - } else if (r->in.offered < _ndr_info->offset) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]!",\ - (unsigned)r->in.offered, (unsigned)_ndr_info->offset);\ - }\ - _data_blob_info = ndr_push_blob(_ndr_info);\ - _r.out.info = &_data_blob_info;\ - }\ - NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ -} while(0) - -#define NDR_SPOOLSS_PUSH_ENUM(fn,in,out) do { \ - struct _##fn _r;\ - if (flags & NDR_IN) {\ - in;\ - NDR_SPOOLSS_PUSH_ENUM_IN(fn);\ - }\ - if (flags & NDR_OUT) {\ - out;\ - NDR_SPOOLSS_PUSH_ENUM_OUT(fn);\ - }\ -} while(0) - -#define NDR_SPOOLSS_PULL_ENUM_IN(fn) do { \ - ZERO_STRUCT(r->out);\ - NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ - r->in.level = _r.in.level;\ - r->in.buffer = _r.in.buffer;\ - r->in.offered = _r.in.offered;\ - r->out.needed = _r.out.needed;\ - if (!r->in.buffer && r->in.offered != 0) {\ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\ - (unsigned)r->in.offered);\ - } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\ - (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\ - }\ -} while(0) - -#define NDR_SPOOLSS_PULL_ENUM_OUT(fn) do { \ - _r.in.level = r->in.level;\ - _r.in.buffer = r->in.buffer;\ - _r.in.offered = r->in.offered;\ - _r.out.needed = r->out.needed;\ - NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ - r->out.info = NULL;\ - r->out.needed = _r.out.needed;\ - r->out.count = _r.out.count;\ - r->out.result = _r.out.result;\ - if (_r.out.info) {\ - struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr, ndr->iconv_convenience);\ - NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ - _ndr_info->flags= ndr->flags;\ - if (r->in.offered != _ndr_info->data_size) {\ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: offered[%u] doesn't match length of buffer[%u]",\ - (unsigned)r->in.offered, (unsigned)_ndr_info->data_size);\ - }\ - if (r->out.needed <= _ndr_info->data_size) {\ - struct __##fn __r;\ - __r.in.level = r->in.level;\ - __r.in.count = r->out.count;\ - __r.out.info = NULL;\ - NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\ - r->out.info = __r.out.info;\ - }\ - }\ -} while(0) - -#define NDR_SPOOLSS_PULL_ENUM(fn,in,out) do { \ - struct _##fn _r;\ - if (flags & NDR_IN) {\ - out;\ - NDR_SPOOLSS_PULL_ENUM_IN(fn);\ - in;\ - }\ - if (flags & NDR_OUT) {\ - out;\ - NDR_SPOOLSS_PULL_ENUM_OUT(fn);\ - }\ -} while(0) - -#define _NDR_CHECK_UINT32(call) do {\ - enum ndr_err_code _ndr_err; \ - _ndr_err = call; \ - if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ - return 0; \ - }\ -} while (0) - -/* TODO: set _ndr_info->flags correct */ -#define NDR_SPOOLSS_SIZE_ENUM(fn) do { \ - struct __##fn __r;\ - DATA_BLOB _data_blob_info;\ - struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\ - if (!_ndr_info) return 0;\ - _ndr_info->flags|=0;\ - __r.in.level = level;\ - __r.in.count = count;\ - __r.out.info = info;\ - _NDR_CHECK_UINT32(ndr_push___##fn(_ndr_info, NDR_OUT, &__r)); \ - _data_blob_info = ndr_push_blob(_ndr_info);\ - return _data_blob_info.length;\ -} while(0) - -/* - spoolss_EnumPrinters -*/ -enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinters,{ - _r.in.flags = r->in.flags; - _r.in.server = r->in.server; - },{ - _r.in.flags = r->in.flags; - _r.in.server = r->in.server; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinters,{ - r->in.flags = _r.in.flags; - r->in.server = _r.in.server; - },{ - _r.in.flags = r->in.flags; - _r.in.server = r->in.server; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinters); -} - -/* - spoolss_EnumJobs -*/ -enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumJobs,{ - _r.in.handle = r->in.handle; - _r.in.firstjob = r->in.firstjob; - _r.in.numjobs = r->in.numjobs; - },{ - _r.in.handle = r->in.handle; - _r.in.firstjob = r->in.firstjob; - _r.in.numjobs = r->in.numjobs; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumJobs,{ - r->in.handle = _r.in.handle; - r->in.firstjob = _r.in.firstjob; - r->in.numjobs = _r.in.numjobs; - },{ - _r.in.handle = r->in.handle; - _r.in.firstjob = r->in.firstjob; - _r.in.numjobs = r->in.numjobs; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumJobss_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumJobs); -} - -/* - spoolss_EnumPrinterDrivers -*/ -enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinterDrivers,{ - _r.in.server = r->in.server; - _r.in.environment = r->in.environment; - },{ - _r.in.server = r->in.server; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinterDrivers,{ - r->in.server = _r.in.server; - r->in.environment = _r.in.environment; - },{ - _r.in.server = r->in.server; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_DriverInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinterDrivers); -} - -/* - spoolss_EnumForms -*/ -enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumForms,{ - _r.in.handle = r->in.handle; - },{ - _r.in.handle = r->in.handle; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumForms,{ - r->in.handle = _r.in.handle; - },{ - _r.in.handle = r->in.handle; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_FormInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumForms); -} - -/* - spoolss_EnumPorts -*/ -enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPorts,{ - _r.in.servername= r->in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPorts,{ - r->in.servername= _r.in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PortInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPorts); -} - -/* - spoolss_EnumMonitors -*/ -enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumMonitors,{ - _r.in.servername= r->in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumMonitors,{ - r->in.servername= _r.in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumMonitors); -} - -/* - spoolss_EnumPrintProcessors -*/ -enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcessors,{ - _r.in.servername = r->in.servername; - _r.in.environment = r->in.environment; - },{ - _r.in.servername = r->in.servername; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcessors,{ - r->in.servername = _r.in.servername; - r->in.environment = _r.in.environment; - },{ - _r.in.servername = r->in.servername; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -uint32_t ndr_size_spoolss_EnumPrinterProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, - uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcessors); -} - -/* - spoolss_GetPrinterData -*/ -enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r) -{ - struct _spoolss_GetPrinterData _r; - if (flags & NDR_IN) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); - } - if (flags & NDR_OUT) { - struct ndr_push *_ndr_info; - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - _r.out.type = r->out.type; - _r.out.data = data_blob(NULL, 0); - _r.out.needed = r->out.needed; - _r.out.result = r->out.result; - { - struct __spoolss_GetPrinterData __r; - _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_info); - _ndr_info->flags= ndr->flags; - __r.in.type = r->out.type; - __r.out.data = r->out.data; - NDR_CHECK(ndr_push___spoolss_GetPrinterData(_ndr_info, flags, &__r)); - if (r->in.offered > _ndr_info->offset) { - uint32_t _padding_len = r->in.offered - _ndr_info->offset; - NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len)); - } - _r.out.data = ndr_push_blob(_ndr_info); - } - NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r) -{ - struct _spoolss_GetPrinterData _r; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - _r.out.type = r->out.type; - _r.out.data = data_blob(NULL,0), - _r.out.needed = r->out.needed; - NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r)); - r->in.handle = _r.in.handle; - r->in.value_name= _r.in.value_name; - r->in.offered = _r.in.offered; - r->out.needed = _r.out.needed; - } - if (flags & NDR_OUT) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - _r.out.type = r->out.type; - _r.out.data = data_blob(NULL,0), - _r.out.needed = r->out.needed; - _r.out.result = r->out.result; - NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r)); - r->out.type = _r.out.type; - ZERO_STRUCT(r->out.data); - r->out.needed = _r.out.needed; - r->out.result = _r.out.result; - if (_r.out.data.length != r->in.offered) { - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]", - (unsigned)r->in.offered, (unsigned)_r.out.data.length); - } - if (_r.out.data.length > 0 && r->out.needed <= _r.out.data.length) { - struct __spoolss_GetPrinterData __r; - struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_data); - _ndr_data->flags= ndr->flags; - __r.in.type = r->out.type; - __r.out.data = r->out.data; - NDR_CHECK(ndr_pull___spoolss_GetPrinterData(_ndr_data, flags, &__r)); - r->out.data = __r.out.data; - } else { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_NULL; - } - } - return NDR_ERR_SUCCESS; -} - -/* - spoolss_SetPrinterData -*/ -enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r) -{ - struct _spoolss_SetPrinterData _r; - if (flags & NDR_IN) { - struct ndr_push *_ndr_data; - struct __spoolss_SetPrinterData __r; - DATA_BLOB _data_blob_data; - - _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_data); - _ndr_data->flags= ndr->flags; - - __r.in.type = r->in.type; - __r.out.data = r->in.data; - NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r)); - _data_blob_data = ndr_push_blob(_ndr_data); - - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.type = r->in.type; - _r.in.data = _data_blob_data; - _r.in._offered = _data_blob_data.length; - _r.out.result = r->out.result; - NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); - } - if (flags & NDR_OUT) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.type = r->in.type; - _r.in.data = data_blob(NULL,0), - _r.in._offered = r->in._offered; - _r.out.result = r->out.result; - NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); - } - return NDR_ERR_SUCCESS; -} - -uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags) -{ - if (!devmode) return 0; - return ndr_size_spoolss_DeviceMode(devmode,ic,flags); -} diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 265fa68b48..a2fcdeae29 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co ndr->depth--; } +_PUBLIC_ size_t ndr_size_string_array(const char **a, uint32_t count, int flags) +{ + uint32_t i; + size_t size = 0; + + switch (flags & LIBNDR_STRING_FLAGS) { + case LIBNDR_FLAG_STR_NULLTERM: + for (i = 0; i < count; i++) { + size += strlen_m_term(a[i]); + } + break; + case LIBNDR_FLAG_STR_NOTERM: + for (i = 0; i < count; i++) { + size += strlen_m(a[i]); + } + break; + default: + return 0; + } + + return size; +} + /** * Return number of elements in a string including the last (zeroed) element */ diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c index 93e4a093f3..f89263bba3 100644 --- a/source4/librpc/ndr/py_security.c +++ b/source4/librpc/ndr/py_security.c @@ -41,29 +41,29 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods) } } -static int py_dom_sid_cmp(PyObject *self, PyObject *py_other) +static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other) { - struct dom_sid *this = py_talloc_get_ptr(self), *other; + struct dom_sid *self = py_talloc_get_ptr(py_self), *other; other = py_talloc_get_ptr(py_other); if (other == NULL) return -1; - return dom_sid_compare(this, other); + return dom_sid_compare(self, other); } -static PyObject *py_dom_sid_str(PyObject *self) +static PyObject *py_dom_sid_str(PyObject *py_self) { - struct dom_sid *this = py_talloc_get_ptr(self); - char *str = dom_sid_string(NULL, this); + struct dom_sid *self = py_talloc_get_ptr(py_self); + char *str = dom_sid_string(NULL, self); PyObject *ret = PyString_FromString(str); talloc_free(str); return ret; } -static PyObject *py_dom_sid_repr(PyObject *self) +static PyObject *py_dom_sid_repr(PyObject *py_self) { - struct dom_sid *this = py_talloc_get_ptr(self); - char *str = dom_sid_string(NULL, this); + struct dom_sid *self = py_talloc_get_ptr(py_self); + char *str = dom_sid_string(NULL, self); PyObject *ret = PyString_FromFormat("dom_sid('%s')", str); talloc_free(str); return ret; diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index 45c4e78cf1..7a568d3c9e 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -653,9 +653,9 @@ static void dcerpc_bind_recv_handler(struct rpc_request *req, handle timeouts of individual dcerpc requests */ static void dcerpc_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct rpc_request *req = talloc_get_type(private, struct rpc_request); + struct rpc_request *req = talloc_get_type(private_data, struct rpc_request); if (req->ignore_timeout) { dcerpc_req_dequeue(req); diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 9b8503c04b..0f9fbe0abc 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -709,9 +709,9 @@ static void continue_pipe_auth(struct composite_context *ctx) handle timeouts of a dcerpc connect */ static void dcerpc_connect_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct composite_context *c = talloc_get_type(private, struct composite_context); + struct composite_context *c = talloc_get_type(private_data, struct composite_context); composite_error(c, NT_STATUS_IO_TIMEOUT); } diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 312a44a5f0..013a8578e6 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -84,7 +84,7 @@ static void smb_read_callback(struct smbcli_request *req) uint16_t frag_length; NTSTATUS status; - state = talloc_get_type(req->async.private, struct smb_read_state); + state = talloc_get_type(req->async.private_data, struct smb_read_state); smb = talloc_get_type(state->c->transport.private_data, struct smb_private); io = state->io; @@ -133,7 +133,7 @@ static void smb_read_callback(struct smbcli_request *req) } state->req->async.fn = smb_read_callback; - state->req->async.private = state; + state->req->async.private_data = state; } /* @@ -185,7 +185,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO } req->async.fn = smb_read_callback; - req->async.private = state; + req->async.private_data = state; state->req = req; @@ -221,7 +221,7 @@ struct smb_trans_state { */ static void smb_trans_callback(struct smbcli_request *req) { - struct smb_trans_state *state = (struct smb_trans_state *)req->async.private; + struct smb_trans_state *state = (struct smb_trans_state *)req->async.private_data; struct dcerpc_connection *c = state->c; NTSTATUS status; @@ -293,7 +293,7 @@ static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *b } state->req->async.fn = smb_trans_callback; - state->req->async.private = state; + state->req->async.private_data = state; talloc_steal(state, state->req); @@ -305,7 +305,7 @@ static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *b */ static void smb_write_callback(struct smbcli_request *req) { - struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private; + struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private_data; if (!NT_STATUS_IS_OK(req->status)) { DEBUG(0,("dcerpc_smb: write callback error\n")); @@ -351,7 +351,7 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, } req->async.fn = smb_write_callback; - req->async.private = c; + req->async.private_data = c; if (trigger_read) { send_read_request(c); @@ -501,7 +501,7 @@ struct composite_context *dcerpc_pipe_open_smb_send(struct dcerpc_pipe *p, static void pipe_open_recv(struct smbcli_request *req) { - struct pipe_open_smb_state *state = talloc_get_type(req->async.private, + struct pipe_open_smb_state *state = talloc_get_type(req->async.private_data, struct pipe_open_smb_state); struct composite_context *ctx = state->ctx; struct dcerpc_connection *c = state->c; diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 689249288f..64a5b92e90 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -85,9 +85,9 @@ static void sock_dead(struct dcerpc_connection *p, NTSTATUS status) /* handle socket recv errors */ -static void sock_error_handler(void *private, NTSTATUS status) +static void sock_error_handler(void *private_data, NTSTATUS status) { - struct dcerpc_connection *p = talloc_get_type(private, + struct dcerpc_connection *p = talloc_get_type(private_data, struct dcerpc_connection); sock_dead(p, status); } @@ -95,7 +95,7 @@ static void sock_error_handler(void *private, NTSTATUS status) /* check if a blob is a complete packet */ -static NTSTATUS sock_complete_packet(void *private, DATA_BLOB blob, size_t *size) +static NTSTATUS sock_complete_packet(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < DCERPC_FRAG_LEN_OFFSET+2) { return STATUS_MORE_ENTRIES; @@ -110,9 +110,9 @@ static NTSTATUS sock_complete_packet(void *private, DATA_BLOB blob, size_t *size /* process recv requests */ -static NTSTATUS sock_process_recv(void *private, DATA_BLOB blob) +static NTSTATUS sock_process_recv(void *private_data, DATA_BLOB blob) { - struct dcerpc_connection *p = talloc_get_type(private, + struct dcerpc_connection *p = talloc_get_type(private_data, struct dcerpc_connection); struct sock_private *sock = (struct sock_private *)p->transport.private_data; sock->pending_reads--; @@ -127,9 +127,9 @@ static NTSTATUS sock_process_recv(void *private, DATA_BLOB blob) called when a IO is triggered by the events system */ static void sock_io_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct dcerpc_connection *p = talloc_get_type(private, + struct dcerpc_connection *p = talloc_get_type(private_data, struct dcerpc_connection); struct sock_private *sock = (struct sock_private *)p->transport.private_data; diff --git a/source4/librpc/tests/test_ndrdump.sh b/source4/librpc/tests/test_ndrdump.sh index 511856061c..dccf86df88 100755 --- a/source4/librpc/tests/test_ndrdump.sh +++ b/source4/librpc/tests/test_ndrdump.sh @@ -8,8 +8,8 @@ failed=0 -samba4bindir=`dirname $0`/../../bin -ndrdump=$samba4bindir/ndrdump +samba4bindir="$BUILDDIR/bin" +ndrdump="$samba4bindir/ndrdump$EXEEXT" files=`dirname $0`/ testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1` diff --git a/source4/main.mk b/source4/main.mk index bfff04d13c..04f7a36a5f 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -49,3 +49,4 @@ mkinclude scripting/python/config.mk mkinclude kdc/config.mk mkinclude ../lib/smbconf/config.mk mkinclude ../lib/async_req/config.mk +mkinclude ../libcli/security/config.mk diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index b6db2090d2..afd9242188 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -18,7 +18,7 @@ $(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsdb_proto.h,$(WI SUBSYSTEM = LIBLDB INIT_FUNCTION = LDB_MODULE(wins_ldb) PRIVATE_DEPENDENCIES = \ - LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL + LIBLDB LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL # End MODULE ldb_wins_ldb ####################### diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c index a3a7552f6a..e5c82280e3 100644 --- a/source4/nbt_server/dgram/netlogon.c +++ b/source4/nbt_server/dgram/netlogon.c @@ -161,7 +161,7 @@ void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot, { NTSTATUS status = NT_STATUS_NO_MEMORY; struct nbtd_interface *iface = - talloc_get_type(dgmslot->private, struct nbtd_interface); + talloc_get_type(dgmslot->private_data, struct nbtd_interface); struct nbt_netlogon_packet *netlogon = talloc(dgmslot, struct nbt_netlogon_packet); struct nbtd_iface_name *iname; diff --git a/source4/nbt_server/dgram/ntlogon.c b/source4/nbt_server/dgram/ntlogon.c index 352be34489..87e76e08ee 100644 --- a/source4/nbt_server/dgram/ntlogon.c +++ b/source4/nbt_server/dgram/ntlogon.c @@ -76,7 +76,7 @@ void nbtd_mailslot_ntlogon_handler(struct dgram_mailslot_handler *dgmslot, { NTSTATUS status = NT_STATUS_NO_MEMORY; struct nbtd_interface *iface = - talloc_get_type(dgmslot->private, struct nbtd_interface); + talloc_get_type(dgmslot->private_data, struct nbtd_interface); struct nbt_ntlogon_packet *ntlogon = talloc(dgmslot, struct nbt_ntlogon_packet); struct nbtd_iface_name *iname; diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c index fc61372ead..951f1d296a 100644 --- a/source4/nbt_server/irpc.c +++ b/source4/nbt_server/irpc.c @@ -36,7 +36,8 @@ static NTSTATUS nbtd_information(struct irpc_message *msg, struct nbtd_information *r) { - struct nbtd_server *server = talloc_get_type(msg->private, struct nbtd_server); + struct nbtd_server *server = talloc_get_type(msg->private_data, + struct nbtd_server); switch (r->in.level) { case NBTD_INFO_STATISTICS: @@ -64,7 +65,7 @@ static void getdc_recv_netlogon_reply(struct dgram_mailslot_handler *dgmslot, struct socket_address *src) { struct getdc_state *s = - talloc_get_type(dgmslot->private, struct getdc_state); + talloc_get_type(dgmslot->private_data, struct getdc_state); const char *p; struct nbt_netlogon_response netlogon; NTSTATUS status; @@ -111,7 +112,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, struct nbtd_getdcname *req) { struct nbtd_server *server = - talloc_get_type(msg->private, struct nbtd_server); + talloc_get_type(msg->private_data, struct nbtd_server); struct nbtd_interface *iface = nbtd_find_request_iface(server, req->in.ip_address, true); struct getdc_state *s; struct nbt_netlogon_packet p; diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 557c0f1dc6..93382d7ddc 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -28,18 +28,18 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "nbt_server/nbt_server.h" #include "nbt_server/wins/winsdb.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "lib/ldb/include/ldb_module.h" #include "system/network.h" #include "lib/socket/netif.h" #include "param/param.h" static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req) { - struct winsdb_handle *h = talloc_get_type(ldb_get_opaque(module->ldb, "winsdb_handle"), + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct winsdb_handle *h = talloc_get_type(ldb_get_opaque(ldb, "winsdb_handle"), struct winsdb_handle); const struct ldb_message *msg; @@ -62,7 +62,7 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req) } if (!h) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "%s", "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!"); + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "%s", "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!"); return LDB_ERR_OTHER; } @@ -73,39 +73,40 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); case WINSDB_HANDLE_CALLER_ADMIN: - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "%s\n", "WINS_LDB: TODO verify add/modify for WINSDB_HANDLE_CALLER_ADMIN"); + ldb_debug(ldb, LDB_DEBUG_WARNING, "%s\n", "WINS_LDB: TODO verify add/modify for WINSDB_HANDLE_CALLER_ADMIN"); return ldb_next_request(module, req); } return LDB_ERR_OTHER; } -static int wins_ldb_init(struct ldb_module *ctx) +static int wins_ldb_init(struct ldb_module *module) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct winsdb_handle *h; const char *owner; - struct loadparm_context *lp_ctx = ldb_get_opaque(ctx->ldb, "loadparm"); + struct loadparm_context *lp_ctx = ldb_get_opaque(ldb, "loadparm"); - ctx->private_data = NULL; + ldb_module_set_private(module, NULL); owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner"); if (!owner) { struct interface *ifaces; - load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces); + load_interfaces(module, lp_interfaces(lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); if (!owner) { owner = "0.0.0.0"; } } - h = talloc_zero(ctx, struct winsdb_handle); + h = talloc_zero(module, struct winsdb_handle); if (!h) goto failed; - h->ldb = ctx->ldb; + h->ldb = ldb; h->caller = WINSDB_HANDLE_CALLER_ADMIN; h->local_owner = talloc_strdup(h, owner); if (!h->local_owner) goto failed; - return ldb_set_opaque(ctx->ldb, "winsdb_handle", h); + return ldb_set_opaque(ldb, "winsdb_handle", h); failed: talloc_free(h); diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index bf9b8c442a..5c3efe2b83 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -168,7 +168,7 @@ static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, return dn; } -static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, const struct ldb_dn *dn, struct nbt_name **_name) +static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct nbt_name **_name) { NTSTATUS status; struct nbt_name *name; diff --git a/source4/nbt_server/wins/winswack.c b/source4/nbt_server/wins/winswack.c index c499889f9e..c53fa1d069 100644 --- a/source4/nbt_server/wins/winswack.c +++ b/source4/nbt_server/wins/winswack.c @@ -295,7 +295,7 @@ NTSTATUS nbtd_proxy_wins_challenge(struct irpc_message *msg, struct nbtd_proxy_wins_challenge *req) { struct nbtd_server *nbtd_server = - talloc_get_type(msg->private, struct nbtd_server); + talloc_get_type(msg->private_data, struct nbtd_server); struct proxy_wins_challenge_state *s; uint32_t i; @@ -355,7 +355,7 @@ NTSTATUS nbtd_proxy_wins_release_demand(struct irpc_message *msg, struct nbtd_proxy_wins_release_demand *req) { struct nbtd_server *nbtd_server = - talloc_get_type(msg->private, struct nbtd_server); + talloc_get_type(msg->private_data, struct nbtd_server); struct proxy_wins_release_demand_state *s; uint32_t i; diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c index 575be1e97e..4306e5a938 100644 --- a/source4/ntp_signd/ntp_signd.c +++ b/source4/ntp_signd/ntp_signd.c @@ -110,9 +110,9 @@ static NTSTATUS signing_failure(struct ntp_signd_connection *ntp_signdconn, /* receive a full packet on a NTP_SIGND connection */ -static NTSTATUS ntp_signd_recv(void *private, DATA_BLOB wrapped_input) +static NTSTATUS ntp_signd_recv(void *private_data, DATA_BLOB wrapped_input) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private, + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private_data, struct ntp_signd_connection); NTSTATUS status = NT_STATUS_UNSUCCESSFUL; TALLOC_CTX *tmp_ctx = talloc_new(ntp_signdconn); @@ -263,7 +263,7 @@ static NTSTATUS ntp_signd_recv(void *private, DATA_BLOB wrapped_input) */ static void ntp_signd_recv_handler(struct stream_connection *conn, uint16_t flags) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private, + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private_data, struct ntp_signd_connection); packet_recv(ntp_signdconn->packet); } @@ -271,9 +271,9 @@ static void ntp_signd_recv_handler(struct stream_connection *conn, uint16_t flag /* called on a tcp recv error */ -static void ntp_signd_recv_error(void *private, NTSTATUS status) +static void ntp_signd_recv_error(void *private_data, NTSTATUS status) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private, struct ntp_signd_connection); + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private_data, struct ntp_signd_connection); ntp_signd_terminate_connection(ntp_signdconn, nt_errstr(status)); } @@ -282,7 +282,7 @@ static void ntp_signd_recv_error(void *private, NTSTATUS status) */ static void ntp_signd_send(struct stream_connection *conn, uint16_t flags) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private, + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private_data, struct ntp_signd_connection); packet_queue_run(ntp_signdconn->packet); } @@ -292,7 +292,7 @@ static void ntp_signd_send(struct stream_connection *conn, uint16_t flags) */ static void ntp_signd_accept(struct stream_connection *conn) { - struct ntp_signd_server *ntp_signd = talloc_get_type(conn->private, struct ntp_signd_server); + struct ntp_signd_server *ntp_signd = talloc_get_type(conn->private_data, struct ntp_signd_server); struct ntp_signd_connection *ntp_signdconn; ntp_signdconn = talloc_zero(conn, struct ntp_signd_connection); @@ -302,7 +302,7 @@ static void ntp_signd_accept(struct stream_connection *conn) } ntp_signdconn->conn = conn; ntp_signdconn->ntp_signd = ntp_signd; - conn->private = ntp_signdconn; + conn->private_data = ntp_signdconn; ntp_signdconn->packet = packet_init(ntp_signdconn); if (ntp_signdconn->packet == NULL) { diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index e615401e51..be9096b01f 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -64,14 +64,14 @@ struct async_info { }; #define CHECK_UPSTREAM_OPEN do { \ - if (! private->transport->socket->sock) { \ + if (! p->transport->socket->sock) { \ req->async_states->state|=NTVFS_ASYNC_STATE_CLOSE; \ return NT_STATUS_CONNECTION_DISCONNECTED; \ } \ } while(0) #define SETUP_PID do { \ - private->tree->session->pid = req->smbpid; \ + p->tree->session->pid = req->smbpid; \ CHECK_UPSTREAM_OPEN; \ } while(0) @@ -110,12 +110,12 @@ struct async_info { */ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private) { - struct cvfs_private *private = p_private; + struct cvfs_private *p = p_private; NTSTATUS status; struct ntvfs_handle *h = NULL; struct cvfs_file *f; - for (f=private->files; f; f=f->next) { + for (f=p->files; f; f=f->next) { if (f->fnum != fnum) continue; h = f->h; break; @@ -127,7 +127,7 @@ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin } DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum)); - status = ntvfs_send_oplock_break(private->ntvfs, h, level); + status = ntvfs_send_oplock_break(p->ntvfs, h, level); if (!NT_STATUS_IS_OK(status)) return false; return true; } @@ -139,7 +139,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct cvfs_private *private; + struct cvfs_private *p; const char *host, *user, *pass, *domain, *remote_share; struct smb_composite_connect io; struct composite_context *creq; @@ -163,12 +163,12 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, machine_account = share_bool_option(scfg, CIFS_USE_MACHINE_ACCT, CIFS_USE_MACHINE_ACCT_DEFAULT); - private = talloc_zero(ntvfs, struct cvfs_private); - if (!private) { + p = talloc_zero(ntvfs, struct cvfs_private); + if (!p) { return NT_STATUS_NO_MEMORY; } - ntvfs->private_data = private; + ntvfs->private_data = p; if (!host) { DEBUG(1,("CIFS backend: You must supply server\n")); @@ -177,7 +177,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, if (user && pass) { DEBUG(5, ("CIFS backend: Using specified password\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); if (!credentials) { return NT_STATUS_NO_MEMORY; } @@ -189,7 +189,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, cli_credentials_set_password(credentials, pass, CRED_SPECIFIED); } else if (machine_account) { DEBUG(5, ("CIFS backend: Using machine account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); if (domain) { cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); @@ -217,7 +217,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.service = remote_share; io.in.service_type = "?????"; io.in.iconv_convenience = lp_iconv_convenience(ntvfs->ctx->lp_ctx); - io.in.gensec_settings = lp_gensec_settings(private, ntvfs->ctx->lp_ctx); + io.in.gensec_settings = lp_gensec_settings(p, ntvfs->ctx->lp_ctx); lp_smbcli_options(ntvfs->ctx->lp_ctx, &io.in.options); lp_smbcli_session_options(ntvfs->ctx->lp_ctx, &io.in.session_options); @@ -225,17 +225,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.options.use_level2_oplocks = false; } - creq = smb_composite_connect_send(&io, private, + creq = smb_composite_connect_send(&io, p, lp_resolve_context(ntvfs->ctx->lp_ctx), ntvfs->ctx->event_ctx); - status = smb_composite_connect_recv(creq, private); + status = smb_composite_connect_recv(creq, p); NT_STATUS_NOT_OK_RETURN(status); - private->tree = io.out.tree; + p->tree = io.out.tree; - private->transport = private->tree->session->transport; + p->transport = p->tree->session->transport; SETUP_PID; - private->ntvfs = ntvfs; + p->ntvfs = ntvfs; ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); @@ -243,11 +243,11 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); /* we need to receive oplock break requests from the server */ - smbcli_oplock_handler(private->transport, oplock_handler, private); + smbcli_oplock_handler(p->transport, oplock_handler, p); - private->map_generic = share_bool_option(scfg, CIFS_MAP_GENERIC, CIFS_MAP_GENERIC_DEFAULT); + p->map_generic = share_bool_option(scfg, CIFS_MAP_GENERIC, CIFS_MAP_GENERIC_DEFAULT); - private->map_trans2 = share_bool_option(scfg, CIFS_MAP_TRANS2, CIFS_MAP_TRANS2_DEFAULT); + p->map_trans2 = share_bool_option(scfg, CIFS_MAP_TRANS2, CIFS_MAP_TRANS2_DEFAULT); return NT_STATUS_OK; } @@ -257,17 +257,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct async_info *a, *an; /* first cleanup pending requests */ - for (a=private->pending; a; a = an) { + for (a=p->pending; a; a = an) { an = a->next; smbcli_request_destroy(a->c_req); talloc_free(a); } - talloc_free(private); + talloc_free(p); ntvfs->private_data = NULL; return NT_STATUS_OK; @@ -289,7 +289,7 @@ static int async_info_destructor(struct async_info *async) */ static void async_simple(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smbcli_request_simple_recv(c_req); talloc_free(async); @@ -307,10 +307,10 @@ static void async_simple(struct smbcli_request *c_req) async->parms = io; \ async->req = req; \ async->f = file; \ - async->cvfs = private; \ + async->cvfs = p; \ async->c_req = c_req; \ - DLIST_ADD(private->pending, async); \ - c_req->async.private = async; \ + DLIST_ADD(p->pending, async); \ + c_req->async.private_data = async; \ talloc_set_destructor(async, async_info_destructor); \ } \ c_req->async.fn = async_fn; \ @@ -329,7 +329,7 @@ static void async_simple(struct smbcli_request *c_req) static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_unlink *unl) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; @@ -337,10 +337,10 @@ static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, /* see if the front end will allow us to perform this function asynchronously. */ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_unlink(private->tree, unl); + return smb_raw_unlink(p->tree, unl); } - c_req = smb_raw_unlink_send(private->tree, unl); + c_req = smb_raw_unlink_send(p->tree, unl); SIMPLE_ASYNC_TAIL; } @@ -350,7 +350,7 @@ static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, */ static void async_ioctl(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_ioctl_recv(c_req, req, async->parms); talloc_free(async); @@ -363,7 +363,7 @@ static void async_ioctl(struct smbcli_request *c_req) static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_ioctl *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; @@ -371,10 +371,10 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, /* see if the front end will allow us to perform this function asynchronously. */ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_ioctl(private->tree, req, io); + return smb_raw_ioctl(p->tree, req, io); } - c_req = smb_raw_ioctl_send(private->tree, io); + c_req = smb_raw_ioctl_send(p->tree, io); ASYNC_RECV_TAIL(io, async_ioctl); } @@ -385,16 +385,16 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_chkpath *cp) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_chkpath(private->tree, cp); + return smb_raw_chkpath(p->tree, cp); } - c_req = smb_raw_chkpath_send(private->tree, cp); + c_req = smb_raw_chkpath_send(p->tree, cp); SIMPLE_ASYNC_TAIL; } @@ -404,7 +404,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, */ static void async_qpathinfo(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_pathinfo_recv(c_req, req, async->parms); talloc_free(async); @@ -417,16 +417,16 @@ static void async_qpathinfo(struct smbcli_request *c_req) static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_pathinfo(private->tree, req, info); + return smb_raw_pathinfo(p->tree, req, info); } - c_req = smb_raw_pathinfo_send(private->tree, info); + c_req = smb_raw_pathinfo_send(p->tree, info); ASYNC_RECV_TAIL(info, async_qpathinfo); } @@ -436,7 +436,7 @@ static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, */ static void async_qfileinfo(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_fileinfo_recv(c_req, req, async->parms); talloc_free(async); @@ -449,16 +449,16 @@ static void async_qfileinfo(struct smbcli_request *c_req) static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_fileinfo(private->tree, req, io); + return smb_raw_fileinfo(p->tree, req, io); } - c_req = smb_raw_fileinfo_send(private->tree, io); + c_req = smb_raw_fileinfo_send(p->tree, io); ASYNC_RECV_TAIL(io, async_qfileinfo); } @@ -470,16 +470,16 @@ static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *st) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_setpathinfo(private->tree, st); + return smb_raw_setpathinfo(p->tree, st); } - c_req = smb_raw_setpathinfo_send(private->tree, st); + c_req = smb_raw_setpathinfo_send(p->tree, st); SIMPLE_ASYNC_TAIL; } @@ -490,7 +490,7 @@ static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, */ static void async_open(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct cvfs_private *cvfs = async->cvfs; struct ntvfs_request *req = async->req; struct cvfs_file *f = async->f; @@ -516,7 +516,7 @@ failed: static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; struct ntvfs_handle *h; struct cvfs_file *f; @@ -525,7 +525,7 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, SETUP_PID; if (io->generic.level != RAW_OPEN_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_open(ntvfs, req, io); } @@ -539,21 +539,21 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { union smb_handle *file; - status = smb_raw_open(private->tree, req, io); + status = smb_raw_open(p->tree, req, io); NT_STATUS_NOT_OK_RETURN(status); SMB_OPEN_OUT_FILE(io, file); f->fnum = file->fnum; file->ntvfs = NULL; - status = ntvfs_handle_set_backend_data(f->h, private->ntvfs, f); + status = ntvfs_handle_set_backend_data(f->h, p->ntvfs, f); NT_STATUS_NOT_OK_RETURN(status); file->ntvfs = f->h; - DLIST_ADD(private->files, f); + DLIST_ADD(p->files, f); return NT_STATUS_OK; } - c_req = smb_raw_open_send(private->tree, io); + c_req = smb_raw_open_send(p->tree, io); ASYNC_RECV_TAIL_F(io, async_open, f); } @@ -564,16 +564,16 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_mkdir *md) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_mkdir(private->tree, md); + return smb_raw_mkdir(p->tree, md); } - c_req = smb_raw_mkdir_send(private->tree, md); + c_req = smb_raw_mkdir_send(p->tree, md); SIMPLE_ASYNC_TAIL; } @@ -584,15 +584,15 @@ static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_rmdir *rd) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_rmdir(private->tree, rd); + return smb_raw_rmdir(p->tree, rd); } - c_req = smb_raw_rmdir_send(private->tree, rd); + c_req = smb_raw_rmdir_send(p->tree, rd); SIMPLE_ASYNC_TAIL; } @@ -603,7 +603,7 @@ static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_rename *ren) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; @@ -616,10 +616,10 @@ static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, } if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_rename(private->tree, ren); + return smb_raw_rename(p->tree, ren); } - c_req = smb_raw_rename_send(private->tree, ren); + c_req = smb_raw_rename_send(p->tree, ren); SIMPLE_ASYNC_TAIL; } @@ -638,7 +638,7 @@ static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs, */ static void async_read(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_read_recv(c_req, async->parms); talloc_free(async); @@ -651,23 +651,23 @@ static void async_read(struct smbcli_request *c_req) static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_READ_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_read(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_read(private->tree, io); + return smb_raw_read(p->tree, io); } - c_req = smb_raw_read_send(private->tree, io); + c_req = smb_raw_read_send(p->tree, io); ASYNC_RECV_TAIL(io, async_read); } @@ -677,7 +677,7 @@ static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, */ static void async_write(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_write_recv(c_req, async->parms); talloc_free(async); @@ -690,22 +690,22 @@ static void async_write(struct smbcli_request *c_req) static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_WRITE_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_write(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_write(private->tree, io); + return smb_raw_write(p->tree, io); } - c_req = smb_raw_write_send(private->tree, io); + c_req = smb_raw_write_send(p->tree, io); ASYNC_RECV_TAIL(io, async_write); } @@ -715,7 +715,7 @@ static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, */ static void async_seek(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_seek_recv(c_req, async->parms); talloc_free(async); @@ -729,16 +729,16 @@ static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_seek *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_seek(private->tree, io); + return smb_raw_seek(p->tree, io); } - c_req = smb_raw_seek_send(private->tree, io); + c_req = smb_raw_seek_send(p->tree, io); ASYNC_RECV_TAIL(io, async_seek); } @@ -750,7 +750,7 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; @@ -766,10 +766,10 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, } if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_flush(private->tree, io); + return smb_raw_flush(p->tree, io); } - c_req = smb_raw_flush_send(private->tree, io); + c_req = smb_raw_flush_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -780,7 +780,7 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; struct cvfs_file *f; union smb_close io2; @@ -788,7 +788,7 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, SETUP_PID; if (io->generic.level != RAW_CLOSE_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_close(ntvfs, req, io); } @@ -805,13 +805,13 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, even if file-close fails, we'll remove it from the list, what else would we do? Maybe we should not remove until after the proxied call completes? */ - DLIST_REMOVE(private->files, f); + DLIST_REMOVE(p->files, f); if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_close(private->tree, io); + return smb_raw_close(p->tree, io); } - c_req = smb_raw_close_send(private->tree, io); + c_req = smb_raw_close_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -822,16 +822,16 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_exit(private->tree->session); + return smb_raw_exit(p->tree->session); } - c_req = smb_raw_exit_send(private->tree->session); + c_req = smb_raw_exit_send(p->tree->session); SIMPLE_ASYNC_TAIL; } @@ -851,7 +851,7 @@ static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -862,11 +862,11 @@ static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct async_info *a; /* find the matching request */ - for (a=private->pending;a;a=a->next) { + for (a=p->pending;a;a=a->next) { if (a->req == req) { break; } @@ -885,22 +885,22 @@ static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_lock *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_LOCK_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_lock(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_lock(private->tree, io); + return smb_raw_lock(p->tree, io); } - c_req = smb_raw_lock_send(private->tree, io); + c_req = smb_raw_lock_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -911,15 +911,15 @@ static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_setfileinfo(private->tree, io); + return smb_raw_setfileinfo(p->tree, io); } - c_req = smb_raw_setfileinfo_send(private->tree, io); + c_req = smb_raw_setfileinfo_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -930,7 +930,7 @@ static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, */ static void async_fsinfo(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_fsinfo_recv(c_req, req, async->parms); talloc_free(async); @@ -943,16 +943,16 @@ static void async_fsinfo(struct smbcli_request *c_req) static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_fsinfo(private->tree, req, fs); + return smb_raw_fsinfo(p->tree, req, fs); } - c_req = smb_raw_fsinfo_send(private->tree, req, fs); + c_req = smb_raw_fsinfo_send(p->tree, req, fs); ASYNC_RECV_TAIL(fs, async_fsinfo); } @@ -974,11 +974,11 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; SETUP_PID; - return smb_raw_search_first(private->tree, req, io, search_private, callback); + return smb_raw_search_first(p->tree, req, io, search_private, callback); } /* continue a search */ @@ -987,22 +987,22 @@ static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; SETUP_PID; - return smb_raw_search_next(private->tree, req, io, search_private, callback); + return smb_raw_search_next(p->tree, req, io, search_private, callback); } /* close a search */ static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; SETUP_PID; - return smb_raw_search_close(private->tree, io); + return smb_raw_search_close(p->tree, io); } /* @@ -1010,7 +1010,7 @@ static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs, */ static void async_trans2(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_trans2_recv(c_req, req, async->parms); talloc_free(async); @@ -1022,20 +1022,20 @@ static NTSTATUS cvfs_trans2(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_trans2 *trans2) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; - if (private->map_trans2) { + if (p->map_trans2) { return NT_STATUS_NOT_IMPLEMENTED; } SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_trans2(private->tree, req, trans2); + return smb_raw_trans2(p->tree, req, trans2); } - c_req = smb_raw_trans2_send(private->tree, trans2); + c_req = smb_raw_trans2_send(p->tree, trans2); ASYNC_RECV_TAIL(trans2, async_trans2); } @@ -1054,7 +1054,7 @@ static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs, */ static void async_changenotify(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_changenotify_recv(c_req, req, async->parms); talloc_free(async); @@ -1066,9 +1066,9 @@ static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_notify *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; - int saved_timeout = private->transport->options.request_timeout; + int saved_timeout = p->transport->options.request_timeout; struct cvfs_file *f; if (io->nttrans.level != RAW_NOTIFY_NTTRANS) { @@ -1088,11 +1088,11 @@ static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs, /* we must not timeout on notify requests - they wait forever */ - private->transport->options.request_timeout = 0; + p->transport->options.request_timeout = 0; - c_req = smb_raw_changenotify_send(private->tree, io); + c_req = smb_raw_changenotify_send(p->tree, io); - private->transport->options.request_timeout = saved_timeout; + p->transport->options.request_timeout = saved_timeout; ASYNC_RECV_TAIL(io, async_changenotify); } diff --git a/source4/ntvfs/cifs_posix_cli/svfs_util.c b/source4/ntvfs/cifs_posix_cli/svfs_util.c index e502340229..03a46205a7 100644 --- a/source4/ntvfs/cifs_posix_cli/svfs_util.c +++ b/source4/ntvfs/cifs_posix_cli/svfs_util.c @@ -39,17 +39,17 @@ char *cifspsx_unix_path(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *name) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; char *ret; if (*name != '\\') { - ret = talloc_asprintf(req, "%s/%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s/%s", p->connectpath, name); } else { - ret = talloc_asprintf(req, "%s%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s%s", p->connectpath, name); } all_string_sub(ret, "\\", "/", 0); - strlower(ret + strlen(private->connectpath)); + strlower(ret + strlen(p->connectpath)); return ret; } @@ -145,13 +145,13 @@ struct cifspsx_dir *cifspsx_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request */ struct cifspsx_dir *cifspsx_list(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *pattern) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; char *unix_path; unix_path = cifspsx_unix_path(ntvfs, req, pattern); if (!unix_path) { return NULL; } - return cifspsx_list_unix(private, req, unix_path); + return cifspsx_list_unix(p, req, unix_path); } diff --git a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c index 34a26b06b4..02fe9f2264 100644 --- a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c +++ b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c @@ -51,21 +51,21 @@ static NTSTATUS cifspsx_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct stat st; - struct cifspsx_private *private; + struct cifspsx_private *p; struct share_config *scfg = ntvfs->ctx->config; - private = talloc(ntvfs, struct cifspsx_private); - NT_STATUS_HAVE_NO_MEMORY(private); - private->ntvfs = ntvfs; - private->next_search_handle = 0; - private->connectpath = talloc_strdup(private, share_string_option(scfg, SHARE_PATH, "")); - private->open_files = NULL; - private->search = NULL; + p = talloc(ntvfs, struct cifspsx_private); + NT_STATUS_HAVE_NO_MEMORY(p); + p->ntvfs = ntvfs; + p->next_search_handle = 0; + p->connectpath = talloc_strdup(p, share_string_option(scfg, SHARE_PATH, "")); + p->open_files = NULL; + p->search = NULL; /* the directory must exist */ - if (stat(private->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { + if (stat(p->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { DEBUG(0,("'%s' is not a directory, when connecting to [%s]\n", - private->connectpath, sharename)); + p->connectpath, sharename)); return NT_STATUS_BAD_NETWORK_NAME; } @@ -74,7 +74,7 @@ static NTSTATUS cifspsx_connect(struct ntvfs_module_context *ntvfs, ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); - ntvfs->private_data = private; + ntvfs->private_data = p; DEBUG(0,("WARNING: ntvfs cifs posix: connect to share [%s] with ROOT privileges!!!\n",sharename)); @@ -92,12 +92,12 @@ static NTSTATUS cifspsx_disconnect(struct ntvfs_module_context *ntvfs) /* find open file handle given fd */ -static struct cifspsx_file *find_fd(struct cifspsx_private *private, struct ntvfs_handle *handle) +static struct cifspsx_file *find_fd(struct cifspsx_private *cp, struct ntvfs_handle *handle) { struct cifspsx_file *f; void *p; - p = ntvfs_handle_get_backend_data(handle, private->ntvfs); + p = ntvfs_handle_get_backend_data(handle, cp->ntvfs); if (!p) return NULL; f = talloc_get_type(p, struct cifspsx_file); @@ -278,7 +278,7 @@ static NTSTATUS cifspsx_qpathinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; struct stat st; @@ -286,7 +286,7 @@ static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs, return ntvfs_map_qfileinfo(ntvfs, req, info); } - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -305,7 +305,7 @@ static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; char *unix_path; struct stat st; int fd, flags; @@ -394,7 +394,7 @@ do_open: f->name = talloc_strdup(f, unix_path); NT_STATUS_HAVE_NO_MEMORY(f->name); - DLIST_ADD(private->open_files, f); + DLIST_ADD(p->open_files, f); status = ntvfs_handle_set_backend_data(handle, ntvfs, f); NT_STATUS_NOT_OK_RETURN(status); @@ -495,7 +495,7 @@ static NTSTATUS cifspsx_copy(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; ssize_t ret; @@ -503,7 +503,7 @@ static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - f = find_fd(private, rd->readx.in.file.ntvfs); + f = find_fd(p, rd->readx.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -529,7 +529,7 @@ static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; ssize_t ret; @@ -539,7 +539,7 @@ static NTSTATUS cifspsx_write(struct ntvfs_module_context *ntvfs, CHECK_READ_ONLY(req); - f = find_fd(private, wr->writex.in.file.ntvfs); + f = find_fd(p, wr->writex.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -575,14 +575,14 @@ static NTSTATUS cifspsx_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; switch (io->generic.level) { case RAW_FLUSH_FLUSH: case RAW_FLUSH_SMB2: /* ignore the additional unknown option in SMB2 */ - f = find_fd(private, io->generic.in.file.ntvfs); + f = find_fd(p, io->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -590,7 +590,7 @@ static NTSTATUS cifspsx_flush(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; case RAW_FLUSH_ALL: - for (f=private->open_files;f;f=f->next) { + for (f=p->open_files;f;f=f->next) { fsync(f->fd); } return NT_STATUS_OK; @@ -606,7 +606,7 @@ static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -614,7 +614,7 @@ static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; } - f = find_fd(private, io->close.in.file.ntvfs); + f = find_fd(p, io->close.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -623,7 +623,7 @@ static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs, return map_nt_error_from_unix(errno); } - DLIST_REMOVE(private->open_files, f); + DLIST_REMOVE(p->open_files, f); talloc_free(f->name); talloc_free(f); @@ -653,7 +653,7 @@ static NTSTATUS cifspsx_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cifspsx_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -694,13 +694,13 @@ static NTSTATUS cifspsx_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *info) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; struct utimbuf unix_times; CHECK_READ_ONLY(req); - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -746,14 +746,14 @@ static NTSTATUS cifspsx_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct stat st; if (fs->generic.level != RAW_QFS_GENERIC) { return ntvfs_map_fsinfo(ntvfs, req, fs); } - if (sys_fsusage(private->connectpath, + if (sys_fsusage(p->connectpath, &fs->generic.out.blocks_free, &fs->generic.out.blocks_total) == -1) { return map_nt_error_from_unix(errno); @@ -761,7 +761,7 @@ static NTSTATUS cifspsx_fsinfo(struct ntvfs_module_context *ntvfs, fs->generic.out.block_size = 512; - if (stat(private->connectpath, &st) != 0) { + if (stat(p->connectpath, &st) != 0) { return NT_STATUS_DISK_CORRUPT_ERROR; } @@ -789,13 +789,13 @@ static NTSTATUS cifspsx_fsattr(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsattr *fs) { struct stat st; - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; if (fs->generic.level != RAW_FSATTR_GENERIC) { return ntvfs_map_fsattr(ntvfs, req, fs); } - if (stat(private->connectpath, &st) == -1) { + if (stat(p->connectpath, &st) == -1) { return map_nt_error_from_unix(errno); } @@ -833,7 +833,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, { struct cifspsx_dir *dir; int i; - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -846,7 +846,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - search = talloc_zero(private, struct search_state); + search = talloc_zero(p, struct search_state); if (!search) { return NT_STATUS_NO_MEMORY; } @@ -858,7 +858,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - search->handle = private->next_search_handle; + search->handle = p->next_search_handle; search->dir = dir; if (dir->count < max_count) { @@ -892,8 +892,8 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { talloc_free(search); } else { - private->next_search_handle++; - DLIST_ADD(private->search, search); + p->next_search_handle++; + DLIST_ADD(p->search, search); } return NT_STATUS_OK; @@ -907,7 +907,7 @@ static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs, { struct cifspsx_dir *dir; int i; - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -920,7 +920,7 @@ static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->t2fnext.in.handle) break; } @@ -984,7 +984,7 @@ found: /* work out if we are going to keep the search state */ if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) || ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); } @@ -995,10 +995,10 @@ found: static NTSTATUS cifspsx_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct search_state *search; - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->findclose.in.handle) break; } @@ -1007,7 +1007,7 @@ static NTSTATUS cifspsx_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); return NT_STATUS_OK; diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index cfbb88f90e..12fe7015a7 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -107,9 +107,9 @@ NTSTATUS odb_open_file(struct odb_lock *lck, /* register a pending open file in the open files database */ -NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private) +NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private_data) { - return ops->odb_open_file_pending(lck, private); + return ops->odb_open_file_pending(lck, private_data); } @@ -126,9 +126,9 @@ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle, /* remove a pending opendb entry */ -NTSTATUS odb_remove_pending(struct odb_lock *lck, void *private) +NTSTATUS odb_remove_pending(struct odb_lock *lck, void *private_data) { - return ops->odb_remove_pending(lck, private); + return ops->odb_remove_pending(lck, private_data); } diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index 179db111ca..446df1777f 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -30,10 +30,10 @@ struct opendb_ops { int *fd, NTTIME open_write_time, bool allow_level_II_oplock, uint32_t oplock_level, uint32_t *oplock_granted); - NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private); + NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private_data); NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle, const char **delete_path); - NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private); + NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private_data); NTSTATUS (*odb_rename)(struct odb_lock *lck, const char *path); NTSTATUS (*odb_get_path)(struct odb_lock *lck, const char **path); NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close); diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 83da122fe2..8f5d10f902 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -548,7 +548,7 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, /* register a pending open file in the open files database */ -static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private) +static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private_data) { struct odb_context *odb = lck->odb; @@ -562,7 +562,7 @@ static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private) NT_STATUS_HAVE_NO_MEMORY(lck->file.pending); lck->file.pending[lck->file.num_pending].server = odb->ntvfs_ctx->server_id; - lck->file.pending[lck->file.num_pending].notify_ptr = private; + lck->file.pending[lck->file.num_pending].notify_ptr = private_data; lck->file.num_pending++; @@ -710,7 +710,7 @@ static NTSTATUS odb_tdb_break_oplocks(struct odb_lock *lck) /* remove a pending opendb entry */ -static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private) +static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private_data) { struct odb_context *odb = lck->odb; int i; @@ -721,7 +721,7 @@ static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private) /* find the entry, and delete it */ for (i=0;i<lck->file.num_pending;i++) { - if (private == lck->file.pending[i].notify_ptr && + if (private_data == lck->file.pending[i].notify_ptr && cluster_id_equal(&odb->ntvfs_ctx->server_id, &lck->file.pending[i].server)) { if (i < lck->file.num_pending-1) { memmove(lck->file.pending+i, lck->file.pending+i+1, diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c index df065eb5e2..2bc07c3e7b 100644 --- a/source4/ntvfs/ipc/rap_server.c +++ b/source4/ntvfs/ipc/rap_server.c @@ -21,6 +21,7 @@ #include "includes.h" #include "param/share.h" #include "libcli/rap/rap.h" +#include "libcli/raw/interfaces.h" #include "librpc/gen_ndr/srvsvc.h" #include "rpc_server/common/common.h" #include "param/param.h" diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 5a63edcc3e..2f05a86dfa 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -44,7 +44,7 @@ struct ipc_private { /* a list of open pipes */ struct pipe_state { struct pipe_state *next, *prev; - struct ipc_private *private; + struct ipc_private *ipriv; const char *pipe_name; struct ntvfs_handle *handle; struct dcesrv_connection *dce_conn; @@ -56,12 +56,12 @@ struct ipc_private { /* find a open pipe give a file handle */ -static struct pipe_state *pipe_state_find(struct ipc_private *private, struct ntvfs_handle *handle) +static struct pipe_state *pipe_state_find(struct ipc_private *ipriv, struct ntvfs_handle *handle) { struct pipe_state *s; void *p; - p = ntvfs_handle_get_backend_data(handle, private->ntvfs); + p = ntvfs_handle_get_backend_data(handle, ipriv->ntvfs); if (!p) return NULL; s = talloc_get_type(p, struct pipe_state); @@ -73,14 +73,14 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, struct nt /* find a open pipe give a wire fnum */ -static struct pipe_state *pipe_state_find_key(struct ipc_private *private, struct ntvfs_request *req, const DATA_BLOB *key) +static struct pipe_state *pipe_state_find_key(struct ipc_private *ipriv, struct ntvfs_request *req, const DATA_BLOB *key) { struct ntvfs_handle *h; - h = ntvfs_handle_search_by_wire_key(private->ntvfs, req, key); + h = ntvfs_handle_search_by_wire_key(ipriv->ntvfs, req, key); if (!h) return NULL; - return pipe_state_find(private, h); + return pipe_state_find(ipriv, h); } @@ -91,7 +91,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct ipc_private *private; + struct ipc_private *ipriv; ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "IPC"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); @@ -100,16 +100,16 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); /* prepare the private state for this connection */ - private = talloc(ntvfs, struct ipc_private); - NT_STATUS_HAVE_NO_MEMORY(private); + ipriv = talloc(ntvfs, struct ipc_private); + NT_STATUS_HAVE_NO_MEMORY(ipriv); - ntvfs->private_data = private; + ntvfs->private_data = ipriv; - private->ntvfs = ntvfs; - private->pipe_list = NULL; + ipriv->ntvfs = ntvfs; + ipriv->pipe_list = NULL; /* setup the DCERPC server subsystem */ - status = dcesrv_init_ipc_context(private, ntvfs->ctx->lp_ctx, &private->dcesrv); + status = dcesrv_init_ipc_context(ipriv, ntvfs->ctx->lp_ctx, &ipriv->dcesrv); NT_STATUS_NOT_OK_RETURN(status); return NT_STATUS_OK; @@ -174,23 +174,23 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, */ static int ipc_fd_destructor(struct pipe_state *p) { - DLIST_REMOVE(p->private->pipe_list, p); - ntvfs_handle_remove_backend_data(p->handle, p->private->ntvfs); + DLIST_REMOVE(p->ipriv->pipe_list, p); + ntvfs_handle_remove_backend_data(p->handle, p->ipriv->ntvfs); return 0; } static struct socket_address *ipc_get_my_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx) { - struct ipc_private *private = dce_conn->transport.private_data; + struct ipc_private *ipriv = dce_conn->transport.private_data; - return ntvfs_get_my_addr(private->ntvfs, mem_ctx); + return ntvfs_get_my_addr(ipriv->ntvfs, mem_ctx); } static struct socket_address *ipc_get_peer_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx) { - struct ipc_private *private = dce_conn->transport.private_data; + struct ipc_private *ipriv = dce_conn->transport.private_data; - return ntvfs_get_peer_addr(private->ntvfs, mem_ctx); + return ntvfs_get_peer_addr(ipriv->ntvfs, mem_ctx); } /* @@ -203,7 +203,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, struct pipe_state *p; NTSTATUS status; struct dcerpc_binding *ep_description; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct ntvfs_handle *h; status = ntvfs_handle_new(ntvfs, req, &h); @@ -235,7 +235,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, /* The session info is refcount-increased in the * dcesrv_endpoint_search_connect() function */ - status = dcesrv_endpoint_search_connect(private->dcesrv, + status = dcesrv_endpoint_search_connect(ipriv->dcesrv, p, ep_description, h->session_info, @@ -246,18 +246,18 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, &p->dce_conn); NT_STATUS_NOT_OK_RETURN(status); - p->dce_conn->transport.private_data = private; + p->dce_conn->transport.private_data = ipriv; p->dce_conn->transport.report_output_data = NULL; p->dce_conn->transport.get_my_addr = ipc_get_my_addr; p->dce_conn->transport.get_peer_addr = ipc_get_peer_addr; - DLIST_ADD(private->pipe_list, p); + DLIST_ADD(ipriv->pipe_list, p); - p->private = private; + p->ipriv = ipriv; talloc_set_destructor(p, ipc_fd_destructor); - status = ntvfs_handle_set_backend_data(h, private->ntvfs, p); + status = ntvfs_handle_set_backend_data(h, ipriv->ntvfs, p); NT_STATUS_NOT_OK_RETURN(status); *ps = p; @@ -417,7 +417,7 @@ static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; DATA_BLOB data; struct pipe_state *p; NTSTATUS status = NT_STATUS_OK; @@ -426,7 +426,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, return ntvfs_map_read(ntvfs, req, rd); } - p = pipe_state_find(private, rd->readx.in.file.ntvfs); + p = pipe_state_find(ipriv, rd->readx.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -457,7 +457,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; DATA_BLOB data; struct pipe_state *p; NTSTATUS status; @@ -469,7 +469,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; - p = pipe_state_find(private, wr->writex.in.file.ntvfs); + p = pipe_state_find(ipriv, wr->writex.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -511,14 +511,14 @@ static NTSTATUS ipc_flush(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { return ntvfs_map_close(ntvfs, req, io); } - p = pipe_state_find(private, io->close.in.file.ntvfs); + p = pipe_state_find(ipriv, io->close.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -534,10 +534,10 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p, *next; - for (p=private->pipe_list; p; p=next) { + for (p=ipriv->pipe_list; p; p=next) { next = p->next; if (p->handle->session_info == req->session_info && p->handle->smbpid == req->smbpid) { @@ -554,10 +554,10 @@ static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p, *next; - for (p=private->pipe_list; p; p=next) { + for (p=ipriv->pipe_list; p; p=next) { next = p->next; if (p->handle->session_info == req->session_info) { talloc_free(p); @@ -572,7 +572,7 @@ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS ipc_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -610,8 +610,8 @@ static NTSTATUS ipc_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct ipc_private *private = ntvfs->private_data; - struct pipe_state *p = pipe_state_find(private, info->generic.in.file.ntvfs); + struct ipc_private *ipriv = ntvfs->private_data; + struct pipe_state *p = pipe_state_find(ipriv, info->generic.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -717,7 +717,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; NTSTATUS status; DATA_BLOB fnum_key; uint16_t fnum; @@ -731,7 +731,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, SSVAL(&fnum, 0, trans->in.setup[1]); fnum_key = data_blob_const(&fnum, 2); - p = pipe_state_find_key(private, req, &fnum_key); + p = pipe_state_find_key(ipriv, req, &fnum_key); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -772,14 +772,14 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_trans2 *trans) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p; DATA_BLOB fnum_key; /* the fnum is in setup[1] */ fnum_key = data_blob_const(&trans->in.setup[1], sizeof(trans->in.setup[1])); - p = pipe_state_find_key(private, req, &fnum_key); + p = pipe_state_find_key(ipriv, req, &fnum_key); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -830,7 +830,7 @@ static NTSTATUS ipc_ioctl_smb2(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_ioctl *io) { struct pipe_state *p; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; NTSTATUS status; switch (io->smb2.in.function) { @@ -841,7 +841,7 @@ static NTSTATUS ipc_ioctl_smb2(struct ntvfs_module_context *ntvfs, return NT_STATUS_FS_DRIVER_REQUIRED; } - p = pipe_state_find(private, io->smb2.in.file.ntvfs); + p = pipe_state_find(ipriv, io->smb2.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index 987227a0b7..7ba2e7c649 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -41,7 +41,7 @@ static void nbench_log(struct ntvfs_request *req, static void nbench_log(struct ntvfs_request *req, const char *format, ...) { - struct nbench_private *private = req->async_states->ntvfs->private_data; + struct nbench_private *nprivates = req->async_states->ntvfs->private_data; va_list ap; char *s = NULL; @@ -49,7 +49,7 @@ static void nbench_log(struct ntvfs_request *req, vasprintf(&s, format, ap); va_end(ap); - write(private->log_fd, s, strlen(s)); + write(nprivates->log_fd, s, strlen(s)); free(s); } @@ -671,11 +671,11 @@ static void nbench_async_setup_send(struct ntvfs_request *req) */ static NTSTATUS nbench_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, async_setup, NULL, (ntvfs, req, private)); + PASS_THRU_REQ(ntvfs, req, async_setup, NULL, (ntvfs, req, private_data)); return status; } diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index 5e86030efa..b62595967f 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -55,7 +55,7 @@ struct ntvfs_ops { /* async_setup - called when a backend is processing a async request */ NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private); + void *private_data); /* filesystem operations */ NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs, @@ -94,12 +94,12 @@ struct ntvfs_ops { /* directory search */ NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_first *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)); + union smb_search_first *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)); NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_next *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)); + union smb_search_next *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)); NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io); diff --git a/source4/ntvfs/ntvfs_interface.c b/source4/ntvfs/ntvfs_interface.c index c348558fca..6d3fe55c06 100644 --- a/source4/ntvfs/ntvfs_interface.c +++ b/source4/ntvfs/ntvfs_interface.c @@ -46,13 +46,13 @@ NTSTATUS ntvfs_disconnect(struct ntvfs_context *ntvfs_ctx) /* async setup - called by a backend that wants to setup any state for a async request */ -NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private) +NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private_data) { struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->async_setup) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->ops->async_setup(ntvfs, req, private); + return ntvfs->ops->async_setup(ntvfs, req, private_data); } /* filesystem operations */ @@ -148,24 +148,24 @@ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp) } /* directory search */ -NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private, - bool ntvfs_callback(void *private, const union smb_search_data *file)) +NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private_data, + bool ntvfs_callback(void *private_data, const union smb_search_data *file)) { struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_first) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->ops->search_first(ntvfs, req, io, private, ntvfs_callback); + return ntvfs->ops->search_first(ntvfs, req, io, private_data, ntvfs_callback); } -NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private, - bool ntvfs_callback(void *private, const union smb_search_data *file)) +NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private_data, + bool ntvfs_callback(void *private_data, const union smb_search_data *file)) { struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_next) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->ops->search_next(ntvfs, req, io, private, ntvfs_callback); + return ntvfs->ops->search_next(ntvfs, req, io, private_data, ntvfs_callback); } NTSTATUS ntvfs_search_close(struct ntvfs_request *req, union smb_search_close *io) @@ -354,12 +354,12 @@ NTSTATUS ntvfs_next_disconnect(struct ntvfs_module_context *ntvfs) /* async_setup - called when setting up for a async request */ NTSTATUS ntvfs_next_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { if (!ntvfs->next || !ntvfs->next->ops->async_setup) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->next->ops->async_setup(ntvfs->next, req, private); + return ntvfs->next->ops->async_setup(ntvfs->next, req, private_data); } /* filesystem operations */ @@ -468,24 +468,24 @@ NTSTATUS ntvfs_next_open(struct ntvfs_module_context *ntvfs, /* directory search */ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_first *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)) + union smb_search_first *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)) { if (!ntvfs->next || !ntvfs->next->ops->search_first) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->next->ops->search_first(ntvfs->next, req, io, private, callback); + return ntvfs->next->ops->search_first(ntvfs->next, req, io, private_data, callback); } NTSTATUS ntvfs_next_search_next(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_next *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)) + union smb_search_next *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)) { if (!ntvfs->next || !ntvfs->next->ops->search_next) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->next->ops->search_next(ntvfs->next, req, io, private, callback); + return ntvfs->next->ops->search_next(ntvfs->next, req, io, private_data, callback); } NTSTATUS ntvfs_next_search_close(struct ntvfs_module_context *ntvfs, diff --git a/source4/ntvfs/posix/pvfs_aio.c b/source4/ntvfs/posix/pvfs_aio.c index 7a090e214a..56566e3592 100644 --- a/source4/ntvfs/posix/pvfs_aio.c +++ b/source4/ntvfs/posix/pvfs_aio.c @@ -42,9 +42,9 @@ struct pvfs_aio_write_state { called when an aio read has finished */ static void pvfs_aio_read_handler(struct tevent_context *ev, struct tevent_aio *ae, - int ret, void *private) + int ret, void *private_data) { - struct pvfs_aio_read_state *state = talloc_get_type(private, + struct pvfs_aio_read_state *state = talloc_get_type(private_data, struct pvfs_aio_read_state); struct pvfs_file *f = state->f; union smb_read *rd = state->rd; @@ -107,9 +107,9 @@ NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd, called when an aio write has finished */ static void pvfs_aio_write_handler(struct tevent_context *ev, struct tevent_aio *ae, - int ret, void *private) + int ret, void *private_data) { - struct pvfs_aio_write_state *state = talloc_get_type(private, + struct pvfs_aio_write_state *state = talloc_get_type(private_data, struct pvfs_aio_write_state); struct pvfs_file *f = state->f; union smb_write *wr = state->wr; diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c index 173b2fe187..2353baeff4 100644 --- a/source4/ntvfs/posix/pvfs_lock.c +++ b/source4/ntvfs/posix/pvfs_lock.c @@ -88,9 +88,9 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs, range, so we should try the lock again. Note that on timeout we do retry the lock, giving it a last chance. */ -static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reason) +static void pvfs_pending_lock_continue(void *private_data, enum pvfs_wait_notice reason) { - struct pvfs_pending_lock *pending = private; + struct pvfs_pending_lock *pending = private_data; struct pvfs_state *pvfs = pending->pvfs; struct pvfs_file *f = pending->f; struct ntvfs_request *req = pending->req; diff --git a/source4/ntvfs/posix/pvfs_notify.c b/source4/ntvfs/posix/pvfs_notify.c index 8224d36b7d..09aa0f64e6 100644 --- a/source4/ntvfs/posix/pvfs_notify.c +++ b/source4/ntvfs/posix/pvfs_notify.c @@ -126,9 +126,9 @@ static int pvfs_notify_destructor(struct pvfs_notify_buffer *n) /* called when a async notify event comes in */ -static void pvfs_notify_callback(void *private, const struct notify_event *ev) +static void pvfs_notify_callback(void *private_data, const struct notify_event *ev) { - struct pvfs_notify_buffer *n = talloc_get_type(private, struct pvfs_notify_buffer); + struct pvfs_notify_buffer *n = talloc_get_type(private_data, struct pvfs_notify_buffer); size_t len; struct notify_changes *n2; char *new_path; @@ -201,9 +201,9 @@ static NTSTATUS pvfs_notify_setup(struct pvfs_state *pvfs, struct pvfs_file *f, called from the pvfs_wait code when either an event has come in, or the notify request has been cancelled */ -static void pvfs_notify_end(void *private, enum pvfs_wait_notice reason) +static void pvfs_notify_end(void *private_data, enum pvfs_wait_notice reason) { - struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private, + struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private_data, struct pvfs_notify_buffer); if (reason == PVFS_WAIT_CANCEL) { pvfs_notify_send(notify_buffer, NT_STATUS_CANCELLED, false); diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 601c876cfb..6b0f32e65a 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -28,7 +28,6 @@ #include "librpc/gen_ndr/security.h" #include "../tdb/include/tdb.h" #include "tdb_wrap.h" -#include "../lib/util/util_ldb.h" #include "libcli/security/security.h" #include "lib/events/events.h" #include "param/param.h" diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index 342d28325e..b032ab3f93 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -27,7 +27,7 @@ #include "ntvfs/ntvfs.h" #include "ntvfs/common/ntvfs_common.h" #include "libcli/wbclient/wbclient.h" -#include "dsdb/samdb/samdb.h" +#include "lib/events/events.h" struct pvfs_wait; struct pvfs_oplock; diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c index a0cdbe9c39..f7f011572a 100644 --- a/source4/ntvfs/simple/svfs_util.c +++ b/source4/ntvfs/simple/svfs_util.c @@ -36,17 +36,17 @@ char *svfs_unix_path(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *name) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; char *ret; if (*name != '\\') { - ret = talloc_asprintf(req, "%s/%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s/%s", p->connectpath, name); } else { - ret = talloc_asprintf(req, "%s%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s%s", p->connectpath, name); } all_string_sub(ret, "\\", "/", 0); - strlower(ret + strlen(private->connectpath)); + strlower(ret + strlen(p->connectpath)); return ret; } @@ -142,13 +142,13 @@ struct svfs_dir *svfs_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request *req, */ struct svfs_dir *svfs_list(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *pattern) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; char *unix_path; unix_path = svfs_unix_path(ntvfs, req, pattern); if (!unix_path) { return NULL; } - return svfs_list_unix(private, req, unix_path); + return svfs_list_unix(p, req, unix_path); } diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index 5d904b4fcb..bf0afcec0a 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -50,21 +50,21 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct stat st; - struct svfs_private *private; + struct svfs_private *p; struct share_config *scfg = ntvfs->ctx->config; - private = talloc(ntvfs, struct svfs_private); - NT_STATUS_HAVE_NO_MEMORY(private); - private->ntvfs = ntvfs; - private->next_search_handle = 0; - private->connectpath = talloc_strdup(private, share_string_option(scfg, SHARE_PATH, "")); - private->open_files = NULL; - private->search = NULL; + p = talloc(ntvfs, struct svfs_private); + NT_STATUS_HAVE_NO_MEMORY(p); + p->ntvfs = ntvfs; + p->next_search_handle = 0; + p->connectpath = talloc_strdup(p, share_string_option(scfg, SHARE_PATH, "")); + p->open_files = NULL; + p->search = NULL; /* the directory must exist */ - if (stat(private->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { + if (stat(p->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { DEBUG(0,("'%s' is not a directory, when connecting to [%s]\n", - private->connectpath, sharename)); + p->connectpath, sharename)); return NT_STATUS_BAD_NETWORK_NAME; } @@ -73,7 +73,7 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); - ntvfs->private_data = private; + ntvfs->private_data = p; return NT_STATUS_OK; } @@ -89,12 +89,12 @@ static NTSTATUS svfs_disconnect(struct ntvfs_module_context *ntvfs) /* find open file handle given fd */ -static struct svfs_file *find_fd(struct svfs_private *private, struct ntvfs_handle *handle) +static struct svfs_file *find_fd(struct svfs_private *sp, struct ntvfs_handle *handle) { struct svfs_file *f; void *p; - p = ntvfs_handle_get_backend_data(handle, private->ntvfs); + p = ntvfs_handle_get_backend_data(handle, sp->ntvfs); if (!p) return NULL; f = talloc_get_type(p, struct svfs_file); @@ -275,7 +275,7 @@ static NTSTATUS svfs_qpathinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; struct stat st; @@ -283,7 +283,7 @@ static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs, return ntvfs_map_qfileinfo(ntvfs, req, info); } - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -302,7 +302,7 @@ static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; char *unix_path; struct stat st; int fd, flags; @@ -391,7 +391,7 @@ do_open: f->name = talloc_strdup(f, unix_path); NT_STATUS_HAVE_NO_MEMORY(f->name); - DLIST_ADD(private->open_files, f); + DLIST_ADD(p->open_files, f); status = ntvfs_handle_set_backend_data(handle, ntvfs, f); NT_STATUS_NOT_OK_RETURN(status); @@ -492,7 +492,7 @@ static NTSTATUS svfs_copy(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; ssize_t ret; @@ -500,7 +500,7 @@ static NTSTATUS svfs_read(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - f = find_fd(private, rd->readx.in.file.ntvfs); + f = find_fd(p, rd->readx.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -526,7 +526,7 @@ static NTSTATUS svfs_read(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; ssize_t ret; @@ -536,7 +536,7 @@ static NTSTATUS svfs_write(struct ntvfs_module_context *ntvfs, CHECK_READ_ONLY(req); - f = find_fd(private, wr->writex.in.file.ntvfs); + f = find_fd(p, wr->writex.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -572,14 +572,14 @@ static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; switch (io->generic.level) { case RAW_FLUSH_FLUSH: case RAW_FLUSH_SMB2: /* ignore the additional unknown option in SMB2 */ - f = find_fd(private, io->generic.in.file.ntvfs); + f = find_fd(p, io->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -587,7 +587,7 @@ static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; case RAW_FLUSH_ALL: - for (f=private->open_files;f;f=f->next) { + for (f=p->open_files;f;f=f->next) { fsync(f->fd); } return NT_STATUS_OK; @@ -603,7 +603,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -611,7 +611,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; } - f = find_fd(private, io->close.in.file.ntvfs); + f = find_fd(p, io->close.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -620,7 +620,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, return map_nt_error_from_unix(errno); } - DLIST_REMOVE(private->open_files, f); + DLIST_REMOVE(p->open_files, f); talloc_free(f->name); talloc_free(f); @@ -650,7 +650,7 @@ static NTSTATUS svfs_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS svfs_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -691,13 +691,13 @@ static NTSTATUS svfs_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *info) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; struct utimbuf unix_times; CHECK_READ_ONLY(req); - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -743,14 +743,14 @@ static NTSTATUS svfs_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct stat st; if (fs->generic.level != RAW_QFS_GENERIC) { return ntvfs_map_fsinfo(ntvfs, req, fs); } - if (sys_fsusage(private->connectpath, + if (sys_fsusage(p->connectpath, &fs->generic.out.blocks_free, &fs->generic.out.blocks_total) == -1) { return map_nt_error_from_unix(errno); @@ -758,7 +758,7 @@ static NTSTATUS svfs_fsinfo(struct ntvfs_module_context *ntvfs, fs->generic.out.block_size = 512; - if (stat(private->connectpath, &st) != 0) { + if (stat(p->connectpath, &st) != 0) { return NT_STATUS_DISK_CORRUPT_ERROR; } @@ -786,13 +786,13 @@ static NTSTATUS svfs_fsattr(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsattr *fs) { struct stat st; - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; if (fs->generic.level != RAW_FSATTR_GENERIC) { return ntvfs_map_fsattr(ntvfs, req, fs); } - if (stat(private->connectpath, &st) == -1) { + if (stat(p->connectpath, &st) == -1) { return map_nt_error_from_unix(errno); } @@ -830,7 +830,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, { struct svfs_dir *dir; int i; - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -843,7 +843,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - search = talloc_zero(private, struct search_state); + search = talloc_zero(p, struct search_state); if (!search) { return NT_STATUS_NO_MEMORY; } @@ -855,7 +855,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - search->handle = private->next_search_handle; + search->handle = p->next_search_handle; search->dir = dir; if (dir->count < max_count) { @@ -889,8 +889,8 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { talloc_free(search); } else { - private->next_search_handle++; - DLIST_ADD(private->search, search); + p->next_search_handle++; + DLIST_ADD(p->search, search); } return NT_STATUS_OK; @@ -904,7 +904,7 @@ static NTSTATUS svfs_search_next(struct ntvfs_module_context *ntvfs, { struct svfs_dir *dir; int i; - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -917,7 +917,7 @@ static NTSTATUS svfs_search_next(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->t2fnext.in.handle) break; } @@ -981,7 +981,7 @@ found: /* work out if we are going to keep the search state */ if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) || ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); } @@ -992,10 +992,10 @@ found: static NTSTATUS svfs_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct search_state *search; - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->findclose.in.handle) break; } @@ -1004,7 +1004,7 @@ static NTSTATUS svfs_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); return NT_STATUS_OK; diff --git a/source4/ntvfs/smb2/vfs_smb2.c b/source4/ntvfs/smb2/vfs_smb2.c index ebb17e2806..d1e194f638 100644 --- a/source4/ntvfs/smb2/vfs_smb2.c +++ b/source4/ntvfs/smb2/vfs_smb2.c @@ -100,12 +100,12 @@ struct async_info { */ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private) { - struct cvfs_private *private = p_private; + struct cvfs_private *p = p_private; NTSTATUS status; struct ntvfs_handle *h = NULL; struct cvfs_file *f; - for (f=private->files; f; f=f->next) { + for (f=p->files; f; f=f->next) { if (f->fnum != fnum) continue; h = f->h; break; @@ -117,7 +117,7 @@ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin } DEBUG(5,("vfs_smb2: sending oplock break level %d for fnum %d\n", level, fnum)); - status = ntvfs_send_oplock_break(private->ntvfs, h, level); + status = ntvfs_send_oplock_break(p->ntvfs, h, level); if (!NT_STATUS_IS_OK(status)) return false; return true; } @@ -157,7 +157,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct cvfs_private *private; + struct cvfs_private *p; const char *host, *user, *pass, *domain, *remote_share; struct composite_context *creq; struct share_config *scfg = ntvfs->ctx->config; @@ -181,12 +181,12 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, machine_account = share_bool_option(scfg, SMB2_USE_MACHINE_ACCT, SMB2_USE_MACHINE_ACCT_DEFAULT); - private = talloc_zero(ntvfs, struct cvfs_private); - if (!private) { + p = talloc_zero(ntvfs, struct cvfs_private); + if (!p) { return NT_STATUS_NO_MEMORY; } - ntvfs->private_data = private; + ntvfs->private_data = p; if (!host) { DEBUG(1,("CIFS backend: You must supply server\n")); @@ -195,7 +195,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, if (user && pass) { DEBUG(5, ("CIFS backend: Using specified password\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); if (!credentials) { return NT_STATUS_NO_MEMORY; } @@ -207,7 +207,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, cli_credentials_set_password(credentials, pass, CRED_SPECIFIED); } else if (machine_account) { DEBUG(5, ("CIFS backend: Using machine account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); if (domain) { cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); @@ -226,25 +226,25 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, lp_smbcli_options(ntvfs->ctx->lp_ctx, &options); - creq = smb2_connect_send(private, host, - lp_parm_string_list(private, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL), + creq = smb2_connect_send(p, host, + lp_parm_string_list(p, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL), remote_share, lp_resolve_context(ntvfs->ctx->lp_ctx), credentials, ntvfs->ctx->event_ctx, &options, lp_socket_options(ntvfs->ctx->lp_ctx), - lp_gensec_settings(private, ntvfs->ctx->lp_ctx) + lp_gensec_settings(p, ntvfs->ctx->lp_ctx) ); - status = smb2_connect_recv(creq, private, &tree); + status = smb2_connect_recv(creq, p, &tree); NT_STATUS_NOT_OK_RETURN(status); - status = smb2_get_roothandle(tree, &private->roothandle); + status = smb2_get_roothandle(tree, &p->roothandle); NT_STATUS_NOT_OK_RETURN(status); - private->tree = tree; - private->transport = private->tree->session->transport; - private->ntvfs = ntvfs; + p->tree = tree; + p->transport = p->tree->session->transport; + p->ntvfs = ntvfs; ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); @@ -253,7 +253,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, /* we need to receive oplock break requests from the server */ /* TODO: enable oplocks - smbcli_oplock_handler(private->transport, oplock_handler, private); + smbcli_oplock_handler(p->transport, oplock_handler, p); */ return NT_STATUS_OK; } @@ -263,17 +263,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct async_info *a, *an; /* first cleanup pending requests */ - for (a=private->pending; a; a = an) { + for (a=p->pending; a; a = an) { an = a->next; talloc_free(a->c_req); talloc_free(a); } - talloc_free(private); + talloc_free(p); ntvfs->private_data = NULL; return NT_STATUS_OK; @@ -330,9 +330,9 @@ static void async_simple_composite(struct composite_context *c_req) async->parms = io; \ async->req = req; \ async->f = file; \ - async->cvfs = private; \ + async->cvfs = p; \ async->c_req = c_req; \ - DLIST_ADD(private->pending, async); \ + DLIST_ADD(p->pending, async); \ c_req->async.private_data = async; \ talloc_set_destructor(async, async_info_destructor); \ } \ @@ -364,12 +364,12 @@ static void async_simple_composite(struct composite_context *c_req) static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_unlink *unl) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct composite_context *c_req; CHECK_ASYNC(req); - c_req = smb2_composite_unlink_send(private->tree, unl); + c_req = smb2_composite_unlink_send(p->tree, unl); SIMPLE_COMPOSITE_TAIL; } @@ -389,7 +389,7 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_chkpath *cp) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smb2_request *c_req; struct smb2_find f; @@ -400,7 +400,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, find call, using the roothandle we established at connect time */ ZERO_STRUCT(f); - f.in.file.handle = private->roothandle; + f.in.file.handle = p->roothandle; f.in.level = SMB2_FIND_DIRECTORY_INFO; f.in.pattern = cp->chkpath.in.path; /* SMB2 find doesn't accept \ or the empty string - this is the best @@ -412,7 +412,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, f.in.continue_flags = SMB2_CONTINUE_FLAG_SINGLE | SMB2_CONTINUE_FLAG_RESTART; f.in.max_response_size = 0x1000; - c_req = smb2_find_send(private->tree, &f); + c_req = smb2_find_send(p->tree, &f); SIMPLE_ASYNC_TAIL; } @@ -461,12 +461,12 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_mkdir *md) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct composite_context *c_req; CHECK_ASYNC(req); - c_req = smb2_composite_mkdir_send(private->tree, md); + c_req = smb2_composite_mkdir_send(p->tree, md); SIMPLE_COMPOSITE_TAIL; } @@ -477,12 +477,12 @@ static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_rmdir *rd) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct composite_context *c_req; CHECK_ASYNC(req); - c_req = smb2_composite_rmdir_send(private->tree, rd); + c_req = smb2_composite_rmdir_send(p->tree, rd); SIMPLE_COMPOSITE_TAIL; } @@ -576,7 +576,7 @@ static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -628,7 +628,7 @@ static void async_fsinfo(struct smb2_request *c_req) static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smb2_request *c_req; enum smb_fsinfo_level level = fs->generic.level; @@ -667,9 +667,9 @@ static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, } fs->generic.level = level; - fs->generic.handle = private->roothandle; + fs->generic.handle = p->roothandle; - c_req = smb2_getinfo_fs_send(private->tree, fs); + c_req = smb2_getinfo_fs_send(p->tree, fs); ASYNC_RECV_TAIL(fs, async_fsinfo); } @@ -691,7 +691,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smb2_find f; enum smb_search_data_level smb2_level; uint_t count, i; @@ -733,7 +733,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, distinguish multiple searches happening at once */ ZERO_STRUCT(f); - f.in.file.handle = private->roothandle; + f.in.file.handle = p->roothandle; f.in.level = smb2_level; f.in.pattern = io->t2ffirst.in.pattern; while (f.in.pattern[0] == '\\') { @@ -742,7 +742,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, f.in.continue_flags = 0; f.in.max_response_size = 0x10000; - status = smb2_find_level(private->tree, req, &f, &count, &data); + status = smb2_find_level(p->tree, req, &f, &count, &data); NT_STATUS_NOT_OK_RETURN(status); for (i=0;i<count;i++) { diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c index 448d610819..db22a85492 100644 --- a/source4/ntvfs/unixuid/vfs_unixuid.c +++ b/source4/ntvfs/unixuid/vfs_unixuid.c @@ -170,7 +170,7 @@ static NTSTATUS nt_token_to_unix_security(struct ntvfs_module_context *ntvfs, static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct unix_sec_ctx **sec) { - struct unixuid_private *private = ntvfs->private_data; + struct unixuid_private *priv = ntvfs->private_data; struct security_token *token; struct unix_sec_ctx *newsec; NTSTATUS status; @@ -186,20 +186,20 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - if (token == private->last_token) { - newsec = private->last_sec_ctx; + if (token == priv->last_token) { + newsec = priv->last_sec_ctx; } else { status = nt_token_to_unix_security(ntvfs, req, token, &newsec); if (!NT_STATUS_IS_OK(status)) { talloc_free(*sec); return status; } - if (private->last_sec_ctx) { - talloc_free(private->last_sec_ctx); + if (priv->last_sec_ctx) { + talloc_free(priv->last_sec_ctx); } - private->last_sec_ctx = newsec; - private->last_token = token; - talloc_steal(private, newsec); + priv->last_sec_ctx = newsec; + priv->last_token = token; + talloc_steal(priv, newsec); } status = set_unix_security(newsec); @@ -233,24 +233,24 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct unixuid_private *private; + struct unixuid_private *priv; NTSTATUS status; - private = talloc(ntvfs, struct unixuid_private); - if (!private) { + priv = talloc(ntvfs, struct unixuid_private); + if (!priv) { return NT_STATUS_NO_MEMORY; } - private->wbc_ctx = wbc_init(private, ntvfs->ctx->msg_ctx, + priv->wbc_ctx = wbc_init(priv, ntvfs->ctx->msg_ctx, ntvfs->ctx->event_ctx); - if (private->wbc_ctx == NULL) { - talloc_free(private); + if (priv->wbc_ctx == NULL) { + talloc_free(priv); return NT_STATUS_INTERNAL_ERROR; } - ntvfs->private_data = private; - private->last_sec_ctx = NULL; - private->last_token = NULL; + ntvfs->private_data = priv; + priv->last_sec_ctx = NULL; + priv->last_token = NULL; /* we don't use PASS_THRU_REQ here, as the connect operation runs with root privileges. This allows the backends to setup any database @@ -265,10 +265,10 @@ static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs, */ static NTSTATUS unixuid_disconnect(struct ntvfs_module_context *ntvfs) { - struct unixuid_private *private = ntvfs->private_data; + struct unixuid_private *priv = ntvfs->private_data; NTSTATUS status; - talloc_free(private); + talloc_free(priv); ntvfs->private_data = NULL; status = ntvfs_next_disconnect(ntvfs); @@ -509,12 +509,12 @@ static NTSTATUS unixuid_exit(struct ntvfs_module_context *ntvfs, static NTSTATUS unixuid_logoff(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct unixuid_private *private = ntvfs->private_data; + struct unixuid_private *priv = ntvfs->private_data; NTSTATUS status; PASS_THRU_REQ(ntvfs, req, logoff, (ntvfs, req)); - private->last_token = NULL; + priv->last_token = NULL; return status; } @@ -524,11 +524,11 @@ static NTSTATUS unixuid_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS unixuid_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, async_setup, (ntvfs, req, private)); + PASS_THRU_REQ(ntvfs, req, async_setup, (ntvfs, req, private_data)); return status; } diff --git a/source4/param/config.mk b/source4/param/config.mk index b60d39299c..d420a3883c 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -13,7 +13,7 @@ PUBLIC_HEADERS += param/param.h PC_FILES += $(paramsrcdir)/samba-hostconfig.pc [SUBSYSTEM::PROVISION] -PRIVATE_DEPENDENCIES = LIBPYTHON swig_ldb +PRIVATE_DEPENDENCIES = LIBPYTHON pyldb PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o $(param_OBJ_FILES) @@ -62,5 +62,3 @@ LIBRARY_REALNAME = samba/param.$(SHLIBEXT) PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG PYTALLOC param_OBJ_FILES = $(paramsrcdir)/pyparam.o - -$(param_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 7c0d268868..0cd92c16f1 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1221,9 +1221,9 @@ void *lp_parm_ptr(struct loadparm_context *lp_ctx, struct loadparm_service *service, struct parm_struct *parm) { if (service == NULL) { - if (parm->class == P_LOCAL) + if (parm->pclass == P_LOCAL) return ((char *)lp_ctx->sDefault)+parm->offset; - else if (parm->class == P_GLOBAL) + else if (parm->pclass == P_GLOBAL) return ((char *)lp_ctx->globals)+parm->offset; else return NULL; } else { @@ -1264,7 +1264,7 @@ static void copy_service(struct loadparm_service *pserviceDest, bool not_added; for (i = 0; parm_table[i].label; i++) - if (parm_table[i].offset != -1 && parm_table[i].class == P_LOCAL && + if (parm_table[i].offset != -1 && parm_table[i].pclass == P_LOCAL && (bcopyall || pcopymapDest[i])) { void *src_ptr = ((char *)pserviceSource) + parm_table[i].offset; @@ -1743,7 +1743,7 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx, return true; } - if (parm_table[parmnum].class == P_GLOBAL) { + if (parm_table[parmnum].pclass == P_GLOBAL) { DEBUG(0, ("Global parameter %s found in service section!\n", pszParmName)); @@ -1758,7 +1758,7 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx, * entries with the same data pointer */ for (i = 0; parm_table[i].label; i++) if (parm_table[i].offset == parm_table[parmnum].offset && - parm_table[i].class == parm_table[parmnum].class) + parm_table[i].pclass == parm_table[parmnum].pclass) service->copymap[i] = false; return set_variable(service, parmnum, parm_ptr, pszParmName, @@ -2053,7 +2053,7 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, fprintf(f, "# Global parameters\n[global]\n"); for (i = 0; parm_table[i].label; i++) - if (parm_table[i].class == P_GLOBAL && + if (parm_table[i].pclass == P_GLOBAL && parm_table[i].offset != -1 && (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT)) @@ -2084,7 +2084,7 @@ static void dump_a_service(struct loadparm_service * pService, struct loadparm_s fprintf(f, "\n[%s]\n", pService->szService); for (i = 0; parm_table[i].label; i++) - if (parm_table[i].class == P_LOCAL && + if (parm_table[i].pclass == P_LOCAL && parm_table[i].offset != -1 && (*parm_table[i].label != '-') && (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { @@ -2157,7 +2157,7 @@ struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, struct loadparm_service *pService = lp_ctx->services[snum]; for (; parm_table[*i].label; (*i)++) { - if (parm_table[*i].class == P_LOCAL && + if (parm_table[*i].pclass == P_LOCAL && parm_table[*i].offset != -1 && (*parm_table[*i].label != '-') && ((*i) == 0 || @@ -2267,7 +2267,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) parm_table[i].offset != -1 && !(lp_ctx->flags[i] & FLAG_CMDLINE)) { char **r; - if (parm_table[i].class == P_LOCAL) { + if (parm_table[i].pclass == P_LOCAL) { r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset); } else { r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset); diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h index 47bce75cfb..454d3f8853 100644 --- a/source4/param/loadparm.h +++ b/source4/param/loadparm.h @@ -46,7 +46,7 @@ struct loadparm_context; struct parm_struct { const char *label; parm_type type; - parm_class class; + parm_class pclass; int offset; bool (*special)(struct loadparm_context *, const char *, char **); const struct enum_list *enum_list; diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 42775908ea..07f45d7cf6 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -77,7 +77,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha } parm = lp_parm_struct(param_name); - if (parm == NULL || parm->class == P_GLOBAL) { + if (parm == NULL || parm->pclass == P_GLOBAL) { return NULL; } parm_ptr = lp_parm_ptr(lp_ctx, service, parm); diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index f00c975cca..a7d03ca22d 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -3,6 +3,7 @@ ################################################ # Start SUBSYSTEM DCERPC_COMMON [SUBSYSTEM::DCERPC_COMMON] +PRIVATE_DEPENDENCIES = LIBLDB # # End SUBSYSTEM DCERPC_COMMON ################################################ diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index e4be2e3123..d7bd7601f7 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -603,7 +603,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) * it also matches samba3 */ context->assoc_group_id = SAMBA_ASSOC_GROUP; - context->private = NULL; + context->private_data = NULL; context->handles = NULL; DLIST_ADD(call->conn->contexts, context); call->context = context; @@ -767,7 +767,7 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_ context->iface = iface; context->context_id = context_id; context->assoc_group_id = SAMBA_ASSOC_GROUP; - context->private = NULL; + context->private_data = NULL; context->handles = NULL; DLIST_ADD(call->conn->contexts, context); call->context = context; diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h index 51ad546ab4..7e12a3840b 100644 --- a/source4/rpc_server/dcerpc_server.h +++ b/source4/rpc_server/dcerpc_server.h @@ -66,7 +66,7 @@ struct dcesrv_interface { NTSTATUS (*ndr_push)(struct dcesrv_call_state *, TALLOC_CTX *, struct ndr_push *, const void *); /* for any private use by the interface code */ - const void *private; + const void *private_data; }; enum dcesrv_call_list { @@ -162,7 +162,7 @@ struct dcesrv_connection_context { const struct dcesrv_interface *iface; /* private data for the interface implementation */ - void *private; + void *private_data; /* current rpc handles - this is really the wrong scope for them, but it will do for now */ diff --git a/source4/rpc_server/echo/rpc_echo.c b/source4/rpc_server/echo/rpc_echo.c index 7bb117477c..8bcee7d925 100644 --- a/source4/rpc_server/echo/rpc_echo.c +++ b/source4/rpc_server/echo/rpc_echo.c @@ -157,9 +157,9 @@ struct echo_TestSleep_private { }; static void echo_TestSleep_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct echo_TestSleep_private *p = talloc_get_type(private, + struct echo_TestSleep_private *p = talloc_get_type(private_data, struct echo_TestSleep_private); struct echo_TestSleep *r = p->r; NTSTATUS status; diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 6507c75ae2..1f1f6afa6d 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -1260,28 +1260,28 @@ static NTSTATUS dcesrv_lsa_DeleteTrustedDomain(struct dcesrv_call_state *dce_cal struct lsa_DeleteTrustedDomain *r) { NTSTATUS status; - struct lsa_OpenTrustedDomain open; - struct lsa_DeleteObject delete; + struct lsa_OpenTrustedDomain opn; + struct lsa_DeleteObject del; struct dcesrv_handle *h; - open.in.handle = r->in.handle; - open.in.sid = r->in.dom_sid; - open.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - open.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); - if (!open.out.trustdom_handle) { + opn.in.handle = r->in.handle; + opn.in.sid = r->in.dom_sid; + opn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + opn.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); + if (!opn.out.trustdom_handle) { return NT_STATUS_NO_MEMORY; } - status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &open); + status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &opn); if (!NT_STATUS_IS_OK(status)) { return status; } - DCESRV_PULL_HANDLE(h, open.out.trustdom_handle, DCESRV_HANDLE_ANY); + DCESRV_PULL_HANDLE(h, opn.out.trustdom_handle, DCESRV_HANDLE_ANY); talloc_steal(mem_ctx, h); - delete.in.handle = open.out.trustdom_handle; - delete.out.handle = open.out.trustdom_handle; - status = dcesrv_lsa_DeleteObject(dce_call, mem_ctx, &delete); + del.in.handle = opn.out.trustdom_handle; + del.out.handle = opn.out.trustdom_handle; + status = dcesrv_lsa_DeleteObject(dce_call, mem_ctx, &del); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -1407,26 +1407,27 @@ static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state struct lsa_QueryTrustedDomainInfoBySid *r) { NTSTATUS status; - struct lsa_OpenTrustedDomain open; + struct lsa_OpenTrustedDomain opn; struct lsa_QueryTrustedDomainInfo query; struct dcesrv_handle *h; - open.in.handle = r->in.handle; - open.in.sid = r->in.dom_sid; - open.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - open.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); - if (!open.out.trustdom_handle) { + + opn.in.handle = r->in.handle; + opn.in.sid = r->in.dom_sid; + opn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + opn.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); + if (!opn.out.trustdom_handle) { return NT_STATUS_NO_MEMORY; } - status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &open); + status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &opn); if (!NT_STATUS_IS_OK(status)) { return status; } /* Ensure this handle goes away at the end of this call */ - DCESRV_PULL_HANDLE(h, open.out.trustdom_handle, DCESRV_HANDLE_ANY); + DCESRV_PULL_HANDLE(h, opn.out.trustdom_handle, DCESRV_HANDLE_ANY); talloc_steal(mem_ctx, h); - query.in.trustdom_handle = open.out.trustdom_handle; + query.in.trustdom_handle = opn.out.trustdom_handle; query.in.level = r->in.level; query.out.info = r->out.info; status = dcesrv_lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query); @@ -1455,26 +1456,27 @@ static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state struct lsa_QueryTrustedDomainInfoByName *r) { NTSTATUS status; - struct lsa_OpenTrustedDomainByName open; + struct lsa_OpenTrustedDomainByName opn; struct lsa_QueryTrustedDomainInfo query; struct dcesrv_handle *h; - open.in.handle = r->in.handle; - open.in.name = *r->in.trusted_domain; - open.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - open.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); - if (!open.out.trustdom_handle) { + + opn.in.handle = r->in.handle; + opn.in.name = *r->in.trusted_domain; + opn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + opn.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); + if (!opn.out.trustdom_handle) { return NT_STATUS_NO_MEMORY; } - status = dcesrv_lsa_OpenTrustedDomainByName(dce_call, mem_ctx, &open); + status = dcesrv_lsa_OpenTrustedDomainByName(dce_call, mem_ctx, &opn); if (!NT_STATUS_IS_OK(status)) { return status; } /* Ensure this handle goes away at the end of this call */ - DCESRV_PULL_HANDLE(h, open.out.trustdom_handle, DCESRV_HANDLE_ANY); + DCESRV_PULL_HANDLE(h, opn.out.trustdom_handle, DCESRV_HANDLE_ANY); talloc_steal(mem_ctx, h); - query.in.trustdom_handle = open.out.trustdom_handle; + query.in.trustdom_handle = opn.out.trustdom_handle; query.in.level = r->in.level; query.out.info = r->out.info; status = dcesrv_lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query); diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index fc7fded63b..a9150d1a9a 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -47,7 +47,7 @@ struct server_pipe_state { static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_ServerReqChallenge *r) { - struct server_pipe_state *pipe_state = dce_call->context->private; + struct server_pipe_state *pipe_state = dce_call->context->private_data; ZERO_STRUCTP(r->out.return_credentials); @@ -55,7 +55,7 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal if (pipe_state) { talloc_free(pipe_state); - dce_call->context->private = NULL; + dce_call->context->private_data = NULL; } pipe_state = talloc(dce_call->context, struct server_pipe_state); @@ -68,7 +68,7 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal *r->out.return_credentials = pipe_state->server_challenge; - dce_call->context->private = pipe_state; + dce_call->context->private_data = pipe_state; return NT_STATUS_OK; } @@ -76,7 +76,7 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_ServerAuthenticate3 *r) { - struct server_pipe_state *pipe_state = dce_call->context->private; + struct server_pipe_state *pipe_state = dce_call->context->private_data; struct creds_CredentialState *creds; void *sam_ctx; struct samr_Password *mach_pwd; diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c index 1310ecee90..e20e87b326 100644 --- a/source4/rpc_server/remote/dcesrv_remote.c +++ b/source4/rpc_server/remote/dcesrv_remote.c @@ -39,7 +39,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct { NTSTATUS status; const struct ndr_interface_table *table; - struct dcesrv_remote_private *private; + struct dcesrv_remote_private *priv; const char *binding = lp_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "binding"); const char *user, *pass, *domain; struct cli_credentials *credentials; @@ -47,13 +47,13 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct machine_account = lp_parm_bool(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "use_machine_account", false); - private = talloc(dce_call->conn, struct dcesrv_remote_private); - if (!private) { + priv = talloc(dce_call->conn, struct dcesrv_remote_private); + if (!priv) { return NT_STATUS_NO_MEMORY; } - private->c_pipe = NULL; - dce_call->context->private = private; + priv->c_pipe = NULL; + dce_call->context->private_data = priv; if (!binding) { DEBUG(0,("You must specify a DCE/RPC binding string\n")); @@ -72,7 +72,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct if (user && pass) { DEBUG(5, ("dcerpc_remote: RPC Proxy: Using specified account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(priv); if (!credentials) { return NT_STATUS_NO_MEMORY; } @@ -84,7 +84,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct cli_credentials_set_password(credentials, pass, CRED_SPECIFIED); } else if (machine_account) { DEBUG(5, ("dcerpc_remote: RPC Proxy: Using machine account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(priv); cli_credentials_set_conf(credentials, dce_call->conn->dce_ctx->lp_ctx); if (domain) { cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); @@ -101,8 +101,8 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct return NT_STATUS_INVALID_PARAMETER; } - status = dcerpc_pipe_connect(private, - &(private->c_pipe), binding, table, + status = dcerpc_pipe_connect(priv, + &(priv->c_pipe), binding, table, credentials, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx); @@ -116,9 +116,9 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct static void remote_op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface) { - struct dcesrv_remote_private *private = (struct dcesrv_remote_private *)context->private; + struct dcesrv_remote_private *priv = (struct dcesrv_remote_private *)context->private_data; - talloc_free(private->c_pipe); + talloc_free(priv->c_pipe); return; } @@ -126,7 +126,7 @@ static void remote_op_unbind(struct dcesrv_connection_context *context, const st static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r) { enum ndr_err_code ndr_err; - const struct ndr_interface_table *table = (const struct ndr_interface_table *)dce_call->context->iface->private; + const struct ndr_interface_table *table = (const struct ndr_interface_table *)dce_call->context->iface->private_data; uint16_t opnum = dce_call->pkt.u.request.opnum; dce_call->fault_code = 0; @@ -156,32 +156,32 @@ static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) { - struct dcesrv_remote_private *private = dce_call->context->private; + struct dcesrv_remote_private *priv = dce_call->context->private_data; uint16_t opnum = dce_call->pkt.u.request.opnum; - const struct ndr_interface_table *table = dce_call->context->iface->private; + const struct ndr_interface_table *table = dce_call->context->iface->private_data; const struct ndr_interface_call *call; const char *name; name = table->calls[opnum].name; call = &table->calls[opnum]; - if (private->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_IN) { + if (priv->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_IN) { ndr_print_function_debug(call->ndr_print, name, NDR_IN | NDR_SET_VALUES, r); } - private->c_pipe->conn->flags |= DCERPC_NDR_REF_ALLOC; + priv->c_pipe->conn->flags |= DCERPC_NDR_REF_ALLOC; /* we didn't use the return code of this function as we only check the last_fault_code */ - dcerpc_ndr_request(private->c_pipe, NULL, table, opnum, mem_ctx,r); + dcerpc_ndr_request(priv->c_pipe, NULL, table, opnum, mem_ctx,r); - dce_call->fault_code = private->c_pipe->last_fault_code; + dce_call->fault_code = priv->c_pipe->last_fault_code; if (dce_call->fault_code != 0) { DEBUG(0,("dcesrv_remote: call[%s] failed with: %s!\n",name, dcerpc_errstr(mem_ctx, dce_call->fault_code))); return NT_STATUS_NET_WRITE_FAULT; } if ((dce_call->fault_code == 0) && - (private->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { + (priv->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { ndr_print_function_debug(call->ndr_print, name, NDR_OUT, r); } @@ -191,7 +191,7 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r) { enum ndr_err_code ndr_err; - const struct ndr_interface_table *table = dce_call->context->iface->private; + const struct ndr_interface_table *table = dce_call->context->iface->private_data; uint16_t opnum = dce_call->pkt.u.request.opnum; /* unravel the NDR for the packet */ @@ -207,7 +207,7 @@ static NTSTATUS remote_op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_register_one_iface(struct dcesrv_context *dce_ctx, const struct dcesrv_interface *iface) { int i; - const struct ndr_interface_table *table = iface->private; + const struct ndr_interface_table *table = iface->private_data; for (i=0;i<table->endpoints->count;i++) { NTSTATUS ret; @@ -268,7 +268,7 @@ static bool remote_fill_interface(struct dcesrv_interface *iface, const struct n iface->reply = remote_op_reply; iface->ndr_push = remote_op_ndr_push; - iface->private = if_tabl; + iface->private_data = if_tabl; return true; } diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c index ec10c748f0..5596944bd8 100644 --- a/source4/rpc_server/service_rpc.c +++ b/source4/rpc_server/service_rpc.c @@ -103,7 +103,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) { NTSTATUS status; struct dcesrv_socket_context *dcesrv_sock = - talloc_get_type(srv_conn->private, struct dcesrv_socket_context); + talloc_get_type(srv_conn->private_data, struct dcesrv_socket_context); struct dcesrv_connection *dcesrv_conn = NULL; if (!srv_conn->session_info) { @@ -144,7 +144,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) dcesrv_conn->auth_state.session_key = dcesrv_inherited_session_key; } - srv_conn->private = dcesrv_conn; + srv_conn->private_data = dcesrv_conn; irpc_add_name(srv_conn->msg_ctx, "rpc_server"); @@ -154,7 +154,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) static void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags) { NTSTATUS status; - struct dcesrv_connection *dce_conn = talloc_get_type(conn->private, struct dcesrv_connection); + struct dcesrv_connection *dce_conn = talloc_get_type(conn->private_data, struct dcesrv_connection); DATA_BLOB tmp_blob; size_t nread; @@ -200,7 +200,7 @@ static void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags) static void dcesrv_sock_send(struct stream_connection *conn, uint16_t flags) { - struct dcesrv_connection *dce_conn = talloc_get_type(conn->private, struct dcesrv_connection); + struct dcesrv_connection *dce_conn = talloc_get_type(conn->private_data, struct dcesrv_connection); NTSTATUS status; status = dcesrv_output(dce_conn, conn->socket, dcerpc_write_fn); diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index d041d79b3e..1317dba1a4 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -220,7 +220,7 @@ static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const st lp_ntptr_providor(dce_call->conn->dce_ctx->lp_ctx), &ntptr); NT_STATUS_NOT_OK_RETURN(status); - dce_call->context->private = ntptr; + dce_call->context->private_data = ntptr; return NT_STATUS_OK; } @@ -233,7 +233,7 @@ static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const st static WERROR dcesrv_spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinters *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -369,7 +369,7 @@ static WERROR dcesrv_spoolss_AddPrinterDriver(struct dcesrv_call_state *dce_call static WERROR dcesrv_spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDrivers *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -402,7 +402,7 @@ static WERROR dcesrv_spoolss_GetPrinterDriver(struct dcesrv_call_state *dce_call static WERROR dcesrv_spoolss_GetPrinterDriverDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverDirectory *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -796,7 +796,7 @@ static WERROR dcesrv_spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLO static WERROR dcesrv_spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -819,7 +819,7 @@ static WERROR dcesrv_spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLO static WERROR dcesrv_spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumMonitors *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -1228,7 +1228,7 @@ static WERROR dcesrv_spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX * static WERROR dcesrv_spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); struct ntptr_GenericHandle *handle; struct dcesrv_handle *h; const char *server; diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c index af758afc6f..a1d76ef811 100644 --- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c +++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c @@ -36,7 +36,7 @@ static NTSTATUS dcerpc_unixinfo_bind(struct dcesrv_call_state *dce_call, dce_call->event_ctx); NT_STATUS_HAVE_NO_MEMORY(wbc_ctx); - dce_call->context->private = wbc_ctx; + dce_call->context->private_data = wbc_ctx; return NT_STATUS_OK; } @@ -49,7 +49,7 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call, { NTSTATUS status; struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; @@ -82,7 +82,7 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call, struct unixinfo_UidToSid *r) { struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; @@ -124,7 +124,7 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call, { NTSTATUS status; struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; @@ -157,7 +157,7 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call, struct unixinfo_GidToSid *r) { struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c index aa94505041..6158730759 100644 --- a/source4/rpc_server/winreg/rpc_winreg.c +++ b/source4/rpc_server/winreg/rpc_winreg.c @@ -46,7 +46,7 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, return NT_STATUS_UNSUCCESSFUL; } - dce_call->context->private = ctx; + dce_call->context->private_data = ctx; return NT_STATUS_OK; } @@ -57,7 +57,7 @@ static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, uint32_t hkey, struct policy_handle **outh) { - struct registry_context *ctx = dce_call->context->private; + struct registry_context *ctx = dce_call->context->private_data; struct dcesrv_handle *h; WERROR result; diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index 4d33ed2219..ba624ee163 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -17,11 +17,11 @@ python_uuid_OBJ_FILES = $(pyscriptsrcdir)/uuidmodule.o [PYTHON::python_glue] LIBRARY_REALNAME = samba/glue.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS pyldb python_dcerpc_misc python_dcerpc_security swig_auth +PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS pyldb python_dcerpc_misc python_dcerpc_security pyauth python_glue_OBJ_FILES = $(pyscriptsrcdir)/pyglue.o -$(python_glue_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) -I$(ldbsrcdir) +$(python_glue_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir) _PY_FILES = $(shell find $(pyscriptsrcdir)/samba ../lib/subunit/python -name "*.py") diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index c5f7c5adb4..324532c22a 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -1,6 +1,7 @@ TEST_FORMAT = plain -SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(selftestdir)/selftest.pl --prefix=${selftest_prefix} \ +SELFTEST = $(LD_LIBPATH_OVERRIDE) PYTHON=$(PYTHON) \ + $(PERL) $(selftestdir)/selftest.pl --prefix=${selftest_prefix} \ --builddir=$(builddir) --srcdir=$(srcdir) \ --expected-failures=$(srcdir)/selftest/knownfail \ --format=$(TEST_FORMAT) \ diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 88b83631ba..36e3bbe364 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -54,18 +54,20 @@ plansmbtorturetest() { plantest "$modname" "$env" $cmdline } -samba4srcdir=. -samba4bindir=$samba4srcdir/bin +samba4srcdir="`dirname $0`/.." +samba4bindir="$BUILDDIR/bin" smb4torture="$samba4bindir/smbtorture${EXEEXT}" $smb4torture -V +bbdir=../testprogs/blackbox + prefix_abs="$SELFTEST_PREFIX/s4client" +CONFIGURATION="--configfile=\$SMB_CONF_PATH" test -d "$prefix_abs" || mkdir "$prefix_abs" -conffile="$SELFTEST_CONFFILE" TORTURE_OPTIONS="" -TORTURE_OPTIONS="$TORTURE_OPTIONS --configfile=$conffile" +TORTURE_OPTIONS="$TORTURE_OPTIONS $CONFIGURATION" TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME" TORTURE_OPTIONS="$TORTURE_OPTIONS --target=$SELFTEST_TARGET" TORTURE_OPTIONS="$TORTURE_OPTIONS --basedir=$prefix_abs" @@ -80,23 +82,18 @@ smb4torture="$smb4torture $TORTURE_OPTIONS" echo "OPTIONS $TORTURE_OPTIONS" -SMB_CONF_PATH="$conffile" -export SMB_CONF_PATH -CONFIGURATION="--configfile=$conffile" -export CONFIGURATION - # Simple tests for LDAP and CLDAP for options in "" "--option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD --option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD"; do - plantest "ldb.ldap with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldap \$SERVER_IP $options + plantest "ldb.ldap with options $options" dc $bbdir/test_ldb.sh ldap \$SERVER_IP $options done # see if we support ldaps if grep ENABLE_GNUTLS.1 include/config.h > /dev/null; then for options in "" "-U\$USERNAME%\$PASSWORD"; do - plantest "ldb.ldaps with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldaps \$SERVER_IP $options + plantest "ldb.ldaps with options $options" dc $bbdir/test_ldb.sh ldaps \$SERVER_IP $options done fi -plantest "ldb.ldapi with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldapi \$PREFIX_ABS/dc/private/ldapi $options +plantest "ldb.ldapi with options $options" dc $bbdir/test_ldb.sh ldapi \$PREFIX_ABS/dc/private/ldapi $options for t in LDAP-CLDAP LDAP-BASIC LDAP-SCHEMA LDAP-UPTODATEVECTOR do plansmbtorturetest "$t" dc "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_ @@ -119,7 +116,7 @@ slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS" slow_ncalrpc_tests="RPC-SAMR RPC-SAMR-PASSWORDS" slow_ncacn_ip_tcp_tests="RPC-SAMR RPC-SAMR-PASSWORDS RPC-CRACKNAMES" -all_tests="$ncalrpc_tests $ncacn_np_tests $ncacn_ip_tcp_tests $slow_ncalrpc_tests $slow_ncacn_np_tests $slow_ncacn_ip_tcp_tests RPC-SECRETS RPC-SAMBA3-SHARESEC" +all_tests="$ncalrpc_tests $ncacn_np_tests $ncacn_ip_tcp_tests $slow_ncalrpc_tests $slow_ncacn_np_tests $slow_ncacn_ip_tcp_tests RPC-SECRETS RPC-SAMBA3-SHARESEC RPC-COUNTCALLS" # Make sure all tests get run for t in `$smb4torture --list | grep "^RPC-"` @@ -133,15 +130,16 @@ done for bindoptions in seal,padcheck $VALIDATE bigendian; do for transport in ncalrpc ncacn_np ncacn_ip_tcp; do + env="dc" case $transport in - ncalrpc) tests=$ncalrpc_tests ;; + ncalrpc) tests=$ncalrpc_tests;env="dc:local" ;; ncacn_np) tests=$ncacn_np_tests ;; ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;; esac for t in $tests; do - plantest "`normalize_testname $t` on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" + plantest "`normalize_testname $t` on $transport with $bindoptions" $env $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" done - plantest "rpc.samba3.sharesec on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp RPC-SAMBA3-SHARESEC "$*" + plantest "rpc.samba3.sharesec on $transport with $bindoptions" $env $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp RPC-SAMBA3-SHARESEC "$*" done done @@ -151,15 +149,19 @@ for bindoptions in "" $VALIDATE bigendian; do done done +t="RPC-COUNTCALLS" +plantest "`normalize_testname $t`" dc:local $VALGRIND $smb4torture "\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" + for bindoptions in connect $VALIDATE ; do for transport in ncalrpc ncacn_np ncacn_ip_tcp; do + env="dc" case $transport in - ncalrpc) tests=$slow_ncalrpc_tests ;; + ncalrpc) tests=$slow_ncalrpc_tests; env="dc:local" ;; ncacn_np) tests=$slow_ncacn_np_tests ;; ncacn_ip_tcp) tests=$slow_ncacn_ip_tcp_tests ;; esac for t in $tests; do - plantest "`normalize_testname $t` on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" + plantest "`normalize_testname $t` on $transport with $bindoptions" $env $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" done done done @@ -206,7 +208,11 @@ for transport in $transports; do for bindoptions in connect spnego spnego,sign spnego,seal $VALIDATE padcheck bigendian bigendian,seal; do for ntlmoptions in \ "--option=socket:testnonblock=True --option=torture:quick=yes"; do - plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*" + env="dc" + if test x"$transport" = x"ncalrpc"; then + env="dc:local" + fi + plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" $env $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*" done done done @@ -224,7 +230,11 @@ for transport in $transports; do "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes" \ "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \ ; do - plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*" + env="dc" + if test x"$transport" = x"ncalrpc"; then + env="dc:local" + fi + plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" $env $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*" done done done @@ -287,8 +297,6 @@ fi # the API. These mainly test that the various command-line options of commands # work correctly. -bbdir=../testprogs/blackbox - plantest "blackbox.ndrdump" none $samba4srcdir/librpc/tests/test_ndrdump.sh plantest "blackbox.net" dc $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" $CONFIGURATION @@ -298,8 +306,8 @@ plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh plantest "blackbox.locktest" dc $samba4srcdir/torture/tests/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" plantest "blackbox.masktest" dc $samba4srcdir/torture/tests/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" plantest "blackbox.gentest" dc $samba4srcdir/torture/tests/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" -plantest "blackbox.wbinfo" dc $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc" -plantest "blackbox.wbinfo" member $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member" +plantest "blackbox.wbinfo" dc:local $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc" +plantest "blackbox.wbinfo" member:local $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member" # Tests using the "Simple" NTVFS backend @@ -387,32 +395,32 @@ then fi PYTHON=/usr/bin/python -SUBUNITRUN="$PYTHON ./scripting/bin/subunitrun" -plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:lib/ldb/tests/python/" $SUBUNITRUN api -plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:auth/credentials/tests" $SUBUNITRUN bindings -plantest "registry.python" none PYTHONPATH="$PYTHONPATH:lib/registry/tests/" $SUBUNITRUN bindings +SUBUNITRUN="$VALGRIND $PYTHON $samba4srcdir/scripting/bin/subunitrun" +plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/ldb/tests/python/" $SUBUNITRUN api +plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/auth/credentials/tests" $SUBUNITRUN bindings +plantest "registry.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/registry/tests/" $SUBUNITRUN bindings plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:../lib/tdb/python/tests" $SUBUNITRUN simple -plantest "auth.python" none PYTHONPATH="$PYTHONPATH:auth/tests/" $SUBUNITRUN bindings -plantest "security.python" none PYTHONPATH="$PYTHONPATH:libcli/security/tests" $SUBUNITRUN bindings -plantest "param.python" none PYTHONPATH="$PYTHONPATH:param/tests" $SUBUNITRUN bindings +plantest "auth.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/auth/tests/" $SUBUNITRUN bindings +plantest "security.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/libcli/security/tests" $SUBUNITRUN bindings +plantest "param.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/param/tests" $SUBUNITRUN bindings plantest "upgrade.python" none $SUBUNITRUN samba.tests.upgrade plantest "samba.python" none $SUBUNITRUN samba.tests plantest "provision.python" none $SUBUNITRUN samba.tests.provision plantest "samba3.python" none $SUBUNITRUN samba.tests.samba3 -plantest "samr.python" dc $SUBUNITRUN samba.tests.dcerpc.sam -plantest "dcerpc.bare.python" dc $SUBUNITRUN samba.tests.dcerpc.bare -plantest "unixinfo.python" dc $SUBUNITRUN samba.tests.dcerpc.unix +plantest "samr.python" dc:local $SUBUNITRUN samba.tests.dcerpc.sam +plantest "dcerpc.bare.python" dc:local $SUBUNITRUN samba.tests.dcerpc.bare +plantest "unixinfo.python" dc:local $SUBUNITRUN samba.tests.dcerpc.unix plantest "samdb.python" none $SUBUNITRUN samba.tests.samdb plantest "tevent.python" none PYTHONPATH="$PYTHONPATH:../lib/tevent" $SUBUNITRUN tests -plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:lib/messaging/tests" $SUBUNITRUN bindings -plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam +plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/messaging/tests" $SUBUNITRUN bindings +plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam plantest "subunit.python" none $SUBUNITRUN subunit -plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho -plantest "winreg.python" dc $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry +plantest "rpcecho.python" dc:local $SUBUNITRUN samba.tests.dcerpc.rpcecho +plantest "winreg.python" dc:local $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN -plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3 +plantest "blackbox.samba3dump" none $PYTHON $samba4srcdir/scripting/bin/samba3dump $samba4srcdir/../testdata/samba3 rm -rf $PREFIX/upgrade -plantest "blackbox.upgrade" none $PYTHON setup/upgrade $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf +plantest "blackbox.upgrade" none $PYTHON $samba4srcdir/setup/upgrade $CONFIGURATION --targetdir=$PREFIX/upgrade $samba4srcdir/../testdata/samba3 ../testdata/samba3/smb.conf rm -rf $PREFIX/provision mkdir $PREFIX/provision plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX/provision" diff --git a/source4/smb_server/management.c b/source4/smb_server/management.c index 4306b22c30..e58c278613 100644 --- a/source4/smb_server/management.c +++ b/source4/smb_server/management.c @@ -32,7 +32,8 @@ static NTSTATUS smbsrv_session_information(struct irpc_message *msg, struct smbsrv_information *r) { - struct smbsrv_connection *smb_conn = talloc_get_type(msg->private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(msg->private_data, + struct smbsrv_connection); int i=0, count=0; struct smbsrv_session *sess; @@ -75,7 +76,8 @@ static NTSTATUS smbsrv_session_information(struct irpc_message *msg, static NTSTATUS smbsrv_tcon_information(struct irpc_message *msg, struct smbsrv_information *r) { - struct smbsrv_connection *smb_conn = talloc_get_type(msg->private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(msg->private_data, + struct smbsrv_connection); int i=0, count=0; struct smbsrv_tcon *tcon; diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 0afa3a652d..03631f8f0b 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -351,9 +351,9 @@ static const struct smb_message_struct receive a SMB request header from the wire, forming a request_context from the result ****************************************************************************/ -NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob) +NTSTATUS smbsrv_recv_smb_request(void *private_data, DATA_BLOB blob) { - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); struct smbsrv_request *req; struct timeval cur_time = timeval_current(); uint8_t command; diff --git a/source4/smb_server/smb/search.c b/source4/smb_server/smb/search.c index 90b2331271..bf4721757b 100644 --- a/source4/smb_server/smb/search.c +++ b/source4/smb_server/smb/search.c @@ -65,9 +65,9 @@ static bool find_fill_info(struct smbsrv_request *req, } /* callback function for search first/next */ -static bool find_callback(void *private, const union smb_search_data *file) +static bool find_callback(void *private_data, const union smb_search_data *file) { - struct search_state *state = (struct search_state *)private; + struct search_state *state = (struct search_state *)private_data; return find_fill_info(state->req, file); } diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index 40ffeeef48..e0f6438dc6 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -800,9 +800,9 @@ static NTSTATUS find_fill_info(struct find_state *state, } /* callback function for trans2 findfirst/findnext */ -static bool find_callback(void *private, const union smb_search_data *file) +static bool find_callback(void *private_data, const union smb_search_data *file) { - struct find_state *state = talloc_get_type(private, struct find_state); + struct find_state *state = talloc_get_type(private_data, struct find_state); struct smb_trans2 *trans = state->op->trans; uint_t old_length; diff --git a/source4/smb_server/smb2/find.c b/source4/smb_server/smb2/find.c index 32b280c5c2..10fcda9434 100644 --- a/source4/smb_server/smb2/find.c +++ b/source4/smb_server/smb2/find.c @@ -40,9 +40,9 @@ struct smb2srv_find_state { }; /* callback function for SMB2 Find */ -static bool smb2srv_find_callback(void *private, const union smb_search_data *file) +static bool smb2srv_find_callback(void *private_data, const union smb_search_data *file) { - struct smb2srv_find_state *state = talloc_get_type(private, struct smb2srv_find_state); + struct smb2srv_find_state *state = talloc_get_type(private_data, struct smb2srv_find_state); struct smb2_find *info = state->info; uint32_t old_length; NTSTATUS status; diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c index c3607f0a33..5a857e133f 100644 --- a/source4/smb_server/smb2/receive.c +++ b/source4/smb_server/smb2/receive.c @@ -449,9 +449,9 @@ notcon: return NT_STATUS_OK; } -NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob) +NTSTATUS smbsrv_recv_smb2_request(void *private_data, DATA_BLOB blob) { - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); struct smb2srv_request *req; struct timeval cur_time = timeval_current(); uint32_t protocol_version; diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c index c3675c1ba5..1c84392b0c 100644 --- a/source4/smb_server/smb_samba3.c +++ b/source4/smb_server/smb_samba3.c @@ -31,7 +31,6 @@ #include "system/network.h" #include "lib/socket/netif.h" #include "param/share.h" -#include "dsdb/samdb/samdb.h" #include "param/param.h" #include "dynconfig/dynconfig.h" #include "smbd/process_model.h" diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index e9531d8b39..6206a03b21 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -34,10 +34,10 @@ #include "dsdb/samdb/samdb.h" #include "param/param.h" -static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob) +static NTSTATUS smbsrv_recv_generic_request(void *private_data, DATA_BLOB blob) { NTSTATUS status; - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); uint32_t protocol_version; /* see if its a special NBT packet */ @@ -88,7 +88,7 @@ void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char */ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags) { - struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, + struct smbsrv_connection *smb_conn = talloc_get_type(conn->private_data, struct smbsrv_connection); DEBUG(10,("smbsrv_recv\n")); @@ -101,7 +101,7 @@ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags) */ static void smbsrv_send(struct stream_connection *conn, uint16_t flags) { - struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, + struct smbsrv_connection *smb_conn = talloc_get_type(conn->private_data, struct smbsrv_connection); packet_queue_run(smb_conn->packet); } @@ -109,9 +109,9 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags) /* handle socket recv errors */ -static void smbsrv_recv_error(void *private, NTSTATUS status) +static void smbsrv_recv_error(void *private_data, NTSTATUS status) { - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); smbsrv_terminate_connection(smb_conn, nt_errstr(status)); } @@ -148,7 +148,7 @@ static void smbsrv_accept(struct stream_connection *conn) smb_conn->lp_ctx = conn->lp_ctx; smb_conn->connection = conn; - conn->private = smb_conn; + conn->private_data = smb_conn; smb_conn->statistics.connect_time = timeval_current(); diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c index ad8172d3a7..979a65482e 100644 --- a/source4/smbd/process_prefork.c +++ b/source4/smbd/process_prefork.c @@ -74,7 +74,7 @@ static void prefork_accept_connection(struct tevent_context *ev, void (*new_conn)(struct tevent_context *, struct loadparm_context *, struct socket_context *, struct server_id , void *), - void *private) + void *private_data) { NTSTATUS status; struct socket_context *connected_socket; @@ -86,9 +86,9 @@ static void prefork_accept_connection(struct tevent_context *ev, return; } - talloc_steal(private, connected_socket); + talloc_steal(private_data, connected_socket); - new_conn(ev, lp_ctx, connected_socket, cluster_id(pid, socket_get_fd(connected_socket)), private); + new_conn(ev, lp_ctx, connected_socket, cluster_id(pid, socket_get_fd(connected_socket)), private_data); } /* @@ -98,7 +98,7 @@ static void prefork_new_task(struct tevent_context *ev, struct loadparm_context *lp_ctx, const char *service_name, void (*new_task_fn)(struct tevent_context *, struct loadparm_context *lp_ctx, struct server_id , void *), - void *private) + void *private_data) { pid_t pid; int i, num_children; @@ -120,7 +120,7 @@ static void prefork_new_task(struct tevent_context *ev, /* the service has given us a private pointer that encapsulates the context it needs for this new connection - everything else will be freed */ - talloc_steal(ev2, private); + talloc_steal(ev2, private_data); /* this will free all the listening sockets and all state that is not associated with this new connection */ @@ -131,7 +131,7 @@ static void prefork_new_task(struct tevent_context *ev, prefork_reload_after_fork(); /* setup this new connection: process will bind to it's sockets etc */ - new_task_fn(ev2, lp_ctx, cluster_id(pid, 0), private); + new_task_fn(ev2, lp_ctx, cluster_id(pid, 0), private_data); num_children = lp_parm_int(lp_ctx, NULL, "prefork children", service_name, 0); if (num_children == 0) { diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c index bb82c384d6..738ace95c7 100644 --- a/source4/smbd/process_single.c +++ b/source4/smbd/process_single.c @@ -43,7 +43,7 @@ static void single_accept_connection(struct tevent_context *ev, struct loadparm_context *, struct socket_context *, struct server_id , void *), - void *private) + void *private_data) { NTSTATUS status; struct socket_context *connected_socket; @@ -67,12 +67,12 @@ static void single_accept_connection(struct tevent_context *ev, return; } - talloc_steal(private, connected_socket); + talloc_steal(private_data, connected_socket); /* The cluster_id(0, fd) cannot collide with the incrementing * task below, as the first component is 0, not 1 */ new_conn(ev, lp_ctx, connected_socket, - cluster_id(0, socket_get_fd(connected_socket)), private); + cluster_id(0, socket_get_fd(connected_socket)), private_data); } /* @@ -82,7 +82,7 @@ static void single_new_task(struct tevent_context *ev, struct loadparm_context *lp_ctx, const char *service_name, void (*new_task)(struct tevent_context *, struct loadparm_context *, struct server_id, void *), - void *private) + void *private_data) { static uint32_t taskid = 0; @@ -90,7 +90,7 @@ static void single_new_task(struct tevent_context *ev, * in the accept connection above, and unlikly to collide with * PIDs from process modal standard (don't run samba as * init) */ - new_task(ev, lp_ctx, cluster_id(1, taskid++), private); + new_task(ev, lp_ctx, cluster_id(1, taskid++), private_data); } diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index b20adbfd16..137e0a7ce0 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -61,7 +61,7 @@ static void standard_accept_connection(struct tevent_context *ev, void (*new_conn)(struct tevent_context *, struct loadparm_context *, struct socket_context *, struct server_id , void *), - void *private) + void *private_data) { NTSTATUS status; struct socket_context *sock2; @@ -97,8 +97,8 @@ static void standard_accept_connection(struct tevent_context *ev, /* the service has given us a private pointer that encapsulates the context it needs for this new connection - everything else will be freed */ - talloc_steal(ev2, private); - talloc_steal(private, sock2); + talloc_steal(ev2, private_data); + talloc_steal(private_data, sock2); /* this will free all the listening sockets and all state that is not associated with this new connection */ @@ -128,7 +128,7 @@ static void standard_accept_connection(struct tevent_context *ev, talloc_free(s); /* setup this new connection. Cluster ID is PID based for this process modal */ - new_conn(ev2, lp_ctx, sock2, cluster_id(pid, 0), private); + new_conn(ev2, lp_ctx, sock2, cluster_id(pid, 0), private_data); /* we can't return to the top level here, as that event context is gone, so we now process events in the new event context until there are no @@ -146,7 +146,7 @@ static void standard_new_task(struct tevent_context *ev, struct loadparm_context *lp_ctx, const char *service_name, void (*new_task)(struct tevent_context *, struct loadparm_context *lp_ctx, struct server_id , void *), - void *private) + void *private_data) { pid_t pid; struct tevent_context *ev2; @@ -166,7 +166,7 @@ static void standard_new_task(struct tevent_context *ev, /* the service has given us a private pointer that encapsulates the context it needs for this new connection - everything else will be freed */ - talloc_steal(ev2, private); + talloc_steal(ev2, private_data); /* this will free all the listening sockets and all state that is not associated with this new connection */ @@ -183,7 +183,7 @@ static void standard_new_task(struct tevent_context *ev, setproctitle("task %s server_id[%d]", service_name, pid); /* setup this new task. Cluster ID is PID based for this process modal */ - new_task(ev2, lp_ctx, cluster_id(pid, 0), private); + new_task(ev2, lp_ctx, cluster_id(pid, 0), private_data); /* we can't return to the top level here, as that event context is gone, so we now process events in the new event context until there are no diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c index 3c3b6b287f..5be6374c14 100644 --- a/source4/smbd/process_thread.c +++ b/source4/smbd/process_thread.c @@ -41,14 +41,14 @@ struct new_conn_state { struct socket_context *sock; struct loadparm_context *lp_ctx; void (*new_conn)(struct tevent_context *, struct loadparm_context *lp_ctx, struct socket_context *, uint32_t , void *); - void *private; + void *private_data; }; static void *thread_connection_fn(void *thread_parm) { struct new_conn_state *new_conn = talloc_get_type(thread_parm, struct new_conn_state); - new_conn->new_conn(new_conn->ev, new_conn->lp_ctx, new_conn->sock, pthread_self(), new_conn->private); + new_conn->new_conn(new_conn->ev, new_conn->lp_ctx, new_conn->sock, pthread_self(), new_conn->private_data); /* run this connection from here */ event_loop_wait(new_conn->ev); @@ -68,7 +68,7 @@ static void thread_accept_connection(struct tevent_context *ev, struct loadparm_context *, struct socket_context *, uint32_t , void *), - void *private) + void *private_data) { NTSTATUS status; int rc; @@ -87,7 +87,7 @@ static void thread_accept_connection(struct tevent_context *ev, } state->new_conn = new_conn; - state->private = private; + state->private_data = private_data; state->lp_ctx = lp_ctx; state->ev = ev2; @@ -125,7 +125,7 @@ struct new_task_state { struct loadparm_context *lp_ctx; void (*new_task)(struct tevent_context *, struct loadparm_context *, uint32_t , void *); - void *private; + void *private_data; }; static void *thread_task_fn(void *thread_parm) @@ -133,7 +133,7 @@ static void *thread_task_fn(void *thread_parm) struct new_task_state *new_task = talloc_get_type(thread_parm, struct new_task_state); new_task->new_task(new_task->ev, new_task->lp_ctx, pthread_self(), - new_task->private); + new_task->private_data); /* run this connection from here */ event_loop_wait(new_task->ev); @@ -152,7 +152,7 @@ static void thread_new_task(struct tevent_context *ev, void (*new_task)(struct tevent_context *, struct loadparm_context *, uint32_t , void *), - void *private) + void *private_data) { int rc; pthread_t thread_id; @@ -171,7 +171,7 @@ static void thread_new_task(struct tevent_context *ev, state->new_task = new_task; state->lp_ctx = lp_ctx; - state->private = private; + state->private_data = private_data; state->ev = ev2; pthread_attr_init(&thread_attr); diff --git a/source4/smbd/server.c b/source4/smbd/server.c index df970661f1..247a10f60f 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -149,9 +149,9 @@ static void setup_signals(void) handle io on stdin */ static void server_stdin_handler(struct tevent_context *event_ctx, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - const char *binary_name = (const char *)private; + const char *binary_name = (const char *)private_data; uint8_t c; if (read(0, &c, 1) == 0) { DEBUG(0,("%s: EOF on stdin - terminating\n", binary_name)); @@ -169,9 +169,9 @@ static void server_stdin_handler(struct tevent_context *event_ctx, struct tevent */ _NORETURN_ static void max_runtime_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - const char *binary_name = (const char *)private; + const char *binary_name = (const char *)private_data; DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name)); exit(0); } diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c index e3c0908a15..de4726e4d5 100644 --- a/source4/smbd/service_named_pipe.c +++ b/source4/smbd/service_named_pipe.c @@ -60,8 +60,8 @@ static void named_pipe_handover_connection(void *private_data) /* * remove the named_pipe layer together with its packet layer */ - conn->ops = pipe_conn->pipe_sock->ops; - conn->private = pipe_conn->pipe_sock->private_data; + conn->ops = pipe_conn->pipe_sock->ops; + conn->private_data = pipe_conn->pipe_sock->private_data; talloc_free(pipe_conn); /* we're now ready to start receiving events on this stream */ @@ -209,7 +209,7 @@ reply: static void named_pipe_recv(struct stream_connection *conn, uint16_t flags) { struct named_pipe_connection *pipe_conn = talloc_get_type( - conn->private, struct named_pipe_connection); + conn->private_data, struct named_pipe_connection); DEBUG(10,("named_pipe_recv\n")); @@ -222,7 +222,7 @@ static void named_pipe_recv(struct stream_connection *conn, uint16_t flags) static void named_pipe_send(struct stream_connection *conn, uint16_t flags) { struct named_pipe_connection *pipe_conn = talloc_get_type( - conn->private, struct named_pipe_connection); + conn->private_data, struct named_pipe_connection); packet_queue_run(pipe_conn->packet); } @@ -238,7 +238,7 @@ static void named_pipe_recv_error(void *private_data, NTSTATUS status) stream_terminate_connection(pipe_conn->connection, nt_errstr(status)); } -static NTSTATUS named_pipe_full_request(void *private, DATA_BLOB blob, size_t *size) +static NTSTATUS named_pipe_full_request(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < 8) { return STATUS_MORE_ENTRIES; @@ -262,7 +262,7 @@ static NTSTATUS named_pipe_full_request(void *private, DATA_BLOB blob, size_t *s static void named_pipe_accept(struct stream_connection *conn) { struct named_pipe_socket *pipe_sock = talloc_get_type( - conn->private, struct named_pipe_socket); + conn->private_data, struct named_pipe_socket); struct named_pipe_connection *pipe_conn; DEBUG(5,("named_pipe_accept\n")); @@ -291,7 +291,7 @@ static void named_pipe_accept(struct stream_connection *conn) pipe_conn->pipe_sock = pipe_sock; pipe_conn->connection = conn; - conn->private = pipe_conn; + conn->private_data = pipe_conn; } static const struct stream_server_ops named_pipe_stream_ops = { diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index 6dff01f4f3..e09ac1d9e6 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -47,7 +47,7 @@ struct stream_socket { struct tevent_context *event_ctx; const struct model_ops *model_ops; struct socket_context *sock; - void *private; + void *private_data; }; @@ -101,16 +101,16 @@ static void stream_io_handler(struct stream_connection *conn, uint16_t flags) } static void stream_io_handler_fde(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct stream_connection *conn = talloc_get_type(private, + struct stream_connection *conn = talloc_get_type(private_data, struct stream_connection); stream_io_handler(conn, flags); } -void stream_io_handler_callback(void *private, uint16_t flags) +void stream_io_handler_callback(void *private_data, uint16_t flags) { - struct stream_connection *conn = talloc_get_type(private, + struct stream_connection *conn = talloc_get_type(private_data, struct stream_connection); stream_io_handler(conn, flags); } @@ -136,7 +136,7 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev, talloc_steal(srv_conn, sock); - srv_conn->private = private_data; + srv_conn->private_data = private_data; srv_conn->model_ops = model_ops; srv_conn->socket = sock; srv_conn->server_id = cluster_id(0, 0); @@ -163,9 +163,9 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev, static void stream_new_connection(struct tevent_context *ev, struct loadparm_context *lp_ctx, struct socket_context *sock, - struct server_id server_id, void *private) + struct server_id server_id, void *private_data) { - struct stream_socket *stream_socket = talloc_get_type(private, struct stream_socket); + struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket); struct stream_connection *srv_conn; struct socket_address *c, *s; @@ -177,7 +177,7 @@ static void stream_new_connection(struct tevent_context *ev, talloc_steal(srv_conn, sock); - srv_conn->private = stream_socket->private; + srv_conn->private_data = stream_socket->private_data; srv_conn->model_ops = stream_socket->model_ops; srv_conn->socket = sock; srv_conn->server_id = server_id; @@ -235,9 +235,9 @@ static void stream_new_connection(struct tevent_context *ev, called when someone opens a connection to one of our listening ports */ static void stream_accept_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct stream_socket *stream_socket = talloc_get_type(private, struct stream_socket); + struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket); /* ask the process model to create us a process for this new connection. When done, it calls stream_new_connection() @@ -263,7 +263,7 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context, const char *sock_addr, uint16_t *port, const char *socket_options, - void *private) + void *private_data) { NTSTATUS status; struct stream_socket *stream_socket; @@ -352,7 +352,7 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context, tevent_fd_set_close_fn(fde, socket_tevent_fd_close_fn); socket_set_flags(stream_socket->sock, SOCKET_FLAG_NOCLOSE); - stream_socket->private = talloc_reference(stream_socket, private); + stream_socket->private_data = talloc_reference(stream_socket, private_data); stream_socket->ops = stream_ops; stream_socket->event_ctx = event_context; stream_socket->model_ops = model_ops; diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h index 078887bf14..5d577d4dd8 100644 --- a/source4/smbd/service_stream.h +++ b/source4/smbd/service_stream.h @@ -39,7 +39,7 @@ struct stream_connection { const struct stream_server_ops *ops; const struct model_ops *model_ops; struct server_id server_id; - void *private; + void *private_data; struct { struct tevent_context *ctx; diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c index d3951a4a9a..c4fd3d4e98 100644 --- a/source4/smbd/service_task.c +++ b/source4/smbd/service_task.c @@ -53,9 +53,9 @@ struct task_state { */ static void task_server_callback(struct tevent_context *event_ctx, struct loadparm_context *lp_ctx, - struct server_id server_id, void *private) + struct server_id server_id, void *private_data) { - struct task_state *state = talloc_get_type(private, struct task_state); + struct task_state *state = talloc_get_type(private_data, struct task_state); struct task_server *task; task = talloc(event_ctx, struct task_server); diff --git a/source4/smbd/service_task.h b/source4/smbd/service_task.h index f5788da021..69ecb1b970 100644 --- a/source4/smbd/service_task.h +++ b/source4/smbd/service_task.h @@ -30,7 +30,7 @@ struct task_server { struct messaging_context *msg_ctx; struct loadparm_context *lp_ctx; struct server_id server_id; - void *private; + void *private_data; }; diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 23844a2c85..f4f91c8ba3 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -510,7 +510,7 @@ static NTSTATUS benchrw_close(struct torture_context *tctx, NT_STATUS_HAVE_NO_MEMORY(req); /*register the callback function!*/ req->async.fn = benchrw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -521,7 +521,7 @@ static void benchrw_callback(struct smbcli_request *req); static void benchrw_rw_callback(struct smbcli_request *req) { - struct benchrw_state *state = req->async.private; + struct benchrw_state *state = req->async.private_data; struct torture_context *tctx = state->tctx; if (!NT_STATUS_IS_OK(req->status)) { @@ -596,7 +596,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, NT_STATUS_HAVE_NO_MEMORY(req); /*register the callback function!*/ req->async.fn = benchrw_rw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -644,7 +644,7 @@ static NTSTATUS benchrw_open(struct torture_context *tctx, /*register the callback function!*/ req->async.fn = benchrw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -691,7 +691,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx, /*register the callback function!*/ req->async.fn = benchrw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -701,7 +701,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx, */ static void benchrw_callback(struct smbcli_request *req) { - struct benchrw_state *state = req->async.private; + struct benchrw_state *state = req->async.private_data; struct torture_context *tctx = state->tctx; /*dont send new requests when torture_numops is reached*/ @@ -913,7 +913,7 @@ bool run_benchrw(struct torture_context *tctx) req = smb_raw_mkdir_send(state[i]->cli,&parms); /* register callback fn + private data */ req->async.fn = benchrw_callback; - req->async.private=state[i]; + req->async.private_data=state[i]; break; /* error occured , finish */ case ERROR: diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 0677d9ac8e..be02f33378 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -125,9 +125,9 @@ static struct smb2_handle bad_smb2_handle; static bool oplock_handler_smb2(struct smb2_transport *transport, const struct smb2_handle *handle, uint8_t level, void *private_data); -static void idle_func_smb2(struct smb2_transport *transport, void *private); -static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private); -static void idle_func_smb(struct smbcli_transport *transport, void *private); +static void idle_func_smb2(struct smb2_transport *transport, void *private_data); +static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data); +static void idle_func_smb(struct smbcli_transport *transport, void *private_data); /* check if a string should be ignored. This is used as the basis @@ -976,7 +976,7 @@ static void oplock_handler_close_recv_smb(struct smbcli_request *req) /* the oplock handler will either ack the break or close the file */ -static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data) { union smb_close io; int i, j; @@ -1024,7 +1024,7 @@ static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, } req->async.fn = oplock_handler_close_recv_smb; - req->async.private = NULL; + req->async.private_data = NULL; return true; } @@ -1035,7 +1035,7 @@ static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, an operation on another connection blocking until that break is acked we check for operations on all transports in the idle function */ -static void idle_func_smb(struct smbcli_transport *transport, void *private) +static void idle_func_smb(struct smbcli_transport *transport, void *private_data) { int i, j; for (i=0;i<NSERVERS;i++) { @@ -1155,7 +1155,7 @@ static bool oplock_handler_smb2(struct smb2_transport *transport, const struct s an operation on another connection blocking until that break is acked we check for operations on all transports in the idle function */ -static void idle_func_smb2(struct smb2_transport *transport, void *private) +static void idle_func_smb2(struct smb2_transport *transport, void *private_data) { int i, j; for (i=0;i<NSERVERS;i++) { diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c index df2a5b0551..1fcfe5a050 100644 --- a/source4/torture/ldap/cldapbench.c +++ b/source4/torture/ldap/cldapbench.c @@ -33,7 +33,7 @@ struct bench_state { static void request_handler(struct cldap_request *req) { struct cldap_netlogon io; - struct bench_state *state = talloc_get_type(req->async.private, struct bench_state); + struct bench_state *state = talloc_get_type(req->async.private_data, struct bench_state); NTSTATUS status; TALLOC_CTX *tmp_ctx = talloc_new(NULL); io.in.version = 6; @@ -75,7 +75,7 @@ static bool bench_cldap(struct torture_context *tctx, const char *address) struct cldap_request *req; req = cldap_netlogon_send(cldap, &search); - req->async.private = state; + req->async.private_data = state; req->async.fn = request_handler; num_sent++; if (num_sent % 50 == 0) { diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c index be09018acf..bf594088cd 100644 --- a/source4/torture/nbench/nbio.c +++ b/source4/torture/nbench/nbio.c @@ -384,9 +384,9 @@ static struct smbcli_state *c; a handler function for oplock break requests */ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, void *private) + uint16_t fnum, uint8_t level, void *private_data) { - struct smbcli_tree *tree = (struct smbcli_tree *)private; + struct smbcli_tree *tree = (struct smbcli_tree *)private_data; return smbcli_oplock_ack(tree, fnum, OPLOCK_BREAK_TO_NONE); } @@ -802,15 +802,15 @@ bool nb_mkdir(const char *dname, NTSTATUS status, bool retry) return true; } -bool nb_rename(const char *old, const char *new, NTSTATUS status, bool retry) +bool nb_rename(const char *o, const char *n, NTSTATUS status, bool retry) { NTSTATUS ret; union smb_rename io; io.generic.level = RAW_RENAME_RENAME; io.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY; - io.rename.in.pattern1 = old; - io.rename.in.pattern2 = new; + io.rename.in.pattern1 = o; + io.rename.in.pattern2 = n; ret = smb_raw_rename(c->tree, &io); @@ -906,7 +906,7 @@ bool nb_qfsinfo(int level, NTSTATUS status) } /* callback function used for trans2 search */ -static bool findfirst_callback(void *private, const union smb_search_data *file) +static bool findfirst_callback(void *private_data, const union smb_search_data *file) { return true; } diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index 5d26d65e0c..8eb315127a 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -42,11 +42,11 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot, struct socket_address *src) { NTSTATUS status; - struct nbt_netlogon_response *netlogon = dgmslot->private; + struct nbt_netlogon_response *netlogon = dgmslot->private_data; - dgmslot->private = netlogon = talloc(dgmslot, struct nbt_netlogon_response); + dgmslot->private_data = netlogon = talloc(dgmslot, struct nbt_netlogon_response); - if (!dgmslot->private) { + if (!dgmslot->private_data) { return; } @@ -139,11 +139,11 @@ static bool nbt_test_netlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private_data) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -234,11 +234,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -273,11 +273,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -324,11 +324,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -365,11 +365,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -378,7 +378,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); - dgmslot->private = NULL; + dgmslot->private_data = NULL; ZERO_STRUCT(logon); logon.command = LOGON_SAM_LOGON_REQUEST; @@ -404,11 +404,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -513,11 +513,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -557,11 +557,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -597,11 +597,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private_data) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -634,11 +634,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private_data) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 4077ae97e6..d20175a018 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -112,7 +112,7 @@ static void lock_send(struct benchlock_state *state) DEBUG(0,("Failed to setup lock\n")); lock_failed++; } - state->req->async.private = state; + state->req->async.private_data = state; state->req->async.fn = lock_completion; } @@ -222,7 +222,7 @@ static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te */ static void lock_completion(struct smbcli_request *req) { - struct benchlock_state *state = (struct benchlock_state *)req->async.private; + struct benchlock_state *state = (struct benchlock_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); state->req = NULL; if (!NT_STATUS_IS_OK(status)) { @@ -262,7 +262,7 @@ static void lock_completion(struct smbcli_request *req) static void echo_completion(struct smbcli_request *req) { - struct benchlock_state *state = (struct benchlock_state *)req->async.private; + struct benchlock_state *state = (struct benchlock_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { @@ -305,7 +305,7 @@ static void report_rate(struct tevent_context *ev, struct tevent_timer *te, p.in.size = 0; p.in.data = NULL; req = smb_raw_echo_send(state[i].tree->session->transport, &p); - req->async.private = &state[i]; + req->async.private_data = &state[i]; req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/offline.c b/source4/torture/raw/offline.c index 2d97efa049..5322f471a2 100644 --- a/source4/torture/raw/offline.c +++ b/source4/torture/raw/offline.c @@ -159,7 +159,7 @@ static void savefile_callback(struct composite_context *ctx) */ static void setoffline_callback(struct smbcli_request *req) { - struct offline_state *state = req->async.private; + struct offline_state *state = req->async.private_data; NTSTATUS status; status = smbcli_request_simple_recv(req); @@ -183,7 +183,7 @@ static void setoffline_callback(struct smbcli_request *req) */ static void getoffline_callback(struct smbcli_request *req) { - struct offline_state *state = req->async.private; + struct offline_state *state = req->async.private_data; NTSTATUS status; union smb_fileinfo io; @@ -286,7 +286,7 @@ static void test_offline(struct offline_state *state) } state->req->async.fn = setoffline_callback; - state->req->async.private = state; + state->req->async.private_data = state; break; } @@ -303,7 +303,7 @@ static void test_offline(struct offline_state *state) } state->req->async.fn = getoffline_callback; - state->req->async.private = state; + state->req->async.private_data = state; break; } @@ -318,7 +318,7 @@ static void test_offline(struct offline_state *state) static void echo_completion(struct smbcli_request *req) { - struct offline_state *state = (struct offline_state *)req->async.private; + struct offline_state *state = (struct offline_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { @@ -380,7 +380,7 @@ static void report_rate(struct tevent_context *ev, struct tevent_timer *te, p.in.size = 0; p.in.data = NULL; req = smb_raw_echo_send(state[i].tree->session->transport, &p); - req->async.private = &state[i]; + req->async.private_data = &state[i]; req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index a9ce4aec0d..bdad2b16a5 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -186,7 +186,7 @@ static void next_open(struct benchopen_state *state) state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; - state->req_open->async.private = state; + state->req_open->async.private_data = state; } @@ -203,7 +203,7 @@ static void next_close(struct benchopen_state *state) state->req_close = smb_raw_close_send(state->tree, &state->close_parms); state->req_close->async.fn = close_completed; - state->req_close->async.private = state; + state->req_close->async.private_data = state; } /* @@ -211,7 +211,7 @@ static void next_close(struct benchopen_state *state) */ static void open_completed(struct smbcli_request *req) { - struct benchopen_state *state = (struct benchopen_state *)req->async.private; + struct benchopen_state *state = (struct benchopen_state *)req->async.private_data; TALLOC_CTX *tmp_ctx = talloc_new(state->mem_ctx); NTSTATUS status; @@ -243,7 +243,7 @@ static void open_completed(struct smbcli_request *req) state->open_retries++; state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; - state->req_open->async.private = state; + state->req_open->async.private_data = state; return; } @@ -275,7 +275,7 @@ static void open_completed(struct smbcli_request *req) */ static void close_completed(struct smbcli_request *req) { - struct benchopen_state *state = (struct benchopen_state *)req->async.private; + struct benchopen_state *state = (struct benchopen_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); state->req_close = NULL; @@ -312,7 +312,7 @@ static void close_completed(struct smbcli_request *req) static void echo_completion(struct smbcli_request *req) { - struct benchopen_state *state = (struct benchopen_state *)req->async.private; + struct benchopen_state *state = (struct benchopen_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { @@ -357,7 +357,7 @@ static void report_rate(struct tevent_context *ev, struct tevent_timer *te, p.in.size = 0; p.in.data = NULL; req = smb_raw_echo_send(state[i].tree->session->transport, &p); - req->async.private = &state[i]; + req->async.private_data = &state[i]; req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index d31d841e13..c10c49ecf3 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -74,9 +74,9 @@ static struct { */ static bool oplock_handler_ack_to_given(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, - uint8_t level, void *private) + uint8_t level, void *private_data) { - struct smbcli_tree *tree = (struct smbcli_tree *)private; + struct smbcli_tree *tree = (struct smbcli_tree *)private_data; const char *name; break_info.fnum = fnum; @@ -105,9 +105,9 @@ static bool oplock_handler_ack_to_given(struct smbcli_transport *transport, */ static bool oplock_handler_ack_to_none(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, - uint8_t level, void *private) + uint8_t level, void *private_data) { - struct smbcli_tree *tree = (struct smbcli_tree *)private; + struct smbcli_tree *tree = (struct smbcli_tree *)private_data; break_info.fnum = fnum; break_info.level = level; break_info.count++; @@ -122,7 +122,7 @@ static bool oplock_handler_ack_to_none(struct smbcli_transport *transport, */ static bool oplock_handler_timeout(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, - uint8_t level, void *private) + uint8_t level, void *private_data) { break_info.fnum = fnum; break_info.level = level; @@ -146,10 +146,10 @@ static void oplock_handler_close_recv(struct smbcli_request *req) a handler function for oplock break requests - close the file */ static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, void *private) + uint16_t fnum, uint8_t level, void *private_data) { union smb_close io; - struct smbcli_tree *tree = (struct smbcli_tree *)private; + struct smbcli_tree *tree = (struct smbcli_tree *)private_data; struct smbcli_request *req; break_info.fnum = fnum; @@ -166,7 +166,7 @@ static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t ti } req->async.fn = oplock_handler_close_recv; - req->async.private = NULL; + req->async.private_data = NULL; return true; } @@ -2999,9 +2999,9 @@ static struct hold_oplock_info { static bool oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, - void *private) + void *private_data) { - struct smbcli_tree *tree = (struct smbcli_tree *)private; + struct smbcli_tree *tree = (struct smbcli_tree *)private_data; struct hold_oplock_info *info; int i; @@ -3019,7 +3019,7 @@ static bool oplock_handler_hold(struct smbcli_transport *transport, if (info->close_on_break) { printf("oplock break on %s - closing\n", info->fname); - oplock_handler_close(transport, tid, fnum, level, private); + oplock_handler_close(transport, tid, fnum, level, private_data); return true; } diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index 2a6aef20b5..8a3168dcc4 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -31,9 +31,9 @@ /* callback function for single_search */ -static bool single_search_callback(void *private, const union smb_search_data *file) +static bool single_search_callback(void *private_data, const union smb_search_data *file) { - union smb_search_data *data = (union smb_search_data *)private; + union smb_search_data *data = (union smb_search_data *)private_data; *data = *file; @@ -510,9 +510,9 @@ struct multiple_result { /* callback function for multiple_search */ -static bool multiple_search_callback(void *private, const union smb_search_data *file) +static bool multiple_search_callback(void *private_data, const union smb_search_data *file) { - struct multiple_result *data = (struct multiple_result *)private; + struct multiple_result *data = (struct multiple_result *)private_data; data->count++; diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index d5bc4e6501..2fd9d923f1 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -125,9 +125,10 @@ static bool test_ReadEventLog(struct torture_context *tctx, while (1) { DATA_BLOB blob; - struct eventlog_Record rec; - struct ndr_pull *ndr; + struct EVENTLOGRECORD rec; enum ndr_err_code ndr_err; + uint32_t size = 0; + uint32_t pos = 0; /* Read first for number of bytes in record */ @@ -140,6 +141,7 @@ static bool test_ReadEventLog(struct torture_context *tctx, status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r); if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_END_OF_FILE)) { + /* FIXME: still need to decode then */ break; } @@ -156,17 +158,32 @@ static bool test_ReadEventLog(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed"); /* Decode a user-marshalled record */ + size = IVAL(r.out.data, pos); - blob.length = *r.out.sent_size; - blob.data = talloc_steal(tctx, r.out.data); + while (size > 0) { - ndr = ndr_pull_init_blob(&blob, tctx, lp_iconv_convenience(tctx->lp_ctx)); + blob = data_blob_const(r.out.data + pos, size); + dump_data(0, blob.data, blob.length); - ndr_err = ndr_pull_eventlog_Record( - ndr, NDR_SCALARS|NDR_BUFFERS, &rec); - status = ndr_map_error2ntstatus(ndr_err); + ndr_err = ndr_pull_struct_blob_all(&blob, tctx, + lp_iconv_convenience(tctx->lp_ctx), &rec, + (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + torture_assert_ntstatus_ok(tctx, status, + "ReadEventLog failed parsing event log record"); + } - NDR_PRINT_DEBUG(eventlog_Record, &rec); + NDR_PRINT_DEBUG(EVENTLOGRECORD, &rec); + + pos += size; + + if (pos + 4 > *r.out.sent_size) { + break; + } + + size = IVAL(r.out.data, pos); + } torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed parsing event log record"); diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 2207786f17..5b493db813 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -49,7 +49,7 @@ #include "libcli/auth/libcli_auth.h" #include "../lib/crypto/crypto.h" #include "auth/ntlmssp/ntlmssp.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "param/param.h" #include "lib/registry/registry.h" #include "libcli/resolve/resolve.h" @@ -1867,7 +1867,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) d_printf("(%s) whoami on user connection failed\n", __location__); ret = false; - goto delete; + goto del; } talloc_free(tree); @@ -1881,7 +1881,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) ret = false; } - delete: + del: if (!delete_user(cli, torture->lp_ctx, cmdline_credentials, cli_credentials_get_username(user_creds))) { @@ -3050,7 +3050,7 @@ static NTSTATUS enumkeys(struct dcerpc_pipe *p, struct policy_handle *handle, TALLOC_CTX *mem_ctx, int depth) { struct winreg_EnumKey r; - struct winreg_StringBuf class, name; + struct winreg_StringBuf kclass, name; NTSTATUS status; NTTIME t = 0; @@ -3058,13 +3058,13 @@ static NTSTATUS enumkeys(struct dcerpc_pipe *p, struct policy_handle *handle, return NT_STATUS_OK; } - class.name = ""; - class.size = 1024; + kclass.name = ""; + kclass.size = 1024; r.in.handle = handle; r.in.enum_index = 0; r.in.name = &name; - r.in.keyclass = &class; + r.in.keyclass = &kclass; r.out.name = &name; r.in.last_changed_time = &t; diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index a3fc6f740f..00798214f3 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -830,14 +830,14 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam { struct netr_DELTA_SECRET *secret = delta->delta_union.secret; const char *name = delta->delta_id_union.name; - struct samsync_secret *new = talloc(samsync_state, struct samsync_secret); + struct samsync_secret *nsec = talloc(samsync_state, struct samsync_secret); struct samsync_secret *old = talloc(mem_ctx, struct samsync_secret); struct lsa_QuerySecret q; struct lsa_OpenSecret o; struct policy_handle sec_handle; struct lsa_DATA_BUF_PTR bufp1; struct lsa_DATA_BUF_PTR bufp2; - NTTIME new_mtime; + NTTIME nsec_mtime; NTTIME old_mtime; bool ret = true; DATA_BLOB lsa_blob1, lsa_blob_out, session_key; @@ -849,12 +849,12 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam creds_arcfour_crypt(samsync_state->creds, secret->old_cipher.cipher_data, secret->old_cipher.maxlen); - new->name = talloc_reference(new, name); - new->secret = data_blob_talloc(new, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); - new->mtime = secret->current_cipher_set_time; + nsec->name = talloc_reference(nsec, name); + nsec->secret = data_blob_talloc(nsec, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); + nsec->mtime = secret->current_cipher_set_time; - new = talloc_reference(samsync_state, new); - DLIST_ADD(samsync_state->secrets, new); + nsec = talloc_reference(samsync_state, nsec); + DLIST_ADD(samsync_state->secrets, nsec); old->name = talloc_reference(old, name); old->secret = data_blob_const(secret->old_cipher.cipher_data, secret->old_cipher.maxlen); @@ -882,13 +882,13 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam } - ZERO_STRUCT(new_mtime); + ZERO_STRUCT(nsec_mtime); ZERO_STRUCT(old_mtime); /* fetch the secret back again */ q.in.sec_handle = &sec_handle; q.in.new_val = &bufp1; - q.in.new_mtime = &new_mtime; + q.in.new_mtime = &nsec_mtime; q.in.old_val = &bufp2; q.in.old_mtime = &old_mtime; @@ -957,26 +957,26 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam } if (!q.out.new_mtime) { - printf("NEW mtime not available on LSA for secret %s\n", new->name); + printf("NEW mtime not available on LSA for secret %s\n", nsec->name); ret = false; } - if (new->mtime != *q.out.new_mtime) { + if (nsec->mtime != *q.out.new_mtime) { printf("NEW mtime on secret %s does not match between SAMSYNC (%s) and LSA (%s)\n", - new->name, nt_time_string(mem_ctx, new->mtime), + nsec->name, nt_time_string(mem_ctx, nsec->mtime), nt_time_string(mem_ctx, *q.out.new_mtime)); ret = false; } - if (new->secret.length != lsa_blob_out.length) { + if (nsec->secret.length != lsa_blob_out.length) { printf("Returned secret %s doesn't match: %d != %d\n", - new->name, (int)new->secret.length, (int)lsa_blob_out.length); + nsec->name, (int)nsec->secret.length, (int)lsa_blob_out.length); ret = false; } else if (memcmp(lsa_blob_out.data, - new->secret.data, new->secret.length) != 0) { + nsec->secret.data, nsec->secret.length) != 0) { printf("Returned secret %s doesn't match: \n", - new->name); + nsec->name); DEBUG(1, ("SamSync Secret:\n")); - dump_data(1, new->secret.data, new->secret.length); + dump_data(1, nsec->secret.data, nsec->secret.length); DEBUG(1, ("LSA Secret:\n")); dump_data(1, lsa_blob_out.data, lsa_blob_out.length); ret = false; @@ -994,7 +994,7 @@ static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain; struct dom_sid *dom_sid = delta->delta_id_union.sid; - struct samsync_trusted_domain *new = talloc(samsync_state, struct samsync_trusted_domain); + struct samsync_trusted_domain *ndom = talloc(samsync_state, struct samsync_trusted_domain); struct lsa_OpenTrustedDomain t; struct policy_handle trustdom_handle; struct lsa_QueryTrustedDomainInfo q; @@ -1003,8 +1003,8 @@ static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st int levels [] = {1, 3, 8}; int i; - new->name = talloc_reference(new, trusted_domain->domain_name.string); - new->sid = talloc_reference(new, dom_sid); + ndom->name = talloc_reference(ndom, trusted_domain->domain_name.string); + ndom->sid = talloc_reference(ndom, dom_sid); t.in.handle = samsync_state->lsa_handle; t.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -1044,8 +1044,8 @@ static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st We would like to do this, but it is NOT_SUPPORTED on win2k3 TEST_SEC_DESC_EQUAL(trusted_domain->sdbuf, lsa, &trustdom_handle); */ - new = talloc_reference(samsync_state, new); - DLIST_ADD(samsync_state->trusted_domains, new); + ndom = talloc_reference(samsync_state, ndom); + DLIST_ADD(samsync_state->trusted_domains, ndom); return ret; } diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index b544e74181..b85dac7bf1 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -104,7 +104,7 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle, const char *name, - const char *class) + const char *kclass) { struct winreg_CreateKey r; struct policy_handle newhandle; @@ -114,7 +114,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.handle = handle; r.out.new_handle = &newhandle; init_winreg_String(&r.in.name, name); - init_winreg_String(&r.in.keyclass, class); + init_winreg_String(&r.in.keyclass, kclass); r.in.options = 0x0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.in.action_taken = r.out.action_taken = &action_taken; @@ -135,7 +135,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, static bool test_CreateKey_sd(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle, const char *name, - const char *class, + const char *kclass, struct policy_handle *newhandle) { struct winreg_CreateKey r; @@ -169,7 +169,7 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p, r.in.handle = handle; r.out.new_handle = newhandle; init_winreg_String(&r.in.name, name); - init_winreg_String(&r.in.keyclass, class); + init_winreg_String(&r.in.keyclass, kclass); r.in.options = 0x0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.in.action_taken = r.out.action_taken = &action_taken; @@ -1393,7 +1393,7 @@ static bool test_DeleteKey(struct dcerpc_pipe *p, struct torture_context *tctx, static bool test_QueryInfoKey(struct dcerpc_pipe *p, struct torture_context *tctx, - struct policy_handle *handle, char *class) + struct policy_handle *handle, char *kclass) { struct winreg_QueryInfoKey r; uint32_t num_subkeys, max_subkeylen, max_classlen, @@ -1415,7 +1415,7 @@ static bool test_QueryInfoKey(struct dcerpc_pipe *p, r.out.classname = talloc(tctx, struct winreg_String); r.in.classname = talloc(tctx, struct winreg_String); - init_winreg_String(r.in.classname, class); + init_winreg_String(r.in.classname, kclass); torture_assert_ntstatus_ok(tctx, dcerpc_winreg_QueryInfoKey(p, tctx, &r), @@ -1435,18 +1435,18 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx, bool test_security) { struct winreg_EnumKey r; - struct winreg_StringBuf class, name; + struct winreg_StringBuf kclass, name; NTSTATUS status; NTTIME t = 0; - class.name = ""; - class.size = 1024; + kclass.name = ""; + kclass.size = 1024; ZERO_STRUCT(r); r.in.handle = handle; r.in.enum_index = 0; r.in.name = &name; - r.in.keyclass = &class; + r.in.keyclass = &kclass; r.out.name = &name; r.in.last_changed_time = &t; diff --git a/source4/torture/tests/test_gentest.sh b/source4/torture/tests/test_gentest.sh index 2f4d00dc77..c7f66c8445 100755 --- a/source4/torture/tests/test_gentest.sh +++ b/source4/torture/tests/test_gentest.sh @@ -17,8 +17,8 @@ DOMAIN=$4 shift 4 failed=0 -samba4bindir=`dirname $0`/../../bin -gentest=$samba4bindir/gentest +samba4bindir="$BUILDDIR/bin" +gentest="$samba4bindir/gentest$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/torture/tests/test_locktest.sh b/source4/torture/tests/test_locktest.sh index 1fe39b4d1d..a8f11ee0ba 100755 --- a/source4/torture/tests/test_locktest.sh +++ b/source4/torture/tests/test_locktest.sh @@ -18,8 +18,8 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../bin -locktest=$samba4bindir/locktest +samba4bindir="$BUILDDIR/bin" +locktest="$samba4bindir/locktest$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/torture/tests/test_masktest.sh b/source4/torture/tests/test_masktest.sh index 59165e47df..e4fa65ccfb 100755 --- a/source4/torture/tests/test_masktest.sh +++ b/source4/torture/tests/test_masktest.sh @@ -18,8 +18,8 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../bin -masktest=$samba4bindir/masktest +samba4bindir="$BUILDDIR/bin" +masktest="$samba4bindir/masktest$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c index d0a2c3d041..30fe912234 100644 --- a/source4/torture/unix/unix_info2.c +++ b/source4/torture/unix/unix_info2.c @@ -201,9 +201,9 @@ static bool query_path_info2(void *mem_ctx, -1, fname, info2); } -static bool search_callback(void *private, const union smb_search_data *fdata) +static bool search_callback(void *private_data, const union smb_search_data *fdata) { - struct unix_info2 *info2 = (struct unix_info2 *)private; + struct unix_info2 *info2 = (struct unix_info2 *)private_data; info2->end_of_file = fdata->unix_info2.end_of_file; info2->num_bytes = fdata->unix_info2.num_bytes; diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 732b84af73..1c50694279 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -583,10 +583,10 @@ _PUBLIC_ bool check_error(const char *location, struct smbcli_state *c, status = smbcli_nt_error(c->tree); if (NT_STATUS_IS_DOS(status)) { - int class, num; - class = NT_STATUS_DOS_CLASS(status); + int classnum, num; + classnum = NT_STATUS_DOS_CLASS(status); num = NT_STATUS_DOS_CODE(status); - if (eclass != class || ecode != num) { + if (eclass != classnum || ecode != num) { printf("unexpected error code %s\n", nt_errstr(status)); printf(" expected %s or %s (at %s)\n", nt_errstr(NT_STATUS_DOS(eclass, ecode)), diff --git a/source4/utils/ad2oLschema.c b/source4/utils/ad2oLschema.c index 29fda09f3c..236b1fa350 100644 --- a/source4/utils/ad2oLschema.c +++ b/source4/utils/ad2oLschema.c @@ -32,7 +32,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb.h" #include "system/locale.h" #include "lib/ldb/tools/cmdline.h" #include "param/param.h" diff --git a/source4/utils/net/net_machinepw.c b/source4/utils/net/net_machinepw.c index 4e3165dbfd..390eb8df0b 100644 --- a/source4/utils/net/net_machinepw.c +++ b/source4/utils/net/net_machinepw.c @@ -19,12 +19,12 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "utils/net/net.h" #include "libnet/libnet.h" #include "libcli/security/security.h" #include "param/secrets.h" #include "param/param.h" -#include "lib/events/events.h" #include "lib/util/util_ldb.h" int net_machinepw_usage(struct net_context *ctx, int argc, const char **argv) diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 074ab698cf..bd262683d5 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -59,22 +59,22 @@ enum stdio_helper_mode { typedef void (*stdio_helper_function)(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_squid_basic_request (enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_gensec_request (enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_ntlm_server_1_request (enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_squid_request(struct loadparm_context *lp_ctx, @@ -248,7 +248,7 @@ static NTSTATUS local_pw_check_specified(struct loadparm_context *lp_ctx, static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2) { char *user, *pass; @@ -280,7 +280,7 @@ static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode, static void manage_gensec_get_pw_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **password) { DATA_BLOB in; @@ -298,7 +298,7 @@ static void manage_gensec_get_pw_request(enum stdio_helper_mode stdio_helper_mod if (strncmp(buf, "PW ", 3) == 0) { - *password = talloc_strndup(*private /* hopefully the right gensec context, useful to use for talloc */, + *password = talloc_strndup(*private1 /* hopefully the right gensec context, useful to use for talloc */, (const char *)in.data, in.length); if (*password == NULL) { @@ -380,7 +380,7 @@ static void gensec_want_feature_list(struct gensec_security *state, char* featur static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2) { DATA_BLOB in; @@ -405,15 +405,15 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, TALLOC_CTX *mem_ctx; - if (*private) { - state = (struct gensec_ntlm_state *)*private; + if (*private1) { + state = (struct gensec_ntlm_state *)*private1; } else { state = talloc_zero(NULL, struct gensec_ntlm_state); if (!state) { mux_printf(mux_id, "BH No Memory\n"); exit(1); } - *private = state; + *private1 = state; if (opt_password) { state->set_password = opt_password; } @@ -714,7 +714,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2) { char *request, *parameter; @@ -922,7 +922,7 @@ static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_hel static struct mux_private *mux_private; static void *normal_private; - void **private; + void **private1; buf = talloc_strdup(NULL, ""); @@ -1004,13 +1004,13 @@ static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_hel (sizeof(*mux_private->private_pointers) * (mux_private->max_mux - prev_max))); }; - private = &mux_private->private_pointers[mux_id]; + private1 = &mux_private->private_pointers[mux_id]; } else { c = buf; - private = &normal_private; + private1 = &normal_private; } - fn(helper_mode, lp_ctx, c, length, private, mux_id, private2); + fn(helper_mode, lp_ctx, c, length, private1, mux_id, private2); talloc_free(buf); } diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c index 6c4e6a9c80..701d221046 100644 --- a/source4/utils/oLschema2ldif.c +++ b/source4/utils/oLschema2ldif.c @@ -32,7 +32,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" #include "dsdb/samdb/samdb.h" diff --git a/source4/utils/tests/test_net.sh b/source4/utils/tests/test_net.sh index 3406c87cda..eb598bf5e1 100755 --- a/source4/utils/tests/test_net.sh +++ b/source4/utils/tests/test_net.sh @@ -9,8 +9,9 @@ shift 4 failed=0 -samba4bindir=`dirname $0`/../../bin -smbclient=$samba4bindir/smbclient +samba4bindir="$BUILDDIR/bin" +smbclient="$samba4bindir/smbclient$EXEEXT" +net="$samba4bindir/net$EXEEXT" testit() { name="$1" @@ -28,7 +29,7 @@ testit() { return $status } -testit "domain join" $VALGRIND bin/net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` +testit "domain join" $VALGRIND $net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` testit "Test login with --machine-pass without kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k no || failed=`expr $failed + 1` diff --git a/source4/utils/tests/test_nmblookup.sh b/source4/utils/tests/test_nmblookup.sh index ad9b3ba799..e2230e162f 100755 --- a/source4/utils/tests/test_nmblookup.sh +++ b/source4/utils/tests/test_nmblookup.sh @@ -26,11 +26,14 @@ testit() { return $status } -testit "nmblookup -U \$SERVER_IP \$SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $SERVER -testit "nmblookup -U \$SERVER_IP \$NETBIOSNAME" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSNAME -testit "nmblookup -U \$SERVER_IP \$NETBIOSALIAS" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSALIAS -testit "nmblookup \$SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER -testit "nmblookup \$NETBIOSNAME" bin/nmblookup $TORTURE_OPTIONS $NETBIOSNAME -testit "nmblookup \$NETBIOSALIAS" bin/nmblookup $TORTURE_OPTIONS $NETBIOSALIAS +samba4bindir="$BUILDDIR/bin" +nmblookup="$samba4bindir/nmblookup$EXEEXT" + +testit "nmblookup -U \$SERVER_IP \$SERVER" $nmblookup $TORTURE_OPTIONS -U $SERVER_IP $SERVER +testit "nmblookup -U \$SERVER_IP \$NETBIOSNAME" $nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSNAME +testit "nmblookup -U \$SERVER_IP \$NETBIOSALIAS" $nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSALIAS +testit "nmblookup \$SERVER" $nmblookup $TORTURE_OPTIONS $SERVER +testit "nmblookup \$NETBIOSNAME" $nmblookup $TORTURE_OPTIONS $NETBIOSNAME +testit "nmblookup \$NETBIOSALIAS" $nmblookup $TORTURE_OPTIONS $NETBIOSALIAS exit $failed diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c index c79fa8c753..2a2bfbb13b 100644 --- a/source4/web_server/web_server.c +++ b/source4/web_server/web_server.c @@ -50,9 +50,9 @@ static int websrv_destructor(struct websrv_context *web) */ static void websrv_timeout(struct tevent_context *event_context, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct websrv_context *web = talloc_get_type(private, struct websrv_context); + struct websrv_context *web = talloc_get_type(private_data, struct websrv_context); struct stream_connection *conn = web->conn; web->conn = NULL; /* TODO: send a message to any running esp context on this connection @@ -145,7 +145,7 @@ NTSTATUS http_parse_header(struct websrv_context *web, const char *line) static void websrv_recv(struct stream_connection *conn, uint16_t flags) { struct web_server_data *wdata; - struct websrv_context *web = talloc_get_type(conn->private, + struct websrv_context *web = talloc_get_type(conn->private_data, struct websrv_context); NTSTATUS status; uint8_t buf[1024]; @@ -202,7 +202,7 @@ static void websrv_recv(struct stream_connection *conn, uint16_t flags) destroy the stack variables being used by that rendering process when we handle the timeout. */ if (!talloc_reference(web->task, web)) goto failed; - wdata = talloc_get_type(web->task->private, struct web_server_data); + wdata = talloc_get_type(web->task->private_data, struct web_server_data); if (wdata == NULL) goto failed; wdata->http_process_input(wdata, web); talloc_unlink(web->task, web); @@ -220,7 +220,7 @@ failed: */ static void websrv_send(struct stream_connection *conn, uint16_t flags) { - struct websrv_context *web = talloc_get_type(conn->private, + struct websrv_context *web = talloc_get_type(conn->private_data, struct websrv_context); NTSTATUS status; size_t nsent; @@ -251,8 +251,8 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags) */ static void websrv_accept(struct stream_connection *conn) { - struct task_server *task = talloc_get_type(conn->private, struct task_server); - struct web_server_data *wdata = talloc_get_type(task->private, struct web_server_data); + struct task_server *task = talloc_get_type(conn->private_data, struct task_server); + struct web_server_data *wdata = talloc_get_type(task->private_data, struct web_server_data); struct websrv_context *web; struct socket_context *tls_socket; @@ -261,7 +261,7 @@ static void websrv_accept(struct stream_connection *conn) web->task = task; web->conn = conn; - conn->private = web; + conn->private_data = web; talloc_set_destructor(web, websrv_destructor); event_add_timed(conn->event.ctx, web, @@ -343,7 +343,7 @@ static void websrv_task_init(struct task_server *task) wdata = talloc_zero(task, struct web_server_data); if (wdata == NULL)goto failed; - task->private = wdata; + task->private_data = wdata; wdata->tls_params = tls_initialise(wdata, task->lp_ctx); if (wdata->tls_params == NULL) goto failed; diff --git a/source4/web_server/web_server.h b/source4/web_server/web_server.h index f91c766494..3b02feaf7d 100644 --- a/source4/web_server/web_server.h +++ b/source4/web_server/web_server.h @@ -25,7 +25,7 @@ struct web_server_data { struct tls_params *tls_params; void (*http_process_input)(struct web_server_data *wdata, struct websrv_context *web); - void *private; + void *private_data; }; struct http_header { diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c index 53ba2a2d9b..4d6b441f17 100644 --- a/source4/web_server/wsgi.c +++ b/source4/web_server/wsgi.c @@ -323,7 +323,7 @@ static void wsgi_process_http_input(struct web_server_data *wdata, struct websrv_context *web) { PyObject *py_environ, *result, *item, *iter; - PyObject *request_handler = wdata->private; + PyObject *request_handler = (PyObject *)wdata->private_data; struct socket_address *socket_address; web_request_Object *py_web = PyObject_New(web_request_Object, &web_request_Type); @@ -386,6 +386,6 @@ bool wsgi_initialize(struct web_server_data *wdata) DEBUG(0, ("Unable to find SWAT\n")); return false; } - wdata->private = py_swat; + wdata->private_data = py_swat; return true; } diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index f7be59136c..d0efbb159b 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -29,7 +29,7 @@ #include "lib/ldb_wrap.h" #include "param/param.h" #include "winbind/idmap.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "libcli/ldap/ldap_ndr.h" /** diff --git a/source4/winbind/wb_cmd_getpwnam.c b/source4/winbind/wb_cmd_getpwnam.c index 7d821537f0..be43684f82 100644 --- a/source4/winbind/wb_cmd_getpwnam.c +++ b/source4/winbind/wb_cmd_getpwnam.c @@ -27,7 +27,7 @@ #include "winbind/wb_helper.h" #include "smbd/service_task.h" #include "libnet/libnet_proto.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" struct cmd_getpwnam_state { struct composite_context *ctx; diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c index 0535045adb..42f4e7c94b 100644 --- a/source4/winbind/wb_irpc.c +++ b/source4/winbind/wb_irpc.c @@ -36,7 +36,7 @@ static void wb_irpc_SamLogon_callback(struct composite_context *ctx); static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg, struct winbind_SamLogon *req) { - struct wbsrv_service *service = talloc_get_type(msg->private, + struct wbsrv_service *service = talloc_get_type(msg->private_data, struct wbsrv_service); struct wb_irpc_SamLogon_state *s; struct composite_context *ctx; @@ -83,7 +83,7 @@ static void wb_irpc_get_idmap_callback(struct composite_context *ctx); static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg, struct winbind_get_idmap *req) { - struct wbsrv_service *service = talloc_get_type(msg->private, + struct wbsrv_service *service = talloc_get_type(msg->private_data, struct wbsrv_service); struct wb_irpc_get_idmap_state *s; struct composite_context *ctx; diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c index d40e0e6bc6..77c5bf3a1e 100644 --- a/source4/winbind/wb_samba3_protocol.c +++ b/source4/winbind/wb_samba3_protocol.c @@ -28,7 +28,7 @@ work out if a packet is complete for protocols that use a 32 bit host byte order length */ -NTSTATUS wbsrv_samba3_packet_full_request(void *private, DATA_BLOB blob, size_t *size) +NTSTATUS wbsrv_samba3_packet_full_request(void *private_data, DATA_BLOB blob, size_t *size) { uint32_t *len; if (blob.length < 4) { @@ -270,10 +270,10 @@ NTSTATUS wbsrv_samba3_send_reply(struct wbsrv_samba3_call *call) return status; } -NTSTATUS wbsrv_samba3_process(void *private, DATA_BLOB blob) +NTSTATUS wbsrv_samba3_process(void *private_data, DATA_BLOB blob) { NTSTATUS status; - struct wbsrv_connection *wbconn = talloc_get_type(private, + struct wbsrv_connection *wbconn = talloc_get_type(private_data, struct wbsrv_connection); struct wbsrv_samba3_call *call; status = wbsrv_samba3_pull_request(blob, wbconn, &call); diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c index 9ffcd467ee..95be49d1e3 100644 --- a/source4/winbind/wb_server.c +++ b/source4/winbind/wb_server.c @@ -41,15 +41,15 @@ void wbsrv_terminate_connection(struct wbsrv_connection *wbconn, const char *rea /* called on a tcp recv error */ -static void wbsrv_recv_error(void *private, NTSTATUS status) +static void wbsrv_recv_error(void *private_data, NTSTATUS status) { - struct wbsrv_connection *wbconn = talloc_get_type(private, struct wbsrv_connection); + struct wbsrv_connection *wbconn = talloc_get_type(private_data, struct wbsrv_connection); wbsrv_terminate_connection(wbconn, nt_errstr(status)); } static void wbsrv_accept(struct stream_connection *conn) { - struct wbsrv_listen_socket *listen_socket = talloc_get_type(conn->private, + struct wbsrv_listen_socket *listen_socket = talloc_get_type(conn->private_data, struct wbsrv_listen_socket); struct wbsrv_connection *wbconn; @@ -61,7 +61,7 @@ static void wbsrv_accept(struct stream_connection *conn) wbconn->conn = conn; wbconn->listen_socket = listen_socket; wbconn->lp_ctx = listen_socket->service->task->lp_ctx; - conn->private = wbconn; + conn->private_data = wbconn; wbconn->packet = packet_init(wbconn); if (wbconn->packet == NULL) { @@ -83,7 +83,7 @@ static void wbsrv_accept(struct stream_connection *conn) */ static void wbsrv_recv(struct stream_connection *conn, uint16_t flags) { - struct wbsrv_connection *wbconn = talloc_get_type(conn->private, + struct wbsrv_connection *wbconn = talloc_get_type(conn->private_data, struct wbsrv_connection); packet_recv(wbconn->packet); @@ -94,7 +94,7 @@ static void wbsrv_recv(struct stream_connection *conn, uint16_t flags) */ static void wbsrv_send(struct stream_connection *conn, uint16_t flags) { - struct wbsrv_connection *wbconn = talloc_get_type(conn->private, + struct wbsrv_connection *wbconn = talloc_get_type(conn->private_data, struct wbsrv_connection); packet_queue_run(wbconn->packet); } diff --git a/source4/winbind/wb_sid2gid.c b/source4/winbind/wb_sid2gid.c index d68956ce85..282d10c9c9 100644 --- a/source4/winbind/wb_sid2gid.c +++ b/source4/winbind/wb_sid2gid.c @@ -24,7 +24,7 @@ #include "winbind/wb_server.h" #include "smbd/service_task.h" #include "winbind/wb_helper.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "winbind/idmap.h" struct sid2gid_state { diff --git a/source4/winbind/wb_sid2uid.c b/source4/winbind/wb_sid2uid.c index b65e41978c..151f39906b 100644 --- a/source4/winbind/wb_sid2uid.c +++ b/source4/winbind/wb_sid2uid.c @@ -24,7 +24,7 @@ #include "winbind/wb_server.h" #include "smbd/service_task.h" #include "winbind/wb_helper.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "winbind/idmap.h" struct sid2uid_state { diff --git a/source4/wrepl_server/wrepl_apply_records.c b/source4/wrepl_server/wrepl_apply_records.c index 96a6033b1e..e6ff9a03bf 100644 --- a/source4/wrepl_server/wrepl_apply_records.c +++ b/source4/wrepl_server/wrepl_apply_records.c @@ -893,7 +893,7 @@ struct r_do_challenge_state { static void r_do_late_release_demand_handler(struct irpc_request *ireq) { NTSTATUS status; - struct r_do_challenge_state *state = talloc_get_type(ireq->async.private, + struct r_do_challenge_state *state = talloc_get_type(ireq->async.private_data, struct r_do_challenge_state); status = irpc_call_recv(ireq); @@ -931,7 +931,7 @@ static NTSTATUS r_do_late_release_demand(struct r_do_challenge_state *state) NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = r_do_late_release_demand_handler; - ireq->async.private = state; + ireq->async.private_data= state; return NT_STATUS_OK; } @@ -954,7 +954,7 @@ _UA_MA_DI_A<00>: C:BEST vs. B:BEST2 (C:ALL) => B:MHOMED => MHOMED_MERGE static void r_do_challenge_handler(struct irpc_request *ireq) { NTSTATUS status; - struct r_do_challenge_state *state = talloc_get_type(ireq->async.private, + struct r_do_challenge_state *state = talloc_get_type(ireq->async.private_data, struct r_do_challenge_state); bool old_is_subset = false; bool new_is_subset = false; @@ -1076,7 +1076,7 @@ static NTSTATUS r_do_challenge(struct wreplsrv_partner *partner, NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = r_do_challenge_handler; - ireq->async.private = state; + ireq->async.private_data= state; talloc_steal(partner, state); return NT_STATUS_OK; @@ -1090,7 +1090,7 @@ struct r_do_release_demand_state { static void r_do_release_demand_handler(struct irpc_request *ireq) { NTSTATUS status; - struct r_do_release_demand_state *state = talloc_get_type(ireq->async.private, + struct r_do_release_demand_state *state = talloc_get_type(ireq->async.private_data, struct r_do_release_demand_state); status = irpc_call_recv(ireq); @@ -1152,7 +1152,7 @@ static NTSTATUS r_do_release_demand(struct wreplsrv_partner *partner, NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = r_do_release_demand_handler; - ireq->async.private = state; + ireq->async.private_data= state; talloc_steal(partner, state); return NT_STATUS_OK; diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index ecc265e590..e6a69b829a 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -47,9 +47,9 @@ static int terminate_after_send_destructor(struct wreplsrv_in_connection **tas) /* receive some data on a WREPL connection */ -static NTSTATUS wreplsrv_recv_request(void *private, DATA_BLOB blob) +static NTSTATUS wreplsrv_recv_request(void *private_data, DATA_BLOB blob) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(private, struct wreplsrv_in_connection); + struct wreplsrv_in_connection *wreplconn = talloc_get_type(private_data, struct wreplsrv_in_connection); struct wreplsrv_in_call *call; DATA_BLOB packet_in_blob; DATA_BLOB packet_out_blob; @@ -123,7 +123,7 @@ static NTSTATUS wreplsrv_recv_request(void *private, DATA_BLOB blob) */ static void wreplsrv_recv(struct stream_connection *conn, uint16_t flags) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private, + struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private_data, struct wreplsrv_in_connection); packet_recv(wreplconn->packet); @@ -134,7 +134,7 @@ static void wreplsrv_recv(struct stream_connection *conn, uint16_t flags) */ static void wreplsrv_send(struct stream_connection *conn, uint16_t flags) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private, + struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private_data, struct wreplsrv_in_connection); packet_queue_run(wreplconn->packet); } @@ -142,9 +142,9 @@ static void wreplsrv_send(struct stream_connection *conn, uint16_t flags) /* handle socket recv errors */ -static void wreplsrv_recv_error(void *private, NTSTATUS status) +static void wreplsrv_recv_error(void *private_data, NTSTATUS status) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(private, + struct wreplsrv_in_connection *wreplconn = talloc_get_type(private_data, struct wreplsrv_in_connection); wreplsrv_terminate_in_connection(wreplconn, nt_errstr(status)); } @@ -154,7 +154,7 @@ static void wreplsrv_recv_error(void *private, NTSTATUS status) */ static void wreplsrv_accept(struct stream_connection *conn) { - struct wreplsrv_service *service = talloc_get_type(conn->private, struct wreplsrv_service); + struct wreplsrv_service *service = talloc_get_type(conn->private_data, struct wreplsrv_service); struct wreplsrv_in_connection *wreplconn; struct socket_address *peer_ip; @@ -189,7 +189,7 @@ static void wreplsrv_accept(struct stream_connection *conn) wreplconn->partner = wreplsrv_find_partner(service, peer_ip->addr); - conn->private = wreplconn; + conn->private_data = wreplconn; irpc_add_name(conn->msg_ctx, "wreplsrv_connection"); } diff --git a/source4/wrepl_server/wrepl_out_helpers.c b/source4/wrepl_server/wrepl_out_helpers.c index d9a9684c79..6aff134072 100644 --- a/source4/wrepl_server/wrepl_out_helpers.c +++ b/source4/wrepl_server/wrepl_out_helpers.c @@ -62,7 +62,7 @@ static NTSTATUS wreplsrv_out_connect_wait_socket(struct wreplsrv_out_connect_sta NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_out_connect_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_OUT_CONNECT_STAGE_WAIT_ASSOC_CTX; @@ -131,7 +131,7 @@ static void wreplsrv_out_connect_handler_creq(struct composite_context *creq) static void wreplsrv_out_connect_handler_req(struct wrepl_request *req) { - struct wreplsrv_out_connect_state *state = talloc_get_type(req->async.private, + struct wreplsrv_out_connect_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_out_connect_state); wreplsrv_out_connect_handler(state); return; @@ -276,7 +276,7 @@ static NTSTATUS wreplsrv_pull_table_wait_connection(struct wreplsrv_pull_table_s NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_pull_table_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PULL_TABLE_STAGE_WAIT_TABLE_REPLY; @@ -330,7 +330,7 @@ static void wreplsrv_pull_table_handler_creq(struct composite_context *creq) static void wreplsrv_pull_table_handler_req(struct wrepl_request *req) { - struct wreplsrv_pull_table_state *state = talloc_get_type(req->async.private, + struct wreplsrv_pull_table_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_pull_table_state); wreplsrv_pull_table_handler(state); return; @@ -436,7 +436,7 @@ static NTSTATUS wreplsrv_pull_names_wait_connection(struct wreplsrv_pull_names_s NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_pull_names_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PULL_NAMES_STAGE_WAIT_SEND_REPLY; @@ -490,7 +490,7 @@ static void wreplsrv_pull_names_handler_creq(struct composite_context *creq) static void wreplsrv_pull_names_handler_req(struct wrepl_request *req) { - struct wreplsrv_pull_names_state *state = talloc_get_type(req->async.private, + struct wreplsrv_pull_names_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_pull_names_state); wreplsrv_pull_names_handler(state); return; @@ -651,7 +651,7 @@ static NTSTATUS wreplsrv_pull_cycle_next_owner_wrapper(struct wreplsrv_pull_cycl NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_pull_cycle_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PULL_CYCLE_STAGE_WAIT_STOP_ASSOC; } @@ -773,7 +773,7 @@ static void wreplsrv_pull_cycle_handler_creq(struct composite_context *creq) static void wreplsrv_pull_cycle_handler_req(struct wrepl_request *req) { - struct wreplsrv_pull_cycle_state *state = talloc_get_type(req->async.private, + struct wreplsrv_pull_cycle_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_pull_cycle_state); wreplsrv_pull_cycle_handler(state); return; @@ -957,7 +957,7 @@ static NTSTATUS wreplsrv_push_notify_inform(struct wreplsrv_push_notify_state *s NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_push_notify_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PUSH_NOTIFY_STAGE_WAIT_INFORM; @@ -1056,7 +1056,7 @@ static void wreplsrv_push_notify_handler_creq(struct composite_context *creq) static void wreplsrv_push_notify_handler_req(struct wrepl_request *req) { - struct wreplsrv_push_notify_state *state = talloc_get_type(req->async.private, + struct wreplsrv_push_notify_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_push_notify_state); wreplsrv_push_notify_handler(state); return; diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c index 9f6a49ef09..8fc7d0a6f0 100644 --- a/source4/wrepl_server/wrepl_scavenging.c +++ b/source4/wrepl_server/wrepl_scavenging.c @@ -314,7 +314,7 @@ struct verify_state { static void verify_handler(struct irpc_request *ireq) { - struct verify_state *s = talloc_get_type(ireq->async.private, + struct verify_state *s = talloc_get_type(ireq->async.private_data, struct verify_state); struct winsdb_record *rec = s->rec; const char *action; @@ -495,7 +495,7 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = verify_handler; - ireq->async.private = s; + ireq->async.private_data= s; talloc_steal(service, s); } diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c index 5e100f46cc..c8316a5f4c 100644 --- a/source4/wrepl_server/wrepl_server.c +++ b/source4/wrepl_server/wrepl_server.c @@ -464,7 +464,7 @@ static void wreplsrv_task_init(struct task_server *task) } service->task = task; service->startup_time = timeval_current(); - task->private = service; + task->private_data = service; /* * setup up all partners, and open the winsdb |