diff options
Diffstat (limited to 'source4')
157 files changed, 6893 insertions, 2323 deletions
diff --git a/source4/Makefile b/source4/Makefile index f2567e6ac4..0ee36ec830 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -4,6 +4,8 @@ include mkconfig.mk +pidldir := $(srcdir)/pidl + VPATH = $(builddir):$(srcdir):heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des BASEDIR = $(prefix) @@ -25,7 +27,7 @@ $(srcdir)/version.h: $(srcdir)/VERSION .DEFAULT_GOAL := all ifneq ($(automatic_dependencies),yes) -ALL_PREDEP = proto +ALL_PREDEP = basics .NOTPARALLEL: endif @@ -41,7 +43,7 @@ pch:: clean_pch include/includes.h.gch .DEFAULT_GOAL := all ifneq ($(automatic_dependencies),yes) -ALL_PREDEP = proto +ALL_PREDEP = basics .NOTPARALLEL: endif diff --git a/source4/auth/config.mk b/source4/auth/config.mk index b13b8abf1f..7d31a6a0c0 100644 --- a/source4/auth/config.mk +++ b/source4/auth/config.mk @@ -1,4 +1,5 @@ # auth server subsystem +gensecsrcdir := $(authsrcdir)/gensec mkinclude gensec/config.mk mkinclude kerberos/config.mk mkinclude ntlmssp/config.mk @@ -6,35 +7,38 @@ mkinclude ntlm/config.mk mkinclude credentials/config.mk [SUBSYSTEM::auth_session] -PRIVATE_PROTO_HEADER = session_proto.h PUBLIC_DEPENDENCIES = CREDENTIALS -PUBLIC_HEADERS += auth/session.h +PUBLIC_HEADERS += $(authsrcdir)/session.h -auth_session_OBJ_FILES = $(addprefix auth/, session.o) +auth_session_OBJ_FILES = $(addprefix $(authsrcdir)/, session.o) + +$(eval $(call proto_header_template,$(authsrcdir)/session_proto.h,$(auth_session_OBJ_FILES:.o=.c))) [SUBSYSTEM::auth_system_session] -PRIVATE_PROTO_HEADER = system_session_proto.h PUBLIC_DEPENDENCIES = CREDENTIALS PRIVATE_DEPENDENCIES = auth_session LIBSAMBA-UTIL LIBSECURITY -auth_system_session_OBJ_FILES = $(addprefix auth/, system_session.o) +auth_system_session_OBJ_FILES = $(addprefix $(authsrcdir)/, system_session.o) +$(eval $(call proto_header_template,$(authsrcdir)/system_session_proto.h,$(auth_system_session_OBJ_FILES:.o=.c))) [SUBSYSTEM::auth_sam] -PRIVATE_PROTO_HEADER = auth_sam.h PUBLIC_DEPENDENCIES = SAMDB UTIL_LDB LIBSECURITY PRIVATE_DEPENDENCIES = LDAP_ENCODE -auth_sam_OBJ_FILES = $(addprefix auth/, sam.o) +auth_sam_OBJ_FILES = $(addprefix $(authsrcdir)/, sam.o) + +$(eval $(call proto_header_template,$(authsrcdir)/auth_sam.h,$(auth_sam_OBJ_FILES:.o=.c))) [SUBSYSTEM::auth_sam_reply] -PRIVATE_PROTO_HEADER = auth_sam_reply.h -auth_sam_reply_OBJ_FILES = $(addprefix auth/, auth_sam_reply.o) +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] PUBLIC_DEPENDENCIES = auth_system_session PRIVATE_DEPENDENCIES = SAMDB SWIG_FILE = auth.i -swig_auth_OBJ_FILES = auth/auth_wrap.o +swig_auth_OBJ_FILES = $(authsrcdir)/auth_wrap.o diff --git a/source4/auth/credentials/config.mk b/source4/auth/credentials/config.mk index 6f3ec3997c..d71a8238a5 100644 --- a/source4/auth/credentials/config.mk +++ b/source4/auth/credentials/config.mk @@ -1,18 +1,20 @@ ################################# # Start SUBSYSTEM CREDENTIALS [SUBSYSTEM::CREDENTIALS] -PRIVATE_PROTO_HEADER = credentials_proto.h PUBLIC_DEPENDENCIES = \ LIBCLI_AUTH SECRETS LIBCRYPTO KERBEROS UTIL_LDB HEIMDAL_GSSAPI PRIVATE_DEPENDENCIES = \ SECRETS -CREDENTIALS_OBJ_FILES = $(addprefix auth/credentials/, credentials.o credentials_files.o credentials_ntlm.o credentials_krb5.o ../kerberos/kerberos_util.o) -PUBLIC_HEADERS += auth/credentials/credentials.h +CREDENTIALS_OBJ_FILES = $(addprefix $(authsrcdir)/credentials/, credentials.o credentials_files.o credentials_ntlm.o credentials_krb5.o ../kerberos/kerberos_util.o) + +$(eval $(call proto_header_template,$(authsrcdir)/credentials/credentials_proto.h,$(CREDENTIALS_OBJ_FILES:.o=.c))) + +PUBLIC_HEADERS += $(authsrcdir)/credentials/credentials.h [PYTHON::swig_credentials] PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS SWIG_FILE = credentials.i -swig_credentials_OBJ_FILES = auth/credentials/credentials_wrap.o +swig_credentials_OBJ_FILES = $(authsrcdir)/credentials/credentials_wrap.o diff --git a/source4/auth/gensec/config.mk b/source4/auth/gensec/config.mk index 8b602e75f0..f08ff2638a 100644 --- a/source4/auth/gensec/config.mk +++ b/source4/auth/gensec/config.mk @@ -1,19 +1,20 @@ ################################# # Start SUBSYSTEM gensec [LIBRARY::gensec] -PRIVATE_PROTO_HEADER = gensec_proto.h PUBLIC_DEPENDENCIES = \ CREDENTIALS LIBSAMBA-UTIL LIBCRYPTO ASN1_UTIL samba-socket LIBPACKET # End SUBSYSTEM gensec ################################# -PC_FILES += auth/gensec/gensec.pc +PC_FILES += $(gensecsrcdir)/gensec.pc gensec_VERSION = 0.0.1 gensec_SOVERSION = 0 -gensec_OBJ_FILES = $(addprefix auth/gensec/, gensec.o socket.o) +gensec_OBJ_FILES = $(addprefix $(gensecsrcdir)/, gensec.o socket.o) -PUBLIC_HEADERS += auth/gensec/gensec.h +PUBLIC_HEADERS += $(gensecsrcdir)/gensec.h + +$(eval $(call proto_header_template,$(gensecsrcdir)/gensec_proto.h,$(gensec_OBJ_FILES:.o=.c))) ################################################ # Start MODULE gensec_krb5 @@ -24,7 +25,7 @@ PRIVATE_DEPENDENCIES = CREDENTIALS KERBEROS auth_session auth_sam # End MODULE gensec_krb5 ################################################ -gensec_krb5_OBJ_FILES = $(addprefix auth/gensec/, gensec_krb5.o) +gensec_krb5_OBJ_FILES = $(addprefix $(gensecsrcdir)/, gensec_krb5.o) ################################################ # Start MODULE gensec_gssapi @@ -35,7 +36,7 @@ PRIVATE_DEPENDENCIES = HEIMDAL_GSSAPI CREDENTIALS KERBEROS # End MODULE gensec_gssapi ################################################ -gensec_gssapi_OBJ_FILES = $(addprefix auth/gensec/, gensec_gssapi.o) +gensec_gssapi_OBJ_FILES = $(addprefix $(gensecsrcdir)/, gensec_gssapi.o) ################################################ # Start MODULE cyrus_sasl @@ -46,40 +47,41 @@ PRIVATE_DEPENDENCIES = CREDENTIALS SASL # End MODULE cyrus_sasl ################################################ -cyrus_sasl_OBJ_FILES = $(addprefix auth/gensec/, cyrus_sasl.o) +cyrus_sasl_OBJ_FILES = $(addprefix $(gensecsrcdir)/, cyrus_sasl.o) ################################################ # Start MODULE gensec_spnego [MODULE::gensec_spnego] SUBSYSTEM = gensec INIT_FUNCTION = gensec_spnego_init -PRIVATE_PROTO_HEADER = spnego_proto.h PRIVATE_DEPENDENCIES = ASN1_UTIL CREDENTIALS # End MODULE gensec_spnego ################################################ -gensec_spnego_OBJ_FILES = $(addprefix auth/gensec/, spnego.o spnego_parse.o) +gensec_spnego_OBJ_FILES = $(addprefix $(gensecsrcdir)/, spnego.o spnego_parse.o) + +$(eval $(call proto_header_template,$(gensecsrcdir)/spnego_proto.h,$(gensec_spnego_OBJ_FILES:.o=.c))) ################################################ # Start MODULE gensec_schannel [MODULE::gensec_schannel] SUBSYSTEM = gensec -PRIVATE_PROTO_HEADER = schannel_proto.h INIT_FUNCTION = gensec_schannel_init PRIVATE_DEPENDENCIES = SCHANNELDB NDR_SCHANNEL CREDENTIALS LIBNDR OUTPUT_TYPE = MERGED_OBJ # End MODULE gensec_schannel ################################################ -gensec_schannel_OBJ_FILES = $(addprefix auth/gensec/, schannel.o schannel_sign.o) +gensec_schannel_OBJ_FILES = $(addprefix $(gensecsrcdir)/, schannel.o schannel_sign.o) +$(eval $(call proto_header_template,$(gensecsrcdir)/schannel_proto.h,$(gensec_schannel_OBJ_FILES:.o=.c))) ################################################ # Start SUBSYSTEM SCHANNELDB [SUBSYSTEM::SCHANNELDB] -PRIVATE_PROTO_HEADER = schannel_state.h PRIVATE_DEPENDENCIES = LDB_WRAP SAMDB # End SUBSYSTEM SCHANNELDB ################################################ -SCHANNELDB_OBJ_FILES = $(addprefix auth/gensec/, schannel_state.o) +SCHANNELDB_OBJ_FILES = $(addprefix $(gensecsrcdir)/, schannel_state.o) +$(eval $(call proto_header_template,$(gensecsrcdir)/schannel_state.h,$(SCHANNELDB_OBJ_FILES:.o=.c))) diff --git a/source4/auth/kerberos/config.mk b/source4/auth/kerberos/config.mk index 762d6f8c49..951e247258 100644 --- a/source4/auth/kerberos/config.mk +++ b/source4/auth/kerberos/config.mk @@ -1,13 +1,12 @@ ################################# # Start SUBSYSTEM KERBEROS [SUBSYSTEM::KERBEROS] -PRIVATE_PROTO_HEADER = proto.h PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 NDR_KRB5PAC samba-socket LIBCLI_RESOLVE PRIVATE_DEPENDENCIES = ASN1_UTIL auth_sam_reply LIBPACKET LIBNDR # End SUBSYSTEM KERBEROS ################################# -KERBEROS_OBJ_FILES = $(addprefix auth/kerberos/, \ +KERBEROS_OBJ_FILES = $(addprefix $(authsrcdir)/kerberos/, \ kerberos.o \ clikrb5.o \ kerberos_heimdal.o \ @@ -15,3 +14,5 @@ KERBEROS_OBJ_FILES = $(addprefix auth/kerberos/, \ gssapi_parse.o \ krb5_init_context.o) +$(eval $(call proto_header_template,$(authsrcdir)/kerberos/proto.h,$(KERBEROS_OBJ_FILES:.o=.c))) + diff --git a/source4/auth/ntlm/config.mk b/source4/auth/ntlm/config.mk index 319aca7318..f31c2b7279 100644 --- a/source4/auth/ntlm/config.mk +++ b/source4/auth/ntlm/config.mk @@ -3,7 +3,7 @@ [SUBSYSTEM::ntlm_check] PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL -ntlm_check_OBJ_FILES = $(addprefix auth/ntlm/, ntlm_check.o) +ntlm_check_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, ntlm_check.o) ####################### # Start MODULE auth_sam @@ -16,7 +16,7 @@ PRIVATE_DEPENDENCIES = \ # End MODULE auth_sam ####################### -auth_sam_module_OBJ_FILES = $(addprefix auth/ntlm/, auth_sam.o) +auth_sam_module_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_sam.o) ####################### # Start MODULE auth_anonymous @@ -26,7 +26,7 @@ SUBSYSTEM = auth # End MODULE auth_anonymous ####################### -auth_anonymous_OBJ_FILES = $(addprefix auth/ntlm/, auth_anonymous.o) +auth_anonymous_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_anonymous.o) ####################### # Start MODULE auth_anonymous @@ -38,7 +38,7 @@ OUTPUT_TYPE = SHARED_LIBRARY # End MODULE auth_server ####################### -auth_server_OBJ_FILES = $(addprefix auth/ntlm/, auth_server.o) +auth_server_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_server.o) ####################### # Start MODULE auth_winbind @@ -49,7 +49,7 @@ PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING LIBWINBIND-CLIENT # End MODULE auth_winbind ####################### -auth_winbind_OBJ_FILES = $(addprefix auth/ntlm/, auth_winbind.o) +auth_winbind_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_winbind.o) ####################### # Start MODULE auth_developer @@ -59,29 +59,28 @@ SUBSYSTEM = auth # End MODULE auth_developer ####################### -auth_developer_OBJ_FILES = $(addprefix auth/ntlm/, auth_developer.o) +auth_developer_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_developer.o) [MODULE::auth_unix] INIT_FUNCTION = auth_unix_init SUBSYSTEM = auth PRIVATE_DEPENDENCIES = CRYPT PAM PAM_ERRORS NSS_WRAPPER -auth_unix_OBJ_FILES = $(addprefix auth/ntlm/, auth_unix.o) +auth_unix_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_unix.o) [SUBSYSTEM::PAM_ERRORS] -PRIVATE_PROTO_HEADER = pam_errors.h #VERSION = 0.0.1 #SO_VERSION = 0 -PAM_ERRORS_OBJ_FILES = $(addprefix auth/ntlm/, pam_errors.o) +PAM_ERRORS_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, pam_errors.o) [MODULE::auth] INIT_FUNCTION = server_service_auth_init SUBSYSTEM = service -PRIVATE_PROTO_HEADER = auth_proto.h PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSECURITY SAMDB CREDENTIALS -auth_OBJ_FILES = $(addprefix auth/ntlm/, auth.o auth_util.o auth_simple.o) +auth_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth.o auth_util.o auth_simple.o) +$(eval $(call proto_header_template,$(authsrcdir)/auth_proto.h,$(auth_OBJ_FILES:.o=.c))) # PUBLIC_HEADERS += auth/auth.h diff --git a/source4/auth/ntlm/pam_errors.h b/source4/auth/ntlm/pam_errors.h index 904950caa6..959e1f3517 100644 --- a/source4/auth/ntlm/pam_errors.h +++ b/source4/auth/ntlm/pam_errors.h @@ -1,16 +1,26 @@ +/* + * Unix SMB/CIFS implementation. + * PAM error mapping functions + * Copyright (C) Andrew Bartlett 2002 + * + * 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 __AUTH_NTLM_PAM_ERRORS_H__ #define __AUTH_NTLM_PAM_ERRORS_H__ -#undef _PRINTF_ATTRIBUTE -#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) -/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ - -/* this file contains prototypes for functions that are private - * to this subsystem or library. These functions should not be - * used outside this particular subsystem! */ - - -/* The following definitions come from auth/ntlm/pam_errors.c */ +/* The following definitions come from auth/pam_errors.c */ /***************************************************************************** @@ -32,8 +42,6 @@ NTSTATUS pam_to_nt_status(int pam_error); convert an NT status32 code to a PAM error *****************************************************************************/ int nt_status_to_pam(NTSTATUS nt_status); -#undef _PRINTF_ATTRIBUTE -#define _PRINTF_ATTRIBUTE(a1, a2) #endif /* __AUTH_NTLM_PAM_ERRORS_H__ */ diff --git a/source4/auth/ntlmssp/config.mk b/source4/auth/ntlmssp/config.mk index 849448f5bb..129f58de83 100644 --- a/source4/auth/ntlmssp/config.mk +++ b/source4/auth/ntlmssp/config.mk @@ -1,17 +1,19 @@ [SUBSYSTEM::MSRPC_PARSE] -PRIVATE_PROTO_HEADER = msrpc_parse.h -MSRPC_PARSE_OBJ_FILES = $(addprefix auth/ntlmssp/, ntlmssp_parse.o) +MSRPC_PARSE_OBJ_FILES = $(addprefix $(authsrcdir)/ntlmssp/, ntlmssp_parse.o) + +$(eval $(call proto_header_template,$(authsrcdir)/ntlmssp/msrpc_parse.h,$(MSRPC_PARSE_OBJ_FILES:.o=.c))) ################################################ # Start MODULE gensec_ntlmssp [MODULE::gensec_ntlmssp] SUBSYSTEM = gensec INIT_FUNCTION = gensec_ntlmssp_init -PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = MSRPC_PARSE CREDENTIALS auth OUTPUT_TYPE = MERGED_OBJ # End MODULE gensec_ntlmssp ################################################ -gensec_ntlmssp_OBJ_FILES = $(addprefix auth/ntlmssp/, ntlmssp.o ntlmssp_sign.o ntlmssp_client.o ntlmssp_server.o) +gensec_ntlmssp_OBJ_FILES = $(addprefix $(authsrcdir)/ntlmssp/, ntlmssp.o ntlmssp_sign.o ntlmssp_client.o ntlmssp_server.o) + +$(eval $(call proto_header_template,$(authsrcdir)/ntlmssp/proto.h,$(gensec_ntlmssp_OBJ_FILES:.o=.c))) diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4 index ba8251e65d..d932f09a69 100644 --- a/source4/build/m4/public.m4 +++ b/source4/build/m4/public.m4 @@ -12,6 +12,10 @@ dnl SMB_ENABLE(name,default_build) dnl dnl SMB_INCLUDE_MK(file) dnl +dnl SMB_WRITE_MAKEVARS(file) +dnl +dnl SMB_WRITE_PERLVARS(file) +dnl dnl ####################################################### dnl ### And now the implementation ### dnl ####################################################### @@ -150,3 +154,70 @@ $1_ENABLE = $2 SMB_INFO_ENABLES="$SMB_INFO_ENABLES \$enabled{$1} = \"$2\";" ]) + +dnl SMB_WRITE_MAKEVARS(path) +AC_DEFUN([SMB_WRITE_MAKEVARS], +[ +echo "configure: creating $1" +cat >$1<<CEOF +# $1 - Autogenerated by configure, DO NOT EDIT! +AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [ +AC_Var = $AC_Var]) +$MAKE_SETTINGS +CEOF +]) + +dnl SMB_WRITE_PERLVARS(path) +AC_DEFUN([SMB_WRITE_PERLVARS], +[ +echo "configure: creating $1" +cat >$1<<CEOF +# config.pm - Autogenerate by configure. DO NOT EDIT! + +package config; +require Exporter; +@ISA = qw(Exporter); +@EXPORT_OK = qw(%enabled %config); +use strict; + +use vars qw(%enabled %config); + +%config = (AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [ + AC_Var => '$AC_Var',]) +); + +$SMB_INFO_ENABLES +1; +CEOF +]) + +dnl SMB_BUILD_RUN(OUTPUT_FILE) +AC_DEFUN([SMB_BUILD_RUN], +[ +AC_OUTPUT_COMMANDS( +[ +test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && ( + cd $builddir; + # NOTE: We *must* use -R so we don't follow symlinks (at least on BSD + # systems). + test -d heimdal || cp -R $srcdir/heimdal $builddir/ + test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/ + test -d build || builddir="$builddir" \ + srcdir="$srcdir" \ + $PERL ${srcdir}/script/buildtree.pl + ) + +$PERL -I${builddir} -I${builddir}/build \ + -I${srcdir} -I${srcdir}/build \ + ${srcdir}/build/smb_build/main.pl --output=$1 main.mk || exit $? +], +[ +srcdir="$srcdir" +builddir="$builddir" +PERL="$PERL" + +export PERL +export srcdir +export builddir +]) +]) diff --git a/source4/build/make/rules.mk b/source4/build/make/rules.mk index c0359a8297..176e67a691 100644 --- a/source4/build/make/rules.mk +++ b/source4/build/make/rules.mk @@ -56,8 +56,6 @@ clean:: clean_pch @echo Removing generated files @-rm -f bin/*_init_module.c @-rm -rf librpc/gen_* - @echo Removing proto headers - @-rm -f $(PROTO_HEADERS) distclean:: clean -rm -f include/config.h include/config_tmp.h include/build.h @@ -88,102 +86,7 @@ unused_macros: @mkdir -p $(@D) @$(STLD) $(STLD_FLAGS) $@ $^ -############################################################################### -# Templates -############################################################################### - -# Partially link -# Arguments: target object file, source object files -define partial_link_template -$(1): $(2) ; - @echo Partially linking $$@ - @mkdir -p $$(@D) - $$(PARTLINK) -o $$@ $$^ -endef - -# Link a binary -# Arguments: target file, depends, flags -define binary_link_template -$(1): $(2) ; - @echo Linking $$@ - @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) -endef - -# Link a host-machine binary -# Arguments: target file, depends, flags -define host_binary_link_template -$(1): $(2) ; - @echo Linking $$@ - @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) -endef - -# Create a prototype header -# Arguments: header file, c files -define proto_header_template -$(1): $(2) ; - @echo "Creating $$@" - @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --public=/dev/null --private=$$@ $$^ -endef - -# Shared module -# Arguments: Target, dependencies, objects -define shared_module_template - -$(1): $(2) ; - @echo Linking $$@ - @mkdir -p $$(@D) - @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) - -endef - -# Shared library -# Arguments: Target, dependencies, link flags, soname -define shared_library_template -$(1): $(2) - @echo Linking $$@ - @mkdir -p $$(@D) - @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \ - $(3) \ - $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4))) - -ifneq ($(notdir $(1)),$(notdir $(4))) -$(4): $(1) - @echo "Creating symbolic link for $$@" - @ln -fs $$(<F) $$@ -endif - -ifneq ($(notdir $(1)),$(notdir $(5))) -$(5): $(1) - @echo "Creating symbolic link for $$@" - @ln -fs $$(<F) $$@ -endif -endef - -# Shared alias -# Arguments: Target, subsystem name, alias name -define shared_module_alias_template -bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1) - @ln -fs $$(<F) $$@ - -PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT) - -uninstallplugins:: - @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT) -installplugins:: - @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT) - -endef - -define shared_module_install_template -installplugins:: bin/modules/$(1)/$(2) - @echo Installing $(2) as $$(DESTDIR)$$(modulesdir)/$(1)/$(2) - @mkdir -p $$(DESTDIR)$$(modulesdir)/$(1)/ - @cp bin/modules/$(1)/$(2) $$(DESTDIR)$$(modulesdir)/$(1)/$(2) -uninstallplugins:: - @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2) - @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2) - -endef +include build/make/templates.mk ############################################################################### # File types diff --git a/source4/build/make/templates.mk b/source4/build/make/templates.mk new file mode 100644 index 0000000000..48678c5603 --- /dev/null +++ b/source4/build/make/templates.mk @@ -0,0 +1,108 @@ +# Templates file for Samba 4 +# This relies on GNU make. +# +# © 2008 Jelmer Vernooij <jelmer@samba.org> +# +############################################################################### +# Templates +############################################################################### + +# Partially link +# Arguments: target object file, source object files +define partial_link_template +$(1): $(2) ; + @echo Partially linking $$@ + @mkdir -p $$(@D) + $$(PARTLINK) -o $$@ $$^ +endef + +# Link a binary +# Arguments: target file, depends, flags +define binary_link_template +$(1): $(2) ; + @echo Linking $$@ + @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) +endef + +# Link a host-machine binary +# Arguments: target file, depends, flags +define host_binary_link_template +$(1): $(2) ; + @echo Linking $$@ + @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) +endef + +# Create a prototype header +# Arguments: header file, c files +define proto_header_template + +proto:: $(1) ; + +clean:: ; + rm -f $(1) + +$(1): $(2) ; + @echo "Creating $$@" + @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --public=/dev/null --private=$$@ $$^ + +endef + +# Shared module +# Arguments: Target, dependencies, objects +define shared_module_template + +$(1): $(2) ; + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) + +endef + +# Shared library +# Arguments: Target, dependencies, link flags, soname +define shared_library_template +$(1): $(2) + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \ + $(3) \ + $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4))) + +ifneq ($(notdir $(1)),$(notdir $(4))) +$(4): $(1) + @echo "Creating symbolic link for $$@" + @ln -fs $$(<F) $$@ +endif + +ifneq ($(notdir $(1)),$(notdir $(5))) +$(5): $(1) + @echo "Creating symbolic link for $$@" + @ln -fs $$(<F) $$@ +endif +endef + +# Shared alias +# Arguments: Target, subsystem name, alias name +define shared_module_alias_template +bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1) + @ln -fs $$(<F) $$@ + +PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT) + +uninstallplugins:: + @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT) +installplugins:: + @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT) + +endef + +define shared_module_install_template +installplugins:: bin/modules/$(1)/$(2) + @echo Installing $(2) as $$(DESTDIR)$$(modulesdir)/$(1)/$(2) + @mkdir -p $$(DESTDIR)$$(modulesdir)/$(1)/ + @cp bin/modules/$(1)/$(2) $$(DESTDIR)$$(modulesdir)/$(1)/$(2) +uninstallplugins:: + @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2) + @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2) + +endef diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm index 81c3363cfb..88e24a5876 100644 --- a/source4/build/smb_build/config_mk.pm +++ b/source4/build/smb_build/config_mk.pm @@ -33,8 +33,6 @@ my $section_types = { "ENABLE" => "bool", - "PRIVATE_PROTO_HEADER" => "string", - "CFLAGS" => "list", "LDFLAGS" => "list", "STANDARD_VISIBILITY" => "string", @@ -53,8 +51,6 @@ my $section_types = { "OUTPUT_TYPE" => "list", - "PRIVATE_PROTO_HEADER" => "string", - "CFLAGS" => "list" }, "BINARY" => { @@ -64,8 +60,6 @@ my $section_types = { "ENABLE" => "bool", "INSTALLDIR" => "string", - "PRIVATE_PROTO_HEADER" => "string", - "CFLAGS" => "list", "LDFLAGS" => "list", "STANDARD_VISIBILITY" => "string", @@ -84,8 +78,6 @@ my $section_types = { "ENABLE" => "bool", - "PRIVATE_PROTO_HEADER" => "string", - "CFLAGS" => "list", "LDFLAGS" => "list", "STANDARD_VISIBILITY" => "string" @@ -96,14 +88,11 @@ use vars qw(@parsed_files); @parsed_files = (); -sub _read_config_file +sub _read_config_file($$$) { - use File::Basename; use Cwd; - my $srcdir = shift; - my $builddir = shift; - my $filename = shift; + my ($srcdir, $builddir, $filename) = @_; my @dirlist; # We need to change our working directory because config.mk files can diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl index d31bea73f3..b31bfaa1f2 100644 --- a/source4/build/smb_build/main.pl +++ b/source4/build/smb_build/main.pl @@ -11,10 +11,22 @@ use smb_build::config_mk; use smb_build::output; use smb_build::summary; use smb_build::config; +use Getopt::Long; use strict; +my $output_file = "data.mk"; + +my $result = GetOptions ( + 'output=s' => \$output_file); + +if (not $result) { + exit(1); +} + +my $input_file = shift @ARGV; + my $INPUT = {}; -my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk"); +my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, $input_file); my $subsys_output_type = ["MERGED_OBJ"]; @@ -43,6 +55,7 @@ my $mkenv = new smb_build::makefile(\%config::config, $mkfile); my $shared_libs_used = 0; foreach my $key (values %$OUTPUT) { + next if ($key->{ENABLE} ne "YES"); push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_FILES)"); } @@ -80,11 +93,10 @@ foreach my $key (values %$OUTPUT) { grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}})); $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON"); $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}}); - $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}); $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS}); } -$mkenv->write("data.mk"); +$mkenv->write($output_file); summary::show($OUTPUT, \%config::config); diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index 4c375cecf6..a0fee2736b 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -223,15 +223,6 @@ sub PythonFiles($$) } } -sub ProtoHeader($$) -{ - my ($self,$ctx) = @_; - - my $target = "\$(addprefix $ctx->{BASEDIR}/, $ctx->{PRIVATE_PROTO_HEADER})"; - $self->output("PROTO_HEADERS += $target\n"); - $self->output("\$(call proto_header_template, $target, \$($ctx->{NAME}_OBJ_FILES:.o=.c))\n"); -} - sub write($$) { my ($self, $file) = @_; diff --git a/source4/cldap_server/config.mk b/source4/cldap_server/config.mk index 0773412bfd..137a44d0f7 100644 --- a/source4/cldap_server/config.mk +++ b/source4/cldap_server/config.mk @@ -5,14 +5,14 @@ [MODULE::CLDAPD] INIT_FUNCTION = server_service_cldapd_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_CLDAP LIBNETIF process_model # End SUBSYSTEM CLDAPD ####################### -CLDAPD_OBJ_FILES = $(addprefix cldap_server/, \ +CLDAPD_OBJ_FILES = $(addprefix $(cldap_serversrcdir)/, \ cldap_server.o \ netlogon.o \ rootdse.o) +$(eval $(call proto_header_template,$(cldap_serversrcdir)/proto.h,$(CLDAPD_OBJ_FILES:.o=.c))) diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c index a524a6f8bd..f263f33d48 100644 --- a/source4/cldap_server/netlogon.c +++ b/source4/cldap_server/netlogon.c @@ -4,6 +4,7 @@ CLDAP server - netlogon handling Copyright (C) Andrew Tridgell 2005 + Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,29 +29,33 @@ #include "cldap_server/cldap_server.h" #include "librpc/gen_ndr/ndr_misc.h" #include "libcli/ldap/ldap_ndr.h" +#include "libcli/security/security.h" #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "ldb_wrap.h" #include "system/network.h" #include "lib/socket/netif.h" #include "param/param.h" - /* fill in the cldap netlogon union for a given version */ -static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, - TALLOC_CTX *mem_ctx, - const char *domain, - const char *domain_guid, - const char *user, - const char *src_address, - uint32_t version, - struct loadparm_context *lp_ctx, - union nbt_cldap_netlogon *netlogon) +NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, + TALLOC_CTX *mem_ctx, + const char *domain, + const char *netbios_domain, + struct dom_sid *domain_sid, + const char *domain_guid, + const char *user, + uint32_t acct_control, + const char *src_address, + uint32_t version, + struct loadparm_context *lp_ctx, + struct netlogon_samlogon_response *netlogon) { const char *ref_attrs[] = {"nETBIOSName", "dnsRoot", "ncName", NULL}; const char *dom_attrs[] = {"objectGUID", NULL}; - struct ldb_result *ref_res = NULL, *dom_res = NULL; + const char *none_attrs[] = {NULL}; + struct ldb_result *ref_res = NULL, *dom_res = NULL, *user_res = NULL; int ret; const char **services = lp_server_services(lp_ctx); uint32_t server_type; @@ -65,8 +70,9 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, const char *pdc_ip; struct ldb_dn *partitions_basedn; struct interface *ifaces; + bool user_known; - partitions_basedn = samdb_partitions_dn(cldapd->samctx, mem_ctx); + partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx); /* the domain has an optional trailing . */ if (domain && domain[strlen(domain)-1] == '.') { @@ -77,7 +83,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, struct ldb_dn *dom_dn; /* try and find the domain */ - ret = ldb_search_exp_fmt(cldapd->samctx, mem_ctx, &ref_res, + ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res, partitions_basedn, LDB_SCOPE_ONELEVEL, ref_attrs, "(&(&(objectClass=crossRef)(dnsRoot=%s))(nETBIOSName=*))", @@ -86,19 +92,58 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, if (ret != LDB_SUCCESS) { DEBUG(2,("Unable to find referece to '%s' in sam: %s\n", domain, - ldb_errstring(cldapd->samctx))); + ldb_errstring(sam_ctx))); + return NT_STATUS_NO_SUCH_DOMAIN; + } else if (ref_res->count == 1) { + talloc_steal(mem_ctx, dom_res); + dom_dn = ldb_msg_find_attr_as_dn(sam_ctx, mem_ctx, ref_res->msgs[0], "ncName"); + if (!dom_dn) { + return NT_STATUS_NO_SUCH_DOMAIN; + } + ret = ldb_search(sam_ctx, dom_dn, + LDB_SCOPE_BASE, "objectClass=domain", + dom_attrs, &dom_res); + if (ret != LDB_SUCCESS) { + DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(sam_ctx))); + return NT_STATUS_NO_SUCH_DOMAIN; + } + talloc_steal(mem_ctx, dom_res); + if (dom_res->count != 1) { + DEBUG(2,("Error finding domain '%s'/'%s' in sam\n", domain, ldb_dn_get_linearized(dom_dn))); + return NT_STATUS_NO_SUCH_DOMAIN; + } + } else if (ref_res->count > 1) { + talloc_free(ref_res); + return NT_STATUS_NO_SUCH_DOMAIN; + } + } + + if (netbios_domain) { + struct ldb_dn *dom_dn; + /* try and find the domain */ + + ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res, + partitions_basedn, LDB_SCOPE_ONELEVEL, + ref_attrs, + "(&(objectClass=crossRef)(ncName=*)(nETBIOSName=%s))", + netbios_domain); + + if (ret != LDB_SUCCESS) { + DEBUG(2,("Unable to find referece to '%s' in sam: %s\n", + netbios_domain, + ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } else if (ref_res->count == 1) { talloc_steal(mem_ctx, dom_res); - dom_dn = ldb_msg_find_attr_as_dn(cldapd->samctx, mem_ctx, ref_res->msgs[0], "ncName"); + dom_dn = ldb_msg_find_attr_as_dn(sam_ctx, mem_ctx, ref_res->msgs[0], "ncName"); if (!dom_dn) { return NT_STATUS_NO_SUCH_DOMAIN; } - ret = ldb_search(cldapd->samctx, dom_dn, + ret = ldb_search(sam_ctx, dom_dn, LDB_SCOPE_BASE, "objectClass=domain", dom_attrs, &dom_res); if (ret != LDB_SUCCESS) { - DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(cldapd->samctx))); + DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } talloc_steal(mem_ctx, dom_res); @@ -112,23 +157,31 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, } } - if ((dom_res == NULL || dom_res->count == 0) && domain_guid) { + if ((dom_res == NULL || dom_res->count == 0) && (domain_guid || domain_sid)) { ref_res = NULL; - ret = ldb_search_exp_fmt(cldapd->samctx, mem_ctx, &dom_res, - NULL, LDB_SCOPE_SUBTREE, - dom_attrs, - "(&(objectClass=domainDNS)(objectGUID=%s))", - domain_guid); + if (domain_guid) { + ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &dom_res, + NULL, LDB_SCOPE_SUBTREE, + dom_attrs, + "(&(objectClass=domainDNS)(objectGUID=%s))", + domain_guid); + } else { /* domain_sid case */ + ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &dom_res, + NULL, LDB_SCOPE_SUBTREE, + dom_attrs, + "(&(objectClass=domainDNS)(objectSID=%s))", + dom_sid_string(mem_ctx, domain_sid)); + } if (ret != LDB_SUCCESS) { - DEBUG(2,("Unable to find referece to GUID '%s' in sam: %s\n", - domain_guid, - ldb_errstring(cldapd->samctx))); + DEBUG(2,("Unable to find referece to GUID '%s' or SID %s in sam: %s\n", + domain_guid, dom_sid_string(mem_ctx, domain_sid), + ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } else if (dom_res->count == 1) { /* try and find the domain */ - ret = ldb_search_exp_fmt(cldapd->samctx, mem_ctx, &ref_res, + ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res, partitions_basedn, LDB_SCOPE_ONELEVEL, ref_attrs, "(&(objectClass=crossRef)(ncName=%s))", @@ -137,7 +190,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, if (ret != LDB_SUCCESS) { DEBUG(2,("Unable to find referece to '%s' in sam: %s\n", ldb_dn_get_linearized(dom_res->msgs[0]->dn), - ldb_errstring(cldapd->samctx))); + ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } else if (ref_res->count != 1) { @@ -151,6 +204,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, } } + if ((ref_res == NULL || ref_res->count == 0)) { DEBUG(2,("Unable to find domain reference with name %s or GUID {%s}\n", domain, domain_guid)); return NT_STATUS_NO_SUCH_DOMAIN; @@ -161,16 +215,54 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, return NT_STATUS_NO_SUCH_DOMAIN; } + /* work around different inputs for not-specified users */ + if (!user) { + user = ""; + } + + /* Enquire about any valid username with just a CLDAP packet - + * if kerberos didn't also do this, the security folks would + * scream... */ + if (user[0]) { \ + /* Only allow some bits to be enquired: [MS-ATDS] 7.3.3.2 */ + if (acct_control == (uint32_t)-1) { + acct_control = 0; + } + acct_control = acct_control & (ACB_TEMPDUP | ACB_NORMAL | ACB_DOMTRUST | ACB_WSTRUST | ACB_SVRTRUST); + + /* We must exclude disabled accounts, but otherwise do the bitwise match the client asked for */ + ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &user_res, + dom_res->msgs[0]->dn, LDB_SCOPE_SUBTREE, + none_attrs, + "(&(objectClass=user)(samAccountName=%s)" + "(!(userAccountControl:" LDB_OID_COMPARATOR_AND ":=%u))" + "(userAccountControl:" LDB_OID_COMPARATOR_OR ":=%u))", + user, UF_ACCOUNTDISABLE, samdb_acb2uf(acct_control)); + if (ret != LDB_SUCCESS) { + DEBUG(2,("Unable to find referece to user '%s' with ACB 0x%8x under %s: %s\n", + user, acct_control, ldb_dn_get_linearized(dom_res->msgs[0]->dn), + ldb_errstring(sam_ctx))); + return NT_STATUS_NO_SUCH_USER; + } else if (user_res->count == 1) { + user_known = true; + } else { + user_known = false; + } + + } else { + user_known = true; + } + server_type = NBT_SERVER_DS | NBT_SERVER_TIMESERV | NBT_SERVER_CLOSEST | NBT_SERVER_WRITABLE | NBT_SERVER_GOOD_TIMESERV; - if (samdb_is_pdc(cldapd->samctx)) { + if (samdb_is_pdc(sam_ctx)) { server_type |= NBT_SERVER_PDC; } - if (samdb_is_gc(cldapd->samctx)) { + if (samdb_is_gc(sam_ctx)) { server_type |= NBT_SERVER_GC; } @@ -200,68 +292,75 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, ZERO_STRUCTP(netlogon); - switch (version & 0xF) { - case 0: - case 1: - netlogon->logon1.type = (user?19+2:19); - netlogon->logon1.pdc_name = pdc_name; - netlogon->logon1.user_name = user; - netlogon->logon1.domain_name = flatname; - netlogon->logon1.nt_version = 1; - netlogon->logon1.lmnt_token = 0xFFFF; - netlogon->logon1.lm20_token = 0xFFFF; - break; - case 2: - case 3: - netlogon->logon3.type = (user?19+2:19); - netlogon->logon3.pdc_name = pdc_name; - netlogon->logon3.user_name = user; - netlogon->logon3.domain_name = flatname; - netlogon->logon3.domain_uuid = domain_uuid; - netlogon->logon3.forest = realm; - netlogon->logon3.dns_domain = dns_domain; - netlogon->logon3.pdc_dns_name = pdc_dns_name; - netlogon->logon3.pdc_ip = pdc_ip; - netlogon->logon3.server_type = server_type; - netlogon->logon3.lmnt_token = 0xFFFF; - netlogon->logon3.lm20_token = 0xFFFF; - break; - case 4: - case 5: - case 6: - case 7: - netlogon->logon5.type = (user?NETLOGON_RESPONSE_FROM_PDC_USER:NETLOGON_RESPONSE_FROM_PDC2); - netlogon->logon5.server_type = server_type; - netlogon->logon5.domain_uuid = domain_uuid; - netlogon->logon5.forest = realm; - netlogon->logon5.dns_domain = dns_domain; - netlogon->logon5.pdc_dns_name = pdc_dns_name; - netlogon->logon5.domain = flatname; - netlogon->logon5.pdc_name = lp_netbios_name(lp_ctx); - netlogon->logon5.user_name = user; - netlogon->logon5.server_site = server_site; - netlogon->logon5.client_site = client_site; - netlogon->logon5.lmnt_token = 0xFFFF; - netlogon->logon5.lm20_token = 0xFFFF; - break; - default: - netlogon->logon13.type = (user?NETLOGON_RESPONSE_FROM_PDC_USER:NETLOGON_RESPONSE_FROM_PDC2); - netlogon->logon13.server_type = server_type; - netlogon->logon13.domain_uuid = domain_uuid; - netlogon->logon13.forest = realm; - netlogon->logon13.dns_domain = dns_domain; - netlogon->logon13.pdc_dns_name = pdc_dns_name; - netlogon->logon13.domain = flatname; - netlogon->logon13.pdc_name = lp_netbios_name(lp_ctx); - netlogon->logon13.user_name = user; - netlogon->logon13.server_site = server_site; - netlogon->logon13.client_site = client_site; - netlogon->logon13.unknown = 10; - netlogon->logon13.unknown2 = 2; - netlogon->logon13.pdc_ip = pdc_ip; - netlogon->logon13.lmnt_token = 0xFFFF; - netlogon->logon13.lm20_token = 0xFFFF; - break; + /* check if either of these bits is present */ + if (version & (NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_5EX_WITH_IP)) { + uint32_t extra_flags = 0; + netlogon->ntver = NETLOGON_NT_VERSION_5EX; + + /* could check if the user exists */ + if (user_known) { + netlogon->nt5_ex.command = LOGON_SAM_LOGON_RESPONSE_EX; + } else { + netlogon->nt5_ex.command = LOGON_SAM_LOGON_USER_UNKNOWN_EX; + } + netlogon->nt5_ex.server_type = server_type; + netlogon->nt5_ex.domain_uuid = domain_uuid; + netlogon->nt5_ex.forest = realm; + netlogon->nt5_ex.dns_domain = dns_domain; + netlogon->nt5_ex.pdc_dns_name = pdc_dns_name; + netlogon->nt5_ex.domain = flatname; + netlogon->nt5_ex.pdc_name = lp_netbios_name(lp_ctx); + netlogon->nt5_ex.user_name = user; + netlogon->nt5_ex.server_site = server_site; + netlogon->nt5_ex.client_site = client_site; + + if (version & NETLOGON_NT_VERSION_5EX_WITH_IP) { + /* Clearly this needs to be fixed up for IPv6 */ + extra_flags = NETLOGON_NT_VERSION_5EX_WITH_IP; + netlogon->nt5_ex.sockaddr.sa_family = 2; + netlogon->nt5_ex.sockaddr.pdc_ip = pdc_ip; + netlogon->nt5_ex.sockaddr.remaining = data_blob_talloc_zero(mem_ctx, 8); + } + netlogon->nt5_ex.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5EX|extra_flags; + netlogon->nt5_ex.lmnt_token = 0xFFFF; + netlogon->nt5_ex.lm20_token = 0xFFFF; + + } else if (version & NETLOGON_NT_VERSION_5) { + netlogon->ntver = NETLOGON_NT_VERSION_5; + + /* could check if the user exists */ + if (user_known) { + netlogon->nt5.command = LOGON_SAM_LOGON_RESPONSE; + } else { + netlogon->nt5.command = LOGON_SAM_LOGON_USER_UNKNOWN; + } + netlogon->nt5.pdc_name = pdc_name; + netlogon->nt5.user_name = user; + netlogon->nt5.domain_name = flatname; + netlogon->nt5.domain_uuid = domain_uuid; + netlogon->nt5.forest = realm; + netlogon->nt5.dns_domain = dns_domain; + netlogon->nt5.pdc_dns_name = pdc_dns_name; + netlogon->nt5.pdc_ip = pdc_ip; + netlogon->nt5.server_type = server_type; + netlogon->nt5.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5; + netlogon->nt5.lmnt_token = 0xFFFF; + netlogon->nt5.lm20_token = 0xFFFF; + + } else /* (version & NETLOGON_NT_VERSION_1) and all other cases */ { + netlogon->ntver = NETLOGON_NT_VERSION_1; + /* could check if the user exists */ + if (user_known) { + netlogon->nt4.command = LOGON_SAM_LOGON_RESPONSE; + } else { + netlogon->nt4.command = LOGON_SAM_LOGON_USER_UNKNOWN; + } + netlogon->nt4.server = pdc_name; + netlogon->nt4.user_name = user; + netlogon->nt4.domain = flatname; + netlogon->nt4.nt_version = NETLOGON_NT_VERSION_1; + netlogon->nt4.lmnt_token = 0xFFFF; + netlogon->nt4.lm20_token = 0xFFFF; } return NT_STATUS_OK; @@ -285,7 +384,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap, const char *domain_sid = NULL; int acct_control = -1; int version = -1; - union nbt_cldap_netlogon netlogon; + struct netlogon_samlogon_response netlogon; NTSTATUS status = NT_STATUS_INVALID_PARAMETER; TALLOC_CTX *tmp_ctx = talloc_new(cldap); @@ -346,9 +445,9 @@ void cldapd_netlogon_request(struct cldap_socket *cldap, DEBUG(5,("cldap netlogon query domain=%s host=%s user=%s version=%d guid=%s\n", domain, host, user, version, domain_guid)); - status = cldapd_netlogon_fill(cldapd, tmp_ctx, domain, domain_guid, - user, src->addr, - version, cldapd->task->lp_ctx, &netlogon); + status = fill_netlogon_samlogon_response(cldapd->samctx, tmp_ctx, domain, NULL, NULL, domain_guid, + user, acct_control, src->addr, + version, cldapd->task->lp_ctx, &netlogon); if (!NT_STATUS_IS_OK(status)) { goto failed; } diff --git a/source4/client/client.c b/source4/client/client.c index 120a80ccd2..01197e8a9e 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -214,15 +214,18 @@ check the space on a device ****************************************************************************/ static int do_dskattr(struct smbclient_context *ctx) { - int total, bsize, avail; + uint32_t bsize; + uint64_t total, avail; if (NT_STATUS_IS_ERR(smbcli_dskattr(ctx->cli->tree, &bsize, &total, &avail))) { d_printf("Error in dskattr: %s\n",smbcli_errstr(ctx->cli->tree)); return 1; } - d_printf("\n\t\t%d blocks of size %d. %d blocks available\n", - total, bsize, avail); + d_printf("\n\t\t%llu blocks of size %u. %llu blocks available\n", + (unsigned long long)total, + (unsigned)bsize, + (unsigned long long)avail); return 0; } diff --git a/source4/client/config.mk b/source4/client/config.mk index 5cfa542fba..877544a09a 100644 --- a/source4/client/config.mk +++ b/source4/client/config.mk @@ -18,7 +18,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY smbclient ################################# -smbclient_OBJ_FILES = client/client.o +smbclient_OBJ_FILES = $(clientsrcdir)/client.o ################################# # Start BINARY cifsdd @@ -33,4 +33,4 @@ PRIVATE_DEPENDENCIES = \ # End BINARY sdd ################################# -cifsdd_OBJ_FILES = client/cifsdd.o client/cifsddio.o +cifsdd_OBJ_FILES = $(addprefix $(clientsrcdir)/, cifsdd.o cifsddio.o) diff --git a/source4/cluster/config.mk b/source4/cluster/config.mk index 00ac597f94..e841956a0c 100644 --- a/source4/cluster/config.mk +++ b/source4/cluster/config.mk @@ -1,6 +1,7 @@ +ctdbsrcdir = $(clustersrcdir)/ctdb mkinclude ctdb/config.mk [SUBSYSTEM::CLUSTER] PRIVATE_DEPENDENCIES = ctdb -CLUSTER_OBJ_FILES = cluster/cluster.o cluster/local.o +CLUSTER_OBJ_FILES = $(addprefix $(clustersrcdir)/, cluster.o local.o) diff --git a/source4/cluster/ctdb/config.mk b/source4/cluster/ctdb/config.mk index 01c639d142..28b18c17ce 100644 --- a/source4/cluster/ctdb/config.mk +++ b/source4/cluster/ctdb/config.mk @@ -2,19 +2,19 @@ [SUBSYSTEM::brlock_ctdb] PUBLIC_DEPENDENCIES = ctdb -brlock_ctdb_OBJ_FILES = cluster/ctdb/brlock_ctdb.o +brlock_ctdb_OBJ_FILES = $(ctdbsrcdir)/brlock_ctdb.o ################## [SUBSYSTEM::opendb_ctdb] PUBLIC_DEPENDENCIES = ctdb -opendb_ctdb_OBJ_FILES = cluster/ctdb/opendb_ctdb.o +opendb_ctdb_OBJ_FILES = $(ctdbsrcdir)/opendb_ctdb.o ################## [SUBSYSTEM::ctdb] PUBLIC_DEPENDENCIES = TDB_WRAP LIBTALLOC -ctdb_OBJ_FILES = $(addprefix cluster/ctdb/, \ +ctdb_OBJ_FILES = $(addprefix $(ctdbsrcdir)/, \ ctdb_cluster.o \ client/ctdb_client.o \ common/ctdb_io.o \ diff --git a/source4/configure.ac b/source4/configure.ac index d07632a291..34657cf6f9 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -160,27 +160,9 @@ fi CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS" -echo "configure: creating build/smb_build/config.pm" -cat >build/smb_build/config.pm<<CEOF -# config.pm - Autogenerate by configure. DO NOT EDIT! +SMB_WRITE_PERLVARS(build/smb_build/config.pm) -package config; -require Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(%enabled %config); -use strict; - -use vars qw(%enabled %config); - -%config = (AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [ - AC_Var => '$AC_Var',]) -); - -$SMB_INFO_ENABLES -1; -CEOF - -echo "configure: creating config.mk" +../../source/echo "configure: creating config.mk" cat >config.mk<<CEOF # config.mk - Autogenerated by configure, DO NOT EDIT! $SMB_INFO_EXT_LIBS @@ -188,32 +170,7 @@ $SMB_INFO_SUBSYSTEMS $SMB_INFO_LIBRARIES CEOF -AC_OUTPUT_COMMANDS( -[ -test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && ( - cd $builddir; - # NOTE: We *must* use -R so we don't follow symlinks (at least on BSD - # systems). - test -d heimdal || cp -R $srcdir/heimdal $builddir/ - test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/ - test -d build || builddir="$builddir" \ - srcdir="$srcdir" \ - $PERL ${srcdir}/script/buildtree.pl - ) - -$PERL -I${builddir} -I${builddir}/build \ - -I${srcdir} -I${srcdir}/build \ - ${srcdir}/build/smb_build/main.pl || exit $? -], -[ -srcdir="$srcdir" -builddir="$builddir" -PERL="$PERL" - -export PERL -export srcdir -export builddir -]) +SMB_BUILD_RUN(data.mk) AC_OUTPUT cmp include/config_tmp.h include/config.h >/dev/null 2>&1 @@ -222,13 +179,7 @@ if test $CMP_RET != 0; then cp include/config_tmp.h include/config.h fi -echo "configure: creating mkconfig.mk" -cat >mkconfig.mk<<CEOF -# mkconfig.mk - Autogenerated by configure, DO NOT EDIT! -AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [ -AC_Var = $AC_Var]) -$MAKE_SETTINGS -CEOF +SMB_WRITE_MAKEVARS(mkconfig.mk) if test $USESHARED = true then diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk index e621391617..7b700fda22 100644 --- a/source4/dsdb/config.mk +++ b/source4/dsdb/config.mk @@ -5,39 +5,39 @@ mkinclude samdb/ldb_modules/config.mk ################################################ # Start SUBSYSTEM SAMDB [SUBSYSTEM::SAMDB] -PRIVATE_PROTO_HEADER = samdb/samdb_proto.h PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 PRIVATE_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI NDR_DRSBLOBS NSS_WRAPPER \ auth_system_session LDAP_ENCODE LIBCLI_AUTH LIBNDR \ SAMDB_SCHEMA LDB_WRAP SAMDB_COMMON -SAMDB_OBJ_FILES = $(addprefix dsdb/, \ +SAMDB_OBJ_FILES = $(addprefix $(dsdbsrcdir)/, \ samdb/samdb.o \ samdb/samdb_privilege.o \ samdb/cracknames.o \ repl/replicated_objects.o) +$(eval $(call proto_header_template,$(dsdbsrcdir)/samdb/samdb_proto.h,$(SAMDB_OBJ_FILES:.o=.c))) # PUBLIC_HEADERS += dsdb/samdb/samdb.h [SUBSYSTEM::SAMDB_COMMON] -PRIVATE_PROTO_HEADER = common/proto.h PRIVATE_DEPENDENCIES = LIBLDB -SAMDB_COMMON_OBJ_FILES = $(addprefix dsdb/common/, \ +SAMDB_COMMON_OBJ_FILES = $(addprefix $(dsdbsrcdir)/common/, \ sidmap.o \ flag_mapping.o \ util.o) +$(eval $(call proto_header_template,$(dsdbsrcdir)/common/proto.h,$(SAMDB_COMMON_OBJ_FILES:.o=.c))) [SUBSYSTEM::SAMDB_SCHEMA] -PRIVATE_PROTO_HEADER = schema/proto.h PRIVATE_DEPENDENCIES = SAMDB_COMMON NDR_DRSUAPI NDR_DRSBLOBS -SAMDB_SCHEMA_OBJ_FILES = $(addprefix dsdb/schema/, \ +SAMDB_SCHEMA_OBJ_FILES = $(addprefix $(dsdbsrcdir)/schema/, \ schema_init.o \ schema_syntax.o \ schema_constructed.o) +$(eval $(call proto_header_template,$(dsdbsrcdir)/schema/proto.h,$(SAMDB_SCHEMA_OBJ_FILES:.o=.c))) # PUBLIC_HEADERS += dsdb/schema/schema.h ####################### @@ -45,17 +45,17 @@ SAMDB_SCHEMA_OBJ_FILES = $(addprefix dsdb/schema/, \ [MODULE::DREPL_SRV] INIT_FUNCTION = server_service_drepl_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = repl/drepl_service_proto.h PRIVATE_DEPENDENCIES = \ SAMDB \ process_model # End SUBSYSTEM DREPL_SRV ####################### -DREPL_SRV_OBJ_FILES = $(addprefix dsdb/repl/, \ +DREPL_SRV_OBJ_FILES = $(addprefix $(dsdbsrcdir)/repl/, \ drepl_service.o \ drepl_periodic.o \ drepl_partitions.o \ drepl_out_pull.o \ drepl_out_helpers.o) +$(eval $(call proto_header_template,$(dsdbsrcdir)/repl/drepl_service_proto.h,$(DREPL_SRV_OBJ_FILES:.o=.c))) diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 9e02ef76c6..8370857aba 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -37,6 +37,7 @@ struct event_context; #include "dsdb/schema/schema.h" #include "dsdb/samdb/samdb_proto.h" #include "dsdb/common/proto.h" +#include "dsdb/common/flags.h" #define DSDB_CONTROL_CURRENT_PARTITION_OID "1.3.6.1.4.1.7165.4.3.2" struct dsdb_control_current_partition { diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk index 487d924036..f365911c6a 100644 --- a/source4/dynconfig.mk +++ b/source4/dynconfig.mk @@ -9,8 +9,11 @@ CONFIGFILE = $(sysconfdir)/smb.conf PKGCONFIGDIR = $(libdir)/pkgconfig LMHOSTSFILE = $(sysconfdir)/lmhosts -PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \ - -DBINDIR=\"$(bindir)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \ +dynconfig.o: dynconfig.c Makefile + @echo Compiling $< + @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) -c $< -o $@ \ + -DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(bindir)\" \ + -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \ -DLOCKDIR=\"$(lockdir)\" -DPIDDIR=\"$(piddir)\" -DDATADIR=\"$(datadir)\" \ -DLOGFILEBASE=\"$(logfilebase)\" \ -DCONFIGDIR=\"$(sysconfdir)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \ @@ -20,6 +23,4 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \ -DTORTUREDIR=\"$(TORTUREDIR)\" \ -DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(winbindd_socket_dir)\" -dynconfig.o: dynconfig.c Makefile - @echo Compiling $< - @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@ + diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk index fc46381a23..a4f24c9026 100644 --- a/source4/heimdal_build/config.mk +++ b/source4/heimdal_build/config.mk @@ -7,34 +7,35 @@ PUBLIC_DEPENDENCIES = HEIMDAL_NTLM HEIMDAL_HCRYPTO # End SUBSYSTEM HEIMDAL_KDC ####################### + HEIMDAL_KDC_OBJ_FILES = \ - ./heimdal/kdc/default_config.o \ - ./heimdal/kdc/kerberos5.o \ - ./heimdal/kdc/krb5tgs.o \ - ./heimdal/kdc/pkinit.o \ - ./heimdal/kdc/log.o \ - ./heimdal/kdc/misc.o \ - ./heimdal/kdc/524.o \ - ./heimdal/kdc/kerberos4.o \ - ./heimdal/kdc/kaserver.o \ - ./heimdal/kdc/digest.o \ - ./heimdal/kdc/process.o \ - ./heimdal/kdc/windc.o \ - ./heimdal/kdc/kx509.o + $(heimdalsrcdir)/kdc/default_config.o \ + $(heimdalsrcdir)/kdc/kerberos5.o \ + $(heimdalsrcdir)/kdc/krb5tgs.o \ + $(heimdalsrcdir)/kdc/pkinit.o \ + $(heimdalsrcdir)/kdc/log.o \ + $(heimdalsrcdir)/kdc/misc.o \ + $(heimdalsrcdir)/kdc/524.o \ + $(heimdalsrcdir)/kdc/kerberos4.o \ + $(heimdalsrcdir)/kdc/kaserver.o \ + $(heimdalsrcdir)/kdc/digest.o \ + $(heimdalsrcdir)/kdc/process.o \ + $(heimdalsrcdir)/kdc/windc.o \ + $(heimdalsrcdir)/kdc/kx509.o [SUBSYSTEM::HEIMDAL_NTLM] CFLAGS = -Iheimdal_build -Iheimdal/lib/ntlm PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5 HEIMDAL_NTLM_OBJ_FILES = \ - ./heimdal/lib/ntlm/ntlm.o + $(heimdalsrcdir)/lib/ntlm/ntlm.o [SUBSYSTEM::HEIMDAL_HDB_KEYS] CFLAGS = -Iheimdal_build -Iheimdal/lib/hdb PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5 \ HEIMDAL_HDB_ASN1 -HEIMDAL_HDB_KEYS_OBJ_FILES = ./heimdal/lib/hdb/keys.o +HEIMDAL_HDB_KEYS_OBJ_FILES = $(heimdalsrcdir)/lib/hdb/keys.o ####################### # Start SUBSYSTEM HEIMDAL_HDB @@ -45,14 +46,14 @@ PRIVATE_DEPENDENCIES = HDB_LDB HEIMDAL_KRB5 HEIMDAL_HDB_KEYS HEIMDAL_ROKEN HEIMD ####################### HEIMDAL_HDB_OBJ_FILES = \ - ./heimdal/lib/hdb/db.o \ - ./heimdal/lib/hdb/dbinfo.o \ - ./heimdal/lib/hdb/hdb.o \ - ./heimdal/lib/hdb/ext.o \ - ./heimdal/lib/hdb/keytab.o \ - ./heimdal/lib/hdb/mkey.o \ - ./heimdal/lib/hdb/ndbm.o \ - ./heimdal/lib/hdb/hdb_err.o + $(heimdalsrcdir)/lib/hdb/db.o \ + $(heimdalsrcdir)/lib/hdb/dbinfo.o \ + $(heimdalsrcdir)/lib/hdb/hdb.o \ + $(heimdalsrcdir)/lib/hdb/ext.o \ + $(heimdalsrcdir)/lib/hdb/keytab.o \ + $(heimdalsrcdir)/lib/hdb/mkey.o \ + $(heimdalsrcdir)/lib/hdb/ndbm.o \ + $(heimdalsrcdir)/lib/hdb/hdb_err.o ####################### # Start SUBSYSTEM HEIMDAL_GSSAPI @@ -64,112 +65,112 @@ PUBLIC_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_KRB5 ####################### HEIMDAL_GSSAPI_OBJ_FILES = \ - ./heimdal/lib/gssapi/mech/context.o \ - ./heimdal/lib/gssapi/mech/gss_krb5.o \ - ./heimdal/lib/gssapi/mech/gss_mech_switch.o \ - ./heimdal/lib/gssapi/mech/gss_process_context_token.o \ - ./heimdal/lib/gssapi/mech/gss_buffer_set.o \ - ./heimdal/lib/gssapi/mech/gss_add_cred.o \ - ./heimdal/lib/gssapi/mech/gss_add_oid_set_member.o \ - ./heimdal/lib/gssapi/mech/gss_compare_name.o \ - ./heimdal/lib/gssapi/mech/gss_release_oid_set.o \ - ./heimdal/lib/gssapi/mech/gss_create_empty_oid_set.o \ - ./heimdal/lib/gssapi/mech/gss_decapsulate_token.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_cred_by_oid.o \ - ./heimdal/lib/gssapi/mech/gss_canonicalize_name.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_sec_context_by_oid.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_names_for_mech.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_mechs_for_name.o \ - ./heimdal/lib/gssapi/mech/gss_wrap_size_limit.o \ - ./heimdal/lib/gssapi/mech/gss_names.o \ - ./heimdal/lib/gssapi/mech/gss_verify.o \ - ./heimdal/lib/gssapi/mech/gss_display_name.o \ - ./heimdal/lib/gssapi/mech/gss_duplicate_oid.o \ - ./heimdal/lib/gssapi/mech/gss_display_status.o \ - ./heimdal/lib/gssapi/mech/gss_release_buffer.o \ - ./heimdal/lib/gssapi/mech/gss_release_oid.o \ - ./heimdal/lib/gssapi/mech/gss_test_oid_set_member.o \ - ./heimdal/lib/gssapi/mech/gss_release_cred.o \ - ./heimdal/lib/gssapi/mech/gss_set_sec_context_option.o \ - ./heimdal/lib/gssapi/mech/gss_export_name.o \ - ./heimdal/lib/gssapi/mech/gss_seal.o \ - ./heimdal/lib/gssapi/mech/gss_acquire_cred.o \ - ./heimdal/lib/gssapi/mech/gss_unseal.o \ - ./heimdal/lib/gssapi/mech/gss_verify_mic.o \ - ./heimdal/lib/gssapi/mech/gss_accept_sec_context.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_cred_by_mech.o \ - ./heimdal/lib/gssapi/mech/gss_indicate_mechs.o \ - ./heimdal/lib/gssapi/mech/gss_delete_sec_context.o \ - ./heimdal/lib/gssapi/mech/gss_sign.o \ - ./heimdal/lib/gssapi/mech/gss_utils.o \ - ./heimdal/lib/gssapi/mech/gss_init_sec_context.o \ - ./heimdal/lib/gssapi/mech/gss_oid_equal.o \ - ./heimdal/lib/gssapi/mech/gss_oid_to_str.o \ - ./heimdal/lib/gssapi/mech/gss_context_time.o \ - ./heimdal/lib/gssapi/mech/gss_encapsulate_token.o \ - ./heimdal/lib/gssapi/mech/gss_get_mic.o \ - ./heimdal/lib/gssapi/mech/gss_import_sec_context.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_cred.o \ - ./heimdal/lib/gssapi/mech/gss_wrap.o \ - ./heimdal/lib/gssapi/mech/gss_import_name.o \ - ./heimdal/lib/gssapi/mech/gss_duplicate_name.o \ - ./heimdal/lib/gssapi/mech/gss_unwrap.o \ - ./heimdal/lib/gssapi/mech/gss_export_sec_context.o \ - ./heimdal/lib/gssapi/mech/gss_inquire_context.o \ - ./heimdal/lib/gssapi/mech/gss_release_name.o \ - ./heimdal/lib/gssapi/mech/gss_set_cred_option.o \ - ./heimdal/lib/gssapi/asn1_GSSAPIContextToken.o \ - ./heimdal/lib/gssapi/spnego/init_sec_context.o \ - ./heimdal/lib/gssapi/spnego/external.o \ - ./heimdal/lib/gssapi/spnego/compat.o \ - ./heimdal/lib/gssapi/spnego/context_stubs.o \ - ./heimdal/lib/gssapi/spnego/cred_stubs.o \ - ./heimdal/lib/gssapi/spnego/accept_sec_context.o \ - ./heimdal/lib/gssapi/krb5/copy_ccache.o \ - ./heimdal/lib/gssapi/krb5/delete_sec_context.o \ - ./heimdal/lib/gssapi/krb5/init_sec_context.o \ - ./heimdal/lib/gssapi/krb5/context_time.o \ - ./heimdal/lib/gssapi/krb5/init.o \ - ./heimdal/lib/gssapi/krb5/address_to_krb5addr.o \ - ./heimdal/lib/gssapi/krb5/get_mic.o \ - ./heimdal/lib/gssapi/krb5/inquire_context.o \ - ./heimdal/lib/gssapi/krb5/add_cred.o \ - ./heimdal/lib/gssapi/krb5/inquire_cred.o \ - ./heimdal/lib/gssapi/krb5/inquire_cred_by_oid.o \ - ./heimdal/lib/gssapi/krb5/inquire_cred_by_mech.o \ - ./heimdal/lib/gssapi/krb5/inquire_mechs_for_name.o \ - ./heimdal/lib/gssapi/krb5/inquire_names_for_mech.o \ - ./heimdal/lib/gssapi/krb5/indicate_mechs.o \ - ./heimdal/lib/gssapi/krb5/inquire_sec_context_by_oid.o \ - ./heimdal/lib/gssapi/krb5/export_sec_context.o \ - ./heimdal/lib/gssapi/krb5/import_sec_context.o \ - ./heimdal/lib/gssapi/krb5/duplicate_name.o \ - ./heimdal/lib/gssapi/krb5/import_name.o \ - ./heimdal/lib/gssapi/krb5/compare_name.o \ - ./heimdal/lib/gssapi/krb5/export_name.o \ - ./heimdal/lib/gssapi/krb5/canonicalize_name.o \ - ./heimdal/lib/gssapi/krb5/unwrap.o \ - ./heimdal/lib/gssapi/krb5/wrap.o \ - ./heimdal/lib/gssapi/krb5/release_name.o \ - ./heimdal/lib/gssapi/krb5/cfx.o \ - ./heimdal/lib/gssapi/krb5/8003.o \ - ./heimdal/lib/gssapi/krb5/arcfour.o \ - ./heimdal/lib/gssapi/krb5/encapsulate.o \ - ./heimdal/lib/gssapi/krb5/display_name.o \ - ./heimdal/lib/gssapi/krb5/sequence.o \ - ./heimdal/lib/gssapi/krb5/display_status.o \ - ./heimdal/lib/gssapi/krb5/release_buffer.o \ - ./heimdal/lib/gssapi/krb5/external.o \ - ./heimdal/lib/gssapi/krb5/compat.o \ - ./heimdal/lib/gssapi/krb5/acquire_cred.o \ - ./heimdal/lib/gssapi/krb5/release_cred.o \ - ./heimdal/lib/gssapi/krb5/set_cred_option.o \ - ./heimdal/lib/gssapi/krb5/decapsulate.o \ - ./heimdal/lib/gssapi/krb5/verify_mic.o \ - ./heimdal/lib/gssapi/krb5/accept_sec_context.o \ - ./heimdal/lib/gssapi/krb5/set_sec_context_option.o \ - ./heimdal/lib/gssapi/krb5/process_context_token.o \ - ./heimdal/lib/gssapi/krb5/prf.o + $(heimdalsrcdir)/lib/gssapi/mech/context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_krb5.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_mech_switch.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_process_context_token.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_buffer_set.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_add_cred.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_add_oid_set_member.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_compare_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_release_oid_set.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_create_empty_oid_set.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_decapsulate_token.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_cred_by_oid.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_canonicalize_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_sec_context_by_oid.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_names_for_mech.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_mechs_for_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_wrap_size_limit.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_names.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_verify.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_display_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_duplicate_oid.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_display_status.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_release_buffer.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_release_oid.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_test_oid_set_member.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_release_cred.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_set_sec_context_option.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_export_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_seal.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_acquire_cred.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_unseal.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_verify_mic.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_accept_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_cred_by_mech.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_indicate_mechs.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_delete_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_sign.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_utils.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_init_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_oid_equal.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_oid_to_str.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_context_time.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_encapsulate_token.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_get_mic.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_import_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_cred.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_wrap.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_import_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_duplicate_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_unwrap.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_export_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_context.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_release_name.o \ + $(heimdalsrcdir)/lib/gssapi/mech/gss_set_cred_option.o \ + $(heimdalsrcdir)/lib/gssapi/asn1_GSSAPIContextToken.o \ + $(heimdalsrcdir)/lib/gssapi/spnego/init_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/spnego/external.o \ + $(heimdalsrcdir)/lib/gssapi/spnego/compat.o \ + $(heimdalsrcdir)/lib/gssapi/spnego/context_stubs.o \ + $(heimdalsrcdir)/lib/gssapi/spnego/cred_stubs.o \ + $(heimdalsrcdir)/lib/gssapi/spnego/accept_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/copy_ccache.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/delete_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/init_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/context_time.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/init.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/address_to_krb5addr.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/get_mic.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/add_cred.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_cred.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_cred_by_oid.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_cred_by_mech.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_mechs_for_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_names_for_mech.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/indicate_mechs.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/inquire_sec_context_by_oid.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/export_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/import_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/duplicate_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/import_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/compare_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/export_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/canonicalize_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/unwrap.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/wrap.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/release_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/cfx.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/8003.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/arcfour.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/encapsulate.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/display_name.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/sequence.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/display_status.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/release_buffer.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/external.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/compat.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/acquire_cred.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/release_cred.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/set_cred_option.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/decapsulate.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/verify_mic.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/accept_sec_context.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/set_sec_context_option.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/process_context_token.o \ + $(heimdalsrcdir)/lib/gssapi/krb5/prf.o ####################### @@ -182,92 +183,92 @@ PUBLIC_DEPENDENCIES = HEIMDAL_KRB5_ASN1 HEIMDAL_GLUE HEIMDAL_HX509 HEIMDAL_HCRYP ####################### HEIMDAL_KRB5_OBJ_FILES = \ - ./heimdal/lib/krb5/acache.o \ - ./heimdal/lib/krb5/add_et_list.o \ - ./heimdal/lib/krb5/addr_families.o \ - ./heimdal/lib/krb5/appdefault.o \ - ./heimdal/lib/krb5/asn1_glue.o \ - ./heimdal/lib/krb5/auth_context.o \ - ./heimdal/lib/krb5/build_ap_req.o \ - ./heimdal/lib/krb5/build_auth.o \ - ./heimdal/lib/krb5/cache.o \ - ./heimdal/lib/krb5/changepw.o \ - ./heimdal/lib/krb5/codec.o \ - ./heimdal/lib/krb5/config_file.o \ - ./heimdal/lib/krb5/config_file_netinfo.o \ - ./heimdal/lib/krb5/constants.o \ - ./heimdal/lib/krb5/context.o \ - ./heimdal/lib/krb5/convert_creds.o \ - ./heimdal/lib/krb5/copy_host_realm.o \ - ./heimdal/lib/krb5/crc.o \ - ./heimdal/lib/krb5/creds.o \ - ./heimdal/lib/krb5/crypto.o \ - ./heimdal/lib/krb5/data.o \ - ./heimdal/lib/krb5/eai_to_heim_errno.o \ - ./heimdal/lib/krb5/error_string.o \ - ./heimdal/lib/krb5/expand_hostname.o \ - ./heimdal/lib/krb5/fcache.o \ - ./heimdal/lib/krb5/free.o \ - ./heimdal/lib/krb5/free_host_realm.o \ - ./heimdal/lib/krb5/generate_seq_number.o \ - ./heimdal/lib/krb5/generate_subkey.o \ - ./heimdal/lib/krb5/get_cred.o \ - ./heimdal/lib/krb5/get_default_principal.o \ - ./heimdal/lib/krb5/get_default_realm.o \ - ./heimdal/lib/krb5/get_for_creds.o \ - ./heimdal/lib/krb5/get_host_realm.o \ - ./heimdal/lib/krb5/get_in_tkt.o \ - ./heimdal/lib/krb5/get_in_tkt_with_keytab.o \ - ./heimdal/lib/krb5/get_port.o \ - ./heimdal/lib/krb5/init_creds.o \ - ./heimdal/lib/krb5/init_creds_pw.o \ - ./heimdal/lib/krb5/kcm.o \ - ./heimdal/lib/krb5/keyblock.o \ - ./heimdal/lib/krb5/keytab.o \ - ./heimdal/lib/krb5/keytab_any.o \ - ./heimdal/lib/krb5/keytab_file.o \ - ./heimdal/lib/krb5/keytab_memory.o \ - ./heimdal/lib/krb5/keytab_keyfile.o \ - ./heimdal/lib/krb5/keytab_krb4.o \ - ./heimdal/lib/krb5/krbhst.o \ - ./heimdal/lib/krb5/log.o \ - ./heimdal/lib/krb5/mcache.o \ - ./heimdal/lib/krb5/misc.o \ - ./heimdal/lib/krb5/mk_error.o \ - ./heimdal/lib/krb5/mk_priv.o \ - ./heimdal/lib/krb5/mk_rep.o \ - ./heimdal/lib/krb5/mk_req.o \ - ./heimdal/lib/krb5/mk_req_ext.o \ - ./heimdal/lib/krb5/mit_glue.o \ - ./heimdal/lib/krb5/n-fold.o \ - ./heimdal/lib/krb5/padata.o \ - ./heimdal/lib/krb5/pkinit.o \ - ./heimdal/lib/krb5/plugin.o \ - ./heimdal/lib/krb5/principal.o \ - ./heimdal/lib/krb5/pac.o \ - ./heimdal/lib/krb5/prompter_posix.o \ - ./heimdal/lib/krb5/rd_cred.o \ - ./heimdal/lib/krb5/rd_error.o \ - ./heimdal/lib/krb5/rd_priv.o \ - ./heimdal/lib/krb5/rd_rep.o \ - ./heimdal/lib/krb5/rd_req.o \ - ./heimdal/lib/krb5/replay.o \ - ./heimdal/lib/krb5/send_to_kdc.o \ - ./heimdal/lib/krb5/set_default_realm.o \ - ./heimdal/lib/krb5/store.o \ - ./heimdal/lib/krb5/store_emem.o \ - ./heimdal/lib/krb5/store_fd.o \ - ./heimdal/lib/krb5/store_mem.o \ - ./heimdal/lib/krb5/ticket.o \ - ./heimdal/lib/krb5/time.o \ - ./heimdal/lib/krb5/transited.o \ - ./heimdal/lib/krb5/v4_glue.o \ - ./heimdal/lib/krb5/version.o \ - ./heimdal/lib/krb5/warn.o \ - ./heimdal/lib/krb5/krb5_err.o \ - ./heimdal/lib/krb5/heim_err.o \ - ./heimdal/lib/krb5/k524_err.o \ - ./heimdal/lib/krb5/krb_err.o + $(heimdalsrcdir)/lib/krb5/acache.o \ + $(heimdalsrcdir)/lib/krb5/add_et_list.o \ + $(heimdalsrcdir)/lib/krb5/addr_families.o \ + $(heimdalsrcdir)/lib/krb5/appdefault.o \ + $(heimdalsrcdir)/lib/krb5/asn1_glue.o \ + $(heimdalsrcdir)/lib/krb5/auth_context.o \ + $(heimdalsrcdir)/lib/krb5/build_ap_req.o \ + $(heimdalsrcdir)/lib/krb5/build_auth.o \ + $(heimdalsrcdir)/lib/krb5/cache.o \ + $(heimdalsrcdir)/lib/krb5/changepw.o \ + $(heimdalsrcdir)/lib/krb5/codec.o \ + $(heimdalsrcdir)/lib/krb5/config_file.o \ + $(heimdalsrcdir)/lib/krb5/config_file_netinfo.o \ + $(heimdalsrcdir)/lib/krb5/constants.o \ + $(heimdalsrcdir)/lib/krb5/context.o \ + $(heimdalsrcdir)/lib/krb5/convert_creds.o \ + $(heimdalsrcdir)/lib/krb5/copy_host_realm.o \ + $(heimdalsrcdir)/lib/krb5/crc.o \ + $(heimdalsrcdir)/lib/krb5/creds.o \ + $(heimdalsrcdir)/lib/krb5/crypto.o \ + $(heimdalsrcdir)/lib/krb5/data.o \ + $(heimdalsrcdir)/lib/krb5/eai_to_heim_errno.o \ + $(heimdalsrcdir)/lib/krb5/error_string.o \ + $(heimdalsrcdir)/lib/krb5/expand_hostname.o \ + $(heimdalsrcdir)/lib/krb5/fcache.o \ + $(heimdalsrcdir)/lib/krb5/free.o \ + $(heimdalsrcdir)/lib/krb5/free_host_realm.o \ + $(heimdalsrcdir)/lib/krb5/generate_seq_number.o \ + $(heimdalsrcdir)/lib/krb5/generate_subkey.o \ + $(heimdalsrcdir)/lib/krb5/get_cred.o \ + $(heimdalsrcdir)/lib/krb5/get_default_principal.o \ + $(heimdalsrcdir)/lib/krb5/get_default_realm.o \ + $(heimdalsrcdir)/lib/krb5/get_for_creds.o \ + $(heimdalsrcdir)/lib/krb5/get_host_realm.o \ + $(heimdalsrcdir)/lib/krb5/get_in_tkt.o \ + $(heimdalsrcdir)/lib/krb5/get_in_tkt_with_keytab.o \ + $(heimdalsrcdir)/lib/krb5/get_port.o \ + $(heimdalsrcdir)/lib/krb5/init_creds.o \ + $(heimdalsrcdir)/lib/krb5/init_creds_pw.o \ + $(heimdalsrcdir)/lib/krb5/kcm.o \ + $(heimdalsrcdir)/lib/krb5/keyblock.o \ + $(heimdalsrcdir)/lib/krb5/keytab.o \ + $(heimdalsrcdir)/lib/krb5/keytab_any.o \ + $(heimdalsrcdir)/lib/krb5/keytab_file.o \ + $(heimdalsrcdir)/lib/krb5/keytab_memory.o \ + $(heimdalsrcdir)/lib/krb5/keytab_keyfile.o \ + $(heimdalsrcdir)/lib/krb5/keytab_krb4.o \ + $(heimdalsrcdir)/lib/krb5/krbhst.o \ + $(heimdalsrcdir)/lib/krb5/log.o \ + $(heimdalsrcdir)/lib/krb5/mcache.o \ + $(heimdalsrcdir)/lib/krb5/misc.o \ + $(heimdalsrcdir)/lib/krb5/mk_error.o \ + $(heimdalsrcdir)/lib/krb5/mk_priv.o \ + $(heimdalsrcdir)/lib/krb5/mk_rep.o \ + $(heimdalsrcdir)/lib/krb5/mk_req.o \ + $(heimdalsrcdir)/lib/krb5/mk_req_ext.o \ + $(heimdalsrcdir)/lib/krb5/mit_glue.o \ + $(heimdalsrcdir)/lib/krb5/n-fold.o \ + $(heimdalsrcdir)/lib/krb5/padata.o \ + $(heimdalsrcdir)/lib/krb5/pkinit.o \ + $(heimdalsrcdir)/lib/krb5/plugin.o \ + $(heimdalsrcdir)/lib/krb5/principal.o \ + $(heimdalsrcdir)/lib/krb5/pac.o \ + $(heimdalsrcdir)/lib/krb5/prompter_posix.o \ + $(heimdalsrcdir)/lib/krb5/rd_cred.o \ + $(heimdalsrcdir)/lib/krb5/rd_error.o \ + $(heimdalsrcdir)/lib/krb5/rd_priv.o \ + $(heimdalsrcdir)/lib/krb5/rd_rep.o \ + $(heimdalsrcdir)/lib/krb5/rd_req.o \ + $(heimdalsrcdir)/lib/krb5/replay.o \ + $(heimdalsrcdir)/lib/krb5/send_to_kdc.o \ + $(heimdalsrcdir)/lib/krb5/set_default_realm.o \ + $(heimdalsrcdir)/lib/krb5/store.o \ + $(heimdalsrcdir)/lib/krb5/store_emem.o \ + $(heimdalsrcdir)/lib/krb5/store_fd.o \ + $(heimdalsrcdir)/lib/krb5/store_mem.o \ + $(heimdalsrcdir)/lib/krb5/ticket.o \ + $(heimdalsrcdir)/lib/krb5/time.o \ + $(heimdalsrcdir)/lib/krb5/transited.o \ + $(heimdalsrcdir)/lib/krb5/v4_glue.o \ + $(heimdalsrcdir)/lib/krb5/version.o \ + $(heimdalsrcdir)/lib/krb5/warn.o \ + $(heimdalsrcdir)/lib/krb5/krb5_err.o \ + $(heimdalsrcdir)/lib/krb5/heim_err.o \ + $(heimdalsrcdir)/lib/krb5/k524_err.o \ + $(heimdalsrcdir)/lib/krb5/krb_err.o ####################### # Start SUBSYSTEM HEIMDAL_HEIM_ASN1 @@ -278,16 +279,16 @@ PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_COM_ERR ####################### HEIMDAL_HEIM_ASN1_OBJ_FILES = \ - ./heimdal/lib/asn1/der_get.o \ - ./heimdal/lib/asn1/der_put.o \ - ./heimdal/lib/asn1/der_free.o \ - ./heimdal/lib/asn1/der_format.o \ - ./heimdal/lib/asn1/der_length.o \ - ./heimdal/lib/asn1/der_copy.o \ - ./heimdal/lib/asn1/der_cmp.o \ - ./heimdal/lib/asn1/extra.o \ - ./heimdal/lib/asn1/timegm.o \ - ./heimdal/lib/asn1/asn1_err.o + $(heimdalsrcdir)/lib/asn1/der_get.o \ + $(heimdalsrcdir)/lib/asn1/der_put.o \ + $(heimdalsrcdir)/lib/asn1/der_free.o \ + $(heimdalsrcdir)/lib/asn1/der_format.o \ + $(heimdalsrcdir)/lib/asn1/der_length.o \ + $(heimdalsrcdir)/lib/asn1/der_copy.o \ + $(heimdalsrcdir)/lib/asn1/der_cmp.o \ + $(heimdalsrcdir)/lib/asn1/extra.o \ + $(heimdalsrcdir)/lib/asn1/timegm.o \ + $(heimdalsrcdir)/lib/asn1/asn1_err.o ####################### # Start SUBSYSTEM HEIMDAL_HCRYPTO_IMATH @@ -298,8 +299,8 @@ PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN ####################### HEIMDAL_HCRYPTO_IMATH_OBJ_FILES = \ - ./heimdal/lib/hcrypto/imath/imath.o \ - ./heimdal/lib/hcrypto/imath/iprime.o + $(heimdalsrcdir)/lib/hcrypto/imath/imath.o \ + $(heimdalsrcdir)/lib/hcrypto/imath/iprime.o [SUBSYSTEM::HEIMDAL_HCRYPTO] CFLAGS = -Iheimdal_build -Iheimdal/lib/hcrypto -Iheimdal/lib @@ -308,36 +309,36 @@ PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HEIM_ASN1 HEIMDAL_HCRYPTO_IMATH HEI ####################### HEIMDAL_HCRYPTO_OBJ_FILES = \ - ./heimdal/lib/hcrypto/aes.o \ - ./heimdal/lib/hcrypto/bn.o \ - ./heimdal/lib/hcrypto/dh.o \ - ./heimdal/lib/hcrypto/dh-imath.o \ - ./heimdal/lib/hcrypto/des.o \ - ./heimdal/lib/hcrypto/dsa.o \ - ./heimdal/lib/hcrypto/engine.o \ - ./heimdal/lib/hcrypto/md2.o \ - ./heimdal/lib/hcrypto/md4.o \ - ./heimdal/lib/hcrypto/md5.o \ - ./heimdal/lib/hcrypto/rsa.o \ - ./heimdal/lib/hcrypto/rsa-imath.o \ - ./heimdal/lib/hcrypto/rc2.o \ - ./heimdal/lib/hcrypto/rc4.o \ - ./heimdal/lib/hcrypto/rijndael-alg-fst.o \ - ./heimdal/lib/hcrypto/rnd_keys.o \ - ./heimdal/lib/hcrypto/sha.o \ - ./heimdal/lib/hcrypto/sha256.o \ - ./heimdal/lib/hcrypto/ui.o \ - ./heimdal/lib/hcrypto/evp.o \ - ./heimdal/lib/hcrypto/pkcs5.o \ - ./heimdal/lib/hcrypto/pkcs12.o \ - ./heimdal/lib/hcrypto/rand.o \ - ./heimdal/lib/hcrypto/rand-egd.o \ - ./heimdal/lib/hcrypto/rand-unix.o \ - ./heimdal/lib/hcrypto/rand-fortuna.o \ - ./heimdal/lib/hcrypto/rand-timer.o \ - ./heimdal/lib/hcrypto/hmac.o \ - ./heimdal/lib/hcrypto/camellia.o \ - ./heimdal/lib/hcrypto/camellia-ntt.o + $(heimdalsrcdir)/lib/hcrypto/aes.o \ + $(heimdalsrcdir)/lib/hcrypto/bn.o \ + $(heimdalsrcdir)/lib/hcrypto/dh.o \ + $(heimdalsrcdir)/lib/hcrypto/dh-imath.o \ + $(heimdalsrcdir)/lib/hcrypto/des.o \ + $(heimdalsrcdir)/lib/hcrypto/dsa.o \ + $(heimdalsrcdir)/lib/hcrypto/engine.o \ + $(heimdalsrcdir)/lib/hcrypto/md2.o \ + $(heimdalsrcdir)/lib/hcrypto/md4.o \ + $(heimdalsrcdir)/lib/hcrypto/md5.o \ + $(heimdalsrcdir)/lib/hcrypto/rsa.o \ + $(heimdalsrcdir)/lib/hcrypto/rsa-imath.o \ + $(heimdalsrcdir)/lib/hcrypto/rc2.o \ + $(heimdalsrcdir)/lib/hcrypto/rc4.o \ + $(heimdalsrcdir)/lib/hcrypto/rijndael-alg-fst.o \ + $(heimdalsrcdir)/lib/hcrypto/rnd_keys.o \ + $(heimdalsrcdir)/lib/hcrypto/sha.o \ + $(heimdalsrcdir)/lib/hcrypto/sha256.o \ + $(heimdalsrcdir)/lib/hcrypto/ui.o \ + $(heimdalsrcdir)/lib/hcrypto/evp.o \ + $(heimdalsrcdir)/lib/hcrypto/pkcs5.o \ + $(heimdalsrcdir)/lib/hcrypto/pkcs12.o \ + $(heimdalsrcdir)/lib/hcrypto/rand.o \ + $(heimdalsrcdir)/lib/hcrypto/rand-egd.o \ + $(heimdalsrcdir)/lib/hcrypto/rand-unix.o \ + $(heimdalsrcdir)/lib/hcrypto/rand-fortuna.o \ + $(heimdalsrcdir)/lib/hcrypto/rand-timer.o \ + $(heimdalsrcdir)/lib/hcrypto/hmac.o \ + $(heimdalsrcdir)/lib/hcrypto/camellia.o \ + $(heimdalsrcdir)/lib/hcrypto/camellia-ntt.o ####################### # Start SUBSYSTEM HEIMDAL_HX509 @@ -355,29 +356,29 @@ PRIVATE_DEPENDENCIES = \ ####################### HEIMDAL_HX509_OBJ_FILES = \ - ./heimdal/lib/hx509/ca.o \ - ./heimdal/lib/hx509/cert.o \ - ./heimdal/lib/hx509/cms.o \ - ./heimdal/lib/hx509/collector.o \ - ./heimdal/lib/hx509/crypto.o \ - ./heimdal/lib/hx509/error.o \ - ./heimdal/lib/hx509/env.o \ - ./heimdal/lib/hx509/file.o \ - ./heimdal/lib/hx509/keyset.o \ - ./heimdal/lib/hx509/ks_dir.o \ - ./heimdal/lib/hx509/ks_file.o \ - ./heimdal/lib/hx509/ks_keychain.o \ - ./heimdal/lib/hx509/ks_mem.o \ - ./heimdal/lib/hx509/ks_null.o \ - ./heimdal/lib/hx509/ks_p11.o \ - ./heimdal/lib/hx509/ks_p12.o \ - ./heimdal/lib/hx509/lock.o \ - ./heimdal/lib/hx509/name.o \ - ./heimdal/lib/hx509/peer.o \ - ./heimdal/lib/hx509/print.o \ - ./heimdal/lib/hx509/req.o \ - ./heimdal/lib/hx509/revoke.o \ - ./heimdal/lib/hx509/hx509_err.o + $(heimdalsrcdir)/lib/hx509/ca.o \ + $(heimdalsrcdir)/lib/hx509/cert.o \ + $(heimdalsrcdir)/lib/hx509/cms.o \ + $(heimdalsrcdir)/lib/hx509/collector.o \ + $(heimdalsrcdir)/lib/hx509/crypto.o \ + $(heimdalsrcdir)/lib/hx509/error.o \ + $(heimdalsrcdir)/lib/hx509/env.o \ + $(heimdalsrcdir)/lib/hx509/file.o \ + $(heimdalsrcdir)/lib/hx509/keyset.o \ + $(heimdalsrcdir)/lib/hx509/ks_dir.o \ + $(heimdalsrcdir)/lib/hx509/ks_file.o \ + $(heimdalsrcdir)/lib/hx509/ks_keychain.o \ + $(heimdalsrcdir)/lib/hx509/ks_mem.o \ + $(heimdalsrcdir)/lib/hx509/ks_null.o \ + $(heimdalsrcdir)/lib/hx509/ks_p11.o \ + $(heimdalsrcdir)/lib/hx509/ks_p12.o \ + $(heimdalsrcdir)/lib/hx509/lock.o \ + $(heimdalsrcdir)/lib/hx509/name.o \ + $(heimdalsrcdir)/lib/hx509/peer.o \ + $(heimdalsrcdir)/lib/hx509/print.o \ + $(heimdalsrcdir)/lib/hx509/req.o \ + $(heimdalsrcdir)/lib/hx509/revoke.o \ + $(heimdalsrcdir)/lib/hx509/hx509_err.o ####################### # Start SUBSYSTEM HEIMDAL_WIND @@ -387,37 +388,37 @@ PRIVATE_DEPENDENCIES = \ HEIMDAL_ROKEN HEIMDAL_COM_ERR HEIMDAL_WIND_OBJ_FILES = \ - ./heimdal/lib/wind/wind_err.o \ - ./heimdal/lib/wind/stringprep.o \ - ./heimdal/lib/wind/errorlist.o \ - ./heimdal/lib/wind/errorlist_table.o \ - ./heimdal/lib/wind/normalize.o \ - ./heimdal/lib/wind/normalize_table.o \ - ./heimdal/lib/wind/combining.o \ - ./heimdal/lib/wind/combining_table.o \ - ./heimdal/lib/wind/utf8.o \ - ./heimdal/lib/wind/bidi.o \ - ./heimdal/lib/wind/bidi_table.o \ - ./heimdal/lib/wind/ldap.o \ - ./heimdal/lib/wind/map.o \ - ./heimdal/lib/wind/map_table.o + $(heimdalsrcdir)/lib/wind/wind_err.o \ + $(heimdalsrcdir)/lib/wind/stringprep.o \ + $(heimdalsrcdir)/lib/wind/errorlist.o \ + $(heimdalsrcdir)/lib/wind/errorlist_table.o \ + $(heimdalsrcdir)/lib/wind/normalize.o \ + $(heimdalsrcdir)/lib/wind/normalize_table.o \ + $(heimdalsrcdir)/lib/wind/combining.o \ + $(heimdalsrcdir)/lib/wind/combining_table.o \ + $(heimdalsrcdir)/lib/wind/utf8.o \ + $(heimdalsrcdir)/lib/wind/bidi.o \ + $(heimdalsrcdir)/lib/wind/bidi_table.o \ + $(heimdalsrcdir)/lib/wind/ldap.o \ + $(heimdalsrcdir)/lib/wind/map.o \ + $(heimdalsrcdir)/lib/wind/map_table.o # End SUBSYSTEM HEIMDAL_WIND ####################### [SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME] CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper -HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES = ./heimdal/lib/roken/getprogname.o +HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.o [SUBSYSTEM::HEIMDAL_ROKEN_CLOSEFROM] CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper -HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES = ./heimdal/lib/roken/closefrom.o +HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES = $(heimdalsrcdir)/lib/roken/closefrom.o [SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME_H] CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper -HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES = ./heimdal/lib/roken/getprogname.ho +HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.ho ####################### # Start SUBSYSTEM HEIMDAL_ROKEN @@ -432,34 +433,34 @@ PUBLIC_DEPENDENCIES = \ ####################### HEIMDAL_ROKEN_OBJ_FILES = \ - ./heimdal/lib/roken/base64.o \ - ./heimdal/lib/roken/hex.o \ - ./heimdal/lib/roken/bswap.o \ - ./heimdal/lib/roken/dumpdata.o \ - ./heimdal/lib/roken/emalloc.o \ - ./heimdal/lib/roken/ecalloc.o \ - ./heimdal/lib/roken/get_window_size.o \ - ./heimdal/lib/roken/h_errno.o \ - ./heimdal/lib/roken/issuid.o \ - ./heimdal/lib/roken/net_read.o \ - ./heimdal/lib/roken/net_write.o \ - ./heimdal/lib/roken/socket.o \ - ./heimdal/lib/roken/parse_time.o \ - ./heimdal/lib/roken/parse_units.o \ - ./heimdal/lib/roken/resolve.o \ - ./heimdal/lib/roken/roken_gethostby.o \ - ./heimdal/lib/roken/signal.o \ - ./heimdal/lib/roken/vis.o \ - ./heimdal/lib/roken/strlwr.o \ - ./heimdal/lib/roken/strsep_copy.o \ - ./heimdal/lib/roken/strsep.o \ - ./heimdal/lib/roken/strupr.o \ - ./heimdal/lib/roken/strpool.o \ - ./heimdal/lib/roken/estrdup.o \ - ./heimdal/lib/roken/erealloc.o \ - ./heimdal/lib/roken/simple_exec.o \ - ./heimdal/lib/roken/strcollect.o \ - ./heimdal/lib/roken/rtbl.o \ + $(heimdalsrcdir)/lib/roken/base64.o \ + $(heimdalsrcdir)/lib/roken/hex.o \ + $(heimdalsrcdir)/lib/roken/bswap.o \ + $(heimdalsrcdir)/lib/roken/dumpdata.o \ + $(heimdalsrcdir)/lib/roken/emalloc.o \ + $(heimdalsrcdir)/lib/roken/ecalloc.o \ + $(heimdalsrcdir)/lib/roken/get_window_size.o \ + $(heimdalsrcdir)/lib/roken/h_errno.o \ + $(heimdalsrcdir)/lib/roken/issuid.o \ + $(heimdalsrcdir)/lib/roken/net_read.o \ + $(heimdalsrcdir)/lib/roken/net_write.o \ + $(heimdalsrcdir)/lib/roken/socket.o \ + $(heimdalsrcdir)/lib/roken/parse_time.o \ + $(heimdalsrcdir)/lib/roken/parse_units.o \ + $(heimdalsrcdir)/lib/roken/resolve.o \ + $(heimdalsrcdir)/lib/roken/roken_gethostby.o \ + $(heimdalsrcdir)/lib/roken/signal.o \ + $(heimdalsrcdir)/lib/roken/vis.o \ + $(heimdalsrcdir)/lib/roken/strlwr.o \ + $(heimdalsrcdir)/lib/roken/strsep_copy.o \ + $(heimdalsrcdir)/lib/roken/strsep.o \ + $(heimdalsrcdir)/lib/roken/strupr.o \ + $(heimdalsrcdir)/lib/roken/strpool.o \ + $(heimdalsrcdir)/lib/roken/estrdup.o \ + $(heimdalsrcdir)/lib/roken/erealloc.o \ + $(heimdalsrcdir)/lib/roken/simple_exec.o \ + $(heimdalsrcdir)/lib/roken/strcollect.o \ + $(heimdalsrcdir)/lib/roken/rtbl.o \ ./heimdal_build/replace.o ####################### @@ -481,8 +482,8 @@ PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN ####################### HEIMDAL_COM_ERR_OBJ_FILES = \ - ./heimdal/lib/com_err/com_err.o \ - ./heimdal/lib/com_err/error.o + $(heimdalsrcdir)/lib/com_err/com_err.o \ + $(heimdalsrcdir)/lib/com_err/error.o ####################### # Start SUBSYSTEM HEIMDAL_ASN1_COMPILE_LEX @@ -491,7 +492,7 @@ CFLAGS = -Iheimdal_build -Iheimdal/lib/asn1 -Iheimdal/lib/roken -Ilib/socket_wr # End SUBSYSTEM HEIMDAL_ASN1_COMPILE_LEX ####################### -HEIMDAL_ASN1_COMPILE_LEX_OBJ_FILES = ./heimdal/lib/asn1/lex.ho +HEIMDAL_ASN1_COMPILE_LEX_OBJ_FILES = $(heimdalsrcdir)/lib/asn1/lex.ho ####################### # Start BINARY asn1_compile @@ -501,26 +502,26 @@ USE_HOSTCC = YES PRIVATE_DEPENDENCIES = HEIMDAL_ASN1_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK asn1_compile_OBJ_FILES = \ - ./heimdal/lib/asn1/main.ho \ - ./heimdal/lib/asn1/gen.ho \ - ./heimdal/lib/asn1/gen_copy.ho \ - ./heimdal/lib/asn1/gen_decode.ho \ - ./heimdal/lib/asn1/gen_encode.ho \ - ./heimdal/lib/asn1/gen_free.ho \ - ./heimdal/lib/asn1/gen_glue.ho \ - ./heimdal/lib/asn1/gen_length.ho \ - ./heimdal/lib/asn1/gen_seq.ho \ - ./heimdal/lib/asn1/hash.ho \ - ./heimdal/lib/asn1/parse.ho \ - ./heimdal/lib/roken/emalloc.ho \ - ./heimdal/lib/roken/getarg.ho \ - ./heimdal/lib/roken/setprogname.ho \ - ./heimdal/lib/roken/strupr.ho \ - ./heimdal/lib/roken/get_window_size.ho \ - ./heimdal/lib/roken/estrdup.ho \ - ./heimdal/lib/roken/ecalloc.ho \ - ./heimdal/lib/asn1/symbol.ho \ - ./heimdal/lib/vers/print_version.ho \ + $(heimdalsrcdir)/lib/asn1/main.ho \ + $(heimdalsrcdir)/lib/asn1/gen.ho \ + $(heimdalsrcdir)/lib/asn1/gen_copy.ho \ + $(heimdalsrcdir)/lib/asn1/gen_decode.ho \ + $(heimdalsrcdir)/lib/asn1/gen_encode.ho \ + $(heimdalsrcdir)/lib/asn1/gen_free.ho \ + $(heimdalsrcdir)/lib/asn1/gen_glue.ho \ + $(heimdalsrcdir)/lib/asn1/gen_length.ho \ + $(heimdalsrcdir)/lib/asn1/gen_seq.ho \ + $(heimdalsrcdir)/lib/asn1/hash.ho \ + $(heimdalsrcdir)/lib/asn1/parse.ho \ + $(heimdalsrcdir)/lib/roken/emalloc.ho \ + $(heimdalsrcdir)/lib/roken/getarg.ho \ + $(heimdalsrcdir)/lib/roken/setprogname.ho \ + $(heimdalsrcdir)/lib/roken/strupr.ho \ + $(heimdalsrcdir)/lib/roken/get_window_size.ho \ + $(heimdalsrcdir)/lib/roken/estrdup.ho \ + $(heimdalsrcdir)/lib/roken/ecalloc.ho \ + $(heimdalsrcdir)/lib/asn1/symbol.ho \ + $(heimdalsrcdir)/lib/vers/print_version.ho \ ./lib/socket_wrapper/socket_wrapper.ho \ ./heimdal_build/replace.ho @@ -534,7 +535,7 @@ CFLAGS = -Iheimdal_build -Iheimdal/lib/com_err -Iheimdal/lib/roken -Ilib/socket # End SUBSYSTEM HEIMDAL_COM_ERR_COMPILE_LEX ####################### -HEIMDAL_COM_ERR_COMPILE_LEX_OBJ_FILES = ./heimdal/lib/com_err/lex.ho +HEIMDAL_COM_ERR_COMPILE_LEX_OBJ_FILES = $(heimdalsrcdir)/lib/com_err/lex.ho ####################### # Start BINARY compile_et @@ -545,13 +546,13 @@ PRIVATE_DEPENDENCIES = HEIMDAL_COM_ERR_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H L # End BINARY compile_et ####################### -compile_et_OBJ_FILES = ./heimdal/lib/vers/print_version.ho \ - ./heimdal/lib/com_err/parse.ho \ - ./heimdal/lib/com_err/compile_et.ho \ - ./heimdal/lib/roken/getarg.ho \ - ./heimdal/lib/roken/get_window_size.ho \ - ./heimdal/lib/roken/strupr.ho \ - ./heimdal/lib/roken/setprogname.ho \ +compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \ + $(heimdalsrcdir)/lib/com_err/parse.ho \ + $(heimdalsrcdir)/lib/com_err/compile_et.ho \ + $(heimdalsrcdir)/lib/roken/getarg.ho \ + $(heimdalsrcdir)/lib/roken/get_window_size.ho \ + $(heimdalsrcdir)/lib/roken/strupr.ho \ + $(heimdalsrcdir)/lib/roken/setprogname.ho \ ./lib/socket_wrapper/socket_wrapper.ho \ ./heimdal_build/replace.ho @@ -596,7 +597,7 @@ PUBLIC_DEPENDENCIES = \ # End SUBSYSTEM HEIMDAL ####################### -HEIMDAL_OBJ_FILES = ./heimdal/lib/vers/print_version.o +HEIMDAL_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.o ####################### # Start BINARY compile_et @@ -606,10 +607,10 @@ PRIVATE_DEPENDENCIES = HEIMDAL_KRB5 HEIMDAL_NTLM # End BINARY compile_et ####################### -samba4kinit_OBJ_FILES = ./heimdal/kuser/kinit.o \ - ./heimdal/lib/vers/print_version.o \ - ./heimdal/lib/roken/setprogname.o \ - ./heimdal/lib/roken/getarg.o +samba4kinit_OBJ_FILES = $(heimdalsrcdir)/kuser/kinit.o \ + $(heimdalsrcdir)/lib/vers/print_version.o \ + $(heimdalsrcdir)/lib/roken/setprogname.o \ + $(heimdalsrcdir)/lib/roken/getarg.o -dist:: heimdal/lib/asn1/lex.c heimdal/lib/com_err/lex.c \ - heimdal/lib/asn1/parse.c heimdal/lib/com_err/parse.c +dist:: $(heimdalsrcdir)/lib/asn1/lex.c $(heimdalsrcdir)/lib/com_err/lex.c \ + $(heimdalsrcdir)/lib/asn1/parse.c $(heimdalsrcdir)/lib/com_err/parse.c diff --git a/source4/kdc/config.mk b/source4/kdc/config.mk index 7a96cf6432..b3b8b216f0 100644 --- a/source4/kdc/config.mk +++ b/source4/kdc/config.mk @@ -10,17 +10,17 @@ PRIVATE_DEPENDENCIES = \ # End SUBSYSTEM KDC ####################### -KDC_OBJ_FILES = $(addprefix kdc/, kdc.o kpasswdd.o) +KDC_OBJ_FILES = $(addprefix $(kdcsrcdir)/, kdc.o kpasswdd.o) ####################### # Start SUBSYSTEM KDC [SUBSYSTEM::HDB_LDB] CFLAGS = -Iheimdal/kdc -Iheimdal/lib/hdb -PRIVATE_PROTO_HEADER = pac_glue.h PRIVATE_DEPENDENCIES = \ LIBLDB auth_sam auth_sam_reply HEIMDAL CREDENTIALS \ HEIMDAL_HDB_ASN1 # End SUBSYSTEM KDC ####################### -HDB_LDB_OBJ_FILES = $(addprefix kdc/, hdb-ldb.o pac-glue.o) +HDB_LDB_OBJ_FILES = $(addprefix $(kdcsrcdir)/, hdb-ldb.o pac-glue.o) +$(eval $(call proto_header_template,$(kdcsrcdir)/pac_glue.h,$(HDB_LDB_OBJ_FILES:.o=.c))) diff --git a/source4/ldap_server/config.mk b/source4/ldap_server/config.mk index 47eb85cab9..65f5b17f9a 100644 --- a/source4/ldap_server/config.mk +++ b/source4/ldap_server/config.mk @@ -5,7 +5,6 @@ [MODULE::LDAP] INIT_FUNCTION = server_service_ldap_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = CREDENTIALS \ LIBCLI_LDAP SAMDB \ process_model \ @@ -14,9 +13,10 @@ PRIVATE_DEPENDENCIES = CREDENTIALS \ # End SUBSYSTEM SMB ####################### -LDAP_OBJ_FILES = $(addprefix ldap_server/, \ +LDAP_OBJ_FILES = $(addprefix $(ldap_serversrcdir)/, \ ldap_server.o \ ldap_backend.o \ ldap_bind.o \ ldap_extended.o) +$(eval $(call proto_header_template,$(ldap_serversrcdir)/proto.h,$(LDAP_OBJ_FILES:.o=.c))) diff --git a/source4/lib/appweb/config.mk b/source4/lib/appweb/config.mk index c0bba35ba5..4d27b69fb5 100644 --- a/source4/lib/appweb/config.mk +++ b/source4/lib/appweb/config.mk @@ -4,7 +4,7 @@ # End SUBSYSTEM MPR ####################### -MPR_OBJ_FILES = $(addprefix lib/appweb/mpr/, miniMpr.o var.o) +MPR_OBJ_FILES = $(addprefix $(appwebsrcdir)/mpr/, miniMpr.o var.o) ####################### # Start SUBSYSTEM EJS @@ -13,7 +13,7 @@ PUBLIC_DEPENDENCIES = MPR # End SUBSYSTEM EJS ####################### -EJS_OBJ_FILES = $(addprefix lib/appweb/ejs/, ejsLib.o ejsLex.o ejsParser.o ejsProcs.o) +EJS_OBJ_FILES = $(addprefix $(appwebsrcdir)/ejs/, ejsLib.o ejsLex.o ejsParser.o ejsProcs.o) ####################### # Start SUBSYSTEM ESP @@ -22,4 +22,4 @@ PUBLIC_DEPENDENCIES = EJS # End SUBSYSTEM ESP ####################### -ESP_OBJ_FILES = $(addprefix lib/appweb/esp/, esp.o espProcs.o) +ESP_OBJ_FILES = $(addprefix $(appwebsrcdir)/esp/, esp.o espProcs.o) diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index e7e0ba80c4..b86df5dc9f 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -1,45 +1,25 @@ -# LIB BASIC subsystem -mkinclude samba3/config.mk -mkinclude socket/config.mk -mkinclude charset/config.mk -mkinclude ldb-samba/config.mk -mkinclude tls/config.mk -mkinclude registry/config.mk -mkinclude messaging/config.mk -mkinclude events/config.mk -mkinclude cmdline/config.mk -mkinclude socket_wrapper/config.mk -mkinclude nss_wrapper/config.mk -mkinclude appweb/config.mk -mkinclude stream/config.mk -mkinclude util/config.mk -mkinclude tdr/config.mk -mkinclude dbwrap/config.mk -mkinclude crypto/config.mk -mkinclude torture/config.mk - [SUBSYSTEM::LIBCOMPRESSION] -LIBCOMPRESSION_OBJ_FILES = lib/compression/mszip.o +LIBCOMPRESSION_OBJ_FILES = $(libcompressionsrcdir)/mszip.o [SUBSYSTEM::GENCACHE] PRIVATE_DEPENDENCIES = TDB_WRAP -GENCACHE_OBJ_FILES = gencache/gencache.o +GENCACHE_OBJ_FILES = $(libgencachesrcdir)/gencache.o -# PUBLIC_HEADERS += lib/gencache/gencache.h +# PUBLIC_HEADERS += $(libgencachesrcdir)/gencache.h [SUBSYSTEM::LDB_WRAP] PUBLIC_DEPENDENCIES = LIBLDB PRIVATE_DEPENDENCIES = LDBSAMBA UTIL_LDB -LDB_WRAP_OBJ_FILES = lib/ldb_wrap.o -PUBLIC_HEADERS += lib/ldb_wrap.h +LDB_WRAP_OBJ_FILES = $(libsrcdir)/ldb_wrap.o +PUBLIC_HEADERS += $(libsrcdir)/ldb_wrap.h [SUBSYSTEM::TDB_WRAP] PUBLIC_DEPENDENCIES = LIBTDB -TDB_WRAP_OBJ_FILES = lib/tdb_wrap.o -PUBLIC_HEADERS += lib/tdb_wrap.h +TDB_WRAP_OBJ_FILES = $(libsrcdir)/tdb_wrap.o +PUBLIC_HEADERS += $(libsrcdir)/tdb_wrap.h SMBREADLINE_OBJ_LIST = $(SMBREADLINE_OBJ_FILES) diff --git a/source4/lib/charset/config.mk b/source4/lib/charset/config.mk index e5e5bd4560..12c2f5f321 100644 --- a/source4/lib/charset/config.mk +++ b/source4/lib/charset/config.mk @@ -1,12 +1,13 @@ ################################################ # Start SUBSYSTEM CHARSET [SUBSYSTEM::CHARSET] -PRIVATE_PROTO_HEADER = charset_proto.h PUBLIC_DEPENDENCIES = ICONV PRIVATE_DEPENDENCIES = DYNCONFIG # End SUBSYSTEM CHARSET ################################################ -CHARSET_OBJ_FILES = $(addprefix lib/charset/, iconv.o charcnv.o util_unistr.o) +CHARSET_OBJ_FILES = $(addprefix $(libcharsetsrcdir)/, iconv.o charcnv.o util_unistr.o) -PUBLIC_HEADERS += lib/charset/charset.h +PUBLIC_HEADERS += $(libcharsetsrcdir)/charset.h + +$(eval $(call proto_header_template,$(libcharsetsrcdir)/charset_proto.h,$(CHARSET_OBJ_FILES:.o=.c))) diff --git a/source4/lib/cmdline/config.mk b/source4/lib/cmdline/config.mk index f8a971a063..4434ff3701 100644 --- a/source4/lib/cmdline/config.mk +++ b/source4/lib/cmdline/config.mk @@ -1,19 +1,21 @@ [SUBSYSTEM::LIBCMDLINE_CREDENTIALS] -PRIVATE_PROTO_HEADER = credentials.h PUBLIC_DEPENDENCIES = CREDENTIALS LIBPOPT -LIBCMDLINE_CREDENTIALS_OBJ_FILES = lib/cmdline/credentials.o +LIBCMDLINE_CREDENTIALS_OBJ_FILES = $(libcmdlinesrcdir)/credentials.o + +$(eval $(call proto_header_template,$(libcmdlinesrcdir)/credentials.h,$(LIBCMDLINE_CREDENTIALS_OBJ_FILES:.o=.c))) [SUBSYSTEM::POPT_SAMBA] PUBLIC_DEPENDENCIES = LIBPOPT -POPT_SAMBA_OBJ_FILES = lib/cmdline/popt_common.o +POPT_SAMBA_OBJ_FILES = $(libcmdlinesrcdir)/popt_common.o -PUBLIC_HEADERS += lib/cmdline/popt_common.h +PUBLIC_HEADERS += $(libcmdlinesrcdir)/popt_common.h [SUBSYSTEM::POPT_CREDENTIALS] -PRIVATE_PROTO_HEADER = popt_credentials.h PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS LIBPOPT PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL -POPT_CREDENTIALS_OBJ_FILES = lib/cmdline/popt_credentials.o +POPT_CREDENTIALS_OBJ_FILES = $(libcmdlinesrcdir)/popt_credentials.o + +$(eval $(call proto_header_template,$(libcmdlinesrcdir)/popt_credentials.h,$(POPT_CREDENTIALS_OBJ_FILES:.o=.c))) diff --git a/source4/lib/crypto/config.mk b/source4/lib/crypto/config.mk index 8e0cba17f0..b9a7f7cb9e 100644 --- a/source4/lib/crypto/config.mk +++ b/source4/lib/crypto/config.mk @@ -4,7 +4,7 @@ # End SUBSYSTEM LIBCRYPTO ############################## -LIBCRYPTO_OBJ_FILES = $(addprefix lib/crypto/, \ +LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \ crc32.o md5.o hmacmd5.o md4.o \ arcfour.o sha1.o hmacsha1.o) @@ -12,8 +12,8 @@ LIBCRYPTO_OBJ_FILES = $(addprefix lib/crypto/, \ [MODULE::TORTURE_LIBCRYPTO] SUBSYSTEM = smbtorture PRIVATE_DEPENDENCIES = LIBCRYPTO -PRIVATE_PROTO_HEADER = test_proto.h -TORTURE_LIBCRYPTO_OBJ_FILES = $(addprefix lib/crypto/, \ +TORTURE_LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \ md4test.o md5test.o hmacmd5test.o sha1test.o hmacsha1test.o) +$(eval $(call proto_header_template,$(libcryptosrcdir)/test_proto.h,$(TORTURE_LIBCRYPTO_OBJ_FILES:.o=.c))) diff --git a/source4/lib/dbwrap/config.mk b/source4/lib/dbwrap/config.mk index 9038873d32..34e2629b16 100644 --- a/source4/lib/dbwrap/config.mk +++ b/source4/lib/dbwrap/config.mk @@ -2,5 +2,5 @@ PUBLIC_DEPENDENCIES = \ LIBTDB ctdb -LIBDBWRAP_OBJ_FILES = $(addprefix lib/dbwrap/, dbwrap.o dbwrap_tdb.o dbwrap_ctdb.o) +LIBDBWRAP_OBJ_FILES = $(addprefix $(libdbwrapsrcdir)/, dbwrap.o dbwrap_tdb.o dbwrap_ctdb.o) diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 34c24f76f5..3a20770427 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -15,7 +15,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_aio_init ############################## -EVENTS_AIO_OBJ_FILES = lib/events/events_aio.o +EVENTS_AIO_OBJ_FILES = $(libeventssrcdir)/events_aio.o ############################## [MODULE::EVENTS_EPOLL] @@ -23,7 +23,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_epoll_init ############################## -EVENTS_EPOLL_OBJ_FILES = lib/events/events_epoll.o +EVENTS_EPOLL_OBJ_FILES = $(libeventssrcdir)/events_epoll.o ############################## [MODULE::EVENTS_SELECT] @@ -31,7 +31,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_select_init ############################## -EVENTS_SELECT_OBJ_FILES = lib/events/events_select.o +EVENTS_SELECT_OBJ_FILES = $(libeventssrcdir)/events_select.o ############################## [MODULE::EVENTS_STANDARD] @@ -39,7 +39,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_standard_init ############################## -EVENTS_STANDARD_OBJ_FILES = lib/events/events_standard.o +EVENTS_STANDARD_OBJ_FILES = $(libeventssrcdir)/events_standard.o ############################## # Start SUBSYSTEM LIBEVENTS @@ -47,12 +47,12 @@ EVENTS_STANDARD_OBJ_FILES = lib/events/events_standard.o # End SUBSYSTEM LIBEVENTS ############################## -LIBEVENTS_OBJ_FILES = $(addprefix lib/events/, events.o events_timed.o events_signal.o) +LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, events.o events_timed.o events_signal.o) -PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) +PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h) [PYTHON::swig_events] SWIG_FILE = events.i PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG -swig_events_OBJ_FILES = lib/events/events_wrap.o +swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o diff --git a/source4/lib/ldb-samba/config.mk b/source4/lib/ldb-samba/config.mk index 6a0b842fff..84007f3833 100644 --- a/source4/lib/ldb-samba/config.mk +++ b/source4/lib/ldb-samba/config.mk @@ -2,10 +2,10 @@ # Start SUBSYSTEM LDBSAMBA [SUBSYSTEM::LDBSAMBA] PUBLIC_DEPENDENCIES = LIBLDB -PRIVATE_PROTO_HEADER = ldif_handlers.h PRIVATE_DEPENDENCIES = LIBSECURITY SAMDB_SCHEMA LIBNDR NDR_MISC # End SUBSYSTEM LDBSAMBA ################################################ -LDBSAMBA_OBJ_FILES = lib/ldb-samba/ldif_handlers.o +LDBSAMBA_OBJ_FILES = $(ldb_sambasrcdir)/ldif_handlers.o +$(eval $(call proto_header_template,$(ldb_sambasrcdir)/ldif_handlers.h,$(LDBSAMBA_OBJ_FILES:.o=.c))) diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index 6b94f19cb5..18e981f7be 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -229,6 +229,14 @@ fail: return ldb_dn_canonical_ex_string($self, $self); } #ifdef SWIGPYTHON + char *__repr__(void) + { + char *dn = ldb_dn_get_linearized($self), *ret; + asprintf(&ret, "Dn('%s')", dn); + talloc_free(dn); + return ret; + } + ldb_dn *__add__(ldb_dn *other) { ldb_dn *ret = ldb_dn_copy(NULL, $self); @@ -376,6 +384,9 @@ typedef struct ldb_message_element { raise KeyError("no such value") return ret + def __repr__(self): + return "MessageElement([%s])" % (",".join(repr(x) for x in self.__set__())) + def __eq__(self, other): if (len(self) == 1 and self.get(0) == other): return True @@ -400,17 +411,22 @@ typedef struct ldb_message_element { else $result = SWIG_NewPointerObj($1, SWIGTYPE_p_ldb_message_element, 0); } -%rename(__getitem__) ldb_message::find_element; //%typemap(out) ldb_msg_element *; %inline { PyObject *ldb_msg_list_elements(ldb_msg *msg) { - int i; - PyObject *obj = PyList_New(msg->num_elements); - for (i = 0; i < msg->num_elements; i++) - PyList_SetItem(obj, i, PyString_FromString(msg->elements[i].name)); + int i, j = 0; + PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0)); + if (msg->dn != NULL) { + PyList_SetItem(obj, j, PyString_FromString("dn")); + j++; + } + for (i = 0; i < msg->num_elements; i++) { + PyList_SetItem(obj, j, PyString_FromString(msg->elements[i].name)); + j++; + } return obj; } } @@ -466,6 +482,28 @@ typedef struct ldb_message { } #endif void remove_attr(const char *name); +%pythoncode { + def get(self, key, default=None): + if key == "dn": + return self.dn + return self.find_element(key) + + def __getitem__(self, key): + ret = self.get(key, None) + if ret is None: + raise KeyError("No such element") + return ret + + def iteritems(self): + for k in self.keys(): + yield k, self[k] + + def items(self): + return list(self.iteritems()) + + def __repr__(self): + return "Message(%s)" % repr(dict(self.iteritems())) +} } } ldb_msg; @@ -743,6 +781,12 @@ typedef struct ldb_context { return PyObject_GetIter(list); } + char *__repr__(void) + { + char *ret; + asprintf(&ret, "<ldb connection at 0x%x>", ret); + return ret; + } #endif } %pythoncode { @@ -753,6 +797,8 @@ typedef struct ldb_context { def search(self, base=None, scope=SCOPE_DEFAULT, expression=None, attrs=None, controls=None): + if not (attrs is None or isinstance(attrs, list)): + raise TypeError("attributes not a list") parsed_controls = None if controls is not None: parsed_controls = self.parse_control_strings(controls) diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py index b148782c63..e9f4055fbf 100644 --- a/source4/lib/ldb/ldb.py +++ b/source4/lib/ldb/ldb.py @@ -68,7 +68,6 @@ CHANGETYPE_MODIFY = _ldb.CHANGETYPE_MODIFY ldb_val_to_py_object = _ldb.ldb_val_to_py_object class Dn(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') - __repr__ = _swig_repr def __init__(self, *args, **kwargs): _ldb.Dn_swiginit(self,_ldb.new_Dn(*args, **kwargs)) __swig_destroy__ = _ldb.delete_Dn @@ -93,6 +92,7 @@ Dn.add_child = new_instancemethod(_ldb.Dn_add_child,None,Dn) Dn.add_base = new_instancemethod(_ldb.Dn_add_base,None,Dn) Dn.canonical_str = new_instancemethod(_ldb.Dn_canonical_str,None,Dn) Dn.canonical_ex_str = new_instancemethod(_ldb.Dn_canonical_ex_str,None,Dn) +Dn.__repr__ = new_instancemethod(_ldb.Dn___repr__,None,Dn) Dn.__add__ = new_instancemethod(_ldb.Dn___add__,None,Dn) Dn_swigregister = _ldb.Dn_swigregister Dn_swigregister(Dn) @@ -108,6 +108,9 @@ class ldb_msg_element(object): raise KeyError("no such value") return ret + def __repr__(self): + return "MessageElement([%s])" % (",".join(repr(x) for x in self.__set__())) + def __eq__(self, other): if (len(self) == 1 and self.get(0) == other): return True @@ -139,7 +142,28 @@ class Message(object): def __init__(self, *args, **kwargs): _ldb.Message_swiginit(self,_ldb.new_Message(*args, **kwargs)) __swig_destroy__ = _ldb.delete_Message -Message.__getitem__ = new_instancemethod(_ldb.Message___getitem__,None,Message) + def get(self, key, default=None): + if key == "dn": + return self.dn + return self.find_element(key) + + def __getitem__(self, key): + ret = self.get(key, None) + if ret is None: + raise KeyError("No such element") + return ret + + def iteritems(self): + for k in self.keys(): + yield k, self[k] + + def items(self): + return list(self.iteritems()) + + def __repr__(self): + return "Message(%s)" % repr(dict(self.iteritems())) + +Message.find_element = new_instancemethod(_ldb.Message_find_element,None,Message) Message.__setitem__ = new_instancemethod(_ldb.Message___setitem__,None,Message) Message.__len__ = new_instancemethod(_ldb.Message___len__,None,Message) Message.keys = new_instancemethod(_ldb.Message_keys,None,Message) @@ -191,7 +215,6 @@ LDB_ERR_AFFECTS_MULTIPLE_DSAS = _ldb.LDB_ERR_AFFECTS_MULTIPLE_DSAS LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER class Ldb(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') - __repr__ = _swig_repr def __init__(self, *args, **kwargs): _ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs)) __swig_destroy__ = _ldb.delete_Ldb @@ -202,6 +225,8 @@ class Ldb(object): def search(self, base=None, scope=SCOPE_DEFAULT, expression=None, attrs=None, controls=None): + if not (attrs is None or isinstance(attrs, list)): + raise TypeError("attributes not a list") parsed_controls = None if controls is not None: parsed_controls = self.parse_control_strings(controls) @@ -234,6 +259,7 @@ Ldb.schema_attribute_add = new_instancemethod(_ldb.Ldb_schema_attribute_add,None Ldb.setup_wellknown_attributes = new_instancemethod(_ldb.Ldb_setup_wellknown_attributes,None,Ldb) Ldb.__contains__ = new_instancemethod(_ldb.Ldb___contains__,None,Ldb) Ldb.parse_ldif = new_instancemethod(_ldb.Ldb_parse_ldif,None,Ldb) +Ldb.__repr__ = new_instancemethod(_ldb.Ldb___repr__,None,Ldb) Ldb_swigregister = _ldb.Ldb_swigregister Ldb_swigregister(Ldb) diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c index 390652eebe..d787266416 100644 --- a/source4/lib/ldb/ldb_wrap.c +++ b/source4/lib/ldb/ldb_wrap.c @@ -2719,6 +2719,12 @@ SWIGINTERN char const *ldb_dn_canonical_str(ldb_dn *self){ SWIGINTERN char const *ldb_dn_canonical_ex_str(ldb_dn *self){ return ldb_dn_canonical_ex_string(self, self); } +SWIGINTERN char *ldb_dn___repr__(ldb_dn *self){ + char *dn = ldb_dn_get_linearized(self), *ret; + asprintf(&ret, "Dn('%s')", dn); + talloc_free(dn); + return ret; + } SWIGINTERN ldb_dn *ldb_dn___add__(ldb_dn *self,ldb_dn *other){ ldb_dn *ret = ldb_dn_copy(NULL, self); ldb_dn_add_child(ret, other); @@ -2970,10 +2976,16 @@ SWIGINTERN void delete_ldb_msg_element(ldb_msg_element *self){ talloc_free(self) PyObject *ldb_msg_list_elements(ldb_msg *msg) { - int i; - PyObject *obj = PyList_New(msg->num_elements); - for (i = 0; i < msg->num_elements; i++) - PyList_SetItem(obj, i, PyString_FromString(msg->elements[i].name)); + int i, j = 0; + PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0)); + if (msg->dn != NULL) { + PyList_SetItem(obj, j, PyString_FromString("dn")); + j++; + } + for (i = 0; i < msg->num_elements; i++) { + PyList_SetItem(obj, j, PyString_FromString(msg->elements[i].name)); + j++; + } return obj; } @@ -3188,6 +3200,11 @@ SWIGINTERN PyObject *ldb_parse_ldif(ldb *self,char const *s){ } return PyObject_GetIter(list); } +SWIGINTERN char *ldb___repr__(ldb *self){ + char *ret; + asprintf(&ret, "<ldb connection at 0x%x>", ret); + return ret; + } static char *timestring(time_t t) { @@ -3678,6 +3695,29 @@ fail: } +SWIGINTERN PyObject *_wrap_Dn___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_dn *arg1 = (ldb_dn *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn___repr__" "', argument " "1"" of type '" "ldb_dn *""'"); + } + arg1 = (ldb_dn *)(argp1); + result = (char *)ldb_dn___repr__(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_Dn___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; @@ -4074,7 +4114,7 @@ fail: } -SWIGINTERN PyObject *_wrap_Message___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { +SWIGINTERN PyObject *_wrap_Message_find_element(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; char *arg2 = (char *) 0 ; @@ -4090,15 +4130,15 @@ SWIGINTERN PyObject *_wrap_Message___getitem__(PyObject *SWIGUNUSEDPARM(self), P (char *) "self",(char *) "name", NULL }; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Message___getitem__",kwnames,&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Message_find_element",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message___getitem__" "', argument " "1"" of type '" "ldb_msg *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message_find_element" "', argument " "1"" of type '" "ldb_msg *""'"); } arg1 = (ldb_msg *)(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message___getitem__" "', argument " "2"" of type '" "char const *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message_find_element" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); if (arg1 == NULL) @@ -5538,6 +5578,32 @@ fail: } +SWIGINTERN PyObject *_wrap_Ldb___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb *arg1 = (ldb *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb___repr__" "', argument " "1"" of type '" "ldb *""'"); + } + arg1 = (ldb *)(argp1); + if (arg1 == NULL) + SWIG_exception(SWIG_ValueError, + "ldb context must be non-NULL"); + result = (char *)ldb___repr__(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *Ldb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; @@ -5673,6 +5739,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"Dn_add_base", (PyCFunction) _wrap_Dn_add_base, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Dn_canonical_str", (PyCFunction)_wrap_Dn_canonical_str, METH_O, NULL}, { (char *)"Dn_canonical_ex_str", (PyCFunction)_wrap_Dn_canonical_ex_str, METH_O, NULL}, + { (char *)"Dn___repr__", (PyCFunction)_wrap_Dn___repr__, METH_O, NULL}, { (char *)"Dn___add__", (PyCFunction) _wrap_Dn___add__, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Dn_swigregister", Dn_swigregister, METH_VARARGS, NULL}, { (char *)"Dn_swiginit", Dn_swiginit, METH_VARARGS, NULL}, @@ -5689,7 +5756,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"Message_dn_get", (PyCFunction)_wrap_Message_dn_get, METH_O, NULL}, { (char *)"new_Message", (PyCFunction) _wrap_new_Message, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"delete_Message", (PyCFunction)_wrap_delete_Message, METH_O, NULL}, - { (char *)"Message___getitem__", (PyCFunction) _wrap_Message___getitem__, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Message_find_element", (PyCFunction) _wrap_Message_find_element, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Message___setitem__", _wrap_Message___setitem__, METH_VARARGS, NULL}, { (char *)"Message___len__", (PyCFunction)_wrap_Message___len__, METH_O, NULL}, { (char *)"Message_keys", (PyCFunction)_wrap_Message_keys, METH_O, NULL}, @@ -5726,6 +5793,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"Ldb_setup_wellknown_attributes", (PyCFunction)_wrap_Ldb_setup_wellknown_attributes, METH_O, NULL}, { (char *)"Ldb___contains__", (PyCFunction) _wrap_Ldb___contains__, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Ldb_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Ldb___repr__", (PyCFunction)_wrap_Ldb___repr__, METH_O, NULL}, { (char *)"Ldb_swigregister", Ldb_swigregister, METH_VARARGS, NULL}, { (char *)"Ldb_swiginit", Ldb_swiginit, METH_VARARGS, NULL}, { (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, NULL}, diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py index 5f3f727b5d..1ae3fde744 100755 --- a/source4/lib/ldb/tests/python/api.py +++ b/source4/lib/ldb/tests/python/api.py @@ -36,6 +36,10 @@ class SimpleLdb(unittest.TestCase): x = ldb.Ldb() x.connect("foo.tdb") + def test_repr(self): + x = ldb.Ldb() + self.assertTrue(repr(x).startswith("<ldb connection")) + def test_set_create_perms(self): x = ldb.Ldb() x.set_create_perms(0600) @@ -60,6 +64,10 @@ class SimpleLdb(unittest.TestCase): l = ldb.Ldb("foo.tdb") self.assertEquals(len(l.search("", ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0) + def test_search_attr_string(self): + l = ldb.Ldb("foo.tdb") + self.assertRaises(TypeError, l.search, attrs="dc") + def test_opaque(self): l = ldb.Ldb("foo.tdb") l.set_opaque("my_opaque", l) @@ -257,6 +265,10 @@ class DnTests(unittest.TestCase): x = ldb.Dn(self.ldb, "dc=foo,bar=bloe") self.assertEquals(x.__str__(), "dc=foo,bar=bloe") + def test_repr(self): + x = ldb.Dn(self.ldb, "dc=foo,bla=blie") + self.assertEquals(x.__repr__(), "Dn('dc=foo,bla=blie')") + def test_get_casefold(self): x = ldb.Dn(self.ldb, "dc=foo,bar=bloe") self.assertEquals(x.get_casefold(), "DC=FOO,BAR=bloe") @@ -347,6 +359,16 @@ class LdbMsgTests(unittest.TestCase): self.msg = ldb.Message(ldb.Dn(ldb.Ldb(), "dc=foo")) self.assertEquals("dc=foo", str(self.msg.dn)) + def test_iter_items(self): + self.assertEquals(0, len(self.msg.items())) + self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "dc=foo") + self.assertEquals(1, len(self.msg.items())) + + def test_repr(self): + self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "dc=foo") + self.msg["dc"] = "foo" + self.assertEquals("Message({'dn': Dn('dc=foo'), 'dc': MessageElement(['foo'])})", repr(self.msg)) + def test_len(self): self.assertEquals(0, len(self.msg)) @@ -374,14 +396,26 @@ class LdbMsgTests(unittest.TestCase): self.assertEquals(["bar"], list(self.msg["foo"])) def test_keys(self): + self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO") self.msg["foo"] = ["bla"] self.msg["bar"] = ["bla"] - self.assertEquals(["foo", "bar"], self.msg.keys()) + self.assertEquals(["dn", "foo", "bar"], self.msg.keys()) def test_dn(self): self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO") self.assertEquals("@BASEINFO", self.msg.dn.__str__()) + def test_get_dn(self): + self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO") + self.assertEquals("@BASEINFO", self.msg.get("dn").__str__()) + + def test_get_other(self): + self.msg["foo"] = ["bar"] + self.assertEquals("bar", self.msg.get("foo")[0]) + + def test_get_unknown(self): + self.assertRaises(KeyError, self.msg.get, "lalalala") + class MessageElementTests(unittest.TestCase): def test_cmp_element(self): @@ -395,6 +429,12 @@ class MessageElementTests(unittest.TestCase): x = ldb.MessageElement(["foo"]) self.assertEquals(["foo"], list(x)) + def test_repr(self): + x = ldb.MessageElement(["foo"]) + self.assertEquals("MessageElement(['foo'])", repr(x)) + x = ldb.MessageElement(["foo", "bla"]) + self.assertEquals("MessageElement(['foo','bla'])", repr(x)) + def test_get_item(self): x = ldb.MessageElement(["foo", "bar"]) self.assertEquals("foo", x[0]) diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py index ead5796b7b..7cbe6e5e7d 100755 --- a/source4/lib/ldb/tests/python/ldap.py +++ b/source4/lib/ldb/tests/python/ldap.py @@ -6,6 +6,8 @@ import getopt import optparse import sys +sys.path.append("bin/python") + import samba.getopt as options from auth import system_session diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c index 67b16dd06e..0a89656fa2 100644 --- a/source4/lib/ldb/tools/ad2oLschema.c +++ b/source4/lib/ldb/tools/ad2oLschema.c @@ -429,7 +429,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_ /* We might have been asked to remap this oid, * due to a conflict, or lack of * implementation */ - for (j=0; syntax_oid && oid_map[j].old_oid; j++) { + for (j=0; syntax_oid && oid_map && oid_map[j].old_oid; j++) { if (strcasecmp(syntax_oid, oid_map[j].old_oid) == 0) { syntax_oid = oid_map[j].new_oid; break; @@ -494,7 +494,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_ } /* We might have been asked to remap this oid, due to a conflict */ - for (j=0; oid_map[j].old_oid; j++) { + for (j=0; oid_map && oid_map[j].old_oid; j++) { if (strcasecmp(oid, oid_map[j].old_oid) == 0) { oid = oid_map[j].new_oid; break; diff --git a/source4/lib/messaging/config.mk b/source4/lib/messaging/config.mk index 0a0097bdf3..eaf7e3581e 100644 --- a/source4/lib/messaging/config.mk +++ b/source4/lib/messaging/config.mk @@ -13,5 +13,4 @@ PUBLIC_DEPENDENCIES = \ # End SUBSYSTEM MESSAGING ################################################ - -MESSAGING_OBJ_FILES = lib/messaging/messaging.o +MESSAGING_OBJ_FILES = $(libmessagingsrcdir)/messaging.o diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 19284461ee..e7b654894f 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -1085,8 +1085,14 @@ void irpc_remove_name(struct messaging_context *msg_ctx, const char *name) return; } rec = tdb_fetch_bystring(t->tdb, name); + if (rec.dptr == NULL) { + tdb_unlock_bystring(t->tdb, name); + talloc_free(t); + return; + } count = rec.dsize / sizeof(struct server_id); if (count == 0) { + free(rec.dptr); tdb_unlock_bystring(t->tdb, name); talloc_free(t); return; diff --git a/source4/lib/nss_wrapper/config.mk b/source4/lib/nss_wrapper/config.mk index 5f136a465d..015fbe511c 100644 --- a/source4/lib/nss_wrapper/config.mk +++ b/source4/lib/nss_wrapper/config.mk @@ -4,4 +4,4 @@ # End SUBSYSTEM NSS_WRAPPER ############################## -NSS_WRAPPER_OBJ_FILES = lib/nss_wrapper/nss_wrapper.o +NSS_WRAPPER_OBJ_FILES = $(nsswrappersrcdir)/nss_wrapper.o diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index ce19d8512e..c0ad613c52 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -1,19 +1,19 @@ [SUBSYSTEM::TDR_REGF] PUBLIC_DEPENDENCIES = TDR -TDR_REGF_OBJ_FILES = lib/registry/tdr_regf.o +TDR_REGF_OBJ_FILES = $(libregistrysrcdir)/tdr_regf.o # Special support for external builddirs -lib/registry/regf.c: lib/registry/tdr_regf.c -$(srcdir)/lib/registry/regf.c: lib/registry/tdr_regf.c -lib/registry/tdr_regf.h: lib/registry/tdr_regf.c -lib/registry/tdr_regf.c: $(srcdir)/lib/registry/regf.idl +$(libregistrysrcdir)/regf.c: $(libregistrysrcdir)/tdr_regf.c +$(srcdir)/$(libregistrysrcdir)/regf.c: $(libregistrysrcdir)/tdr_regf.c +$(libregistrysrcdir)/tdr_regf.h: $(libregistrysrcdir)/tdr_regf.c +$(libregistrysrcdir)/tdr_regf.c: $(srcdir)/$(libregistrysrcdir)/regf.idl @CPP="$(CPP)" srcdir="$(srcdir)" $(PERL) $(srcdir)/pidl/pidl $(PIDL_ARGS) \ --header --outputdir=lib/registry \ - --tdr-parser -- $(srcdir)/lib/registry/regf.idl + --tdr-parser -- $(srcdir)/$(libregistrysrcdir)/regf.idl clean:: - @-rm -f lib/registry/regf.h lib/registry/tdr_regf* + @-rm -f $(libregistrysrcdir)/regf.h $(libregistrysrcdir)/tdr_regf* ################################################ # Start SUBSYSTEM registry @@ -24,22 +24,23 @@ PUBLIC_DEPENDENCIES = \ # End MODULE registry_ldb ################################################ -PC_FILES += lib/registry/registry.pc +PC_FILES += $(libregistrysrcdir)/registry.pc registry_VERSION = 0.0.1 registry_SOVERSION = 0 -registry_OBJ_FILES = $(addprefix lib/registry/, interface.o util.o samba.o \ +registry_OBJ_FILES = $(addprefix $(libregistrysrcdir)/, interface.o util.o samba.o \ patchfile_dotreg.o patchfile_preg.o patchfile.o regf.o \ hive.o local.o ldb.o dir.o rpc.o) -PUBLIC_HEADERS += lib/registry/registry.h +PUBLIC_HEADERS += $(libregistrysrcdir)/registry.h [SUBSYSTEM::registry_common] PUBLIC_DEPENDENCIES = registry -PRIVATE_PROTO_HEADER = tools/common.h -registry_common_OBJ_FILES = lib/registry/tools/common.o +registry_common_OBJ_FILES = $(libregistrysrcdir)/tools/common.o + +$(eval $(call proto_header_template,$(libregistrysrcdir)/tools/common.h,$(registry_common_OBJ_FILES:.o=.c))) ################################################ # Start BINARY regdiff @@ -50,9 +51,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY regdiff ################################################ -regdiff_OBJ_FILES = lib/registry/tools/regdiff.o +regdiff_OBJ_FILES = $(libregistrysrcdir)/tools/regdiff.o -MANPAGES += lib/registry/man/regdiff.1 +MANPAGES += $(libregistrysrcdir)/man/regdiff.1 ################################################ # Start BINARY regpatch @@ -64,9 +65,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY regpatch ################################################ -regpatch_OBJ_FILES = lib/registry/tools/regpatch.o +regpatch_OBJ_FILES = $(libregistrysrcdir)/tools/regpatch.o -MANPAGES += lib/registry/man/regpatch.1 +MANPAGES += $(libregistrysrcdir)/man/regpatch.1 ################################################ # Start BINARY regshell @@ -78,9 +79,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY regshell ################################################ -regshell_OBJ_FILES = lib/registry/tools/regshell.o +regshell_OBJ_FILES = $(libregistrysrcdir)/tools/regshell.o -MANPAGES += lib/registry/man/regshell.1 +MANPAGES += $(libregistrysrcdir)/man/regshell.1 ################################################ # Start BINARY regtree @@ -92,18 +93,19 @@ PRIVATE_DEPENDENCIES = \ # End BINARY regtree ################################################ -regtree_OBJ_FILES = lib/registry/tools/regtree.o +regtree_OBJ_FILES = $(libregistrysrcdir)/tools/regtree.o -MANPAGES += lib/registry/man/regtree.1 +MANPAGES += $(libregistrysrcdir)/man/regtree.1 [SUBSYSTEM::torture_registry] PRIVATE_DEPENDENCIES = registry -PRIVATE_PROTO_HEADER = tests/proto.h -torture_registry_OBJ_FILES = $(addprefix lib/registry/tests/, generic.o hive.o diff.o registry.o) +torture_registry_OBJ_FILES = $(addprefix $(libregistrysrcdir)/tests/, generic.o hive.o diff.o registry.o) + +$(eval $(call proto_header_template,$(libregistrysrcdir)/tests/proto.h,$(torture_registry_OBJ_FILES:.o=.c))) [PYTHON::swig_registry] PUBLIC_DEPENDENCIES = registry SWIG_FILE = registry.i -swig_registry_OBJ_FILES = lib/registry/registry_wrap.o +swig_registry_OBJ_FILES = $(libregistrysrcdir)/registry_wrap.o diff --git a/source4/lib/samba3/config.mk b/source4/lib/samba3/config.mk index d33b38cab0..e089149393 100644 --- a/source4/lib/samba3/config.mk +++ b/source4/lib/samba3/config.mk @@ -1,9 +1,10 @@ ################################################ # Start SUBSYSTEM LIBSAMBA3 [SUBSYSTEM::SMBPASSWD] -PRIVATE_PROTO_HEADER = samba3_smbpasswd_proto.h PRIVATE_DEPENDENCIES = CHARSET LIBSAMBA-UTIL # End SUBSYSTEM LIBSAMBA3 ################################################ -SMBPASSWD_OBJ_FILES = lib/samba3/smbpasswd.o +SMBPASSWD_OBJ_FILES = $(libsrcdir)/samba3/smbpasswd.o + +$(eval $(call proto_header_template,$(libsrcdir)/samba3/samba3_smbpasswd_proto.h,$(SMBPASSWD_OBJ_FILES:.o=.c))) diff --git a/source4/lib/socket/config.mk b/source4/lib/socket/config.mk index 2400190175..18aa806e41 100644 --- a/source4/lib/socket/config.mk +++ b/source4/lib/socket/config.mk @@ -1,12 +1,13 @@ ############################## # Start SUBSYSTEM LIBNETIF [SUBSYSTEM::LIBNETIF] -PRIVATE_PROTO_HEADER = netif_proto.h PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBREPLACE_NETWORK # End SUBSYSTEM LIBNETIF ############################## -LIBNETIF_OBJ_FILES = $(addprefix lib/socket/, interface.o netif.o) +LIBNETIF_OBJ_FILES = $(addprefix $(libsocketsrcdir)/, interface.o netif.o) + +$(eval $(call proto_header_template,$(libsocketsrcdir)/netif_proto.h,$(LIBNETIF_OBJ_FILES:.o=.c))) ################################################ # Start MODULE socket_ip @@ -17,7 +18,7 @@ PRIVATE_DEPENDENCIES = LIBSAMBA-ERRORS LIBREPLACE_NETWORK # End MODULE socket_ip ################################################ -socket_ip_OBJ_FILES = lib/socket/socket_ip.o +socket_ip_OBJ_FILES = $(libsocketsrcdir)/socket_ip.o ################################################ # Start MODULE socket_unix @@ -28,7 +29,7 @@ PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK # End MODULE socket_unix ################################################ -socket_unix_OBJ_FILES = lib/socket/socket_unix.o +socket_unix_OBJ_FILES = $(libsocketsrcdir)/socket_unix.o ################################################ # Start SUBSYSTEM SOCKET @@ -38,5 +39,5 @@ PRIVATE_DEPENDENCIES = SOCKET_WRAPPER LIBCLI_COMPOSITE LIBCLI_RESOLVE # End SUBSYSTEM SOCKET ################################################ -samba-socket_OBJ_FILES = $(addprefix lib/socket/, socket.o access.o connect_multi.o connect.o) +samba-socket_OBJ_FILES = $(addprefix $(libsocketsrcdir)/, socket.o access.o connect_multi.o connect.o) diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk index 2067d988cb..60cfb3209a 100644 --- a/source4/lib/socket_wrapper/config.mk +++ b/source4/lib/socket_wrapper/config.mk @@ -5,4 +5,4 @@ PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK # End SUBSYSTEM SOCKET_WRAPPER ############################## -SOCKET_WRAPPER_OBJ_FILES = lib/socket_wrapper/socket_wrapper.o +SOCKET_WRAPPER_OBJ_FILES = $(socketwrappersrcdir)/socket_wrapper.o diff --git a/source4/lib/stream/config.mk b/source4/lib/stream/config.mk index 52c8525483..56d117e7bd 100644 --- a/source4/lib/stream/config.mk +++ b/source4/lib/stream/config.mk @@ -1,4 +1,4 @@ [SUBSYSTEM::LIBPACKET] PRIVATE_DEPENDENCIES = LIBTLS -LIBPACKET_OBJ_FILES = lib/stream/packet.o +LIBPACKET_OBJ_FILES = $(libstreamsrcdir)/packet.o diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c index 07b0c23858..69c81e6e98 100644 --- a/source4/lib/tdb/common/traverse.c +++ b/source4/lib/tdb/common/traverse.c @@ -204,18 +204,23 @@ int tdb_traverse_read(struct tdb_context *tdb, { struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK }; int ret; + bool in_transaction = (tdb->transaction != NULL); /* we need to get a read lock on the transaction lock here to cope with the lock ordering semantics of solaris10 */ - if (tdb_transaction_lock(tdb, F_RDLCK)) { - return -1; + if (!in_transaction) { + if (tdb_transaction_lock(tdb, F_RDLCK)) { + return -1; + } } tdb->traverse_read++; ret = tdb_traverse_internal(tdb, fn, private_data, &tl); tdb->traverse_read--; - tdb_transaction_unlock(tdb); + if (!in_transaction) { + tdb_transaction_unlock(tdb); + } return ret; } @@ -232,20 +237,25 @@ int tdb_traverse(struct tdb_context *tdb, { struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; int ret; + bool in_transaction = (tdb->transaction != NULL); if (tdb->read_only || tdb->traverse_read) { return tdb_traverse_read(tdb, fn, private_data); } - if (tdb_transaction_lock(tdb, F_WRLCK)) { - return -1; + if (!in_transaction) { + if (tdb_transaction_lock(tdb, F_WRLCK)) { + return -1; + } } tdb->traverse_write++; ret = tdb_traverse_internal(tdb, fn, private_data, &tl); tdb->traverse_write--; - tdb_transaction_unlock(tdb); + if (!in_transaction) { + tdb_transaction_unlock(tdb); + } return ret; } diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac index 9b16a82c33..eaf70d30b4 100644 --- a/source4/lib/tdb/configure.ac +++ b/source4/lib/tdb/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.50) AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) AC_DEFUN([SMB_ENABLE], [echo -n ""]) -AC_INIT(tdb, 1.1.1) +AC_INIT(tdb, 1.1.2) AC_CONFIG_SRCDIR([common/tdb.c]) AC_CONFIG_HEADER(include/config.h) AC_LIBREPLACE_ALL_CHECKS diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py index 94407b6398..7147718c91 100644 --- a/source4/lib/tdb/python/tests/simple.py +++ b/source4/lib/tdb/python/tests/simple.py @@ -3,8 +3,8 @@ # Note that this tests the interface of the Python bindings # It does not test tdb itself. # -# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU LGPL +# Copyright (C) 2007-2008 Jelmer Vernooij <jelmer@samba.org> +# Published under the GNU LGPLv3 or later import tdb from unittest import TestCase @@ -25,6 +25,9 @@ class SimpleTdbTests(TestCase): def tearDown(self): del self.tdb + def test_repr(self): + self.assertTrue(repr(self.tdb).startswith("Tdb('")) + def test_lockall(self): self.tdb.lock_all() diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i index c82d2d0a6d..704f0facc6 100644 --- a/source4/lib/tdb/tdb.i +++ b/source4/lib/tdb/tdb.i @@ -182,8 +182,8 @@ typedef struct tdb_context { } %pythoncode { - def __str__(self): - return self.name() + def __repr__(self): + return "Tdb('%s')" % self.name() # Random access to keys, values def __getitem__(self, key): diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk index c91b1289cb..fa8db6d34c 100644 --- a/source4/lib/tdb/tdb.mk +++ b/source4/lib/tdb/tdb.mk @@ -50,7 +50,7 @@ install-python:: build-python cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` -check-python:: build-python +check-python:: build-python $(TDB_SONAME) $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py install-swig:: diff --git a/source4/lib/tdb/tdb.py b/source4/lib/tdb/tdb.py index 0effa3ff98..eb76ca6459 100644 --- a/source4/lib/tdb/tdb.py +++ b/source4/lib/tdb/tdb.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.33 +# Version 1.3.35 # # Don't modify this file, modify the SWIG interface instead. @@ -80,11 +80,11 @@ TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY class tdb(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') - def __init__(self): raise AttributeError, "No constructor defined" + def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined" __repr__ = _swig_repr __swig_destroy__ = _tdb.delete_tdb - def __str__(self): - return self.name() + def __repr__(self): + return "Tdb('%s')" % self.name() def __getitem__(self, key): diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c index 6a5b7feffc..f36d569937 100644 --- a/source4/lib/tdb/tdb_wrap.c +++ b/source4/lib/tdb/tdb_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.33 + * Version 1.3.35 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -126,7 +126,7 @@ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "3" +#define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -161,6 +161,7 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { extern "C" { #endif -typedef void *(*swig_converter_func)(void *); +typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); -/* Structure to store inforomation on one type */ +/* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ @@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* @@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg) Py_DECREF(old_str); Py_DECREF(value); } else { - PyErr_Format(PyExc_RuntimeError, mesg); + PyErr_SetString(PyExc_RuntimeError, mesg); } } @@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v) { PySwigObject *sobj = (PySwigObject *) v; PyObject *next = sobj->next; - if (sobj->own) { + if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; @@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v) res = ((*meth)(mself, v)); } Py_XDECREF(res); - } else { - const char *name = SWIG_TypePrettyName(ty); + } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); -#endif + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } +#endif } Py_XDECREF(next); PyObject_DEL(v); @@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own) { + if (own == SWIG_POINTER_OWN) { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; @@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int return SWIG_OK; } else { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { @@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (!tc) { sobj = (PySwigObject *)sobj->next; } else { - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } break; } } @@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } if (sobj) { - if (own) *own = sobj->own; + if (own) + *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } @@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { } if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (!tc) return SWIG_ERROR; - *ptr = SWIG_TypeCast(tc,vptr); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } } else { *ptr = vptr; } @@ -2500,7 +2518,7 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; #define SWIG_name "_tdb" -#define SWIGVERSION 0x010333 +#define SWIGVERSION 0x010335 #define SWIG_VERSION SWIGVERSION @@ -3753,7 +3771,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found; + int found, init; clientdata = clientdata; @@ -3763,6 +3781,9 @@ SWIG_InitializeModule(void *clientdata) { swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; + init = 1; + } else { + init = 0; } /* Try and load any already created modules */ @@ -3791,6 +3812,12 @@ SWIG_InitializeModule(void *clientdata) { module_head->next = &swig_module; } + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); diff --git a/source4/lib/tdr/config.mk b/source4/lib/tdr/config.mk index 3e05f6c30c..07506ec647 100644 --- a/source4/lib/tdr/config.mk +++ b/source4/lib/tdr/config.mk @@ -1,8 +1,9 @@ [SUBSYSTEM::TDR] CFLAGS = -Ilib/tdr -PRIVATE_PROTO_HEADER = tdr_proto.h PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL -TDR_OBJ_FILES = lib/tdr/tdr.o +TDR_OBJ_FILES = $(libtdrsrcdir)/tdr.o -PUBLIC_HEADERS += lib/tdr/tdr.h +$(eval $(call proto_header_template,$(libtdrsrcdir)/tdr_proto.h,$(TDR_OBJ_FILES:.o=.c))) + +PUBLIC_HEADERS += $(libtdrsrcdir)/tdr.h diff --git a/source4/lib/tls/config.mk b/source4/lib/tls/config.mk index e2d7cd517a..e01f79ce10 100644 --- a/source4/lib/tls/config.mk +++ b/source4/lib/tls/config.mk @@ -2,4 +2,4 @@ PUBLIC_DEPENDENCIES = \ LIBTALLOC GNUTLS LIBSAMBA-HOSTCONFIG samba-socket -LIBTLS_OBJ_FILES = lib/tls/tls.o lib/tls/tlscert.o +LIBTLS_OBJ_FILES = $(addprefix $(libtlssrcdir)/, tls.o tlscert.o) diff --git a/source4/lib/torture/config.mk b/source4/lib/torture/config.mk index 888e285e95..49e7b1a171 100644 --- a/source4/lib/torture/config.mk +++ b/source4/lib/torture/config.mk @@ -8,7 +8,7 @@ PUBLIC_DEPENDENCIES = \ torture_VERSION = 0.0.1 torture_SOVERSION = 0 -PC_FILES += lib/torture/torture.pc -torture_OBJ_FILES = $(addprefix lib/torture/, torture.o) +PC_FILES += $(libtorturesrcdir)/torture.pc +torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o) -PUBLIC_HEADERS += lib/torture/torture.h +PUBLIC_HEADERS += $(libtorturesrcdir)/torture.h diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk index 5a4b831ed5..925713a53c 100644 --- a/source4/lib/util/config.mk +++ b/source4/lib/util/config.mk @@ -4,7 +4,7 @@ PUBLIC_DEPENDENCIES = \ SOCKET_WRAPPER LIBREPLACE_NETWORK \ CHARSET EXECINFO -LIBSAMBA-UTIL_OBJ_FILES = $(addprefix lib/util/, \ +LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \ xfile.o \ debug.o \ fault.o \ @@ -25,7 +25,7 @@ LIBSAMBA-UTIL_OBJ_FILES = $(addprefix lib/util/, \ become_daemon.o \ params.o) -PUBLIC_HEADERS += $(addprefix lib/util/, util.h \ +PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \ attr.h \ byteorder.h \ data_blob.h \ @@ -37,14 +37,16 @@ PUBLIC_HEADERS += $(addprefix lib/util/, util.h \ xfile.h) [SUBSYSTEM::ASN1_UTIL] -PRIVATE_PROTO_HEADER = asn1_proto.h -ASN1_UTIL_OBJ_FILES = lib/util/asn1.o +ASN1_UTIL_OBJ_FILES = $(libutilsrcdir)/asn1.o + +$(eval $(call proto_header_template,$(libutilsrcdir)/asn1_proto.h,$(ASN1_UTIL_OBJ_FILES:.o=.c))) [SUBSYSTEM::UNIX_PRIVS] -PRIVATE_PROTO_HEADER = unix_privs.h -UNIX_PRIVS_OBJ_FILES = lib/util/unix_privs.o +UNIX_PRIVS_OBJ_FILES = $(libutilsrcdir)/unix_privs.o + +$(eval $(call proto_header_template,$(libutilsrcdir)/unix_privs.h,$(UNIX_PRIVS_OBJ_FILES:.o=.c))) ################################################ # Start SUBSYSTEM WRAP_XATTR @@ -54,15 +56,16 @@ PUBLIC_DEPENDENCIES = XATTR # End SUBSYSTEM WRAP_XATTR ################################################ -WRAP_XATTR_OBJ_FILES = lib/util/wrap_xattr.o +WRAP_XATTR_OBJ_FILES = $(libutilsrcdir)/wrap_xattr.o [SUBSYSTEM::UTIL_TDB] -PRIVATE_PROTO_HEADER = util_tdb.h PUBLIC_DEPENDENCIES = LIBTDB -UTIL_TDB_OBJ_FILES = lib/util/util_tdb.o +UTIL_TDB_OBJ_FILES = $(libutilsrcdir)/util_tdb.o + +$(eval $(call proto_header_template,$(libutilsrcdir)/util_tdb.h,$(UTIL_TDB_OBJ_FILES:.o=.c))) [SUBSYSTEM::UTIL_LDB] PUBLIC_DEPENDENCIES = LIBLDB -UTIL_LDB_OBJ_FILES = lib/util/util_ldb.o +UTIL_LDB_OBJ_FILES = $(libutilsrcdir)/util_ldb.o diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c index a181885806..978d73cc0a 100644 --- a/source4/lib/util/time.c +++ b/source4/lib/util/time.c @@ -376,7 +376,7 @@ _PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset) /** return (tv1 - tv2) in microseconds */ -_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2) +_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2) { int64_t sec_diff = tv1->tv_sec - tv2->tv_sec; return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec); diff --git a/source4/lib/util/time.h b/source4/lib/util/time.h index 1ab976ca78..e4008c5782 100644 --- a/source4/lib/util/time.h +++ b/source4/lib/util/time.h @@ -127,7 +127,7 @@ _PUBLIC_ NTTIME nttime_from_string(const char *s); /** return (tv1 - tv2) in microseconds */ -_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2); +_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2); /** return a zero timeval diff --git a/source4/libcli/auth/config.mk b/source4/libcli/auth/config.mk index 85fc4ab527..498c2af258 100644 --- a/source4/libcli/auth/config.mk +++ b/source4/libcli/auth/config.mk @@ -1,17 +1,17 @@ ################################# # Start SUBSYSTEM LIBCLI_AUTH [SUBSYSTEM::LIBCLI_AUTH] -PRIVATE_PROTO_HEADER = proto.h PUBLIC_DEPENDENCIES = \ MSRPC_PARSE \ LIBSAMBA-HOSTCONFIG # End SUBSYSTEM LIBCLI_AUTH ################################# -LIBCLI_AUTH_OBJ_FILES = $(addprefix libcli/auth/, \ +LIBCLI_AUTH_OBJ_FILES = $(addprefix $(libclisrcdir)/auth/, \ credentials.o \ session.o \ smbencrypt.o \ smbdes.o) -PUBLIC_HEADERS += libcli/auth/credentials.h +PUBLIC_HEADERS += $(libclisrcdir)/auth/credentials.h +$(eval $(call proto_header_template,$(libclisrcdir)/auth/proto.h,$(LIBCLI_AUTH_OBJ_FILES:.o=.c))) diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c index 614bd51d2a..860bd358d5 100644 --- a/source4/libcli/cldap/cldap.c +++ b/source4/libcli/cldap/cldap.c @@ -595,7 +595,6 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req, struct cldap_netlogon *io) { NTSTATUS status; - enum ndr_err_code ndr_err; struct cldap_search search; struct cldap_socket *cldap; DATA_BLOB *data; @@ -618,18 +617,15 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req, } data = search.out.response->attributes[0].values; - ndr_err = ndr_pull_union_blob_all(data, mem_ctx, - cldap->iconv_convenience, - &io->out.netlogon, - io->in.version & 0xF, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(2,("cldap failed to parse netlogon response of type 0x%02x\n", - SVAL(data->data, 0))); - dump_data(10, data->data, data->length); - return ndr_map_error2ntstatus(ndr_err); + status = pull_netlogon_samlogon_response(data, mem_ctx, req->cldap->iconv_convenience, + &io->out.netlogon); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (io->in.map_response) { + map_netlogon_samlogon_response(&io->out.netlogon); } - return NT_STATUS_OK; } @@ -704,25 +700,20 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap, uint32_t message_id, struct socket_address *src, uint32_t version, - union nbt_cldap_netlogon *netlogon) + struct netlogon_samlogon_response *netlogon) { NTSTATUS status; - enum ndr_err_code ndr_err; struct cldap_reply reply; struct ldap_SearchResEntry response; struct ldap_Result result; TALLOC_CTX *tmp_ctx = talloc_new(cldap); DATA_BLOB blob; - ndr_err = ndr_push_union_blob(&blob, tmp_ctx, - cldap->iconv_convenience, - netlogon, version & 0xF, - (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(tmp_ctx); - return ndr_map_error2ntstatus(ndr_err); + status = push_netlogon_samlogon_response(&blob, tmp_ctx, cldap->iconv_convenience, + netlogon); + if (!NT_STATUS_IS_OK(status)) { + return status; } - reply.messageid = message_id; reply.dest = src; reply.response = &response; diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h index eb0191d0f4..7c2daf0ca2 100644 --- a/source4/libcli/cldap/cldap.h +++ b/source4/libcli/cldap/cldap.h @@ -20,7 +20,7 @@ */ #include "lib/util/asn1.h" -#include "librpc/gen_ndr/nbt.h" +#include "libcli/netlogon.h" struct ldap_message; @@ -161,9 +161,10 @@ struct cldap_netlogon { const char *domain_sid; int acct_control; uint32_t version; + bool map_response; } in; struct { - union nbt_cldap_netlogon netlogon; + struct netlogon_samlogon_response netlogon; } out; }; @@ -178,4 +179,4 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap, uint32_t message_id, struct socket_address *src, uint32_t version, - union nbt_cldap_netlogon *netlogon); + struct netlogon_samlogon_response *netlogon); diff --git a/source4/libcli/clifile.c b/source4/libcli/clifile.c index e59b7f9af3..2cf174060b 100644 --- a/source4/libcli/clifile.c +++ b/source4/libcli/clifile.c @@ -650,7 +650,8 @@ NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path) /**************************************************************************** Query disk space. ****************************************************************************/ -NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *avail) +NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, uint32_t *bsize, + uint64_t *total, uint64_t *avail) { union smb_fsinfo fsinfo_parms; TALLOC_CTX *mem_ctx; @@ -658,12 +659,12 @@ NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *a mem_ctx = talloc_init("smbcli_dskattr"); - fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR; + fsinfo_parms.dskattr.level = RAW_QFS_SIZE_INFO; status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms); if (NT_STATUS_IS_OK(status)) { - *bsize = fsinfo_parms.dskattr.out.block_size; - *total = fsinfo_parms.dskattr.out.units_total; - *avail = fsinfo_parms.dskattr.out.units_free; + *bsize = fsinfo_parms.size_info.out.bytes_per_sector * fsinfo_parms.size_info.out.sectors_per_unit; + *total = fsinfo_parms.size_info.out.total_alloc_units; + *avail = fsinfo_parms.size_info.out.avail_alloc_units; } talloc_free(mem_ctx); diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 966f56cba8..3e3f224f47 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -69,6 +69,17 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c) return c->status; } +/* + block until a composite function has completed, then return the status. + Free the composite context before returning +*/ +_PUBLIC_ NTSTATUS composite_wait_free(struct composite_context *c) +{ + NTSTATUS status = composite_wait(c); + talloc_free(c); + return status; +} + /* callback from composite_done() and composite_error() @@ -94,6 +105,12 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status) { + /* you are allowed to pass NT_STATUS_OK to composite_error(), in which + case it is equivalent to composite_done() */ + if (NT_STATUS_IS_OK(status)) { + composite_done(ctx); + return; + } if (!ctx->used_wait && !ctx->async.fn) { event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); } @@ -187,7 +204,7 @@ _PUBLIC_ void composite_continue_smb2(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_nbt(struct composite_context *ctx, diff --git a/source4/libcli/composite/composite.h b/source4/libcli/composite/composite.h index f1bed20361..28cd6a88dc 100644 --- a/source4/libcli/composite/composite.h +++ b/source4/libcli/composite/composite.h @@ -101,6 +101,7 @@ bool composite_is_ok(struct composite_context *ctx); void composite_done(struct composite_context *ctx); void composite_error(struct composite_context *ctx, NTSTATUS status); NTSTATUS composite_wait(struct composite_context *c); +NTSTATUS composite_wait_free(struct composite_context *c); #endif /* __COMPOSITE_H__ */ diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk index 95b45003be..16e23430d7 100644 --- a/source4/libcli/config.mk +++ b/source4/libcli/config.mk @@ -5,117 +5,140 @@ mkinclude wbclient/config.mk [SUBSYSTEM::LIBSAMBA-ERRORS] -LIBSAMBA-ERRORS_OBJ_FILES = $(addprefix libcli/util/, doserr.o errormap.o nterr.o) +LIBSAMBA-ERRORS_OBJ_FILES = $(addprefix $(libclisrcdir)/util/, doserr.o errormap.o nterr.o) -PUBLIC_HEADERS += $(addprefix libcli/, util/error.h util/ntstatus.h util/doserr.h util/werror.h) +PUBLIC_HEADERS += $(addprefix $(libclisrcdir)/, util/error.h util/ntstatus.h util/doserr.h util/werror.h) [SUBSYSTEM::LIBCLI_LSA] -PRIVATE_PROTO_HEADER = util/clilsa.h PUBLIC_DEPENDENCIES = RPC_NDR_LSA PRIVATE_DEPENDENCIES = LIBSECURITY -LIBCLI_LSA_OBJ_FILES = libcli/util/clilsa.o +LIBCLI_LSA_OBJ_FILES = $(libclisrcdir)/util/clilsa.o + +$(eval $(call proto_header_template,$(libclisrcdir)/util/clilsa.h,$(LIBCLI_LSA_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_COMPOSITE] -PRIVATE_PROTO_HEADER = composite/proto.h PUBLIC_DEPENDENCIES = LIBEVENTS -LIBCLI_COMPOSITE_OBJ_FILES = libcli/composite/composite.o +LIBCLI_COMPOSITE_OBJ_FILES = $(libclisrcdir)/composite/composite.o +$(eval $(call proto_header_template,$(libclisrcdir)/composite/proto.h,$(LIBCLI_COMPOSITE_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_SMB_COMPOSITE] -PRIVATE_PROTO_HEADER = smb_composite/proto.h PUBLIC_DEPENDENCIES = LIBCLI_COMPOSITE CREDENTIALS gensec LIBCLI_RESOLVE -LIBCLI_SMB_COMPOSITE_OBJ_FILES = $(addprefix libcli/smb_composite/, \ +LIBCLI_SMB_COMPOSITE_OBJ_FILES = $(addprefix $(libclisrcdir)/smb_composite/, \ loadfile.o \ savefile.o \ connect.o \ sesssetup.o \ fetchfile.o \ appendacl.o \ - fsinfo.o) + fsinfo.o \ + smb2.o) +$(eval $(call proto_header_template,$(libclisrcdir)/smb_composite/proto.h,$(LIBCLI_SMB_COMPOSITE_OBJ_FILES:.o=.c))) [SUBSYSTEM::NDR_NBT_BUF] -PRIVATE_PROTO_HEADER = nbt/nbtname.h -NDR_NBT_BUF_OBJ_FILES = libcli/nbt/nbtname.o +NDR_NBT_BUF_OBJ_FILES = $(libclisrcdir)/nbt/nbtname.o + +$(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbtname.h,$(NDR_NBT_BUF_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_NBT] -PRIVATE_PROTO_HEADER = nbt/nbt_proto.h PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \ NDR_SECURITY samba-socket LIBSAMBA-UTIL -LIBCLI_NBT_OBJ_FILES = $(addprefix libcli/nbt/, \ +LIBCLI_NBT_OBJ_FILES = $(addprefix $(libclisrcdir)/nbt/, \ nbtsocket.o \ namequery.o \ nameregister.o \ namerefresh.o \ namerelease.o) +$(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbt_proto.h,$(LIBCLI_NBT_OBJ_FILES:.o=.c))) + +[SUBSYSTEM::LIBCLI_NDR_NETLOGON] +PUBLIC_DEPENDENCIES = LIBNDR \ + NDR_SECURITY + +LIBCLI_NDR_NETLOGON_OBJ_FILES = $(addprefix libcli/, \ + ndr_netlogon.o) + +$(eval $(call proto_header_template,$(libclisrcdir)/ndr_netlogon_proto.h,$(LIBCLI_NDR_NETLOGON_OBJ_FILES:.o=.c))) + +[SUBSYSTEM::LIBCLI_NETLOGON] +PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_NDR_NETLOGON + +LIBCLI_NETLOGON_OBJ_FILES = $(addprefix libcli/, \ + netlogon.o) + +$(eval $(call proto_header_template,$(libclisrcdir)/netlogon_proto.h,$(LIBCLI_NETLOGON_OBJ_FILES:.o=.c))) + [PYTHON::python_libcli_nbt] SWIG_FILE = swig/libcli_nbt.i PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-HOSTCONFIG -python_libcli_nbt_OBJ_FILES = libcli/swig/libcli_nbt_wrap.o +python_libcli_nbt_OBJ_FILES = $(libclisrcdir)/swig/libcli_nbt_wrap.o [PYTHON::python_libcli_smb] SWIG_FILE = swig/libcli_smb.i PUBLIC_DEPENDENCIES = LIBCLI_SMB DYNCONFIG LIBSAMBA-HOSTCONFIG -python_libcli_smb_OBJ_FILES = libcli/swig/libcli_smb_wrap.o +python_libcli_smb_OBJ_FILES = $(libclisrcdir)/swig/libcli_smb_wrap.o [SUBSYSTEM::LIBCLI_DGRAM] -PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE +PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE LIBCLI_NETLOGON -LIBCLI_DGRAM_OBJ_FILES = $(addprefix libcli/dgram/, \ +LIBCLI_DGRAM_OBJ_FILES = $(addprefix $(libclisrcdir)/dgram/, \ dgramsocket.o \ mailslot.o \ netlogon.o \ - ntlogon.o \ browse.o) [SUBSYSTEM::LIBCLI_CLDAP] PUBLIC_DEPENDENCIES = LIBCLI_LDAP -PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBLDB +PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBLDB LIBCLI_NETLOGON -LIBCLI_CLDAP_OBJ_FILES = libcli/cldap/cldap.o -# PUBLIC_HEADERS += libcli/cldap/cldap.h +LIBCLI_CLDAP_OBJ_FILES = $(libclisrcdir)/cldap/cldap.o +# PUBLIC_HEADERS += $(libclisrcdir)/cldap/cldap.h [SUBSYSTEM::LIBCLI_WREPL] -PRIVATE_PROTO_HEADER = wrepl/winsrepl_proto.h PUBLIC_DEPENDENCIES = NDR_WINSREPL samba-socket LIBCLI_RESOLVE LIBEVENTS \ LIBPACKET LIBNDR -LIBCLI_WREPL_OBJ_FILES = libcli/wrepl/winsrepl.o +LIBCLI_WREPL_OBJ_FILES = $(libclisrcdir)/wrepl/winsrepl.o + +$(eval $(call proto_header_template,$(libclisrcdir)/wrepl/winsrepl_proto.h,$(LIBCLI_WREPL_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_RESOLVE] -PRIVATE_PROTO_HEADER = resolve/proto.h PUBLIC_DEPENDENCIES = NDR_NBT -LIBCLI_RESOLVE_OBJ_FILES = libcli/resolve/resolve.o +LIBCLI_RESOLVE_OBJ_FILES = $(libclisrcdir)/resolve/resolve.o + +$(eval $(call proto_header_template,$(libclisrcdir)/resolve/proto.h,$(LIBCLI_RESOLVE_OBJ_FILES:.o=.c))) [SUBSYSTEM::LP_RESOLVE] -PRIVATE_PROTO_HEADER = resolve/lp_proto.h PRIVATE_DEPENDENCIES = LIBCLI_NBT LIBSAMBA-HOSTCONFIG LIBNETIF -LP_RESOLVE_OBJ_FILES = $(addprefix libcli/resolve/, \ +LP_RESOLVE_OBJ_FILES = $(addprefix $(libclisrcdir)/resolve/, \ bcast.o nbtlist.o wins.o \ host.o resolve_lp.o) +$(eval $(call proto_header_template,$(libclisrcdir)/resolve/lp_proto.h,$(LP_RESOLVE_OBJ_FILES:.o=.c))) + [SUBSYSTEM::LIBCLI_FINDDCS] -PRIVATE_PROTO_HEADER = finddcs.h PUBLIC_DEPENDENCIES = LIBCLI_NBT MESSAGING -LIBCLI_FINDDCS_OBJ_FILES = libcli/finddcs.o +LIBCLI_FINDDCS_OBJ_FILES = $(libclisrcdir)/finddcs.o + +$(eval $(call proto_header_template,$(libclisrcdir)/finddcs.h,$(LIBCLI_FINDDCS_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_SMB] -PRIVATE_PROTO_HEADER = libcli_proto.h PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBSAMBA-ERRORS LIBCLI_AUTH \ LIBCLI_SMB_COMPOSITE LIBCLI_NBT LIBSECURITY LIBCLI_RESOLVE \ LIBCLI_DGRAM LIBCLI_SMB2 LIBCLI_FINDDCS samba-socket -LIBCLI_SMB_OBJ_FILES = $(addprefix libcli/, \ +LIBCLI_SMB_OBJ_FILES = $(addprefix $(libclisrcdir)/, \ clireadwrite.o \ cliconnect.o \ clifile.o \ @@ -124,18 +147,22 @@ LIBCLI_SMB_OBJ_FILES = $(addprefix libcli/, \ climessage.o \ clideltree.o) -# PUBLIC_HEADERS += libcli/libcli.h +$(eval $(call proto_header_template,$(libclisrcdir)/libcli_proto.h,$(LIBCLI_SMB_OBJ_FILES:.o=.c))) + +# PUBLIC_HEADERS += $(libclisrcdir)/libcli.h [SUBSYSTEM::LIBCLI_RAW] -PRIVATE_PROTO_HEADER = raw/raw_proto.h PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE LP_RESOLVE gensec LIBCLI_RESOLVE LIBSECURITY LIBNDR #LDFLAGS = $(LIBCLI_SMB_COMPOSITE_OUTPUT) PUBLIC_DEPENDENCIES = samba-socket LIBPACKET gensec LIBCRYPTO CREDENTIALS -LIBCLI_RAW_OBJ_FILES = $(addprefix libcli/raw/, rawfile.o smb_signing.o clisocket.o \ +LIBCLI_RAW_OBJ_FILES = $(addprefix $(libclisrcdir)/raw/, rawfile.o smb_signing.o clisocket.o \ clitransport.o clisession.o clitree.o clierror.o rawrequest.o \ rawreadwrite.o rawsearch.o rawsetfileinfo.o raweas.o rawtrans.o \ clioplock.o rawnegotiate.o rawfsinfo.o rawfileinfo.o rawnotify.o \ rawioctl.o rawacl.o rawdate.o rawlpq.o rawshadow.o) + +$(eval $(call proto_header_template,$(libclisrcdir)/raw/raw_proto.h,$(LIBCLI_RAW_OBJ_FILES:.o=.c))) + mkinclude smb2/config.mk diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index 707cca8cc5..e1209e7a54 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "librpc/gen_ndr/nbt.h" +#include "libcli/netlogon.h" /* a datagram name request @@ -121,33 +121,23 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock, NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, struct nbt_name *dest_name, struct socket_address *dest, + const char *mailslot_name, struct nbt_name *src_name, struct nbt_netlogon_packet *request); NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, struct nbt_dgram_packet *request, const char *my_netbios_name, const char *mailslot_name, - struct nbt_netlogon_packet *reply); -NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot, - TALLOC_CTX *mem_ctx, - struct nbt_dgram_packet *dgram, - struct nbt_netlogon_packet *netlogon); - -NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, - enum dgram_msg_type msg_type, - struct nbt_name *dest_name, - struct socket_address *dest, - struct nbt_name *src_name, - struct nbt_ntlogon_packet *request); -NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, - struct nbt_dgram_packet *request, - const char *my_netbios_name, - const char *mailslot_name, - struct nbt_ntlogon_packet *reply); -NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot, - TALLOC_CTX *mem_ctx, - struct nbt_dgram_packet *dgram, - struct nbt_ntlogon_packet *ntlogon); + struct nbt_netlogon_response *reply); +NTSTATUS dgram_mailslot_netlogon_parse_request(struct dgram_mailslot_handler *dgmslot, + TALLOC_CTX *mem_ctx, + struct nbt_dgram_packet *dgram, + struct nbt_netlogon_packet *netlogon); + +NTSTATUS dgram_mailslot_netlogon_parse_response(struct dgram_mailslot_handler *dgmslot, + TALLOC_CTX *mem_ctx, + struct nbt_dgram_packet *dgram, + struct nbt_netlogon_response *netlogon); NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock, struct nbt_name *dest_name, diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c index 5c7dedc7bb..b37d4a2ee6 100644 --- a/source4/libcli/dgram/netlogon.c +++ b/source4/libcli/dgram/netlogon.c @@ -32,6 +32,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, struct nbt_name *dest_name, struct socket_address *dest, + const char *mailslot, struct nbt_name *src_name, struct nbt_netlogon_packet *request) { @@ -51,7 +52,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, - NBT_MAILSLOT_NETLOGON, + mailslot, dest_name, dest, src_name, &blob); talloc_free(tmp_ctx); @@ -66,22 +67,18 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, struct nbt_dgram_packet *request, const char *my_netbios_name, const char *mailslot_name, - struct nbt_netlogon_packet *reply) + struct nbt_netlogon_response *reply) { NTSTATUS status; - enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; struct socket_address *dest; - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, - dgmsock->iconv_convenience, - reply, - (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(tmp_ctx); - return ndr_map_error2ntstatus(ndr_err); + status = push_nbt_netlogon_response(&blob, tmp_ctx, dgmsock->iconv_convenience, + reply); + if (!NT_STATUS_IS_OK(status)) { + return status; } make_nbt_name_client(&myname, my_netbios_name); @@ -106,10 +103,10 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, /* parse a netlogon response. The packet must be a valid mailslot packet */ -NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot, - TALLOC_CTX *mem_ctx, - struct nbt_dgram_packet *dgram, - struct nbt_netlogon_packet *netlogon) +NTSTATUS dgram_mailslot_netlogon_parse_request(struct dgram_mailslot_handler *dgmslot, + TALLOC_CTX *mem_ctx, + struct nbt_dgram_packet *dgram, + struct nbt_netlogon_packet *netlogon) { DATA_BLOB data = dgram_mailslot_data(dgram); enum ndr_err_code ndr_err; @@ -127,3 +124,23 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot, } return NT_STATUS_OK; } + +/* + parse a netlogon response. The packet must be a valid mailslot packet +*/ +NTSTATUS dgram_mailslot_netlogon_parse_response(struct dgram_mailslot_handler *dgmslot, + TALLOC_CTX *mem_ctx, + struct nbt_dgram_packet *dgram, + struct nbt_netlogon_response *netlogon) +{ + NTSTATUS status; + DATA_BLOB data = dgram_mailslot_data(dgram); + + status = pull_nbt_netlogon_response(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, netlogon); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return NT_STATUS_OK; +} + diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c deleted file mode 100644 index 7b26ed7c00..0000000000 --- a/source4/libcli/dgram/ntlogon.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - handling for ntlogon dgram requests - - Copyright (C) Andrew Tridgell 2005 - - 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 "libcli/dgram/libdgram.h" -#include "lib/socket/socket.h" -#include "libcli/resolve/resolve.h" -#include "librpc/gen_ndr/ndr_nbt.h" -#include "param/param.h" - -/* - send a ntlogon mailslot request -*/ -NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, - enum dgram_msg_type msg_type, - struct nbt_name *dest_name, - struct socket_address *dest, - struct nbt_name *src_name, - struct nbt_ntlogon_packet *request) -{ - NTSTATUS status; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, - request, - (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(tmp_ctx); - return ndr_map_error2ntstatus(ndr_err); - } - - - status = dgram_mailslot_send(dgmsock, msg_type, - NBT_MAILSLOT_NTLOGON, - dest_name, dest, - src_name, &blob); - talloc_free(tmp_ctx); - return status; -} - - -/* - send a ntlogon mailslot reply -*/ -NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, - struct nbt_dgram_packet *request, - const char *my_netbios_name, - const char *mailslot_name, - struct nbt_ntlogon_packet *reply) -{ - NTSTATUS status; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - struct nbt_name myname; - struct socket_address *dest; - - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, reply, - (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(tmp_ctx); - return ndr_map_error2ntstatus(ndr_err); - } - - make_nbt_name_client(&myname, my_netbios_name); - - dest = socket_address_from_strings(tmp_ctx, - dgmsock->sock->backend_name, - request->src_addr, request->src_port); - if (!dest) { - talloc_free(tmp_ctx); - return NT_STATUS_NO_MEMORY; - } - - status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, - mailslot_name, - &request->data.msg.source_name, - dest, - &myname, &blob); - talloc_free(tmp_ctx); - return status; -} - - -/* - parse a ntlogon response. The packet must be a valid mailslot packet -*/ -NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot, - TALLOC_CTX *mem_ctx, - struct nbt_dgram_packet *dgram, - struct nbt_ntlogon_packet *ntlogon) -{ - DATA_BLOB data = dgram_mailslot_data(dgram); - enum ndr_err_code ndr_err; - - ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, ntlogon, - (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - DEBUG(0,("Failed to parse ntlogon packet of length %d: %s\n", - (int)data.length, nt_errstr(status))); - if (DEBUGLVL(10)) { - file_save("ntlogon.dat", data.data, data.length); - } - return status; - } - return NT_STATUS_OK; -} diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk index 33e32c7417..02678eed7a 100644 --- a/source4/libcli/ldap/config.mk +++ b/source4/libcli/ldap/config.mk @@ -1,17 +1,18 @@ [SUBSYSTEM::LIBCLI_LDAP] -PRIVATE_PROTO_HEADER = ldap_proto.h PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBEVENTS LIBPACKET PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE samba-socket NDR_SAMR LIBTLS ASN1_UTIL \ LDAP_ENCODE LIBNDR LP_RESOLVE gensec -LIBCLI_LDAP_OBJ_FILES = $(addprefix libcli/ldap/, \ +LIBCLI_LDAP_OBJ_FILES = $(addprefix $(libclisrcdir)/ldap/, \ ldap.o ldap_client.o ldap_bind.o \ ldap_msg.o ldap_ildap.o ldap_controls.o) -PUBLIC_HEADERS += libcli/ldap/ldap.h libcli/ldap/ldap_ndr.h +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 -LDAP_ENCODE_OBJ_FILES = libcli/ldap/ldap_ndr.o +LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o diff --git a/source4/libcli/ndr_netlogon.c b/source4/libcli/ndr_netlogon.c new file mode 100644 index 0000000000..504b3b02a7 --- /dev/null +++ b/source4/libcli/ndr_netlogon.c @@ -0,0 +1,209 @@ +/* + Unix SMB/CIFS implementation. + + CLDAP server structures + + Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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/>. +*/ + +/* parser auto-generated by pidl, then hand-modified by abartlet */ + +#include "includes.h" +#include "libcli/netlogon.h" +/* Manually modified to handle the dom_sid being optional based on if it is present or all zero */ +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_REQUEST(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_REQUEST *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_samr_AcctFlags(ndr, NDR_SCALARS, r->acct_control)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags))); + if (ndr_size_dom_sid0(&r->sid, ndr->flags)) { + struct ndr_push *_ndr_sid; + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); + ndr->flags = _flags_save_DATA_BLOB; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); + NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); + } + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +/* Manually modified to handle the dom_sid being optional based on if it is present (size is non-zero) or not */ +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_REQUEST(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_REQUEST *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_samr_AcctFlags(ndr, NDR_SCALARS, &r->acct_control)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size)); + if (r->sid_size) { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + struct ndr_pull *_ndr_sid; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); + ndr->flags = _flags_save_DATA_BLOB; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size)); + NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size)); + } else { + ZERO_STRUCT(r->sid); + } + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +/* Manually modified to only push some parts of the structure if certain flags are set */ +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz)); + NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); + if (r->nt_version & NETLOGON_NT_VERSION_5EX_WITH_IP) { + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags))); + { + struct ndr_push *_ndr_sockaddr; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags))); + NDR_CHECK(ndr_push_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags))); + } + } + if (r->nt_version & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) { + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site)); + } + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_uuid)); + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +/* Manually modified to only pull some parts of the structure if certain flags provided */ +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r, + uint32_t nt_version_flags) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ZERO_STRUCTP(r); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); + NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); + if (nt_version_flags & NETLOGON_NT_VERSION_5EX_WITH_IP) { + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sockaddr_size)); + { + struct ndr_pull *_ndr_sockaddr; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sockaddr, 0, r->sockaddr_size)); + NDR_CHECK(ndr_pull_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sockaddr, 0, r->sockaddr_size)); + } + } + if (nt_version_flags & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) { + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site)); + } + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); + if (r->nt_version != nt_version_flags) { + return NDR_ERR_VALIDATE; + } + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_uuid)); + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} diff --git a/source4/libcli/netlogon.c b/source4/libcli/netlogon.c new file mode 100644 index 0000000000..052d7cbc1e --- /dev/null +++ b/source4/libcli/netlogon.c @@ -0,0 +1,239 @@ +/* + Unix SMB/CIFS implementation. + + CLDAP server structures + + Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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 "libcli/netlogon.h" + +NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct netlogon_samlogon_response *response) +{ + enum ndr_err_code ndr_err; + if (response->ntver == NETLOGON_NT_VERSION_1) { + ndr_err = ndr_push_struct_blob(data, mem_ctx, + iconv_convenience, + &response->nt4, + (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_NT40); + } else if (response->ntver & NETLOGON_NT_VERSION_5EX) { + ndr_err = ndr_push_struct_blob(data, mem_ctx, + iconv_convenience, + &response->nt5_ex, + (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags); + } else if (response->ntver & NETLOGON_NT_VERSION_5) { + ndr_err = ndr_push_struct_blob(data, mem_ctx, + iconv_convenience, + &response->nt5, + (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE); + } else { + DEBUG(0, ("Asked to push unknown netlogon response type 0x%02x\n", response->ntver)); + return NT_STATUS_INVALID_PARAMETER; + } + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(2,("failed to push netlogon response of type 0x%02x\n", + response->ntver)); + return ndr_map_error2ntstatus(ndr_err); + } + return NT_STATUS_OK; +} + +NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct netlogon_samlogon_response *response) +{ + uint32_t ntver; + enum ndr_err_code ndr_err; + + if (data->length < 8) { + return NT_STATUS_BUFFER_TOO_SMALL; + } + + /* lmnttoken */ + if (SVAL(data->data, data->length - 4) != 0xffff) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + /* lm20token */ + if (SVAL(data->data, data->length - 2) != 0xffff) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + ntver = IVAL(data->data, data->length - 8); + + if (ntver == NETLOGON_NT_VERSION_1) { + ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, + iconv_convenience, + &response->nt4, + (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_NT40); + response->ntver = NETLOGON_NT_VERSION_1; + } else if (ntver & NETLOGON_NT_VERSION_5EX) { + struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(data, mem_ctx, iconv_convenience); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + ndr_err = ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(ndr, NDR_SCALARS|NDR_BUFFERS, &response->nt5_ex, ntver); + if (ndr->offset < ndr->data_size) { + ndr_err = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, + "not all bytes consumed ofs[%u] size[%u]", + ndr->offset, ndr->data_size); + } + response->ntver = NETLOGON_NT_VERSION_5EX; + + } else if (ntver & NETLOGON_NT_VERSION_5) { + ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, + iconv_convenience, + &response->nt5, + (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE); + response->ntver = NETLOGON_NT_VERSION_5; + } else { + DEBUG(2,("failed to parse netlogon response of type 0x%02x - unknown response type\n", + ntver)); + dump_data(10, data->data, data->length); + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(2,("failed to parse netlogon response of type 0x%02x\n", + ntver)); + dump_data(10, data->data, data->length); + return ndr_map_error2ntstatus(ndr_err); + } + return NT_STATUS_OK; +} + +void map_netlogon_samlogon_response(struct netlogon_samlogon_response *response) +{ + struct NETLOGON_SAM_LOGON_RESPONSE_EX response_5_ex; + switch (response->ntver) { + case NETLOGON_NT_VERSION_5EX: + break; + case NETLOGON_NT_VERSION_5: + ZERO_STRUCT(response_5_ex); + response_5_ex.command = response->nt5.command; + response_5_ex.pdc_name = response->nt5.pdc_name; + response_5_ex.user_name = response->nt5.user_name; + response_5_ex.domain = response->nt5.domain_name; + response_5_ex.domain_uuid = response->nt5.domain_uuid; + response_5_ex.forest = response->nt5.forest; + response_5_ex.dns_domain = response->nt5.dns_domain; + response_5_ex.pdc_dns_name = response->nt5.pdc_dns_name; + response_5_ex.sockaddr.pdc_ip = response->nt5.pdc_ip; + response_5_ex.server_type = response->nt5.server_type; + response_5_ex.nt_version = response->nt5.nt_version; + response_5_ex.lmnt_token = response->nt5.lmnt_token; + response_5_ex.lm20_token = response->nt5.lm20_token; + response->ntver = NETLOGON_NT_VERSION_5EX; + response->nt5_ex = response_5_ex; + break; + + case NETLOGON_NT_VERSION_1: + ZERO_STRUCT(response_5_ex); + response_5_ex.command = response->nt4.command; + response_5_ex.pdc_name = response->nt4.server; + response_5_ex.user_name = response->nt4.user_name; + response_5_ex.domain = response->nt4.domain; + response_5_ex.nt_version = response->nt4.nt_version; + response_5_ex.lmnt_token = response->nt4.lmnt_token; + response_5_ex.lm20_token = response->nt4.lm20_token; + response->ntver = NETLOGON_NT_VERSION_5EX; + response->nt5_ex = response_5_ex; + break; + } + return; +} + +NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct nbt_netlogon_response *response) +{ + NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE; + enum ndr_err_code ndr_err; + switch (response->response_type) { + case NETLOGON_GET_PDC: + ndr_err = ndr_push_struct_blob(data, mem_ctx, iconv_convenience, &response->get_pdc, + (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_response_from_pdc); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("Failed to parse netlogon packet of length %d: %s\n", + (int)data->length, nt_errstr(status))); + if (DEBUGLVL(10)) { + file_save("netlogon.dat", data->data, data->length); + } + return status; + } + status = NT_STATUS_OK; + break; + case NETLOGON_SAMLOGON: + status = push_netlogon_samlogon_response(data, mem_ctx, iconv_convenience, &response->samlogon); + break; + } + return status; +} + + +NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct nbt_netlogon_response *response) +{ + NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE; + enum netlogon_command command; + enum ndr_err_code ndr_err; + if (data->length < 4) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + command = SVAL(data->data, 0); + + switch (command) { + case NETLOGON_RESPONSE_FROM_PDC: + ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, iconv_convenience, &response->get_pdc, + (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_response_from_pdc); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("Failed to parse netlogon packet of length %d: %s\n", + (int)data->length, nt_errstr(status))); + if (DEBUGLVL(10)) { + file_save("netlogon.dat", data->data, data->length); + } + return status; + } + status = NT_STATUS_OK; + response->response_type = NETLOGON_GET_PDC; + break; + case LOGON_SAM_LOGON_RESPONSE: + case LOGON_SAM_LOGON_PAUSE_RESPONSE: + case LOGON_SAM_LOGON_USER_UNKNOWN: + case LOGON_SAM_LOGON_RESPONSE_EX: + case LOGON_SAM_LOGON_PAUSE_RESPONSE_EX: + case LOGON_SAM_LOGON_USER_UNKNOWN_EX: + status = pull_netlogon_samlogon_response(data, mem_ctx, iconv_convenience, &response->samlogon); + response->response_type = NETLOGON_SAMLOGON; + break; + + /* These levels are queries, not responses */ + case LOGON_PRIMARY_QUERY: + case NETLOGON_ANNOUNCE_UAS: + case LOGON_SAM_LOGON_REQUEST: + status = NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + return status; + +} diff --git a/source4/libcli/netlogon.h b/source4/libcli/netlogon.h new file mode 100644 index 0000000000..177ed3a514 --- /dev/null +++ b/source4/libcli/netlogon.h @@ -0,0 +1,54 @@ +/* + Unix SMB/CIFS implementation. + + CLDAP server structures + + Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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 __LIBCLI_NETLOGON_H__ +#define __LIBCLI_NETLOGON_H__ + +#include "librpc/gen_ndr/ndr_nbt.h" + +#include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/gen_ndr/ndr_security.h" +#include "librpc/gen_ndr/ndr_svcctl.h" +#include "librpc/gen_ndr/ndr_samr.h" + +struct netlogon_samlogon_response +{ + uint32_t ntver; + union { + struct NETLOGON_SAM_LOGON_RESPONSE_NT40 nt4; + struct NETLOGON_SAM_LOGON_RESPONSE nt5; + struct NETLOGON_SAM_LOGON_RESPONSE_EX nt5_ex; + }; + +}; + +struct nbt_netlogon_response +{ + enum {NETLOGON_GET_PDC, NETLOGON_SAMLOGON} response_type; + union { + struct nbt_netlogon_response_from_pdc get_pdc; + struct netlogon_samlogon_response samlogon; + }; +}; + +#include "libcli/netlogon_proto.h" +#include "libcli/ndr_netlogon_proto.h" +#endif /* __CLDAP_SERVER_PROTO_H__ */ diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index bad3743721..871bab01db 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -2354,10 +2354,11 @@ union smb_search_first { #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26 -/* flags for RAW_FILEINFO_SMB2_ALL_EAS */ +/* flags for SMB2 find */ #define SMB2_CONTINUE_FLAG_RESTART 0x01 #define SMB2_CONTINUE_FLAG_SINGLE 0x02 -#define SMB2_CONTINUE_FLAG_NEW 0x10 +#define SMB2_CONTINUE_FLAG_INDEX 0x04 +#define SMB2_CONTINUE_FLAG_REOPEN 0x10 /* SMB2 Find */ struct smb2_find { @@ -2370,7 +2371,7 @@ union smb_search_first { /* uint16_t buffer_code; 0x21 = 0x20 + 1 */ uint8_t level; uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */ - uint32_t unknown; /* perhaps a continue token? */ + uint32_t file_index; /* struct smb2_handle handle; */ /* uint16_t pattern_ofs; */ /* uint16_t pattern_size; */ diff --git a/source4/libcli/security/config.mk b/source4/libcli/security/config.mk index fde065aa34..63e54fac8a 100644 --- a/source4/libcli/security/config.mk +++ b/source4/libcli/security/config.mk @@ -1,14 +1,14 @@ [SUBSYSTEM::LIBSECURITY] -PRIVATE_PROTO_HEADER = proto.h PUBLIC_DEPENDENCIES = NDR_MISC LIBNDR -LIBSECURITY_OBJ_FILES = $(addprefix libcli/security/, \ +LIBSECURITY_OBJ_FILES = $(addprefix $(libclisrcdir)/security/, \ security_token.o security_descriptor.o \ dom_sid.o access_check.o privilege.o sddl.o) +$(eval $(call proto_header_template,$(libclisrcdir)/security/proto.h,$(LIBSECURITY_OBJ_FILES:.o=.c))) [PYTHON::swig_security] SWIG_FILE = security.i PRIVATE_DEPENDENCIES = LIBSECURITY -swig_security_OBJ_FILES = libcli/security/security_wrap.o +swig_security_OBJ_FILES = $(libclisrcdir)/security/security_wrap.o diff --git a/source4/libcli/smb2/config.mk b/source4/libcli/smb2/config.mk index 18f6245a3e..00b6305def 100644 --- a/source4/libcli/smb2/config.mk +++ b/source4/libcli/smb2/config.mk @@ -1,10 +1,10 @@ [SUBSYSTEM::LIBCLI_SMB2] -PRIVATE_PROTO_HEADER = smb2_proto.h PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBPACKET gensec -LIBCLI_SMB2_OBJ_FILES = $(addprefix libcli/smb2/, \ +LIBCLI_SMB2_OBJ_FILES = $(addprefix $(libclisrcdir)/smb2/, \ transport.o request.o negprot.o session.o tcon.o \ create.o close.o connect.o getinfo.o write.o read.o \ setinfo.o find.o ioctl.o logoff.o tdis.o flush.o \ - lock.o notify.o cancel.o keepalive.o break.o) + lock.o notify.o cancel.o keepalive.o break.o util.o) +$(eval $(call proto_header_template,$(libclisrcdir)/smb2/smb2_proto.h,$(LIBCLI_SMB2_OBJ_FILES:.o=.c))) diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c index 59d4e6ea2d..eabfa410ad 100644 --- a/source4/libcli/smb2/connect.c +++ b/source4/libcli/smb2/connect.c @@ -44,7 +44,7 @@ struct smb2_connect_state { */ static void continue_tcon(struct smb2_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); struct smb2_connect_state *state = talloc_get_type(c->private_data, struct smb2_connect_state); @@ -83,7 +83,7 @@ static void continue_session(struct composite_context *creq) if (composite_nomem(req, c)) return; req->async.fn = continue_tcon; - req->async.private = c; + req->async.private_data = c; } /* @@ -91,7 +91,7 @@ static void continue_session(struct composite_context *creq) */ static void continue_negprot(struct smb2_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); struct smb2_connect_state *state = talloc_get_type(c->private_data, struct smb2_connect_state); @@ -101,6 +101,9 @@ static void continue_negprot(struct smb2_request *req) c->status = smb2_negprot_recv(req, c, &state->negprot); if (!composite_is_ok(c)) return; + transport->negotiate.system_time = state->negprot.out.system_time; + transport->negotiate.server_start_time = state->negprot.out.server_start_time; + state->session = smb2_session_init(transport, global_loadparm, state, true); if (composite_nomem(state->session, c)) return; @@ -142,7 +145,7 @@ static void continue_socket(struct composite_context *creq) if (composite_nomem(req, c)) return; req->async.fn = continue_negprot; - req->async.private = c; + req->async.private_data = c; } diff --git a/source4/libcli/smb2/find.c b/source4/libcli/smb2/find.c index 6b4902a026..8ebfd81bcd 100644 --- a/source4/libcli/smb2/find.c +++ b/source4/libcli/smb2/find.c @@ -38,7 +38,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io SCVAL(req->out.body, 0x02, io->in.level); SCVAL(req->out.body, 0x03, io->in.continue_flags); - SIVAL(req->out.body, 0x04, io->in.unknown); + SIVAL(req->out.body, 0x04, io->in.file_index); smb2_push_handle(req->out.body+0x08, &io->in.file.handle); status = smb2_push_o16s16_string(&req->out, 0x18, io->in.pattern); diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index f52b0ceef2..64d427f889 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -43,6 +43,18 @@ void smb2_setup_bufinfo(struct smb2_request *req) } } + +/* destroy a request structure */ +static int smb2_request_destructor(struct smb2_request *req) +{ + if (req->transport) { + /* remove it from the list of pending requests (a null op if + its not in the list) */ + DLIST_REMOVE(req->transport->pending_recv, req); + } + return 0; +} + /* initialise a smb2 request */ @@ -122,6 +134,8 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_ SCVAL(req->out.dynamic, 0, 0); } + talloc_set_destructor(req, smb2_request_destructor); + return req; } @@ -154,18 +168,13 @@ NTSTATUS smb2_request_destroy(struct smb2_request *req) _send() call fails completely */ if (!req) return NT_STATUS_UNSUCCESSFUL; - if (req->transport) { - /* remove it from the list of pending requests (a null op if - its not in the list) */ - DLIST_REMOVE(req->transport->pending_recv, req); - } - if (req->state == SMB2_REQUEST_ERROR && NT_STATUS_IS_OK(req->status)) { - req->status = NT_STATUS_INTERNAL_ERROR; + status = NT_STATUS_INTERNAL_ERROR; + } else { + status = req->status; } - status = req->status; talloc_free(req); return status; } diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c index 18fe3486a4..29af6652f2 100644 --- a/source4/libcli/smb2/session.c +++ b/source4/libcli/smb2/session.c @@ -145,7 +145,7 @@ struct smb2_session_state { */ static void session_request_handler(struct smb2_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); struct smb2_session_state *state = talloc_get_type(c->private_data, struct smb2_session_state); @@ -178,7 +178,7 @@ static void session_request_handler(struct smb2_request *req) } state->req->async.fn = session_request_handler; - state->req->async.private = c; + state->req->async.private_data = c; return; } diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index ae66a6e0d3..b55da05e21 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef __LIBCLI_SMB2_SMB2_H__ +#define __LIBCLI_SMB2_SMB2_H__ + #include "libcli/raw/request.h" struct smb2_handle; @@ -32,6 +35,8 @@ struct smb2_options { */ struct smb2_negotiate { DATA_BLOB secblob; + NTTIME system_time; + NTTIME server_start_time; }; /* this is the context for the smb2 transport layer */ @@ -165,7 +170,7 @@ struct smb2_request { */ struct { void (*fn)(struct smb2_request *); - void *private; + void *private_data; } async; }; @@ -282,3 +287,5 @@ struct smb2_request { return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) + +#endif diff --git a/source4/libcli/smb2/util.c b/source4/libcli/smb2/util.c new file mode 100644 index 0000000000..9eb344e83f --- /dev/null +++ b/source4/libcli/smb2/util.c @@ -0,0 +1,200 @@ +/* + Unix SMB/CIFS implementation. + + SMB2 client utility functions + + Copyright (C) Andrew Tridgell 2005 + + 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 "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" +#include "libcli/smb_composite/smb_composite.h" + +/* + simple close wrapper with SMB2 +*/ +NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h) +{ + struct smb2_close c; + + ZERO_STRUCT(c); + c.in.file.handle = h; + + return smb2_close(tree, &c); +} + +/* + unlink a file with SMB2 +*/ +NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) +{ + union smb_unlink io; + + ZERO_STRUCT(io); + io.unlink.in.pattern = fname; + + return smb2_composite_unlink(tree, &io); +} + + +/* + rmdir with SMB2 +*/ +NTSTATUS smb2_util_rmdir(struct smb2_tree *tree, const char *dname) +{ + struct smb_rmdir io; + + ZERO_STRUCT(io); + io.in.path = dname; + + return smb2_composite_rmdir(tree, &io); +} + + +/* + mkdir with SMB2 +*/ +NTSTATUS smb2_util_mkdir(struct smb2_tree *tree, const char *dname) +{ + union smb_mkdir io; + + ZERO_STRUCT(io); + io.mkdir.level = RAW_MKDIR_MKDIR; + io.mkdir.in.path = dname; + + return smb2_composite_mkdir(tree, &io); +} + + +/* + set file attribute with SMB2 +*/ +NTSTATUS smb2_util_setatr(struct smb2_tree *tree, const char *name, uint32_t attrib) +{ + union smb_setfileinfo io; + + ZERO_STRUCT(io); + io.basic_info.level = RAW_SFILEINFO_BASIC_INFORMATION; + io.basic_info.in.file.path = name; + io.basic_info.in.attrib = attrib; + + return smb2_composite_setpathinfo(tree, &io); +} + + + + +/* + recursively descend a tree deleting all files + returns the number of files deleted, or -1 on error +*/ +int smb2_deltree(struct smb2_tree *tree, const char *dname) +{ + NTSTATUS status; + uint32_t total_deleted = 0; + uint_t count, i; + union smb_search_data *list; + TALLOC_CTX *tmp_ctx = talloc_new(tree); + struct smb2_find f; + struct smb2_create create_parm; + + /* it might be a file */ + status = smb2_util_unlink(tree, dname); + if (NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return 1; + } + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) || + NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND) || + NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) { + talloc_free(tmp_ctx); + return 0; + } + + ZERO_STRUCT(create_parm); + create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED; + create_parm.in.share_access = + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + create_parm.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + create_parm.in.create_disposition = NTCREATEX_DISP_OPEN; + create_parm.in.fname = dname; + + status = smb2_create(tree, tmp_ctx, &create_parm); + if (NT_STATUS_IS_ERR(status)) { + DEBUG(2,("Failed to open %s - %s\n", dname, nt_errstr(status))); + talloc_free(tmp_ctx); + return -1; + } + + + ZERO_STRUCT(f); + f.in.file.handle = create_parm.out.file.handle; + f.in.max_response_size = 0x10000; + f.in.level = SMB2_FIND_NAME_INFO; + f.in.pattern = "*"; + + status = smb2_find_level(tree, tmp_ctx, &f, &count, &list); + if (NT_STATUS_IS_ERR(status)) { + DEBUG(2,("Failed to list %s - %s\n", + dname, nt_errstr(status))); + smb2_util_close(tree, create_parm.out.file.handle); + talloc_free(tmp_ctx); + return -1; + } + + for (i=0;i<count;i++) { + char *name; + if (strcmp(".", list[i].name_info.name.s) == 0 || + strcmp("..", list[i].name_info.name.s) == 0) { + continue; + } + name = talloc_asprintf(tmp_ctx, "%s\\%s", dname, list[i].name_info.name.s); + status = smb2_util_unlink(tree, name); + if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { + /* it could be read-only */ + status = smb2_util_setatr(tree, name, FILE_ATTRIBUTE_NORMAL); + status = smb2_util_unlink(tree, name); + } + + if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) { + int ret; + ret = smb2_deltree(tree, name); + if (ret > 0) total_deleted += ret; + } + talloc_free(name); + if (NT_STATUS_IS_OK(status)) { + total_deleted++; + } + } + + smb2_util_close(tree, create_parm.out.file.handle); + + status = smb2_util_rmdir(tree, dname); + if (NT_STATUS_IS_ERR(status)) { + DEBUG(2,("Failed to delete %s - %s\n", + dname, nt_errstr(status))); + talloc_free(tmp_ctx); + return -1; + } + + talloc_free(tmp_ctx); + + return total_deleted; +} diff --git a/source4/libcli/smb_composite/smb2.c b/source4/libcli/smb_composite/smb2.c new file mode 100644 index 0000000000..6e005e03c0 --- /dev/null +++ b/source4/libcli/smb_composite/smb2.c @@ -0,0 +1,371 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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/>. +*/ +/* + a composite API for making SMB-like calls using SMB2. This is useful + as SMB2 often requires more than one requests where a single SMB + request would do. In converting code that uses SMB to use SMB2, + these routines make life a lot easier +*/ + + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" +#include "libcli/composite/composite.h" +#include "libcli/smb_composite/smb_composite.h" +#include "param/param.h" +#include "libcli/smb2/smb2_calls.h" + +/* + continue after a SMB2 close + */ +static void continue_close(struct smb2_request *req) +{ + struct composite_context *ctx = talloc_get_type(req->async.private_data, + struct composite_context); + NTSTATUS status; + struct smb2_close close_parm; + + status = smb2_close_recv(req, &close_parm); + composite_error(ctx, status); +} + +/* + continue after the create in a composite unlink + */ +static void continue_unlink(struct smb2_request *req) +{ + struct composite_context *ctx = talloc_get_type(req->async.private_data, + struct composite_context); + struct smb2_tree *tree = req->tree; + struct smb2_create create_parm; + struct smb2_close close_parm; + NTSTATUS status; + + status = smb2_create_recv(req, ctx, &create_parm); + if (!NT_STATUS_IS_OK(status)) { + composite_error(ctx, status); + return; + } + + ZERO_STRUCT(close_parm); + close_parm.in.file.handle = create_parm.out.file.handle; + + req = smb2_close_send(tree, &close_parm); + composite_continue_smb2(ctx, req, continue_close, ctx); +} + +/* + composite SMB2 unlink call +*/ +struct composite_context *smb2_composite_unlink_send(struct smb2_tree *tree, + union smb_unlink *io) +{ + struct composite_context *ctx; + struct smb2_create create_parm; + struct smb2_request *req; + + ctx = composite_create(tree, tree->session->transport->socket->event.ctx); + if (ctx == NULL) return NULL; + + /* check for wildcards - we could support these with a + search, but for now they aren't necessary */ + if (strpbrk(io->unlink.in.pattern, "*?<>") != NULL) { + composite_error(ctx, NT_STATUS_NOT_SUPPORTED); + return ctx; + } + + ZERO_STRUCT(create_parm); + create_parm.in.desired_access = SEC_STD_DELETE; + create_parm.in.create_disposition = NTCREATEX_DISP_OPEN; + create_parm.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + create_parm.in.create_options = + NTCREATEX_OPTIONS_DELETE_ON_CLOSE | + NTCREATEX_OPTIONS_NON_DIRECTORY_FILE; + create_parm.in.fname = io->unlink.in.pattern; + if (create_parm.in.fname[0] == '\\') { + create_parm.in.fname++; + } + + req = smb2_create_send(tree, &create_parm); + + composite_continue_smb2(ctx, req, continue_unlink, ctx); + return ctx; +} + + +/* + composite unlink call - sync interface +*/ +NTSTATUS smb2_composite_unlink(struct smb2_tree *tree, union smb_unlink *io) +{ + struct composite_context *c = smb2_composite_unlink_send(tree, io); + return composite_wait_free(c); +} + + + + +/* + continue after the create in a composite mkdir + */ +static void continue_mkdir(struct smb2_request *req) +{ + struct composite_context *ctx = talloc_get_type(req->async.private_data, + struct composite_context); + struct smb2_tree *tree = req->tree; + struct smb2_create create_parm; + struct smb2_close close_parm; + NTSTATUS status; + + status = smb2_create_recv(req, ctx, &create_parm); + if (!NT_STATUS_IS_OK(status)) { + composite_error(ctx, status); + return; + } + + ZERO_STRUCT(close_parm); + close_parm.in.file.handle = create_parm.out.file.handle; + + req = smb2_close_send(tree, &close_parm); + composite_continue_smb2(ctx, req, continue_close, ctx); +} + +/* + composite SMB2 mkdir call +*/ +struct composite_context *smb2_composite_mkdir_send(struct smb2_tree *tree, + union smb_mkdir *io) +{ + struct composite_context *ctx; + struct smb2_create create_parm; + struct smb2_request *req; + + ctx = composite_create(tree, tree->session->transport->socket->event.ctx); + if (ctx == NULL) return NULL; + + ZERO_STRUCT(create_parm); + + create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED; + create_parm.in.share_access = + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + create_parm.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + create_parm.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY; + create_parm.in.create_disposition = NTCREATEX_DISP_CREATE; + create_parm.in.fname = io->mkdir.in.path; + if (create_parm.in.fname[0] == '\\') { + create_parm.in.fname++; + } + + req = smb2_create_send(tree, &create_parm); + + composite_continue_smb2(ctx, req, continue_mkdir, ctx); + + return ctx; +} + + +/* + composite mkdir call - sync interface +*/ +NTSTATUS smb2_composite_mkdir(struct smb2_tree *tree, union smb_mkdir *io) +{ + struct composite_context *c = smb2_composite_mkdir_send(tree, io); + return composite_wait_free(c); +} + + + +/* + continue after the create in a composite rmdir + */ +static void continue_rmdir(struct smb2_request *req) +{ + struct composite_context *ctx = talloc_get_type(req->async.private_data, + struct composite_context); + struct smb2_tree *tree = req->tree; + struct smb2_create create_parm; + struct smb2_close close_parm; + NTSTATUS status; + + status = smb2_create_recv(req, ctx, &create_parm); + if (!NT_STATUS_IS_OK(status)) { + composite_error(ctx, status); + return; + } + + ZERO_STRUCT(close_parm); + close_parm.in.file.handle = create_parm.out.file.handle; + + req = smb2_close_send(tree, &close_parm); + composite_continue_smb2(ctx, req, continue_close, ctx); +} + +/* + composite SMB2 rmdir call +*/ +struct composite_context *smb2_composite_rmdir_send(struct smb2_tree *tree, + struct smb_rmdir *io) +{ + struct composite_context *ctx; + struct smb2_create create_parm; + struct smb2_request *req; + + ctx = composite_create(tree, tree->session->transport->socket->event.ctx); + if (ctx == NULL) return NULL; + + ZERO_STRUCT(create_parm); + create_parm.in.desired_access = SEC_STD_DELETE; + create_parm.in.create_disposition = NTCREATEX_DISP_OPEN; + create_parm.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + create_parm.in.create_options = + NTCREATEX_OPTIONS_DIRECTORY | + NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + create_parm.in.fname = io->in.path; + if (create_parm.in.fname[0] == '\\') { + create_parm.in.fname++; + } + + req = smb2_create_send(tree, &create_parm); + + composite_continue_smb2(ctx, req, continue_rmdir, ctx); + return ctx; +} + + +/* + composite rmdir call - sync interface +*/ +NTSTATUS smb2_composite_rmdir(struct smb2_tree *tree, struct smb_rmdir *io) +{ + struct composite_context *c = smb2_composite_rmdir_send(tree, io); + return composite_wait_free(c); +} + + +/* + continue after the setfileinfo in a composite setpathinfo + */ +static void continue_setpathinfo_close(struct smb2_request *req) +{ + struct composite_context *ctx = talloc_get_type(req->async.private_data, + struct composite_context); + struct smb2_tree *tree = req->tree; + struct smb2_close close_parm; + NTSTATUS status; + union smb_setfileinfo *io2 = talloc_get_type(ctx->private_data, + union smb_setfileinfo); + + status = smb2_setinfo_recv(req); + if (!NT_STATUS_IS_OK(status)) { + composite_error(ctx, status); + return; + } + + ZERO_STRUCT(close_parm); + close_parm.in.file.handle = io2->generic.in.file.handle; + + req = smb2_close_send(tree, &close_parm); + composite_continue_smb2(ctx, req, continue_close, ctx); +} + + +/* + continue after the create in a composite setpathinfo + */ +static void continue_setpathinfo(struct smb2_request *req) +{ + struct composite_context *ctx = talloc_get_type(req->async.private_data, + struct composite_context); + struct smb2_tree *tree = req->tree; + struct smb2_create create_parm; + NTSTATUS status; + union smb_setfileinfo *io2 = talloc_get_type(ctx->private_data, + union smb_setfileinfo); + + status = smb2_create_recv(req, ctx, &create_parm); + if (!NT_STATUS_IS_OK(status)) { + composite_error(ctx, status); + return; + } + + io2->generic.in.file.handle = create_parm.out.file.handle; + + req = smb2_setinfo_file_send(tree, io2); + composite_continue_smb2(ctx, req, continue_setpathinfo_close, ctx); +} + + +/* + composite SMB2 setpathinfo call +*/ +struct composite_context *smb2_composite_setpathinfo_send(struct smb2_tree *tree, + union smb_setfileinfo *io) +{ + struct composite_context *ctx; + struct smb2_create create_parm; + struct smb2_request *req; + union smb_setfileinfo *io2; + + ctx = composite_create(tree, tree->session->transport->socket->event.ctx); + if (ctx == NULL) return NULL; + + ZERO_STRUCT(create_parm); + create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED; + create_parm.in.create_disposition = NTCREATEX_DISP_OPEN; + create_parm.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + create_parm.in.create_options = 0; + create_parm.in.fname = io->generic.in.file.path; + if (create_parm.in.fname[0] == '\\') { + create_parm.in.fname++; + } + + req = smb2_create_send(tree, &create_parm); + + io2 = talloc(ctx, union smb_setfileinfo); + if (composite_nomem(io2, ctx)) { + return ctx; + } + *io2 = *io; + + ctx->private_data = io2; + + composite_continue_smb2(ctx, req, continue_setpathinfo, ctx); + return ctx; +} + + +/* + composite setpathinfo call + */ +NTSTATUS smb2_composite_setpathinfo(struct smb2_tree *tree, union smb_setfileinfo *io) +{ + struct composite_context *c = smb2_composite_setpathinfo_send(tree, io); + return composite_wait_free(c); +} diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h index afee11ce3b..7f4b9d73e4 100644 --- a/source4/libcli/smb_composite/smb_composite.h +++ b/source4/libcli/smb_composite/smb_composite.h @@ -29,6 +29,7 @@ #include "libcli/raw/signing.h" #include "libcli/raw/libcliraw.h" +#include "libcli/smb2/smb2.h" /* diff --git a/source4/libcli/wbclient/config.mk b/source4/libcli/wbclient/config.mk index 94e30d44f1..00df5dbb22 100644 --- a/source4/libcli/wbclient/config.mk +++ b/source4/libcli/wbclient/config.mk @@ -2,4 +2,4 @@ PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBEVENTS PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING -LIBWBCLIENT_OBJ_FILES = libcli/wbclient/wbclient.o +LIBWBCLIENT_OBJ_FILES = $(libclisrcdir)/wbclient/wbclient.o diff --git a/source4/libnet/config.mk b/source4/libnet/config.mk index 243fc1813a..f60ca6d94d 100644 --- a/source4/libnet/config.mk +++ b/source4/libnet/config.mk @@ -1,8 +1,7 @@ [SUBSYSTEM::LIBSAMBA-NET] -PRIVATE_PROTO_HEADER = libnet_proto.h PUBLIC_DEPENDENCIES = CREDENTIALS dcerpc dcerpc_samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI LIBCLI_COMPOSITE LIBCLI_RESOLVE LIBCLI_FINDDCS LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH LIBNDR SMBPASSWD PROVISION -LIBSAMBA-NET_OBJ_FILES = $(addprefix libnet/, \ +LIBSAMBA-NET_OBJ_FILES = $(addprefix $(libnetsrcdir)/, \ libnet.o libnet_passwd.o libnet_time.o libnet_rpc.o \ libnet_join.o libnet_site.o libnet_become_dc.o libnet_unbecome_dc.o \ libnet_vampire.o libnet_samdump.o libnet_samdump_keytab.o \ @@ -10,7 +9,9 @@ LIBSAMBA-NET_OBJ_FILES = $(addprefix libnet/, \ libnet_lookup.o libnet_domain.o userinfo.o groupinfo.o userman.o \ groupman.o prereq_domain.o libnet_samsync.o) +$(eval $(call proto_header_template,$(libnetsrcdir)/libnet_proto.h,$(LIBSAMBA-NET_OBJ_FILES:.o=.c))) + [PYTHON::python_net] PRIVATE_DEPENDENCIES = LIBSAMBA-NET -python_net_OBJ_FILES = libnet/py_net.o +python_net_OBJ_FILES = $(libnetsrcdir)/py_net.o diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index e8a5329985..1c4c1d0732 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -30,6 +30,7 @@ #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_security.h" +#include "librpc/gen_ndr/ndr_nbt.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "auth/gensec/gensec.h" #include "param/param.h" @@ -687,7 +688,7 @@ struct libnet_BecomeDC_state { struct { struct cldap_socket *sock; struct cldap_netlogon io; - struct nbt_cldap_netlogon_5 netlogon5; + struct NETLOGON_SAM_LOGON_RESPONSE_EX netlogon; } cldap; struct becomeDC_ldap { @@ -745,7 +746,8 @@ static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s) s->cldap.io.in.domain_guid = NULL; s->cldap.io.in.domain_sid = NULL; s->cldap.io.in.acct_control = -1; - s->cldap.io.in.version = 6; + s->cldap.io.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + s->cldap.io.in.map_response = true; s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx, lp_iconv_convenience(s->libnet->lp_ctx)); @@ -768,19 +770,19 @@ static void becomeDC_recv_cldap(struct cldap_request *req) c->status = cldap_netlogon_recv(req, s, &s->cldap.io); if (!composite_is_ok(c)) return; - s->cldap.netlogon5 = s->cldap.io.out.netlogon.logon5; + s->cldap.netlogon = s->cldap.io.out.netlogon.nt5_ex; - s->domain.dns_name = s->cldap.netlogon5.dns_domain; - s->domain.netbios_name = s->cldap.netlogon5.domain; - s->domain.guid = s->cldap.netlogon5.domain_uuid; + s->domain.dns_name = s->cldap.netlogon.dns_domain; + s->domain.netbios_name = s->cldap.netlogon.domain; + s->domain.guid = s->cldap.netlogon.domain_uuid; - s->forest.dns_name = s->cldap.netlogon5.forest; + s->forest.dns_name = s->cldap.netlogon.forest; - s->source_dsa.dns_name = s->cldap.netlogon5.pdc_dns_name; - s->source_dsa.netbios_name = s->cldap.netlogon5.pdc_name; - s->source_dsa.site_name = s->cldap.netlogon5.server_site; + s->source_dsa.dns_name = s->cldap.netlogon.pdc_dns_name; + s->source_dsa.netbios_name = s->cldap.netlogon.pdc_name; + s->source_dsa.site_name = s->cldap.netlogon.server_site; - s->dest_dsa.site_name = s->cldap.netlogon5.client_site; + s->dest_dsa.site_name = s->cldap.netlogon.client_site; becomeDC_connect_ldap1(s); } diff --git a/source4/libnet/libnet_site.c b/source4/libnet/libnet_site.c index f39d9e039c..bb65de1f54 100644 --- a/source4/libnet/libnet_site.c +++ b/source4/libnet/libnet_site.c @@ -53,11 +53,12 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li search.in.dest_address = r->in.dest_address; search.in.dest_port = r->in.cldap_port; search.in.acct_control = -1; - search.in.version = 6; + search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + search.in.map_response = true; cldap = cldap_socket_init(tmp_ctx, lctx->event_ctx, lp_iconv_convenience(global_loadparm)); status = cldap_netlogon(cldap, tmp_ctx, &search); - if (!NT_STATUS_IS_OK(status)) { + if (!NT_STATUS_IS_OK(status) || !search.out.netlogon.nt5_ex.client_site) { /* If cldap_netlogon() returns in error, default to using Default-First-Site-Name. @@ -71,7 +72,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li } } else { site_name_str = talloc_asprintf(tmp_ctx, "%s", - search.out.netlogon.logon5.client_site); + search.out.netlogon.nt5_ex.client_site); if (!site_name_str) { r->out.error_string = NULL; talloc_free(tmp_ctx); diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c index 6f06585880..cff919018a 100644 --- a/source4/libnet/libnet_unbecome_dc.c +++ b/source4/libnet/libnet_unbecome_dc.c @@ -193,7 +193,7 @@ struct libnet_UnbecomeDC_state { struct { struct cldap_socket *sock; struct cldap_netlogon io; - struct nbt_cldap_netlogon_5 netlogon5; + struct NETLOGON_SAM_LOGON_RESPONSE_EX netlogon; } cldap; struct { @@ -265,7 +265,8 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s) s->cldap.io.in.domain_guid = NULL; s->cldap.io.in.domain_sid = NULL; s->cldap.io.in.acct_control = -1; - s->cldap.io.in.version = 6; + s->cldap.io.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + s->cldap.io.in.map_response = true; s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx, lp_iconv_convenience(s->libnet->lp_ctx)); @@ -288,17 +289,17 @@ static void unbecomeDC_recv_cldap(struct cldap_request *req) c->status = cldap_netlogon_recv(req, s, &s->cldap.io); if (!composite_is_ok(c)) return; - s->cldap.netlogon5 = s->cldap.io.out.netlogon.logon5; + s->cldap.netlogon = s->cldap.io.out.netlogon.nt5_ex; - s->domain.dns_name = s->cldap.netlogon5.dns_domain; - s->domain.netbios_name = s->cldap.netlogon5.domain; - s->domain.guid = s->cldap.netlogon5.domain_uuid; + s->domain.dns_name = s->cldap.netlogon.dns_domain; + s->domain.netbios_name = s->cldap.netlogon.domain; + s->domain.guid = s->cldap.netlogon.domain_uuid; - s->source_dsa.dns_name = s->cldap.netlogon5.pdc_dns_name; - s->source_dsa.netbios_name = s->cldap.netlogon5.pdc_name; - s->source_dsa.site_name = s->cldap.netlogon5.server_site; + s->source_dsa.dns_name = s->cldap.netlogon.pdc_dns_name; + s->source_dsa.netbios_name = s->cldap.netlogon.pdc_name; + s->source_dsa.site_name = s->cldap.netlogon.server_site; - s->dest_dsa.site_name = s->cldap.netlogon5.client_site; + s->dest_dsa.site_name = s->cldap.netlogon.client_site; unbecomeDC_connect_ldap(s); } diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 24fad8c9c4..69dafb34c6 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -1,20 +1,25 @@ +ndrsrcdir = $(librpcsrcdir)/ndr +gen_ndrsrcdir = $(librpcsrcdir)/gen_ndr +dcerpcsrcdir = $(librpcsrcdir)/rpc + ################################################ # Start SUBSYSTEM LIBNDR [LIBRARY::LIBNDR] -PRIVATE_PROTO_HEADER = ndr/libndr_proto.h PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET \ LIBSAMBA-HOSTCONFIG -LIBNDR_OBJ_FILES = $(addprefix librpc/ndr/, ndr.o ndr_basic.o ndr_string.o uuid.o) +LIBNDR_OBJ_FILES = $(addprefix $(ndrsrcdir)/, ndr.o ndr_basic.o ndr_string.o uuid.o) + +$(eval $(call proto_header_template,$(ndrsrcdir)/libndr_proto.h,$(LIBNDR_OBJ_FILES:.o=.c))) -PC_FILES += librpc/ndr.pc +PC_FILES += $(librpcsrcdir)/ndr.pc LIBNDR_VERSION = 0.0.1 LIBNDR_SOVERSION = 0 # End SUBSYSTEM LIBNDR ################################################ -PUBLIC_HEADERS += librpc/ndr/libndr.h +PUBLIC_HEADERS += $(ndrsrcdir)/libndr.h ################################# # Start BINARY ndrdump @@ -31,332 +36,333 @@ PRIVATE_DEPENDENCIES = \ # End BINARY ndrdump ################################# -ndrdump_OBJ_FILES = librpc/tools/ndrdump.o +ndrdump_OBJ_FILES = $(librpcsrcdir)/tools/ndrdump.o -MANPAGES += librpc/tools/ndrdump.1 +MANPAGES += $(librpcsrcdir)/tools/ndrdump.1 ################################################ # Start SUBSYSTEM NDR_COMPRESSION [SUBSYSTEM::NDR_COMPRESSION] -PRIVATE_PROTO_HEADER = ndr/ndr_compression.h PUBLIC_DEPENDENCIES = LIBCOMPRESSION LIBSAMBA-ERRORS LIBNDR # End SUBSYSTEM NDR_COMPRESSION ################################################ -NDR_COMPRESSION_OBJ_FILES = librpc/ndr/ndr_compression.o +NDR_COMPRESSION_OBJ_FILES = $(ndrsrcdir)/ndr_compression.o + +$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_compression.h,$(NDR_COMPRESSION_OBJ_FILES:.o=.c))) [SUBSYSTEM::NDR_SECURITY] PUBLIC_DEPENDENCIES = NDR_MISC LIBSECURITY -NDR_SECURITY_OBJ_FILES = librpc/gen_ndr/ndr_security.o librpc/ndr/ndr_sec_helper.o +NDR_SECURITY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_security.o $(ndrsrcdir)/ndr_sec_helper.o -PUBLIC_HEADERS += librpc/gen_ndr/security.h +PUBLIC_HEADERS += $(gen_ndrsrcdir)/security.h [SUBSYSTEM::NDR_AUDIOSRV] PUBLIC_DEPENDENCIES = LIBNDR -NDR_AUDIOSRV_OBJ_FILES = librpc/gen_ndr/ndr_audiosrv.o +NDR_AUDIOSRV_OBJ_FILES = $(gen_ndrsrcdir)/ndr_audiosrv.o [SUBSYSTEM::NDR_DNSSERVER] PUBLIC_DEPENDENCIES = LIBNDR -NDR_DNSSERVER_OBJ_FILES = librpc/gen_ndr/ndr_dnsserver.o +NDR_DNSSERVER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dnsserver.o [SUBSYSTEM::NDR_WINSTATION] PUBLIC_DEPENDENCIES = LIBNDR -NDR_WINSTATION_OBJ_FILES = librpc/gen_ndr/ndr_winstation.o +NDR_WINSTATION_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winstation.o [SUBSYSTEM::NDR_ECHO] PUBLIC_DEPENDENCIES = LIBNDR -NDR_ECHO_OBJ_FILES = librpc/gen_ndr/ndr_echo.o +NDR_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo.o [SUBSYSTEM::NDR_IRPC] PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY NDR_NBT -NDR_IRPC_OBJ_FILES = librpc/gen_ndr/ndr_irpc.o +NDR_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc.o [SUBSYSTEM::NDR_DSBACKUP] PUBLIC_DEPENDENCIES = LIBNDR -NDR_DSBACKUP_OBJ_FILES = librpc/gen_ndr/ndr_dsbackup.o +NDR_DSBACKUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dsbackup.o [SUBSYSTEM::NDR_EFS] PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY -NDR_EFS_OBJ_FILES = librpc/gen_ndr/ndr_efs.o +NDR_EFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_efs.o [SUBSYSTEM::NDR_MISC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_MISC_OBJ_FILES = librpc/gen_ndr/ndr_misc.o librpc/ndr/ndr_misc.o +NDR_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc.o $(ndrsrcdir)/ndr_misc.o -PUBLIC_HEADERS += librpc/gen_ndr/misc.h librpc/gen_ndr/ndr_misc.h +PUBLIC_HEADERS += $(gen_ndrsrcdir)/misc.h $(gen_ndrsrcdir)/ndr_misc.h [SUBSYSTEM::NDR_ROT] PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC -NDR_ROT_OBJ_FILES = librpc/gen_ndr/ndr_rot.o +NDR_ROT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_rot.o [SUBSYSTEM::NDR_LSA] PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY -NDR_LSA_OBJ_FILES = librpc/gen_ndr/ndr_lsa.o +NDR_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa.o -PUBLIC_HEADERS += librpc/gen_ndr/lsa.h +PUBLIC_HEADERS += $(gen_ndrsrcdir)/lsa.h [SUBSYSTEM::NDR_DFS] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC -NDR_DFS_OBJ_FILES = librpc/gen_ndr/ndr_dfs.o +NDR_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs.o [SUBSYSTEM::NDR_FRSRPC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_FRSRPC_OBJ_FILES = librpc/gen_ndr/ndr_frsrpc.o +NDR_FRSRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsrpc.o [SUBSYSTEM::NDR_FRSAPI] PUBLIC_DEPENDENCIES = LIBNDR -NDR_FRSAPI_OBJ_FILES = librpc/gen_ndr/ndr_frsapi.o +NDR_FRSAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsapi.o [SUBSYSTEM::NDR_DRSUAPI] PUBLIC_DEPENDENCIES = LIBNDR NDR_COMPRESSION NDR_SECURITY NDR_SAMR ASN1_UTIL -NDR_DRSUAPI_OBJ_FILES = librpc/gen_ndr/ndr_drsuapi.o librpc/ndr/ndr_drsuapi.o +NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi.o $(ndrsrcdir)/ndr_drsuapi.o [SUBSYSTEM::NDR_DRSBLOBS] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI -NDR_DRSBLOBS_OBJ_FILES = librpc/gen_ndr/ndr_drsblobs.o +NDR_DRSBLOBS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsblobs.o [SUBSYSTEM::NDR_SASL_HELPERS] PUBLIC_DEPENDENCIES = LIBNDR -NDR_SASL_HELPERS_OBJ_FILES = librpc/gen_ndr/ndr_sasl_helpers.o +NDR_SASL_HELPERS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_sasl_helpers.o [SUBSYSTEM::NDR_POLICYAGENT] PUBLIC_DEPENDENCIES = LIBNDR -NDR_POLICYAGENT_OBJ_FILES = librpc/gen_ndr/ndr_policyagent.o +NDR_POLICYAGENT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_policyagent.o [SUBSYSTEM::NDR_UNIXINFO] PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY -NDR_UNIXINFO_OBJ_FILES = librpc/gen_ndr/ndr_unixinfo.o +NDR_UNIXINFO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_unixinfo.o [SUBSYSTEM::NDR_SAMR] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_LSA NDR_SECURITY -NDR_SAMR_OBJ_FILES = librpc/gen_ndr/ndr_samr.o +NDR_SAMR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr.o -PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/samr.h gen_ndr/ndr_samr.h gen_ndr/ndr_samr_c.h) +PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/samr.h gen_ndr/ndr_samr.h gen_ndr/ndr_samr_c.h) [SUBSYSTEM::NDR_NFS4ACL] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_SECURITY -NDR_NFS4ACL_OBJ_FILES = librpc/gen_ndr/ndr_nfs4acl.o +NDR_NFS4ACL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_nfs4acl.o [SUBSYSTEM::NDR_SPOOLSS] PUBLIC_DEPENDENCIES = LIBNDR NDR_SPOOLSS_BUF NDR_SECURITY -NDR_SPOOLSS_OBJ_FILES = librpc/gen_ndr/ndr_spoolss.o +NDR_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss.o [SUBSYSTEM::NDR_SPOOLSS_BUF] -PRIVATE_PROTO_HEADER = ndr/ndr_spoolss_buf.h -NDR_SPOOLSS_BUF_OBJ_FILES = librpc/ndr/ndr_spoolss_buf.o +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))) [SUBSYSTEM::NDR_WKSSVC] PUBLIC_DEPENDENCIES = LIBNDR NDR_SRVSVC NDR_MISC NDR_SECURITY -NDR_WKSSVC_OBJ_FILES = librpc/gen_ndr/ndr_wkssvc.o +NDR_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc.o [SUBSYSTEM::NDR_SRVSVC] PUBLIC_DEPENDENCIES = LIBNDR NDR_SVCCTL NDR_SECURITY -NDR_SRVSVC_OBJ_FILES = librpc/gen_ndr/ndr_srvsvc.o +NDR_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc.o [SUBSYSTEM::NDR_SVCCTL] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC -NDR_SVCCTL_OBJ_FILES = librpc/gen_ndr/ndr_svcctl.o +NDR_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl.o -PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/ndr_svcctl.h gen_ndr/svcctl.h) +PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/ndr_svcctl.h gen_ndr/svcctl.h) [SUBSYSTEM::NDR_ATSVC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_ATSVC_OBJ_FILES = librpc/gen_ndr/ndr_atsvc.o +NDR_ATSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_atsvc.o -PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/atsvc.h gen_ndr/ndr_atsvc.h) +PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/atsvc.h gen_ndr/ndr_atsvc.h) [SUBSYSTEM::NDR_EVENTLOG] PUBLIC_DEPENDENCIES = LIBNDR NDR_LSA -NDR_EVENTLOG_OBJ_FILES = librpc/gen_ndr/ndr_eventlog.o +NDR_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog.o [SUBSYSTEM::NDR_EPMAPPER] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC -NDR_EPMAPPER_OBJ_FILES = librpc/gen_ndr/ndr_epmapper.o +NDR_EPMAPPER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_epmapper.o [SUBSYSTEM::NDR_DBGIDL] PUBLIC_DEPENDENCIES = LIBNDR -NDR_DBGIDL_OBJ_FILES = librpc/gen_ndr/ndr_dbgidl.o +NDR_DBGIDL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dbgidl.o [SUBSYSTEM::NDR_DSSETUP] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC -NDR_DSSETUP_OBJ_FILES = librpc/gen_ndr/ndr_dssetup.o +NDR_DSSETUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dssetup.o [SUBSYSTEM::NDR_MSGSVC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_MSGSVC_OBJ_FILES = librpc/gen_ndr/ndr_msgsvc.o +NDR_MSGSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_msgsvc.o [SUBSYSTEM::NDR_WINS] PUBLIC_DEPENDENCIES = LIBNDR -NDR_WINS_OBJ_FILES = librpc/gen_ndr/ndr_wins.o +NDR_WINS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wins.o [SUBSYSTEM::NDR_WINREG] PUBLIC_DEPENDENCIES = LIBNDR NDR_INITSHUTDOWN NDR_SECURITY NDR_MISC -NDR_WINREG_OBJ_FILES = librpc/gen_ndr/ndr_winreg.o +NDR_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg.o [SUBSYSTEM::NDR_INITSHUTDOWN] PUBLIC_DEPENDENCIES = LIBNDR -NDR_INITSHUTDOWN_OBJ_FILES = librpc/gen_ndr/ndr_initshutdown.o +NDR_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown.o [SUBSYSTEM::NDR_MGMT] PUBLIC_DEPENDENCIES = LIBNDR -NDR_MGMT_OBJ_FILES = librpc/gen_ndr/ndr_mgmt.o +NDR_MGMT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_mgmt.o [SUBSYSTEM::NDR_PROTECTED_STORAGE] PUBLIC_DEPENDENCIES = LIBNDR -NDR_PROTECTED_STORAGE_OBJ_FILES = librpc/gen_ndr/ndr_protected_storage.o +NDR_PROTECTED_STORAGE_OBJ_FILES = $(gen_ndrsrcdir)/ndr_protected_storage.o [SUBSYSTEM::NDR_ORPC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_ORPC_OBJ_FILES = librpc/gen_ndr/ndr_orpc.o librpc/ndr/ndr_orpc.o +NDR_ORPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_orpc.o $(ndrsrcdir)/ndr_orpc.o [SUBSYSTEM::NDR_OXIDRESOLVER] PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC NDR_MISC -NDR_OXIDRESOLVER_OBJ_FILES = librpc/gen_ndr/ndr_oxidresolver.o +NDR_OXIDRESOLVER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_oxidresolver.o [SUBSYSTEM::NDR_REMACT] PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC NDR_MISC -NDR_REMACT_OBJ_FILES = librpc/gen_ndr/ndr_remact.o +NDR_REMACT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_remact.o [SUBSYSTEM::NDR_WZCSVC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_WZCSVC_OBJ_FILES = librpc/gen_ndr/ndr_wzcsvc.o +NDR_WZCSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wzcsvc.o [SUBSYSTEM::NDR_BROWSER] PUBLIC_DEPENDENCIES = LIBNDR -NDR_BROWSER_OBJ_FILES = librpc/gen_ndr/ndr_browser.o +NDR_BROWSER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_browser.o [SUBSYSTEM::NDR_W32TIME] PUBLIC_DEPENDENCIES = LIBNDR -NDR_W32TIME_OBJ_FILES = librpc/gen_ndr/ndr_w32time.o +NDR_W32TIME_OBJ_FILES = $(gen_ndrsrcdir)/ndr_w32time.o [SUBSYSTEM::NDR_SCERPC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_SCERPC_OBJ_FILES = librpc/gen_ndr/ndr_scerpc.o +NDR_SCERPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_scerpc.o [SUBSYSTEM::NDR_NTSVCS] PUBLIC_DEPENDENCIES = LIBNDR -NDR_NTSVCS_OBJ_FILES = librpc/gen_ndr/ndr_ntsvcs.o +NDR_NTSVCS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_ntsvcs.o [SUBSYSTEM::NDR_NETLOGON] PUBLIC_DEPENDENCIES = LIBNDR NDR_SAMR NDR_LSA NDR_SECURITY -NDR_NETLOGON_OBJ_FILES = librpc/gen_ndr/ndr_netlogon.o +NDR_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon.o -PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/netlogon.h) +PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/netlogon.h) [SUBSYSTEM::NDR_TRKWKS] PUBLIC_DEPENDENCIES = LIBNDR -NDR_TRKWKS_OBJ_FILES = librpc/gen_ndr/ndr_trkwks.o +NDR_TRKWKS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_trkwks.o [SUBSYSTEM::NDR_KEYSVC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_KEYSVC_OBJ_FILES = librpc/gen_ndr/ndr_keysvc.o +NDR_KEYSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_keysvc.o [SUBSYSTEM::NDR_KRB5PAC] PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON NDR_SECURITY -NDR_KRB5PAC_OBJ_FILES = librpc/gen_ndr/ndr_krb5pac.o librpc/ndr/ndr_krb5pac.o +NDR_KRB5PAC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_krb5pac.o $(ndrsrcdir)/ndr_krb5pac.o [SUBSYSTEM::NDR_XATTR] PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY -NDR_XATTR_OBJ_FILES = librpc/gen_ndr/ndr_xattr.o +NDR_XATTR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_xattr.o [SUBSYSTEM::NDR_OPENDB] PUBLIC_DEPENDENCIES = LIBNDR -NDR_OPENDB_OBJ_FILES = librpc/gen_ndr/ndr_opendb.o +NDR_OPENDB_OBJ_FILES = $(gen_ndrsrcdir)/ndr_opendb.o [SUBSYSTEM::NDR_NOTIFY] PUBLIC_DEPENDENCIES = LIBNDR -NDR_NOTIFY_OBJ_FILES = librpc/gen_ndr/ndr_notify.o +NDR_NOTIFY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_notify.o [SUBSYSTEM::NDR_SCHANNEL] PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT -NDR_SCHANNEL_OBJ_FILES = librpc/gen_ndr/ndr_schannel.o +NDR_SCHANNEL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_schannel.o [SUBSYSTEM::NDR_NBT] -PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_NBT_BUF NDR_SVCCTL NDR_SECURITY +PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_NBT_BUF NDR_SVCCTL NDR_SECURITY NDR_SAMR LIBCLI_NDR_NETLOGON -NDR_NBT_OBJ_FILES = librpc/gen_ndr/ndr_nbt.o +NDR_NBT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_nbt.o -PUBLIC_HEADERS += librpc/gen_ndr/nbt.h +PUBLIC_HEADERS += $(gen_ndrsrcdir)/nbt.h [SUBSYSTEM::NDR_WINSREPL] PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT -NDR_WINSREPL_OBJ_FILES = librpc/gen_ndr/ndr_winsrepl.o +NDR_WINSREPL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winsrepl.o [SUBSYSTEM::NDR_WINBIND] PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON -NDR_WINBIND_OBJ_FILES = librpc/gen_ndr/ndr_winbind.o -#PUBLIC_HEADERS += librpc/gen_ndr/winbind.h +NDR_WINBIND_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winbind.o +#PUBLIC_HEADERS += $(gen_ndrsrcdir)/winbind.h -librpc/idl-deps: - ./librpc/idl-deps.pl librpc/idl/*.idl >$@ +$(librpcsrcdir)/idl-deps: + ./$(librpcsrcdir)/idl-deps.pl $(librpcsrcdir)/idl/*.idl >$@ clean:: - rm -f librpc/idl-deps + rm -f $(librpcsrcdir)/idl-deps -include librpc/idl-deps +include $(librpcsrcdir)/idl-deps -librpc/gen_ndr/tables.c: $(IDL_NDR_PARSE_H_FILES) +$(gen_ndrsrcdir)/tables.c: $(IDL_NDR_PARSE_H_FILES) @echo Generating $@ - @$(PERL) $(srcdir)/librpc/tables.pl --output=$@ $^ > librpc/gen_ndr/tables.x - @mv librpc/gen_ndr/tables.x $@ + @$(PERL) $(librpcsrcdir)/tables.pl --output=$@ $^ > $(gen_ndrsrcdir)/tables.x + @mv $(gen_ndrsrcdir)/tables.x $@ [SUBSYSTEM::NDR_TABLE] -PRIVATE_PROTO_HEADER = ndr/ndr_table.h PUBLIC_DEPENDENCIES = \ NDR_AUDIOSRV NDR_ECHO NDR_DCERPC \ NDR_DSBACKUP NDR_EFS NDR_MISC NDR_LSA NDR_DFS NDR_DRSUAPI \ @@ -369,93 +375,95 @@ PUBLIC_DEPENDENCIES = \ NDR_INITSHUTDOWN NDR_DNSSERVER NDR_WINSTATION NDR_IRPC NDR_OPENDB \ NDR_SASL_HELPERS NDR_NOTIFY NDR_WINBIND NDR_FRSRPC NDR_FRSAPI NDR_NFS4ACL -NDR_TABLE_OBJ_FILES = librpc/ndr/ndr_table.o librpc/gen_ndr/tables.o +NDR_TABLE_OBJ_FILES = $(ndrsrcdir)/ndr_table.o $(gen_ndrsrcdir)/tables.o + +$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_table.h,$(NDR_TABLE_OBJ_FILES:.o=.c))) [SUBSYSTEM::RPC_NDR_ROT] PUBLIC_DEPENDENCIES = NDR_ROT dcerpc -RPC_NDR_ROT_OBJ_FILES = librpc/gen_ndr/ndr_rot_c.o +RPC_NDR_ROT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_rot_c.o [SUBSYSTEM::RPC_NDR_AUDIOSRV] PUBLIC_DEPENDENCIES = NDR_AUDIOSRV dcerpc -RPC_NDR_AUDIOSRV_OBJ_FILES = librpc/gen_ndr/ndr_audiosrv_c.o +RPC_NDR_AUDIOSRV_OBJ_FILES = $(gen_ndrsrcdir)/ndr_audiosrv_c.o [SUBSYSTEM::RPC_NDR_ECHO] PUBLIC_DEPENDENCIES = dcerpc NDR_ECHO -RPC_NDR_ECHO_OBJ_FILES = librpc/gen_ndr/ndr_echo_c.o +RPC_NDR_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo_c.o [SUBSYSTEM::RPC_NDR_DSBACKUP] PUBLIC_DEPENDENCIES = dcerpc NDR_DSBACKUP -RPC_NDR_DSBACKUP_OBJ_FILES = librpc/gen_ndr/ndr_dsbackup_c.o +RPC_NDR_DSBACKUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dsbackup_c.o [SUBSYSTEM::RPC_NDR_EFS] PUBLIC_DEPENDENCIES = dcerpc NDR_EFS -RPC_NDR_EFS_OBJ_FILES = librpc/gen_ndr/ndr_efs_c.o +RPC_NDR_EFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_efs_c.o [SUBSYSTEM::RPC_NDR_LSA] PUBLIC_DEPENDENCIES = dcerpc NDR_LSA -RPC_NDR_LSA_OBJ_FILES = librpc/gen_ndr/ndr_lsa_c.o +RPC_NDR_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa_c.o [SUBSYSTEM::RPC_NDR_DFS] PUBLIC_DEPENDENCIES = dcerpc NDR_DFS -RPC_NDR_DFS_OBJ_FILES = librpc/gen_ndr/ndr_dfs_c.o +RPC_NDR_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs_c.o [SUBSYSTEM::RPC_NDR_FRSAPI] PUBLIC_DEPENDENCIES = dcerpc NDR_FRSAPI -RPC_NDR_FRSAPI_OBJ_FILES = librpc/gen_ndr/ndr_frsapi_c.o +RPC_NDR_FRSAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsapi_c.o [SUBSYSTEM::RPC_NDR_DRSUAPI] PUBLIC_DEPENDENCIES = dcerpc NDR_DRSUAPI -RPC_NDR_DRSUAPI_OBJ_FILES = librpc/gen_ndr/ndr_drsuapi_c.o +RPC_NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi_c.o [SUBSYSTEM::RPC_NDR_POLICYAGENT] PUBLIC_DEPENDENCIES = dcerpc NDR_POLICYAGENT -RPC_NDR_POLICYAGENT_OBJ_FILES = librpc/gen_ndr/ndr_policyagent_c.o +RPC_NDR_POLICYAGENT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_policyagent_c.o [SUBSYSTEM::RPC_NDR_UNIXINFO] PUBLIC_DEPENDENCIES = dcerpc NDR_UNIXINFO -RPC_NDR_UNIXINFO_OBJ_FILES = librpc/gen_ndr/ndr_unixinfo_c.o +RPC_NDR_UNIXINFO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_unixinfo_c.o [LIBRARY::dcerpc_samr] PUBLIC_DEPENDENCIES = dcerpc NDR_SAMR -PC_FILES += librpc/dcerpc_samr.pc +PC_FILES += $(librpcsrcdir)/dcerpc_samr.pc dcerpc_samr_VERSION = 0.0.1 dcerpc_samr_SOVERSION = 0 -dcerpc_samr_OBJ_FILES = librpc/gen_ndr/ndr_samr_c.o +dcerpc_samr_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr_c.o [SUBSYSTEM::RPC_NDR_SPOOLSS] PUBLIC_DEPENDENCIES = dcerpc NDR_SPOOLSS -RPC_NDR_SPOOLSS_OBJ_FILES = librpc/gen_ndr/ndr_spoolss_c.o +RPC_NDR_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss_c.o [SUBSYSTEM::RPC_NDR_WKSSVC] PUBLIC_DEPENDENCIES = dcerpc NDR_WKSSVC -RPC_NDR_WKSSVC_OBJ_FILES = librpc/gen_ndr/ndr_wkssvc_c.o +RPC_NDR_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc_c.o [SUBSYSTEM::RPC_NDR_SRVSVC] PUBLIC_DEPENDENCIES = dcerpc NDR_SRVSVC -RPC_NDR_SRVSVC_OBJ_FILES = librpc/gen_ndr/ndr_srvsvc_c.o +RPC_NDR_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc_c.o [SUBSYSTEM::RPC_NDR_SVCCTL] PUBLIC_DEPENDENCIES = dcerpc NDR_SVCCTL -RPC_NDR_SVCCTL_OBJ_FILES = librpc/gen_ndr/ndr_svcctl_c.o +RPC_NDR_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl_c.o -PUBLIC_HEADERS += librpc/gen_ndr/ndr_svcctl_c.h +PUBLIC_HEADERS += $(gen_ndrsrcdir)/ndr_svcctl_c.h [LIBRARY::dcerpc_atsvc] PUBLIC_DEPENDENCIES = dcerpc NDR_ATSVC @@ -463,117 +471,116 @@ PUBLIC_DEPENDENCIES = dcerpc NDR_ATSVC dcerpc_atsvc_VERSION = 0.0.1 dcerpc_atsvc_SOVERSION = 0 -dcerpc_atsvc_OBJ_FILES = librpc/gen_ndr/ndr_atsvc_c.o -PC_FILES += librpc/dcerpc_atsvc.pc +dcerpc_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/ndr_atsvc_c.o +PC_FILES += $(librpcsrcdir)/dcerpc_atsvc.pc -PUBLIC_HEADERS += librpc/gen_ndr/ndr_atsvc_c.h +PUBLIC_HEADERS += $(gen_ndrsrcdir)/ndr_atsvc_c.h [SUBSYSTEM::RPC_NDR_EVENTLOG] PUBLIC_DEPENDENCIES = dcerpc NDR_EVENTLOG -RPC_NDR_EVENTLOG_OBJ_FILES = librpc/gen_ndr/ndr_eventlog_c.o +RPC_NDR_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog_c.o [SUBSYSTEM::RPC_NDR_EPMAPPER] PUBLIC_DEPENDENCIES = NDR_EPMAPPER -RPC_NDR_EPMAPPER_OBJ_FILES = librpc/gen_ndr/ndr_epmapper_c.o +RPC_NDR_EPMAPPER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_epmapper_c.o [SUBSYSTEM::RPC_NDR_DBGIDL] PUBLIC_DEPENDENCIES = dcerpc NDR_DBGIDL -RPC_NDR_DBGIDL_OBJ_FILES = librpc/gen_ndr/ndr_dbgidl_c.o +RPC_NDR_DBGIDL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dbgidl_c.o [SUBSYSTEM::RPC_NDR_DSSETUP] PUBLIC_DEPENDENCIES = dcerpc NDR_DSSETUP -RPC_NDR_DSSETUP_OBJ_FILES = librpc/gen_ndr/ndr_dssetup_c.o +RPC_NDR_DSSETUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dssetup_c.o [SUBSYSTEM::RPC_NDR_MSGSVC] PUBLIC_DEPENDENCIES = dcerpc NDR_MSGSVC -RPC_NDR_MSGSVC_OBJ_FILES = librpc/gen_ndr/ndr_msgsvc_c.o +RPC_NDR_MSGSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_msgsvc_c.o [SUBSYSTEM::RPC_NDR_WINS] PUBLIC_DEPENDENCIES = dcerpc NDR_WINS -RPC_NDR_WINS_OBJ_FILES = librpc/gen_ndr/ndr_wins_c.o +RPC_NDR_WINS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wins_c.o [SUBSYSTEM::RPC_NDR_WINREG] PUBLIC_DEPENDENCIES = dcerpc NDR_WINREG -RPC_NDR_WINREG_OBJ_FILES = librpc/gen_ndr/ndr_winreg_c.o +RPC_NDR_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg_c.o [SUBSYSTEM::RPC_NDR_INITSHUTDOWN] PUBLIC_DEPENDENCIES = dcerpc NDR_INITSHUTDOWN -RPC_NDR_INITSHUTDOWN_OBJ_FILES = librpc/gen_ndr/ndr_initshutdown_c.o +RPC_NDR_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown_c.o [SUBSYSTEM::RPC_NDR_MGMT] PRIVATE_DEPENDENCIES = NDR_MGMT -RPC_NDR_MGMT_OBJ_FILES = librpc/gen_ndr/ndr_mgmt_c.o +RPC_NDR_MGMT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_mgmt_c.o [SUBSYSTEM::RPC_NDR_PROTECTED_STORAGE] PUBLIC_DEPENDENCIES = dcerpc NDR_PROTECTED_STORAGE -RPC_NDR_PROTECTED_STORAGE_OBJ_FILES = librpc/gen_ndr/ndr_protected_storage_c.o +RPC_NDR_PROTECTED_STORAGE_OBJ_FILES = $(gen_ndrsrcdir)/ndr_protected_storage_c.o [SUBSYSTEM::RPC_NDR_OXIDRESOLVER] PUBLIC_DEPENDENCIES = dcerpc NDR_OXIDRESOLVER -RPC_NDR_OXIDRESOLVER_OBJ_FILES = librpc/gen_ndr/ndr_oxidresolver_c.o +RPC_NDR_OXIDRESOLVER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_oxidresolver_c.o [SUBSYSTEM::RPC_NDR_REMACT] PUBLIC_DEPENDENCIES = dcerpc NDR_REMACT -RPC_NDR_REMACT_OBJ_FILES = librpc/gen_ndr/ndr_remact_c.o +RPC_NDR_REMACT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_remact_c.o [SUBSYSTEM::RPC_NDR_WZCSVC] PUBLIC_DEPENDENCIES = dcerpc NDR_WZCSVC -RPC_NDR_WZCSVC_OBJ_FILES = librpc/gen_ndr/ndr_wzcsvc_c.o +RPC_NDR_WZCSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wzcsvc_c.o [SUBSYSTEM::RPC_NDR_W32TIME] PUBLIC_DEPENDENCIES = dcerpc NDR_W32TIME -RPC_NDR_W32TIME_OBJ_FILES = librpc/gen_ndr/ndr_w32time_c.o +RPC_NDR_W32TIME_OBJ_FILES = $(gen_ndrsrcdir)/ndr_w32time_c.o [SUBSYSTEM::RPC_NDR_SCERPC] PUBLIC_DEPENDENCIES = dcerpc NDR_SCERPC -RPC_NDR_SCERPC_OBJ_FILES = librpc/gen_ndr/ndr_scerpc_c.o +RPC_NDR_SCERPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_scerpc_c.o [SUBSYSTEM::RPC_NDR_NTSVCS] PUBLIC_DEPENDENCIES = dcerpc NDR_NTSVCS -RPC_NDR_NTSVCS_OBJ_FILES = librpc/gen_ndr/ndr_ntsvcs_c.o +RPC_NDR_NTSVCS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_ntsvcs_c.o [SUBSYSTEM::RPC_NDR_NETLOGON] PUBLIC_DEPENDENCIES = NDR_NETLOGON -RPC_NDR_NETLOGON_OBJ_FILES = librpc/gen_ndr/ndr_netlogon_c.o +RPC_NDR_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon_c.o [SUBSYSTEM::RPC_NDR_TRKWKS] PUBLIC_DEPENDENCIES = dcerpc NDR_TRKWKS -RPC_NDR_TRKWKS_OBJ_FILES = librpc/gen_ndr/ndr_trkwks_c.o +RPC_NDR_TRKWKS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_trkwks_c.o [SUBSYSTEM::RPC_NDR_KEYSVC] PUBLIC_DEPENDENCIES = dcerpc NDR_KEYSVC -RPC_NDR_KEYSVC_OBJ_FILES = librpc/gen_ndr/ndr_keysvc_c.o +RPC_NDR_KEYSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_keysvc_c.o [SUBSYSTEM::NDR_DCERPC] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC -NDR_DCERPC_OBJ_FILES = librpc/gen_ndr/ndr_dcerpc.o +NDR_DCERPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dcerpc.o -PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h) +PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h) ################################################ # Start SUBSYSTEM dcerpc [LIBRARY::dcerpc] -PRIVATE_PROTO_HEADER = rpc/dcerpc_proto.h PRIVATE_DEPENDENCIES = \ samba-socket LIBCLI_RESOLVE LIBCLI_SMB LIBCLI_SMB2 \ LIBNDR NDR_DCERPC RPC_NDR_EPMAPPER \ @@ -585,15 +592,17 @@ PUBLIC_DEPENDENCIES = CREDENTIALS # End SUBSYSTEM dcerpc ################################################ -PC_FILES += librpc/dcerpc.pc +PC_FILES += $(librpcsrcdir)/dcerpc.pc dcerpc_VERSION = 0.0.1 dcerpc_SOVERSION = 0 -dcerpc_OBJ_FILES = $(addprefix librpc/rpc/, dcerpc.o dcerpc_auth.o dcerpc_schannel.o dcerpc_util.o binding.o \ +dcerpc_OBJ_FILES = $(addprefix $(dcerpcsrcdir)/, dcerpc.o dcerpc_auth.o dcerpc_schannel.o dcerpc_util.o binding.o \ dcerpc_error.o dcerpc_smb.o dcerpc_smb2.o dcerpc_sock.o dcerpc_connect.o dcerpc_secondary.o) +$(eval $(call proto_header_template,$(dcerpcsrcdir)/dcerpc_proto.h,$(dcerpc_OBJ_FILES:.o=.c))) + -PUBLIC_HEADERS += $(addprefix librpc/, rpc/dcerpc.h \ +PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, rpc/dcerpc.h \ gen_ndr/mgmt.h gen_ndr/ndr_mgmt.h gen_ndr/ndr_mgmt_c.h \ gen_ndr/epmapper.h gen_ndr/ndr_epmapper.h gen_ndr/ndr_epmapper_c.h) @@ -603,49 +612,49 @@ INIT_FUNCTION = ejs_init_rpcecho SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_ECHO EJSRPC -RPC_EJS_ECHO_OBJ_FILES = librpc/gen_ndr/ndr_echo_ejs.o +RPC_EJS_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo_ejs.o [MODULE::RPC_EJS_MISC] INIT_FUNCTION = ejs_init_misc SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_MISC EJSRPC -RPC_EJS_MISC_OBJ_FILES = librpc/gen_ndr/ndr_misc_ejs.o +RPC_EJS_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc_ejs.o [MODULE::RPC_EJS_SAMR] INIT_FUNCTION = ejs_init_samr SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_SAMR EJSRPC RPC_EJS_LSA RPC_EJS_SECURITY RPC_EJS_MISC -RPC_EJS_SAMR_OBJ_FILES = librpc/gen_ndr/ndr_samr_ejs.o +RPC_EJS_SAMR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr_ejs.o [MODULE::RPC_EJS_SECURITY] INIT_FUNCTION = ejs_init_security SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_SECURITY EJSRPC -RPC_EJS_SECURITY_OBJ_FILES = librpc/gen_ndr/ndr_security_ejs.o +RPC_EJS_SECURITY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_security_ejs.o [MODULE::RPC_EJS_LSA] INIT_FUNCTION = ejs_init_lsarpc SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_LSA EJSRPC RPC_EJS_SECURITY RPC_EJS_MISC -RPC_EJS_LSA_OBJ_FILES = librpc/gen_ndr/ndr_lsa_ejs.o +RPC_EJS_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa_ejs.o [MODULE::RPC_EJS_DFS] INIT_FUNCTION = ejs_init_netdfs SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_DFS EJSRPC -RPC_EJS_DFS_OBJ_FILES = librpc/gen_ndr/ndr_dfs_ejs.o +RPC_EJS_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs_ejs.o [MODULE::RPC_EJS_DRSUAPI] INIT_FUNCTION = ejs_init_drsuapi SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_DRSUAPI EJSRPC RPC_EJS_MISC RPC_EJS_SAMR -RPC_EJS_DRSUAPI_OBJ_FILES = librpc/gen_ndr/ndr_drsuapi_ejs.o +RPC_EJS_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi_ejs.o [MODULE::RPC_EJS_SPOOLSS] INIT_FUNCTION = ejs_init_spoolss @@ -653,28 +662,28 @@ SUBSYSTEM = smbcalls ENABLE = NO PRIVATE_DEPENDENCIES = dcerpc NDR_SPOOLSS EJSRPC -RPC_EJS_SPOOLSS_OBJ_FILES = librpc/gen_ndr/ndr_spoolss_ejs.o +RPC_EJS_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss_ejs.o [MODULE::RPC_EJS_WKSSVC] INIT_FUNCTION = ejs_init_wkssvc SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_WKSSVC EJSRPC RPC_EJS_SRVSVC RPC_EJS_MISC -RPC_EJS_WKSSVC_OBJ_FILES = librpc/gen_ndr/ndr_wkssvc_ejs.o +RPC_EJS_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc_ejs.o [MODULE::RPC_EJS_SRVSVC] INIT_FUNCTION = ejs_init_srvsvc SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_SRVSVC EJSRPC RPC_EJS_MISC RPC_EJS_SVCCTL RPC_EJS_SECURITY -RPC_EJS_SRVSVC_OBJ_FILES = librpc/gen_ndr/ndr_srvsvc_ejs.o +RPC_EJS_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc_ejs.o [MODULE::RPC_EJS_EVENTLOG] INIT_FUNCTION = ejs_init_eventlog SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_EVENTLOG EJSRPC RPC_EJS_MISC -RPC_EJS_EVENTLOG_OBJ_FILES = librpc/gen_ndr/ndr_eventlog_ejs.o +RPC_EJS_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog_ejs.o [MODULE::RPC_EJS_WINREG] INIT_FUNCTION = ejs_init_winreg @@ -682,113 +691,127 @@ SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_WINREG EJSRPC RPC_EJS_INITSHUTDOWN \ RPC_EJS_MISC RPC_EJS_SECURITY -RPC_EJS_WINREG_OBJ_FILES = librpc/gen_ndr/ndr_winreg_ejs.o +RPC_EJS_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg_ejs.o [MODULE::RPC_EJS_INITSHUTDOWN] INIT_FUNCTION = ejs_init_initshutdown SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_INITSHUTDOWN EJSRPC -RPC_EJS_INITSHUTDOWN_OBJ_FILES = librpc/gen_ndr/ndr_initshutdown_ejs.o +RPC_EJS_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown_ejs.o [MODULE::RPC_EJS_NETLOGON] INIT_FUNCTION = ejs_init_netlogon SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_NETLOGON EJSRPC RPC_EJS_SAMR RPC_EJS_SECURITY RPC_EJS_MISC -RPC_EJS_NETLOGON_OBJ_FILES = librpc/gen_ndr/ndr_netlogon_ejs.o +RPC_EJS_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon_ejs.o [MODULE::RPC_EJS_SVCCTL] INIT_FUNCTION = ejs_init_svcctl SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_SVCCTL EJSRPC RPC_EJS_MISC -RPC_EJS_SVCCTL_OBJ_FILES = librpc/gen_ndr/ndr_svcctl_ejs.o +RPC_EJS_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl_ejs.o [MODULE::RPC_EJS_IRPC] INIT_FUNCTION = ejs_init_irpc SUBSYSTEM = smbcalls PRIVATE_DEPENDENCIES = dcerpc NDR_IRPC EJSRPC -RPC_EJS_IRPC_OBJ_FILES = librpc/gen_ndr/ndr_irpc_ejs.o +RPC_EJS_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc_ejs.o [PYTHON::swig_dcerpc] SWIG_FILE = rpc/dcerpc.i PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG -swig_dcerpc_OBJ_FILES = librpc/rpc/dcerpc_wrap.o +swig_dcerpc_OBJ_FILES = $(dcerpcsrcdir)/dcerpc_wrap.o [PYTHON::python_echo] PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param swig_credentials -python_echo_OBJ_FILES = librpc/gen_ndr/py_echo.o +python_echo_OBJ_FILES = $(gen_ndrsrcdir)/py_echo.o [PYTHON::python_winreg] PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc PYTALLOC param swig_credentials -python_winreg_OBJ_FILES = librpc/gen_ndr/py_winreg.o +python_winreg_OBJ_FILES = $(gen_ndrsrcdir)/py_winreg.o [PYTHON::python_dcerpc_misc] PRIVATE_DEPENDENCIES = PYTALLOC -python_dcerpc_misc_OBJ_FILES = librpc/gen_ndr/py_misc.o +python_dcerpc_misc_OBJ_FILES = $(gen_ndrsrcdir)/py_misc.o [PYTHON::python_initshutdown] PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials -python_initshutdown_OBJ_FILES = librpc/gen_ndr/py_initshutdown.o +python_initshutdown_OBJ_FILES = $(gen_ndrsrcdir)/py_initshutdown.o [PYTHON::python_epmapper] PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials -python_epmapper_OBJ_FILES = librpc/gen_ndr/py_epmapper.o +python_epmapper_OBJ_FILES = $(gen_ndrsrcdir)/py_epmapper.o [PYTHON::python_mgmt] PRIVATE_DEPENDENCIES = dcerpc_mgmt PYTALLOC param swig_credentials -python_mgmt_OBJ_FILES = librpc/gen_ndr/py_mgmt.o +python_mgmt_OBJ_FILES = $(gen_ndrsrcdir)/py_mgmt.o [PYTHON::python_atsvc] PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param swig_credentials -python_atsvc_OBJ_FILES = librpc/gen_ndr/py_atsvc.o +python_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/py_atsvc.o [PYTHON::python_samr] PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC python_dcerpc_security python_lsa python_dcerpc_misc swig_credentials param -python_samr_OBJ_FILES = librpc/gen_ndr/py_samr.o +python_samr_OBJ_FILES = $(gen_ndrsrcdir)/py_samr.o [PYTHON::python_svcctl] PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials -python_svcctl_OBJ_FILES = librpc/gen_ndr/py_svcctl.o +python_svcctl_OBJ_FILES = $(gen_ndrsrcdir)/py_svcctl.o [PYTHON::python_lsa] PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials -python_lsa_OBJ_FILES = librpc/gen_ndr/py_lsa.o +python_lsa_OBJ_FILES = $(gen_ndrsrcdir)/py_lsa.o [PYTHON::python_wkssvc] PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials -python_wkssvc_OBJ_FILES = librpc/gen_ndr/py_wkssvc.o +python_wkssvc_OBJ_FILES = $(gen_ndrsrcdir)/py_wkssvc.o [PYTHON::python_dfs] PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials -python_dfs_OBJ_FILES = librpc/gen_ndr/py_dfs.o +python_dfs_OBJ_FILES = $(gen_ndrsrcdir)/py_dfs.o [PYTHON::python_unixinfo] PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param swig_credentials python_dcerpc_security python_dcerpc_misc -python_unixinfo_OBJ_FILES = librpc/gen_ndr/py_unixinfo.o +python_unixinfo_OBJ_FILES = $(gen_ndrsrcdir)/py_unixinfo.o [PYTHON::python_drsuapi] PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials -python_drsuapi_OBJ_FILES = librpc/gen_ndr/py_drsuapi.o +python_drsuapi_OBJ_FILES = $(gen_ndrsrcdir)/py_drsuapi.o [PYTHON::python_dcerpc_security] PRIVATE_DEPENDENCIES = PYTALLOC -python_dcerpc_security_OBJ_FILES = librpc/gen_ndr/py_security.o +python_dcerpc_security_OBJ_FILES = $(gen_ndrsrcdir)/py_security.o + +$(IDL_HEADER_FILES) $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \ + $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \ + $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \ + $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES) \ + $(IDL_NDR_PY_C_FILES) $(IDL_NDR_PY_H_FILES): idl + +idl_full:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm + @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh FULL $(librpcsrcdir)/idl $(librpcsrcdir)/gen_ndr + +idl:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm + @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh PARTIAL $(librpcsrcdir)/idl $(librpcsrcdir)/gen_ndr + + diff --git a/source4/librpc/idl-deps.pl b/source4/librpc/idl-deps.pl index d5bfe0b2ec..e630ee4f61 100755 --- a/source4/librpc/idl-deps.pl +++ b/source4/librpc/idl-deps.pl @@ -6,17 +6,17 @@ my %vars = (); foreach(@ARGV) { push (@{$vars{IDL_FILES}}, $_); my $b = $_; $b =~ s/.*\/(.*?).idl$/$1/; - push (@{$vars{IDL_HEADER_FILES}}, "librpc/gen_ndr/$b.h"); - push (@{$vars{IDL_NDR_PARSE_H_FILES}}, "librpc/gen_ndr/ndr_$b.h"); - push (@{$vars{IDL_NDR_PARSE_C_FILES}}, "librpc/gen_ndr/ndr_$b.c"); - push (@{$vars{IDL_NDR_CLIENT_C_FILES}}, "librpc/gen_ndr/ndr_$b\_c.c"); - push (@{$vars{IDL_NDR_CLIENT_H_FILES}}, "librpc/gen_ndr/ndr_$b\_c.h"); - push (@{$vars{IDL_SWIG_FILES}}, "librpc/gen_ndr/$b.i"); - push (@{$vars{IDL_NDR_SERVER_C_FILES}}, "librpc/gen_ndr/ndr_$b\_s.c"); - push (@{$vars{IDL_NDR_EJS_C_FILES}}, "librpc/gen_ndr/ndr_$b\_ejs.c"); - push (@{$vars{IDL_NDR_EJS_H_FILES}}, "librpc/gen_ndr/ndr_$b\_ejs.h"); - push (@{$vars{IDL_NDR_PY_C_FILES}}, "librpc/gen_ndr/py_$b.c"); - push (@{$vars{IDL_NDR_PY_H_FILES}}, "librpc/gen_ndr/py_$b.h"); + push (@{$vars{IDL_HEADER_FILES}}, "\$(librpcsrcdir)/gen_ndr/$b.h"); + push (@{$vars{IDL_NDR_PARSE_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.h"); + push (@{$vars{IDL_NDR_PARSE_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.c"); + push (@{$vars{IDL_NDR_CLIENT_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_c.c"); + push (@{$vars{IDL_NDR_CLIENT_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_c.h"); + push (@{$vars{IDL_SWIG_FILES}}, "\$(librpcsrcdir)/gen_ndr/$b.i"); + push (@{$vars{IDL_NDR_SERVER_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_s.c"); + push (@{$vars{IDL_NDR_EJS_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_ejs.c"); + push (@{$vars{IDL_NDR_EJS_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_ejs.h"); + push (@{$vars{IDL_NDR_PY_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/py_$b.c"); + push (@{$vars{IDL_NDR_PY_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/py_$b.h"); } foreach (keys %vars) { diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl index dddfa4e1ce..783f04eb42 100644 --- a/source4/librpc/idl/nbt.idl +++ b/source4/librpc/idl/nbt.idl @@ -8,9 +8,9 @@ encoding if it doesn't work out */ -import "misc.idl", "security.idl", "svcctl.idl"; +import "misc.idl", "security.idl", "svcctl.idl", "samr.idl"; [ -helper("libcli/nbt/libnbt.h") + helper("libcli/netlogon.h", "libcli/nbt/libnbt.h") ] interface nbt { @@ -338,52 +338,19 @@ interface nbt } nbt_dgram_packet; - /*******************************************/ - /* \MAILSLOT\NET\NETLOGON mailslot requests */ - typedef enum { - NETLOGON_QUERY_FOR_PDC = 0x7, - NETLOGON_ANNOUNCE_UAS = 0xa, - NETLOGON_RESPONSE_FROM_PDC = 0xc, - NETLOGON_QUERY_FOR_PDC2 = 0x12, - NETLOGON_RESPONSE_FROM_PDC2 = 0x17, - NETLOGON_RESPONSE_FROM_PDC_USER = 0x19 - } nbt_netlogon_command; - - /* query for pdc request */ - typedef struct { - astring computer_name; - astring mailslot_name; - [flag(NDR_ALIGN2)] DATA_BLOB _pad; - nstring unicode_name; - uint32 nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_query_for_pdc; - - /* query for pdc request - new style */ - typedef struct { - uint16 request_count; - nstring computer_name; - nstring user_name; - astring mailslot_name; - uint32 unknown[2]; - uint32 nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_query_for_pdc2; + /****************************************** + * \MAILSLOT\NET\NETLOGON mailslot requests + * and + * \MAILSLOT\NET\NTLOGON mailslot requests + */ - /* response from pdc */ - typedef struct { - astring pdc_name; - [flag(NDR_ALIGN2)] DATA_BLOB _pad; - nstring unicode_pdc_name; - nstring domain_name; - uint32 nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_response_from_pdc; + typedef [public,gensize] struct { + uint32 sa_family; + [flag(NDR_BIG_ENDIAN)] ipv4address pdc_ip; + [flag(NDR_REMAINING)] DATA_BLOB remaining; + } nbt_sockaddr; - typedef [bitmap32bit] bitmap { + typedef [bitmap32bit,public] bitmap { NBT_SERVER_PDC = 0x00000001, NBT_SERVER_GC = 0x00000004, NBT_SERVER_LDAP = 0x00000008, @@ -395,107 +362,90 @@ interface nbt NBT_SERVER_GOOD_TIMESERV = 0x00000200 } nbt_server_type; - /* response from pdc - type2 */ - typedef struct { - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - uint8 unknown; - uint32 unknown2; - [flag(NDR_BIG_ENDIAN)] - ipv4address pdc_ip; - uint32 unknown3[2]; - uint32 nt_version; + typedef [bitmap32bit,public] bitmap { + NETLOGON_NT_VERSION_1 = 0x00000001, + NETLOGON_NT_VERSION_5 = 0x00000002, + NETLOGON_NT_VERSION_5EX = 0x00000004, + NETLOGON_NT_VERSION_5EX_WITH_IP = 0x00000008, + NETLOGON_NT_VERSION_WITH_CLOSEST_SITE = 0x00000010, + NETLOGON_NT_VERSION_AVIOD_NT4EMUL = 0x01000000, + NETLOGON_NT_VERSION_PDC = 0x10000000, + NETLOGON_NT_VERSION_IP = 0x20000000, + NETLOGON_NT_VERSION_LOCAL = 0x40000000, + NETLOGON_NT_VERSION_GC = 0x80000000 + } netlogon_nt_version_flags; + + + typedef [enum16bit,public] enum { + LOGON_PRIMARY_QUERY = 7, /* Was also NETLOGON_QUERY_FOR_PDC */ + NETLOGON_ANNOUNCE_UAS = 10, + NETLOGON_RESPONSE_FROM_PDC = 12, + LOGON_SAM_LOGON_REQUEST = 18, /* Was also NETLOGON_QUERY_FOR_PDC2, NTLOGON_SAM_LOGON */ + LOGON_SAM_LOGON_RESPONSE = 19, /* Was also NTLOGON_SAM_LOGON_REPLY */ + LOGON_SAM_LOGON_PAUSE_RESPONSE = 20, + LOGON_SAM_LOGON_USER_UNKNOWN = 21, /* Was also NTLOGON_SAM_LOGON_REPLY15 */ + LOGON_SAM_LOGON_RESPONSE_EX = 23, /* was NETLOGON_RESPONSE_FROM_PDC2 */ + LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24, + LOGON_SAM_LOGON_USER_UNKNOWN_EX = 25 /* was NETLOGON_RESPONSE_FROM_PDC_USER */ + } netlogon_command; + + typedef bitmap samr_AcctFlags samr_AcctFlags; + + /* query to dc hand marshaled, as it has 'optional' + * parts */ + typedef [nopull,nopush] struct { + uint16 request_count; + nstring computer_name; + nstring user_name; + astring mailslot_name; + samr_AcctFlags acct_control; + [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; + /* The manual alignment is required because this + * structure is marked flag(NDR_NOALIGN) via the + * nbt_netlogon_packet below. + * + * However, both MUST only be present if sid_size > 0 + */ + [flag(NDR_ALIGN4)] DATA_BLOB _pad; + [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; + netlogon_nt_version_flags nt_version; uint16 lmnt_token; uint16 lm20_token; - } nbt_netlogon_response_from_pdc2; - - typedef enum netr_SamDatabaseID netr_SamDatabaseID; - - /* announce change to UAS or SAM */ - typedef struct { - netr_SamDatabaseID db_index; - hyper serial; - NTTIME timestamp; - } nbt_db_change; - - /* used to announce SAM changes */ - typedef struct { - uint32 serial_lo; - time_t timestamp; - uint32 pulse; - uint32 random; - astring pdc_name; - astring domain; - [flag(NDR_ALIGN2)] DATA_BLOB _pad; - nstring unicode_pdc_name; - nstring unicode_domain; - uint32 db_count; - nbt_db_change dbchange[db_count]; - [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; - [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; - uint32 nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_announce_uas; - - typedef [nodiscriminant] union { - [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc; - [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2; - [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas; - [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response; - [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2; - [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2; - } nbt_netlogon_request; + } NETLOGON_SAM_LOGON_REQUEST; typedef [flag(NDR_NOALIGN),public] struct { - nbt_netlogon_command command; - [switch_is(command)] nbt_netlogon_request req; - } nbt_netlogon_packet; - - /*******************************************/ - /* CLDAP netlogon response */ - - /* note that these structures are very similar to, but not - quite identical to, the netlogon structures above */ - - typedef struct { - uint16 type; - nstring pdc_name; + netlogon_command command; + nstring server; nstring user_name; - nstring domain_name; - [value(1)] uint32 nt_version; + nstring domain; + netlogon_nt_version_flags nt_version; uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_1; + uint16 lm20_token; + } NETLOGON_SAM_LOGON_RESPONSE_NT40; - typedef struct { - uint16 type; + typedef [flag(NDR_NOALIGN),public] struct { + netlogon_command command; nstring pdc_name; nstring user_name; nstring domain_name; GUID domain_uuid; - GUID unknown_uuid; + GUID zero_uuid; nbt_string forest; nbt_string dns_domain; nbt_string pdc_dns_name; ipv4address pdc_ip; nbt_server_type server_type; - [value(3)] uint32 nt_version; + netlogon_nt_version_flags nt_version; uint16 lmnt_token; uint16 lm20_token; - } nbt_cldap_netlogon_3; + } NETLOGON_SAM_LOGON_RESPONSE; - typedef struct { - uint32 type; + /* response from pdc hand marshaled (we have an additional + * function that uses this structure), as it has 'optional' + * parts */ + typedef [flag(NDR_NOALIGN),public] struct { + netlogon_command command; + uint16 sbz; /* From the docs */ nbt_server_type server_type; GUID domain_uuid; nbt_string forest; @@ -506,85 +456,91 @@ interface nbt nbt_string user_name; nbt_string server_site; nbt_string client_site; - [value(5)] uint32 nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_5; - typedef struct { - uint32 type; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - uint8 unknown; - uint32 unknown2; - [flag(NDR_BIG_ENDIAN)] - ipv4address pdc_ip; - uint32 unknown3[2]; - [value(13)] uint32 nt_version; + /* Optional on NETLOGON_NT_VERSION_5EX_WITH_IP */ + [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->flags))] uint8 sockaddr_size; + [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr; + + /* Optional on NETLOGON_NT_VERSION_WITH_CLOSEST_SITE */ + nbt_string next_closest_site; + + netlogon_nt_version_flags nt_version; uint16 lmnt_token; uint16 lm20_token; - } nbt_cldap_netlogon_13; - - typedef [flag(NDR_NOALIGN),public,nodiscriminant] union { - [case(0)] nbt_cldap_netlogon_1 logon1; - [case(1)] nbt_cldap_netlogon_1 logon1; - [case(2)] nbt_cldap_netlogon_3 logon3; - [case(3)] nbt_cldap_netlogon_3 logon3; - [case(4)] nbt_cldap_netlogon_5 logon5; - [case(5)] nbt_cldap_netlogon_5 logon5; - [case(6)] nbt_cldap_netlogon_5 logon5; - [case(7)] nbt_cldap_netlogon_5 logon5; - [default] nbt_cldap_netlogon_13 logon13; - } nbt_cldap_netlogon; - - /*******************************************/ - /* \MAILSLOT\NET\NTLOGON mailslot requests */ - typedef enum { - NTLOGON_SAM_LOGON = 0x12, - NTLOGON_SAM_LOGON_REPLY = 0x13, - NTLOGON_SAM_LOGON_REPLY15 = 0x15 - } nbt_ntlogon_command; + } NETLOGON_SAM_LOGON_RESPONSE_EX; + /* query for pdc request */ typedef struct { - uint16 request_count; - nstring computer_name; - nstring user_name; + astring computer_name; astring mailslot_name; - uint32 acct_control; - [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; - [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; - uint32 nt_version; + [flag(NDR_ALIGN2)] DATA_BLOB _pad; + nstring unicode_name; + netlogon_nt_version_flags nt_version; uint16 lmnt_token; uint16 lm20_token; - } nbt_ntlogon_sam_logon; + } nbt_netlogon_query_for_pdc; - typedef struct { - nstring server; - nstring user_name; - nstring domain; - uint32 nt_version; + /* response from pdc */ + typedef [flag(NDR_NOALIGN),public] struct { + netlogon_command command; + astring pdc_name; + [flag(NDR_ALIGN2)] DATA_BLOB _pad; + nstring unicode_pdc_name; + nstring domain_name; + netlogon_nt_version_flags nt_version; uint16 lmnt_token; uint16 lm20_token; - } nbt_ntlogon_sam_logon_reply; + } nbt_netlogon_response_from_pdc; + + typedef enum netr_SamDatabaseID netr_SamDatabaseID; + + /* used to announce SAM changes - MS-NRPC 2.2.1.5.1 */ + typedef struct { + netr_SamDatabaseID db_index; + hyper serial; + NTTIME timestamp; + } nbt_db_change_info; + + typedef struct { + uint32 serial_lo; + time_t timestamp; + uint32 pulse; + uint32 random; + astring pdc_name; + astring domain; + [flag(NDR_ALIGN2)] DATA_BLOB _pad; + nstring unicode_pdc_name; + nstring unicode_domain; + uint32 db_count; + nbt_db_change_info dbchange[db_count]; + [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; + [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; + uint32 message_format_version; + uint32 message_token; + } NETLOGON_DB_CHANGE; typedef [nodiscriminant] union { - [case(NTLOGON_SAM_LOGON)] nbt_ntlogon_sam_logon logon; - [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply; - [case(NTLOGON_SAM_LOGON_REPLY15)] nbt_ntlogon_sam_logon_reply reply; - } nbt_ntlogon_request; + [case(LOGON_SAM_LOGON_REQUEST)] NETLOGON_SAM_LOGON_REQUEST logon; + [case(LOGON_PRIMARY_QUERY)] nbt_netlogon_query_for_pdc pdc; + [case(NETLOGON_ANNOUNCE_UAS)] NETLOGON_DB_CHANGE uas; + } nbt_netlogon_request; + +#if 0 + [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response; + [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2; + + [case(LOGON_SAM_LOGON_PAUSE_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply; + [case(LOGON_SAM_LOGON_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply; + [case(LOGON_SAM_LOGON_USER_UNKNOWN)] NETLOGON_SAM_LOGON_RESPONSE reply; + [case(LOGON_SAM_LOGON_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; + [case(LOGON_SAM_LOGON_PAUSE_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; + [case(LOGON_SAM_LOGON_USER_UNKNOWN_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; +#endif typedef [flag(NDR_NOALIGN),public] struct { - nbt_ntlogon_command command; - [switch_is(command)] nbt_ntlogon_request req; - } nbt_ntlogon_packet; + netlogon_command command; + [switch_is(command)] nbt_netlogon_request req; + } nbt_netlogon_packet; /********************************************************/ /* \MAILSLOT\BROWSE mailslot requests */ diff --git a/source4/librpc/rpc/dcerpc_smb2.c b/source4/librpc/rpc/dcerpc_smb2.c index 8adca4caba..4767165fba 100644 --- a/source4/librpc/rpc/dcerpc_smb2.c +++ b/source4/librpc/rpc/dcerpc_smb2.c @@ -83,7 +83,7 @@ static void smb2_read_callback(struct smb2_request *req) uint16_t frag_length; NTSTATUS status; - state = talloc_get_type(req->async.private, struct smb2_read_state); + state = talloc_get_type(req->async.private_data, struct smb2_read_state); smb = talloc_get_type(state->c->transport.private_data, struct smb2_private); status = smb2_read_recv(req, state, &io); @@ -136,7 +136,7 @@ static void smb2_read_callback(struct smb2_request *req) } req->async.fn = smb2_read_callback; - req->async.private = state; + req->async.private_data = state; } @@ -180,7 +180,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO } req->async.fn = smb2_read_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -212,7 +212,7 @@ struct smb2_trans_state { */ static void smb2_trans_callback(struct smb2_request *req) { - struct smb2_trans_state *state = talloc_get_type(req->async.private, + struct smb2_trans_state *state = talloc_get_type(req->async.private_data, struct smb2_trans_state); struct dcerpc_connection *c = state->c; NTSTATUS status; @@ -269,7 +269,7 @@ static NTSTATUS smb2_send_trans_request(struct dcerpc_connection *c, DATA_BLOB * } req->async.fn = smb2_trans_callback; - req->async.private = state; + req->async.private_data = state; talloc_steal(state, req); @@ -281,7 +281,7 @@ static NTSTATUS smb2_send_trans_request(struct dcerpc_connection *c, DATA_BLOB * */ static void smb2_write_callback(struct smb2_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_smb2: write callback error\n")); @@ -319,7 +319,7 @@ static NTSTATUS smb2_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, } req->async.fn = smb2_write_callback; - req->async.private = c; + req->async.private_data = c; return NT_STATUS_OK; } @@ -444,7 +444,7 @@ struct composite_context *dcerpc_pipe_open_smb2_send(struct dcerpc_pipe *p, static void pipe_open_recv(struct smb2_request *req) { struct pipe_open_smb2_state *state = - talloc_get_type(req->async.private, + talloc_get_type(req->async.private_data, struct pipe_open_smb2_state); struct composite_context *ctx = state->ctx; struct dcerpc_connection *c = state->c; diff --git a/source4/script/build_idl.sh b/source4/librpc/scripts/build_idl.sh index ea0cb78b0e..5796f40c61 100755 --- a/source4/script/build_idl.sh +++ b/source4/librpc/scripts/build_idl.sh @@ -1,24 +1,26 @@ #!/bin/sh FULLBUILD=$1 -shift 1 +IDLDIR=$2 +OUTDIR=$3 +shift 3 PIDL_EXTRA_ARGS="$*" -[ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1 +[ -d $OUTDIR ] || mkdir -p $OUTDIR || exit 1 -PIDL="$PERL $srcdir/pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --swig --ejs --python $PIDL_EXTRA_ARGS" +PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --ejs --python $PIDL_EXTRA_ARGS" if [ x$FULLBUILD = xFULL ]; then - echo Rebuilding all idl files in librpc/idl - $PIDL $srcdir/librpc/idl/*.idl || exit 1 + echo Rebuilding all idl files in $IDLDIR + $PIDL $IDLDIR/*.idl || exit 1 exit 0 fi list="" -for f in $srcdir/librpc/idl/*.idl ; do +for f in $IDLDIR/*.idl ; do basename=`basename $f .idl` - ndr="librpc/gen_ndr/ndr_$basename.c" + ndr="$OUTDIR/ndr_$basename.c" # blergh - most shells don't have the -nt function if [ -f $ndr ]; then if [ x`find $f -newer $ndr -print` = x$f ]; then diff --git a/source4/main.mk b/source4/main.mk index b8364aca5a..5e31044c09 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -1,31 +1,95 @@ mkinclude dynconfig.mk +heimdalsrcdir := heimdal mkinclude heimdal_build/config.mk mkinclude config.mk +dsdbsrcdir := dsdb mkinclude dsdb/config.mk +smbdsrcdir := smbd mkinclude smbd/config.mk +clustersrcdir := cluster mkinclude cluster/config.mk mkinclude smbd/process_model.mk +libnetsrcdir := libnet mkinclude libnet/config.mk +authsrcdir := auth mkinclude auth/config.mk +nsswitchsrcdir := nsswitch mkinclude nsswitch/config.mk +libsrcdir := lib +mkinclude lib/samba3/config.mk +libsocketsrcdir := lib/socket +mkinclude lib/socket/config.mk +libcharsetsrcdir := lib/charset +mkinclude lib/charset/config.mk +ldb_sambasrcdir := lib/ldb-samba +mkinclude lib/ldb-samba/config.mk +libtlssrcdir := lib/tls +mkinclude lib/tls/config.mk +libregistrysrcdir := lib/registry +mkinclude lib/registry/config.mk +libmessagingsrcdir := lib/messaging +mkinclude lib/messaging/config.mk +libeventssrcdir := lib/events +mkinclude lib/events/config.mk +libcmdlinesrcdir := lib/cmdline +mkinclude lib/cmdline/config.mk +socketwrappersrcdir := lib/socket_wrapper +mkinclude lib/socket_wrapper/config.mk +nsswrappersrcdir := lib/nss_wrapper +mkinclude lib/nss_wrapper/config.mk +appwebsrcdir := lib/appweb +mkinclude lib/appweb/config.mk +libstreamsrcdir := lib/stream +mkinclude lib/stream/config.mk +libutilsrcdir := lib/util +mkinclude lib/util/config.mk +libtdrsrcdir := lib/tdr +mkinclude lib/tdr/config.mk +libdbwrapsrcdir := lib/dbwrap +mkinclude lib/dbwrap/config.mk +libcryptosrcdir := lib/crypto +mkinclude lib/crypto/config.mk +libtorturesrcdir := lib/torture +mkinclude lib/torture/config.mk +libcompressionsrcdir := lib/compression +libgencachesrcdir := lib mkinclude lib/basic.mk +paramsrcdir := param mkinclude param/config.mk +smb_serversrcdir := smb_server mkinclude smb_server/config.mk +rpc_serversrcdir := rpc_server mkinclude rpc_server/config.mk +ldap_serversrcdir := ldap_server mkinclude ldap_server/config.mk +web_serversrcdir := web_server mkinclude web_server/config.mk +winbindsrcdir := winbind mkinclude winbind/config.mk +nbt_serversrcdir := nbt_server mkinclude nbt_server/config.mk +wrepl_serversrcdir := wrepl_server mkinclude wrepl_server/config.mk +cldap_serversrcdir := cldap_server mkinclude cldap_server/config.mk +utilssrcdir := utils mkinclude utils/net/config.mk mkinclude utils/config.mk +ntvfssrcdir := ntvfs mkinclude ntvfs/config.mk +ntptrsrcdir := ntptr mkinclude ntptr/config.mk +torturesrcdir := torture mkinclude torture/config.mk +librpcsrcdir := librpc mkinclude librpc/config.mk +clientsrcdir := client mkinclude client/config.mk +libclisrcdir := libcli mkinclude libcli/config.mk +ejsscriptsrcdir := scripting/ejs mkinclude scripting/ejs/config.mk +pyscriptsrcdir := scripting/python mkinclude scripting/python/config.mk +kdcsrcdir := kdc mkinclude kdc/config.mk diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index 84e6b661bf..b17fd4ce52 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -3,13 +3,14 @@ ####################### # Start SUBSYSTEM WINSDB [SUBSYSTEM::WINSDB] -PRIVATE_PROTO_HEADER = wins/winsdb_proto.h PUBLIC_DEPENDENCIES = \ LIBLDB # End SUBSYSTEM WINSDB ####################### -WINSDB_OBJ_FILES = $(addprefix nbt_server/wins/, winsdb.o wins_hook.o) +WINSDB_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/wins/, winsdb.o wins_hook.o) + +$(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsdb_proto.h,$(WINSDB_OBJ_FILES:.o=.c))) ####################### # Start MODULE ldb_wins_ldb @@ -22,40 +23,42 @@ PRIVATE_DEPENDENCIES = \ # End MODULE ldb_wins_ldb ####################### -ldb_wins_ldb_OBJ_FILES = nbt_server/wins/wins_ldb.o +ldb_wins_ldb_OBJ_FILES = $(nbt_serversrcdir)/wins/wins_ldb.o ####################### # Start SUBSYSTEM NBTD_WINS [SUBSYSTEM::NBTD_WINS] -PRIVATE_PROTO_HEADER = wins/winsserver_proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_NBT WINSDB # End SUBSYSTEM NBTD_WINS ####################### -NBTD_WINS_OBJ_FILES = $(addprefix nbt_server/wins/, winsserver.o winsclient.o winswack.o wins_dns_proxy.o) + +NBTD_WINS_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/wins/, winsserver.o winsclient.o winswack.o wins_dns_proxy.o) + +$(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsserver_proto.h,$(NBTD_WINS_OBJ_FILES:.o=.c))) ####################### # Start SUBSYSTEM NBTD_DGRAM [SUBSYSTEM::NBTD_DGRAM] -PRIVATE_PROTO_HEADER = dgram/proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_DGRAM # End SUBSYSTEM NBTD_DGRAM ####################### -NBTD_DGRAM_OBJ_FILES = $(addprefix nbt_server/dgram/, request.o netlogon.o ntlogon.o browse.o) +NBTD_DGRAM_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/dgram/, request.o netlogon.o browse.o) + +$(eval $(call proto_header_template,$(nbt_serversrcdir)/dgram/proto.h,$(NBTD_DGRAM_OBJ_FILES:.o=.c))) ####################### # Start SUBSYSTEM NBTD [SUBSYSTEM::NBT_SERVER] -PRIVATE_PROTO_HEADER = nbt_server_proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_NBT NBTD_WINS NBTD_DGRAM # End SUBSYSTEM NBTD ####################### -NBT_SERVER_OBJ_FILES = $(addprefix nbt_server/, \ +NBT_SERVER_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/, \ interfaces.o \ register.o \ query.o \ @@ -64,10 +67,12 @@ NBT_SERVER_OBJ_FILES = $(addprefix nbt_server/, \ packet.o \ irpc.o) +$(eval $(call proto_header_template,$(nbt_serversrcdir)/nbt_server_proto.h,$(NBT_SERVER_OBJ_FILES:.o=.c))) + [MODULE::service_nbtd] INIT_FUNCTION = server_service_nbtd_init SUBSYSTEM = smbd PRIVATE_DEPENDENCIES = NBT_SERVER process_model service_nbtd_OBJ_FILES = \ - nbt_server/nbt_server.o + $(nbt_serversrcdir)/nbt_server.o diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c index 7fae6bc1f6..5e263a5854 100644 --- a/source4/nbt_server/dgram/netlogon.c +++ b/source4/nbt_server/dgram/netlogon.c @@ -4,7 +4,8 @@ NBT datagram netlogon server Copyright (C) Andrew Tridgell 2005 - + Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or @@ -26,9 +27,10 @@ #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "util/util_ldb.h" -#include "librpc/gen_ndr/ndr_nbt.h" #include "param/param.h" #include "smbd/service_task.h" +#include "cldap_server/cldap_server.h" +#include "libcli/security/security.h" /* reply to a GETDC request @@ -41,12 +43,12 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot, { struct nbt_name *name = &packet->data.msg.dest_name; struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, false); - struct nbt_netlogon_packet reply; struct nbt_netlogon_response_from_pdc *pdc; const char *ref_attrs[] = {"nETBIOSName", NULL}; struct ldb_message **ref_res; struct ldb_context *samctx; struct ldb_dn *partitions_basedn; + struct nbt_netlogon_response netlogon_response; int ret; /* only answer getdc requests on the PDC or LOGON names */ @@ -60,6 +62,11 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot, return; } + if (!samdb_is_pdc(samctx)) { + DEBUG(2, ("Not a PDC, so not processing LOGON_PRIMARY_QUERY\n")); + return; + } + partitions_basedn = samdb_partitions_dn(samctx, packet); ret = gendb_search(samctx, packet, partitions_basedn, &ref_res, ref_attrs, @@ -72,10 +79,11 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot, } /* setup a GETDC reply */ - ZERO_STRUCT(reply); - reply.command = NETLOGON_RESPONSE_FROM_PDC; - pdc = &reply.req.response; + ZERO_STRUCT(netlogon_response); + netlogon_response.response_type = NETLOGON_GET_PDC; + pdc = &netlogon_response.get_pdc; + pdc->command = NETLOGON_RESPONSE_FROM_PDC; pdc->pdc_name = lp_netbios_name(iface->nbtsrv->task->lp_ctx); pdc->unicode_pdc_name = pdc->pdc_name; pdc->domain_name = samdb_result_string(ref_res[0], "nETBIOSName", name->name);; @@ -83,38 +91,31 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot, pdc->lmnt_token = 0xFFFF; pdc->lm20_token = 0xFFFF; - - packet->data.msg.dest_name.type = 0; - dgram_mailslot_netlogon_reply(reply_iface->dgmsock, packet, lp_netbios_name(iface->nbtsrv->task->lp_ctx), netlogon->req.pdc.mailslot_name, - &reply); + &netlogon_response); } /* reply to a ADS style GETDC request */ -static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot, - struct nbtd_interface *iface, - struct nbt_dgram_packet *packet, - const struct socket_address *src, - struct nbt_netlogon_packet *netlogon) +static void nbtd_netlogon_samlogon(struct dgram_mailslot_handler *dgmslot, + struct nbtd_interface *iface, + struct nbt_dgram_packet *packet, + const struct socket_address *src, + struct nbt_netlogon_packet *netlogon) { struct nbt_name *name = &packet->data.msg.dest_name; struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, false); - struct nbt_netlogon_packet reply; - struct nbt_netlogon_response_from_pdc2 *pdc; struct ldb_context *samctx; - const char *ref_attrs[] = {"nETBIOSName", "dnsRoot", "ncName", NULL}; - const char *dom_attrs[] = {"objectGUID", NULL}; - struct ldb_message **ref_res, **dom_res; - int ret; - const char **services = lp_server_services(iface->nbtsrv->task->lp_ctx); const char *my_ip = reply_iface->ip_address; - struct ldb_dn *partitions_basedn; + struct dom_sid *sid; + struct nbt_netlogon_response netlogon_response; + NTSTATUS status; + if (!my_ip) { DEBUG(0, ("Could not obtain own IP address for datagram socket\n")); return; @@ -131,90 +132,30 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot, return; } - partitions_basedn = samdb_partitions_dn(samctx, packet); - - ret = gendb_search(samctx, packet, partitions_basedn, &ref_res, ref_attrs, - "(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))", - name->name); - - if (ret != 1) { - DEBUG(2,("Unable to find domain reference '%s' in sam\n", name->name)); - return; + if (netlogon->req.logon.sid_size) { + sid = &netlogon->req.logon.sid; + } else { + sid = NULL; } - /* try and find the domain */ - ret = gendb_search_dn(samctx, packet, - samdb_result_dn(samctx, samctx, ref_res[0], "ncName", NULL), - &dom_res, dom_attrs); - if (ret != 1) { - DEBUG(2,("Unable to find domain from reference '%s' in sam\n", - ldb_dn_get_linearized(ref_res[0]->dn))); + status = fill_netlogon_samlogon_response(samctx, packet, NULL, name->name, sid, NULL, + netlogon->req.logon.user_name, netlogon->req.logon.acct_control, src->addr, + netlogon->req.logon.nt_version, iface->nbtsrv->task->lp_ctx, &netlogon_response.samlogon); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(2,("NBT netlogon query failed domain=%s sid=%s version=%d - %s\n", + name->name, dom_sid_string(packet, sid), netlogon->req.logon.nt_version, nt_errstr(status))); return; } - /* setup a GETDC reply */ - ZERO_STRUCT(reply); - reply.command = NETLOGON_RESPONSE_FROM_PDC2; - -#if 0 - /* newer testing shows that the reply command type is not - changed based on whether a username is given in the - reply. This was what was causing the w2k join to be so - slow */ - if (netlogon->req.pdc2.user_name[0]) { - reply.command = NETLOGON_RESPONSE_FROM_PDC_USER; - } -#endif - - pdc = &reply.req.response2; - - /* TODO: accurately depict which services we are running */ - pdc->server_type = - NBT_SERVER_PDC | NBT_SERVER_GC | - NBT_SERVER_DS | NBT_SERVER_TIMESERV | - NBT_SERVER_CLOSEST | NBT_SERVER_WRITABLE | - NBT_SERVER_GOOD_TIMESERV; - - /* hmm, probably a better way to do this */ - if (str_list_check(services, "ldap")) { - pdc->server_type |= NBT_SERVER_LDAP; - } - - if (str_list_check(services, "kdc")) { - pdc->server_type |= NBT_SERVER_KDC; - } - - pdc->domain_uuid = samdb_result_guid(dom_res[0], "objectGUID"); - pdc->forest = samdb_result_string(ref_res[0], "dnsRoot", - lp_realm(iface->nbtsrv->task->lp_ctx)); - pdc->dns_domain = samdb_result_string(ref_res[0], "dnsRoot", - lp_realm(iface->nbtsrv->task->lp_ctx)); - - /* TODO: get our full DNS name from somewhere else */ - pdc->pdc_dns_name = talloc_asprintf(packet, "%s.%s", - strlower_talloc(packet, - lp_netbios_name(iface->nbtsrv->task->lp_ctx)), - pdc->dns_domain); - pdc->domain = samdb_result_string(ref_res[0], "nETBIOSName", name->name);; - pdc->pdc_name = lp_netbios_name(iface->nbtsrv->task->lp_ctx); - pdc->user_name = netlogon->req.pdc2.user_name; - /* TODO: we need to make sure these are in our DNS zone */ - pdc->server_site = "Default-First-Site-Name"; - pdc->client_site = "Default-First-Site-Name"; - pdc->unknown = 0x10; /* what is this? */ - pdc->unknown2 = 2; /* and this ... */ - pdc->pdc_ip = my_ip; - pdc->nt_version = 13; - pdc->lmnt_token = 0xFFFF; - pdc->lm20_token = 0xFFFF; + netlogon_response.response_type = NETLOGON_SAMLOGON; packet->data.msg.dest_name.type = 0; dgram_mailslot_netlogon_reply(reply_iface->dgmsock, packet, lp_netbios_name(iface->nbtsrv->task->lp_ctx), - netlogon->req.pdc2.mailslot_name, - &reply); + netlogon->req.logon.mailslot_name, + &netlogon_response); } @@ -246,15 +187,17 @@ void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot, DEBUG(2,("netlogon request to %s from %s:%d\n", nbt_name_string(netlogon, name), src->addr, src->port)); - status = dgram_mailslot_netlogon_parse(dgmslot, netlogon, packet, netlogon); + status = dgram_mailslot_netlogon_parse_request(dgmslot, netlogon, packet, netlogon); if (!NT_STATUS_IS_OK(status)) goto failed; switch (netlogon->command) { - case NETLOGON_QUERY_FOR_PDC: - nbtd_netlogon_getdc(dgmslot, iface, packet, src, netlogon); + case LOGON_PRIMARY_QUERY: + nbtd_netlogon_getdc(dgmslot, iface, packet, + src, netlogon); break; - case NETLOGON_QUERY_FOR_PDC2: - nbtd_netlogon_getdc2(dgmslot, iface, packet, src, netlogon); + case LOGON_SAM_LOGON_REQUEST: + nbtd_netlogon_samlogon(dgmslot, iface, packet, + src, netlogon); break; default: DEBUG(2,("unknown netlogon op %d from %s:%d\n", diff --git a/source4/nbt_server/dgram/request.c b/source4/nbt_server/dgram/request.c index 205a544209..277b64741d 100644 --- a/source4/nbt_server/dgram/request.c +++ b/source4/nbt_server/dgram/request.c @@ -35,8 +35,10 @@ static const struct { const char *mailslot_name; dgram_mailslot_handler_t handler; } mailslot_handlers[] = { + /* Handle both NTLOGON and NETLOGON in the same function, as + * they are very similar */ { NBT_MAILSLOT_NETLOGON, nbtd_mailslot_netlogon_handler }, - { NBT_MAILSLOT_NTLOGON, nbtd_mailslot_ntlogon_handler }, + { NBT_MAILSLOT_NTLOGON, nbtd_mailslot_netlogon_handler }, { NBT_MAILSLOT_BROWSE, nbtd_mailslot_browse_handler } }; diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c index 8f2f7fc2c2..8f1f74afcf 100644 --- a/source4/nbt_server/irpc.c +++ b/source4/nbt_server/irpc.c @@ -49,7 +49,7 @@ static NTSTATUS nbtd_information(struct irpc_message *msg, /* - winbind needs to be able to do a getdc request, but some windows + winbind needs to be able to do a getdc request, but most (all?) windows servers always send the reply to port 138, regardless of the request port. To cope with this we use a irpc request to the NBT server which has port 138 open, and thus can receive the replies @@ -59,57 +59,49 @@ struct getdc_state { struct nbtd_getdcname *req; }; -static void getdc_recv_ntlogon_reply(struct dgram_mailslot_handler *dgmslot, - struct nbt_dgram_packet *packet, - struct socket_address *src) +static void getdc_recv_netlogon_reply(struct dgram_mailslot_handler *dgmslot, + struct nbt_dgram_packet *packet, + struct socket_address *src) { struct getdc_state *s = talloc_get_type(dgmslot->private, struct getdc_state); - - struct nbt_ntlogon_packet ntlogon; + const char *p; + struct nbt_netlogon_response netlogon; NTSTATUS status; - status = dgram_mailslot_ntlogon_parse(dgmslot, packet, packet, - &ntlogon); + status = dgram_mailslot_netlogon_parse_response(dgmslot, packet, packet, + &netlogon); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("dgram_mailslot_ntlogon_parse failed: %s\n", nt_errstr(status))); goto done; } - status = NT_STATUS_NO_LOGON_SERVERS; + /* We asked for version 1 only */ + if (netlogon.response_type == NETLOGON_SAMLOGON + && netlogon.samlogon.ntver != NETLOGON_NT_VERSION_1) { + status = NT_STATUS_INVALID_NETWORK_RESPONSE; + goto done; + } - DEBUG(10, ("reply: command=%d\n", ntlogon.command)); + p = netlogon.samlogon.nt4.server; - switch (ntlogon.command) { - case NTLOGON_SAM_LOGON: - DEBUG(0, ("Huh -- got NTLOGON_SAM_LOGON as reply\n")); - break; - case NTLOGON_SAM_LOGON_REPLY: - case NTLOGON_SAM_LOGON_REPLY15: { - const char *p = ntlogon.req.reply.server; - - DEBUG(10, ("NTLOGON_SAM_LOGON_REPLY: server: %s, user: %s, " - "domain: %s\n", p, ntlogon.req.reply.user_name, - ntlogon.req.reply.domain)); - - if (*p == '\\') p += 1; - if (*p == '\\') p += 1; - - s->req->out.dcname = talloc_strdup(s->req, p); - if (s->req->out.dcname == NULL) { - DEBUG(0, ("talloc failed\n")); - status = NT_STATUS_NO_MEMORY; - goto done; - } - status = NT_STATUS_OK; - break; - } - default: - DEBUG(0, ("Got unknown packet: %d\n", ntlogon.command)); - break; + DEBUG(10, ("NTLOGON_SAM_LOGON_REPLY: server: %s, user: %s, " + "domain: %s\n", p, netlogon.samlogon.nt4.user_name, + netlogon.samlogon.nt4.domain)); + + if (*p == '\\') p += 1; + if (*p == '\\') p += 1; + + s->req->out.dcname = talloc_strdup(s->req, p); + if (s->req->out.dcname == NULL) { + DEBUG(0, ("talloc failed\n")); + status = NT_STATUS_NO_MEMORY; + goto done; } + status = NT_STATUS_OK; + done: irpc_send_reply(s->msg, status); } @@ -121,8 +113,8 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, talloc_get_type(msg->private, struct nbtd_server); struct nbtd_interface *iface = nbtd_find_request_iface(server, req->in.ip_address, true); struct getdc_state *s; - struct nbt_ntlogon_packet p; - struct nbt_ntlogon_sam_logon *r; + struct nbt_netlogon_packet p; + struct NETLOGON_SAM_LOGON_REQUEST *r; struct nbt_name src, dst; struct socket_address *dest; struct dgram_mailslot_handler *handler; @@ -137,11 +129,11 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, s->req = req; handler = dgram_mailslot_temp(iface->dgmsock, NBT_MAILSLOT_GETDC, - getdc_recv_ntlogon_reply, s); + getdc_recv_netlogon_reply, s); NT_STATUS_HAVE_NO_MEMORY(handler); ZERO_STRUCT(p); - p.command = NTLOGON_SAM_LOGON; + p.command = LOGON_SAM_LOGON_REQUEST; r = &p.req.logon; r->request_count = 0; r->computer_name = req->in.my_computername; @@ -149,7 +141,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, r->mailslot_name = handler->mailslot_name; r->acct_control = req->in.account_control; r->sid = *req->in.domain_sid; - r->nt_version = 1; + r->nt_version = NETLOGON_NT_VERSION_1; r->lmnt_token = 0xffff; r->lm20_token = 0xffff; @@ -160,9 +152,10 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, req->in.ip_address, 138); NT_STATUS_HAVE_NO_MEMORY(dest); - status = dgram_mailslot_ntlogon_send(iface->dgmsock, DGRAM_DIRECT_GROUP, - &dst, dest, - &src, &p); + status = dgram_mailslot_netlogon_send(iface->dgmsock, + &dst, dest, + NBT_MAILSLOT_NETLOGON, + &src, &p); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("dgram_mailslot_ntlogon_send failed: %s\n", nt_errstr(status))); diff --git a/source4/nsswitch/config.mk b/source4/nsswitch/config.mk index a0ceff0033..e8b9600882 100644 --- a/source4/nsswitch/config.mk +++ b/source4/nsswitch/config.mk @@ -1,7 +1,7 @@ [SUBSYSTEM::LIBWINBIND-CLIENT] PRIVATE_DEPENDENCIES = SOCKET_WRAPPER -LIBWINBIND-CLIENT_OBJ_FILES = nsswitch/wb_common.o +LIBWINBIND-CLIENT_OBJ_FILES = $(nsswitchsrcdir)/wb_common.o ################################# # Start BINARY nsstest @@ -14,7 +14,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY nsstest ################################# -nsstest_OBJ_FILES = nsswitch/nsstest.o +nsstest_OBJ_FILES = $(nsswitchsrcdir)/nsstest.o ################################# # Start BINARY wbinfo @@ -31,4 +31,4 @@ PRIVATE_DEPENDENCIES = \ ################################# wbinfo_OBJ_FILES = \ - nsswitch/wbinfo.o + $(nsswitchsrcdir)/wbinfo.o diff --git a/source4/ntptr/config.mk b/source4/ntptr/config.mk index dda4c29444..71b3bc05a8 100644 --- a/source4/ntptr/config.mk +++ b/source4/ntptr/config.mk @@ -10,17 +10,18 @@ PRIVATE_DEPENDENCIES = \ # End MODULE ntptr_simple_ldb ################################################ -ntptr_simple_ldb_OBJ_FILES = ntptr/simple_ldb/ntptr_simple_ldb.o +ntptr_simple_ldb_OBJ_FILES = $(ntptrsrcdir)/simple_ldb/ntptr_simple_ldb.o ################################################ # Start SUBSYSTEM ntptr [SUBSYSTEM::ntptr] -PRIVATE_PROTO_HEADER = ntptr_proto.h PUBLIC_DEPENDENCIES = DCERPC_COMMON # # End SUBSYSTEM ntptr ################################################ ntptr_OBJ_FILES = \ - ntptr/ntptr_base.o \ - ntptr/ntptr_interface.o + $(ntptrsrcdir)/ntptr_base.o \ + $(ntptrsrcdir)/ntptr_interface.o + +$(eval $(call proto_header_template,$(ntptrsrcdir)/ntptr_proto.h,$(ntptr_OBJ_FILES:.o=.c))) diff --git a/source4/ntvfs/common/config.mk b/source4/ntvfs/common/config.mk index c66257b73f..1fe093bb69 100644 --- a/source4/ntvfs/common/config.mk +++ b/source4/ntvfs/common/config.mk @@ -1,11 +1,12 @@ ################################################ # Start LIBRARY ntvfs_common [SUBSYSTEM::ntvfs_common] -PRIVATE_PROTO_HEADER = proto.h PUBLIC_DEPENDENCIES = NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share LIBDBWRAP PRIVATE_DEPENDENCIES = brlock_ctdb opendb_ctdb # End LIBRARY ntvfs_common ################################################ -ntvfs_common_OBJ_FILES = $(addprefix ntvfs/common/, init.o brlock.o brlock_tdb.o opendb.o opendb_tdb.o notify.o) +ntvfs_common_OBJ_FILES = $(addprefix $(ntvfssrcdir)/common/, init.o brlock.o brlock_tdb.o opendb.o opendb_tdb.o notify.o) + +$(eval $(call proto_header_template,$(ntvfssrcdir)/common/proto.h,$(ntvfs_common_OBJ_FILES:.o=.c))) diff --git a/source4/ntvfs/config.mk b/source4/ntvfs/config.mk index 93cbf64d8f..bf34c4082a 100644 --- a/source4/ntvfs/config.mk +++ b/source4/ntvfs/config.mk @@ -14,18 +14,33 @@ PRIVATE_DEPENDENCIES = \ # End MODULE ntvfs_cifs ################################################ -ntvfs_cifs_OBJ_FILES = ntvfs/cifs/vfs_cifs.o +ntvfs_cifs_OBJ_FILES = $(ntvfssrcdir)/cifs/vfs_cifs.o + + +################################################ +# Start MODULE ntvfs_smb2 +[MODULE::ntvfs_smb2] +INIT_FUNCTION = ntvfs_smb2_init +SUBSYSTEM = ntvfs +PRIVATE_DEPENDENCIES = \ + LIBCLI_SMB LIBCLI_RAW +# End MODULE ntvfs_smb2 +################################################ + +ntvfs_smb2_OBJ_FILES = ntvfs/smb2/vfs_smb2.o + ################################################ # Start MODULE ntvfs_simple [MODULE::ntvfs_simple] INIT_FUNCTION = ntvfs_simple_init SUBSYSTEM = ntvfs -PRIVATE_PROTO_HEADER = simple/proto.h # End MODULE ntvfs_simple ################################################ -ntvfs_simple_OBJ_FILES = $(addprefix ntvfs/simple/, vfs_simple.o svfs_util.o) +ntvfs_simple_OBJ_FILES = $(addprefix $(ntvfssrcdir)/simple/, vfs_simple.o svfs_util.o) + +$(eval $(call proto_header_template,$(ntvfssrcdir)/simple/proto.h,$(ntvfs_simple_OBJ_FILES:.o=.c))) ################################################ # Start MODULE ntvfs_cifsposix @@ -33,12 +48,13 @@ ntvfs_simple_OBJ_FILES = $(addprefix ntvfs/simple/, vfs_simple.o svfs_util.o) #ENABLE = NO INIT_FUNCTION = ntvfs_cifs_posix_init SUBSYSTEM = ntvfs -PRIVATE_PROTO_HEADER = cifs_posix_cli/proto.h # End MODULE ntvfs_cifsposix ################################################ ntvfs_cifsposix_OBJ_FILES = \ - $(addprefix ntvfs/cifs_posix_cli/, vfs_cifs_posix.o svfs_util.o) + $(addprefix $(ntvfssrcdir)/cifs_posix_cli/, vfs_cifs_posix.o svfs_util.o) + +$(eval $(call proto_header_template,$(ntvfssrcdir)/cifs_posix_cli/proto.h,$(ntvfs_cifsposix_OBJ_FILES:.o=.c))) ################################################ # Start MODULE ntvfs_print @@ -48,19 +64,20 @@ SUBSYSTEM = ntvfs # End MODULE ntvfs_print ################################################ -ntvfs_print_OBJ_FILES = ntvfs/print/vfs_print.o +ntvfs_print_OBJ_FILES = $(ntvfssrcdir)/print/vfs_print.o ################################################ # Start MODULE ntvfs_ipc [MODULE::ntvfs_ipc] SUBSYSTEM = ntvfs INIT_FUNCTION = ntvfs_ipc_init -PRIVATE_PROTO_HEADER = ipc/proto.h PRIVATE_DEPENDENCIES = dcerpc_server DCERPC_COMMON # End MODULE ntvfs_ipc ################################################ -ntvfs_ipc_OBJ_FILES = $(addprefix ntvfs/ipc/, vfs_ipc.o ipc_rap.o rap_server.o) +ntvfs_ipc_OBJ_FILES = $(addprefix $(ntvfssrcdir)/ipc/, vfs_ipc.o ipc_rap.o rap_server.o) + +$(eval $(call proto_header_template,$(ntvfssrcdir)/ipc/proto.h,$(ntvfs_ipc_OBJ_FILES:.o=.c))) ################################################ # Start MODULE ntvfs_nbench @@ -70,16 +87,17 @@ INIT_FUNCTION = ntvfs_nbench_init # End MODULE ntvfs_nbench ################################################ -ntvfs_nbench_OBJ_FILES = ntvfs/nbench/vfs_nbench.o +ntvfs_nbench_OBJ_FILES = $(ntvfssrcdir)/nbench/vfs_nbench.o ################################################ # Start SUBSYSTEM NTVFS [SUBSYSTEM::ntvfs] -PRIVATE_PROTO_HEADER = ntvfs_proto.h -ntvfs_OBJ_FILES = $(addprefix ntvfs/, ntvfs_base.o ntvfs_generic.o ntvfs_interface.o ntvfs_util.o) +ntvfs_OBJ_FILES = $(addprefix $(ntvfssrcdir)/, ntvfs_base.o ntvfs_generic.o ntvfs_interface.o ntvfs_util.o) + +$(eval $(call proto_header_template,$(ntvfssrcdir)/ntvfs_proto.h,$(ntvfs_OBJ_FILES:.o=.c))) -# PUBLIC_HEADERS += ntvfs/ntvfs.h +# PUBLIC_HEADERS += $(ntvfssrcdir)/ntvfs.h # # End SUBSYSTEM NTVFS ################################################ diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index 3706cd172c..6de13e4a0a 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -205,6 +205,7 @@ NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx) static bool initialized = false; extern NTSTATUS ntvfs_posix_init(void); extern NTSTATUS ntvfs_cifs_init(void); + extern NTSTATUS ntvfs_smb2_init(void); extern NTSTATUS ntvfs_nbench_init(void); extern NTSTATUS ntvfs_unixuid_init(void); extern NTSTATUS ntvfs_ipc_init(void); diff --git a/source4/ntvfs/posix/config.mk b/source4/ntvfs/posix/config.mk index 865a0ffd4a..0ee3e3be16 100644 --- a/source4/ntvfs/posix/config.mk +++ b/source4/ntvfs/posix/config.mk @@ -7,7 +7,7 @@ PRIVATE_DEPENDENCIES = NDR_XATTR ntvfs_posix # End MODULE pvfs_acl_xattr ################################################ -pvfs_acl_xattr_OBJ_FILES = ntvfs/posix/pvfs_acl_xattr.o +pvfs_acl_xattr_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_acl_xattr.o ################################################ # Start MODULE pvfs_acl_nfs4 @@ -18,7 +18,7 @@ PRIVATE_DEPENDENCIES = NDR_NFS4ACL SAMDB ntvfs_posix # End MODULE pvfs_acl_nfs4 ################################################ -pvfs_acl_nfs4_OBJ_FILES = ntvfs/posix/pvfs_acl_nfs4.o +pvfs_acl_nfs4_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_acl_nfs4.o ################################################ [MODULE::pvfs_aio] @@ -26,7 +26,7 @@ SUBSYSTEM = ntvfs PRIVATE_DEPENDENCIES = LIBAIO_LINUX ################################################ -pvfs_aio_OBJ_FILES = ntvfs/posix/pvfs_aio.o +pvfs_aio_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_aio.o ################################################ # Start MODULE ntvfs_posix @@ -34,14 +34,13 @@ pvfs_aio_OBJ_FILES = ntvfs/posix/pvfs_aio.o SUBSYSTEM = ntvfs OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = ntvfs_posix_init -PRIVATE_PROTO_HEADER = vfs_posix_proto.h #PRIVATE_DEPENDENCIES = pvfs_acl_xattr pvfs_acl_nfs4 PRIVATE_DEPENDENCIES = NDR_XATTR WRAP_XATTR BLKID ntvfs_common MESSAGING pvfs_aio \ LIBWBCLIENT # End MODULE ntvfs_posix ################################################ -ntvfs_posix_OBJ_FILES = $(addprefix ntvfs/posix/, \ +ntvfs_posix_OBJ_FILES = $(addprefix $(ntvfssrcdir)/posix/, \ vfs_posix.o \ pvfs_util.o \ pvfs_search.o \ @@ -71,3 +70,5 @@ ntvfs_posix_OBJ_FILES = $(addprefix ntvfs/posix/, \ xattr_system.o \ xattr_tdb.o) +$(eval $(call proto_header_template,$(ntvfssrcdir)/posix/vfs_posix_proto.h,$(ntvfs_posix_OBJ_FILES:.o=.c))) + diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index c9c1c56f14..67937324cc 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -1117,6 +1117,20 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs, return status; } + /* if the client specified that it must not be a directory then + check that it isn't */ + if (name->exists && (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) && + (io->generic.in.create_options & NTCREATEX_OPTIONS_NON_DIRECTORY_FILE)) { + return NT_STATUS_FILE_IS_A_DIRECTORY; + } + + /* if the client specified that it must be a directory then + check that it is */ + if (name->exists && !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) && + (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)) { + return NT_STATUS_NOT_A_DIRECTORY; + } + /* directory opens are handled separately */ if ((name->exists && (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) || (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)) { diff --git a/source4/ntvfs/smb2/vfs_smb2.c b/source4/ntvfs/smb2/vfs_smb2.c new file mode 100644 index 0000000000..cc09daf83f --- /dev/null +++ b/source4/ntvfs/smb2/vfs_smb2.c @@ -0,0 +1,844 @@ +/* + Unix SMB/CIFS implementation. + + CIFS-to-SMB2 NTVFS filesystem backend + + Copyright (C) Andrew Tridgell 2008 + + largely based on vfs_cifs.c which was + Copyright (C) Andrew Tridgell 2003 + Copyright (C) James J Myers 2003 <myersjj@samba.org> + + 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/>. +*/ +/* + this implements a CIFS->CIFS NTVFS filesystem backend. + +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" +#include "libcli/composite/composite.h" +#include "libcli/smb_composite/smb_composite.h" +#include "auth/auth.h" +#include "auth/credentials/credentials.h" +#include "ntvfs/ntvfs.h" +#include "lib/util/dlinklist.h" +#include "param/param.h" +#include "libcli/resolve/resolve.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" + +struct cvfs_file { + struct cvfs_file *prev, *next; + uint16_t fnum; + struct ntvfs_handle *h; +}; + +/* this is stored in ntvfs_private */ +struct cvfs_private { + struct smb2_tree *tree; + struct smb2_transport *transport; + struct ntvfs_module_context *ntvfs; + struct async_info *pending; + struct cvfs_file *files; + + /* a handle on the root of the share */ + /* TODO: leaving this handle open could prevent other users + from opening the share with exclusive access. We probably + need to open it on demand */ + struct smb2_handle roothandle; +}; + + +/* a structure used to pass information to an async handler */ +struct async_info { + struct async_info *next, *prev; + struct cvfs_private *cvfs; + struct ntvfs_request *req; + void *c_req; + struct composite_context *c_comp; + struct cvfs_file *f; + void *parms; +}; + +#define SETUP_FILE_HERE(f) do { \ + f = ntvfs_handle_get_backend_data(io->generic.in.file.ntvfs, ntvfs); \ + if (!f) return NT_STATUS_INVALID_HANDLE; \ + io->generic.in.file.fnum = f->fnum; \ +} while (0) + +#define SETUP_FILE do { \ + struct cvfs_file *f; \ + SETUP_FILE_HERE(f); \ +} while (0) + +#define SMB2_SERVER "smb2:server" +#define SMB2_USER "smb2:user" +#define SMB2_PASSWORD "smb2:password" +#define SMB2_DOMAIN "smb2:domain" +#define SMB2_SHARE "smb2:share" +#define SMB2_USE_MACHINE_ACCT "smb2:use-machine-account" + +#define SMB2_USE_MACHINE_ACCT_DEFAULT false + +/* + a handler for oplock break events from the server - these need to be passed + along to the client + */ +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; + NTSTATUS status; + struct ntvfs_handle *h = NULL; + struct cvfs_file *f; + + for (f=private->files; f; f=f->next) { + if (f->fnum != fnum) continue; + h = f->h; + break; + } + + if (!h) { + DEBUG(5,("vfs_smb2: ignoring oplock break level %d for fnum %d\n", level, fnum)); + return true; + } + + DEBUG(5,("vfs_smb2: sending oplock break level %d for fnum %d\n", level, fnum)); + status = ntvfs_send_oplock_break(private->ntvfs, h, level); + if (!NT_STATUS_IS_OK(status)) return false; + return true; +} + +/* + return a handle to the root of the share +*/ +static NTSTATUS smb2_get_roothandle(struct smb2_tree *tree, struct smb2_handle *handle) +{ + struct smb2_create io; + NTSTATUS status; + + ZERO_STRUCT(io); + io.in.oplock_level = 0; + io.in.desired_access = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE | SEC_DIR_LIST; + io.in.file_attributes = 0; + io.in.create_disposition = NTCREATEX_DISP_OPEN; + io.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE; + io.in.create_options = 0; + io.in.fname = NULL; + + status = smb2_create(tree, tree, &io); + NT_STATUS_NOT_OK_RETURN(status); + + *handle = io.out.file.handle; + + return NT_STATUS_OK; +} + +/* + connect to a share - used when a tree_connect operation comes in. +*/ +static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, const char *sharename) +{ + NTSTATUS status; + struct cvfs_private *private; + const char *host, *user, *pass, *domain, *remote_share; + struct composite_context *creq; + struct share_config *scfg = ntvfs->ctx->config; + struct smb2_tree *tree; + + struct cli_credentials *credentials; + bool machine_account; + + /* Here we need to determine which server to connect to. + * For now we use parametric options, type cifs. + * Later we will use security=server and auth_server.c. + */ + host = share_string_option(scfg, SMB2_SERVER, NULL); + user = share_string_option(scfg, SMB2_USER, NULL); + pass = share_string_option(scfg, SMB2_PASSWORD, NULL); + domain = share_string_option(scfg, SMB2_DOMAIN, NULL); + remote_share = share_string_option(scfg, SMB2_SHARE, NULL); + if (!remote_share) { + remote_share = sharename; + } + + machine_account = share_bool_option(scfg, SMB2_USE_MACHINE_ACCT, SMB2_USE_MACHINE_ACCT_DEFAULT); + + private = talloc_zero(ntvfs, struct cvfs_private); + if (!private) { + return NT_STATUS_NO_MEMORY; + } + + ntvfs->private_data = private; + + if (!host) { + DEBUG(1,("CIFS backend: You must supply server\n")); + return NT_STATUS_INVALID_PARAMETER; + } + + if (user && pass) { + DEBUG(5, ("CIFS backend: Using specified password\n")); + credentials = cli_credentials_init(private); + if (!credentials) { + return NT_STATUS_NO_MEMORY; + } + cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); + cli_credentials_set_username(credentials, user, CRED_SPECIFIED); + if (domain) { + cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); + } + 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); + cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); + if (domain) { + cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); + } + status = cli_credentials_set_machine_account(credentials, ntvfs->ctx->lp_ctx); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } else if (req->session_info->credentials) { + DEBUG(5, ("CIFS backend: Using delegated credentials\n")); + credentials = req->session_info->credentials; + } else { + DEBUG(1,("CIFS backend: NO delegated credentials found: You must supply server, user and password or the client must supply delegated credentials\n")); + return NT_STATUS_INVALID_PARAMETER; + } + + creq = smb2_connect_send(private, host, remote_share, + lp_resolve_context(ntvfs->ctx->lp_ctx), + credentials, + ntvfs->ctx->event_ctx); + + status = smb2_connect_recv(creq, private, &tree); + NT_STATUS_NOT_OK_RETURN(status); + + status = smb2_get_roothandle(tree, &private->roothandle); + NT_STATUS_NOT_OK_RETURN(status); + + private->tree = tree; + private->transport = private->tree->session->transport; + private->ntvfs = ntvfs; + + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); + + /* we need to receive oplock break requests from the server */ + /* TODO: enable oplocks + smbcli_oplock_handler(private->transport, oplock_handler, private); + */ + return NT_STATUS_OK; +} + +/* + disconnect from a share +*/ +static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs) +{ + struct cvfs_private *private = ntvfs->private_data; + struct async_info *a, *an; + + /* first cleanup pending requests */ + for (a=private->pending; a; a = an) { + an = a->next; + talloc_free(a->c_req); + talloc_free(a); + } + + talloc_free(private); + ntvfs->private_data = NULL; + + return NT_STATUS_OK; +} + +/* + destroy an async info structure +*/ +static int async_info_destructor(struct async_info *async) +{ + DLIST_REMOVE(async->cvfs->pending, async); + return 0; +} + +/* + a handler for simple async SMB2 replies + this handler can only be used for functions that don't return any + parameters (those that just return a status code) + */ +static void async_simple_smb2(struct smb2_request *c_req) +{ + struct async_info *async = c_req->async.private_data; + struct ntvfs_request *req = async->req; + + smb2_request_receive(c_req); + req->async_states->status = smb2_request_destroy(c_req); + talloc_free(async); + req->async_states->send_fn(req); +} + +/* + a handler for simple async composite replies + this handler can only be used for functions that don't return any + parameters (those that just return a status code) + */ +static void async_simple_composite(struct composite_context *c_req) +{ + struct async_info *async = c_req->async.private_data; + struct ntvfs_request *req = async->req; + + req->async_states->status = composite_wait_free(c_req); + talloc_free(async); + req->async_states->send_fn(req); +} + + +/* save some typing for the simple functions */ +#define ASYNC_RECV_TAIL_F(io, async_fn, file) do { \ + if (!c_req) return NT_STATUS_UNSUCCESSFUL; \ + { \ + struct async_info *async; \ + async = talloc(req, struct async_info); \ + if (!async) return NT_STATUS_NO_MEMORY; \ + async->parms = io; \ + async->req = req; \ + async->f = file; \ + async->cvfs = private; \ + async->c_req = c_req; \ + DLIST_ADD(private->pending, async); \ + c_req->async.private_data = async; \ + talloc_set_destructor(async, async_info_destructor); \ + } \ + c_req->async.fn = async_fn; \ + req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; \ + return NT_STATUS_OK; \ +} while (0) + +#define ASYNC_RECV_TAIL(io, async_fn) ASYNC_RECV_TAIL_F(io, async_fn, NULL) + +#define SIMPLE_ASYNC_TAIL ASYNC_RECV_TAIL(NULL, async_simple_smb2) +#define SIMPLE_COMPOSITE_TAIL ASYNC_RECV_TAIL(NULL, async_simple_composite) + +#define CHECK_ASYNC(req) do { \ + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { \ + DEBUG(0,("SMB2 proxy backend does not support sync operation at %s\n", \ + __location__)); \ + return NT_STATUS_NOT_IMPLEMENTED; \ + }} while (0) + +/* + delete a file - the dirtype specifies the file types to include in the search. + The name can contain CIFS wildcards, but rarely does (except with OS/2 clients) + + BUGS: + - doesn't handle wildcards + - doesn't obey attrib restrictions +*/ +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 composite_context *c_req; + + CHECK_ASYNC(req); + + c_req = smb2_composite_unlink_send(private->tree, unl); + + SIMPLE_COMPOSITE_TAIL; +} + +/* + ioctl interface +*/ +static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_ioctl *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + check if a directory exists +*/ +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 smb2_request *c_req; + struct smb2_find f; + + CHECK_ASYNC(req); + + /* SMB2 doesn't have a chkpath operation, and also doesn't + have a query path info call, so the best seems to be to do a + find call, using the roothandle we established at connect + time */ + ZERO_STRUCT(f); + f.in.file.handle = private->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 + approximation */ + if (strcmp(f.in.pattern, "\\") == 0 || + strcmp(f.in.pattern, "") == 0) { + f.in.pattern = "?"; + } + 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); + + SIMPLE_ASYNC_TAIL; +} + +/* + return info on a pathname +*/ +static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_fileinfo *info) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + query info on a open file +*/ +static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_fileinfo *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + + +/* + set info on a pathname +*/ +static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_setfileinfo *st) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + + +/* + open a file +*/ +static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_open *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + create a directory +*/ +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 composite_context *c_req; + + CHECK_ASYNC(req); + + c_req = smb2_composite_mkdir_send(private->tree, md); + + SIMPLE_COMPOSITE_TAIL; +} + +/* + remove a directory +*/ +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 composite_context *c_req; + + CHECK_ASYNC(req); + + c_req = smb2_composite_rmdir_send(private->tree, rd); + + SIMPLE_COMPOSITE_TAIL; +} + +/* + rename a set of files +*/ +static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_rename *ren) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + copy a set of files +*/ +static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, struct smb_copy *cp) +{ + return NT_STATUS_NOT_SUPPORTED; +} + +/* + read from a file +*/ +static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_read *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + write to a file +*/ +static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_write *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + seek in a file +*/ +static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_seek *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + flush a file +*/ +static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_flush *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + close a file +*/ +static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_close *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + exit - closing files open by the pid +*/ +static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + logoff - closing files open by the user +*/ +static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req) +{ + /* we can't do this right in the cifs backend .... */ + return NT_STATUS_OK; +} + +/* + setup for an async call - nothing to do yet +*/ +static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + void *private) +{ + return NT_STATUS_OK; +} + +/* + cancel an async call +*/ +static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + lock a byte range +*/ +static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_lock *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + set info on a open file +*/ +static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_setfileinfo *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + + +/* + a handler for async fsinfo replies + */ +static void async_fsinfo(struct smb2_request *c_req) +{ + struct async_info *async = c_req->async.private_data; + struct ntvfs_request *req = async->req; + req->async_states->status = smb2_getinfo_fs_recv(c_req, req, async->parms); + talloc_free(async); + req->async_states->send_fn(req); +} + +/* + return filesystem space info +*/ +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 smb2_request *c_req; + enum smb_fsinfo_level level = fs->generic.level; + + CHECK_ASYNC(req); + + switch (level) { + /* some levels go straight through */ + case RAW_QFS_VOLUME_INFORMATION: + case RAW_QFS_SIZE_INFORMATION: + case RAW_QFS_DEVICE_INFORMATION: + case RAW_QFS_ATTRIBUTE_INFORMATION: + case RAW_QFS_QUOTA_INFORMATION: + case RAW_QFS_FULL_SIZE_INFORMATION: + case RAW_QFS_OBJECTID_INFORMATION: + break; + + /* some get mapped */ + case RAW_QFS_VOLUME_INFO: + level = RAW_QFS_VOLUME_INFORMATION; + break; + case RAW_QFS_SIZE_INFO: + level = RAW_QFS_SIZE_INFORMATION; + break; + case RAW_QFS_DEVICE_INFO: + level = RAW_QFS_DEVICE_INFORMATION; + break; + case RAW_QFS_ATTRIBUTE_INFO: + level = RAW_QFS_ATTRIBUTE_INFO; + break; + + default: + /* the rest get refused for now */ + DEBUG(0,("fsinfo level %u not possible on SMB2\n", + (unsigned)fs->generic.level)); + break; + } + + fs->generic.level = level; + fs->generic.handle = private->roothandle; + + c_req = smb2_getinfo_fs_send(private->tree, fs); + + ASYNC_RECV_TAIL(fs, async_fsinfo); +} + +/* + return print queue info +*/ +static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_lpq *lpq) +{ + return NT_STATUS_NOT_SUPPORTED; +} + +/* + list files in a directory matching a wildcard pattern +*/ +static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_first *io, + void *search_private, + bool (*callback)(void *, const union smb_search_data *)) +{ + struct cvfs_private *private = ntvfs->private_data; + struct smb2_find f; + enum smb_search_data_level smb2_level; + uint_t count, i; + union smb_search_data *data; + NTSTATUS status; + + if (io->generic.level != RAW_SEARCH_TRANS2) { + DEBUG(0,("We only support trans2 search in smb2 backend\n")); + return NT_STATUS_NOT_SUPPORTED; + } + + switch (io->generic.data_level) { + case RAW_SEARCH_DATA_DIRECTORY_INFO: + smb2_level = SMB2_FIND_DIRECTORY_INFO; + break; + case RAW_SEARCH_DATA_FULL_DIRECTORY_INFO: + smb2_level = SMB2_FIND_FULL_DIRECTORY_INFO; + break; + case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO: + smb2_level = SMB2_FIND_BOTH_DIRECTORY_INFO; + break; + case RAW_SEARCH_DATA_NAME_INFO: + smb2_level = SMB2_FIND_NAME_INFO; + break; + case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO: + smb2_level = SMB2_FIND_ID_FULL_DIRECTORY_INFO; + break; + case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO: + smb2_level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO; + break; + default: + DEBUG(0,("Unsupported search level %u for smb2 backend\n", + (unsigned)io->generic.data_level)); + return NT_STATUS_INVALID_INFO_CLASS; + } + + /* we do the search on the roothandle. This only works because + search is synchronous, otherwise we'd have no way to + distinguish multiple searches happening at once + */ + ZERO_STRUCT(f); + f.in.file.handle = private->roothandle; + f.in.level = smb2_level; + f.in.pattern = io->t2ffirst.in.pattern; + while (f.in.pattern[0] == '\\') { + f.in.pattern++; + } + f.in.continue_flags = 0; + f.in.max_response_size = 0x10000; + + status = smb2_find_level(private->tree, req, &f, &count, &data); + NT_STATUS_NOT_OK_RETURN(status); + + for (i=0;i<count;i++) { + if (!callback(search_private, &data[i])) break; + } + + io->t2ffirst.out.handle = 0; + io->t2ffirst.out.count = i; + /* TODO: fix end_of_file */ + io->t2ffirst.out.end_of_search = 1; + + talloc_free(data); + + return NT_STATUS_OK; +} + +/* continue a search */ +static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_next *io, + void *search_private, + bool (*callback)(void *, const union smb_search_data *)) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* close a search */ +static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_close *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* SMBtrans - not used on file shares */ +static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + struct smb_trans2 *trans2) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* change notify request - always async */ +static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_notify *io) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/* + initialise the CIFS->CIFS backend, registering ourselves with the ntvfs subsystem + */ +NTSTATUS ntvfs_smb2_init(void) +{ + NTSTATUS ret; + struct ntvfs_ops ops; + NTVFS_CURRENT_CRITICAL_SIZES(vers); + + ZERO_STRUCT(ops); + + /* fill in the name and type */ + ops.name = "smb2"; + ops.type = NTVFS_DISK; + + /* fill in all the operations */ + ops.connect = cvfs_connect; + ops.disconnect = cvfs_disconnect; + ops.unlink = cvfs_unlink; + ops.chkpath = cvfs_chkpath; + ops.qpathinfo = cvfs_qpathinfo; + ops.setpathinfo = cvfs_setpathinfo; + ops.open = cvfs_open; + ops.mkdir = cvfs_mkdir; + ops.rmdir = cvfs_rmdir; + ops.rename = cvfs_rename; + ops.copy = cvfs_copy; + ops.ioctl = cvfs_ioctl; + ops.read = cvfs_read; + ops.write = cvfs_write; + ops.seek = cvfs_seek; + ops.flush = cvfs_flush; + ops.close = cvfs_close; + ops.exit = cvfs_exit; + ops.lock = cvfs_lock; + ops.setfileinfo = cvfs_setfileinfo; + ops.qfileinfo = cvfs_qfileinfo; + ops.fsinfo = cvfs_fsinfo; + ops.lpq = cvfs_lpq; + ops.search_first = cvfs_search_first; + ops.search_next = cvfs_search_next; + ops.search_close = cvfs_search_close; + ops.trans = cvfs_trans; + ops.logoff = cvfs_logoff; + ops.async_setup = cvfs_async_setup; + ops.cancel = cvfs_cancel; + ops.notify = cvfs_notify; + + /* register ourselves with the NTVFS subsystem. We register + under the name 'smb2'. */ + ret = ntvfs_register(&ops, &vers); + + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(0,("Failed to register SMB2 backend\n")); + } + + return ret; +} diff --git a/source4/ntvfs/sysdep/config.mk b/source4/ntvfs/sysdep/config.mk index 68be660049..1122d5c39d 100644 --- a/source4/ntvfs/sysdep/config.mk +++ b/source4/ntvfs/sysdep/config.mk @@ -6,7 +6,7 @@ INIT_FUNCTION = sys_notify_inotify_init # End MODULE sys_notify_inotify ################################################ -sys_notify_inotify_OBJ_FILES = ntvfs/sysdep/inotify.o +sys_notify_inotify_OBJ_FILES = $(ntvfssrcdir)/sysdep/inotify.o ################################################ # Start SUBSYSTEM sys_notify @@ -14,12 +14,12 @@ sys_notify_inotify_OBJ_FILES = ntvfs/sysdep/inotify.o # End SUBSYSTEM sys_notify ################################################ -sys_notify_OBJ_FILES = ntvfs/sysdep/sys_notify.o +sys_notify_OBJ_FILES = $(ntvfssrcdir)/sysdep/sys_notify.o [SUBSYSTEM::sys_lease_linux] -sys_lease_linux_OBJ_FILES = ntvfs/sysdep/sys_lease_linux.o +sys_lease_linux_OBJ_FILES = $(ntvfssrcdir)/sysdep/sys_lease_linux.o [SUBSYSTEM::sys_lease] -sys_lease_OBJ_FILES = ntvfs/sysdep/sys_lease.o +sys_lease_OBJ_FILES = $(ntvfssrcdir)/sysdep/sys_lease.o diff --git a/source4/ntvfs/unixuid/config.mk b/source4/ntvfs/unixuid/config.mk index 968e56bde4..6377657cec 100644 --- a/source4/ntvfs/unixuid/config.mk +++ b/source4/ntvfs/unixuid/config.mk @@ -7,4 +7,4 @@ PRIVATE_DEPENDENCIES = SAMDB NSS_WRAPPER # End MODULE ntvfs_unixuid ################################################ -ntvfs_unixuid_OBJ_FILES = ntvfs/unixuid/vfs_unixuid.o +ntvfs_unixuid_OBJ_FILES = $(ntvfssrcdir)/unixuid/vfs_unixuid.o diff --git a/source4/param/config.mk b/source4/param/config.mk index 4c202dc6de..a25dd32194 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -5,35 +5,28 @@ PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET LIBSAMBA-HOSTCONFIG_VERSION = 0.0.1 LIBSAMBA-HOSTCONFIG_SOVERSION = 0 -LIBSAMBA-HOSTCONFIG_OBJ_FILES = param/loadparm.o \ - param/generic.o \ - param/util.o \ - lib/version.o - -LIBSAMBA-CONFIG_OBJ_FILES = param/loadparm.o \ - param/params.o \ - param/generic.o \ - param/util.o \ - lib/version.o +LIBSAMBA-HOSTCONFIG_OBJ_FILES = $(addprefix $(paramsrcdir)/, \ + loadparm.o generic.o util.o) lib/version.o PUBLIC_HEADERS += param/param.h -PC_FILES += param/samba-hostconfig.pc +PC_FILES += $(paramsrcdir)/samba-hostconfig.pc [SUBSYSTEM::PROVISION] PRIVATE_DEPENDENCIES = LIBPYTHON -PROVISION_OBJ_FILES = param/provision.o +PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o ################################# # Start SUBSYSTEM share [SUBSYSTEM::share] -PRIVATE_PROTO_HEADER = share_proto.h PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL # End SUBSYSTEM share ################################# -share_OBJ_FILES = param/share.o +share_OBJ_FILES = $(paramsrcdir)/share.o + +$(eval $(call proto_header_template,$(paramsrcdir)/share_proto.h,$(share_OBJ_FILES:.o=.c))) PUBLIC_HEADERS += param/share.h @@ -46,7 +39,7 @@ PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL # End MODULE share_classic ################################################ -share_classic_OBJ_FILES = param/share_classic.o +share_classic_OBJ_FILES = $(paramsrcdir)/share_classic.o ################################################ # Start MODULE share_ldb @@ -57,15 +50,15 @@ PRIVATE_DEPENDENCIES = LIBLDB LDB_WRAP # End MODULE share_ldb ################################################ -share_ldb_OBJ_FILES = param/share_ldb.o +share_ldb_OBJ_FILES = $(paramsrcdir)/share_ldb.o [SUBSYSTEM::SECRETS] PRIVATE_DEPENDENCIES = LIBLDB TDB_WRAP UTIL_TDB NDR_SECURITY -SECRETS_OBJ_FILES = param/secrets.o +SECRETS_OBJ_FILES = $(paramsrcdir)/secrets.o [PYTHON::param] SWIG_FILE = param.i PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG -param_OBJ_FILES = param/param_wrap.o +param_OBJ_FILES = $(paramsrcdir)/param_wrap.o diff --git a/source4/pidl/config.mk b/source4/pidl/config.mk index 19b2d53659..07c8647ecd 100644 --- a/source4/pidl/config.mk +++ b/source4/pidl/config.mk @@ -1,11 +1,13 @@ -pidl/Makefile: pidl/Makefile.PL - cd pidl && $(PERL) Makefile.PL PREFIX=$(prefix) +PIDL = $(PERL) $(pidldir)/pidl -pidl-testcov: pidl/Makefile - cd pidl && cover -test +$(pidldir)/Makefile: $(pidldir)/Makefile.PL + cd $(pidldir) && $(PERL) Makefile.PL PREFIX=$(prefix) -installpidl:: pidl/Makefile - $(MAKE) -C pidl install_vendor VENDORPREFIX=$(prefix) \ +pidl-testcov: $(pidldir)/Makefile + cd $(pidldir) && cover -test + +installpidl:: $(pidldir)/Makefile + $(MAKE) -C $(pidldir) install_vendor VENDORPREFIX=$(prefix) \ INSTALLVENDORLIB=$(datarootdir)/perl5 \ INSTALLVENDORBIN=$(bindir) \ INSTALLVENDORSCRIPT=$(bindir) \ @@ -16,27 +18,14 @@ ifeq ($(HAVE_PERL_EXTUTILS_MAKEMAKER),1) install:: installpidl endif -idl_full:: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm - @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL - -idl:: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm - @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL +$(pidldir)/lib/Parse/Pidl/IDL.pm: $(pidldir)/idl.yp + -$(YAPP) -m 'Parse::Pidl::IDL' -o $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/idl.yp ||\ + touch $(pidldir)/lib/Parse/Pidl/IDL.pm -pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp - -$(YAPP) -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\ - touch pidl/lib/Parse/Pidl/IDL.pm - -pidl/lib/Parse/Pidl/Expr.pm: pidl/idl.yp - -$(YAPP) -m 'Parse::Pidl::Expr' -o pidl/lib/Parse/Pidl/Expr.pm pidl/expr.yp ||\ - touch pidl/lib/Parse/Pidl/Expr.pm +$(pidldir)/lib/Parse/Pidl/Expr.pm: $(pidldir)/idl.yp + -$(YAPP) -m 'Parse::Pidl::Expr' -o $(pidldir)/lib/Parse/Pidl/Expr.pm $(pidldir)/expr.yp ||\ + touch $(pidldir)/lib/Parse/Pidl/Expr.pm testcov-html:: pidl-testcov -$(IDL_HEADER_FILES) \ - $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \ - $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \ - $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \ - $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES) \ - $(IDL_NDR_PY_C_FILES) $(IDL_NDR_PY_H_FILES): idl - diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index 974d12c882..6b1813544e 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -3,14 +3,15 @@ ################################################ # Start SUBSYSTEM DCERPC_COMMON [SUBSYSTEM::DCERPC_COMMON] -PRIVATE_PROTO_HEADER = common/proto.h # # End SUBSYSTEM DCERPC_COMMON ################################################ -DCERPC_COMMON_OBJ_FILES = $(addprefix rpc_server/common/, server_info.o share_info.o) +DCERPC_COMMON_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/common/, server_info.o share_info.o) -PUBLIC_HEADERS += rpc_server/common/common.h +$(eval $(call proto_header_template,$(rpc_serversrcdir)/common/proto.h,$(DCERPC_COMMON_OBJ_FILES:.o=.c))) + +PUBLIC_HEADERS += $(rpc_serversrcdir)/common/common.h ################################################ # Start MODULE dcerpc_rpcecho @@ -21,7 +22,7 @@ PRIVATE_DEPENDENCIES = NDR_ECHO # End MODULE dcerpc_rpcecho ################################################ -dcerpc_rpcecho_OBJ_FILES = rpc_server/echo/rpc_echo.o +dcerpc_rpcecho_OBJ_FILES = $(rpc_serversrcdir)/echo/rpc_echo.o ################################################ # Start MODULE dcerpc_epmapper @@ -32,7 +33,7 @@ PRIVATE_DEPENDENCIES = NDR_EPMAPPER # End MODULE dcerpc_epmapper ################################################ -dcerpc_epmapper_OBJ_FILES = rpc_server/epmapper/rpc_epmapper.o +dcerpc_epmapper_OBJ_FILES = $(rpc_serversrcdir)/epmapper/rpc_epmapper.o ################################################ # Start MODULE dcerpc_remote @@ -44,20 +45,22 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_remote ################################################ -dcerpc_remote_OBJ_FILES = rpc_server/remote/dcesrv_remote.o +dcerpc_remote_OBJ_FILES = $(rpc_serversrcdir)/remote/dcesrv_remote.o ################################################ # Start MODULE dcerpc_srvsvc [MODULE::dcerpc_srvsvc] INIT_FUNCTION = dcerpc_server_srvsvc_init -PRIVATE_PROTO_HEADER = srvsvc/proto.h SUBSYSTEM = DCESRV PRIVATE_DEPENDENCIES = \ DCERPC_COMMON NDR_SRVSVC share # End MODULE dcerpc_srvsvc ################################################ -dcerpc_srvsvc_OBJ_FILES = $(addprefix rpc_server/srvsvc/, dcesrv_srvsvc.o srvsvc_ntvfs.o) + +dcerpc_srvsvc_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/srvsvc/, dcesrv_srvsvc.o srvsvc_ntvfs.o) + +$(eval $(call proto_header_template,$(rpc_serversrcdir)/srvsvc/proto.h,$(dcerpc_srvsvc_OBJ_FILES:.o=.c))) ################################################ # Start MODULE dcerpc_wkssvc @@ -69,7 +72,7 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_wkssvc ################################################ -dcerpc_wkssvc_OBJ_FILES = rpc_server/wkssvc/dcesrv_wkssvc.o +dcerpc_wkssvc_OBJ_FILES = $(rpc_serversrcdir)/wkssvc/dcesrv_wkssvc.o ################################################ # Start MODULE dcerpc_unixinfo @@ -85,13 +88,12 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_unixinfo ################################################ -dcerpc_unixinfo_OBJ_FILES = rpc_server/unixinfo/dcesrv_unixinfo.o +dcerpc_unixinfo_OBJ_FILES = $(rpc_serversrcdir)/unixinfo/dcesrv_unixinfo.o ################################################ # Start MODULE dcesrv_samr [MODULE::dcesrv_samr] INIT_FUNCTION = dcerpc_server_samr_init -PRIVATE_PROTO_HEADER = samr/proto.h SUBSYSTEM = DCESRV PRIVATE_DEPENDENCIES = \ SAMDB \ @@ -100,7 +102,9 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcesrv_samr ################################################ -dcesrv_samr_OBJ_FILES = $(addprefix rpc_server/samr/, dcesrv_samr.o samr_password.o) +dcesrv_samr_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/samr/, dcesrv_samr.o samr_password.o) + +$(eval $(call proto_header_template,$(rpc_serversrcdir)/samr/proto.h,$(dcesrv_samr_OBJ_FILES:.o=.c))) ################################################ # Start MODULE dcerpc_winreg @@ -113,7 +117,7 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_winreg ################################################ -dcerpc_winreg_OBJ_FILES = rpc_server/winreg/rpc_winreg.o +dcerpc_winreg_OBJ_FILES = $(rpc_serversrcdir)/winreg/rpc_winreg.o ################################################ # Start MODULE dcerpc_netlogon @@ -128,14 +132,13 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_netlogon ################################################ -dcerpc_netlogon_OBJ_FILES = rpc_server/netlogon/dcerpc_netlogon.o +dcerpc_netlogon_OBJ_FILES = $(rpc_serversrcdir)/netlogon/dcerpc_netlogon.o ################################################ # Start MODULE dcerpc_lsa [MODULE::dcerpc_lsarpc] INIT_FUNCTION = dcerpc_server_lsa_init SUBSYSTEM = DCESRV -PRIVATE_PROTO_HEADER= lsa/proto.h PRIVATE_DEPENDENCIES = \ SAMDB \ DCERPC_COMMON \ @@ -145,7 +148,9 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_lsa ################################################ -dcerpc_lsarpc_OBJ_FILES = $(addprefix rpc_server/lsa/, dcesrv_lsa.o lsa_init.o lsa_lookup.o) +dcerpc_lsarpc_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/lsa/, dcesrv_lsa.o lsa_init.o lsa_lookup.o) + +$(eval $(call proto_header_template,$(rpc_serversrcdir)/lsa/proto.h,$(dcerpc_lsarpc_OBJ_FILES:.o=.c))) ################################################ @@ -162,7 +167,7 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_spoolss ################################################ -dcerpc_spoolss_OBJ_FILES = rpc_server/spoolss/dcesrv_spoolss.o +dcerpc_spoolss_OBJ_FILES = $(rpc_serversrcdir)/spoolss/dcesrv_spoolss.o ################################################ # Start MODULE dcerpc_drsuapi @@ -176,31 +181,32 @@ PRIVATE_DEPENDENCIES = \ # End MODULE dcerpc_drsuapi ################################################ -dcerpc_drsuapi_OBJ_FILES = rpc_server/drsuapi/dcesrv_drsuapi.o +dcerpc_drsuapi_OBJ_FILES = $(rpc_serversrcdir)/drsuapi/dcesrv_drsuapi.o ################################################ # Start SUBSYSTEM dcerpc_server [SUBSYSTEM::dcerpc_server] -PRIVATE_PROTO_HEADER = dcerpc_server_proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_AUTH \ LIBNDR \ dcerpc -dcerpc_server_OBJ_FILES = $(addprefix rpc_server/, \ +dcerpc_server_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/, \ dcerpc_server.o \ dcesrv_auth.o \ dcesrv_mgmt.o \ handles.o) +$(eval $(call proto_header_template,$(rpc_serversrcdir)/dcerpc_server_proto.h,$(dcerpc_server_OBJ_FILES:.o=.c))) + # End SUBSYSTEM DCERPC ################################################ -PUBLIC_HEADERS += rpc_server/dcerpc_server.h +PUBLIC_HEADERS += $(rpc_serversrcdir)/dcerpc_server.h [MODULE::DCESRV] INIT_FUNCTION = server_service_rpc_init SUBSYSTEM = smbd PRIVATE_DEPENDENCIES = dcerpc_server -DCESRV_OBJ_FILES = rpc_server/service_rpc.o +DCESRV_OBJ_FILES = $(rpc_serversrcdir)/service_rpc.o diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema.py index fb9d7b05aa..6dd5b42aff 100755 --- a/source4/scripting/bin/minschema.py +++ b/source4/scripting/bin/minschema.py @@ -4,6 +4,10 @@ # import optparse + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba from samba import getopt as options import sys diff --git a/source4/scripting/bin/rpcclient b/source4/scripting/bin/rpcclient index 34efafdf73..aba4f9ddb3 100755 --- a/source4/scripting/bin/rpcclient +++ b/source4/scripting/bin/rpcclient @@ -1,6 +1,10 @@ #!/usr/bin/python import sys, os, string + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + from cmd import Cmd from optparse import OptionParser from pprint import pprint diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump index 8f56d423d8..d89667233f 100755 --- a/source4/scripting/bin/samba3dump +++ b/source4/scripting/bin/samba3dump @@ -7,7 +7,10 @@ import optparse import os, sys -sys.path.append(os.path.join(os.path.dirname(__file__), "../python")) + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba import samba.samba3 diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index fbbffde42c..de11aba3cc 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -17,8 +17,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -from subunit import SubunitTestRunner import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + +from subunit import SubunitTestRunner from unittest import TestProgram import optparse import os diff --git a/source4/scripting/bin/winreg.py b/source4/scripting/bin/winreg.py index 1e39ee8f78..19d39e56ab 100755 --- a/source4/scripting/bin/winreg.py +++ b/source4/scripting/bin/winreg.py @@ -7,6 +7,10 @@ # import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import winreg import optparse import samba.getopt as options diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk index 896b292e23..c1a1ca1f0f 100644 --- a/source4/scripting/ejs/config.mk +++ b/source4/scripting/ejs/config.mk @@ -1,13 +1,13 @@ [SUBSYSTEM::EJSRPC] -EJSRPC_OBJ_FILES = scripting/ejs/ejsrpc.o +EJSRPC_OBJ_FILES = $(ejsscriptsrcdir)/ejsrpc.o [MODULE::smbcalls_config] OUTPUT_TYPE = MERGED_OBJ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_config -smbcalls_config_OBJ_FILES = scripting/ejs/smbcalls_config.o +smbcalls_config_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_config.o [MODULE::smbcalls_ldb] OUTPUT_TYPE = MERGED_OBJ @@ -15,7 +15,7 @@ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_ldb PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR -smbcalls_ldb_OBJ_FILES = scripting/ejs/smbcalls_ldb.o +smbcalls_ldb_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_ldb.o [MODULE::smbcalls_reg] SUBSYSTEM = smbcalls @@ -23,21 +23,21 @@ OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_reg PRIVATE_DEPENDENCIES = registry SAMDB LIBNDR -smbcalls_reg_OBJ_FILES = scripting/ejs/smbcalls_reg.o +smbcalls_reg_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_reg.o [MODULE::smbcalls_nbt] SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_nbt -smbcalls_nbt_OBJ_FILES = scripting/ejs/smbcalls_nbt.o +smbcalls_nbt_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_nbt.o [MODULE::smbcalls_rand] SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_random -smbcalls_rand_OBJ_FILES = scripting/ejs/smbcalls_rand.o +smbcalls_rand_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_rand.o [MODULE::smbcalls_nss] SUBSYSTEM = smbcalls @@ -45,14 +45,14 @@ OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_nss PRIVATE_DEPENDENCIES = NSS_WRAPPER -smbcalls_nss_OBJ_FILES = scripting/ejs/smbcalls_nss.o +smbcalls_nss_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_nss.o [MODULE::smbcalls_data] SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_datablob -smbcalls_data_OBJ_FILES = scripting/ejs/smbcalls_data.o +smbcalls_data_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_data.o [MODULE::smbcalls_auth] OUTPUT_TYPE = MERGED_OBJ @@ -60,28 +60,27 @@ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_auth PRIVATE_DEPENDENCIES = service_auth -smbcalls_auth_OBJ_FILES = scripting/ejs/smbcalls_auth.o +smbcalls_auth_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_auth.o -smbcalls_auth_OBJ_FILES = scripting/ejs/smbcalls_auth.o +smbcalls_auth_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_auth.o [MODULE::smbcalls_string] SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_string -smbcalls_string_OBJ_FILES = scripting/ejs/smbcalls_string.o +smbcalls_string_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_string.o [MODULE::smbcalls_sys] SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_system -smbcalls_sys_OBJ_FILES = scripting/ejs/smbcalls_sys.o +smbcalls_sys_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_sys.o mkinclude ejsnet/config.mk [SUBSYSTEM::smbcalls] -PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = \ EJS LIBSAMBA-UTIL \ EJSRPC MESSAGING \ @@ -90,7 +89,7 @@ PRIVATE_DEPENDENCIES = \ dcerpc \ NDR_TABLE -smbcalls_OBJ_FILES = $(addprefix scripting/ejs/, \ +smbcalls_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/, \ smbcalls.o \ smbcalls_cli.o \ smbcalls_rpc.o \ @@ -100,6 +99,8 @@ smbcalls_OBJ_FILES = $(addprefix scripting/ejs/, \ mprutil.o \ literal.o) +$(eval $(call proto_header_template,$(ejsscriptsrcdir)/proto.h,$(smbcalls_OBJ_FILES:.o=.c))) + ####################### # Start BINARY SMBSCRIPT [BINARY::smbscript] @@ -107,4 +108,4 @@ PRIVATE_DEPENDENCIES = EJS LIBSAMBA-UTIL smbcalls LIBSAMBA-HOSTCONFIG # End BINARY SMBSCRIPT ####################### -smbscript_OBJ_FILES = scripting/ejs/smbscript.o +smbscript_OBJ_FILES = $(ejsscriptsrcdir)/smbscript.o diff --git a/source4/scripting/ejs/ejsnet/config.mk b/source4/scripting/ejs/ejsnet/config.mk index 85a5b2bf09..710221e37d 100644 --- a/source4/scripting/ejs/ejsnet/config.mk +++ b/source4/scripting/ejs/ejsnet/config.mk @@ -1,13 +1,13 @@ [MODULE::smbcalls_net] SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_net -PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = LIBSAMBA-NET LIBCLI_SMB CREDENTIALS -smbcalls_net_OBJ_FILES = $(addprefix scripting/ejs/ejsnet/, \ +smbcalls_net_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/ejsnet/, \ net_ctx.o \ net_user.o \ mpr_user.o \ net_host.o \ mpr_host.o) +$(eval $(call proto_header_template,$(ejsscriptsrcdir)/ejsnet/proto.h,$(smbcalls_net_OBJ_FILES:.o=.c))) diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index a61d541049..1a86951bfb 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -64,7 +64,6 @@ SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS]) AC_MSG_CHECKING(working python module support) if test $working_python = yes; then SMB_ENABLE(EXT_LIB_PYTHON,YES) - SMB_ENABLE(smbpython,YES) SMB_ENABLE(LIBPYTHON,YES) AC_MSG_RESULT([yes]) else diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index e57ff1d1ac..1fa273e99d 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -1,31 +1,28 @@ -[BINARY::smbpython] -PRIVATE_DEPENDENCIES = LIBPYTHON - -smbpython_OBJ_FILES = scripting/python/smbpython.o - [SUBSYSTEM::LIBPYTHON] PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON PRIVATE_DEPENDENCIES = PYTALLOC INIT_FUNCTION_SENTINEL = { NULL, NULL } -LIBPYTHON_OBJ_FILES = $(addprefix scripting/python/, modules.o) +LIBPYTHON_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, modules.o) [SUBSYSTEM::PYTALLOC] PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON -PYTALLOC_OBJ_FILES = $(addprefix scripting/python/, pytalloc.o) +PYTALLOC_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, pytalloc.o) [PYTHON::python_uuid] PRIVATE_DEPENDENCIES = LIBNDR -python_uuid_OBJ_FILES = scripting/python/uuidmodule.o +python_uuid_OBJ_FILES = $(pyscriptsrcdir)/uuidmodule.o [PYTHON::python_misc] PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS SWIG_FILE = misc.i -python_misc_OBJ_FILES = scripting/python/misc_wrap.o +python_misc_OBJ_FILES = $(pyscriptsrcdir)/misc_wrap.o + +_PY_FILES = $(shell find $(pyscriptsrcdir) -name "*.py") -_PY_FILES = $(shell find scripting/python -name "*.py") +$(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst $(pyscriptsrcdir)/%,%,$(pyfile)),$(pyfile)))) -$(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst scripting/python/%,%,$(pyfile)),$(pyfile)))) +install:: installpython diff --git a/source4/scripting/python/smbpython.c b/source4/scripting/python/smbpython.c deleted file mode 100644 index c5de53fd60..0000000000 --- a/source4/scripting/python/smbpython.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include <Python.h> -#include "scripting/python/modules.h" - -int main(int argc, char **argv) -{ - py_load_samba_modules(); - Py_Initialize(); - if (strchr(argv[0], '/') != NULL) { - char *bindir = strndup(argv[0], strrchr(argv[0], '/')-argv[0]); - py_update_path(bindir); - free(bindir); - } - return Py_Main(argc,argv); -} diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index 9c7e93906c..5a9cdafe3b 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -328,7 +328,7 @@ then plantest "nss.test using winbind" member $VALGRIND $samba4bindir/nsstest $samba4bindir/shared/libnss_winbind.so fi -PYTHON=bin/smbpython +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 diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm index 9488ae3e04..a12939b0a1 100644 --- a/source4/selftest/target/Samba4.pm +++ b/source4/selftest/target/Samba4.pm @@ -705,7 +705,7 @@ nogroup:x:65534:nobody push (@provision_options, "$self->{bindir}/smbscript"); push (@provision_options, "$self->{setupdir}/provision.js"); } else { - push (@provision_options, "$self->{bindir}/smbpython"); +# push (@provision_options, "$self->{bindir}/smbpython"); push (@provision_options, "$self->{setupdir}/provision"); } push (@provision_options, split(' ', $configuration)); diff --git a/source4/setup/newuser b/source4/setup/newuser index 04a5440ee1..26bac76f02 100755 --- a/source4/setup/newuser +++ b/source4/setup/newuser @@ -6,10 +6,14 @@ # Released under the GNU GPL version 3 or later # +import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba.getopt as options import optparse import pwd -import sys from getpass import getpass from auth import system_session from samba.samdb import SamDB diff --git a/source4/setup/provision b/source4/setup/provision index b748dab339..2579bc4f19 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -26,6 +26,9 @@ import getopt import optparse import os, sys +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba import param diff --git a/source4/setup/provision-backend.js b/source4/setup/provision-backend.js deleted file mode 100644 index 9482d8c435..0000000000 --- a/source4/setup/provision-backend.js +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/sh -exec smbscript "$0" ${1+"$@"} -/* - provision a Samba4 server - Copyright Andrew Tridgell 2005 - Released under the GNU GPL version 3 or later -*/ - -options = GetOptions(ARGV, - "POPT_AUTOHELP", - "POPT_COMMON_SAMBA", - "POPT_COMMON_VERSION", - "POPT_COMMON_CREDENTIALS", - 'realm=s', - 'host-name=s', - 'ldap-manager-pass=s', - 'root=s', - 'quiet', - 'ldap-backend-type=s', - 'ldap-backend-port=i'); - -if (options == undefined) { - println("Failed to parse options"); - return -1; -} - -sys = sys_init(); - -libinclude("base.js"); -libinclude("provision.js"); - -/* - print a message if quiet is not set -*/ -function message() -{ - if (options["quiet"] == undefined) { - print(vsprintf(arguments)); - } -} - -/* - show some help -*/ -function ShowHelp() -{ - print(" -Samba4 provisioning - -provision [options] - --realm REALM set realm - --host-name HOSTNAME set hostname - --ldap-manager-pass PASSWORD choose LDAP Manager password (otherwise random) - --root USERNAME choose 'root' unix username - --quiet Be quiet - --ldap-backend-type LDAPSERVER Select either \"openldap\" or \"fedora-ds\" as a target to configure - --ldap-backend-port PORT Select the TCP port (if any) that the LDAP backend should listen on (Fedora DS only) -You must provide at least a realm and ldap-backend-type - -"); - exit(1); -} - -if (options['host-name'] == undefined) { - options['host-name'] = hostname(); -} - -/* - main program -*/ -if (options["realm"] == undefined || - options["ldap-backend-type"] == undefined || - options["host-name"] == undefined) { - ShowHelp(); -} - -/* cope with an initially blank smb.conf */ -var lp = loadparm_init(); -lp.set("realm", options.realm); -lp.reload(); - -var subobj = provision_guess(); -for (r in options) { - var key = strupper(join("", split("-", r))); - subobj[key] = options[r]; -} - - - -var paths = provision_default_paths(subobj); -provision_fix_subobj(subobj, paths); -message("Provisioning LDAP backend for %s in realm %s into %s\n", subobj.HOSTNAME, subobj.REALM, subobj.LDAPDIR); -message("Using %s password: %s\n", subobj.LDAPMANAGERDN, subobj.LDAPMANAGERPASS); -var tmp_schema_ldb = subobj.LDAPDIR + "/schema-tmp.ldb"; -sys.mkdir(subobj.LDAPDIR, 0700); - -provision_schema(subobj, message, tmp_schema_ldb, paths); - -var mapping; -var backend_schema; -var slapd_command; -if (options["ldap-backend-type"] == "fedora-ds") { - mapping = "schema-map-fedora-ds-1.0"; - backend_schema = "99_ad.ldif"; - if (options["ldap-backend-port"] != undefined) { - message("Will listen on TCP port " + options["ldap-backend-port"] + "\n"); - subobj.SERVERPORT="ServerPort = " + options["ldap-backend-port"]; - } else { - message("Will listen on LDAPI only\n"); - subobj.SERVERPORT=""; - } - setup_file("fedorads.inf", message, subobj.LDAPDIR + "/fedorads.inf", subobj); - setup_file("fedorads-partitions.ldif", message, subobj.LDAPDIR + "/fedorads-partitions.ldif", subobj); - - slapd_command = "(see documentation)"; -} else if (options["ldap-backend-type"] == "openldap") { - mapping = "schema-map-openldap-2.3"; - backend_schema = "backend-schema.schema"; - setup_file("slapd.conf", message, subobj.LDAPDIR + "/slapd.conf", subobj); - setup_file("modules.conf", message, subobj.LDAPDIR + "/modules.conf", subobj); - sys.mkdir(subobj.LDAPDIR + "/db", 0700); - subobj.LDAPDBDIR = subobj.LDAPDIR + "/db/user"; - sys.mkdir(subobj.LDAPDBDIR, 0700); - sys.mkdir(subobj.LDAPDBDIR + "/bdb-logs", 0700); - sys.mkdir(subobj.LDAPDBDIR + "/tmp", 0700); - setup_file("DB_CONFIG", message, subobj.LDAPDBDIR + "/DB_CONFIG", subobj); - subobj.LDAPDBDIR = subobj.LDAPDIR + "/db/config"; - sys.mkdir(subobj.LDAPDBDIR, 0700); - sys.mkdir(subobj.LDAPDBDIR + "/bdb-logs", 0700); - sys.mkdir(subobj.LDAPDBDIR + "/tmp", 0700); - setup_file("DB_CONFIG", message, subobj.LDAPDBDIR + "/DB_CONFIG", subobj); - subobj.LDAPDBDIR = subobj.LDAPDIR + "/db/schema"; - sys.mkdir(subobj.LDAPDBDIR, 0700); - sys.mkdir(subobj.LDAPDBDIR + "/tmp", 0700); - sys.mkdir(subobj.LDAPDBDIR + "/bdb-logs", 0700); - setup_file("DB_CONFIG", message, subobj.LDAPDBDIR + "/DB_CONFIG", subobj); - if (options["ldap-backend-port"] != undefined) { - message("\nStart slapd with: \n"); - slapd_command = "slapd -f " + subobj.LDAPDIR + "/slapd.conf -h \"ldap://0.0.0.0:" + options["ldap-backend-port"] + " " + subobj.LDAPI_URI "\""; - } else { - slapd_command = "slapd -f " + subobj.LDAPDIR + "/slapd.conf -h " + subobj.LDAPI_URI; - } - - var ldb = ldb_init(); - ldb.filename = tmp_schema_ldb; - - var connect_ok = ldb.connect(ldb.filename); - assert(connect_ok); - var attrs = new Array("linkID", "lDAPDisplayName"); - var res = ldb.search("(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", subobj.SCHEMADN, ldb.SCOPE_SUBTREE, attrs); - assert(res.error == 0); - var memberof_config = ""; - var refint_attributes = ""; - for (i=0; i < res.msgs.length; i++) { - var target = searchone(ldb, subobj.SCHEMADN, "(&(objectclass=attributeSchema)(linkID=" + (res.msgs[i].linkID + 1) + "))", "lDAPDisplayName"); - if (target != undefined) { - refint_attributes = refint_attributes + " " + target + " " + res.msgs[i].lDAPDisplayName; - memberof_config = memberof_config + "overlay memberof -memberof-dangling error -memberof-refint TRUE -memberof-group-oc top -memberof-member-ad " + res.msgs[i].lDAPDisplayName + " -memberof-memberof-ad " + target + " -memberof-dangling-error 32 - -"; - } - } - - memberof_config = memberof_config + " -overlay refint -refint_attributes" + refint_attributes + " -"; - - ok = sys.file_save(subobj.LDAPDIR + "/memberof.conf", memberof_config); - if (!ok) { - message("failed to create file: " + f + "\n"); - assert(ok); - } - -} -var schema_command = "ad2oLschema --option=convert:target=" + options["ldap-backend-type"] + " -I " + lp.get("setup directory") + "/" + mapping + " -H tdb://" + tmp_schema_ldb + " -O " + subobj.LDAPDIR + "/" + backend_schema; - -message("\nCreate a suitable schema file with:\n%s\n", schema_command); -message("\nStart slapd with: \n%s\n", slapd_command); - -message("All OK\n"); -return 0; diff --git a/source4/setup/upgrade b/source4/setup/upgrade index 3bcc57ab64..b1d9ffa37c 100755 --- a/source4/setup/upgrade +++ b/source4/setup/upgrade @@ -7,6 +7,10 @@ import getopt import optparse import os, sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import param import samba import samba.getopt as options diff --git a/source4/smb_server/config.mk b/source4/smb_server/config.mk index 1e3da1fab6..e11968a100 100644 --- a/source4/smb_server/config.mk +++ b/source4/smb_server/config.mk @@ -3,15 +3,15 @@ [MODULE::SERVICE_SMB] INIT_FUNCTION = server_service_smb_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = service_smb_proto.h PRIVATE_DEPENDENCIES = SMB_SERVER -SERVICE_SMB_OBJ_FILES = smb_server/smb_server.o +SERVICE_SMB_OBJ_FILES = $(smb_serversrcdir)/smb_server.o + +$(eval $(call proto_header_template,$(smb_serversrcdir)/service_smb_proto.h,$(SERVICE_SMB_OBJ_FILES:.o=.c))) ####################### # Start SUBSYSTEM SMB [SUBSYSTEM::SMB_SERVER] -PRIVATE_PROTO_HEADER = smb_server_proto.h PUBLIC_DEPENDENCIES = \ share \ LIBPACKET \ @@ -20,12 +20,14 @@ PUBLIC_DEPENDENCIES = \ # End SUBSYSTEM SMB ####################### -SMB_SERVER_OBJ_FILES = $(addprefix smb_server/, \ +SMB_SERVER_OBJ_FILES = $(addprefix $(smb_serversrcdir)/, \ handle.o \ tcon.o \ session.o \ blob.o \ management.o) +$(eval $(call proto_header_template,$(smb_serversrcdir)/smb_server_proto.h,$(SMB_SERVER_OBJ_FILES:.o=.c))) + mkinclude smb/config.mk mkinclude smb2/config.mk diff --git a/source4/smb_server/smb/config.mk b/source4/smb_server/smb/config.mk index 3d4aa8ba38..9adf334850 100644 --- a/source4/smb_server/smb/config.mk +++ b/source4/smb_server/smb/config.mk @@ -1,13 +1,12 @@ ####################### # Start SUBSYSTEM SMB_PROTOCOL [SUBSYSTEM::SMB_PROTOCOL] -PRIVATE_PROTO_HEADER = smb_proto.h PUBLIC_DEPENDENCIES = \ ntvfs LIBPACKET CREDENTIALS # End SUBSYSTEM SMB_PROTOCOL ####################### -SMB_PROTOCOL_OBJ_FILES = $(addprefix smb_server/smb/, \ +SMB_PROTOCOL_OBJ_FILES = $(addprefix $(smb_serversrcdir)/smb/, \ receive.o \ negprot.o \ nttrans.o \ @@ -20,3 +19,4 @@ SMB_PROTOCOL_OBJ_FILES = $(addprefix smb_server/smb/, \ trans2.o \ signing.o) +$(eval $(call proto_header_template,$(smb_serversrcdir)/smb/smb_proto.h,$(SMB_PROTOCOL_OBJ_FILES:.o=.c))) diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 6cf33cf7c3..0afa3a652d 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -508,7 +508,8 @@ static void switch_message(int type, struct smbsrv_request *req) } } - DEBUG(5,("switch message %s (task_id %d)\n",smb_fn_name(type), req->smb_conn->connection->server_id.id)); + DEBUG(5,("switch message %s (task_id %u)\n", + smb_fn_name(type), (unsigned)req->smb_conn->connection->server_id.id)); /* this must be called before we do any reply */ if (flags & SIGNING_NO_REPLY) { diff --git a/source4/smb_server/smb2/config.mk b/source4/smb_server/smb2/config.mk index c9ba3269fa..68ee6e58f6 100644 --- a/source4/smb_server/smb2/config.mk +++ b/source4/smb_server/smb2/config.mk @@ -1,13 +1,12 @@ ####################### # Start SUBSYSTEM SMB2_PROTOCOL [SUBSYSTEM::SMB2_PROTOCOL] -PRIVATE_PROTO_HEADER = smb2_proto.h PUBLIC_DEPENDENCIES = \ ntvfs LIBPACKET LIBCLI_SMB2 # End SUBSYSTEM SMB2_PROTOCOL ####################### -SMB2_PROTOCOL_OBJ_FILES = $(addprefix smb_server/smb2/, \ +SMB2_PROTOCOL_OBJ_FILES = $(addprefix $(smb_serversrcdir)/smb2/, \ receive.o \ negprot.o \ sesssetup.o \ @@ -17,3 +16,4 @@ SMB2_PROTOCOL_OBJ_FILES = $(addprefix smb_server/smb2/, \ find.o \ keepalive.o) +$(eval $(call proto_header_template,$(smb_serversrcdir)/smb2/smb2_proto.h,$(SMB2_PROTOCOL_OBJ_FILES:.o=.c))) diff --git a/source4/smb_server/smb2/find.c b/source4/smb_server/smb2/find.c index 6018f1958f..32b280c5c2 100644 --- a/source4/smb_server/smb2/find.c +++ b/source4/smb_server/smb2/find.c @@ -112,7 +112,7 @@ static NTSTATUS smb2srv_find_backend(struct smb2srv_find_state *state) return NT_STATUS_FOOBAR; } - if (info->in.continue_flags & SMB2_CONTINUE_FLAG_NEW) { + if (info->in.continue_flags & SMB2_CONTINUE_FLAG_REOPEN) { state->ff = talloc(state, union smb_search_first); NT_STATUS_HAVE_NO_MEMORY(state->ff); @@ -156,7 +156,7 @@ void smb2srv_find_recv(struct smb2srv_request *req) info->data_level = RAW_SEARCH_DATA_GENERIC;/* will be overwritten later */ info->in.level = CVAL(req->in.body, 0x02); info->in.continue_flags = CVAL(req->in.body, 0x03); - info->in.unknown = IVAL(req->in.body, 0x04); + info->in.file_index = IVAL(req->in.body, 0x04); info->in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08); SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, info, req->in.body+0x18, &info->in.pattern)); info->in.max_response_size = IVAL(req->in.body, 0x1C); diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk index 006135f818..e60f444456 100644 --- a/source4/smbd/config.mk +++ b/source4/smbd/config.mk @@ -1,19 +1,21 @@ # server subsystem [SUBSYSTEM::service] -PRIVATE_PROTO_HEADER = service_proto.h PRIVATE_DEPENDENCIES = \ MESSAGING samba-socket -service_OBJ_FILES = $(addprefix smbd/, \ +service_OBJ_FILES = $(addprefix $(smbdsrcdir)/, \ service.o \ service_stream.o \ service_task.o) +$(eval $(call proto_header_template,$(smbdsrcdir)/service_proto.h,$(service_OBJ_FILES:.o=.c))) + [SUBSYSTEM::PIDFILE] -PRIVATE_PROTO_HEADER = pidfile.h -PIDFILE_OBJ_FILES = smbd/pidfile.o +PIDFILE_OBJ_FILES = $(smbdsrcdir)/pidfile.o + +$(eval $(call proto_header_template,$(smbdsrcdir)/pidfile.h,$(PIDFILE_OBJ_FILES:.o=.c))) ################################# # Start BINARY smbd @@ -34,8 +36,8 @@ PRIVATE_DEPENDENCIES = \ share \ CLUSTER -smbd_OBJ_FILES = smbd/server.o +smbd_OBJ_FILES = $(smbdsrcdir)/server.o -MANPAGES += smbd/smbd.8 +MANPAGES += $(smbdsrcdir)/smbd.8 # End BINARY smbd ################################# diff --git a/source4/smbd/process_model.mk b/source4/smbd/process_model.mk index 48899078f7..5ed8471a9d 100644 --- a/source4/smbd/process_model.mk +++ b/source4/smbd/process_model.mk @@ -8,7 +8,7 @@ SUBSYSTEM = process_model # End MODULE process_model_single ################################################ -process_model_single_OBJ_FILES = smbd/process_single.o +process_model_single_OBJ_FILES = $(smbdsrcdir)/process_single.o ################################################ # Start MODULE process_model_standard @@ -19,7 +19,7 @@ PRIVATE_DEPENDENCIES = SETPROCTITLE # End MODULE process_model_standard ################################################ -process_model_standard_OBJ_FILES = smbd/process_standard.o +process_model_standard_OBJ_FILES = $(smbdsrcdir)/process_standard.o ################################################ # Start MODULE process_model_thread @@ -30,7 +30,7 @@ PRIVATE_DEPENDENCIES = PTHREAD # End MODULE process_model_thread ################################################ -process_model_thread_OBJ_FILES = smbd/process_thread.o +process_model_thread_OBJ_FILES = $(smbdsrcdir)/process_thread.o ################################################ # Start MODULE process_model_prefork @@ -40,10 +40,11 @@ SUBSYSTEM = process_model # End MODULE process_model_thread ################################################ -process_model_prefork_OBJ_FILES = smbd/process_prefork.o +process_model_prefork_OBJ_FILES = $(smbdsrcdir)/process_prefork.o [SUBSYSTEM::process_model] -PRIVATE_PROTO_HEADER = process_model_proto.h PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG -process_model_OBJ_FILES = smbd/process_model.o +process_model_OBJ_FILES = $(smbdsrcdir)/process_model.o + +$(eval $(call proto_header_template,$(smbdsrcdir)/process_model_proto.h,$(process_model_OBJ_FILES:.o=.c))) diff --git a/source4/static_deps.mk b/source4/static_deps.mk index a442b01025..7eb8fa10fe 100644 --- a/source4/static_deps.mk +++ b/source4/static_deps.mk @@ -38,8 +38,5 @@ heimdal_basics: \ heimdal/lib/hx509/hx509_err.h \ heimdal/lib/wind/wind_err.h -proto: basics -basics: include/includes.h \ - idl \ - $(PROTO_HEADERS) \ - heimdal_basics +proto:: +basics:: include/includes.h idl proto heimdal_basics diff --git a/source4/torture/config.mk b/source4/torture/config.mk index ee9f8b71b5..2857b99582 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -2,15 +2,13 @@ PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls PROVISION PUBLIC_DEPENDENCIES = POPT_CREDENTIALS -TORTURE_UTIL_OBJ_FILES = $(addprefix torture/, util_smb.o) +TORTURE_UTIL_OBJ_FILES = $(addprefix $(torturesrcdir)/, util_smb.o) ################################# # Start SUBSYSTEM TORTURE_BASIC [MODULE::TORTURE_BASIC] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_base_init -PRIVATE_PROTO_HEADER = \ - basic/proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_SMB POPT_CREDENTIALS \ TORTURE_UTIL LIBCLI_RAW \ @@ -18,7 +16,7 @@ PRIVATE_DEPENDENCIES = \ # End SUBSYSTEM TORTURE_BASIC ################################# -TORTURE_BASIC_OBJ_FILES = $(addprefix torture/basic/, \ +TORTURE_BASIC_OBJ_FILES = $(addprefix $(torturesrcdir)/basic/, \ base.o \ misc.o \ scanner.o \ @@ -38,21 +36,20 @@ TORTURE_BASIC_OBJ_FILES = $(addprefix torture/basic/, \ attr.o \ properties.o) +$(eval $(call proto_header_template,$(torturesrcdir)/basic/proto.h,$(TORTURE_BASIC_OBJ_FILES:.o=.c))) ################################# # Start SUBSYSTEM TORTURE_RAW [MODULE::TORTURE_RAW] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_raw_init -PRIVATE_PROTO_HEADER = \ - raw/proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_SMB LIBCLI_LSA LIBCLI_SMB_COMPOSITE \ POPT_CREDENTIALS TORTURE_UTIL # End SUBSYSTEM TORTURE_RAW ################################# -TORTURE_RAW_OBJ_FILES = $(addprefix torture/raw/, \ +TORTURE_RAW_OBJ_FILES = $(addprefix $(torturesrcdir)/raw/, \ qfsinfo.o \ qfileinfo.o \ setfileinfo.o \ @@ -73,6 +70,7 @@ TORTURE_RAW_OBJ_FILES = $(addprefix torture/raw/, \ pingpong.o \ lockbench.o \ lookuprate.o \ + tconrate.o \ openbench.o \ rename.o \ eas.o \ @@ -85,22 +83,22 @@ TORTURE_RAW_OBJ_FILES = $(addprefix torture/raw/, \ raw.o \ offline.o) +$(eval $(call proto_header_template,$(torturesrcdir)/raw/proto.h,$(TORTURE_RAW_OBJ_FILES:.o=.c))) mkinclude smb2/config.mk mkinclude winbind/config.mk [SUBSYSTEM::TORTURE_NDR] -PRIVATE_PROTO_HEADER = ndr/proto.h -TORTURE_NDR_OBJ_FILES = $(addprefix torture/ndr/, ndr.o winreg.o atsvc.o lsa.o epmap.o dfs.o netlogon.o drsuapi.o spoolss.o samr.o) +TORTURE_NDR_OBJ_FILES = $(addprefix $(torturesrcdir)/ndr/, ndr.o winreg.o atsvc.o lsa.o epmap.o dfs.o netlogon.o drsuapi.o spoolss.o samr.o) + +$(eval $(call proto_header_template,$(torturesrcdir)/ndr/proto.h,$(TORTURE_NDR_OBJ_FILES:.o=.c))) [MODULE::torture_rpc] # TORTURE_NET and TORTURE_NBT use functions from torture_rpc... #OUTPUT_TYPE = MERGED_OBJ SUBSYSTEM = smbtorture INIT_FUNCTION = torture_rpc_init -PRIVATE_PROTO_HEADER = \ - rpc/proto.h PRIVATE_DEPENDENCIES = \ NDR_TABLE RPC_NDR_UNIXINFO dcerpc_samr RPC_NDR_WINREG RPC_NDR_INITSHUTDOWN \ RPC_NDR_OXIDRESOLVER RPC_NDR_EVENTLOG RPC_NDR_ECHO RPC_NDR_SVCCTL \ @@ -111,7 +109,7 @@ PRIVATE_DEPENDENCIES = \ LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \ dcerpc_server service process_model ntvfs SERVICE_SMB -torture_rpc_OBJ_FILES = $(addprefix torture/rpc/, \ +torture_rpc_OBJ_FILES = $(addprefix $(torturesrcdir)/rpc/, \ join.o lsa.o lsa_lookup.o session_key.o echo.o dfs.o drsuapi.o \ drsuapi_cracknames.o dssync.o spoolss.o spoolss_notify.o spoolss_win.o \ unixinfo.o samr.o samr_accessmask.o wkssvc.o srvsvc.o svcctl.o atsvc.o \ @@ -120,32 +118,34 @@ torture_rpc_OBJ_FILES = $(addprefix torture/rpc/, \ samsync.o bind.o dssetup.o alter_context.o bench.o samba3rpc.o rpc.o async_bind.o \ handles.o frsapi.o) +$(eval $(call proto_header_template,$(torturesrcdir)/rpc/proto.h,$(torture_rpc_OBJ_FILES:.o=.c))) + ################################# # Start SUBSYSTEM TORTURE_RAP [MODULE::TORTURE_RAP] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_rap_init -PRIVATE_PROTO_HEADER = \ - rap/proto.h PRIVATE_DEPENDENCIES = TORTURE_UTIL LIBCLI_SMB # End SUBSYSTEM TORTURE_RAP ################################# -TORTURE_RAP_OBJ_FILES = torture/rap/rap.o +TORTURE_RAP_OBJ_FILES = $(torturesrcdir)/rap/rap.o + +$(eval $(call proto_header_template,$(torturesrcdir)/rap/proto.h,$(TORTURE_RAP_OBJ_FILES:.o=.c))) ################################# # Start SUBSYSTEM TORTURE_AUTH [MODULE::TORTURE_AUTH] SUBSYSTEM = smbtorture -PRIVATE_PROTO_HEADER = \ - auth/proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_SMB gensec auth KERBEROS \ POPT_CREDENTIALS SMBPASSWD # End SUBSYSTEM TORTURE_AUTH ################################# -TORTURE_AUTH_OBJ_FILES = $(addprefix torture/auth/, ntlmssp.o pac.o) +TORTURE_AUTH_OBJ_FILES = $(addprefix $(torturesrcdir)/auth/, ntlmssp.o pac.o) + +$(eval $(call proto_header_template,$(torturesrcdir)/auth/proto.h,$(TORTURE_AUTH_OBJ_FILES:.o=.c))) mkinclude local/config.mk @@ -155,12 +155,12 @@ mkinclude local/config.mk SUBSYSTEM = smbtorture INIT_FUNCTION = torture_nbench_init PRIVATE_DEPENDENCIES = TORTURE_UTIL -PRIVATE_PROTO_HEADER = \ - nbench/proto.h # End MODULE TORTURE_NBENCH ################################# -TORTURE_NBENCH_OBJ_FILES = $(addprefix torture/nbench/, nbio.o nbench.o) +TORTURE_NBENCH_OBJ_FILES = $(addprefix $(torturesrcdir)/nbench/, nbio.o nbench.o) + +$(eval $(call proto_header_template,$(torturesrcdir)/nbench/proto.h,$(TORTURE_NBENCH_OBJ_FILES:.o=.c))) ################################# # Start MODULE TORTURE_UNIX @@ -168,51 +168,47 @@ TORTURE_NBENCH_OBJ_FILES = $(addprefix torture/nbench/, nbio.o nbench.o) SUBSYSTEM = smbtorture INIT_FUNCTION = torture_unix_init PRIVATE_DEPENDENCIES = TORTURE_UTIL -PRIVATE_PROTO_HEADER = \ - unix/proto.h # End MODULE TORTURE_UNIX ################################# -TORTURE_UNIX_OBJ_FILES = $(addprefix torture/unix/, unix.o whoami.o unix_info2.o) +TORTURE_UNIX_OBJ_FILES = $(addprefix $(torturesrcdir)/unix/, unix.o whoami.o unix_info2.o) + +$(eval $(call proto_header_template,$(torturesrcdir)/unix/proto.h,$(TORTURE_UNIX_OBJ_FILES:.o=.c))) ################################# # Start SUBSYSTEM TORTURE_LDAP [MODULE::TORTURE_LDAP] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_ldap_init -PRIVATE_PROTO_HEADER = \ - ldap/proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_LDAP LIBCLI_CLDAP SAMDB POPT_CREDENTIALS # End SUBSYSTEM TORTURE_LDAP ################################# -TORTURE_LDAP_OBJ_FILES = $(addprefix torture/ldap/, common.o basic.o schema.o uptodatevector.o cldap.o cldapbench.o) +TORTURE_LDAP_OBJ_FILES = $(addprefix $(torturesrcdir)/ldap/, common.o basic.o schema.o uptodatevector.o cldap.o cldapbench.o) +$(eval $(call proto_header_template,$(torturesrcdir)/ldap/proto.h,$(TORTURE_LDAP_OBJ_FILES:.o=.c))) ################################# # Start SUBSYSTEM TORTURE_NBT [MODULE::TORTURE_NBT] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_nbt_init -PRIVATE_PROTO_HEADER = \ - nbt/proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_SMB LIBCLI_NBT LIBCLI_DGRAM LIBCLI_WREPL torture_rpc # End SUBSYSTEM TORTURE_NBT ################################# -TORTURE_NBT_OBJ_FILES = $(addprefix torture/nbt/, query.o register.o \ +TORTURE_NBT_OBJ_FILES = $(addprefix $(torturesrcdir)/nbt/, query.o register.o \ wins.o winsbench.o winsreplication.o dgram.o nbt.o) +$(eval $(call proto_header_template,$(torturesrcdir)/nbt/proto.h,$(TORTURE_NBT_OBJ_FILES:.o=.c))) ################################# # Start SUBSYSTEM TORTURE_NET [MODULE::TORTURE_NET] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_net_init -PRIVATE_PROTO_HEADER = \ - libnet/proto.h PRIVATE_DEPENDENCIES = \ LIBSAMBA-NET \ POPT_CREDENTIALS \ @@ -220,11 +216,12 @@ PRIVATE_DEPENDENCIES = \ # End SUBSYSTEM TORTURE_NET ################################# -TORTURE_NET_OBJ_FILES = $(addprefix torture/libnet/, libnet.o \ +TORTURE_NET_OBJ_FILES = $(addprefix $(torturesrcdir)/libnet/, libnet.o \ utils.o userinfo.o userman.o groupinfo.o groupman.o \ domain.o libnet_lookup.o libnet_user.o libnet_group.o \ libnet_share.o libnet_rpc.o libnet_domain.o libnet_BecomeDC.o) +$(eval $(call proto_header_template,$(torturesrcdir)/libnet/proto.h,$(TORTURE_NET_OBJ_FILES:.o=.c))) ################################# # Start BINARY smbtorture @@ -241,10 +238,10 @@ PRIVATE_DEPENDENCIES = \ # End BINARY smbtorture ################################# -smbtorture_OBJ_FILES = torture/smbtorture.o torture/torture.o +smbtorture_OBJ_FILES = $(torturesrcdir)/smbtorture.o $(torturesrcdir)/torture.o -PUBLIC_HEADERS += torture/smbtorture.h -MANPAGES += torture/man/smbtorture.1 +PUBLIC_HEADERS += $(torturesrcdir)/smbtorture.h +MANPAGES += $(torturesrcdir)/man/smbtorture.1 ################################# # Start BINARY gentest @@ -261,9 +258,26 @@ PRIVATE_DEPENDENCIES = \ # End BINARY gentest ################################# -gentest_OBJ_FILES = torture/gentest.o +gentest_OBJ_FILES = $(torturesrcdir)/gentest.o + +MANPAGES += $(torturesrcdir)/man/gentest.1 + +################################# +# Start BINARY gentest_smb2 +[BINARY::gentest_smb2] +INSTALLDIR = BINDIR +PRIVATE_DEPENDENCIES = \ + LIBSAMBA-HOSTCONFIG \ + LIBSAMBA-UTIL \ + LIBPOPT \ + POPT_SAMBA \ + POPT_CREDENTIALS \ + LIBCLI_SMB \ + LIBCLI_RAW +# End BINARY gentest_smb2 +################################# -MANPAGES += torture/man/gentest.1 +gentest_smb2_OBJ_FILES = $(torturesrcdir)/gentest_smb2.o ################################# # Start BINARY masktest @@ -279,9 +293,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY masktest ################################# -masktest_OBJ_FILES = torture/masktest.o +masktest_OBJ_FILES = $(torturesrcdir)/masktest.o -MANPAGES += torture/man/masktest.1 +MANPAGES += $(torturesrcdir)/man/masktest.1 ################################# # Start BINARY locktest @@ -297,9 +311,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY locktest ################################# -locktest_OBJ_FILES = torture/locktest.o +locktest_OBJ_FILES = $(torturesrcdir)/locktest.o -MANPAGES += torture/man/locktest.1 +MANPAGES += $(torturesrcdir)/man/locktest.1 GCOV=0 diff --git a/source4/torture/gentest_smb2.c b/source4/torture/gentest_smb2.c new file mode 100644 index 0000000000..9c4be90b3c --- /dev/null +++ b/source4/torture/gentest_smb2.c @@ -0,0 +1,1952 @@ +/* + Unix SMB/CIFS implementation. + + generic testing tool - version with SMB2 support + + Copyright (C) Andrew Tridgell 2003-2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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 "lib/cmdline/popt_common.h" +#include "lib/events/events.h" +#include "system/time.h" +#include "system/filesys.h" +#include "libcli/raw/request.h" +#include "libcli/libcli.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" +#include "librpc/gen_ndr/security.h" +#include "auth/credentials/credentials.h" +#include "libcli/resolve/resolve.h" +#include "auth/gensec/gensec.h" +#include "param/param.h" +#include "dynconfig.h" + +#define NSERVERS 2 +#define NINSTANCES 2 + +/* global options */ +static struct gentest_options { + int showall; + int analyze; + int analyze_always; + int analyze_continuous; + uint_t max_open_handles; + uint_t seed; + uint_t numops; + int use_oplocks; + char **ignore_patterns; + const char *seeds_file; + int use_preset_seeds; + int fast_reconnect; +} options; + +/* mapping between open handles on the server and local handles */ +static struct { + bool active; + uint_t instance; + struct smb2_handle server_handle[NSERVERS]; + const char *name; +} *open_handles; +static uint_t num_open_handles; + +/* state information for the servers. We open NINSTANCES connections to + each server */ +static struct { + struct smb2_tree *tree[NINSTANCES]; + char *server_name; + char *share_name; + struct cli_credentials *credentials; +} servers[NSERVERS]; + +/* the seeds and flags for each operation */ +static struct { + uint_t seed; + bool disabled; +} *op_parms; + + +/* oplock break info */ +static struct { + bool got_break; + struct smb2_handle server_handle; + uint16_t handle; + uint8_t level; + bool do_close; +} oplocks[NSERVERS][NINSTANCES]; + +/* change notify reply info */ +static struct { + int notify_count; + NTSTATUS status; + union smb_notify notify; +} notifies[NSERVERS][NINSTANCES]; + +/* info relevant to the current operation */ +static struct { + const char *name; + uint_t seed; + NTSTATUS status; + uint_t opnum; + TALLOC_CTX *mem_ctx; +} current_op; + +static struct smb2_handle bad_smb2_handle; + + +#define BAD_HANDLE 0xFFFE + +static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private); +static void idle_func(struct smb2_transport *transport, void *private); + +/* + check if a string should be ignored. This is used as the basis + for all error ignore settings +*/ +static bool ignore_pattern(const char *str) +{ + int i; + if (!options.ignore_patterns) return false; + + for (i=0;options.ignore_patterns[i];i++) { + if (strcmp(options.ignore_patterns[i], str) == 0 || + gen_fnmatch(options.ignore_patterns[i], str) == 0) { + DEBUG(2,("Ignoring '%s'\n", str)); + return true; + } + } + return false; +} + +/***************************************************** +connect to the servers +*******************************************************/ +static bool connect_servers_fast(void) +{ + int h, i; + + /* close all open files */ + for (h=0;h<options.max_open_handles;h++) { + if (!open_handles[h].active) continue; + for (i=0;i<NSERVERS;i++) { + NTSTATUS status = smb2_util_close(servers[i].tree[open_handles[h].instance], + open_handles[h].server_handle[i]); + if (NT_STATUS_IS_ERR(status)) { + return false; + } + open_handles[h].active = false; + } + } + + return true; +} + + + + +/***************************************************** +connect to the servers +*******************************************************/ +static bool connect_servers(struct event_context *ev, + struct loadparm_context *lp_ctx) +{ + int i, j; + + if (options.fast_reconnect && servers[0].tree[0]) { + if (connect_servers_fast()) { + return true; + } + } + + /* close any existing connections */ + for (i=0;i<NSERVERS;i++) { + for (j=0;j<NINSTANCES;j++) { + if (servers[i].tree[j]) { + smb2_tdis(servers[i].tree[j]); + talloc_free(servers[i].tree[j]); + servers[i].tree[j] = NULL; + } + } + } + + for (i=0;i<NSERVERS;i++) { + for (j=0;j<NINSTANCES;j++) { + NTSTATUS status; + printf("Connecting to \\\\%s\\%s as %s - instance %d\n", + servers[i].server_name, servers[i].share_name, + servers[i].credentials->username, j); + + cli_credentials_set_workstation(servers[i].credentials, + "gentest", CRED_SPECIFIED); + + status = smb2_connect(NULL, servers[i].server_name, + servers[i].share_name, + lp_resolve_context(lp_ctx), + servers[i].credentials, + &servers[i].tree[j], + ev); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to connect to \\\\%s\\%s - %s\n", + servers[i].server_name, servers[i].share_name, + nt_errstr(status)); + return false; + } + +// smb2_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL); + smb2_transport_idle_handler(servers[i].tree[j]->session->transport, idle_func, 50000, NULL); + } + } + + return true; +} + +/* + work out the time skew between the servers - be conservative +*/ +static uint_t time_skew(void) +{ + uint_t ret; + ret = labs(servers[0].tree[0]->session->transport->negotiate.system_time - + servers[1].tree[0]->session->transport->negotiate.system_time); + return ret + 300; +} + + +static bool smb2_handle_equal(const struct smb2_handle *h1, const struct smb2_handle *h2) +{ + return memcmp(h1, h2, sizeof(struct smb2_handle)) == 0; +} + +/* + turn a server handle into a local handle +*/ +static uint_t fnum_to_handle(int server, int instance, struct smb2_handle server_handle) +{ + uint_t i; + for (i=0;i<options.max_open_handles;i++) { + if (!open_handles[i].active || + instance != open_handles[i].instance) continue; + if (smb2_handle_equal(&open_handles[i].server_handle[server], &server_handle)) { + return i; + } + } + printf("Invalid server handle in fnum_to_handle on server %d instance %d\n", + server, instance); + return BAD_HANDLE; +} + +/* + add some newly opened handles +*/ +static void gen_add_handle(int instance, const char *name, struct smb2_handle handles[NSERVERS]) +{ + int i, h; + for (h=0;h<options.max_open_handles;h++) { + if (!open_handles[h].active) break; + } + if (h == options.max_open_handles) { + /* we have to force close a random handle */ + h = random() % options.max_open_handles; + for (i=0;i<NSERVERS;i++) { + NTSTATUS status; + status = smb2_util_close(servers[i].tree[open_handles[h].instance], + open_handles[h].server_handle[i]); + if (NT_STATUS_IS_ERR(status)) { + printf("INTERNAL ERROR: Close failed when recovering handle! - %s\n", + nt_errstr(status)); + } + } + printf("Recovered handle %d\n", h); + num_open_handles--; + } + for (i=0;i<NSERVERS;i++) { + open_handles[h].server_handle[i] = handles[i]; + open_handles[h].instance = instance; + open_handles[h].active = true; + open_handles[h].name = name; + } + num_open_handles++; + + printf("OPEN num_open_handles=%d h=%d (%s)\n", + num_open_handles, h, name); +} + +/* + remove a closed handle +*/ +static void gen_remove_handle(int instance, struct smb2_handle handles[NSERVERS]) +{ + int h; + for (h=0;h<options.max_open_handles;h++) { + if (instance == open_handles[h].instance && + smb2_handle_equal(&open_handles[h].server_handle[0], &handles[0])) { + open_handles[h].active = false; + num_open_handles--; + printf("CLOSE num_open_handles=%d h=%d (%s)\n", + num_open_handles, h, + open_handles[h].name); + return; + } + } + printf("Removing invalid handle!?\n"); + exit(1); +} + +/* + return true with 'chance' probability as a percentage +*/ +static bool gen_chance(uint_t chance) +{ + return ((random() % 100) <= chance); +} + +/* + map an internal handle number to a server handle +*/ +static struct smb2_handle gen_lookup_handle(int server, uint16_t handle) +{ + if (handle == BAD_HANDLE) return bad_smb2_handle; + return open_handles[handle].server_handle[server]; +} + +/* + return a file handle +*/ +static uint16_t gen_fnum(int instance) +{ + uint16_t h; + int count = 0; + + if (gen_chance(20)) return BAD_HANDLE; + + while (num_open_handles > 0 && count++ < 10*options.max_open_handles) { + h = random() % options.max_open_handles; + if (open_handles[h].active && + open_handles[h].instance == instance) { + return h; + } + } + return BAD_HANDLE; +} + +/* + return a file handle, but skewed so we don't close the last + couple of handles too readily +*/ +static uint16_t gen_fnum_close(int instance) +{ + if (num_open_handles < 3) { + if (gen_chance(80)) return BAD_HANDLE; + } + + return gen_fnum(instance); +} + +/* + generate an integer in a specified range +*/ +static int gen_int_range(uint64_t min, uint64_t max) +{ + uint_t r = random(); + return min + (r % (1+max-min)); +} + +/* + return a fnum for use as a root fid + be careful to call GEN_SET_FNUM() when you use this! +*/ +static uint16_t gen_root_fid(int instance) +{ + if (gen_chance(5)) return gen_fnum(instance); + return 0; +} + +/* + generate a file offset +*/ +static int gen_offset(void) +{ + if (gen_chance(20)) return 0; +// if (gen_chance(5)) return gen_int_range(0, 0xFFFFFFFF); + return gen_int_range(0, 1024*1024); +} + +/* + generate a io count +*/ +static int gen_io_count(void) +{ + if (gen_chance(20)) return 0; +// if (gen_chance(5)) return gen_int_range(0, 0xFFFFFFFF); + return gen_int_range(0, 4096); +} + +/* + generate a filename +*/ +static const char *gen_fname(void) +{ + const char *names[] = {"gentest\\gentest.dat", + "gentest\\foo", + "gentest\\foo2.sym", + "gentest\\foo3.dll", + "gentest\\foo4", + "gentest\\foo4:teststream1", + "gentest\\foo4:teststream2", + "gentest\\foo5.exe", + "gentest\\foo5.exe:teststream3", + "gentest\\foo5.exe:teststream4", + "gentest\\foo6.com", + "gentest\\blah", + "gentest\\blah\\blergh.txt", + "gentest\\blah\\blergh2", + "gentest\\blah\\blergh3.txt", + "gentest\\blah\\blergh4", + "gentest\\blah\\blergh5.txt", + "gentest\\blah\\blergh5", + "gentest\\blah\\.", +#if 0 + /* this causes problem with w2k3 */ + "gentest\\blah\\..", +#endif + "gentest\\a_very_long_name.bin", + "gentest\\x.y", + "gentest\\blah"}; + int i; + + do { + i = gen_int_range(0, ARRAY_SIZE(names)-1); + } while (ignore_pattern(names[i])); + + return names[i]; +} + +/* + generate a filename with a higher chance of choosing an already + open file +*/ +static const char *gen_fname_open(int instance) +{ + uint16_t h; + h = gen_fnum(instance); + if (h == BAD_HANDLE) { + return gen_fname(); + } + return open_handles[h].name; +} + +/* + generate a wildcard pattern +*/ +static const char *gen_pattern(void) +{ + int i; + const char *names[] = {"gentest\\*.dat", + "gentest\\*", + "gentest\\*.*", + "gentest\\blah\\*.*", + "gentest\\blah\\*", + "gentest\\?"}; + + if (gen_chance(50)) return gen_fname(); + + do { + i = gen_int_range(0, ARRAY_SIZE(names)-1); + } while (ignore_pattern(names[i])); + + return names[i]; +} + +static uint32_t gen_bits_levels(int nlevels, ...) +{ + va_list ap; + uint32_t pct; + uint32_t mask; + int i; + va_start(ap, nlevels); + for (i=0;i<nlevels;i++) { + pct = va_arg(ap, uint32_t); + mask = va_arg(ap, uint32_t); + if (pct == 100 || gen_chance(pct)) { + va_end(ap); + return mask & random(); + } + } + va_end(ap); + return 0; +} + +/* + generate a bitmask +*/ +static uint32_t gen_bits_mask(uint_t mask) +{ + uint_t ret = random(); + return ret & mask; +} + +/* + generate a bitmask with high probability of the first mask + and low of the second +*/ +static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2) +{ + if (gen_chance(10)) return gen_bits_mask(mask2); + return gen_bits_mask(mask1); +} + +/* + generate a boolean +*/ +static bool gen_bool(void) +{ + return gen_bits_mask2(0x1, 0xFF); +} + +/* + generate ntrename flags +*/ +static uint16_t gen_rename_flags(void) +{ + if (gen_chance(30)) return RENAME_FLAG_RENAME; + if (gen_chance(30)) return RENAME_FLAG_HARD_LINK; + if (gen_chance(30)) return RENAME_FLAG_COPY; + return gen_bits_mask(0xFFFF); +} + + +/* + return a lockingx lock mode +*/ +static uint16_t gen_lock_mode(void) +{ + if (gen_chance(5)) return gen_bits_mask(0xFFFF); + if (gen_chance(20)) return gen_bits_mask(0x1F); + return gen_bits_mask(LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES); +} + +/* + generate a pid +*/ +static uint16_t gen_pid(void) +{ + if (gen_chance(10)) return gen_bits_mask(0xFFFF); + return getpid(); +} + +/* + generate a lock count +*/ +static off_t gen_lock_count(void) +{ + return gen_int_range(0, 3); +} + +/* + generate a ntcreatex flags field +*/ +static uint32_t gen_ntcreatex_flags(void) +{ + if (gen_chance(70)) return NTCREATEX_FLAGS_EXTENDED; + return gen_bits_mask2(0x1F, 0xFFFFFFFF); +} + +/* + generate a NT access mask +*/ +static uint32_t gen_access_mask(void) +{ + if (gen_chance(50)) return SEC_FLAG_MAXIMUM_ALLOWED; + if (gen_chance(20)) return SEC_FILE_ALL; + return gen_bits_mask(0xFFFFFFFF); +} + +/* + generate a ntcreatex create options bitfield +*/ +static uint32_t gen_create_options(void) +{ + if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF); + if (gen_chance(50)) return 0; + return gen_bits_mask(NTCREATEX_OPTIONS_DELETE_ON_CLOSE | NTCREATEX_OPTIONS_DIRECTORY); +} + +/* + generate a ntcreatex open disposition +*/ +static uint32_t gen_open_disp(void) +{ + if (gen_chance(10)) return gen_bits_mask(0xFFFFFFFF); + return gen_int_range(0, 5); +} + +/* + generate an openx open mode +*/ +static uint16_t gen_openx_mode(void) +{ + if (gen_chance(20)) return gen_bits_mask(0xFFFF); + if (gen_chance(20)) return gen_bits_mask(0xFF); + return OPENX_MODE_DENY_NONE | gen_bits_mask(0x3); +} + +/* + generate an openx flags field +*/ +static uint16_t gen_openx_flags(void) +{ + if (gen_chance(20)) return gen_bits_mask(0xFFFF); + return gen_bits_mask(0x7); +} + +/* + generate an openx open function +*/ +static uint16_t gen_openx_func(void) +{ + if (gen_chance(20)) return gen_bits_mask(0xFFFF); + return gen_bits_mask(0x13); +} + +/* + generate a file attrib combination +*/ +static uint32_t gen_attrib(void) +{ + if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF); + return gen_bits_mask(FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY); +} + +/* + generate a unix timestamp +*/ +static time_t gen_timet(void) +{ + if (gen_chance(30)) return 0; + return (time_t)random(); +} + +/* + generate a unix timestamp +*/ +static NTTIME gen_nttime(void) +{ + NTTIME ret; + unix_to_nt_time(&ret, gen_timet()); + return ret; +} + +/* + generate a milliseconds protocol timeout +*/ +static uint32_t gen_timeout(void) +{ + if (gen_chance(98)) return 0; + return random() % 50; +} + +/* + generate a file allocation size +*/ +static uint_t gen_alloc_size(void) +{ + uint_t ret; + + if (gen_chance(30)) return 0; + + ret = random() % 4*1024*1024; + /* give a high chance of a round number */ + if (gen_chance(60)) { + ret &= ~(1024*1024 - 1); + } + return ret; +} + +/* + generate an ea_struct +*/ +static struct ea_struct gen_ea_struct(void) +{ + struct ea_struct ea; + const char *names[] = {"EAONE", + "", + "FOO!", + " WITH SPACES ", + ".", + "AVERYLONGATTRIBUTENAME"}; + const char *values[] = {"VALUE1", + "", + "NOT MUCH FOO", + " LEADING SPACES ", + ":", + "ASOMEWHATLONGERATTRIBUTEVALUE"}; + int i; + + ZERO_STRUCT(ea); + + do { + i = gen_int_range(0, ARRAY_SIZE(names)-1); + } while (ignore_pattern(names[i])); + + ea.name.s = names[i]; + + do { + i = gen_int_range(0, ARRAY_SIZE(values)-1); + } while (ignore_pattern(values[i])); + + ea.value = data_blob(values[i], strlen(values[i])); + + if (gen_chance(10)) ea.flags = gen_bits_mask(0xFF); + ea.flags = 0; + + return ea; +} + +/* + the idle function tries to cope with getting an oplock break on a connection, and + 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(struct smb2_transport *transport, void *private) +{ + int i, j; + for (i=0;i<NSERVERS;i++) { + for (j=0;j<NINSTANCES;j++) { + if (servers[i].tree[j] && + transport != servers[i].tree[j]->session->transport) { + // smb2_transport_process(servers[i].tree[j]->session->transport); + } + } + } + +} + + +/* + compare NTSTATUS, using checking ignored patterns +*/ +static bool compare_status(NTSTATUS status1, NTSTATUS status2) +{ + if (NT_STATUS_EQUAL(status1, status2)) return true; + + /* one code being an error and the other OK is always an error */ + if (NT_STATUS_IS_OK(status1) || NT_STATUS_IS_OK(status2)) return false; + + /* if we are ignoring one of the status codes then consider this a match */ + if (ignore_pattern(nt_errstr(status1)) || + ignore_pattern(nt_errstr(status2))) { + return true; + } + return false; +} + + +/* + check for pending packets on all connections +*/ +static void check_pending(void) +{ + int i, j; + + msleep(20); + + for (j=0;j<NINSTANCES;j++) { + for (i=0;i<NSERVERS;i++) { + // smb2_transport_process(servers[i].tree[j]->session->transport); + } + } +} + +/* + check that the same oplock breaks have been received by all instances +*/ +static bool check_oplocks(const char *call) +{ +#if 0 + int i, j; + int tries = 0; + +again: + check_pending(); + + for (j=0;j<NINSTANCES;j++) { + for (i=1;i<NSERVERS;i++) { + if (oplocks[0][j].got_break != oplocks[i][j].got_break || + oplocks[0][j].handle != oplocks[i][j].handle || + oplocks[0][j].level != oplocks[i][j].level) { + if (tries++ < 10) goto again; + printf("oplock break inconsistent - %d/%d/%d vs %d/%d/%d\n", + oplocks[0][j].got_break, + oplocks[0][j].handle, + oplocks[0][j].level, + oplocks[i][j].got_break, + oplocks[i][j].handle, + oplocks[i][j].level); + return false; + } + } + } + + /* if we got a break and closed then remove the handle */ + for (j=0;j<NINSTANCES;j++) { + if (oplocks[0][j].got_break && + oplocks[0][j].do_close) { + uint16_t fnums[NSERVERS]; + for (i=0;i<NSERVERS;i++) { + fnums[i] = oplocks[i][j].fnum; + } + gen_remove_handle(j, fnums); + break; + } + } +#endif + return true; +} + + +/* + check that the same change notify info has been received by all instances +*/ +static bool check_notifies(const char *call) +{ +#if 0 + int i, j; + int tries = 0; + +again: + check_pending(); + + for (j=0;j<NINSTANCES;j++) { + for (i=1;i<NSERVERS;i++) { + int n; + union smb_notify not1, not2; + + if (notifies[0][j].notify_count != notifies[i][j].notify_count) { + if (tries++ < 10) goto again; + printf("Notify count inconsistent %d %d\n", + notifies[0][j].notify_count, + notifies[i][j].notify_count); + return false; + } + + if (notifies[0][j].notify_count == 0) continue; + + if (!NT_STATUS_EQUAL(notifies[0][j].status, + notifies[i][j].status)) { + printf("Notify status mismatch - %s - %s\n", + nt_errstr(notifies[0][j].status), + nt_errstr(notifies[i][j].status)); + return false; + } + + if (!NT_STATUS_IS_OK(notifies[0][j].status)) { + continue; + } + + not1 = notifies[0][j].notify; + not2 = notifies[i][j].notify; + + for (n=0;n<not1.nttrans.out.num_changes;n++) { + if (not1.nttrans.out.changes[n].action != + not2.nttrans.out.changes[n].action) { + printf("Notify action %d inconsistent %d %d\n", n, + not1.nttrans.out.changes[n].action, + not2.nttrans.out.changes[n].action); + return false; + } + if (strcmp(not1.nttrans.out.changes[n].name.s, + not2.nttrans.out.changes[n].name.s)) { + printf("Notify name %d inconsistent %s %s\n", n, + not1.nttrans.out.changes[n].name.s, + not2.nttrans.out.changes[n].name.s); + return false; + } + if (not1.nttrans.out.changes[n].name.private_length != + not2.nttrans.out.changes[n].name.private_length) { + printf("Notify name length %d inconsistent %d %d\n", n, + not1.nttrans.out.changes[n].name.private_length, + not2.nttrans.out.changes[n].name.private_length); + return false; + } + } + } + } + + ZERO_STRUCT(notifies); + +#endif + return true; +} + +#define GEN_COPY_PARM do { \ + int i; \ + for (i=1;i<NSERVERS;i++) { \ + parm[i] = parm[0]; \ + } \ +} while (0) + +#define GEN_CALL(call) do { \ + int i; \ + ZERO_STRUCT(oplocks); \ + ZERO_STRUCT(notifies); \ + for (i=0;i<NSERVERS;i++) { \ + struct smb2_tree *tree = servers[i].tree[instance]; \ + status[i] = call; \ + } \ + current_op.status = status[0]; \ + for (i=1;i<NSERVERS;i++) { \ + if (!compare_status(status[i], status[0])) { \ + printf("status different in %s - %s %s\n", #call, \ + nt_errstr(status[0]), nt_errstr(status[i])); \ + return false; \ + } \ + } \ + if (!check_oplocks(#call)) return false; \ + if (!check_notifies(#call)) return false; \ + if (!NT_STATUS_IS_OK(status[0])) { \ + return true; \ + } \ +} while(0) + +#define ADD_HANDLE(name, field) do { \ + struct smb2_handle handles[NSERVERS]; \ + int i; \ + for (i=0;i<NSERVERS;i++) { \ + handles[i] = parm[i].field; \ + } \ + gen_add_handle(instance, name, handles); \ +} while(0) + +#define REMOVE_HANDLE(field) do { \ + struct smb2_handle handles[NSERVERS]; \ + int i; \ + for (i=0;i<NSERVERS;i++) { \ + handles[i] = parm[i].field; \ + } \ + gen_remove_handle(instance, handles); \ +} while(0) + +#define GEN_SET_FNUM(field) do { \ + int i; \ + for (i=0;i<NSERVERS;i++) { \ + parm[i].field = gen_lookup_handle(i, parm[i].field.data[0]); \ + } \ +} while(0) + +#define CHECK_EQUAL(field) do { \ + if (parm[0].field != parm[1].field && !ignore_pattern(#field)) { \ + printf("Mismatch in %s - 0x%x 0x%x\n", #field, \ + (int)parm[0].field, (int)parm[1].field); \ + return false; \ + } \ +} while(0) + +#define CHECK_WSTR_EQUAL(field) do { \ + if ((!parm[0].field.s && parm[1].field.s) || (parm[0].field.s && !parm[1].field.s)) { \ + printf("%s is NULL!\n", #field); \ + return false; \ + } \ + if (parm[0].field.s && strcmp(parm[0].field.s, parm[1].field.s) != 0 && !ignore_pattern(#field)) { \ + printf("Mismatch in %s - %s %s\n", #field, \ + parm[0].field.s, parm[1].field.s); \ + return false; \ + } \ + CHECK_EQUAL(field.private_length); \ +} while(0) + +#define CHECK_BLOB_EQUAL(field) do { \ + if (memcmp(parm[0].field.data, parm[1].field.data, parm[0].field.length) != 0 && !ignore_pattern(#field)) { \ + printf("Mismatch in %s\n", #field); \ + return false; \ + } \ + CHECK_EQUAL(field.length); \ +} while(0) + +#define CHECK_TIMES_EQUAL(field) do { \ + if (labs(parm[0].field - parm[1].field) > time_skew() && \ + !ignore_pattern(#field)) { \ + printf("Mismatch in %s - 0x%x 0x%x\n", #field, \ + (int)parm[0].field, (int)parm[1].field); \ + return false; \ + } \ +} while(0) + +#define CHECK_NTTIMES_EQUAL(field) do { \ + if (labs(nt_time_to_unix(parm[0].field) - \ + nt_time_to_unix(parm[1].field)) > time_skew() && \ + !ignore_pattern(#field)) { \ + printf("Mismatch in %s - 0x%x 0x%x\n", #field, \ + (int)nt_time_to_unix(parm[0].field), \ + (int)nt_time_to_unix(parm[1].field)); \ + return false; \ + } \ +} while(0) + +/* + generate ntcreatex operations +*/ +static bool handler_ntcreatex(int instance) +{ + struct smb2_create parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + + ZERO_STRUCT(parm[0]); + parm[0].in.security_flags = gen_bits_levels(3, 70, 0x0, 70, 0x3, 100, 0xFF); + parm[0].in.oplock_level = gen_bits_levels(3, 70, 0x0, 70, 0x9, 100, 0xFF); + parm[0].in.impersonation_level = gen_bits_levels(3, 70, 0x0, 70, 0x3, 100, 0xFFFFFFFF); + parm[0].in.create_flags = gen_bits_levels(2, 80, 0x0, 100, 0xFFFFFFFF); + if (gen_chance(2)) { + parm[0].in.create_flags |= gen_bits_mask(0xFFFFFFFF); + } + parm[0].in.reserved = gen_bits_levels(2, 80, 0x0, 100, 0xFFFFFFFF); + if (gen_chance(2)) { + parm[0].in.reserved |= gen_bits_mask(0xFFFFFFFF); + } + parm[0].in.desired_access = gen_access_mask(); + parm[0].in.file_attributes = gen_attrib(); + parm[0].in.share_access = gen_bits_mask2(0x7, 0xFFFFFFFF); + parm[0].in.create_disposition = gen_open_disp(); + parm[0].in.create_options = gen_create_options(); + parm[0].in.fname = gen_fname_open(instance); + + if (!options.use_oplocks) { + /* mask out oplocks */ + parm[0].in.oplock_level = 0; + } + + GEN_COPY_PARM; + GEN_CALL(smb2_create(tree, current_op.mem_ctx, &parm[i])); + + CHECK_EQUAL(out.oplock_level); + CHECK_EQUAL(out.reserved); + CHECK_EQUAL(out.create_action); + CHECK_NTTIMES_EQUAL(out.create_time); + CHECK_NTTIMES_EQUAL(out.access_time); + CHECK_NTTIMES_EQUAL(out.write_time); + CHECK_NTTIMES_EQUAL(out.change_time); + CHECK_EQUAL(out.alloc_size); + CHECK_EQUAL(out.size); + CHECK_EQUAL(out.file_attr); + CHECK_EQUAL(out.reserved2); + + /* ntcreatex creates a new file handle */ + ADD_HANDLE(parm[0].in.fname, out.file.handle); + + return true; +} + +/* + generate close operations +*/ +static bool handler_close(int instance) +{ + struct smb2_close parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + + ZERO_STRUCT(parm[0]); + parm[0].in.file.handle.data[0] = gen_fnum_close(instance); + parm[0].in.flags = gen_bits_mask2(0x1, 0xFFFF); + + GEN_COPY_PARM; + GEN_SET_FNUM(in.file.handle); + GEN_CALL(smb2_close(tree, &parm[i])); + + CHECK_EQUAL(out.flags); + CHECK_EQUAL(out._pad); + CHECK_NTTIMES_EQUAL(out.create_time); + CHECK_NTTIMES_EQUAL(out.access_time); + CHECK_NTTIMES_EQUAL(out.write_time); + CHECK_NTTIMES_EQUAL(out.change_time); + CHECK_EQUAL(out.alloc_size); + CHECK_EQUAL(out.size); + CHECK_EQUAL(out.file_attr); + + REMOVE_HANDLE(in.file.handle); + + return true; +} + +/* + generate read operations +*/ +static bool handler_read(int instance) +{ + struct smb2_read parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + + parm[0].in.file.handle.data[0] = gen_fnum(instance); + parm[0].in.reserved = gen_bits_mask2(0x0, 0xFF); + parm[0].in.length = gen_io_count(); + parm[0].in.offset = gen_offset(); + parm[0].in.min_count = gen_io_count(); + parm[0].in.channel = gen_bits_mask2(0x0, 0xFFFFFFFF); + parm[0].in.remaining = gen_bits_mask2(0x0, 0xFFFFFFFF); + parm[0].in.channel_offset = gen_bits_mask2(0x0, 0xFFFF); + parm[0].in.channel_length = gen_bits_mask2(0x0, 0xFFFF); + + GEN_COPY_PARM; + GEN_SET_FNUM(in.file.handle); + GEN_CALL(smb2_read(tree, current_op.mem_ctx, &parm[i])); + + CHECK_EQUAL(out.remaining); + CHECK_EQUAL(out.reserved); + CHECK_EQUAL(out.data.length); + + return true; +} + +/* + generate write operations +*/ +static bool handler_write(int instance) +{ + struct smb2_write parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + + parm[0].in.file.handle.data[0] = gen_fnum(instance); + parm[0].in.offset = gen_offset(); + parm[0].in.unknown1 = gen_bits_mask2(0, 0xFFFFFFFF); + parm[0].in.unknown2 = gen_bits_mask2(0, 0xFFFFFFFF); + parm[0].in.data = data_blob_talloc(current_op.mem_ctx, NULL, + gen_io_count()); + + GEN_COPY_PARM; + GEN_SET_FNUM(in.file.handle); + GEN_CALL(smb2_write(tree, &parm[i])); + + CHECK_EQUAL(out._pad); + CHECK_EQUAL(out.nwritten); + CHECK_EQUAL(out.unknown1); + + return true; +} + +#if 0 +/* + generate lockingx operations +*/ +static bool handler_lock(int instance) +{ + union smb_lock parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + int n, nlocks; + + parm[0].lockx.level = RAW_LOCK_LOCKX; + parm[0].lockx.in.file.fnum = gen_fnum(instance); + parm[0].lockx.in.mode = gen_lock_mode(); + parm[0].lockx.in.timeout = gen_timeout(); + do { + /* make sure we don't accidentially generate an oplock + break ack - otherwise the server can just block forever */ + parm[0].lockx.in.ulock_cnt = gen_lock_count(); + parm[0].lockx.in.lock_cnt = gen_lock_count(); + nlocks = parm[0].lockx.in.ulock_cnt + parm[0].lockx.in.lock_cnt; + } while (nlocks == 0); + + if (nlocks > 0) { + parm[0].lockx.in.locks = talloc_array(current_op.mem_ctx, + struct smb_lock_entry, + nlocks); + for (n=0;n<nlocks;n++) { + parm[0].lockx.in.locks[n].pid = gen_pid(); + parm[0].lockx.in.locks[n].offset = gen_offset(); + parm[0].lockx.in.locks[n].count = gen_io_count(); + } + } + + GEN_COPY_PARM; + GEN_SET_FNUM(lockx.in.file.fnum); + GEN_CALL(smb_raw_lock(tree, &parm[i])); + + return true; +} + +/* + generate a fileinfo query structure +*/ +static void gen_fileinfo(int instance, union smb_fileinfo *info) +{ + int i; + #define LVL(v) {RAW_FILEINFO_ ## v, "RAW_FILEINFO_" #v} + struct { + enum smb_fileinfo_level level; + const char *name; + } levels[] = { + LVL(GETATTR), LVL(GETATTRE), LVL(STANDARD), + LVL(EA_SIZE), LVL(ALL_EAS), LVL(IS_NAME_VALID), + LVL(BASIC_INFO), LVL(STANDARD_INFO), LVL(EA_INFO), + LVL(NAME_INFO), LVL(ALL_INFO), LVL(ALT_NAME_INFO), + LVL(STREAM_INFO), LVL(COMPRESSION_INFO), LVL(BASIC_INFORMATION), + LVL(STANDARD_INFORMATION), LVL(INTERNAL_INFORMATION), LVL(EA_INFORMATION), + LVL(ACCESS_INFORMATION), LVL(NAME_INFORMATION), LVL(POSITION_INFORMATION), + LVL(MODE_INFORMATION), LVL(ALIGNMENT_INFORMATION), LVL(ALL_INFORMATION), + LVL(ALT_NAME_INFORMATION), LVL(STREAM_INFORMATION), LVL(COMPRESSION_INFORMATION), + LVL(NETWORK_OPEN_INFORMATION), LVL(ATTRIBUTE_TAG_INFORMATION) + }; + do { + i = gen_int_range(0, ARRAY_SIZE(levels)-1); + } while (ignore_pattern(levels[i].name)); + + info->generic.level = levels[i].level; +} + +/* + compare returned fileinfo structures +*/ +static bool cmp_fileinfo(int instance, + union smb_fileinfo parm[NSERVERS], + NTSTATUS status[NSERVERS]) +{ + int i; + + switch (parm[0].generic.level) { + case RAW_FILEINFO_GENERIC: + return false; + + case RAW_FILEINFO_GETATTR: + CHECK_EQUAL(getattr.out.attrib); + CHECK_EQUAL(getattr.out.size); + CHECK_TIMES_EQUAL(getattr.out.write_time); + break; + + case RAW_FILEINFO_GETATTRE: + CHECK_TIMES_EQUAL(getattre.out.create_time); + CHECK_TIMES_EQUAL(getattre.out.access_time); + CHECK_TIMES_EQUAL(getattre.out.write_time); + CHECK_EQUAL(getattre.out.size); + CHECK_EQUAL(getattre.out.alloc_size); + CHECK_EQUAL(getattre.out.attrib); + break; + + case RAW_FILEINFO_STANDARD: + CHECK_TIMES_EQUAL(standard.out.create_time); + CHECK_TIMES_EQUAL(standard.out.access_time); + CHECK_TIMES_EQUAL(standard.out.write_time); + CHECK_EQUAL(standard.out.size); + CHECK_EQUAL(standard.out.alloc_size); + CHECK_EQUAL(standard.out.attrib); + break; + + case RAW_FILEINFO_EA_SIZE: + CHECK_TIMES_EQUAL(ea_size.out.create_time); + CHECK_TIMES_EQUAL(ea_size.out.access_time); + CHECK_TIMES_EQUAL(ea_size.out.write_time); + CHECK_EQUAL(ea_size.out.size); + CHECK_EQUAL(ea_size.out.alloc_size); + CHECK_EQUAL(ea_size.out.attrib); + CHECK_EQUAL(ea_size.out.ea_size); + break; + + case RAW_FILEINFO_ALL_EAS: + CHECK_EQUAL(all_eas.out.num_eas); + for (i=0;i<parm[0].all_eas.out.num_eas;i++) { + CHECK_EQUAL(all_eas.out.eas[i].flags); + CHECK_WSTR_EQUAL(all_eas.out.eas[i].name); + CHECK_BLOB_EQUAL(all_eas.out.eas[i].value); + } + break; + + case RAW_FILEINFO_IS_NAME_VALID: + break; + + case RAW_FILEINFO_BASIC_INFO: + case RAW_FILEINFO_BASIC_INFORMATION: + CHECK_NTTIMES_EQUAL(basic_info.out.create_time); + CHECK_NTTIMES_EQUAL(basic_info.out.access_time); + CHECK_NTTIMES_EQUAL(basic_info.out.write_time); + CHECK_NTTIMES_EQUAL(basic_info.out.change_time); + CHECK_EQUAL(basic_info.out.attrib); + break; + + case RAW_FILEINFO_STANDARD_INFO: + case RAW_FILEINFO_STANDARD_INFORMATION: + CHECK_EQUAL(standard_info.out.alloc_size); + CHECK_EQUAL(standard_info.out.size); + CHECK_EQUAL(standard_info.out.nlink); + CHECK_EQUAL(standard_info.out.delete_pending); + CHECK_EQUAL(standard_info.out.directory); + break; + + case RAW_FILEINFO_EA_INFO: + case RAW_FILEINFO_EA_INFORMATION: + CHECK_EQUAL(ea_info.out.ea_size); + break; + + case RAW_FILEINFO_NAME_INFO: + case RAW_FILEINFO_NAME_INFORMATION: + CHECK_WSTR_EQUAL(name_info.out.fname); + break; + + case RAW_FILEINFO_ALL_INFO: + case RAW_FILEINFO_ALL_INFORMATION: + CHECK_NTTIMES_EQUAL(all_info.out.create_time); + CHECK_NTTIMES_EQUAL(all_info.out.access_time); + CHECK_NTTIMES_EQUAL(all_info.out.write_time); + CHECK_NTTIMES_EQUAL(all_info.out.change_time); + CHECK_EQUAL(all_info.out.attrib); + CHECK_EQUAL(all_info.out.alloc_size); + CHECK_EQUAL(all_info.out.size); + CHECK_EQUAL(all_info.out.nlink); + CHECK_EQUAL(all_info.out.delete_pending); + CHECK_EQUAL(all_info.out.directory); + CHECK_EQUAL(all_info.out.ea_size); + CHECK_WSTR_EQUAL(all_info.out.fname); + break; + + case RAW_FILEINFO_ALT_NAME_INFO: + case RAW_FILEINFO_ALT_NAME_INFORMATION: + CHECK_WSTR_EQUAL(alt_name_info.out.fname); + break; + + case RAW_FILEINFO_STREAM_INFO: + case RAW_FILEINFO_STREAM_INFORMATION: + CHECK_EQUAL(stream_info.out.num_streams); + for (i=0;i<parm[0].stream_info.out.num_streams;i++) { + CHECK_EQUAL(stream_info.out.streams[i].size); + CHECK_EQUAL(stream_info.out.streams[i].alloc_size); + CHECK_WSTR_EQUAL(stream_info.out.streams[i].stream_name); + } + break; + + case RAW_FILEINFO_COMPRESSION_INFO: + case RAW_FILEINFO_COMPRESSION_INFORMATION: + CHECK_EQUAL(compression_info.out.compressed_size); + CHECK_EQUAL(compression_info.out.format); + CHECK_EQUAL(compression_info.out.unit_shift); + CHECK_EQUAL(compression_info.out.chunk_shift); + CHECK_EQUAL(compression_info.out.cluster_shift); + break; + + case RAW_FILEINFO_INTERNAL_INFORMATION: + CHECK_EQUAL(internal_information.out.file_id); + break; + + case RAW_FILEINFO_ACCESS_INFORMATION: + CHECK_EQUAL(access_information.out.access_flags); + break; + + case RAW_FILEINFO_POSITION_INFORMATION: + CHECK_EQUAL(position_information.out.position); + break; + + case RAW_FILEINFO_MODE_INFORMATION: + CHECK_EQUAL(mode_information.out.mode); + break; + + case RAW_FILEINFO_ALIGNMENT_INFORMATION: + CHECK_EQUAL(alignment_information.out.alignment_requirement); + break; + + case RAW_FILEINFO_NETWORK_OPEN_INFORMATION: + CHECK_NTTIMES_EQUAL(network_open_information.out.create_time); + CHECK_NTTIMES_EQUAL(network_open_information.out.access_time); + CHECK_NTTIMES_EQUAL(network_open_information.out.write_time); + CHECK_NTTIMES_EQUAL(network_open_information.out.change_time); + CHECK_EQUAL(network_open_information.out.alloc_size); + CHECK_EQUAL(network_open_information.out.size); + CHECK_EQUAL(network_open_information.out.attrib); + break; + + case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION: + CHECK_EQUAL(attribute_tag_information.out.attrib); + CHECK_EQUAL(attribute_tag_information.out.reparse_tag); + break; + + /* Unhandled levels */ + + case RAW_FILEINFO_SEC_DESC: + case RAW_FILEINFO_EA_LIST: + case RAW_FILEINFO_UNIX_BASIC: + case RAW_FILEINFO_UNIX_LINK: + case RAW_FILEINFO_SMB2_ALL_EAS: + case RAW_FILEINFO_SMB2_ALL_INFORMATION: + case RAW_FILEINFO_UNIX_INFO2: + break; + } + + return true; +} + +/* + generate qfileinfo operations +*/ +static bool handler_qfileinfo(int instance) +{ + union smb_fileinfo parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + + parm[0].generic.in.file.fnum = gen_fnum(instance); + + gen_fileinfo(instance, &parm[0]); + + GEN_COPY_PARM; + GEN_SET_FNUM(generic.in.file.fnum); + GEN_CALL(smb_raw_fileinfo(tree, current_op.mem_ctx, &parm[i])); + + return cmp_fileinfo(instance, parm, status); +} + + +/* + generate a fileinfo query structure +*/ +static void gen_setfileinfo(int instance, union smb_setfileinfo *info) +{ + int i; + #undef LVL + #define LVL(v) {RAW_SFILEINFO_ ## v, "RAW_SFILEINFO_" #v} + struct { + enum smb_setfileinfo_level level; + const char *name; + } levels[] = { +#if 0 + /* disabled until win2003 can handle them ... */ + LVL(EA_SET), LVL(BASIC_INFO), LVL(DISPOSITION_INFO), + LVL(STANDARD), LVL(ALLOCATION_INFO), LVL(END_OF_FILE_INFO), +#endif + LVL(SETATTR), LVL(SETATTRE), LVL(BASIC_INFORMATION), + LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION), + LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION), + LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION), + LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040) + }; + do { + i = gen_int_range(0, ARRAY_SIZE(levels)-1); + } while (ignore_pattern(levels[i].name)); + + info->generic.level = levels[i].level; + + switch (info->generic.level) { + case RAW_SFILEINFO_SETATTR: + info->setattr.in.attrib = gen_attrib(); + info->setattr.in.write_time = gen_timet(); + break; + case RAW_SFILEINFO_SETATTRE: + info->setattre.in.create_time = gen_timet(); + info->setattre.in.access_time = gen_timet(); + info->setattre.in.write_time = gen_timet(); + break; + case RAW_SFILEINFO_STANDARD: + info->standard.in.create_time = gen_timet(); + info->standard.in.access_time = gen_timet(); + info->standard.in.write_time = gen_timet(); + break; + case RAW_SFILEINFO_EA_SET: { + static struct ea_struct ea; + info->ea_set.in.num_eas = 1; + info->ea_set.in.eas = &ea; + info->ea_set.in.eas[0] = gen_ea_struct(); + } + break; + case RAW_SFILEINFO_BASIC_INFO: + case RAW_SFILEINFO_BASIC_INFORMATION: + info->basic_info.in.create_time = gen_nttime(); + info->basic_info.in.access_time = gen_nttime(); + info->basic_info.in.write_time = gen_nttime(); + info->basic_info.in.change_time = gen_nttime(); + info->basic_info.in.attrib = gen_attrib(); + break; + case RAW_SFILEINFO_DISPOSITION_INFO: + case RAW_SFILEINFO_DISPOSITION_INFORMATION: + info->disposition_info.in.delete_on_close = gen_bool(); + break; + case RAW_SFILEINFO_ALLOCATION_INFO: + case RAW_SFILEINFO_ALLOCATION_INFORMATION: + info->allocation_info.in.alloc_size = gen_alloc_size(); + break; + case RAW_SFILEINFO_END_OF_FILE_INFO: + case RAW_SFILEINFO_END_OF_FILE_INFORMATION: + info->end_of_file_info.in.size = gen_offset(); + break; + case RAW_SFILEINFO_RENAME_INFORMATION: + case RAW_SFILEINFO_RENAME_INFORMATION_SMB2: + info->rename_information.in.overwrite = gen_bool(); + info->rename_information.in.root_fid = gen_root_fid(instance); + info->rename_information.in.new_name = gen_fname_open(instance); + break; + case RAW_SFILEINFO_POSITION_INFORMATION: + info->position_information.in.position = gen_offset(); + break; + case RAW_SFILEINFO_MODE_INFORMATION: + info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF); + break; + case RAW_SFILEINFO_GENERIC: + case RAW_SFILEINFO_SEC_DESC: + case RAW_SFILEINFO_UNIX_BASIC: + case RAW_SFILEINFO_UNIX_LINK: + case RAW_SFILEINFO_UNIX_HLINK: + case RAW_SFILEINFO_1023: + case RAW_SFILEINFO_1025: + case RAW_SFILEINFO_1029: + case RAW_SFILEINFO_1032: + case RAW_SFILEINFO_1039: + case RAW_SFILEINFO_1040: + case RAW_SFILEINFO_UNIX_INFO2: + /* Untested */ + break; + } +} + +/* + generate setfileinfo operations +*/ +static bool handler_sfileinfo(int instance) +{ + union smb_setfileinfo parm[NSERVERS]; + NTSTATUS status[NSERVERS]; + + parm[0].generic.in.file.fnum = gen_fnum(instance); + + gen_setfileinfo(instance, &parm[0]); + + GEN_COPY_PARM; + GEN_SET_FNUM(generic.in.file.fnum); + GEN_CALL(smb_raw_setfileinfo(tree, &parm[i])); + + return true; +} + +#endif + + +/* + wipe any relevant files +*/ +static void wipe_files(void) +{ + int i; + NTSTATUS status; + + for (i=0;i<NSERVERS;i++) { + int n = smb2_deltree(servers[i].tree[0], "gentest"); + if (n == -1) { + printf("Failed to wipe tree on server %d\n", i); + exit(1); + } + status = smb2_util_mkdir(servers[i].tree[0], "gentest"); + if (NT_STATUS_IS_ERR(status)) { + printf("Failed to create gentest on server %d - %s\n", i, nt_errstr(status)); + exit(1); + } + if (n > 0) { + printf("Deleted %d files on server %d\n", n, i); + } + } +} + +/* + dump the current seeds - useful for continuing a backtrack +*/ +static void dump_seeds(void) +{ + int i; + FILE *f; + + if (!options.seeds_file) { + return; + } + f = fopen("seeds.tmp", "w"); + if (!f) return; + + for (i=0;i<options.numops;i++) { + fprintf(f, "%u\n", op_parms[i].seed); + } + fclose(f); + rename("seeds.tmp", options.seeds_file); +} + + + +/* + the list of top-level operations that we will generate +*/ +static struct { + const char *name; + bool (*handler)(int instance); + int count, success_count; +} gen_ops[] = { + {"NTCREATEX", handler_ntcreatex}, + {"CLOSE", handler_close}, + {"READ", handler_read}, + {"WRITE", handler_write}, +}; + + +/* + run the test with the current set of op_parms parameters + return the number of operations that completed successfully +*/ +static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx) +{ + int op, i; + + if (!connect_servers(ev, lp_ctx)) { + printf("Failed to connect to servers\n"); + exit(1); + } + + dump_seeds(); + + /* wipe any leftover files from old runs */ + wipe_files(); + + /* reset the open handles array */ + memset(open_handles, 0, options.max_open_handles * sizeof(open_handles[0])); + num_open_handles = 0; + + for (i=0;i<ARRAY_SIZE(gen_ops);i++) { + gen_ops[i].count = 0; + gen_ops[i].success_count = 0; + } + + for (op=0; op<options.numops; op++) { + int instance, which_op; + bool ret; + + if (op_parms[op].disabled) continue; + + srandom(op_parms[op].seed); + + instance = gen_int_range(0, NINSTANCES-1); + + /* generate a non-ignored operation */ + do { + which_op = gen_int_range(0, ARRAY_SIZE(gen_ops)-1); + } while (ignore_pattern(gen_ops[which_op].name)); + + DEBUG(3,("Generating op %s on instance %d\n", + gen_ops[which_op].name, instance)); + + current_op.seed = op_parms[op].seed; + current_op.opnum = op; + current_op.name = gen_ops[which_op].name; + current_op.status = NT_STATUS_OK; + current_op.mem_ctx = talloc_named(NULL, 0, "%s", current_op.name); + + ret = gen_ops[which_op].handler(instance); + + talloc_free(current_op.mem_ctx); + + gen_ops[which_op].count++; + if (NT_STATUS_IS_OK(current_op.status)) { + gen_ops[which_op].success_count++; + } + + if (!ret) { + printf("Failed at operation %d - %s\n", + op, gen_ops[which_op].name); + return op; + } + + if (op % 100 == 0) { + printf("%d\n", op); + } + } + + for (i=0;i<ARRAY_SIZE(gen_ops);i++) { + printf("Op %-10s got %d/%d success\n", + gen_ops[i].name, + gen_ops[i].success_count, + gen_ops[i].count); + } + + return op; +} + +/* + perform a backtracking analysis of the minimal set of operations + to generate an error +*/ +static void backtrack_analyze(struct event_context *ev, + struct loadparm_context *lp_ctx) +{ + int chunk, ret; + + chunk = options.numops / 2; + + do { + int base; + for (base=0; + chunk > 0 && base+chunk < options.numops && options.numops > 1; ) { + int i, max; + + chunk = MIN(chunk, options.numops / 2); + + /* mark this range as disabled */ + max = MIN(options.numops, base+chunk); + for (i=base;i<max; i++) { + op_parms[i].disabled = true; + } + printf("Testing %d ops with %d-%d disabled\n", + options.numops, base, max-1); + ret = run_test(ev, lp_ctx); + printf("Completed %d of %d ops\n", ret, options.numops); + for (i=base;i<max; i++) { + op_parms[i].disabled = false; + } + if (ret == options.numops) { + /* this chunk is needed */ + base += chunk; + } else if (ret < base) { + printf("damn - inconsistent errors! found early error\n"); + options.numops = ret+1; + base = 0; + } else { + /* it failed - this chunk isn't needed for a failure */ + memmove(&op_parms[base], &op_parms[max], + sizeof(op_parms[0]) * (options.numops - max)); + options.numops = (ret+1) - (max - base); + } + } + + if (chunk == 2) { + chunk = 1; + } else { + chunk *= 0.4; + } + + if (options.analyze_continuous && chunk == 0 && options.numops != 1) { + chunk = 1; + } + } while (chunk > 0); + + printf("Reduced to %d ops\n", options.numops); + ret = run_test(ev, lp_ctx); + if (ret != options.numops - 1) { + printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops); + } +} + +/* + start the main gentest process +*/ +static bool start_gentest(struct event_context *ev, + struct loadparm_context *lp_ctx) +{ + int op; + int ret; + + /* allocate the open_handles array */ + open_handles = calloc(options.max_open_handles, sizeof(open_handles[0])); + + srandom(options.seed); + op_parms = calloc(options.numops, sizeof(op_parms[0])); + + /* generate the seeds - after this everything is deterministic */ + if (options.use_preset_seeds) { + int numops; + char **preset = file_lines_load(options.seeds_file, &numops, NULL); + if (!preset) { + printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno)); + exit(1); + } + if (numops < options.numops) { + options.numops = numops; + } + for (op=0;op<options.numops;op++) { + if (!preset[op]) { + printf("Not enough seeds in %s\n", options.seeds_file); + exit(1); + } + op_parms[op].seed = atoi(preset[op]); + } + printf("Loaded %d seeds from %s\n", options.numops, options.seeds_file); + } else { + for (op=0; op<options.numops; op++) { + op_parms[op].seed = random(); + } + } + + ret = run_test(ev, lp_ctx); + + if (ret != options.numops && options.analyze) { + options.numops = ret+1; + backtrack_analyze(ev, lp_ctx); + } else if (options.analyze_always) { + backtrack_analyze(ev, lp_ctx); + } else if (options.analyze_continuous) { + while (run_test(ev, lp_ctx) == options.numops) ; + } + + return ret == options.numops; +} + + +static void usage(poptContext pc) +{ + printf( +"Usage:\n\ + gentest //server1/share1 //server2/share2 [options..]\n\ +"); + poptPrintUsage(pc, stdout, 0); +} + +/** + split a UNC name into server and share names +*/ +static bool split_unc_name(const char *unc, char **server, char **share) +{ + char *p = strdup(unc); + if (!p) return false; + all_string_sub(p, "\\", "/", 0); + if (strncmp(p, "//", 2) != 0) return false; + + (*server) = p+2; + p = strchr(*server, '/'); + if (!p) return false; + + *p = 0; + (*share) = p+1; + + return true; +} + + + +/**************************************************************************** + main program +****************************************************************************/ + int main(int argc, char *argv[]) +{ + int opt; + int i, username_count=0; + bool ret; + char *ignore_file=NULL; + struct event_context *ev; + struct loadparm_context *lp_ctx; + poptContext pc; + int argc_new; + char **argv_new; + enum {OPT_UNCLIST=1000}; + struct poptOption long_options[] = { + POPT_AUTOHELP + {"seed", 0, POPT_ARG_INT, &options.seed, 0, "Seed to use for randomizer", NULL}, + {"num-ops", 0, POPT_ARG_INT, &options.numops, 0, "num ops", NULL}, + {"oplocks", 0, POPT_ARG_NONE, &options.use_oplocks,0, "use oplocks", NULL}, + {"showall", 0, POPT_ARG_NONE, &options.showall, 0, "display all operations", NULL}, + {"analyse", 0, POPT_ARG_NONE, &options.analyze, 0, "do backtrack analysis", NULL}, + {"analysealways", 0, POPT_ARG_NONE, &options.analyze_always, 0, "analysis always", NULL}, + {"analysecontinuous", 0, POPT_ARG_NONE, &options.analyze_continuous, 0, "analysis continuous", NULL}, + {"ignore", 0, POPT_ARG_STRING, &ignore_file, 0, "ignore from file", NULL}, + {"preset", 0, POPT_ARG_NONE, &options.use_preset_seeds, 0, "use preset seeds", NULL}, + {"fast", 0, POPT_ARG_NONE, &options.fast_reconnect, 0, "use fast reconnect", NULL}, + {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL}, + {"seedsfile", 0, POPT_ARG_STRING, &options.seeds_file, 0, "seed file", NULL}, + { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" }, + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + { NULL } + }; + + memset(&bad_smb2_handle, 0xFF, sizeof(bad_smb2_handle)); + + setlinebuf(stdout); + options.seed = time(NULL); + options.numops = 1000; + options.max_open_handles = 20; + options.seeds_file = "gentest_seeds.dat"; + + pc = poptGetContext("gentest", argc, (const char **) argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, "<unc1> <unc2>"); + + lp_ctx = cmdline_lp_ctx; + servers[0].credentials = cli_credentials_init(talloc_autofree_context()); + servers[1].credentials = cli_credentials_init(talloc_autofree_context()); + cli_credentials_guess(servers[0].credentials, lp_ctx); + cli_credentials_guess(servers[1].credentials, lp_ctx); + + while((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case OPT_UNCLIST: + lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc)); + break; + case 'U': + if (username_count == 2) { + usage(pc); + exit(1); + } + cli_credentials_parse_string(servers[username_count].credentials, poptGetOptArg(pc), CRED_SPECIFIED); + username_count++; + break; + } + } + + if (ignore_file) { + options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL); + } + + argv_new = discard_const_p(char *, poptGetArgs(pc)); + argc_new = argc; + for (i=0; i<argc; i++) { + if (argv_new[i] == NULL) { + argc_new = i; + break; + } + } + + if (!(argc_new >= 3)) { + usage(pc); + exit(1); + } + + setlinebuf(stdout); + + setup_logging("gentest", DEBUG_STDOUT); + + if (argc < 3 || argv[1][0] == '-') { + usage(pc); + exit(1); + } + + setup_logging(argv[0], DEBUG_STDOUT); + + for (i=0;i<NSERVERS;i++) { + const char *share = argv[1+i]; + if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) { + printf("Invalid share name '%s'\n", share); + return -1; + } + } + + if (username_count == 0) { + usage(pc); + return -1; + } + if (username_count == 1) { + servers[1].credentials = servers[0].credentials; + } + + printf("seed=%u\n", options.seed); + + ev = event_context_init(talloc_autofree_context()); + + gensec_init(lp_ctx); + + ret = start_gentest(ev, lp_ctx); + + if (ret) { + printf("gentest completed - no errors\n"); + } else { + printf("gentest failed\n"); + } + + return ret?0:-1; +} diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c index ca4d9b7705..5d4acd581b 100644 --- a/source4/torture/ldap/cldap.c +++ b/source4/torture/ldap/cldap.c @@ -41,7 +41,7 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) struct cldap_socket *cldap; NTSTATUS status; struct cldap_netlogon search, empty_search; - union nbt_cldap_netlogon n1; + struct netlogon_samlogon_response n1; struct GUID guid; int i; @@ -51,7 +51,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) search.in.dest_address = dest; search.in.dest_port = lp_cldap_port(tctx->lp_ctx); search.in.acct_control = -1; - search.in.version = 6; + search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + search.in.map_response = true; empty_search = search; @@ -63,7 +64,7 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) n1 = search.out.netlogon; search.in.user = "Administrator"; - search.in.realm = n1.logon5.dns_domain; + search.in.realm = n1.nt5_ex.dns_domain; search.in.host = "__cldap_torture__"; printf("Scanning for netlogon levels\n"); @@ -82,7 +83,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) CHECK_STATUS(status, NT_STATUS_OK); } - search.in.version = 0x20000006; + search.in.version = NETLOGON_NT_VERSION_5|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_IP; + status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); @@ -91,8 +93,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) search.in.user = NULL; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.user_name, ""); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); printf("Trying with User=Administrator\n"); @@ -100,10 +102,10 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC_USER); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); - search.in.version = 6; + search.in.version = NETLOGON_NT_VERSION_5; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); @@ -112,8 +114,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) search.in.user = NULL; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.user_name, ""); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE); printf("Trying with User=Administrator\n"); @@ -121,16 +123,18 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC_USER); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN); + + search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; printf("Trying with a GUID\n"); search.in.realm = NULL; - search.in.domain_guid = GUID_string(tctx, &n1.logon5.domain_uuid); + search.in.domain_guid = GUID_string(tctx, &n1.nt5_ex.domain_uuid); status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC_USER); - CHECK_STRING(GUID_string(tctx, &search.out.netlogon.logon5.domain_uuid), search.in.domain_guid); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); + CHECK_STRING(GUID_string(tctx, &search.out.netlogon.nt5_ex.domain_uuid), search.in.domain_guid); printf("Trying with a incorrect GUID\n"); guid = GUID_random(); @@ -140,33 +144,54 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) CHECK_STATUS(status, NT_STATUS_NOT_FOUND); printf("Trying with a AAC\n"); - search.in.acct_control = 0x180; - search.in.realm = n1.logon5.dns_domain; + search.in.acct_control = ACB_WSTRUST|ACB_SVRTRUST; + search.in.realm = n1.nt5_ex.dns_domain; + status = cldap_netlogon(cldap, tctx, &search); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + + printf("Trying with a zero AAC\n"); + search.in.acct_control = 0x0; + search.in.realm = n1.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2); - CHECK_STRING(search.out.netlogon.logon5.user_name, ""); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + + printf("Trying with a zero AAC and user=Administrator\n"); + search.in.acct_control = 0x0; + search.in.user = "Administrator"; + search.in.realm = n1.nt5_ex.dns_domain; + status = cldap_netlogon(cldap, tctx, &search); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "Administrator"); printf("Trying with a bad AAC\n"); + search.in.user = NULL; search.in.acct_control = 0xFF00FF00; - search.in.realm = n1.logon5.dns_domain; + search.in.realm = n1.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); printf("Trying with a user only\n"); search = empty_search; search.in.user = "Administrator"; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain); - CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user); + CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); printf("Trying with just a bad username\n"); search.in.user = "___no_such_user___"; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user); - CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); + CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); printf("Trying with just a bad domain\n"); search = empty_search; @@ -175,29 +200,29 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) CHECK_STATUS(status, NT_STATUS_NOT_FOUND); printf("Trying with a incorrect domain and correct guid\n"); - search.in.domain_guid = GUID_string(tctx, &n1.logon5.domain_uuid); + search.in.domain_guid = GUID_string(tctx, &n1.nt5_ex.domain_uuid); status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain); - CHECK_STRING(search.out.netlogon.logon5.user_name, ""); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2); + CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); printf("Trying with a incorrect domain and incorrect guid\n"); search.in.domain_guid = GUID_string(tctx, &guid); status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain); - CHECK_STRING(search.out.netlogon.logon5.user_name, ""); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2); + CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); printf("Trying with a incorrect GUID and correct domain\n"); search.in.domain_guid = GUID_string(tctx, &guid); - search.in.realm = n1.logon5.dns_domain; + search.in.realm = n1.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain); - CHECK_STRING(search.out.netlogon.logon5.user_name, ""); - CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2); + CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); return true; } diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk index d7cac101df..cd1c7b1422 100644 --- a/source4/torture/local/config.mk +++ b/source4/torture/local/config.mk @@ -3,8 +3,6 @@ [MODULE::TORTURE_LOCAL] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_local_init -PRIVATE_PROTO_HEADER = \ - proto.h PRIVATE_DEPENDENCIES = \ RPC_NDR_ECHO \ TDR \ @@ -21,32 +19,34 @@ PRIVATE_DEPENDENCIES = \ ################################# TORTURE_LOCAL_OBJ_FILES = \ - lib/charset/tests/iconv.o \ - lib/talloc/testsuite.o \ - lib/replace/test/getifaddrs.o \ - lib/replace/test/os2_delete.o \ - lib/replace/test/strptime.o \ - lib/replace/test/testsuite.o \ - lib/messaging/tests/messaging.o \ - lib/messaging/tests/irpc.o \ - librpc/tests/binding_string.o \ - lib/util/tests/idtree.o \ - lib/socket/testsuite.o \ - lib/socket_wrapper/testsuite.o \ - libcli/resolve/testsuite.o \ - lib/util/tests/strlist.o \ - lib/util/tests/str.o \ - lib/util/tests/file.o \ - lib/util/tests/genrand.o \ - lib/compression/testsuite.o \ - lib/charset/tests/charset.o \ - libcli/security/tests/sddl.o \ - lib/tdr/testsuite.o \ - lib/events/testsuite.o \ - param/tests/share.o \ - param/tests/loadparm.o \ - auth/credentials/tests/simple.o \ - torture/local/local.o \ - torture/local/dbspeed.o \ - torture/local/torture.o + $(torturesrcdir)/../lib/charset/tests/iconv.o \ + $(torturesrcdir)/../lib/talloc/testsuite.o \ + $(torturesrcdir)/../lib/replace/test/getifaddrs.o \ + $(torturesrcdir)/../lib/replace/test/os2_delete.o \ + $(torturesrcdir)/../lib/replace/test/strptime.o \ + $(torturesrcdir)/../lib/replace/test/testsuite.o \ + $(torturesrcdir)/../lib/messaging/tests/messaging.o \ + $(torturesrcdir)/../lib/messaging/tests/irpc.o \ + $(torturesrcdir)/../librpc/tests/binding_string.o \ + $(torturesrcdir)/../lib/util/tests/idtree.o \ + $(torturesrcdir)/../lib/socket/testsuite.o \ + $(torturesrcdir)/../lib/socket_wrapper/testsuite.o \ + $(torturesrcdir)/../libcli/resolve/testsuite.o \ + $(torturesrcdir)/../lib/util/tests/strlist.o \ + $(torturesrcdir)/../lib/util/tests/str.o \ + $(torturesrcdir)/../lib/util/tests/file.o \ + $(torturesrcdir)/../lib/util/tests/genrand.o \ + $(torturesrcdir)/../lib/compression/testsuite.o \ + $(torturesrcdir)/../lib/charset/tests/charset.o \ + $(torturesrcdir)/../libcli/security/tests/sddl.o \ + $(torturesrcdir)/../lib/tdr/testsuite.o \ + $(torturesrcdir)/../lib/events/testsuite.o \ + $(torturesrcdir)/../param/tests/share.o \ + $(torturesrcdir)/../param/tests/loadparm.o \ + $(torturesrcdir)/../auth/credentials/tests/simple.o \ + $(torturesrcdir)/local/local.o \ + $(torturesrcdir)/local/dbspeed.o \ + $(torturesrcdir)/local/torture.o + +$(eval $(call proto_header_template,$(torturesrcdir)/local/proto.h,$(TORTURE_LOCAL_OBJ_FILES:.o=.c))) diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index a3585896eb..f8f9eaf884 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -42,21 +42,24 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot, struct socket_address *src) { NTSTATUS status; - struct nbt_netlogon_packet netlogon; - int *replies = (int *)dgmslot->private; + struct nbt_netlogon_response *netlogon = dgmslot->private; + dgmslot->private = netlogon = talloc(dgmslot, struct nbt_netlogon_response); + + if (!dgmslot->private) { + return; + } + printf("netlogon reply from %s:%d\n", src->addr, src->port); - status = dgram_mailslot_netlogon_parse(dgmslot, dgmslot, packet, &netlogon); + /* Fills in the netlogon pointer */ + status = dgram_mailslot_netlogon_parse_response(dgmslot, netlogon, packet, netlogon); if (!NT_STATUS_IS_OK(status)) { printf("Failed to parse netlogon packet from %s:%d\n", src->addr, src->port); return; } - NDR_PRINT_DEBUG(nbt_netlogon_packet, &netlogon); - - (*replies)++; } @@ -69,10 +72,10 @@ static bool nbt_test_netlogon(struct torture_context *tctx) struct socket_address *dest; const char *myaddress; struct nbt_netlogon_packet logon; + struct nbt_netlogon_response *response; struct nbt_name myname; NTSTATUS status; struct timeval tv = timeval_current(); - int replies = 0; struct socket_address *socket_address; @@ -80,7 +83,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx) struct nbt_name name; struct interface *ifaces; - + name.name = lp_workgroup(tctx->lp_ctx); name.type = NBT_NAME_LOGON; name.scope = NULL; @@ -101,7 +104,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx) /* try receiving replies on port 138 first, which will only work if we are root and smbd/nmbd are not running - fall back to listening on any port, which means replies from - some windows versions won't be seen */ + most windows versions won't be seen */ status = socket_listen(dgmsock->sock, socket_address, 0, 0); if (!NT_STATUS_IS_OK(status)) { talloc_free(socket_address); @@ -114,10 +117,10 @@ static bool nbt_test_netlogon(struct torture_context *tctx) /* setup a temporary mailslot listener for replies */ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, - netlogon_handler, &replies); + netlogon_handler, NULL); ZERO_STRUCT(logon); - logon.command = NETLOGON_QUERY_FOR_PDC; + logon.command = LOGON_PRIMARY_QUERY; logon.req.pdc.computer_name = TEST_NAME; logon.req.pdc.mailslot_name = dgmslot->mailslot_name; logon.req.pdc.unicode_name = TEST_NAME; @@ -132,13 +135,21 @@ static bool nbt_test_netlogon(struct torture_context *tctx) torture_assert(tctx, dest != NULL, "Error getting address"); status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, + NBT_MAILSLOT_NETLOGON, &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && replies == 0) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { event_loop_once(dgmsock->event_ctx); } + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert(tctx, response->response_type == NETLOGON_GET_PDC, "Got incorrect type of netlogon response"); + torture_assert(tctx, response->get_pdc.command == NETLOGON_RESPONSE_FROM_PDC, "Got incorrect netlogon response command"); + return true; } @@ -152,10 +163,10 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) struct socket_address *dest; const char *myaddress; struct nbt_netlogon_packet logon; + struct nbt_netlogon_response *response; struct nbt_name myname; NTSTATUS status; struct timeval tv = timeval_current(); - int replies = 0; struct socket_address *socket_address; @@ -163,6 +174,9 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) struct nbt_name name; struct interface *ifaces; + struct test_join *join_ctx; + struct cli_credentials *machine_credentials; + const struct dom_sid *dom_sid; name.name = lp_workgroup(tctx->lp_ctx); name.type = NBT_NAME_LOGON; @@ -196,18 +210,18 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) /* setup a temporary mailslot listener for replies */ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, - netlogon_handler, &replies); + netlogon_handler, NULL); ZERO_STRUCT(logon); - logon.command = NETLOGON_QUERY_FOR_PDC2; - logon.req.pdc2.request_count = 0; - logon.req.pdc2.computer_name = TEST_NAME; - logon.req.pdc2.user_name = ""; - logon.req.pdc2.mailslot_name = dgmslot->mailslot_name; - logon.req.pdc2.nt_version = 11; - logon.req.pdc2.lmnt_token = 0xFFFF; - logon.req.pdc2.lm20_token = 0xFFFF; + logon.command = LOGON_SAM_LOGON_REQUEST; + logon.req.logon.request_count = 0; + logon.req.logon.computer_name = TEST_NAME; + logon.req.logon.user_name = ""; + logon.req.logon.mailslot_name = dgmslot->mailslot_name; + logon.req.logon.nt_version = NETLOGON_NT_VERSION_5EX_WITH_IP|NETLOGON_NT_VERSION_5|NETLOGON_NT_VERSION_1; + logon.req.logon.lmnt_token = 0xFFFF; + logon.req.logon.lm20_token = 0xFFFF; make_nbt_name_client(&myname, TEST_NAME); @@ -216,40 +230,191 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert(tctx, dest != NULL, "Error getting address"); status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, + NBT_MAILSLOT_NETLOGON, &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && replies == 0) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { event_loop_once(dgmsock->event_ctx); } - return true; -} + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); -/* - reply handler for ntlogon request -*/ -static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot, - struct nbt_dgram_packet *packet, - struct socket_address *src) -{ - NTSTATUS status; - struct nbt_ntlogon_packet ntlogon; - int *replies = (int *)dgmslot->private; + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); - printf("ntlogon reply from %s:%d\n", src->addr, src->port); + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.nt_version, NETLOGON_NT_VERSION_5EX_WITH_IP|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_5|NETLOGON_NT_VERSION_1, "Got incorrect netlogon response command"); - status = dgram_mailslot_ntlogon_parse(dgmslot, dgmslot, packet, &ntlogon); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to parse ntlogon packet from %s:%d\n", - src->addr, src->port); - return; + /* setup (another) temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, NULL); + + ZERO_STRUCT(logon); + logon.command = LOGON_SAM_LOGON_REQUEST; + logon.req.logon.request_count = 0; + logon.req.logon.computer_name = TEST_NAME; + logon.req.logon.user_name = TEST_NAME"$"; + logon.req.logon.mailslot_name = dgmslot->mailslot_name; + logon.req.logon.nt_version = 1; + logon.req.logon.lmnt_token = 0xFFFF; + logon.req.logon.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, + NBT_MAILSLOT_NETLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); + + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + event_loop_once(dgmsock->event_ctx); + } + + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); + + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); + + torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); + + join_ctx = torture_join_domain(tctx, TEST_NAME, + ACB_WSTRUST, &machine_credentials); + + dom_sid = torture_join_sid(join_ctx); + + /* setup (another) temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, NULL); + + ZERO_STRUCT(logon); + logon.command = LOGON_SAM_LOGON_REQUEST; + logon.req.logon.request_count = 0; + logon.req.logon.computer_name = TEST_NAME; + logon.req.logon.user_name = TEST_NAME"$"; + logon.req.logon.mailslot_name = dgmslot->mailslot_name; + logon.req.logon.sid = *dom_sid; + logon.req.logon.nt_version = 1; + logon.req.logon.lmnt_token = 0xFFFF; + logon.req.logon.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, + NBT_MAILSLOT_NETLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); + + + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + event_loop_once(dgmsock->event_ctx); + } + + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); + + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); + + /* setup (another) temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, NULL); + + ZERO_STRUCT(logon); + logon.command = LOGON_SAM_LOGON_REQUEST; + logon.req.logon.request_count = 0; + logon.req.logon.computer_name = TEST_NAME; + logon.req.logon.user_name = TEST_NAME"$"; + logon.req.logon.mailslot_name = dgmslot->mailslot_name; + logon.req.logon.sid = *dom_sid; + logon.req.logon.acct_control = ACB_WSTRUST; + logon.req.logon.nt_version = 1; + logon.req.logon.lmnt_token = 0xFFFF; + logon.req.logon.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, + NBT_MAILSLOT_NETLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); + + + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + event_loop_once(dgmsock->event_ctx); + } + + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); + + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); + + dgmslot->private = NULL; + + ZERO_STRUCT(logon); + logon.command = LOGON_SAM_LOGON_REQUEST; + logon.req.logon.request_count = 0; + logon.req.logon.computer_name = TEST_NAME; + logon.req.logon.user_name = TEST_NAME"$"; + logon.req.logon.mailslot_name = dgmslot->mailslot_name; + logon.req.logon.sid = *dom_sid; + logon.req.logon.acct_control = ACB_NORMAL; + logon.req.logon.nt_version = 1; + logon.req.logon.lmnt_token = 0xFFFF; + logon.req.logon.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, + NBT_MAILSLOT_NETLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); + + + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + event_loop_once(dgmsock->event_ctx); } - NDR_PRINT_DEBUG(nbt_ntlogon_packet, &ntlogon); + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); - (*replies)++; + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); + + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); + + torture_leave_domain(join_ctx); + return true; } @@ -261,15 +426,15 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) lp_iconv_convenience(tctx->lp_ctx)); struct socket_address *dest; struct test_join *join_ctx; - struct cli_credentials *machine_credentials; const struct dom_sid *dom_sid; + struct cli_credentials *machine_credentials; const char *myaddress; - struct nbt_ntlogon_packet logon; + struct nbt_netlogon_packet logon; + struct nbt_netlogon_response *response; struct nbt_name myname; NTSTATUS status; struct timeval tv = timeval_current(); - int replies = 0; struct socket_address *socket_address; const char *address; @@ -296,7 +461,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) /* try receiving replies on port 138 first, which will only work if we are root and smbd/nmbd are not running - fall back to listening on any port, which means replies from - some windows versions won't be seen */ + most windows versions won't be seen */ status = socket_listen(dgmsock->sock, socket_address, 0, 0); if (!NT_STATUS_IS_OK(status)) { talloc_free(socket_address); @@ -309,24 +474,25 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) join_ctx = torture_join_domain(tctx, TEST_NAME, ACB_WSTRUST, &machine_credentials); + dom_sid = torture_join_sid(join_ctx); + torture_assert(tctx, join_ctx != NULL, talloc_asprintf(tctx, "Failed to join domain %s as %s\n", lp_workgroup(tctx->lp_ctx), TEST_NAME)); - dom_sid = torture_join_sid(join_ctx); - /* setup a temporary mailslot listener for replies */ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, - ntlogon_handler, &replies); + netlogon_handler, NULL); ZERO_STRUCT(logon); - logon.command = NTLOGON_SAM_LOGON; + logon.command = LOGON_SAM_LOGON_REQUEST; logon.req.logon.request_count = 0; logon.req.logon.computer_name = TEST_NAME; logon.req.logon.user_name = TEST_NAME"$"; logon.req.logon.mailslot_name = dgmslot->mailslot_name; logon.req.logon.acct_control = ACB_WSTRUST; + /* Try with a SID this time */ logon.req.logon.sid = *dom_sid; logon.req.logon.nt_version = 1; logon.req.logon.lmnt_token = 0xFFFF; @@ -337,15 +503,145 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, address, lp_dgram_port(tctx->lp_ctx)); torture_assert(tctx, dest != NULL, "Error getting address"); - status = dgram_mailslot_ntlogon_send(dgmsock, DGRAM_DIRECT_UNIQUE, - &name, dest, &myname, &logon); + status = dgram_mailslot_netlogon_send(dgmsock, + &name, dest, + NBT_MAILSLOT_NTLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); + + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + event_loop_once(dgmsock->event_ctx); + } + + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); + + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); + + torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); + + + /* setup a temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, NULL); + + + ZERO_STRUCT(logon); + logon.command = LOGON_SAM_LOGON_REQUEST; + logon.req.logon.request_count = 0; + logon.req.logon.computer_name = TEST_NAME; + logon.req.logon.user_name = TEST_NAME"$"; + logon.req.logon.mailslot_name = dgmslot->mailslot_name; + logon.req.logon.acct_control = ACB_WSTRUST; + /* Leave sid as all zero */ + logon.req.logon.nt_version = 1; + logon.req.logon.lmnt_token = 0xFFFF; + logon.req.logon.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, + &name, dest, + NBT_MAILSLOT_NTLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); + + while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + event_loop_once(dgmsock->event_ctx); + } + + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); + map_netlogon_samlogon_response(&response->samlogon); + + torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); + + torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); + + + /* setup (another) temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, NULL); + + ZERO_STRUCT(logon); + logon.command = LOGON_PRIMARY_QUERY; + logon.req.pdc.computer_name = TEST_NAME; + logon.req.pdc.mailslot_name = dgmslot->mailslot_name; + logon.req.pdc.unicode_name = TEST_NAME; + logon.req.pdc.nt_version = 1; + logon.req.pdc.lmnt_token = 0xFFFF; + logon.req.pdc.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, + &name, dest, + NBT_MAILSLOT_NTLOGON, + &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && replies == 0) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { event_loop_once(dgmsock->event_ctx); } + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_GET_PDC, "Got incorrect type of ntlogon response"); + torture_assert_int_equal(tctx, response->get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command"); + torture_leave_domain(join_ctx); + + /* setup (another) temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, NULL); + + ZERO_STRUCT(logon); + logon.command = LOGON_PRIMARY_QUERY; + logon.req.pdc.computer_name = TEST_NAME; + logon.req.pdc.mailslot_name = dgmslot->mailslot_name; + logon.req.pdc.unicode_name = TEST_NAME; + logon.req.pdc.nt_version = 1; + logon.req.pdc.lmnt_token = 0xFFFF; + logon.req.pdc.lm20_token = 0xFFFF; + + make_nbt_name_client(&myname, TEST_NAME); + + dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, + address, lp_dgram_port(tctx->lp_ctx)); + torture_assert(tctx, dest != NULL, "Error getting address"); + status = dgram_mailslot_netlogon_send(dgmsock, + &name, dest, + NBT_MAILSLOT_NTLOGON, + &myname, &logon); + torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); + + while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + event_loop_once(dgmsock->event_ctx); + } + + response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + + torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); + + torture_assert_int_equal(tctx, response->response_type, NETLOGON_GET_PDC, "Got incorrect type of ntlogon response"); + torture_assert_int_equal(tctx, response->get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command"); + + return true; } diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index c6133081b0..0a7fc3ebfd 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -35,6 +35,8 @@ NTSTATUS torture_raw_init(void) torture_suite_add_simple_test(suite, "BENCH-OPEN", torture_bench_open); torture_suite_add_simple_test(suite, "BENCH-LOOKUP", torture_bench_lookup); + torture_suite_add_simple_test(suite, "BENCH-TCON", + torture_bench_treeconnect); torture_suite_add_simple_test(suite, "OFFLINE", torture_test_offline); torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo); torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo); diff --git a/source4/torture/raw/tconrate.c b/source4/torture/raw/tconrate.c new file mode 100644 index 0000000000..6f0ba0d617 --- /dev/null +++ b/source4/torture/raw/tconrate.c @@ -0,0 +1,201 @@ +/* + SMB tree connection rate test + + Copyright (C) 2006-2007 James Peach + + 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 "libcli/libcli.h" +#include "libcli/resolve/resolve.h" +#include "torture/smbtorture.h" +#include "lib/cmdline/popt_common.h" +#include "param/param.h" + +#include "system/filesys.h" +#include "system/shmem.h" + +#define TIME_LIMIT_SECS 30 +#define usec_to_sec(s) ((s) / 1000000) +#define sec_to_usec(s) ((s) * 1000000) + +/* Map a shared memory buffer of at least nelem counters. */ +static void * map_count_buffer(unsigned nelem, size_t elemsz) +{ + void * buf; + size_t bufsz; + size_t pagesz = getpagesize(); + + bufsz = nelem * elemsz; + bufsz = (bufsz + pagesz) % pagesz; /* round up to pagesz */ + +#ifdef MAP_ANON + /* BSD */ + buf = mmap(NULL, bufsz, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, + -1 /* fd */, 0 /* offset */); +#else + buf = mmap(NULL, bufsz, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, + open("/dev/zero", O_RDWR), 0 /* offset */); +#endif + + if (buf == MAP_FAILED) { + printf("failed to map count buffer: %s\n", + strerror(errno)); + return NULL; + } + + return buf; + +} + +static int fork_tcon_client(struct torture_context *tctx, + int *tcon_count, unsigned tcon_timelimit, + const char *host, const char *share) +{ + pid_t child; + struct smbcli_state *cli; + struct timeval end; + struct timeval now; + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); + + child = fork(); + if (child == -1) { + printf("failed to fork child: %s\n,", strerror(errno)); + return -1; + } else if (child != 0) { + /* Parent, just return. */ + return 0; + } + + /* Child. Just make as many connections as possible within the + * time limit. Don't bother synchronising the child start times + * because it's probably not work the effort, and a bit of startup + * jitter is probably a more realistic test. + */ + + + end = timeval_current(); + now = timeval_current(); + end.tv_sec += tcon_timelimit; + *tcon_count = 0; + + while (timeval_compare(&now, &end) == -1) { + NTSTATUS status; + + status = smbcli_full_connection(NULL, &cli, + host, lp_smb_ports(tctx->lp_ctx), share, + NULL, cmdline_credentials, + lp_resolve_context(tctx->lp_ctx), + tctx->ev, &options); + + if (!NT_STATUS_IS_OK(status)) { + printf("failed to connect to //%s/%s: %s\n", + host, share, nt_errstr(status)); + goto done; + } + + smbcli_tdis(cli); + + *tcon_count = *tcon_count + 1; + now = timeval_current(); + } + +done: + exit(0); +} + +static bool children_remain(void) +{ + /* Reap as many children as possible. */ + for (;;) { + pid_t ret = waitpid(-1, NULL, WNOHANG); + if (ret == 0) { + /* no children ready */ + return true; + } + if (ret == -1) { + /* no children left. maybe */ + return errno == ECHILD ? false : true; + } + } + + /* notreached */ + return false; +} + +static double rate_convert_secs(unsigned count, + const struct timeval *start, const struct timeval *end) +{ + return (double)count / + usec_to_sec((double)usec_time_diff(end, start)); +} + +/* Test the rate at which the server will accept connections. */ +bool torture_bench_treeconnect(struct torture_context *tctx) +{ + const char *host = torture_setting_string(tctx, "host", NULL); + const char *share = torture_setting_string(tctx, "share", NULL); + + int timelimit = torture_setting_int(tctx, "timelimit", + TIME_LIMIT_SECS); + int nprocs = torture_setting_int(tctx, "nprocs", 4); + + int *curr_counts = map_count_buffer(nprocs, sizeof(int)); + int *last_counts = talloc_array(NULL, int, nprocs); + + struct timeval now, last, start; + int i, delta; + + torture_assert(tctx, nprocs > 0, "bad proc count"); + torture_assert(tctx, timelimit > 0, "bad timelimit"); + torture_assert(tctx, curr_counts, "allocation failure"); + torture_assert(tctx, last_counts, "allocation failure"); + + start = last = timeval_current(); + for (i = 0; i < nprocs; ++i) { + fork_tcon_client(tctx, &curr_counts[i], timelimit, host, share); + } + + while (children_remain()) { + + sleep(1); + now = timeval_current(); + + for (i = 0, delta = 0; i < nprocs; ++i) { + delta += curr_counts[i] - last_counts[i]; + } + + printf("%u connections/sec\n", + (unsigned)rate_convert_secs(delta, &last, &now)); + + memcpy(last_counts, curr_counts, nprocs * sizeof(int)); + last = timeval_current(); + } + + now = timeval_current(); + + for (i = 0, delta = 0; i < nprocs; ++i) { + delta += curr_counts[i]; + } + + printf("TOTAL: %u connections/sec over %u secs\n", + (unsigned)rate_convert_secs(delta, &start, &now), + timelimit); + return true; +} + +/* vim: set sts=8 sw=8 : */ diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index 00617f4072..989a1faf27 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -288,16 +288,17 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) search.in.dest_address = ctx->drsuapi_binding->host; search.in.dest_port = lp_cldap_port(tctx->lp_ctx); search.in.acct_control = -1; - search.in.version = 6; + search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + search.in.map_response = true; status = cldap_netlogon(cldap, ctx, &search); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); ctx->site_name = talloc_asprintf(ctx, "%s", "Default-First-Site-Name"); printf("cldap_netlogon() returned %s. Defaulting to Site-Name: %s\n", errstr, ctx->site_name); } else { - ctx->site_name = talloc_steal(ctx, search.out.netlogon.logon5.client_site); + ctx->site_name = talloc_steal(ctx, search.out.netlogon.nt5_ex.client_site); printf("cldap_netlogon() returned Client Site-Name: %s.\n",ctx->site_name); - printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.logon5.server_site); + printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.nt5_ex.server_site); } return ret; diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index f0279f0d04..a8f70b2ea9 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -738,6 +738,70 @@ bool torture_rpc_schannel_bench1(struct torture_context *torture) } torture_assert_ntstatus_ok(torture, s->error, "Failed establish a connect"); + /* + * Change the workstation password after establishing the netlogon + * schannel connections to prove that existing connections are not + * affected by a wks pwchange. + */ + + { + struct netr_ServerPasswordSet pwset; + char *password = generate_random_str(s->join_ctx1, 8); + struct creds_CredentialState *creds_state; + struct dcerpc_pipe *net_pipe; + + status = dcerpc_pipe_connect_b(s, &net_pipe, s->b, + &ndr_table_netlogon, + s->wks_creds1, + torture->ev, torture->lp_ctx); + + torture_assert_ntstatus_ok(torture, status, + "dcerpc_pipe_connect_b failed"); + + pwset.in.server_name = talloc_asprintf( + net_pipe, "\\\\%s", dcerpc_server_name(net_pipe)); + pwset.in.computer_name = + cli_credentials_get_workstation(s->wks_creds1); + pwset.in.account_name = talloc_asprintf( + net_pipe, "%s$", pwset.in.computer_name); + pwset.in.secure_channel_type = SEC_CHAN_WKSTA; + E_md4hash(password, pwset.in.new_password.hash); + + creds_state = cli_credentials_get_netlogon_creds( + s->wks_creds1); + creds_des_encrypt(creds_state, &pwset.in.new_password); + creds_client_authenticator(creds_state, &pwset.in.credential); + + status = dcerpc_netr_ServerPasswordSet(net_pipe, torture, &pwset); + torture_assert_ntstatus_ok(torture, status, + "ServerPasswordSet failed"); + + if (!creds_client_check(creds_state, + &pwset.out.return_authenticator.cred)) { + printf("Credential chaining failed\n"); + } + + cli_credentials_set_password(s->wks_creds1, password, + CRED_SPECIFIED); + + talloc_free(net_pipe); + + /* Just as a test, connect with the new creds */ + + talloc_free(s->wks_creds1->netlogon_creds); + s->wks_creds1->netlogon_creds = NULL; + + status = dcerpc_pipe_connect_b(s, &net_pipe, s->b, + &ndr_table_netlogon, + s->wks_creds1, + torture->ev, torture->lp_ctx); + + torture_assert_ntstatus_ok(torture, status, + "dcerpc_pipe_connect_b failed"); + + talloc_free(net_pipe); + } + torture_comment(torture, "Start looping LogonSamLogonEx on %d connections for %d secs\n", s->nprocs, s->timelimit); for (i=0; i < s->nprocs; i++) { diff --git a/source4/torture/smb2/config.mk b/source4/torture/smb2/config.mk index 4e0cac0029..11c4e1fa2c 100644 --- a/source4/torture/smb2/config.mk +++ b/source4/torture/smb2/config.mk @@ -4,14 +4,12 @@ [MODULE::TORTURE_SMB2] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_smb2_init -PRIVATE_PROTO_HEADER = \ - proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_SMB2 POPT_CREDENTIALS # End SUBSYSTEM TORTURE_SMB2 ################################# -TORTURE_SMB2_OBJ_FILES = $(addprefix torture/smb2/, \ +TORTURE_SMB2_OBJ_FILES = $(addprefix $(torturesrcdir)/smb2/, \ connect.o \ scan.o \ util.o \ @@ -24,3 +22,5 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix torture/smb2/, \ persistent_handles.o \ oplocks.o) + +$(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c))) diff --git a/source4/torture/smb2/oplocks.c b/source4/torture/smb2/oplocks.c index b0a1b31d1f..9a06ae1f19 100644 --- a/source4/torture/smb2/oplocks.c +++ b/source4/torture/smb2/oplocks.c @@ -99,7 +99,7 @@ static bool torture_oplock_handler(struct smb2_transport *transport, req = smb2_break_send(tree, &break_info.br); req->async.fn = torture_oplock_break_callback; - req->async.private = NULL; + req->async.private_data = NULL; return true; } diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 6ac3926c98..af4f345104 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -22,6 +22,7 @@ #include "includes.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" +#include "libcli/smb_composite/smb_composite.h" #include "lib/cmdline/popt_common.h" #include "lib/events/events.h" #include "system/time.h" @@ -34,47 +35,6 @@ /* - close a handle with SMB2 -*/ -NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h) -{ - struct smb2_close c; - - ZERO_STRUCT(c); - c.in.file.handle = h; - - return smb2_close(tree, &c); -} - -/* - unlink a file with SMB2 -*/ -NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) -{ - struct smb2_create io; - NTSTATUS status; - - ZERO_STRUCT(io); - io.in.desired_access = SEC_RIGHTS_FILE_ALL; - io.in.file_attributes = FILE_ATTRIBUTE_NORMAL; - io.in.create_disposition = NTCREATEX_DISP_OPEN; - io.in.share_access = - NTCREATEX_SHARE_ACCESS_DELETE| - NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE; - io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; - io.in.fname = fname; - - status = smb2_create(tree, tree, &io); - if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - return NT_STATUS_OK; - } - NT_STATUS_NOT_OK_RETURN(status); - - return smb2_util_close(tree, io.out.file.handle); -} - -/* write to a file on SMB2 */ NTSTATUS smb2_util_write(struct smb2_tree *tree, diff --git a/source4/torture/winbind/config.mk b/source4/torture/winbind/config.mk index ee8ff950a6..15bc51daba 100644 --- a/source4/torture/winbind/config.mk +++ b/source4/torture/winbind/config.mk @@ -4,12 +4,12 @@ [MODULE::TORTURE_WINBIND] SUBSYSTEM = smbtorture INIT_FUNCTION = torture_winbind_init -PRIVATE_PROTO_HEADER = \ - proto.h PRIVATE_DEPENDENCIES = \ LIBWINBIND-CLIENT # End SUBSYSTEM TORTURE_WINBIND ################################# -TORTURE_WINBIND_OBJ_FILES = $(addprefix torture/winbind/, winbind.o struct_based.o) +TORTURE_WINBIND_OBJ_FILES = $(addprefix $(torturesrcdir)/winbind/, winbind.o struct_based.o) + +$(eval $(call proto_header_template,$(torturesrcdir)/winbind/proto.h,$(TORTURE_WINBIND_OBJ_FILES:.o=.c))) diff --git a/source4/utils/config.mk b/source4/utils/config.mk index 13f3b0a145..d47b36ea7c 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -19,9 +19,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY ntlm_auth ################################# -ntlm_auth_OBJ_FILES = utils/ntlm_auth.o +ntlm_auth_OBJ_FILES = $(utilssrcdir)/ntlm_auth.o -MANPAGES += utils/man/ntlm_auth.1 +MANPAGES += $(utilssrcdir)/man/ntlm_auth.1 ################################# # Start BINARY getntacl @@ -34,12 +34,12 @@ PRIVATE_DEPENDENCIES = \ WRAP_XATTR \ LIBSAMBA-ERRORS -getntacl_OBJ_FILES = utils/getntacl.o +getntacl_OBJ_FILES = $(utilssrcdir)/getntacl.o # End BINARY getntacl ################################# -MANPAGES += utils/man/getntacl.1 +MANPAGES += $(utilssrcdir)/man/getntacl.1 ################################# # Start BINARY setntacl @@ -49,7 +49,7 @@ MANPAGES += utils/man/getntacl.1 # End BINARY setntacl ################################# -setntacl_OBJ_FILES = utils/setntacl.o +setntacl_OBJ_FILES = $(utilssrcdir)/setntacl.o ################################# # Start BINARY setnttoken @@ -59,7 +59,7 @@ PRIVATE_DEPENDENCIES = # End BINARY setnttoken ################################# -setnttoken_OBJ_FILES = utils/setnttoken.o +setnttoken_OBJ_FILES = $(utilssrcdir)/setnttoken.o ################################# # Start BINARY nmblookup @@ -76,7 +76,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY nmblookup ################################# -nmblookup_OBJ_FILES = utils/nmblookup.o +nmblookup_OBJ_FILES = $(utilssrcdir)/nmblookup.o ################################# # Start BINARY testparm @@ -93,4 +93,4 @@ PRIVATE_DEPENDENCIES = \ # End BINARY testparm ################################# -testparm_OBJ_FILES = utils/testparm.o +testparm_OBJ_FILES = $(utilssrcdir)/testparm.o diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 4423c44c15..93b51e1e28 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -1,10 +1,9 @@ -# utils/net subsystem +# $(utilssrcdir)/net subsystem ################################# # Start BINARY net [BINARY::net] INSTALLDIR = BINDIR -PRIVATE_PROTO_HEADER = net_proto.h PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -15,7 +14,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY net ################################# -net_OBJ_FILES = $(addprefix utils/net/, \ +net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net.o \ net_password.o \ net_time.o \ @@ -23,3 +22,5 @@ net_OBJ_FILES = $(addprefix utils/net/, \ net_vampire.o \ net_user.o) + +$(eval $(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c))) diff --git a/source4/web_server/config.mk b/source4/web_server/config.mk index 86ad04fb7e..fe78687794 100644 --- a/source4/web_server/config.mk +++ b/source4/web_server/config.mk @@ -5,9 +5,10 @@ [MODULE::WEB] INIT_FUNCTION = server_service_web_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = ESP LIBTLS smbcalls process_model # End SUBSYSTEM WEB ####################### -WEB_OBJ_FILES = $(addprefix web_server/, web_server.o http.o) +WEB_OBJ_FILES = $(addprefix $(web_serversrcdir)/, web_server.o http.o) + +$(eval $(call proto_header_template,$(web_serversrcdir)/proto.h,$(WEB_OBJ_FILES:.o=.c))) diff --git a/source4/winbind/config.mk b/source4/winbind/config.mk index 3c5b740e68..b5eb2c23f0 100644 --- a/source4/winbind/config.mk +++ b/source4/winbind/config.mk @@ -5,7 +5,6 @@ [MODULE::WINBIND] INIT_FUNCTION = server_service_winbind_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = wb_proto.h PRIVATE_DEPENDENCIES = \ WB_HELPER \ IDMAP \ @@ -18,7 +17,7 @@ PRIVATE_DEPENDENCIES = \ # End SUBSYSTEM WINBIND ####################### -WINBIND_OBJ_FILES = $(addprefix winbind/, \ +WINBIND_OBJ_FILES = $(addprefix $(winbindsrcdir)/, \ wb_server.o \ wb_irpc.o \ wb_samba3_protocol.o \ @@ -50,22 +49,26 @@ WINBIND_OBJ_FILES = $(addprefix winbind/, \ wb_pam_auth.o \ wb_sam_logon.o) +$(eval $(call proto_header_template,$(winbindsrcdir)/wb_proto.h,$(WINBIND_OBJ_FILES:.o=.c))) + ################################################ # Start SUBYSTEM WB_HELPER [SUBSYSTEM::WB_HELPER] -PRIVATE_PROTO_HEADER = wb_helper.h PUBLIC_DEPENDENCIES = RPC_NDR_LSA dcerpc_samr # End SUBSYSTEM WB_HELPER ################################################ -WB_HELPER_OBJ_FILES = $(addprefix winbind/, wb_async_helpers.o wb_utils.o) +WB_HELPER_OBJ_FILES = $(addprefix $(winbindsrcdir)/, wb_async_helpers.o wb_utils.o) + +$(eval $(call proto_header_template,$(winbindsrcdir)/wb_helper.h,$(WB_HELPER_OBJ_FILES:.o=.c))) ################################################ # Start SUBYSTEM IDMAP [SUBSYSTEM::IDMAP] -PRIVATE_PROTO_HEADER = idmap_proto.h PUBLIC_DEPENDENCIES = SAMDB_COMMON # End SUBSYSTEM IDMAP ################################################ -IDMAP_OBJ_FILES = winbind/idmap.o +IDMAP_OBJ_FILES = $(winbindsrcdir)/idmap.o + +$(eval $(call proto_header_template,$(winbindsrcdir)/idmap_proto.h,$(IDMAP_OBJ_FILES:.o=.c))) diff --git a/source4/wrepl_server/config.mk b/source4/wrepl_server/config.mk index 6428a353b1..235a897503 100644 --- a/source4/wrepl_server/config.mk +++ b/source4/wrepl_server/config.mk @@ -5,13 +5,12 @@ [MODULE::WREPL_SRV] INIT_FUNCTION = server_service_wrepl_init SUBSYSTEM = smbd -PRIVATE_PROTO_HEADER = wrepl_server_proto.h PRIVATE_DEPENDENCIES = \ LIBCLI_WREPL WINSDB process_model # End SUBSYSTEM WREPL_SRV ####################### -WREPL_SRV_OBJ_FILES = $(addprefix wrepl_server/, \ +WREPL_SRV_OBJ_FILES = $(addprefix $(wrepl_serversrcdir)/, \ wrepl_server.o \ wrepl_in_connection.o \ wrepl_in_call.o \ @@ -22,3 +21,4 @@ WREPL_SRV_OBJ_FILES = $(addprefix wrepl_server/, \ wrepl_out_push.o \ wrepl_out_helpers.o) +$(eval $(call proto_header_template,$(wrepl_serversrcdir)/wrepl_server_proto.h,$(WREPL_SRV_OBJ_FILES:.o=.c))) |