Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into registry
authorJelmer Vernooij <jelmer@samba.org>
Fri, 23 May 2008 13:24:40 +0000 (15:24 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 23 May 2008 13:24:40 +0000 (15:24 +0200)
575 files changed:
.gitignore
howto.txt
source/Makefile
source/auth/auth.py
source/auth/auth_server.c [deleted file]
source/auth/auth_wrap.c
source/auth/config.mk
source/auth/credentials/config.mk
source/auth/credentials/credentials.c
source/auth/credentials/credentials.h
source/auth/credentials/credentials.i
source/auth/credentials/credentials.py
source/auth/credentials/credentials_files.c
source/auth/credentials/credentials_krb5.c
source/auth/credentials/credentials_krb5.h
source/auth/credentials/credentials_ntlm.c
source/auth/credentials/credentials_wrap.c
source/auth/credentials/tests/bindings.py
source/auth/gensec/config.mk
source/auth/gensec/gensec.c
source/auth/gensec/gensec_gssapi.c
source/auth/gensec/gensec_krb5.c
source/auth/gensec/schannel.c
source/auth/gensec/schannel_state.c
source/auth/kerberos/config.mk
source/auth/ntlm/auth.c [moved from source/auth/auth.c with 99% similarity]
source/auth/ntlm/auth_anonymous.c [moved from source/auth/auth_anonymous.c with 98% similarity]
source/auth/ntlm/auth_developer.c [moved from source/auth/auth_developer.c with 99% similarity]
source/auth/ntlm/auth_proto.h [new file with mode: 0644]
source/auth/ntlm/auth_sam.c [moved from source/auth/auth_sam.c with 98% similarity]
source/auth/ntlm/auth_server.c [new file with mode: 0644]
source/auth/ntlm/auth_simple.c [moved from source/auth/auth_simple.c with 96% similarity]
source/auth/ntlm/auth_unix.c [moved from source/auth/auth_unix.c with 99% similarity]
source/auth/ntlm/auth_util.c [moved from source/auth/auth_util.c with 100% similarity]
source/auth/ntlm/auth_winbind.c [moved from source/auth/auth_winbind.c with 99% similarity]
source/auth/ntlm/config.mk [new file with mode: 0644]
source/auth/ntlm/ntlm_check.c [moved from source/auth/ntlm_check.c with 99% similarity]
source/auth/ntlm/ntlm_check.h [new file with mode: 0644]
source/auth/ntlm/pam_errors.c [moved from source/auth/pam_errors.c with 100% similarity]
source/auth/ntlm/pam_errors.h [new file with mode: 0644]
source/auth/ntlmssp/config.mk
source/auth/ntlmssp/ntlmssp.c
source/auth/ntlmssp/ntlmssp_server.c
source/auth/sam.c
source/auth/session.c
source/auth/session.h
source/auth/system_session.c
source/auth/tests/bindings.py
source/build/m4/check_ld.m4
source/build/m4/public.m4
source/build/make/python.mk
source/build/make/rules.mk
source/build/make/templates.mk [new file with mode: 0644]
source/build/smb_build/config_mk.pm
source/build/smb_build/dot.pl
source/build/smb_build/header.pm [deleted file]
source/build/smb_build/input.pm
source/build/smb_build/main.pl
source/build/smb_build/makefile.pm
source/build/smb_build/output.pm
source/build/tests/unixsock.c [deleted file]
source/cldap_server/cldap_server.c
source/cldap_server/config.mk
source/cldap_server/netlogon.c
source/client/cifsdd.c
source/client/cifsdd.h
source/client/cifsddio.c
source/client/client.c
source/client/config.mk
source/cluster/config.mk
source/cluster/ctdb/config.mk
source/cluster/ctdb/include/includes.h
source/configure.ac
source/dsdb/common/sidmap.c
source/dsdb/config.mk
source/dsdb/repl/drepl_service.c
source/dsdb/samdb/cracknames.c
source/dsdb/samdb/ldb_modules/config.mk
source/dsdb/samdb/ldb_modules/samldb.c
source/dsdb/samdb/ldb_modules/update_keytab.c
source/dsdb/samdb/samdb.c
source/dsdb/samdb/samdb.h
source/dsdb/samdb/samdb_privilege.c
source/dynconfig.mk
source/headermap.txt
source/heimdal_build/config.mk
source/kdc/config.mk
source/kdc/hdb-ldb.c
source/kdc/kdc.c
source/kdc/kpasswdd.c
source/ldap_server/config.mk
source/ldap_server/ldap_backend.c
source/ldap_server/ldap_bind.c
source/ldap_server/ldap_server.c
source/lib/appweb/config.mk
source/lib/appweb/mpr/miniMpr.c
source/lib/appweb/mpr/miniMpr.h
source/lib/basic.mk
source/lib/charset/config.mk
source/lib/cmdline/config.mk
source/lib/crypto/config.mk
source/lib/crypto/sha1test.c
source/lib/dbwrap/config.mk
source/lib/events/Makefile.in [new file with mode: 0644]
source/lib/events/autogen.sh [new file with mode: 0755]
source/lib/events/config.mk
source/lib/events/configure.ac [new file with mode: 0644]
source/lib/events/events.c
source/lib/events/events.i
source/lib/events/events.mk [new file with mode: 0644]
source/lib/events/events.pc.in [new file with mode: 0644]
source/lib/events/events.py
source/lib/events/events_epoll.c
source/lib/events/events_select.c
source/lib/events/events_signal.c
source/lib/events/events_standard.c
source/lib/events/events_timed.c
source/lib/events/events_util.c [new file with mode: 0644]
source/lib/events/events_util.h [new file with mode: 0644]
source/lib/events/events_wrap.c
source/lib/events/libevents.m4
source/lib/events/tests.py
source/lib/ldb-samba/config.mk
source/lib/ldb/common/ldb_modules.c
source/lib/ldb/config.mk
source/lib/ldb/ldb.i
source/lib/ldb/ldb.mk
source/lib/ldb/ldb.py
source/lib/ldb/ldb_ildap/ldb_ildap.c
source/lib/ldb/ldb_tdb/ldb_index.c
source/lib/ldb/ldb_wrap.c
source/lib/ldb/python.mk
source/lib/ldb/tests/python/api.py
source/lib/ldb/tests/python/ldap.py
source/lib/ldb/tools/ad2oLschema.c
source/lib/ldb_wrap.c
source/lib/ldb_wrap.h
source/lib/messaging/config.mk
source/lib/messaging/messaging.c
source/lib/messaging/tests/messaging.c
source/lib/nss_wrapper/config.mk
source/lib/policy/adm.h [deleted file]
source/lib/policy/config.mk [deleted file]
source/lib/policy/dumpadm.c [deleted file]
source/lib/policy/lex.c [deleted file]
source/lib/policy/lex.l [deleted file]
source/lib/policy/parse_adm.c [deleted file]
source/lib/policy/parse_adm.h [deleted file]
source/lib/policy/parse_adm.y [deleted file]
source/lib/registry/config.mk
source/lib/registry/hive.c
source/lib/registry/interface.c
source/lib/registry/ldb.c
source/lib/registry/local.c
source/lib/registry/registry.h
source/lib/registry/registry.i
source/lib/registry/registry.py
source/lib/registry/registry_wrap.c
source/lib/registry/samba.c
source/lib/registry/tests/bindings.py
source/lib/registry/tests/hive.c
source/lib/registry/tests/registry.c
source/lib/registry/tools/common.c
source/lib/registry/tools/regdiff.c
source/lib/registry/tools/regpatch.c
source/lib/registry/tools/regshell.c
source/lib/registry/tools/regtree.c
source/lib/replace/README
source/lib/replace/configure.ac
source/lib/replace/getaddrinfo.m4 [deleted file]
source/lib/replace/getifaddrs.m4 [deleted file]
source/lib/replace/inet_aton.m4 [deleted file]
source/lib/replace/inet_ntoa.m4 [deleted file]
source/lib/replace/inet_ntop.m4 [deleted file]
source/lib/replace/inet_pton.m4 [deleted file]
source/lib/replace/libreplace.m4
source/lib/replace/libreplace_cc.m4
source/lib/replace/libreplace_ld.m4
source/lib/replace/libreplace_network.m4 [new file with mode: 0644]
source/lib/replace/replace.c
source/lib/replace/replace.h
source/lib/replace/samba.m4
source/lib/replace/socket.m4 [deleted file]
source/lib/replace/socketpair.m4 [deleted file]
source/lib/replace/system/config.m4
source/lib/replace/system/network.h
source/lib/replace/system/time.h
source/lib/replace/test/testsuite.c
source/lib/samba3/config.mk
source/lib/socket/config.m4
source/lib/socket/config.mk
source/lib/socket/testsuite.c
source/lib/socket_wrapper/config.mk
source/lib/stream/config.mk
source/lib/talloc/testsuite.c
source/lib/tdb/common/traverse.c
source/lib/tdb/configure.ac
source/lib/tdb/python.mk
source/lib/tdb/python/tests/simple.py
source/lib/tdb/tdb.i
source/lib/tdb/tdb.mk
source/lib/tdb/tdb.py
source/lib/tdb/tdb_wrap.c
source/lib/tdr/config.mk
source/lib/tls/config.mk
source/lib/torture/config.mk [new file with mode: 0644]
source/lib/torture/torture.c [moved from source/torture/ui.c with 99% similarity]
source/lib/torture/torture.h [moved from source/torture/ui.h with 100% similarity]
source/lib/torture/torture.pc.in [moved from source/torture/torture.pc.in with 100% similarity]
source/lib/util/config.mk
source/lib/util/tests/str.c
source/lib/util/time.c
source/lib/util/time.h
source/lib/util/util.h
source/libcli/auth/config.mk
source/libcli/cldap/cldap.c
source/libcli/cldap/cldap.h
source/libcli/cliconnect.c
source/libcli/clifile.c
source/libcli/composite/composite.c
source/libcli/composite/composite.h
source/libcli/config.mk
source/libcli/dgram/dgramsocket.c
source/libcli/dgram/libdgram.h
source/libcli/dgram/netlogon.c
source/libcli/dgram/ntlogon.c [deleted file]
source/libcli/ldap/config.mk
source/libcli/ldap/ldap_bind.c
source/libcli/ldap/ldap_client.c
source/libcli/nbt/libnbt.h
source/libcli/nbt/nbtsocket.c
source/libcli/ndr_netlogon.c [new file with mode: 0644]
source/libcli/netlogon.c [new file with mode: 0644]
source/libcli/netlogon.h [new file with mode: 0644]
source/libcli/raw/clisocket.c
source/libcli/raw/clitree.c
source/libcli/raw/interfaces.h
source/libcli/raw/raweas.c
source/libcli/raw/rawfile.c
source/libcli/raw/rawfileinfo.c
source/libcli/raw/rawrequest.c
source/libcli/raw/rawtrans.c
source/libcli/raw/smb.h
source/libcli/resolve/host.c
source/libcli/resolve/nbtlist.c
source/libcli/resolve/resolve.c
source/libcli/security/config.mk
source/libcli/security/security.py
source/libcli/security/security_wrap.c
source/libcli/security/tests/bindings.py
source/libcli/smb2/break.c [new file with mode: 0644]
source/libcli/smb2/config.mk
source/libcli/smb2/connect.c
source/libcli/smb2/create.c
source/libcli/smb2/find.c
source/libcli/smb2/flush.c
source/libcli/smb2/lock.c
source/libcli/smb2/request.c
source/libcli/smb2/session.c
source/libcli/smb2/smb2.h
source/libcli/smb2/transport.c
source/libcli/smb2/util.c [new file with mode: 0644]
source/libcli/smb_composite/connect.c
source/libcli/smb_composite/fetchfile.c
source/libcli/smb_composite/fsinfo.c
source/libcli/smb_composite/sesssetup.c
source/libcli/smb_composite/smb2.c [new file with mode: 0644]
source/libcli/smb_composite/smb_composite.h
source/libcli/swig/libcli_nbt.py
source/libcli/swig/libcli_nbt_wrap.c
source/libcli/swig/libcli_smb.py
source/libcli/swig/libcli_smb_wrap.c
source/libcli/wbclient/config.mk
source/libcli/wrepl/winsrepl.c
source/libnet/config.mk
source/libnet/libnet_become_dc.c
source/libnet/libnet_join.c
source/libnet/libnet_samdump_keytab.c
source/libnet/libnet_samsync_ldb.c
source/libnet/libnet_site.c
source/libnet/libnet_unbecome_dc.c
source/libnet/libnet_user.c
source/libnet/libnet_user.h
source/libnet/libnet_vampire.c
source/libnet/py_net.c
source/librpc/config.mk
source/librpc/idl-deps.pl
source/librpc/idl/dcerpc.idl
source/librpc/idl/drsuapi.idl
source/librpc/idl/nbt.idl
source/librpc/idl/policyagent.idl
source/librpc/idl/security.idl
source/librpc/idl/xattr.idl
source/librpc/ndr/libndr.h
source/librpc/ndr/ndr_basic.c
source/librpc/ndr/ndr_sec_helper.c
source/librpc/rpc/dcerpc.c
source/librpc/rpc/dcerpc.py
source/librpc/rpc/dcerpc_connect.c
source/librpc/rpc/dcerpc_smb2.c
source/librpc/rpc/dcerpc_util.c
source/librpc/rpc/dcerpc_wrap.c
source/librpc/scripts/build_idl.sh [moved from source/script/build_idl.sh with 51% similarity]
source/main.mk
source/nbt_server/config.mk
source/nbt_server/dgram/netlogon.c
source/nbt_server/dgram/request.c
source/nbt_server/irpc.c
source/nbt_server/nbt_server.c
source/nbt_server/wins/winsdb.c
source/nbt_server/wins/winsserver.c
source/nsswitch/config.mk
source/ntptr/config.mk
source/ntptr/ntptr.h
source/ntptr/ntptr_base.c
source/ntptr/simple_ldb/ntptr_simple_ldb.c
source/ntvfs/cifs/vfs_cifs.c
source/ntvfs/common/config.mk
source/ntvfs/common/notify.c
source/ntvfs/config.mk
source/ntvfs/ipc/ipc_rap.c
source/ntvfs/ipc/rap_server.c
source/ntvfs/ipc/vfs_ipc.c
source/ntvfs/ntvfs_base.c
source/ntvfs/ntvfs_generic.c
source/ntvfs/posix/config.mk
source/ntvfs/posix/pvfs_acl.c
source/ntvfs/posix/pvfs_fileinfo.c
source/ntvfs/posix/pvfs_open.c
source/ntvfs/posix/pvfs_qfileinfo.c
source/ntvfs/posix/pvfs_resolve.c
source/ntvfs/posix/pvfs_setfileinfo.c
source/ntvfs/posix/pvfs_streams.c
source/ntvfs/posix/pvfs_xattr.c
source/ntvfs/posix/vfs_posix.c
source/ntvfs/posix/vfs_posix.h
source/ntvfs/smb2/vfs_smb2.c [new file with mode: 0644]
source/ntvfs/sysdep/config.mk
source/ntvfs/sysdep/sys_lease.c
source/ntvfs/sysdep/sys_notify.c
source/ntvfs/unixuid/config.mk
source/param/config.mk
source/param/param.i
source/param/param.py
source/param/param_wrap.c
source/param/share.c
source/param/share.h
source/param/share_classic.c
source/param/share_ldb.c
source/param/tests/bindings.py
source/param/tests/share.c
source/pidl/TODO
source/pidl/config.mk
source/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
source/pidl/lib/Parse/Pidl/Samba4/Python.pm
source/rpc_server/common/server_info.c
source/rpc_server/config.mk
source/rpc_server/dcerpc_server.c
source/rpc_server/drsuapi/dcesrv_drsuapi.c
source/rpc_server/lsa/lsa_init.c
source/rpc_server/lsa/lsa_lookup.c
source/rpc_server/netlogon/dcerpc_netlogon.c
source/rpc_server/samr/dcesrv_samr.c
source/rpc_server/samr/samr_password.c
source/rpc_server/service_rpc.c
source/rpc_server/spoolss/dcesrv_spoolss.c
source/rpc_server/srvsvc/dcesrv_srvsvc.c
source/rpc_server/srvsvc/srvsvc_ntvfs.c
source/rpc_server/winreg/rpc_winreg.c
source/samba4-knownfail
source/samba4-skip
source/script/harness2subunit.pl
source/script/installheader.pl
source/scripting/bin/minschema.py
source/scripting/bin/rpcclient
source/scripting/bin/samba3dump
source/scripting/bin/samr.py [new file with mode: 0755]
source/scripting/bin/subunitrun
source/scripting/bin/winreg.py
source/scripting/ejs/config.mk
source/scripting/ejs/ejsnet/config.mk
source/scripting/ejs/ejsnet/net_ctx.c
source/scripting/ejs/ejsnet/net_user.c
source/scripting/ejs/smbcalls.c
source/scripting/ejs/smbcalls_auth.c
source/scripting/ejs/smbcalls_ldb.c
source/scripting/ejs/smbcalls_nbt.c
source/scripting/ejs/smbcalls_reg.c
source/scripting/ejs/smbcalls_rpc.c
source/scripting/libjs/provision.js [deleted file]
source/scripting/libjs/samr.js [deleted file]
source/scripting/libjs/winreg.js [deleted file]
source/scripting/python/config.m4
source/scripting/python/config.mk
source/scripting/python/misc.i
source/scripting/python/misc.py
source/scripting/python/misc_wrap.c
source/scripting/python/modules.c
source/scripting/python/pyrpc.h
source/scripting/python/pytalloc.c
source/scripting/python/samba/__init__.py
source/scripting/python/samba/getopt.py
source/scripting/python/samba/idmap.py
source/scripting/python/samba/provision.py
source/scripting/python/samba/samba3.py
source/scripting/python/samba/samdb.py
source/scripting/python/samba/tests/dcerpc/registry.py
source/scripting/python/samba/tests/dcerpc/rpcecho.py
source/scripting/python/samba/tests/dcerpc/sam.py
source/scripting/python/samba/tests/dcerpc/unix.py
source/scripting/python/samba/tests/provision.py
source/scripting/python/samba/tests/samdb.py
source/scripting/python/samba/upgrade.py
source/scripting/python/smbpython.c [deleted file]
source/scripting/python/uuidmodule.c
source/selftest/README
source/selftest/Subunit.pm
source/selftest/output/plain.pm
source/selftest/samba4_tests.sh
source/selftest/selftest.pl
source/selftest/target/Samba4.pm
source/setup/enableaccount [changed mode: 0644->0755]
source/setup/idmap_init.ldif
source/setup/krb5.conf [new file with mode: 0644]
source/setup/named.conf
source/setup/newuser
source/setup/provision
source/setup/provision-backend
source/setup/provision-backend.js [deleted file]
source/setup/provision_basedn_modify.ldif
source/setup/secrets_dc.ldif
source/setup/setpassword
source/setup/tests/blackbox_newuser.sh [new file with mode: 0755]
source/setup/tests/blackbox_provision.sh
source/setup/tests/blackbox_setpassword.sh [new file with mode: 0755]
source/setup/upgrade [moved from source/setup/upgrade.py with 92% similarity]
source/setup/vampire.py [deleted file]
source/smb_server/blob.c
source/smb_server/config.mk
source/smb_server/smb/config.mk
source/smb_server/smb/receive.c
source/smb_server/smb/request.c
source/smb_server/smb/sesssetup.c
source/smb_server/smb2/config.mk
source/smb_server/smb2/fileio.c
source/smb_server/smb2/find.c
source/smb_server/smb2/negprot.c
source/smb_server/smb2/smb2_server.h
source/smb_server/smb_server.c
source/smbd/config.mk
source/smbd/process_model.c
source/smbd/process_model.mk
source/smbd/server.c
source/smbd/service_stream.c
source/smbd/service_stream.h
source/static_deps.mk
source/torture/auth/ntlmssp.c
source/torture/basic/base.c
source/torture/basic/locking.c
source/torture/basic/misc.c
source/torture/config.mk
source/torture/gentest.c
source/torture/gentest_smb2.c [new file with mode: 0644]
source/torture/ldap/cldap.c
source/torture/ldap/cldapbench.c
source/torture/ldap/common.c
source/torture/ldap/schema.c
source/torture/ldap/uptodatevector.c
source/torture/libnet/domain.c
source/torture/libnet/libnet.c
source/torture/libnet/libnet_BecomeDC.c
source/torture/libnet/libnet_domain.c
source/torture/libnet/libnet_user.c
source/torture/local/config.mk
source/torture/local/dbspeed.c
source/torture/local/local.c
source/torture/locktest.c
source/torture/locktest2.c
source/torture/masktest.c
source/torture/nbench/nbench.c
source/torture/nbt/browse.c
source/torture/nbt/dgram.c
source/torture/nbt/nbt.c
source/torture/nbt/query.c
source/torture/nbt/register.c
source/torture/nbt/wins.c
source/torture/nbt/winsbench.c
source/torture/nbt/winsreplication.c
source/torture/ndr/ndr.c
source/torture/rap/rap.c
source/torture/raw/composite.c
source/torture/raw/lockbench.c
source/torture/raw/lookuprate.c [new file with mode: 0644]
source/torture/raw/offline.c
source/torture/raw/open.c
source/torture/raw/openbench.c
source/torture/raw/oplock.c
source/torture/raw/raw.c
source/torture/raw/samba3hide.c
source/torture/raw/samba3misc.c
source/torture/raw/streams.c
source/torture/raw/tconrate.c [new file with mode: 0644]
source/torture/rpc/async_bind.c
source/torture/rpc/dfs.c
source/torture/rpc/dssync.c
source/torture/rpc/join.c
source/torture/rpc/rpc.c
source/torture/rpc/rpc.h
source/torture/rpc/samba3rpc.c
source/torture/rpc/samlogon.c
source/torture/rpc/samsync.c
source/torture/rpc/schannel.c
source/torture/rpc/session_key.c
source/torture/rpc/spoolss_notify.c
source/torture/rpc/spoolss_win.c
source/torture/rpc/testjoin.c
source/torture/smb2/config.mk
source/torture/smb2/getinfo.c
source/torture/smb2/lock.c
source/torture/smb2/oplocks.c [new file with mode: 0644]
source/torture/smb2/persistent_handles.c [new file with mode: 0644]
source/torture/smb2/scan.c
source/torture/smb2/smb2.c
source/torture/smb2/util.c
source/torture/smbtorture.c
source/torture/smbtorture.h [moved from source/torture/torture.h with 91% similarity]
source/torture/torture.c
source/torture/unix/unix.c
source/torture/unix/unix_info2.c
source/torture/unix/whoami.c
source/torture/util.h
source/torture/util_smb.c
source/torture/winbind/config.mk
source/torture/winbind/struct_based.c
source/torture/winbind/winbind.c
source/utils/config.mk
source/utils/net/config.mk
source/utils/net/net.c
source/utils/net/net.h
source/utils/net/net_join.c
source/utils/net/net_password.c
source/utils/net/net_time.c
source/utils/net/net_user.c
source/utils/net/net_vampire.c
source/utils/nmblookup.c
source/utils/ntlm_auth.c
source/web_server/config.mk
source/winbind/config.mk
source/winbind/idmap.c
source/winbind/idmap.h
source/winbind/wb_cmd_getpwnam.c
source/winbind/wb_cmd_getpwuid.c
source/winbind/wb_cmd_list_trustdom.c
source/winbind/wb_connect_lsa.c
source/winbind/wb_init_domain.c
source/winbind/wb_samba3_cmd.c
source/winbind/wb_server.c
source/wrepl_server/config.mk
source/wrepl_server/wrepl_in_connection.c
source/wrepl_server/wrepl_server.c
testdata/samba3/provision_samba3sam_templates.ldif
testprogs/blackbox/subunit.sh [new file with mode: 0755]
testprogs/blackbox/test_cifsdd.sh
testprogs/blackbox/test_gentest.sh
testprogs/blackbox/test_kinit.sh
testprogs/blackbox/test_ldb.sh
testprogs/blackbox/test_locktest.sh
testprogs/blackbox/test_masktest.sh
testprogs/blackbox/test_ndrdump.sh [changed mode: 0644->0755]
testprogs/blackbox/test_smbclient.sh
testprogs/blackbox/test_wbinfo.sh [new file with mode: 0755]
testprogs/ejs/echo.js [deleted file]
testprogs/ejs/loadparm.js [deleted file]
testprogs/ejs/resolveName.js [deleted file]
testprogs/ejs/samr.js [deleted file]

index 1ad2e2501f5458a96b8a91cd0e43fec48a9f80b1..1e574f00597ccd17a924c4ad28e0de31da73fc14 100644 (file)
@@ -22,7 +22,6 @@ source/heimdal/lib/des/hcrypto
 source/build/smb_build/config.pm
 source/auth/auth_proto.h
 source/auth/auth_sam.h
-source/auth/pam_errors.h
 source/auth/credentials/credentials_proto.h
 source/auth/gensec/gensec_proto.h
 source/auth/gensec/schannel_proto.h
@@ -195,3 +194,9 @@ source/apidocs
 source/mkconfig.mk
 source/data.mk
 source/librpc/idl-deps
+source/libcli/netlogon_proto.h
+source/libcli/ndr_netlogon_proto.h
+source/foo.tdb
+source/gentest_seeds.dat
+source/templates.ldb
+source/torture.tdb
index d128baa5bd47ca483ab3262b2ad1a2ce573cc259..ae9b0e284845e68f9150640c5ecbcd06f4c9cea2 100644 (file)
--- a/howto.txt
+++ b/howto.txt
@@ -27,7 +27,7 @@ There are 2 methods of doing this:
 
   method 1:  "rsync -avz samba.org::ftp/unpacked/samba_4_0_test/ samba4"
 
-  method 2:  "git clone git://git.samba.org/samba.git samba4; cd samba4; git checkout v4-0-test; cd .."
+  method 2:  "git clone git://git.samba.org/samba.git samba4; cd samba4 && git checkout -b v4-0-test origin/v4-0-test; cd .."
 
 both methods will create a directory called "samba4" in the current
 directory. If you don't have rsync or git then install one of them. 
index f2567e6ac4a36704dd371af1ef945a6b3c85840a..0ee36ec830d62d7f2f54ca2cc371bf08f90bb6aa 100644 (file)
@@ -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
 
index 88675f36266252d4687fcfe3c5f1d11d519d5e89..1a7aa6d0e78c34394a575ec6a1b253db478039e0 100644 (file)
@@ -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.
 
diff --git a/source/auth/auth_server.c b/source/auth/auth_server.c
deleted file mode 100644 (file)
index f200ad9..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Authenticate to a remote server
-   Copyright (C) Andrew Tridgell 1992-1998
-   Copyright (C) Andrew Bartlett 2001
-
-   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"
-
-/****************************************************************************
- Support for server level security.
-****************************************************************************/
-
-static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx, bool unicode, int maxprotocol, struct resolve_context *resolve_ctx)
-{
-       struct smbcli_state *cli = NULL;
-       fstring desthost;
-       struct in_addr dest_ip;
-       const char *p;
-       char *pserver;
-       bool connected_ok = false;
-
-       if (!(cli = smbcli_initialise(cli)))
-               return NULL;
-
-       /* security = server just can't function with spnego */
-       cli->use_spnego = false;
-
-        pserver = talloc_strdup(mem_ctx, lp_passwordserver());
-       p = pserver;
-
-        while(next_token( &p, desthost, LIST_SEP, sizeof(desthost))) {
-               strupper(desthost);
-
-               if(!resolve_name(resolve_ctx, desthost, &dest_ip, 0x20)) {
-                       DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",desthost));
-                       continue;
-               }
-
-               if (ismyip(dest_ip)) {
-                       DEBUG(1,("Password server loop - disabling password server %s\n",desthost));
-                       continue;
-               }
-
-               /* we use a mutex to prevent two connections at once - when a 
-                  Win2k PDC get two connections where one hasn't completed a 
-                  session setup yet it will send a TCP reset to the first 
-                  connection (tridge) */
-
-               if (!grab_server_mutex(desthost)) {
-                       return NULL;
-               }
-
-               if (smbcli_connect(cli, desthost, &dest_ip)) {
-                       DEBUG(3,("connected to password server %s\n",desthost));
-                       connected_ok = true;
-                       break;
-               }
-       }
-
-       if (!connected_ok) {
-               release_server_mutex();
-               DEBUG(0,("password server not available\n"));
-               talloc_free(cli);
-               return NULL;
-       }
-       
-       if (!attempt_netbios_session_request(cli, lp_netbios_name(), 
-                                            desthost, &dest_ip)) {
-               release_server_mutex();
-               DEBUG(1,("password server fails session request\n"));
-               talloc_free(cli);
-               return NULL;
-       }
-       
-       if (strequal(desthost,myhostname(mem_ctx))) {
-               exit_server("Password server loop!");
-       }
-       
-       DEBUG(3,("got session\n"));
-
-       if (!smbcli_negprot(cli, unicode, maxprotocol)) {
-               DEBUG(1,("%s rejected the negprot\n",desthost));
-               release_server_mutex();
-               talloc_free(cli);
-               return NULL;
-       }
-
-       if (cli->protocol < PROTOCOL_LANMAN2 ||
-           !(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
-               DEBUG(1,("%s isn't in user level security mode\n",desthost));
-               release_server_mutex();
-               talloc_free(cli);
-               return NULL;
-       }
-
-       /* Get the first session setup done quickly, to avoid silly 
-          Win2k bugs.  (The next connection to the server will kill
-          this one... 
-       */
-
-       if (!smbcli_session_setup(cli, "", "", 0, "", 0,
-                              "")) {
-               DEBUG(0,("%s rejected the initial session setup (%s)\n",
-                        desthost, smbcli_errstr(cli)));
-               release_server_mutex();
-               talloc_free(cli);
-               return NULL;
-       }
-       
-       release_server_mutex();
-       
-       DEBUG(3,("password server OK\n"));
-       
-       return cli;
-}
-
-/****************************************************************************
- Clean up our allocated cli.
-****************************************************************************/
-
-static void free_server_private_data(void **private_data_pointer) 
-{
-       struct smbcli_state **cli = (struct smbcli_state **)private_data_pointer;
-       if (*cli && (*cli)->initialised) {
-               talloc_free(*cli);
-       }
-}
-
-/****************************************************************************
- Get the challenge out of a password server.
-****************************************************************************/
-
-static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_context,
-                                          void **my_private_data, 
-                                          TALLOC_CTX *mem_ctx)
-{
-       struct smbcli_state *cli = server_cryptkey(mem_ctx, lp_cli_maxprotocol(auth_context->lp_ctx));
-       
-       if (cli) {
-               DEBUG(3,("using password server validation\n"));
-
-               if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) == 0) {
-                       /* We can't work with unencrypted password servers
-                          unless 'encrypt passwords = no' */
-                       DEBUG(5,("make_auth_info_server: Server is unencrypted, no challenge available..\n"));
-                       
-                       /* However, it is still a perfectly fine connection
-                          to pass that unencrypted password over */
-                       *my_private_data = (void *)cli;
-                       return data_blob(NULL, 0);
-                       
-               } else if (cli->secblob.length < 8) {
-                       /* We can't do much if we don't get a full challenge */
-                       DEBUG(2,("make_auth_info_server: Didn't receive a full challenge from server\n"));
-                       talloc_free(cli);
-                       return data_blob(NULL, 0);
-               }
-
-               *my_private_data = (void *)cli;
-
-               /* The return must be allocated on the caller's mem_ctx, as our own will be
-                  destoyed just after the call. */
-               return data_blob_talloc(auth_context->mem_ctx, cli->secblob.data,8);
-       } else {
-               return data_blob(NULL, 0);
-       }
-}
-
-
-/****************************************************************************
- Check for a valid username and password in security=server mode.
-  - Validate a password with the password server.
-****************************************************************************/
-
-static NTSTATUS check_smbserver_security(const struct auth_context *auth_context,
-                                        void *my_private_data, 
-                                        TALLOC_CTX *mem_ctx,
-                                        const auth_usersupplied_info *user_info, 
-                                        auth_serversupplied_info **server_info)
-{
-       struct smbcli_state *cli;
-       static uint8_t badpass[24];
-       static fstring baduser; 
-       static bool tested_password_server = false;
-       static bool bad_password_server = false;
-       NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
-       bool locally_made_cli = false;
-
-       /* 
-        * Check that the requested domain is not our own machine name.
-        * If it is, we should never check the PDC here, we use our own local
-        * password file.
-        */
-
-       if (lp_is_myname(auth_context->lp_ctx, user_info->domain.str)) {
-               DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
-               return NT_STATUS_LOGON_FAILURE;
-       }
-
-       cli = my_private_data;
-       
-       if (cli) {
-       } else {
-               cli = server_cryptkey(mem_ctx, lp_unicode(auth_context->lp_ctx), lp_cli_maxprotocol(auth_context->lp_ctx), lp_resolve_context(auth_context->lp_ctx));
-               locally_made_cli = true;
-       }
-
-       if (!cli || !cli->initialised) {
-               DEBUG(1,("password server is not connected (cli not initilised)\n"));
-               return NT_STATUS_LOGON_FAILURE;
-       }  
-       
-       if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) == 0) {
-               if (user_info->encrypted) {
-                       DEBUG(1,("password server %s is plaintext, but we are encrypted. This just can't work :-(\n", cli->desthost));
-                       return NT_STATUS_LOGON_FAILURE;         
-               }
-       } else {
-               if (memcmp(cli->secblob.data, auth_context->challenge.data, 8) != 0) {
-                       DEBUG(1,("the challenge that the password server (%s) supplied us is not the one we gave our client. This just can't work :-(\n", cli->desthost));
-                       return NT_STATUS_LOGON_FAILURE;         
-               }
-       }
-
-       if(badpass[0] == 0)
-               memset(badpass, 0x1f, sizeof(badpass));
-
-       if((user_info->nt_resp.length == sizeof(badpass)) && 
-          !memcmp(badpass, user_info->nt_resp.data, sizeof(badpass))) {
-               /* 
-                * Very unlikely, our random bad password is the same as the users
-                * password.
-                */
-               memset(badpass, badpass[0]+1, sizeof(badpass));
-       }
-
-       if(baduser[0] == 0) {
-               fstrcpy(baduser, INVALID_USER_PREFIX);
-               fstrcat(baduser, lp_netbios_name());
-       }
-
-       /*
-        * Attempt a session setup with a totally incorrect password.
-        * If this succeeds with the guest bit *NOT* set then the password
-        * server is broken and is not correctly setting the guest bit. We
-        * need to detect this as some versions of NT4.x are broken. JRA.
-        */
-
-       /* I sure as hell hope that there aren't servers out there that take 
-        * NTLMv2 and have this bug, as we don't test for that... 
-        *  - abartlet@samba.org
-        */
-
-       if ((!tested_password_server) && (lp_paranoid_server_security())) {
-               if (smbcli_session_setup(cli, baduser, (char *)badpass, sizeof(badpass), 
-                                       (char *)badpass, sizeof(badpass), user_info->domain.str)) {
-
-                       /*
-                        * We connected to the password server so we
-                        * can say we've tested it.
-                        */
-                       tested_password_server = true;
-
-                       if ((SVAL(cli->inbuf,smb_vwv2) & 1) == 0) {
-                               DEBUG(0,("server_validate: password server %s allows users as non-guest \
-with a bad password.\n", cli->desthost));
-                               DEBUG(0,("server_validate: This is broken (and insecure) behaviour. Please do not \
-use this machine as the password server.\n"));
-                               smbcli_ulogoff(cli);
-
-                               /*
-                                * Password server has the bug.
-                                */
-                               bad_password_server = true;
-                               return NT_STATUS_LOGON_FAILURE;
-                       }
-                       smbcli_ulogoff(cli);
-               }
-       } else {
-
-               /*
-                * We have already tested the password server.
-                * Fail immediately if it has the bug.
-                */
-
-               if(bad_password_server) {
-                       DEBUG(0,("server_validate: [1] password server %s allows users as non-guest \
-with a bad password.\n", cli->desthost));
-                       DEBUG(0,("server_validate: [1] This is broken (and insecure) behaviour. Please do not \
-use this machine as the password server.\n"));
-                       return NT_STATUS_LOGON_FAILURE;
-               }
-       }
-
-       /*
-        * Now we know the password server will correctly set the guest bit, or is
-        * not guest enabled, we can try with the real password.
-        */
-
-       if (!user_info->encrypted) {
-               /* Plaintext available */
-               if (!smbcli_session_setup(cli, user_info->smb_name.str, 
-                                      (char *)user_info->plaintext_password.data, 
-                                      user_info->plaintext_password.length, 
-                                      NULL, 0,
-                                      user_info->domain.str)) {
-                       DEBUG(1,("password server %s rejected the password\n", cli->desthost));
-                       /* Make this smbcli_nt_error() when the conversion is in */
-                       nt_status = smbcli_nt_error(cli);
-               } else {
-                       nt_status = NT_STATUS_OK;
-               }
-       } else {
-               if (!smbcli_session_setup(cli, user_info->smb_name.str, 
-                                      (char *)user_info->lm_resp.data, 
-                                      user_info->lm_resp.length, 
-                                      (char *)user_info->nt_resp.data, 
-                                      user_info->nt_resp.length, 
-                                      user_info->domain.str)) {
-                       DEBUG(1,("password server %s rejected the password\n", cli->desthost));
-                       /* Make this smbcli_nt_error() when the conversion is in */
-                       nt_status = smbcli_nt_error(cli);
-               } else {
-                       nt_status = NT_STATUS_OK;
-               }
-       }
-
-       /* if logged in as guest then reject */
-       if ((SVAL(cli->inbuf,smb_vwv2) & 1) != 0) {
-               DEBUG(1,("password server %s gave us guest only\n", cli->desthost));
-               nt_status = NT_STATUS_LOGON_FAILURE;
-       }
-
-       smbcli_ulogoff(cli);
-
-       if NT_STATUS_IS_OK(nt_status) {
-               struct passwd *pass = Get_Pwnam(user_info->internal_username.str);
-               if (pass) {
-                       nt_status = make_server_info_pw(auth_context, server_info, pass);
-               } else {
-                       nt_status = NT_STATUS_NO_SUCH_USER;
-               }
-       }
-
-       if (locally_made_cli) {
-               talloc_free(cli);
-       }
-
-       return(nt_status);
-}
-
-NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* param, auth_methods **auth_method) 
-{
-       if (!make_auth_methods(auth_context, auth_method)) {
-               return NT_STATUS_NO_MEMORY;
-       }
-       (*auth_method)->name = "smbserver";
-       (*auth_method)->auth = check_smbserver_security;
-       (*auth_method)->get_chal = auth_get_challenge_server;
-       (*auth_method)->send_keepalive = send_server_keepalive;
-       (*auth_method)->free_private_data = free_server_private_data;
-       return NT_STATUS_OK;
-}
index af1827adc94e4161af21d8c511ca30c2a02983be..dea76ef87d26e93af15b3ddbc26e62e9cad253c2 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2505,7 +2523,7 @@ static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
 
 #define SWIG_name    "_auth"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2733,7 +2751,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -2743,6 +2761,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 */
@@ -2771,6 +2792,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);
index 7d4678b7ac4be15a66da0f58196cace76d4a4a4e..f13c2e5758993e283b6330899a62084ddd5da129 100644 (file)
 # auth server subsystem
+gensecsrcdir := $(authsrcdir)/gensec
 mkinclude gensec/config.mk
 mkinclude kerberos/config.mk
 mkinclude ntlmssp/config.mk
+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 ntlm_check.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)
-
-#######################
-# Start MODULE auth_sam
-[MODULE::auth_sam_module]
-# gensec_krb5 and gensec_gssapi depend on it
-INIT_FUNCTION = auth_sam_init
-SUBSYSTEM = auth
-PRIVATE_DEPENDENCIES = \
-               SAMDB auth_sam
-# End MODULE auth_sam
-#######################
-
-auth_sam_module_OBJ_FILES = $(addprefix auth/, auth_sam.o)
-
-#######################
-# Start MODULE auth_anonymous
-[MODULE::auth_anonymous]
-INIT_FUNCTION = auth_anonymous_init
-SUBSYSTEM = auth
-# End MODULE auth_anonymous
-#######################
-
-auth_anonymous_OBJ_FILES = $(addprefix auth/, auth_anonymous.o)
-
-#######################
-# Start MODULE auth_winbind
-[MODULE::auth_winbind]
-INIT_FUNCTION = auth_winbind_init
-SUBSYSTEM = auth
-PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING LIBWINBIND-CLIENT
-# End MODULE auth_winbind
-#######################
-
-auth_winbind_OBJ_FILES = $(addprefix auth/, auth_winbind.o)
-
-#######################
-# Start MODULE auth_developer
-[MODULE::auth_developer]
-INIT_FUNCTION = auth_developer_init
-SUBSYSTEM = auth
-# End MODULE auth_developer
-#######################
-
-auth_developer_OBJ_FILES = $(addprefix auth/, 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/, 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/, 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/, auth.o auth_util.o auth_simple.o)
-
-# PUBLIC_HEADERS += auth/auth.h
+
+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]
+LIBRARY_REALNAME = samba/_auth.$(SHLIBEXT)
 PUBLIC_DEPENDENCIES = auth_system_session
 PRIVATE_DEPENDENCIES = SAMDB 
-SWIG_FILE = auth.i
 
-swig_auth_OBJ_FILES = auth/auth_wrap.o
+$(eval $(call python_py_module_template,samba/auth.py,$(authsrcdir)/auth.py))
+
+swig_auth_OBJ_FILES = $(authsrcdir)/auth_wrap.o
+
+$(swig_auth_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
index 6f3ec3997c762e5dc62055c79edd2c5456d93839..2eeeec20ecf7eebf68ad92dd9305b5a0667dfede 100644 (file)
@@ -1,18 +1,24 @@
 #################################
 # 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]
+LIBRARY_REALNAME = samba/_credentials.$(SHLIBEXT)
 PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS
-SWIG_FILE = credentials.i
 
-swig_credentials_OBJ_FILES = auth/credentials/credentials_wrap.o
+$(eval $(call python_py_module_template,samba/credentials.py,$(authsrcdir)/credentials/credentials.py))
+
+swig_credentials_OBJ_FILES = $(authsrcdir)/credentials/credentials_wrap.o
+
+$(swig_credentials_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
index 89dddc9e0585408dde0bfa412030e68ebb363ad3..adabe49cb4f3a42a8d6bf72f601d1054fb8dd06d 100644 (file)
@@ -65,7 +65,6 @@ _PUBLIC_ struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx)
 
        cred->tries = 3;
        cred->callback_running = false;
-       cred->ev = NULL;
 
        cli_credentials_set_kerberos_state(cred, CRED_AUTO_USE_KERBEROS);
        cli_credentials_set_gensec_features(cred, 0);
@@ -307,6 +306,8 @@ _PUBLIC_ bool cli_credentials_set_password(struct cli_credentials *cred,
                cli_credentials_invalidate_ccache(cred, cred->password_obtained);
 
                cred->nt_hash = NULL;
+               cred->lm_response = data_blob(NULL, 0);
+               cred->nt_response = data_blob(NULL, 0);
                return true;
        }
 
@@ -377,24 +378,6 @@ _PUBLIC_ const struct samr_Password *cli_credentials_get_nt_hash(struct cli_cred
        }
 }
 
-_PUBLIC_ bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
-                                const struct samr_Password *nt_hash, 
-                                enum credentials_obtained obtained)
-{
-       if (obtained >= cred->password_obtained) {
-               cli_credentials_set_password(cred, NULL, obtained);
-               if (nt_hash) {
-                       cred->nt_hash = talloc(cred, struct samr_Password);
-                       *cred->nt_hash = *nt_hash;
-               } else {
-                       cred->nt_hash = NULL;
-               }
-               return true;
-       }
-
-       return false;
-}
-
 /**
  * Obtain the 'short' or 'NetBIOS' domain for this credentials context.
  * @param cred credentials context
@@ -675,7 +658,7 @@ _PUBLIC_ void cli_credentials_guess(struct cli_credentials *cred,
        }
        
        if (cli_credentials_get_kerberos_state(cred) != CRED_DONT_USE_KERBEROS) {
-               cli_credentials_set_ccache(cred, lp_ctx, NULL, CRED_GUESS_FILE);
+               cli_credentials_set_ccache(cred, event_context_find(cred), lp_ctx, NULL, CRED_GUESS_FILE);
        }
 }
 
@@ -775,22 +758,3 @@ _PUBLIC_ bool cli_credentials_wrong_password(struct cli_credentials *cred)
 
        return (cred->tries > 0);
 }
-
-/*
-  set the common event context for this set of credentials
- */
-_PUBLIC_ void cli_credentials_set_event_context(struct cli_credentials *cred, struct event_context *ev)
-{
-       cred->ev = ev;
-}
-
-/*
-  set the common event context for this set of credentials
- */
-_PUBLIC_ struct event_context *cli_credentials_get_event_context(struct cli_credentials *cred)
-{
-       if (cred->ev == NULL) {
-               cred->ev = event_context_find(cred);
-       }
-       return cred->ev;
-}
index afcb300638388d19f43f5047e7bbb7fee9a8aa6a..79c50ae5afff236b4df2546f5f0b44e063409ecb 100644 (file)
@@ -26,6 +26,7 @@
 #include "librpc/gen_ndr/misc.h"
 
 struct ccache_container;
+struct event_context;
 
 /* In order of priority */
 enum credentials_obtained { 
@@ -79,8 +80,13 @@ struct cli_credentials {
 
        const char *bind_dn;
 
+       /* Allows authentication from a keytab or similar */
        struct samr_Password *nt_hash;
 
+       /* Allows NTLM pass-though authentication */
+       DATA_BLOB lm_response;
+       DATA_BLOB nt_response;
+
        struct ccache_container *ccache;
        struct gssapi_creds_container *client_gss_creds;
        struct keytab_container *keytab;
@@ -121,9 +127,6 @@ struct cli_credentials {
 
        /* Whether any callback is currently running */
        bool callback_running;
-
-       /* an event context for anyone wanting to use the credentials */
-       struct event_context *ev;
 };
 
 struct ldb_context;
@@ -152,12 +155,15 @@ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred, TALLOC_
 const char *cli_credentials_get_realm(struct cli_credentials *cred);
 const char *cli_credentials_get_username(struct cli_credentials *cred);
 int cli_credentials_get_krb5_context(struct cli_credentials *cred, 
+                                    struct event_context *event_ctx,
                                     struct loadparm_context *lp_ctx,
                                     struct smb_krb5_context **smb_krb5_context);
 int cli_credentials_get_ccache(struct cli_credentials *cred, 
+                              struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               struct ccache_container **ccc);
 int cli_credentials_get_keytab(struct cli_credentials *cred, 
+                              struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               struct keytab_container **_ktc);
 const char *cli_credentials_get_domain(struct cli_credentials *cred);
@@ -168,15 +174,15 @@ void cli_credentials_set_conf(struct cli_credentials *cred,
                              struct loadparm_context *lp_ctx);
 const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_CTX *mem_ctx);
 int cli_credentials_get_server_gss_creds(struct cli_credentials *cred, 
+                                        struct event_context *event_ctx,
                                         struct loadparm_context *lp_ctx,
                                         struct gssapi_creds_container **_gcc);
 int cli_credentials_get_client_gss_creds(struct cli_credentials *cred, 
+                                        struct event_context *event_ctx,
                                         struct loadparm_context *lp_ctx,
                                         struct gssapi_creds_container **_gcc);
-void cli_credentials_set_event_context(struct cli_credentials *cred, struct event_context *ev);
 void cli_credentials_set_kerberos_state(struct cli_credentials *creds, 
                                        enum credentials_use_kerberos use_kerberos);
-struct event_context *cli_credentials_get_event_context(struct cli_credentials *cred);
 bool cli_credentials_set_domain(struct cli_credentials *cred, 
                                const char *val, 
                                enum credentials_obtained obtained);
@@ -199,6 +205,7 @@ void cli_credentials_set_netlogon_creds(struct cli_credentials *cred,
 NTSTATUS cli_credentials_set_krb5_context(struct cli_credentials *cred, 
                                          struct smb_krb5_context *smb_krb5_context);
 NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
+                                             struct event_context *event_ctx,
                                              struct loadparm_context *lp_ctx,
                                              const char *serviceprincipal);
 NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cred,
@@ -219,15 +226,22 @@ void cli_credentials_set_kvno(struct cli_credentials *cred,
 bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
                                 const struct samr_Password *nt_hash, 
                                 enum credentials_obtained obtained);
+bool cli_credentials_set_ntlm_response(struct cli_credentials *cred,
+                                      const DATA_BLOB *lm_response, 
+                                      const DATA_BLOB *nt_response, 
+                                      enum credentials_obtained obtained);
 int cli_credentials_set_keytab_name(struct cli_credentials *cred, 
+                                   struct event_context *event_ctx,
                                    struct loadparm_context *lp_ctx,
                                    const char *keytab_name, 
                                    enum credentials_obtained obtained);
 int cli_credentials_update_keytab(struct cli_credentials *cred, 
+                                 struct event_context *event_ctx,
                                  struct loadparm_context *lp_ctx);
 void cli_credentials_set_gensec_features(struct cli_credentials *creds, uint32_t gensec_features);
 uint32_t cli_credentials_get_gensec_features(struct cli_credentials *creds);
 int cli_credentials_set_ccache(struct cli_credentials *cred, 
+                              struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               const char *name, 
                               enum credentials_obtained obtained);
@@ -239,6 +253,7 @@ void cli_credentials_invalidate_ccache(struct cli_credentials *cred,
 void cli_credentials_set_salt_principal(struct cli_credentials *cred, const char *principal);
 enum credentials_use_kerberos cli_credentials_get_kerberos_state(struct cli_credentials *creds);
 NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred, 
+                                    struct event_context *event_ctx,
                                     struct loadparm_context *lp_ctx,
                                     struct ldb_context *ldb,
                                     const char *base,
index 152d2e673ccd84c1b5ab2fabea7ed7b2c1690b6b..89eb4924b307a519b647813682172d9eebdae2e1 100644 (file)
@@ -59,36 +59,53 @@ typedef struct cli_credentials {
             return cli_credentials_init(NULL);
         }
         /* username */
+        %feature("docstring") get_username "S.get_username() -> username\nObtain username.";
         const char *get_username(void);
+        %feature("docstring") set_username "S.set_username(name, obtained=CRED_SPECIFIED) -> None\nChange username.";
         bool set_username(const char *value, 
-                          enum credentials_obtained=CRED_SPECIFIED);
+                          enum credentials_obtained obtained=CRED_SPECIFIED);
 
         /* password */
+        %feature("docstring") get_password "S.get_password() -> password\n" \
+                                           "Obtain password.";
         const char *get_password(void);
+        %feature("docstring") set_password "S.set_password(password, obtained=CRED_SPECIFIED) -> None\n" \
+                                           "Change password.";
         bool set_password(const char *val, 
-                          enum credentials_obtained=CRED_SPECIFIED);
+                          enum credentials_obtained obtained=CRED_SPECIFIED);
 
         /* domain */
+        %feature("docstring") get_password "S.get_domain() -> domain\nObtain domain name.";
         const char *get_domain(void);
+        %feature("docstring") set_domain "S.set_domain(domain, obtained=CRED_SPECIFIED) -> None\n" \
+                                         "Change domain name.";
         bool set_domain(const char *val, 
-                        enum credentials_obtained=CRED_SPECIFIED);
+                        enum credentials_obtained obtained=CRED_SPECIFIED);
 
         /* realm */
+        %feature("docstring") get_realm "S.get_realm() -> realm\nObtain realm name.";
         const char *get_realm(void);
+        %feature("docstring") set_realm "S.set_realm(realm, obtained=CRED_SPECIFIED) -> None\n" \
+                                        "Change realm name.";
         bool set_realm(const char *val, 
-                       enum credentials_obtained=CRED_SPECIFIED);
+                       enum credentials_obtained obtained=CRED_SPECIFIED);
 
-       /* Kerberos */
+        /* Kerberos */
         void set_kerberos_state(enum credentials_use_kerberos use_kerberos);
 
+        %feature("docstring") parse_string "S.parse_string(text, obtained=CRED_SPECIFIED) -> None\n" \
+                                           "Parse credentials string.";
         void parse_string(const char *text,
-                         enum credentials_obtained=CRED_SPECIFIED);
+                          enum credentials_obtained obtained=CRED_SPECIFIED);
 
         /* bind dn */
+        %feature("docstring") get_bind_dn "S.get_bind_dn() -> bind dn\nObtain bind DN.";
         const char *get_bind_dn(void);
+        %feature("docstring") set_bind_dn "S.set_bind_dn(bind_dn) -> None\nChange bind DN.";
         bool set_bind_dn(const char *bind_dn);
 
-       void set_anonymous();
+        %feature("docstring") set_anonymous "S.set_anonymous() -> None\nUse anonymous credentials.";
+        void set_anonymous();
 
         /* workstation name */
         const char *get_workstation(void);
@@ -104,8 +121,10 @@ typedef struct cli_credentials {
 
         bool authentication_requested(void);
 
+        %feature("docstring") wrong_password "S.wrong_password() -> bool\nIndicate the returned password was incorrect.";
         bool wrong_password(void);
 
+        %feature("docstring") set_cmdline_callbacks "S.set_cmdline_callbacks() -> bool\nUse command-line to obtain credentials not explicitly set.";
         bool set_cmdline_callbacks();
     }
 } cli_credentials;
index ba0000dcda889236189d555154e2fc202830b44d..fd00a8e6f0876fc6f7145452586150c1c8b9d452 100644 (file)
@@ -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.
 
@@ -66,6 +66,97 @@ class Credentials(object):
     __repr__ = _swig_repr
     def __init__(self, *args, **kwargs): 
         _credentials.Credentials_swiginit(self,_credentials.new_Credentials(*args, **kwargs))
+    def get_username(*args, **kwargs):
+        """
+        S.get_username() -> username
+        Obtain username.
+        """
+        return _credentials.Credentials_get_username(*args, **kwargs)
+
+    def set_username(*args, **kwargs):
+        """
+        S.set_username(name, obtained=CRED_SPECIFIED) -> None
+        Change username.
+        """
+        return _credentials.Credentials_set_username(*args, **kwargs)
+
+    def get_password(*args, **kwargs):
+        """
+        S.get_password() -> password
+        Obtain password.
+        """
+        return _credentials.Credentials_get_password(*args, **kwargs)
+
+    def set_password(*args, **kwargs):
+        """
+        S.set_password(password, obtained=CRED_SPECIFIED) -> None
+        Change password.
+        """
+        return _credentials.Credentials_set_password(*args, **kwargs)
+
+    def set_domain(*args, **kwargs):
+        """
+        S.set_domain(domain, obtained=CRED_SPECIFIED) -> None
+        Change domain name.
+        """
+        return _credentials.Credentials_set_domain(*args, **kwargs)
+
+    def get_realm(*args, **kwargs):
+        """
+        S.get_realm() -> realm
+        Obtain realm name.
+        """
+        return _credentials.Credentials_get_realm(*args, **kwargs)
+
+    def set_realm(*args, **kwargs):
+        """
+        S.set_realm(realm, obtained=CRED_SPECIFIED) -> None
+        Change realm name.
+        """
+        return _credentials.Credentials_set_realm(*args, **kwargs)
+
+    def parse_string(*args, **kwargs):
+        """
+        S.parse_string(text, obtained=CRED_SPECIFIED) -> None
+        Parse credentials string.
+        """
+        return _credentials.Credentials_parse_string(*args, **kwargs)
+
+    def get_bind_dn(*args, **kwargs):
+        """
+        S.get_bind_dn() -> bind dn
+        Obtain bind DN.
+        """
+        return _credentials.Credentials_get_bind_dn(*args, **kwargs)
+
+    def set_bind_dn(*args, **kwargs):
+        """
+        S.set_bind_dn(bind_dn) -> None
+        Change bind DN.
+        """
+        return _credentials.Credentials_set_bind_dn(*args, **kwargs)
+
+    def set_anonymous(*args, **kwargs):
+        """
+        S.set_anonymous() -> None
+        Use anonymous credentials.
+        """
+        return _credentials.Credentials_set_anonymous(*args, **kwargs)
+
+    def wrong_password(*args, **kwargs):
+        """
+        S.wrong_password() -> bool
+        Indicate the returned password was incorrect.
+        """
+        return _credentials.Credentials_wrong_password(*args, **kwargs)
+
+    def set_cmdline_callbacks(*args, **kwargs):
+        """
+        S.set_cmdline_callbacks() -> bool
+        Use command-line to obtain credentials not explicitly set.
+        """
+        return _credentials.Credentials_set_cmdline_callbacks(*args, **kwargs)
+
     __swig_destroy__ = _credentials.delete_Credentials
 Credentials.get_username = new_instancemethod(_credentials.Credentials_get_username,None,Credentials)
 Credentials.set_username = new_instancemethod(_credentials.Credentials_set_username,None,Credentials)
index 1bbdf8a5ad67fb0b9bcfdf7e4818f0923a32d107..ab76ea2cdec0564c70690f2bada995840f03b5f8 100644 (file)
@@ -30,6 +30,7 @@
 #include "auth/credentials/credentials.h"
 #include "auth/credentials/credentials_krb5.h"
 #include "param/param.h"
+#include "lib/events/events.h"
 
 /**
  * Read a file descriptor, and parse it for a password (eg from a file or stdin)
@@ -169,6 +170,7 @@ _PUBLIC_ bool cli_credentials_parse_file(struct cli_credentials *cred, const cha
  * @retval NTSTATUS error detailing any failure
  */
 _PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred, 
+                                             struct event_context *event_ctx,
                                     struct loadparm_context *lp_ctx,
                                     struct ldb_context *ldb,
                                     const char *base,
@@ -305,13 +307,13 @@ _PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
         * (chewing CPU time) from the password */
        keytab = ldb_msg_find_attr_as_string(msgs[0], "krb5Keytab", NULL);
        if (keytab) {
-               cli_credentials_set_keytab_name(cred, lp_ctx, keytab, CRED_SPECIFIED);
+               cli_credentials_set_keytab_name(cred, event_ctx, lp_ctx, keytab, CRED_SPECIFIED);
        } else {
                keytab = ldb_msg_find_attr_as_string(msgs[0], "privateKeytab", NULL);
                if (keytab) {
                        keytab = talloc_asprintf(mem_ctx, "FILE:%s", private_path(mem_ctx, lp_ctx, keytab));
                        if (keytab) {
-                               cli_credentials_set_keytab_name(cred, lp_ctx, keytab, CRED_SPECIFIED);
+                               cli_credentials_set_keytab_name(cred, event_ctx, lp_ctx, keytab, CRED_SPECIFIED);
                        }
                }
        }
@@ -336,7 +338,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cr
        cred->machine_account_pending = false;
        filter = talloc_asprintf(cred, SECRETS_PRIMARY_DOMAIN_FILTER, 
                                       cli_credentials_get_domain(cred));
-       return cli_credentials_set_secrets(cred, lp_ctx, NULL, 
+       return cli_credentials_set_secrets(cred, event_context_find(cred), lp_ctx, NULL, 
                                           SECRETS_PRIMARY_DOMAIN_DN,
                                           filter);
 }
@@ -348,6 +350,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cr
  * @retval NTSTATUS error detailing any failure
  */
 NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred,
+                                   struct event_context *event_ctx,
                                    struct loadparm_context *lp_ctx)
 {
        char *filter;
@@ -358,7 +361,7 @@ NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred,
        filter = talloc_asprintf(cred, SECRETS_KRBTGT_SEARCH,
                                       cli_credentials_get_realm(cred),
                                       cli_credentials_get_domain(cred));
-       return cli_credentials_set_secrets(cred, lp_ctx, NULL, 
+       return cli_credentials_set_secrets(cred, event_ctx, lp_ctx, NULL, 
                                           SECRETS_PRINCIPALS_DN,
                                           filter);
 }
@@ -370,6 +373,7 @@ NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred,
  * @retval NTSTATUS error detailing any failure
  */
 _PUBLIC_ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
+                                                      struct event_context *event_ctx,
                                              struct loadparm_context *lp_ctx,
                                              const char *serviceprincipal)
 {
@@ -382,7 +386,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *c
                                 cli_credentials_get_realm(cred),
                                 cli_credentials_get_domain(cred),
                                 serviceprincipal);
-       return cli_credentials_set_secrets(cred, lp_ctx, NULL, 
+       return cli_credentials_set_secrets(cred, event_ctx, lp_ctx, NULL, 
                                           SECRETS_PRINCIPALS_DN, filter);
 }
 
index cd9285b09d0592edafe6d10aff3c0692717ac9fa..3bc17644488a090aaf81619ad2fa106fcdfde99c 100644 (file)
@@ -30,6 +30,7 @@
 #include "param/param.h"
 
 _PUBLIC_ int cli_credentials_get_krb5_context(struct cli_credentials *cred, 
+                                             struct event_context *event_ctx,
                                     struct loadparm_context *lp_ctx,
                                     struct smb_krb5_context **smb_krb5_context) 
 {
@@ -39,8 +40,7 @@ _PUBLIC_ int cli_credentials_get_krb5_context(struct cli_credentials *cred,
                return 0;
        }
 
-       ret = smb_krb5_init_context(cred, cli_credentials_get_event_context(cred), 
-                                   lp_ctx, &cred->smb_krb5_context);
+       ret = smb_krb5_init_context(cred, event_ctx, lp_ctx, &cred->smb_krb5_context);
        if (ret) {
                cred->smb_krb5_context = NULL;
                return ret;
@@ -128,6 +128,7 @@ static int free_dccache(struct ccache_container *ccc) {
 }
 
 _PUBLIC_ int cli_credentials_set_ccache(struct cli_credentials *cred, 
+                                       struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               const char *name, 
                               enum credentials_obtained obtained)
@@ -144,7 +145,7 @@ _PUBLIC_ int cli_credentials_set_ccache(struct cli_credentials *cred,
                return ENOMEM;
        }
 
-       ret = cli_credentials_get_krb5_context(cred, lp_ctx, 
+       ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, 
                                               &ccc->smb_krb5_context);
        if (ret) {
                talloc_free(ccc);
@@ -203,6 +204,7 @@ _PUBLIC_ int cli_credentials_set_ccache(struct cli_credentials *cred,
 
 
 static int cli_credentials_new_ccache(struct cli_credentials *cred, 
+                                     struct event_context *event_ctx,
                                      struct loadparm_context *lp_ctx,
                                      struct ccache_container **_ccc)
 {
@@ -221,7 +223,7 @@ static int cli_credentials_new_ccache(struct cli_credentials *cred,
                return ENOMEM;
        }
 
-       ret = cli_credentials_get_krb5_context(cred, lp_ctx, 
+       ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, 
                                               &ccc->smb_krb5_context);
        if (ret) {
                talloc_free(ccc);
@@ -253,6 +255,7 @@ static int cli_credentials_new_ccache(struct cli_credentials *cred,
 }
 
 _PUBLIC_ int cli_credentials_get_ccache(struct cli_credentials *cred, 
+                                       struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               struct ccache_container **ccc)
 {
@@ -271,7 +274,7 @@ _PUBLIC_ int cli_credentials_get_ccache(struct cli_credentials *cred,
                return EINVAL;
        }
 
-       ret = cli_credentials_new_ccache(cred, lp_ctx, ccc);
+       ret = cli_credentials_new_ccache(cred, event_ctx, lp_ctx, ccc);
        if (ret) {
                return ret;
        }
@@ -348,6 +351,7 @@ static int free_gssapi_creds(struct gssapi_creds_container *gcc)
 }
 
 _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred, 
+                                        struct event_context *event_ctx,
                                         struct loadparm_context *lp_ctx,
                                         struct gssapi_creds_container **_gcc) 
 {
@@ -360,7 +364,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
                *_gcc = cred->client_gss_creds;
                return 0;
        }
-       ret = cli_credentials_get_ccache(cred, lp_ctx, 
+       ret = cli_credentials_get_ccache(cred, event_ctx, lp_ctx, 
                                         &ccache);
        if (ret) {
                DEBUG(1, ("Failed to get CCACHE for GSSAPI client: %s\n", error_message(ret)));
@@ -402,6 +406,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
 */
 
  int cli_credentials_set_client_gss_creds(struct cli_credentials *cred, 
+                                         struct event_context *event_ctx,
                                          struct loadparm_context *lp_ctx,
                                          gss_cred_id_t gssapi_cred,
                                          enum credentials_obtained obtained) 
@@ -419,7 +424,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
                return ENOMEM;
        }
 
-       ret = cli_credentials_new_ccache(cred, lp_ctx, &ccc);
+       ret = cli_credentials_new_ccache(cred, event_ctx, lp_ctx, &ccc);
        if (ret != 0) {
                return ret;
        }
@@ -456,6 +461,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
  * it will be generated from the password.
  */
 _PUBLIC_ int cli_credentials_get_keytab(struct cli_credentials *cred, 
+                                       struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               struct keytab_container **_ktc)
 {
@@ -475,7 +481,7 @@ _PUBLIC_ int cli_credentials_get_keytab(struct cli_credentials *cred,
                return EINVAL;
        }
 
-       ret = cli_credentials_get_krb5_context(cred, lp_ctx, 
+       ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, 
                                               &smb_krb5_context);
        if (ret) {
                return ret;
@@ -510,6 +516,7 @@ _PUBLIC_ int cli_credentials_get_keytab(struct cli_credentials *cred,
  * FILE:/etc/krb5.keytab), open it and attach it */
 
 _PUBLIC_ int cli_credentials_set_keytab_name(struct cli_credentials *cred, 
+                                            struct event_context *event_ctx,
                                    struct loadparm_context *lp_ctx,
                                    const char *keytab_name, 
                                    enum credentials_obtained obtained) 
@@ -523,7 +530,7 @@ _PUBLIC_ int cli_credentials_set_keytab_name(struct cli_credentials *cred,
                return 0;
        }
 
-       ret = cli_credentials_get_krb5_context(cred, lp_ctx, &smb_krb5_context);
+       ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, &smb_krb5_context);
        if (ret) {
                return ret;
        }
@@ -549,6 +556,7 @@ _PUBLIC_ int cli_credentials_set_keytab_name(struct cli_credentials *cred,
 }
 
 _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred, 
+                                          struct event_context *event_ctx,
                                  struct loadparm_context *lp_ctx) 
 {
        krb5_error_code ret;
@@ -562,7 +570,7 @@ _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
                return ENOMEM;
        }
 
-       ret = cli_credentials_get_krb5_context(cred, lp_ctx, &smb_krb5_context);
+       ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, &smb_krb5_context);
        if (ret) {
                talloc_free(mem_ctx);
                return ret;
@@ -570,7 +578,7 @@ _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
 
        enctype_strings = cli_credentials_get_enctype_strings(cred);
        
-       ret = cli_credentials_get_keytab(cred, lp_ctx, &ktc);
+       ret = cli_credentials_get_keytab(cred, event_ctx, lp_ctx, &ktc);
        if (ret != 0) {
                talloc_free(mem_ctx);
                return ret;
@@ -585,6 +593,7 @@ _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
 /* Get server gss credentials (in gsskrb5, this means the keytab) */
 
 _PUBLIC_ int cli_credentials_get_server_gss_creds(struct cli_credentials *cred, 
+                                                 struct event_context *event_ctx,
                                         struct loadparm_context *lp_ctx,
                                         struct gssapi_creds_container **_gcc) 
 {
@@ -603,12 +612,12 @@ _PUBLIC_ int cli_credentials_get_server_gss_creds(struct cli_credentials *cred,
                return 0;
        }
 
-       ret = cli_credentials_get_krb5_context(cred, lp_ctx, &smb_krb5_context);
+       ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, &smb_krb5_context);
        if (ret) {
                return ret;
        }
 
-       ret = cli_credentials_get_keytab(cred, lp_ctx, &ktc);
+       ret = cli_credentials_get_keytab(cred, event_ctx, lp_ctx, &ktc);
        if (ret) {
                DEBUG(1, ("Failed to get keytab for GSSAPI server: %s\n", error_message(ret)));
                return ret;
index aaa7d7f0da1c2d6ecd444e903f1cecdc93f66edc..f672b0ad9ad4c9421e64dbe303c90d8eaaafa131 100644 (file)
@@ -32,6 +32,7 @@ struct gssapi_creds_container {
 
 /* Manually prototyped here to avoid needing gss headers in most callers */
 int cli_credentials_set_client_gss_creds(struct cli_credentials *cred, 
+                                        struct event_context *event_ctx,
                                         struct loadparm_context *lp_ctx,
                                         gss_cred_id_t gssapi_cred,
                                         enum credentials_obtained obtained);
index b88f2018df11a008793ca896cdba69c8da303bc1..22e273c35af406b78848caa8e9f23a5332effdf2 100644 (file)
@@ -52,6 +52,20 @@ _PUBLIC_ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred
        const struct samr_Password *nt_hash;
        lm_session_key = data_blob(NULL, 0);
 
+       /* We may already have an NTLM response we prepared earlier.
+        * This is used for NTLM pass-though authentication */
+       if (cred->nt_response.data || cred->lm_response.data) {
+               *_nt_response = cred->nt_response;
+               *_lm_response = cred->lm_response;
+
+               if (!cred->lm_response.data) {
+                       *flags = *flags & ~CLI_CRED_LANMAN_AUTH;
+               }
+               *_lm_session_key = data_blob(NULL, 0);
+               *_session_key = data_blob(NULL, 0);
+               return NT_STATUS_OK;
+       }
+
        nt_hash = cli_credentials_get_nt_hash(cred, mem_ctx);
 
        cli_credentials_get_ntlm_username_domain(cred, mem_ctx, &user, &domain);
@@ -215,3 +229,41 @@ _PUBLIC_ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred
        return NT_STATUS_OK;
 }
        
+_PUBLIC_ bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
+                                const struct samr_Password *nt_hash, 
+                                enum credentials_obtained obtained)
+{
+       if (obtained >= cred->password_obtained) {
+               cli_credentials_set_password(cred, NULL, obtained);
+               if (nt_hash) {
+                       cred->nt_hash = talloc(cred, struct samr_Password);
+                       *cred->nt_hash = *nt_hash;
+               } else {
+                       cred->nt_hash = NULL;
+               }
+               return true;
+       }
+
+       return false;
+}
+
+_PUBLIC_ bool cli_credentials_set_ntlm_response(struct cli_credentials *cred,
+                                               const DATA_BLOB *lm_response, 
+                                               const DATA_BLOB *nt_response, 
+                                               enum credentials_obtained obtained)
+{
+       if (obtained >= cred->password_obtained) {
+               cli_credentials_set_password(cred, NULL, obtained);
+               if (nt_response) {
+                       cred->nt_response = data_blob_talloc(cred, nt_response->data, nt_response->length);
+                       talloc_steal(cred, cred->nt_response.data);
+               }
+               if (nt_response) {
+                       cred->lm_response = data_blob_talloc(cred, lm_response->data, lm_response->length);
+               }
+               return true;
+       }
+
+       return false;
+}
+
index 6c99802b09ddf56f2741d0389d4d0cff7583e7bb..81ba426e456baec106a12ab7b7d6f9389727dd8c 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2506,7 +2524,7 @@ static swig_module_info swig_module = {swig_types, 17, 0, 0, 0, 0};
 
 #define SWIG_name    "_credentials"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2863,7 +2881,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   char *  kwnames[] = {
-    (char *) "self",(char *) "value",(char *)"arg3", NULL 
+    (char *) "self",(char *) "value",(char *) "obtained", NULL 
   };
   
   arg1 = NULL;
@@ -2944,7 +2962,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   char *  kwnames[] = {
-    (char *) "self",(char *) "val",(char *)"arg3", NULL 
+    (char *) "self",(char *) "val",(char *) "obtained", NULL 
   };
   
   arg1 = NULL;
@@ -3025,7 +3043,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self)
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   char *  kwnames[] = {
-    (char *) "self",(char *) "val",(char *)"arg3", NULL 
+    (char *) "self",(char *) "val",(char *) "obtained", NULL 
   };
   
   arg1 = NULL;
@@ -3106,7 +3124,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self),
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   char *  kwnames[] = {
-    (char *) "self",(char *) "val",(char *)"arg3", NULL 
+    (char *) "self",(char *) "val",(char *) "obtained", NULL 
   };
   
   arg1 = NULL;
@@ -3196,7 +3214,7 @@ SWIGINTERN PyObject *_wrap_Credentials_parse_string(PyObject *SWIGUNUSEDPARM(sel
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   char *  kwnames[] = {
-    (char *) "self",(char *) "text",(char *)"arg3", NULL 
+    (char *) "self",(char *) "text",(char *) "obtained", NULL 
   };
   
   arg1 = NULL;
@@ -3672,19 +3690,52 @@ SWIGINTERN PyObject *Credentials_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObje
 
 static PyMethodDef SwigMethods[] = {
         { (char *)"new_Credentials", (PyCFunction)_wrap_new_Credentials, METH_NOARGS, NULL},
-        { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_password", (PyCFunction) _wrap_Credentials_set_password, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_username() -> username\n"
+               "Obtain username.\n"
+               ""},
+        { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_username(name, obtained=CRED_SPECIFIED) -> None\n"
+               "Change username.\n"
+               ""},
+        { (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_password() -> password\n"
+               "Obtain password.\n"
+               ""},
+        { (char *)"Credentials_set_password", (PyCFunction) _wrap_Credentials_set_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_password(password, obtained=CRED_SPECIFIED) -> None\n"
+               "Change password.\n"
+               ""},
         { (char *)"Credentials_get_domain", (PyCFunction) _wrap_Credentials_get_domain, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_domain", (PyCFunction) _wrap_Credentials_set_domain, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_get_realm", (PyCFunction) _wrap_Credentials_get_realm, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_realm", (PyCFunction) _wrap_Credentials_set_realm, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Credentials_set_domain", (PyCFunction) _wrap_Credentials_set_domain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_domain(domain, obtained=CRED_SPECIFIED) -> None\n"
+               "Change domain name.\n"
+               ""},
+        { (char *)"Credentials_get_realm", (PyCFunction) _wrap_Credentials_get_realm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_realm() -> realm\n"
+               "Obtain realm name.\n"
+               ""},
+        { (char *)"Credentials_set_realm", (PyCFunction) _wrap_Credentials_set_realm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_realm(realm, obtained=CRED_SPECIFIED) -> None\n"
+               "Change realm name.\n"
+               ""},
         { (char *)"Credentials_set_kerberos_state", (PyCFunction) _wrap_Credentials_set_kerberos_state, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_parse_string", (PyCFunction) _wrap_Credentials_parse_string, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_get_bind_dn", (PyCFunction) _wrap_Credentials_get_bind_dn, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_bind_dn", (PyCFunction) _wrap_Credentials_set_bind_dn, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_anonymous", (PyCFunction) _wrap_Credentials_set_anonymous, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Credentials_parse_string", (PyCFunction) _wrap_Credentials_parse_string, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.parse_string(text, obtained=CRED_SPECIFIED) -> None\n"
+               "Parse credentials string.\n"
+               ""},
+        { (char *)"Credentials_get_bind_dn", (PyCFunction) _wrap_Credentials_get_bind_dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_bind_dn() -> bind dn\n"
+               "Obtain bind DN.\n"
+               ""},
+        { (char *)"Credentials_set_bind_dn", (PyCFunction) _wrap_Credentials_set_bind_dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_bind_dn(bind_dn) -> None\n"
+               "Change bind DN.\n"
+               ""},
+        { (char *)"Credentials_set_anonymous", (PyCFunction) _wrap_Credentials_set_anonymous, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_anonymous() -> None\n"
+               "Use anonymous credentials.\n"
+               ""},
         { (char *)"Credentials_get_workstation", (PyCFunction) _wrap_Credentials_get_workstation, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_set_workstation", (PyCFunction) _wrap_Credentials_set_workstation, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_set_machine_account", (PyCFunction) _wrap_Credentials_set_machine_account, METH_VARARGS | METH_KEYWORDS, NULL},
@@ -3692,8 +3743,14 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"Credentials_is_anonymous", (PyCFunction) _wrap_Credentials_is_anonymous, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_get_nt_hash", (PyCFunction) _wrap_Credentials_get_nt_hash, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_authentication_requested", (PyCFunction) _wrap_Credentials_authentication_requested, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.wrong_password() -> bool\n"
+               "Indicate the returned password was incorrect.\n"
+               ""},
+        { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_cmdline_callbacks() -> bool\n"
+               "Use command-line to obtain credentials not explicitly set.\n"
+               ""},
         { (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_swigregister", Credentials_swigregister, METH_VARARGS, NULL},
         { (char *)"Credentials_swiginit", Credentials_swiginit, METH_VARARGS, NULL},
@@ -3845,7 +3902,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -3855,6 +3912,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 */
@@ -3883,6 +3943,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);
index d0a99502c17d94de43b990cbf7970928d150202b..30120b3a605dbe4ddabafda78335c9f01b71f970 100644 (file)
@@ -24,7 +24,7 @@ the functionality, that's already done in other tests.
 """
 
 import unittest
-import credentials
+from samba import credentials
 
 class CredentialsTests(unittest.TestCase):
     def setUp(self):
index cfb349348477d4b73dce17568d8d9cbfad27daf3..f08ff2638a539133becad04a652270fe3246669d 100644 (file)
@@ -1,30 +1,31 @@
 #################################
 # 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
 [MODULE::gensec_krb5]
 SUBSYSTEM = gensec
 INIT_FUNCTION = gensec_krb5_init
-PRIVATE_DEPENDENCIES = CREDENTIALS KERBEROS auth auth_sam
+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)))
 
index 59ad15740eba809adce8eb0f0a3a91ac43819551..0edb34d7403fc7d048314ac3d005bf2128bb202f 100644 (file)
@@ -23,7 +23,6 @@
 #include "includes.h"
 #include "auth/auth.h"
 #include "lib/events/events.h"
-#include "build.h"
 #include "librpc/rpc/dcerpc.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
@@ -482,6 +481,11 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
                             struct messaging_context *msg,
                             struct gensec_security **gensec_security)
 {
+       if (ev == NULL) {
+               DEBUG(0, ("No event context available!\n"));
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
        (*gensec_security) = talloc(mem_ctx, struct gensec_security);
        NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
 
@@ -493,14 +497,6 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
 
        (*gensec_security)->subcontext = false;
        (*gensec_security)->want_features = 0;
-       
-       if (ev == NULL) {
-               ev = event_context_init(*gensec_security);
-               if (ev == NULL) {
-                       talloc_free(*gensec_security);
-                       return NT_STATUS_NO_MEMORY;
-               }
-       }
 
        (*gensec_security)->event_ctx = ev;
        (*gensec_security)->msg_ctx = msg;
@@ -548,20 +544,11 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
                             struct loadparm_context *lp_ctx)
 {
        NTSTATUS status;
-       struct event_context *new_ev = NULL;
-
-       if (ev == NULL) {
-               new_ev = event_context_init(mem_ctx);
-               NT_STATUS_HAVE_NO_MEMORY(new_ev);
-               ev = new_ev;
-       }
 
        status = gensec_start(mem_ctx, ev, lp_ctx, NULL, gensec_security);
        if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(new_ev);
                return status;
        }
-       talloc_steal((*gensec_security), new_ev);
        (*gensec_security)->gensec_role = GENSEC_CLIENT;
 
        return status;
index e7dcb4ea688d41ae561516f9a1f0a1f5e2b56c8a..cc0d40469e529099113c12233fdc52f1cc04d1de 100644 (file)
@@ -273,7 +273,9 @@ static NTSTATUS gensec_gssapi_server_start(struct gensec_security *gensec_securi
                DEBUG(3, ("No machine account credentials specified\n"));
                return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
        } else {
-               ret = cli_credentials_get_server_gss_creds(machine_account, gensec_security->lp_ctx, &gcc);
+               ret = cli_credentials_get_server_gss_creds(machine_account, 
+                                                          gensec_security->event_ctx, 
+                                                          gensec_security->lp_ctx, &gcc);
                if (ret) {
                        DEBUG(1, ("Aquiring acceptor credentials failed: %s\n", 
                                  error_message(ret)));
@@ -359,7 +361,9 @@ static NTSTATUS gensec_gssapi_client_start(struct gensec_security *gensec_securi
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       ret = cli_credentials_get_client_gss_creds(creds, gensec_security->lp_ctx, &gcc);
+       ret = cli_credentials_get_client_gss_creds(creds, 
+                                                  gensec_security->event_ctx, 
+                                                  gensec_security->lp_ctx, &gcc);
        switch (ret) {
        case 0:
                break;
@@ -1323,7 +1327,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
        } else if (!lp_parm_bool(gensec_security->lp_ctx, NULL, "gensec", "require_pac", false)) {
                DEBUG(1, ("Unable to find PAC, resorting to local user lookup: %s\n",
                          gssapi_error_string(mem_ctx, maj_stat, min_stat, gensec_gssapi_state->gss_oid)));
-               nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->lp_ctx, principal_string,
+               nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, principal_string,
                                                          &server_info);
 
                if (!NT_STATUS_IS_OK(nt_status)) {
@@ -1338,7 +1342,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
        }
 
        /* references the server_info into the session_info */
-       nt_status = auth_generate_session_info(mem_ctx, gensec_security->lp_ctx, server_info, &session_info);
+       nt_status = auth_generate_session_info(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, server_info, &session_info);
        if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(mem_ctx);
                return nt_status;
@@ -1361,12 +1365,12 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
                        return NT_STATUS_NO_MEMORY;
                }
 
-               cli_credentials_set_event_context(session_info->credentials, gensec_security->event_ctx);
                cli_credentials_set_conf(session_info->credentials, gensec_security->lp_ctx);
                /* Just so we don't segfault trying to get at a username */
                cli_credentials_set_anonymous(session_info->credentials);
                
                ret = cli_credentials_set_client_gss_creds(session_info->credentials, 
+                                                          gensec_security->event_ctx,
                                                           gensec_security->lp_ctx, 
                                                           gensec_gssapi_state->delegated_cred_handle,
                                                           CRED_SPECIFIED);
index ae601b19c25e60fa21f0beaf0b906f42dffd516b..47df2ccfcc27835b920b6751dfc389bd9081ef5e 100644 (file)
@@ -118,7 +118,9 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security)
 
        talloc_set_destructor(gensec_krb5_state, gensec_krb5_destroy); 
 
-       if (cli_credentials_get_krb5_context(creds, gensec_security->lp_ctx, &gensec_krb5_state->smb_krb5_context)) {
+       if (cli_credentials_get_krb5_context(creds, 
+                                            gensec_security->event_ctx, 
+                                            gensec_security->lp_ctx, &gensec_krb5_state->smb_krb5_context)) {
                talloc_free(gensec_krb5_state);
                return NT_STATUS_INTERNAL_ERROR;
        }
@@ -248,7 +250,9 @@ static NTSTATUS gensec_krb5_client_start(struct gensec_security *gensec_security
 
        principal = gensec_get_target_principal(gensec_security);
 
-       ret = cli_credentials_get_ccache(gensec_get_credentials(gensec_security), gensec_security->lp_ctx, &ccache_container);
+       ret = cli_credentials_get_ccache(gensec_get_credentials(gensec_security), 
+                                        gensec_security->event_ctx, 
+                                        gensec_security->lp_ctx, &ccache_container);
        switch (ret) {
        case 0:
                break;
@@ -446,7 +450,9 @@ static NTSTATUS gensec_krb5_update(struct gensec_security *gensec_security,
                }       
 
                /* Grab the keytab, however generated */
-               ret = cli_credentials_get_keytab(gensec_get_credentials(gensec_security), gensec_security->lp_ctx, &keytab);
+               ret = cli_credentials_get_keytab(gensec_get_credentials(gensec_security), 
+                                                gensec_security->event_ctx, 
+                                                gensec_security->lp_ctx, &keytab);
                if (ret) {
                        return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
                }
@@ -597,7 +603,7 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security
                DEBUG(5, ("krb5_ticket_get_authorization_data_type failed to find PAC: %s\n", 
                          smb_get_krb5_error_message(context, 
                                                     ret, mem_ctx)));
-               nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->lp_ctx, principal_string,
+               nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, principal_string,
                                                          &server_info);
                krb5_free_principal(context, client_principal);
                free(principal_string);
@@ -645,7 +651,7 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security
        }
 
        /* references the server_info into the session_info */
-       nt_status = auth_generate_session_info(mem_ctx, gensec_security->lp_ctx, server_info, &session_info);
+       nt_status = auth_generate_session_info(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, server_info, &session_info);
 
        if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(mem_ctx);
index b3117ee9b2e00d0b86a27c31a424bce8cbaad1ee..f21202b86f5486e46a94898adf518d73ba90ae2d 100644 (file)
@@ -125,7 +125,8 @@ static NTSTATUS schannel_update(struct gensec_security *gensec_security, TALLOC_
                }
                
                /* pull the session key for this client */
-               status = schannel_fetch_session_key(out_mem_ctx, gensec_security->lp_ctx, workstation, 
+               status = schannel_fetch_session_key(out_mem_ctx, gensec_security->event_ctx, 
+                                                   gensec_security->lp_ctx, workstation, 
                                                    domain, &creds);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(3, ("Could not find session key for attempted schannel connection from %s: %s\n",
@@ -189,7 +190,7 @@ static NTSTATUS schannel_session_info(struct gensec_security *gensec_security,
                                         struct auth_session_info **_session_info) 
 {
        struct schannel_state *state = talloc_get_type(gensec_security->private_data, struct schannel_state);
-       return auth_anonymous_session_info(state, gensec_security->lp_ctx, _session_info);
+       return auth_anonymous_session_info(state, gensec_security->event_ctx, gensec_security->lp_ctx, _session_info);
 }
 
 static NTSTATUS schannel_start(struct gensec_security *gensec_security)
index 0c7c509954f6a03b1c108927c629264e4c3b5c13..0f7c4ca11d7f9c75b283e901dc65a73c59721d17 100644 (file)
@@ -32,7 +32,8 @@
 /**
   connect to the schannel ldb
 */
-struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx,
+                                       struct loadparm_context *lp_ctx)
 {
        char *path;
        struct ldb_context *ldb;
@@ -49,7 +50,7 @@ struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_con
 
        existed = file_exist(path);
        
-       ldb = ldb_wrap_connect(mem_ctx, lp_ctx, path, 
+       ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, path, 
                               system_session(mem_ctx, lp_ctx), 
                               NULL, LDB_FLG_NOSYNC, NULL);
        talloc_free(path);
@@ -137,6 +138,7 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx,
 }
 
 NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
+                                   struct event_context *ev_ctx,
                                    struct loadparm_context *lp_ctx,
                                    struct creds_CredentialState *creds)
 {
@@ -144,7 +146,7 @@ NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
        NTSTATUS nt_status;
        int ret;
                
-       ldb = schannel_db_connect(mem_ctx, lp_ctx);
+       ldb = schannel_db_connect(mem_ctx, ev_ctx, lp_ctx);
        if (!ldb) {
                return NT_STATUS_ACCESS_DENIED;
        }
@@ -268,6 +270,7 @@ NTSTATUS schannel_fetch_session_key_ldb(TALLOC_CTX *mem_ctx,
 }
 
 NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
+                                   struct event_context *ev_ctx,
                                    struct loadparm_context *lp_ctx,
                                        const char *computer_name, 
                                        const char *domain, 
@@ -276,7 +279,7 @@ NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
        NTSTATUS nt_status;
        struct ldb_context *ldb;
 
-       ldb = schannel_db_connect(mem_ctx, lp_ctx);
+       ldb = schannel_db_connect(mem_ctx, ev_ctx, lp_ctx);
        if (!ldb) {
                return NT_STATUS_ACCESS_DENIED;
        }
index 762d6f8c49f2e2d30aeae867f81ca91d4db9115d..951e247258d391fa4a5daddfc9ff5c3e3f72f023 100644 (file)
@@ -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)))
+
similarity index 99%
rename from source/auth/auth.c
rename to source/auth/ntlm/auth.c
index 6c86cf2d7ce13e227443e347e1af55ca2439dd26..0f1ef3ccdb71e24b13d1d445f2cebb30ebfc2192 100644 (file)
@@ -21,9 +21,8 @@
 #include "includes.h"
 #include "lib/util/dlinklist.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "lib/events/events.h"
-#include "build.h"
 #include "param/param.h"
 
 /***************************************************************************
@@ -521,6 +520,7 @@ _PUBLIC_ NTSTATUS auth_init(void)
        extern NTSTATUS auth_anonymous_init(void);
        extern NTSTATUS auth_unix_init(void);
        extern NTSTATUS auth_sam_init(void);
+       extern NTSTATUS auth_server_init(void);
 
        init_module_fn static_init[] = { STATIC_auth_MODULES };
        
similarity index 98%
rename from source/auth/auth_anonymous.c
rename to source/auth/ntlm/auth_anonymous.c
index b93c7c200868100eb1be9a86151c88984c839f3f..c8890718784c4b5d3e645268edb79f8f38e7d79a 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "param/param.h"
 
 /**
similarity index 99%
rename from source/auth/auth_developer.c
rename to source/auth/ntlm/auth_developer.c
index a2c9cbc828454d60b2a01c572faac3faf88ad728..3b8c83c349b0caca9b75318e11cb81ea7d8388a7 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_samr.h"
 
diff --git a/source/auth/ntlm/auth_proto.h b/source/auth/ntlm/auth_proto.h
new file mode 100644 (file)
index 0000000..572c1a4
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __AUTH_NTLM_AUTH_PROTO_H__
+#define __AUTH_NTLM_AUTH_PROTO_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/auth.c  */
+
+
+/***************************************************************************
+ Set a fixed challenge
+***************************************************************************/
+bool auth_challenge_may_be_modified(struct auth_context *auth_ctx) ;
+const struct auth_operations *auth_backend_byname(const char *name);
+const struct auth_critical_sizes *auth_interface_version(void);
+NTSTATUS server_service_auth_init(void);
+
+/* The following definitions come from auth/ntlm/auth_util.c  */
+
+NTSTATUS auth_get_challenge_not_implemented(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, DATA_BLOB *challenge);
+
+/****************************************************************************
+ Create an auth_usersupplied_data structure after appropriate mapping.
+****************************************************************************/
+NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
+                      const char *default_domain,
+                      const struct auth_usersupplied_info *user_info,
+                      struct auth_usersupplied_info **user_info_mapped);
+
+/****************************************************************************
+ Create an auth_usersupplied_data structure after appropriate mapping.
+****************************************************************************/
+NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_context, 
+                          enum auth_password_state to_state,
+                          const struct auth_usersupplied_info *user_info_in,
+                          const struct auth_usersupplied_info **user_info_encrypted);
+
+/* The following definitions come from auth/ntlm/auth_simple.c  */
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __AUTH_NTLM_AUTH_PROTO_H__ */
+
similarity index 98%
rename from source/auth/auth_sam.c
rename to source/auth/ntlm/auth_sam.c
index 4b467cee75bd2d3dbcbd3a433cd9f4fe6210ce27..2c13cd963dc471635a8c36b721dc1affccf2f296 100644 (file)
@@ -25,7 +25,8 @@
 #include "lib/ldb/include/ldb.h"
 #include "util/util_ldb.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/ntlm_check.h"
+#include "auth/ntlm/auth_proto.h"
 #include "auth/auth_sam.h"
 #include "dsdb/samdb/samdb.h"
 #include "libcli/security/security.h"
@@ -289,7 +290,7 @@ static NTSTATUS authsam_check_password_internals(struct auth_method_context *ctx
                return NT_STATUS_NO_MEMORY;
        }
 
-       sam_ctx = samdb_connect(tmp_ctx, ctx->auth_ctx->lp_ctx, system_session(mem_ctx, ctx->auth_ctx->lp_ctx));
+       sam_ctx = samdb_connect(tmp_ctx, ctx->auth_ctx->event_ctx, ctx->auth_ctx->lp_ctx, system_session(mem_ctx, ctx->auth_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                talloc_free(tmp_ctx);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
diff --git a/source/auth/ntlm/auth_server.c b/source/auth/ntlm/auth_server.c
new file mode 100644 (file)
index 0000000..f154cf0
--- /dev/null
@@ -0,0 +1,225 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Authenticate by using a remote server
+   Copyright (C) Andrew Bartlett         2001-2002, 2008
+   Copyright (C) Jelmer Vernooij              2002
+   Copyright (C) Stefan Metzmacher            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 "auth/auth.h"
+#include "auth/ntlm/auth_proto.h"
+#include "auth/credentials/credentials.h"
+#include "libcli/security/security.h"
+#include "librpc/gen_ndr/ndr_samr.h"
+#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
+#include "libcli/resolve/resolve.h"
+
+/* This version of 'security=server' rewirtten from scratch for Samba4
+ * libraries in 2008 */
+
+
+static NTSTATUS server_want_check(struct auth_method_context *ctx,
+                                           TALLOC_CTX *mem_ctx,
+                                           const struct auth_usersupplied_info *user_info)
+{
+       return NT_STATUS_OK;
+}
+/** 
+ * The challenge from the target server, when operating in security=server
+ **/
+static NTSTATUS server_get_challenge(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, DATA_BLOB *_blob)
+{
+       struct smb_composite_connect io;
+       struct smbcli_options smb_options;
+       const char **host_list;
+       NTSTATUS status;
+
+       /* Make a connection to the target server, found by 'password server' in smb.conf */
+       
+       lp_smbcli_options(ctx->auth_ctx->lp_ctx, &smb_options);
+
+       /* Make a negprot, WITHOUT SPNEGO, so we get a challenge nice an easy */
+       io.in.options.use_spnego = false;
+
+       /* Hope we don't get * (the default), as this won't work... */
+       host_list = lp_passwordserver(ctx->auth_ctx->lp_ctx); 
+       if (!host_list) {
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+       io.in.dest_host = host_list[0];
+       if (strequal(io.in.dest_host, "*")) {
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+       io.in.dest_ports = lp_smb_ports(ctx->auth_ctx->lp_ctx); 
+
+       io.in.called_name = strupper_talloc(mem_ctx, io.in.dest_host);
+
+       /* We don't want to get as far as the session setup */
+       io.in.credentials = NULL;
+       io.in.service = NULL;
+
+       io.in.workgroup = ""; /* only used with SPNEGO, disabled above */
+
+       io.in.options = smb_options;
+
+       status = smb_composite_connect(&io, mem_ctx, lp_resolve_context(ctx->auth_ctx->lp_ctx),
+                                      ctx->auth_ctx->event_ctx);
+       if (!NT_STATUS_IS_OK(status)) {
+               *_blob = io.out.tree->session->transport->negotiate.secblob;
+               ctx->private_data = talloc_steal(ctx, io.out.tree->session);
+       }
+       return NT_STATUS_OK;
+}
+
+/** 
+ * Return an error based on username
+ *
+ * This function allows the testing of obsure errors, as well as the generation
+ * of NT_STATUS -> DOS error mapping tables.
+ *
+ * This module is of no value to end-users.
+ *
+ * The password is ignored.
+ *
+ * @return An NTSTATUS value based on the username
+ **/
+
+static NTSTATUS server_check_password(struct auth_method_context *ctx,
+                                     TALLOC_CTX *mem_ctx,
+                                     const struct auth_usersupplied_info *user_info, 
+                                     struct auth_serversupplied_info **_server_info)
+{
+       NTSTATUS nt_status;
+       struct auth_serversupplied_info *server_info;
+       struct cli_credentials *creds;
+       const char *user;
+       struct smb_composite_sesssetup session_setup;
+
+       struct smbcli_session *session = talloc_get_type(ctx->private_data, struct smbcli_session);
+
+       creds = cli_credentials_init(mem_ctx);
+
+       NT_STATUS_HAVE_NO_MEMORY(creds);
+       
+       cli_credentials_set_username(creds, user_info->client.account_name, CRED_SPECIFIED);
+       cli_credentials_set_domain(creds, user_info->client.domain_name, CRED_SPECIFIED);
+
+       switch (user_info->password_state) {
+       case AUTH_PASSWORD_PLAIN:
+               cli_credentials_set_password(creds, user_info->password.plaintext, 
+                                            CRED_SPECIFIED);
+               break;
+       case AUTH_PASSWORD_HASH:
+               cli_credentials_set_nt_hash(creds, user_info->password.hash.nt,
+                                           CRED_SPECIFIED);
+               break;
+               
+       case AUTH_PASSWORD_RESPONSE:
+               cli_credentials_set_ntlm_response(creds, &user_info->password.response.lanman, &user_info->password.response.nt, CRED_SPECIFIED);
+               break;
+       }
+
+       session_setup.in.sesskey = session->transport->negotiate.sesskey;
+       session_setup.in.capabilities = session->transport->negotiate.capabilities;
+
+       session_setup.in.credentials = creds;
+       session_setup.in.workgroup = ""; /* Only used with SPNEGO, which we are not doing */
+
+       /* Check password with remove server - this should be async some day */
+       nt_status = smb_composite_sesssetup(session, &session_setup);
+
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               return nt_status;
+       }
+
+       server_info = talloc(mem_ctx, struct auth_serversupplied_info);
+       NT_STATUS_HAVE_NO_MEMORY(server_info);
+
+       server_info->account_sid = dom_sid_parse_talloc(server_info, SID_NT_ANONYMOUS);
+       NT_STATUS_HAVE_NO_MEMORY(server_info->account_sid);
+
+       /* is this correct? */
+       server_info->primary_group_sid = dom_sid_parse_talloc(server_info, SID_BUILTIN_GUESTS);
+       NT_STATUS_HAVE_NO_MEMORY(server_info->primary_group_sid);
+
+       server_info->n_domain_groups = 0;
+       server_info->domain_groups = NULL;
+
+       /* annoying, but the Anonymous really does have a session key, 
+          and it is all zeros! */
+       server_info->user_session_key = data_blob(NULL, 0);
+       server_info->lm_session_key = data_blob(NULL, 0);
+
+       server_info->account_name = talloc_strdup(server_info, user_info->client.account_name);
+       NT_STATUS_HAVE_NO_MEMORY(server_info->account_name);
+
+       server_info->domain_name = talloc_strdup(server_info, user_info->client.domain_name);
+       NT_STATUS_HAVE_NO_MEMORY(server_info->domain_name);
+
+       server_info->full_name = NULL;
+
+       server_info->logon_script = talloc_strdup(server_info, "");
+       NT_STATUS_HAVE_NO_MEMORY(server_info->logon_script);
+
+       server_info->profile_path = talloc_strdup(server_info, "");
+       NT_STATUS_HAVE_NO_MEMORY(server_info->profile_path);
+
+       server_info->home_directory = talloc_strdup(server_info, "");
+       NT_STATUS_HAVE_NO_MEMORY(server_info->home_directory);
+
+       server_info->home_drive = talloc_strdup(server_info, "");
+       NT_STATUS_HAVE_NO_MEMORY(server_info->home_drive);
+
+       server_info->last_logon = 0;
+       server_info->last_logoff = 0;
+       server_info->acct_expiry = 0;
+       server_info->last_password_change = 0;
+       server_info->allow_password_change = 0;
+       server_info->force_password_change = 0;
+
+       server_info->logon_count = 0;
+       server_info->bad_password_count = 0;
+
+       server_info->acct_flags = ACB_NORMAL;
+
+       server_info->authenticated = false;
+
+       *_server_info = server_info;
+
+       return nt_status;
+}
+
+static const struct auth_operations server_auth_ops = {
+       .name           = "server",
+       .get_challenge  = server_get_challenge,
+       .want_check     = server_want_check,
+       .check_password = server_check_password
+};
+
+_PUBLIC_ NTSTATUS auth_server_init(void)
+{
+       NTSTATUS ret;
+
+       ret = auth_register(&server_auth_ops);
+       if (!NT_STATUS_IS_OK(ret)) {
+               DEBUG(0,("Failed to register 'server' auth backend!\n"));
+               return ret;
+       }
+
+       return ret;
+}
similarity index 96%
rename from source/auth/auth_simple.c
rename to source/auth/ntlm/auth_simple.c
index 50be02a35334e86c549ca254d41e92cf49e22a7b..e7039c36575fb529e3ede16318eb017636438f6c 100644 (file)
@@ -90,7 +90,7 @@ _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
        }
 
        if (session_info) {
-               nt_status = auth_generate_session_info(tmp_ctx, lp_ctx, server_info, session_info);
+               nt_status = auth_generate_session_info(tmp_ctx, ev, lp_ctx, server_info, session_info);
 
                if (NT_STATUS_IS_OK(nt_status)) {
                        talloc_steal(mem_ctx, *session_info);
similarity index 99%
rename from source/auth/auth_unix.c
rename to source/auth/ntlm/auth_unix.c
index a4171070257e5b55ba4cb2786be65c5c8a441531..1717b9d0e180954caf1d85694bfd4c01b9c675e9 100644 (file)
 
 #include "includes.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "system/passwd.h" /* needed by some systems for struct passwd */
 #include "lib/socket/socket.h" 
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
 #include "param/param.h"
 
 /* TODO: look at how to best fill in parms retrieveing a struct passwd info
similarity index 99%
rename from source/auth/auth_winbind.c
rename to source/auth/ntlm/auth_winbind.c
index 149f549afa129ec7718f2dff0ed495155d85d9e1..ac63b242e49901d3c43ce8699c5646eabbe4c018 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "includes.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "auth/session_proto.h"
 #include "nsswitch/winbind_client.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
diff --git a/source/auth/ntlm/config.mk b/source/auth/ntlm/config.mk
new file mode 100644 (file)
index 0000000..f31c2b7
--- /dev/null
@@ -0,0 +1,86 @@
+# NTLM auth server subsystem
+
+[SUBSYSTEM::ntlm_check]
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
+
+ntlm_check_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, ntlm_check.o)
+
+#######################
+# Start MODULE auth_sam
+[MODULE::auth_sam_module]
+# gensec_krb5 and gensec_gssapi depend on it
+INIT_FUNCTION = auth_sam_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = \
+               SAMDB auth_sam ntlm_check
+# End MODULE auth_sam
+#######################
+
+auth_sam_module_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_sam.o)
+
+#######################
+# Start MODULE auth_anonymous
+[MODULE::auth_anonymous]
+INIT_FUNCTION = auth_anonymous_init
+SUBSYSTEM = auth
+# End MODULE auth_anonymous
+#######################
+
+auth_anonymous_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_anonymous.o)
+
+#######################
+# Start MODULE auth_anonymous
+[MODULE::auth_server]
+INIT_FUNCTION = auth_server_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_SMB
+OUTPUT_TYPE = SHARED_LIBRARY
+# End MODULE auth_server
+#######################
+
+auth_server_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_server.o)
+
+#######################
+# Start MODULE auth_winbind
+[MODULE::auth_winbind]
+INIT_FUNCTION = auth_winbind_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING LIBWINBIND-CLIENT
+# End MODULE auth_winbind
+#######################
+
+auth_winbind_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_winbind.o)
+
+#######################
+# Start MODULE auth_developer
+[MODULE::auth_developer]
+INIT_FUNCTION = auth_developer_init
+SUBSYSTEM = auth
+# End MODULE auth_developer
+#######################
+
+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 $(authsrcdir)/ntlm/, auth_unix.o)
+
+[SUBSYSTEM::PAM_ERRORS]
+
+#VERSION = 0.0.1
+#SO_VERSION = 0
+PAM_ERRORS_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, pam_errors.o)
+
+[MODULE::auth]
+INIT_FUNCTION = server_service_auth_init
+SUBSYSTEM = service
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSECURITY SAMDB CREDENTIALS 
+
+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
+
similarity index 99%
rename from source/auth/ntlm_check.c
rename to source/auth/ntlm/ntlm_check.c
index 55f2595f44bab88a11543f456514ac61f1641efd..0dbbce0edc5c09e63f9a26d3f97d810f994e0c86 100644 (file)
@@ -24,6 +24,7 @@
 #include "librpc/gen_ndr/netlogon.h"
 #include "libcli/auth/libcli_auth.h"
 #include "param/param.h"
+#include "auth/ntlm/ntlm_check.h"
 
 /****************************************************************************
  Core of smb password checking routine.
diff --git a/source/auth/ntlm/ntlm_check.h b/source/auth/ntlm/ntlm_check.h
new file mode 100644 (file)
index 0000000..eb115b7
--- /dev/null
@@ -0,0 +1,75 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Password and authentication handling
+   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001-2004
+   Copyright (C) Gerald Carter                             2003
+   Copyright (C) Luke Kenneth Casson Leighton         1996-2000
+   
+   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/>.
+*/
+
+
+/**
+ * Compare password hashes against those from the SAM
+ *
+ * @param mem_ctx talloc context
+ * @param client_lanman LANMAN password hash, as supplied by the client
+ * @param client_nt NT (MD4) password hash, as supplied by the client
+ * @param username internal Samba username, for log messages
+ * @param client_username username the client used
+ * @param client_domain domain name the client used (may be mapped)
+ * @param stored_lanman LANMAN password hash, as stored on the SAM
+ * @param stored_nt NT (MD4) password hash, as stored on the SAM
+ * @param user_sess_key User session key
+ * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
+ */
+
+NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
+                            struct loadparm_context *lp_ctx, 
+                            const struct samr_Password *client_lanman,
+                            const struct samr_Password *client_nt,
+                            const char *username, 
+                            const struct samr_Password *stored_lanman, 
+                            const struct samr_Password *stored_nt);
+
+/**
+ * Check a challenge-response password against the value of the NT or
+ * LM password hash.
+ *
+ * @param mem_ctx talloc context
+ * @param challenge 8-byte challenge.  If all zero, forces plaintext comparison
+ * @param nt_response 'unicode' NT response to the challenge, or unicode password
+ * @param lm_response ASCII or LANMAN response to the challenge, or password in DOS code page
+ * @param username internal Samba username, for log messages
+ * @param client_username username the client used
+ * @param client_domain domain name the client used (may be mapped)
+ * @param stored_lanman LANMAN ASCII password from our passdb or similar
+ * @param stored_nt MD4 unicode password from our passdb or similar
+ * @param user_sess_key User session key
+ * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
+ */
+
+NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
+                            struct loadparm_context *lp_ctx,
+                            uint32_t logon_parameters,
+                            const DATA_BLOB *challenge,
+                            const DATA_BLOB *lm_response,
+                            const DATA_BLOB *nt_response,
+                            const char *username, 
+                            const char *client_username, 
+                            const char *client_domain,
+                            const struct samr_Password *stored_lanman, 
+                            const struct samr_Password *stored_nt, 
+                            DATA_BLOB *user_sess_key, 
+                            DATA_BLOB *lm_sess_key);
diff --git a/source/auth/ntlm/pam_errors.h b/source/auth/ntlm/pam_errors.h
new file mode 100644 (file)
index 0000000..959e1f3
--- /dev/null
@@ -0,0 +1,47 @@
+/* 
+ *  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__
+
+/* The following definitions come from auth/pam_errors.c  */
+
+
+/*****************************************************************************
+convert a PAM error to a NT status32 code
+ *****************************************************************************/
+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);
+
+/*****************************************************************************
+convert a PAM error to a NT status32 code
+ *****************************************************************************/
+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);
+
+#endif /* __AUTH_NTLM_PAM_ERRORS_H__ */
+
index f8e711feda05e0e349e85df294b00bdd777b9a1a..129f58de8303ac3f553c137c72ef4c808aeeeacc 100644 (file)
@@ -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
+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)))
index 64bfebd3d1fde597badc357881154b22aee2f7dc..0b7f0da9afc8c4e369cb1d37745e65bfa96286a2 100644 (file)
@@ -29,7 +29,7 @@
 #include "auth/gensec/gensec.h"
 #include "auth/gensec/gensec_proto.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "param/param.h"
 
 /**
index 12802b7e79c0d9b90e4130006676a377ed79032a..dfc5940d992f4204f584951e76af6985b9837912 100644 (file)
@@ -30,7 +30,7 @@
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
 #include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
 #include "param/param.h"
 #include "auth/session_proto.h"
 
@@ -725,7 +725,7 @@ NTSTATUS gensec_ntlmssp_session_info(struct gensec_security *gensec_security,
        NTSTATUS nt_status;
        struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
 
-       nt_status = auth_generate_session_info(gensec_ntlmssp_state, gensec_security->lp_ctx, gensec_ntlmssp_state->server_info, session_info);
+       nt_status = auth_generate_session_info(gensec_ntlmssp_state, gensec_security->event_ctx, gensec_security->lp_ctx, gensec_ntlmssp_state->server_info, session_info);
        NT_STATUS_NOT_OK_RETURN(nt_status);
 
        (*session_info)->session_key = data_blob_talloc(*session_info, 
index ed44754993b36e9fedf1130d1d2012b10b6a8208..a2090afcdc53372ee1e1e559b2b668ccaa4506a0 100644 (file)
@@ -428,6 +428,7 @@ NTSTATUS sam_get_results_principal(struct ldb_context *sam_ctx,
                                   
 /* Used in the gensec_gssapi and gensec_krb5 server-side code, where the PAC isn't available */
 NTSTATUS sam_get_server_info_principal(TALLOC_CTX *mem_ctx, 
+                                      struct event_context *event_ctx,
                                       struct loadparm_context *lp_ctx,
                                       const char *principal,
                                       struct auth_serversupplied_info **server_info)
@@ -445,7 +446,7 @@ NTSTATUS sam_get_server_info_principal(TALLOC_CTX *mem_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       sam_ctx = samdb_connect(tmp_ctx, lp_ctx, system_session(tmp_ctx, lp_ctx));
+       sam_ctx = samdb_connect(tmp_ctx, event_ctx, lp_ctx, system_session(tmp_ctx, lp_ctx));
        if (sam_ctx == NULL) {
                talloc_free(tmp_ctx);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
index 112eac95d84aec38c4a60c526a7cff1058f8846a..8f5e8d6c5612685b7c04512cd733efad4b0d2025 100644 (file)
 #include "auth/session_proto.h"
 
 _PUBLIC_ struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx, 
+                                           struct event_context *event_ctx, 
                                            struct loadparm_context *lp_ctx) 
 {
        NTSTATUS nt_status;
        struct auth_session_info *session_info = NULL;
-       nt_status = auth_anonymous_session_info(mem_ctx, lp_ctx, &session_info);
+       nt_status = auth_anonymous_session_info(mem_ctx, event_ctx, lp_ctx, &session_info);
        if (!NT_STATUS_IS_OK(nt_status)) {
                return NULL;
        }
@@ -43,6 +44,7 @@ _PUBLIC_ struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx,
 }
 
 _PUBLIC_ NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx, 
+                                    struct event_context *event_ctx, 
                                     struct loadparm_context *lp_ctx,
                                     struct auth_session_info **_session_info) 
 {
@@ -60,7 +62,7 @@ _PUBLIC_ NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx,
        }
 
        /* references the server_info into the session_info */
-       nt_status = auth_generate_session_info(parent_ctx, lp_ctx, server_info, &session_info);
+       nt_status = auth_generate_session_info(parent_ctx, event_ctx, lp_ctx, server_info, &session_info);
        talloc_free(mem_ctx);
 
        NT_STATUS_NOT_OK_RETURN(nt_status);
@@ -151,6 +153,7 @@ _PUBLIC_ NTSTATUS auth_anonymous_server_info(TALLOC_CTX *mem_ctx,
 }
 
 _PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx, 
+                                   struct event_context *event_ctx, 
                                    struct loadparm_context *lp_ctx,
                                    struct auth_serversupplied_info *server_info, 
                                    struct auth_session_info **_session_info) 
@@ -168,6 +171,7 @@ _PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx,
        session_info->session_key = server_info->user_session_key;
 
        nt_status = security_token_create(session_info,
+                                         event_ctx,
                                          lp_ctx,
                                          server_info->account_sid,
                                          server_info->primary_group_sid,
index 87fc47791a9e446dd7569e3f2bfd4eef007886ca..933b14a1b4481dc96e93b34277c02473e5221193 100644 (file)
@@ -1,6 +1,6 @@
 /* 
    Unix SMB/CIFS implementation.
-   Auth session handling
+   Process and provide the logged on user's authorization token
    Copyright (C) Andrew Bartlett   2001
    Copyright (C) Stefan Metzmacher 2005
    
@@ -30,12 +30,23 @@ struct auth_session_info {
 
 #include "librpc/gen_ndr/netlogon.h"
 
-struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
+/* Create a security token for a session SYSTEM (the most
+ * trusted/prvilaged account), including the local machine account as
+ * the off-host credentials */
 struct auth_session_info *system_session(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) ;
+
+/*
+ * Create a system session, but with anonymous credentials (so we do
+ * not need to open secrets.ldb) 
+ */
+struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
+
+
 NTSTATUS auth_anonymous_server_info(TALLOC_CTX *mem_ctx, 
                                    const char *netbios_name,
                                    struct auth_serversupplied_info **_server_info) ;
 NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx, 
+                                   struct event_context *event_ctx,
                                    struct loadparm_context *lp_ctx,
                                    struct auth_serversupplied_info *server_info, 
                                    struct auth_session_info **_session_info) ;
@@ -46,10 +57,12 @@ NTSTATUS make_server_info_netlogon_validation(TALLOC_CTX *mem_ctx,
                                              union netr_Validation *validation,
                                              struct auth_serversupplied_info **_server_info);
 NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx, 
+                                    struct event_context *ev_ctx,
                                     struct loadparm_context *lp_ctx,
                                     struct auth_session_info **_session_info);
 
 struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx, 
+                                           struct event_context *event_ctx,
                                            struct loadparm_context *lp_ctx);
 
 
index e99bbbb1abbd9309421b3ba832c4fdd845f29256..1d227fe46822fffd3363a510156a29984aa0b2fe 100644 (file)
@@ -147,9 +147,10 @@ static NTSTATUS generate_session_info(TALLOC_CTX *mem_ctx,
 
 
 
-/**
-  Create a system session, with machine account credentials
-*/
+/* Create a security token for a session SYSTEM (the most
+ * trusted/prvilaged account), including the local machine account as
+ * the off-host credentials
+ */ 
 _PUBLIC_ struct auth_session_info *system_session(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) 
 {
        NTSTATUS nt_status;
index 4a4b12bf69e77670dfdabd4343c87225ce67dfb3..b7a5994675961ed294de59c84c17def56efd4a3f 100644 (file)
@@ -24,7 +24,7 @@ the functionality, that's already done in other tests.
 """
 
 import unittest
-import auth
+from samba import auth
 
 class AuthTests(unittest.TestCase):
     def test_system_session(self):
index 0d0742e5d22a8bc99178c30b970e5905a5ea2b93..3a74ffc239505b6a080f08d3dab3920f14b3eb0b 100644 (file)
@@ -151,36 +151,12 @@ if test $BLDSHARED = true; then
                                ac_cv_shmod_works=yes
                        rm -f shlib.${SHLIBEXT} shlib.o
        ])
-       if test $ac_cv_shlib_works = no -o $ac_cv_shmod_works = no; then
-               BLDSHARED=false
+       if test $ac_cv_shlib_works = no; then
+               AC_MSG_ERROR(unable to build shared libraries)
+       fi
+       if test $ac_cv_shmod_works = no; then
+               AC_MSG_ERROR(unable to build shared modules)
        fi
-fi
-
-if test $BLDSHARED != true; then
-       SHLD="shared-libraries-disabled"
-       SHLD_FLAGS="shared-libraries-disabled"
-       MDLD="shared-modules-disabled"
-       MDLD_FLAGS="shared-modules-disabled"
-       SHLIBEXT="shared_libraries_disabled"
-       SONAMEFLAG="shared-libraries-disabled"
-       PICFLAG=""
-       AC_MSG_CHECKING([SHLD])
-       AC_MSG_RESULT([$SHLD])
-       AC_MSG_CHECKING([SHLD_FLAGS])
-       AC_MSG_RESULT([$SHLD_FLAGS])
-
-       AC_MSG_CHECKING([MDLD])
-       AC_MSG_RESULT([$MDLD])
-       AC_MSG_CHECKING([MDLD_FLAGS])
-       AC_MSG_RESULT([$MDLD_FLAGS])
-
-       AC_MSG_CHECKING([SHLIBEXT])
-       AC_MSG_RESULT([$SHLIBEXT])
-       AC_MSG_CHECKING([SONAMEFLAG])
-       AC_MSG_RESULT([$SONAMEFLAG])
-
-       AC_MSG_CHECKING([PICFLAG])
-       AC_MSG_RESULT([$PICFLAG])
 fi
 
 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
index 1eae998ca4b01585a3b043e5ef918815c1db0ff4..d932f09a694e71a404b4dcfbf0f824837da24edf 100644 (file)
@@ -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 #######################################################
@@ -37,13 +41,13 @@ ENABLE = YES
 "
 ])
 
-dnl SMB_LIBRARY(name,obj_files,required_subsystems,version,so_version,cflags,ldflags)
+dnl SMB_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags)
 AC_DEFUN([SMB_LIBRARY],
 [
 MAKE_SETTINGS="$MAKE_SETTINGS
 $1_CFLAGS = $6
 $1_LDFLAGS = $7
-$1_ENABLE = YES
+n1_ENABLE = YES
 $1_OBJ_FILES = $2
 "
 
@@ -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
+])
+])
index 6c1798212e89d557f019062d580375f093d307bd..66e5def8f0c846e224334a19d9e0febbf5881fab 100644 (file)
@@ -1,14 +1,18 @@
 pythonbuilddir = $(builddir)/bin/python
 
+installpython::
+       mkdir -p $(DESTDIR)$(pythondir)
+
 # Install Python
 # Arguments: Module path
 define python_module_template
 
 installpython:: $$(pythonbuilddir)/$(1) ;
-       cp $$< $$(DESTDIR)$$(PYTHONDIR)/$(1)
+       mkdir -p $$(DESTDIR)$$(pythondir)/$$(dir $(1))
+       cp $$< $$(DESTDIR)$$(pythondir)/$(1)
 
 uninstallpython:: 
-       rm -f $$(DESTDIR)$$(PYTHONDIR)/$(1) ;
+       rm -f $$(DESTDIR)$$(pythondir)/$(1) ;
 
 pythonmods:: $$(pythonbuilddir)/$(1) ;
 
@@ -25,7 +29,7 @@ $(call python_module_template,$(1))
 endef
 
 # Python C module
-# Arguments: Module path, object files
+# Arguments: File name, dependencies, link list
 define python_c_module_template
 
 $$(pythonbuilddir)/$(1): $(2) ; 
@@ -39,9 +43,9 @@ endef
 # Swig extensions
 swig:: pythonmods
 
-.SUFFIXES: _wrap.c .i
+.SUFFIXES: _wrap.c .i .py
 
-.i_wrap.c:
+%_wrap.c %.py: %.i
        [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
 
 realdistclean::
index faefb4e323ea2604e428802cb04c7ffb7df0ca70..176e67a691b77f40e85568b6bab9f9fbef9eb86c 100644 (file)
@@ -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
@@ -211,8 +114,8 @@ include/includes.d: include/includes.h
        @echo "Compiling $<"
        @-mkdir -p `dirname $@`
        @$(COMPILE) && exit 0 ; \
-       $(COMPILE) 
-
+               echo "The following command failed:" 1>&2;\
+               echo "$(subst ",\",$(COMPILE))" 1>&2 && exit 1
 
 
 .c.ho:
@@ -220,7 +123,7 @@ include/includes.d: include/includes.h
        @-mkdir -p `dirname $@`
        @$(HCOMPILE) && exit 0;\
                echo "The following command failed:" 1>&2;\
-               echo "$(HCOMPILE)" 1>&2;\
+               echo "$(subst ",\",$(HCOMPILE))" 1>&2;\
                $(HCOMPILE) >/dev/null 2>&1
 
 .h.h.gch:
@@ -233,7 +136,7 @@ include/includes.d: include/includes.h
 
 .l.c:
        @echo "Building $< with $(LEX)"
-       @-$(make_utility_dir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
+       @-$(make_utility_dir)/lex_compile.sh "$(LEX)" "$<" "$@"
 
 %.a:
        @echo Linking $@
diff --git a/source/build/make/templates.mk b/source/build/make/templates.mk
new file mode 100644 (file)
index 0000000..41a7ccd
--- /dev/null
@@ -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 $(notdir $(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
index 307c391e07b602f861a250d6bafee92d8f45fec6..652a52fa60520f61b48769d6d5329fb46da99409 100644 (file)
@@ -20,7 +20,7 @@ my $section_types = {
                "LDFLAGS"               => "list",
                },
        "PYTHON" => {
-               SWIG_FILE => "string",
+               "LIBRARY_REALNAME" => "string",
                "PRIVATE_DEPENDENCIES"  => "list",
                "PUBLIC_DEPENDENCIES"   => "list",
                "ENABLE"                => "bool",
@@ -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
@@ -208,7 +197,7 @@ sub run_config_mk($$$$)
                        $prev = "";
                }
 
-               if ($line =~ /^\[([-a-zA-Z0-9_:]+)\][\t ]*$/) 
+               if ($line =~ /^\[([-a-zA-Z0-9_.:]+)\][\t ]*$/) 
                {
                        $section = $1;
                        $infragment = 0;
@@ -244,7 +233,6 @@ sub run_config_mk($$$$)
                        $infragment = 1;
                        next;
                }
-
                
                # Assignment
                if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
@@ -254,7 +242,7 @@ sub run_config_mk($$$$)
                        next;
                }
 
-               die("$parsing_file:$linenum: Bad line while parsing $parsing_file");
+               die("$parsing_file:$linenum: Bad line");
        }
 
        $makefile .= "# }END $parsing_file\n";
index e50ee50f95369214385fd2f4b9b94cb51271bd79..b30c320c6e1fabdde929d74545cbd7d4d860d000 100755 (executable)
@@ -26,10 +26,10 @@ sub generate($$$)
        foreach my $part (values %{$depend}) {
                next if (defined($only) and not contains($only,$part->{NAME}));
                foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}}) {
-                       $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* public */\n";
+                       $res .= "\t\"$part->{NAME}\" -> \"$elem\" [style=filled]; /* public */\n";
                }
                foreach my $elem (@{$part->{PRIVATE_DEPENDENCIES}}) {
-                       $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* private */\n";
+                       $res .= "\t\"$part->{NAME}\" -> \"$elem\" [style=dotted]; /* private */\n";
                }
        }
 
diff --git a/source/build/smb_build/header.pm b/source/build/smb_build/header.pm
deleted file mode 100644 (file)
index dfb7c62..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-# SMB Build System
-# - create output for build.h
-#
-#  Copyright (C) Stefan (metze) Metzmacher 2004
-#  Copyright (C) Jelmer Vernooij 2005
-#  Released under the GNU GPL
-
-package header;
-use strict;
-
-sub _add_define_section($)
-{
-       my $DEFINE = shift;
-       my $output = "";
-
-       $output .= "
-/* $DEFINE->{COMMENT} */
-#define $DEFINE->{KEY} $DEFINE->{VAL}
-";
-
-       return $output;
-}
-
-sub _prepare_build_h($)
-{
-       my $depend = shift;
-       my @defines = ();
-       my $output = "";
-
-       foreach my $key (values %$depend) {
-               my $DEFINE = ();
-               next if ($key->{TYPE} ne "LIBRARY" and 
-                                $key->{TYPE} ne "MODULE" and
-                                $key->{TYPE} ne "SUBSYSTEM" and
-                                $key->{TYPE} ne "BINARY");
-               next unless defined($key->{INIT_FUNCTIONS});
-
-               my $name = $key->{NAME};
-               $name =~ s/-/_/g;
-               $DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
-               $DEFINE->{KEY} = "STATIC_$name\_MODULES";
-               $DEFINE->{VAL} = "\\\n";
-               foreach (@{$key->{INIT_FUNCTIONS}}) {
-                       $DEFINE->{VAL} .= "\t$_, \\\n";
-               }
-
-               die("Invalid sentinel") unless ($key->{INIT_FUNCTION_SENTINEL});
-               $DEFINE->{VAL} .= "\t$key->{INIT_FUNCTION_SENTINEL} \n";
-
-               push(@defines,$DEFINE);
-       }
-
-       #
-       # loop over all BUILD_H define sections
-       #
-       foreach (@defines) { $output .= _add_define_section($_); }
-
-       return $output;
-}
-
-###########################################################
-# This function creates include/build.h from the SMB_BUILD 
-# context
-#
-# create_build_h($SMB_BUILD_CTX)
-#
-# $SMB_BUILD_CTX -     the global SMB_BUILD context
-#
-# $output -            the resulting output buffer
-sub create_smb_build_h($$)
-{
-       my ($CTX, $file) = @_;
-
-       open(BUILD_H,">$file") || die ("Can't open `$file'\n");
-       print BUILD_H "/* autogenerated by build/smb_build/main.pl */\n";
-       print BUILD_H _prepare_build_h($CTX);
-       close(BUILD_H);
-
-       print __FILE__.": creating $file\n";
-}
-
-1;
index 3ca2f22f0c1991987213f7f628f8aa6d8fa0c6a7..a76da496d990e0ee18536e801c732e86d3aeb9d2 100644 (file)
@@ -94,10 +94,8 @@ sub check_module($$$)
        unless (defined($mod->{INIT_FUNCTION_SENTINEL})) { $mod->{INIT_FUNCTION_SENTINEL} = "NULL"; }
 
        if (not defined($mod->{OUTPUT_TYPE})) {
-               if (not defined($INPUT->{$mod->{SUBSYSTEM}}->{TYPE})) {
-                       die("Invalid type for subsystem $mod->{SUBSYSTEM}");
-               }
-               if ($INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
+               if ((not defined($INPUT->{$mod->{SUBSYSTEM}}->{TYPE})) or 
+                       $INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
                        $mod->{OUTPUT_TYPE} = undef;
                } else {
                        $mod->{OUTPUT_TYPE} = $default_ot;
@@ -140,24 +138,12 @@ sub check_python($$$)
 
        $python->{INSTALLDIR} = "PYTHONDIR";
        unless (defined($python->{CFLAGS})) { $python->{CFLAGS} = []; }
-       if (defined($python->{SWIG_FILE})) {
-               my $dirname = dirname($python->{SWIG_FILE});
-               my $basename = basename($python->{SWIG_FILE}, ".i");
-
-               $dirname .= "/" unless $dirname =~ /\/$/;
-               $dirname = "" if $dirname eq "./";
-
-               $python->{LIBRARY_REALNAME} = "_$basename.\$(SHLIBEXT)";
-               $python->{PYTHON_FILES} = ["$dirname$basename.py"];
-               push (@{$python->{CFLAGS}}, "\$(CFLAG_NO_UNUSED_MACROS)");
-               push (@{$python->{CFLAGS}}, "\$(CFLAG_NO_CAST_QUAL)");
-               $python->{INIT_FUNCTION} = "{ (char *)\"_$basename\", init_$basename }";
-       } else {
-               my $basename = $python->{NAME};
-               $basename =~ s/^python_//g;
+       my $basename = $python->{NAME};
+       $basename =~ s/^python_//g;
+       unless (defined($python->{LIBRARY_REALNAME})) {
                $python->{LIBRARY_REALNAME} = "$basename.\$(SHLIBEXT)";
-               $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
        }
+       $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
        push (@{$python->{CFLAGS}}, "\$(EXT_LIB_PYTHON_CFLAGS)");
 
        $python->{SUBSYSTEM} = "LIBPYTHON";
@@ -172,6 +158,8 @@ sub check_binary($$)
        return if ($bin->{ENABLE} ne "YES");
 
        ($bin->{BINARY} = (lc $bin->{NAME})) if not defined($bin->{BINARY});
+       unless (defined($bin->{INIT_FUNCTION_SENTINEL})) { $bin->{INIT_FUNCTION_SENTINEL} = "NULL"; }
+       unless (defined($bin->{INIT_FUNCTION_TYPE})) { $bin->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)"; }
 
        $bin->{OUTPUT_TYPE} = ["BINARY"];
        add_libreplace($bin);
@@ -181,15 +169,13 @@ sub add_implicit($$)
 {
        my ($INPUT, $n) = @_;
 
-       $INPUT->{$n} = {
-               TYPE => "MAKE_RULE",
-               NAME => $n,
-               OUTPUT_TYPE => undef,
-               LIBS => ["\$(".uc($n)."_LIBS)"],
-               LDFLAGS => ["\$(".uc($n)."_LDFLAGS)"],
-               CFLAGS => ["\$(".uc($n)."_CFLAGS)"],
-               CPPFLAGS => ["\$(".uc($n)."_CPPFLAGS)"]
-       };
+       $INPUT->{$n}->{TYPE} = "MAKE_RULE";
+       $INPUT->{$n}->{NAME} = $n;
+       $INPUT->{$n}->{OUTPUT_TYPE} = undef;
+       $INPUT->{$n}->{LIBS} = ["\$(".uc($n)."_LIBS)"];
+       $INPUT->{$n}->{LDFLAGS} = ["\$(".uc($n)."_LDFLAGS)"];
+       $INPUT->{$n}->{CFLAGS} = ["\$(".uc($n)."_CFLAGS)"];
+       $INPUT->{$n}->{CPPFLAGS} = ["\$(".uc($n)."_CPPFLAGS)"];
 }
 
 sub calc_unique_deps($$$$$$$$)
@@ -198,7 +184,7 @@ sub calc_unique_deps($$$$$$$$)
        my ($name, $INPUT, $deps, $udeps, $withlibs, $forward, $pubonly, $busy) = @_;
 
        foreach my $n (@$deps) {
-               add_implicit($INPUT, $n) unless (defined($INPUT->{$n}));
+               add_implicit($INPUT, $n) unless (defined($INPUT->{$n}) and defined($INPUT->{$n}->{TYPE}));
                my $dep = $INPUT->{$n};
                if (grep (/^$n$/, @$busy)) {
                        next if (@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ");
@@ -206,19 +192,19 @@ sub calc_unique_deps($$$$$$$$)
                }
                next if (grep /^$n$/, @$udeps);
 
-               push (@{$udeps}, $dep->{NAME}) if $forward;
+               push (@{$udeps}, $n) if $forward;
 
                if (defined ($dep->{OUTPUT_TYPE}) && 
                        ($withlibs or 
                        (@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ") or 
                        (@{$dep->{OUTPUT_TYPE}}[0] eq "STATIC_LIBRARY"))) {
-                               push (@$busy, $dep->{NAME});
-                               calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
-                               calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
+                               push (@$busy, $n);
+                               calc_unique_deps($n, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
+                               calc_unique_deps($n, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
                                pop (@$busy);
                }
 
-               unshift (@{$udeps}, $dep->{NAME}) unless $forward;
+               unshift (@{$udeps}, $n) unless $forward;
        }
 }
 
index 14897840a62e9591342e671243f7bdda8a4b5fbc..88289af26d8ca28133162330ae7449e588a02671 100644 (file)
@@ -6,16 +6,27 @@
 #  Released under the GNU GPL                          
 
 use smb_build::makefile;
-use smb_build::header;
 use smb_build::input;
 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"];
 
@@ -44,27 +55,24 @@ 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)");
 }
 
 foreach my $key (values %$OUTPUT) {
        next unless defined $key->{OUTPUT_TYPE};
 
+       $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
-       $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
-       if (defined($key->{PC_FILE})) {
-               $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
-       } 
        $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        if ($key->{TYPE} eq "LIBRARY" and 
            ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
                $shared_libs_used = 1;
        }
-       $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or 
-                                                                  $key->{TYPE} eq "PYTHON") and
-                                       grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
-       $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
+       if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
+               $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
+       }
        $mkenv->CFlags($key);
 }
 
@@ -80,15 +88,14 @@ foreach my $key (values %$OUTPUT) {
 
        $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
-       $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or 
-                                                                  $key->{TYPE} eq "PYTHON") and
-                                       grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
+       $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
+                                       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");
-header::create_smb_build_h($OUTPUT, "include/build.h");
+$mkenv->write($output_file);
 
 summary::show($OUTPUT, \%config::config);
 
index 8f3f1701b7c400f4ebf476846b60399042f091f0..0269cfe8a346712698c34f32cf29bbb501b153bf 100644 (file)
@@ -72,17 +72,7 @@ sub _prepare_mk_files($)
                push (@tmp, $_);
        }
 
-       $self->output("
-ifneq (\$(MAKECMDGOALS),clean)
-ifneq (\$(MAKECMDGOALS),distclean)
-ifneq (\$(MAKECMDGOALS),realdistclean)
-");
        $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
-       $self->output("
-endif
-endif
-endif
-");
 }
 
 sub array2oneperline($)
@@ -112,94 +102,41 @@ sub _prepare_list($$$)
        $self->output("$ctx->{NAME}_$var =$tmplist\n");
 }
 
-sub SharedModulePrimitives($$)
+sub PythonModule($$)
 {
        my ($self,$ctx) = @_;
-       
-       #FIXME
+
+       $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+       $self->_prepare_list($ctx, "DEPEND_LIST");
+       $self->_prepare_list($ctx, "LINK_FLAGS");
+
+       $self->output("\$(eval \$(call python_c_module_template,$ctx->{LIBRARY_REALNAME},\$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS)))\n");
 }
 
 sub SharedModule($$)
 {
        my ($self,$ctx) = @_;
 
-       my $init_obj = "";
-
        my $sane_subsystem = lc($ctx->{SUBSYSTEM});
        $sane_subsystem =~ s/^lib//;
        
-       if ($ctx->{TYPE} eq "PYTHON") {
-               $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
-       } else {
-               $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
-               $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
-               $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
-               $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n");
-               $self->output("\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
-               if (defined($ctx->{ALIASES})) {
-                       foreach (@{$ctx->{ALIASES}}) {
-                               $self->output("\t\@rm -f \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
-                               $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
-                       }
-               }
-
-               $self->output("uninstallplugins::\n");
-               $self->output("\t\@echo Uninstalling \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
-               $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
-
-               if (defined($ctx->{ALIASES})) {
-                       foreach (@{$ctx->{ALIASES}}) {
-                               $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
-                       }
-               }
-       }
+       $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
+       $self->output("\$(eval \$(call shared_module_install_template,$sane_subsystem,$ctx->{LIBRARY_REALNAME}))\n");
 
-       $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
        $self->_prepare_list($ctx, "FULL_OBJ_LIST");
        $self->_prepare_list($ctx, "DEPEND_LIST");
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
-       if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON" and 
-               $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/) {
-               my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
-               $init_fn =~ s/\(\*\)/init_module/;
-               my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
-               $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
-
-               $self->output(<< "__EOD__"
-bin/$ctx->{NAME}_init_module.c:
-       \@echo Creating \$\@
-       \@echo \"#include \\\"includes.h\\\"\" > \$\@
-       \@echo \"$proto_fn;\" >> \$\@
-       \@echo \"_PUBLIC_ $init_fn\" >> \$\@
-       \@echo \"{\" >> \$\@
-       \@echo \"       return $ctx->{INIT_FUNCTION}();\" >> \$\@
-       \@echo \"}\" >> \$\@
-       \@echo \"\" >> \$\@
-__EOD__
-);
-               $init_obj = "bin/$ctx->{NAME}_init_module.o";
+       if (defined($ctx->{INIT_FUNCTION}) and $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/ and not ($ctx->{INIT_FUNCTION} =~ /\(/)) {
+               $self->output("\$($ctx->{NAME}_OBJ_FILES): CFLAGS+=-D$ctx->{INIT_FUNCTION}=init_module\n");
        }
 
-       $self->output(<< "__EOD__"
-#
+       $self->output("\$(eval \$(call shared_module_template,$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS)))\n");
 
-$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj
-       \@echo Linking \$\@
-       \@mkdir -p $ctx->{SHAREDDIR}
-       \@\$(MDLD) \$(LDFLAGS) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
-               \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
-               \$($ctx->{NAME}_LINK_FLAGS)
-__EOD__
-);
 
        if (defined($ctx->{ALIASES})) {
-               foreach (@{$ctx->{ALIASES}}) {
-                       $self->output("\t\@rm -f $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
-                       $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
-               }
+               $self->output("\$(eval \$(foreach alias,". join(' ', @{$ctx->{ALIASES}}) . ",\$(call shared_module_alias_template,$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME},$sane_subsystem,\$(alias))))\n");
        }
-       $self->output("\n");
 }
 
 sub StaticLibraryPrimitives($$)
@@ -224,59 +161,33 @@ sub SharedLibrary($$)
 {
        my ($self,$ctx) = @_;
 
-       if (!defined($ctx->{LIBRARY_SONAME})) {
-               $ctx->{LIBRARY_SONAME} = "";
-       }
-
-       $self->output("SHARED_LIBS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
+       $self->output("SHARED_LIBS += $ctx->{RESULT_SHARED_LIBRARY}\n");
 
        $self->_prepare_list($ctx, "DEPEND_LIST");
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
-       $self->output(<< "__EOD__"
-$ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
-       \@echo Linking \$\@
-       \@mkdir -p \$(\@D)
-       \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
-               \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
-               \$($ctx->{NAME}_LINK_FLAGS) \\
-               \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME})
-__EOD__
-);
-       if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
-               $self->output("ifneq (\$($ctx->{NAME}_VERSION),\$($ctx->{NAME}_SOVERSION))\n");
-               $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n");
-               $self->output("endif\n");
-       }
-       $self->output("ifdef $ctx->{NAME}_SOVERSION\n");
-       $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n");
-       $self->output("endif\n");
+       $self->output("\$(eval \$(call shared_library_template,$ctx->{RESULT_SHARED_LIBRARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS),$ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME},$ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}))\n");
 }
 
 sub MergedObj($$)
 {
        my ($self, $ctx) = @_;
 
-       return unless defined($ctx->{OUTPUT});
-
-       $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
-       $self->output(<< "__EOD__"
-#
-$ctx->{RESULT_MERGED_OBJ}: \$($ctx->{NAME}_OBJ_FILES)
-       \@echo Partially linking \$@
-       \@mkdir -p \$(\@D)
-       \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_FILES)
+       $self->output("\$(call partial_link_template, $ctx->{OUTPUT}, \$($ctx->{NAME}_OBJ_FILES))\n");
+}
 
-__EOD__
-);
+sub InitFunctions($$)
+{
+       my ($self, $ctx) = @_;
+       $self->output("\$($ctx->{NAME}_OBJ_FILES): CFLAGS+=-DSTATIC_$ctx->{NAME}_MODULES=\"\$($ctx->{NAME}_INIT_FUNCTIONS)$ctx->{INIT_FUNCTION_SENTINEL}\"\n");
 }
 
 sub StaticLibrary($$)
 {
        my ($self,$ctx) = @_;
 
-       $self->output("STATIC_LIBS += $ctx->{TARGET_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
-
+       $self->output("STATIC_LIBS += $ctx->{RESULT_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
+       $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
        $self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n");
 }
 
@@ -285,74 +196,31 @@ sub Binary($$)
        my ($self,$ctx) = @_;
 
        unless (defined($ctx->{INSTALLDIR})) {
+               $self->output("BINARIES += $ctx->{TARGET_BINARY}\n");
        } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
-               $self->output("SBIN_PROGS += bin/$ctx->{BINARY}\n");
+               $self->output("SBIN_PROGS += $ctx->{RESULT_BINARY}\n");
        } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
-               $self->output("BIN_PROGS += bin/$ctx->{BINARY}\n");
+               $self->output("BIN_PROGS += $ctx->{RESULT_BINARY}\n");
        }
 
-       $self->output("binaries:: $ctx->{TARGET_BINARY}\n");
-
        $self->_prepare_list($ctx, "FULL_OBJ_LIST");
        $self->_prepare_list($ctx, "DEPEND_LIST");
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
-$self->output(<< "__EOD__"
-$ctx->{RESULT_BINARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
-       \@echo Linking \$\@
-__EOD__
-       );
-
        if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
-               $self->output(<< "__EOD__"
-       \@\$(HOSTLD) \$(HOSTLD_FLAGS) -L\${builddir}/bin/static -o \$\@ \$(INSTALL_LINK_FLAGS) \\
-               \$\($ctx->{NAME}_LINK_FLAGS)
-__EOD__
-               );
+$self->output("\$(call host_binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
        } else {
-               $self->output(<< "__EOD__"
-       \@\$(BNLD) \$(BNLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
-               \$\($ctx->{NAME}_LINK_FLAGS) 
-
-__EOD__
-               );
-       }
-}
-
-sub PythonFiles($$)
-{
-       my ($self,$ctx) = @_;
-
-       foreach (@{$ctx->{PYTHON_FILES}}) {
-               my $target = "bin/python/".basename($_);
-               my $source = "\$(addprefix $ctx->{BASEDIR}/, $_)";
-               $self->output("$target: $source\n\n");
-               $self->output("PYTHON_PYS += $target\n");
+$self->output("\$(call binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
        }
 }
 
-sub ProtoHeader($$)
-{
-       my ($self,$ctx) = @_;
-
-       my $priv = "$ctx->{BASEDIR}/$ctx->{PRIVATE_PROTO_HEADER}";
-       $self->output("PROTO_HEADERS += $priv\n");
-
-       $self->output("$priv: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_FILES:.o=.c) \$(srcdir)/script/mkproto.pl\n");
-       $self->output("\t\@echo \"Creating \$@\"\n");
-       $self->output("\t\@mkdir -p \$(\@D)\n");
-       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --public=/dev/null --private=\$@ \$($ctx->{NAME}_OBJ_FILES)\n\n");
-}
-
 sub write($$)
 {
        my ($self, $file) = @_;
 
-       $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
-
        $self->_prepare_mk_files();
 
-       $self->output($self->{mkfile});
+       $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
 
        open(MAKEFILE,">$file") || die ("Can't open $file\n");
        print MAKEFILE $self->{output};
index aeff7d48ce3e20cd1c0a5a73cb88d82b917c2129..f9f12c3a7326717a63fa9e8b419cd343ffc00d4f 100644 (file)
@@ -154,7 +154,7 @@ sub create_output($$)
                                push (@{$part->{FULL_OBJ_LIST}}, $elem->{TARGET});
                        } else {
                                push(@{$part->{LINK_FLAGS}}, "\$($elem->{NAME}_OUTPUT)") if defined($elem->{OUTPUT});
-                               push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
+                               push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if (defined($elem->{TARGET}));
                        }
                }
        }
diff --git a/source/build/tests/unixsock.c b/source/build/tests/unixsock.c
deleted file mode 100644 (file)
index f2765d6..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- c-file-style: "linux" -*-
- *
- * Try creating a Unix-domain socket, opening it, and reading from it.
- * The POSIX name for these is AF_LOCAL/PF_LOCAL.
- *
- * This is used by the Samba autoconf scripts to detect systems which
- * don't have Unix-domain sockets, such as (probably) VMS, or systems
- * on which they are broken under some conditions, such as RedHat 7.0
- * (unpatched).  We can't build WinBind there at the moment.
- *
- * Coding standard says to always use exit() for this, not return, so
- * we do.
- *
- * Martin Pool <mbp@samba.org>, June 2000. */
-
-/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */
-
-#include <stdio.h>
-
-#ifdef HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-
-#ifdef HAVE_SYS_UN_H
-#  include <sys/un.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
-#if HAVE_ERRNO_DECL
-# include <errno.h>
-#else
-extern int errno;
-#endif
-
-static int bind_socket(char const *filename)
-{
-       int sock_fd;
-       struct sockaddr_un name;
-       size_t size;
-       
-       /* Create the socket. */
-       if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
-               perror ("socket(PF_LOCAL, SOCK_STREAM)");
-               exit(1);
-       }
-     
-       /* Bind a name to the socket. */
-       name.sun_family = AF_LOCAL;
-       strncpy(name.sun_path, filename, sizeof (name.sun_path));
-     
-       /* The size of the address is
-          the offset of the start of the filename,
-          plus its length,
-          plus one for the terminating null byte.
-          Alternatively you can just do:
-          size = SUN_LEN (&name);
-      */
-       size = SUN_LEN(&name);
-       /* XXX: This probably won't work on unfriendly libcs */
-     
-       if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) {
-               perror ("bind");
-               exit(1);
-       }
-
-       return sock_fd;
-}
-
-
-int main(void)
-{
-       int sock_fd;
-       int kid;
-       char const *filename = "conftest.unixsock.sock";
-
-       /* abolish hanging */
-       alarm(15);              /* secs */
-
-       if ((sock_fd = bind_socket(filename)) < 0)
-               exit(1);
-
-       /* the socket will be deleted when autoconf cleans up these
-           files. */
-
-       exit(0);
-}
index 783e31d1ae622267ba55ed65a59f891d8157fb49..58e9e2d89b53af56db9002fac2d322e749af27e5 100644 (file)
@@ -187,7 +187,7 @@ static void cldapd_task_init(struct task_server *task)
        }
 
        cldapd->task = task;
-       cldapd->samctx = samdb_connect(cldapd, task->lp_ctx, anonymous_session(cldapd, task->lp_ctx));
+       cldapd->samctx = samdb_connect(cldapd, task->event_ctx, task->lp_ctx, anonymous_session(cldapd, task->event_ctx, task->lp_ctx));
        if (cldapd->samctx == NULL) {
                task_server_terminate(task, "cldapd failed to open samdb");
                return;
index c10cf57b5b2aaaf737aefd533b694b1efc85c62e..137a44d0f7931e2c539e78817383e1e0ddf6f517 100644 (file)
@@ -4,15 +4,15 @@
 # Start SUBSYSTEM CLDAPD
 [MODULE::CLDAPD]
 INIT_FUNCTION = server_service_cldapd_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = proto.h
+SUBSYSTEM = smbd
 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)))
index a524a6f8bdb3c1551ee28b44724dbaa85f0aa804..f263f33d48889ac89d5154c0be3a875b24a03064 100644 (file)
@@ -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
 #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;
        }
index 8e25dab92756969622859717438e297b4bf502ba..ce48c7bad1f7f73422b6bbb8038bdf7a6e6e22b4 100644 (file)
@@ -24,6 +24,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "libcli/resolve/resolve.h"
 #include "libcli/raw/libcliraw.h"
+#include "lib/events/events.h"
 
 #include "cifsdd.h"
 #include "param/param.h"
@@ -354,6 +355,7 @@ static void print_transfer_stats(void)
 }
 
 static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, 
+                                     struct event_context *ev,
                                      const char * which, const char **ports,
                                      struct smbcli_options *smb_options)
 {
@@ -375,13 +377,13 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
 
        if (strcmp(which, "if") == 0) {
                path = check_arg_pathname("if");
-               handle = dd_open_path(resolve_ctx, path, ports, 
+               handle = dd_open_path(resolve_ctx, ev, path, ports,
                                      check_arg_numeric("ibs"), options,
                                      smb_options);
        } else if (strcmp(which, "of") == 0) {
                options |= DD_WRITE;
                path = check_arg_pathname("of");
-               handle = dd_open_path(resolve_ctx, path, ports, 
+               handle = dd_open_path(resolve_ctx, ev, path, ports,
                                      check_arg_numeric("obs"), options,
                                      smb_options);
        } else {
@@ -396,7 +398,7 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
        return(handle);
 }
 
-static int copy_files(struct loadparm_context *lp_ctx)
+static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx)
 {
        uint8_t *       iobuf;  /* IO buffer. */
        uint64_t        iomax;  /* Size of the IO buffer. */
@@ -433,12 +435,12 @@ static int copy_files(struct loadparm_context *lp_ctx)
        DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
                        (unsigned long long)iomax, options.max_xmit));
 
-       if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if", 
+       if (!(ifile = open_file(lp_resolve_context(lp_ctx), ev, "if",
                                lp_smb_ports(lp_ctx), &options))) {
                return(FILESYS_EXIT_CODE);
        }
 
-       if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of", 
+       if (!(ofile = open_file(lp_resolve_context(lp_ctx), ev, "of",
                                lp_smb_ports(lp_ctx), &options))) {
                return(FILESYS_EXIT_CODE);
        }
@@ -528,6 +530,7 @@ int main(int argc, const char ** argv)
 {
        int i;
        const char ** dd_args;
+       struct event_context *ev;
 
        poptContext pctx;
        struct poptOption poptions[] = {
@@ -578,6 +581,8 @@ int main(int argc, const char ** argv)
                }
        }
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(cmdline_lp_ctx);
        dump_args();
 
@@ -599,7 +604,7 @@ int main(int argc, const char ** argv)
 
        CatchSignal(SIGINT, dd_handle_signal);
        CatchSignal(SIGUSR1, dd_handle_signal);
-       return(copy_files(cmdline_lp_ctx));
+       return(copy_files(ev, cmdline_lp_ctx));
 }
 
 /* vim: set sw=8 sts=8 ts=8 tw=79 : */
index 810c882ea9afb4502378c0eb2d5c386050fcb13c..21a4ad488222048da96c650a219b3ab6533fb7e1 100644 (file)
@@ -89,8 +89,10 @@ struct dd_iohandle
 #define DD_OPLOCK              0x00000008
 
 struct smbcli_options;
+struct event_context;
 
 struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, 
+                                 struct event_context *ev,
                                  const char * path,
                                  const char **ports,
                                uint64_t io_size, int options, 
index 7028e8507887e8a97d57a04fd9f74cbe528d579f..4297c300121ef6c4f57b379caa9005975619efb8 100644 (file)
@@ -221,6 +221,7 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted,
 }
 
 static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx,
+                                             struct event_context *ev,
                                              const char * host,
                                              const char **ports,
                                              const char * share,
@@ -233,8 +234,9 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct
         * each connection, but for now, we just use the same one for both.
         */
        ret = smbcli_full_connection(NULL, &cli, host, ports, share,
-                        NULL /* devtype */, cmdline_credentials, resolve_ctx, 
-                        NULL /* events */, options);
+                                    NULL /* devtype */,
+                                    cmdline_credentials, resolve_ctx,
+                                    ev, options);
 
        if (!NT_STATUS_IS_OK(ret)) {
                fprintf(stderr, "%s: connecting to //%s/%s: %s\n",
@@ -293,6 +295,7 @@ static int open_smb_file(struct smbcli_state * cli,
 }
 
 static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx,
+                                            struct event_context *ev,
                                             const char * host,
                                        const char **ports,
                                        const char * share,
@@ -319,7 +322,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
        smbh->h.io_write = smb_write_func;
        smbh->h.io_seek = smb_seek_func;
 
-       if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share,
+       if ((smbh->cli = init_smb_session(resolve_ctx, ev, host, ports, share,
                                          smb_options)) == NULL) {
                return(NULL);
        }
@@ -336,6 +339,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
 /* ------------------------------------------------------------------------- */
 
 struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, 
+                                 struct event_context *ev,
                                  const char * path,
                                  const char **ports,
                                uint64_t io_size,
@@ -355,7 +359,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
                        /* Skip over leading directory separators. */
                        while (*remain == '/' || *remain == '\\') { remain++; }
 
-                       return(open_cifs_handle(resolve_ctx, host, ports, 
+                       return(open_cifs_handle(resolve_ctx, ev, host, ports,
                                                share, remain,
                                                io_size, options, smb_options));
                }
index 775aa69d37d404e1e1d7f29c3c8499169a152525..01197e8a9ee8cc2abffaf9ade19a01c00ed5eb18 100644 (file)
@@ -32,6 +32,7 @@
 #include "includes.h"
 #include "version.h"
 #include "libcli/libcli.h"
+#include "lib/events/events.h"
 #include "lib/cmdline/popt_common.h"
 #include "librpc/gen_ndr/ndr_srvsvc_c.h"
 #include "librpc/gen_ndr/ndr_lsa.h"
@@ -213,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;
 }
@@ -2545,7 +2549,9 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1)
 /****************************************************************************
 try and browse available shares on a host
 ****************************************************************************/
-static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
+static bool browse_host(struct loadparm_context *lp_ctx,
+                       struct event_context *ev_ctx,
+                       const char *query_host)
 {
        struct dcerpc_pipe *p;
        char *binding;
@@ -2559,7 +2565,7 @@ static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
 
        status = dcerpc_pipe_connect(mem_ctx, &p, binding, 
                                         &ndr_table_srvsvc,
-                                    cmdline_credentials, NULL,
+                                    cmdline_credentials, ev_ctx,
                                     lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Failed to connect to %s - %s\n", 
@@ -3021,6 +3027,7 @@ static int process_stdin(struct smbclient_context *ctx)
 return a connection to a server
 *******************************************************/
 static bool do_connect(struct smbclient_context *ctx, 
+                      struct event_context *ev_ctx,
                       struct resolve_context *resolve_ctx,
                       const char *specified_server, const char **ports, 
                       const char *specified_share, 
@@ -3044,8 +3051,7 @@ static bool do_connect(struct smbclient_context *ctx,
        
        status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
                                        share, NULL, cred, resolve_ctx, 
-                                       cli_credentials_get_event_context(cred),
-                                       options);
+                                       ev_ctx, options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to \\\\%s\\%s failed - %s\n", 
                         server, share, nt_errstr(status));
@@ -3059,9 +3065,12 @@ static bool do_connect(struct smbclient_context *ctx,
 /****************************************************************************
 handle a -L query
 ****************************************************************************/
-static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host, const char *workgroup)
+static int do_host_query(struct loadparm_context *lp_ctx,
+                        struct event_context *ev_ctx,
+                        const char *query_host,
+                        const char *workgroup)
 {
-       browse_host(lp_ctx, query_host);
+       browse_host(lp_ctx, ev_ctx, query_host);
        list_servers(workgroup);
        return(0);
 }
@@ -3070,7 +3079,12 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host
 /****************************************************************************
 handle a message operation
 ****************************************************************************/
-static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options)
+static int do_message_op(const char *netbios_name, const char *desthost,
+                        const char **destports, const char *destip,
+                        int name_type,
+                        struct event_context *ev_ctx,
+                        struct resolve_context *resolve_ctx,
+                        struct smbcli_options *options)
 {
        struct nbt_name called, calling;
        const char *server_name;
@@ -3082,7 +3096,9 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
 
        server_name = destip ? destip : desthost;
 
-       if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) {
+       if (!(cli = smbcli_state_init(NULL)) ||
+           !smbcli_socket_connect(cli, server_name, destports,
+                                  ev_ctx, resolve_ctx, options)) {
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
@@ -3111,11 +3127,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
        const char *query_host = NULL;
        bool message = false;
        const char *desthost = NULL;
-#ifdef KANJI
-       const char *term_code = KANJI;
-#else
-       const char *term_code = "";
-#endif /* KANJI */
        poptContext pc;
        const char *service = NULL;
        int port = 0;
@@ -3123,6 +3134,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
        int rc = 0;
        int name_type = 0x20;
        TALLOC_CTX *mem_ctx;
+       struct event_context *ev_ctx;
        struct smbclient_context *ctx;
        const char *cmdstr = NULL;
        struct smbcli_options smb_options;
@@ -3134,7 +3146,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
                { "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" },
                { "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" },
                { "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" },
-               { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" },
                { "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" },
                { "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" }, 
                { "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" },
@@ -3176,9 +3187,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
                case 'L':
                        query_host = strdup(poptGetOptArg(pc));
                        break;
-               case 't':
-                       term_code = strdup(poptGetOptArg(pc));
-                       break;
                case 'D':
                        base_directory = strdup(poptGetOptArg(pc));
                        break;
@@ -3220,6 +3228,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
 
        lp_smbcli_options(cmdline_lp_ctx, &smb_options);
 
+       ev_ctx = event_context_init(talloc_autofree_context());
+
        DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
 
        if (query_host && (p=strchr_m(query_host,'#'))) {
@@ -3229,14 +3239,23 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
        }
   
        if (query_host) {
-               return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx));
+               rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host,
+                                  lp_workgroup(cmdline_lp_ctx));
+               return rc;
        }
 
        if (message) {
-               return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options);
+               rc = do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost,
+                                  lp_smb_ports(cmdline_lp_ctx), dest_ip,
+                                  name_type, ev_ctx,
+                                  lp_resolve_context(cmdline_lp_ctx),
+                                  &smb_options);
+               return rc;
        }
        
-       if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options))
+       if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx),
+                       desthost, lp_smb_ports(cmdline_lp_ctx), service,
+                       cmdline_credentials, &smb_options))
                return 1;
 
        if (base_directory) 
index 5cfa542fbab3a3fde5da644256cece54606d09d6..877544a09af962ed8ad2088c413ba9e8b65469f7 100644 (file)
@@ -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)
index 00ac597f947926b41d4887f84f02d5b731c7a6e7..e841956a0c07671b8c0c4e3b554a42568e087967 100644 (file)
@@ -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)
index 01c639d142a658ff6fd0d443eb9ccfad478157da..28b18c17ce979be81d4e0db7b28bbea6852a62dd 100644 (file)
@@ -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 \
index 48c3c2ea4cf0f8fd61e00b5b84a6329de79d9959..0ed44cbad031611e96713d7c6a32491433c840bf 100644 (file)
@@ -21,7 +21,7 @@ extern int LogLevel;
 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
 
 #ifndef discard_const
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
 #endif
 
 struct timeval timeval_zero(void);
index 66fb69694e30c9d1cedea0b1548a6a3db022970d..73d3ffd4d9b6c60bde0b4a91710b70a810e1f150 100644 (file)
@@ -31,7 +31,7 @@ m4_include(pidl/config.m4)
 AC_CONFIG_FILES(lib/registry/registry.pc)
 AC_CONFIG_FILES(librpc/dcerpc.pc)
 AC_CONFIG_FILES(librpc/ndr.pc)
-AC_CONFIG_FILES(torture/torture.pc)
+AC_CONFIG_FILES(lib/torture/torture.pc)
 AC_CONFIG_FILES(auth/gensec/gensec.pc)
 AC_CONFIG_FILES(param/samba-hostconfig.pc)
 AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
@@ -59,7 +59,6 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1,
        [
                SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk)
                SMB_INCLUDE_MK(lib/ldb/tools/config.mk)
-               SMB_SUBSYSTEM(ldb_map, [], [LIBLDB])
                define_ldb_modulesdir=no
        ],
        [
@@ -161,25 +160,7 @@ 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!
-
-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
+SMB_WRITE_PERLVARS(build/smb_build/config.pm)
 
 echo "configure: creating config.mk"
 cat >config.mk<<CEOF
@@ -189,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
@@ -223,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
index 2144d61dfcab0ec26486ef5c000b008a4c13ed4f..20bba7a0d93aa413955509da1537e58eca08261f 100644 (file)
@@ -49,14 +49,15 @@ struct sidmap_context {
 /*
   open a sidmap context - use talloc_free to close
 */
-struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx, 
+                                  struct loadparm_context *lp_ctx)
 {
        struct sidmap_context *sidmap;
        sidmap = talloc(mem_ctx, struct sidmap_context);
        if (sidmap == NULL) {
                return NULL;
        }
-       sidmap->samctx = samdb_connect(sidmap, lp_ctx, system_session(sidmap, lp_ctx));
+       sidmap->samctx = samdb_connect(sidmap, ev_ctx, lp_ctx, system_session(sidmap, lp_ctx));
        if (sidmap->samctx == NULL) {
                talloc_free(sidmap);
                return NULL;
index e334e4c6e34cdfec220c7d7964cdc310a121b6c6..7b700fda22ffbdc8207c0164f30f0a5f20ef7c98 100644 (file)
@@ -5,57 +5,57 @@ 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
 
 #######################
 # Start SUBSYSTEM DREPL_SRV
 [MODULE::DREPL_SRV]
 INIT_FUNCTION = server_service_drepl_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = repl/drepl_service_proto.h
+SUBSYSTEM = smbd
 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)))
index 3375059e99e00e58976f4a0af4e59105ad4dcd63..e485c50a473d5e94f0199adc37bbeceb4c492508 100644 (file)
@@ -51,7 +51,7 @@ static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service, struct lo
        const struct GUID *ntds_guid;
        struct drsuapi_DsBindInfo28 *bind_info28;
 
-       service->samdb = samdb_connect(service, lp_ctx, service->system_session_info);
+       service->samdb = samdb_connect(service, service->task->event_ctx, lp_ctx, service->system_session_info);
        if (!service->samdb) {
                return WERR_DS_SERVICE_UNAVAILABLE;
        }
index b9333e451bade34a437f63b53f749673cb0977d0..da10cbb0577fda7032ceab332e6bdbd02567605f 100644 (file)
@@ -1197,6 +1197,7 @@ NTSTATUS crack_service_principal_name(struct ldb_context *sam_ctx,
 }
 
 NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx, 
+                               struct event_context *ev_ctx, 
                                struct loadparm_context *lp_ctx,
                                uint32_t format_offered,
                                const char *name, 
@@ -1214,7 +1215,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
                return NT_STATUS_OK;
        }
 
-       ldb = samdb_connect(mem_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
+       ldb = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
        if (ldb == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
@@ -1259,6 +1260,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
 }
 
 NTSTATUS crack_auto_name_to_nt4_name(TALLOC_CTX *mem_ctx,
+                                    struct event_context *ev_ctx, 
                                     struct loadparm_context *lp_ctx,
                                     const char *name,
                                     const char **nt4_domain,
@@ -1283,5 +1285,5 @@ NTSTATUS crack_auto_name_to_nt4_name(TALLOC_CTX *mem_ctx,
                format_offered = DRSUAPI_DS_NAME_FORMAT_CANONICAL;
        }
 
-       return crack_name_to_nt4_name(mem_ctx, lp_ctx, format_offered, name, nt4_domain, nt4_account);
+       return crack_name_to_nt4_name(mem_ctx, ev_ctx, lp_ctx, format_offered, name, nt4_domain, nt4_account);
 }
index 414b449ba8cbd29de6a0a8630bb132ae6684fa66..eae190a85fcacac21a68c185b3bc2c342924a6cb 100644 (file)
@@ -4,7 +4,7 @@
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR NDR_MISC
-INIT_FUNCTION = objectguid_module_module_ops
+INIT_FUNCTION = LDB_MODULE(objectguid)
 # End MODULE ldb_objectguid
 ################################################
 
@@ -17,7 +17,7 @@ SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBNDR NDR_MISC NDR_DRSUAPI \
                                           NDR_DRSBLOBS LIBNDR
-INIT_FUNCTION = repl_meta_data_module_module_ops
+INIT_FUNCTION = LDB_MODULE(repl_meta_data)
 # End MODULE ldb_repl_meta_data
 ################################################
 
@@ -30,7 +30,7 @@ ldb_repl_meta_data_OBJ_FILES = \
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = dsdb_cache_module_module_ops
+INIT_FUNCTION = LDB_MODULE(dsdb_cache)
 # End MODULE ldb_dsdb_cache
 ################################################
 
@@ -43,7 +43,7 @@ ldb_dsdb_cache_OBJ_FILES = \
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = schema_fsmo_module_module_ops
+INIT_FUNCTION = LDB_MODULE(schema_fsmo)
 # End MODULE ldb_schema_fsmo
 ################################################
 
@@ -56,7 +56,7 @@ ldb_schema_fsmo_OBJ_FILES = \
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = naming_fsmo_module_module_ops
+INIT_FUNCTION = LDB_MODULE(naming_fsmo)
 # End MODULE ldb_naming_fsmo
 ################################################
 
@@ -69,7 +69,7 @@ ldb_naming_fsmo_OBJ_FILES = \
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = pdc_fsmo_module_module_ops
+INIT_FUNCTION = LDB_MODULE(pdc_fsmo)
 # End MODULE ldb_pdc_fsmo
 ################################################
 
@@ -82,7 +82,7 @@ ldb_pdc_fsmo_OBJ_FILES = \
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC LDAP_ENCODE NDR_MISC SAMDB
-INIT_FUNCTION = samldb_module_module_ops
+INIT_FUNCTION = LDB_MODULE(samldb)
 #
 # End MODULE ldb_samldb
 ################################################
@@ -95,10 +95,9 @@ ldb_samldb_OBJ_FILES = \
 [MODULE::ldb_samba3sam]
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = &ldb_samba3sam_module_module_ops
-PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map SMBPASSWD NSS_WRAPPER LIBSECURITY \
+INIT_FUNCTION = LDB_MODULE(samba3sam)
+PRIVATE_DEPENDENCIES = LIBTALLOC SMBPASSWD NSS_WRAPPER LIBSECURITY \
                                           NDR_SECURITY
-#
 # End MODULE ldb_samldb
 ################################################
 
@@ -110,11 +109,10 @@ ldb_samba3sam_OBJ_FILES = \
 [MODULE::ldb_simple_ldap_map]
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = &ldb_simple_ldap_map_module_module_ops
-PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map LIBNDR NDR_MISC
+INIT_FUNCTION = LDB_MODULE(simple_ldap_map)
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR NDR_MISC
 ENABLE = YES
 ALIASES = entryuuid nsuniqueid
-#
 # End MODULE ldb_entryuuid
 ################################################
 
@@ -125,7 +123,7 @@ ldb_simple_ldap_map_OBJ_FILES = \
 # # Start MODULE ldb_proxy
 # [MODULE::ldb_proxy]
 # SUBSYSTEM = LIBLDB
-# INIT_FUNCTION = proxy_module_module_ops
+# INIT_FUNCTION = LDB_MODULE(proxy)
 # OBJ_FILES = \
 #              proxy.o
 # 
@@ -139,7 +137,7 @@ ldb_simple_ldap_map_OBJ_FILES = \
 SUBSYSTEM = LIBLDB
 PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
 OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = rootdse_module_module_ops
+INIT_FUNCTION = LDB_MODULE(rootdse)
 # End MODULE ldb_rootdse
 ################################################
 
@@ -150,7 +148,7 @@ ldb_rootdse_OBJ_FILES = dsdb/samdb/ldb_modules/rootdse.o
 [MODULE::ldb_password_hash]
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = password_hash_module_module_ops
+INIT_FUNCTION = LDB_MODULE(password_hash)
 PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC HEIMDAL_KRB5 LDAP_ENCODE \
                                           LIBCLI_AUTH NDR_DRSBLOBS KERBEROS SAMDB
 # End MODULE ldb_password_hash
@@ -164,7 +162,7 @@ ldb_password_hash_OBJ_FILES = dsdb/samdb/ldb_modules/password_hash.o
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR SAMDB
 OUTPUT_TYPE = SHARED_LIBRARY
 SUBSYSTEM = LIBLDB
-INIT_FUNCTION = local_password_module_module_ops
+INIT_FUNCTION = LDB_MODULE(local_password)
 # End MODULE ldb_local_password
 ################################################
 
@@ -176,7 +174,7 @@ ldb_local_password_OBJ_FILES = dsdb/samdb/ldb_modules/local_password.o
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY SAMDB
 OUTPUT_TYPE = SHARED_LIBRARY
 SUBSYSTEM = LIBLDB
-INIT_FUNCTION = &ldb_kludge_acl_module_ops
+INIT_FUNCTION = LDB_MODULE(kludge_acl)
 
 # End MODULE ldb_kludge_acl
 ################################################
@@ -189,7 +187,7 @@ ldb_kludge_acl_OBJ_FILES = dsdb/samdb/ldb_modules/kludge_acl.o
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR LIBSECURITY SAMDB
-INIT_FUNCTION = &ldb_extended_dn_module_ops
+INIT_FUNCTION = LDB_MODULE(extended_dn)
 # End MODULE ldb_extended_dn
 ################################################
 
@@ -201,7 +199,7 @@ ldb_extended_dn_OBJ_FILES = dsdb/samdb/ldb_modules/extended_dn.o
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_show_deleted_module_ops
+INIT_FUNCTION = LDB_MODULE(show_deleted)
 # End MODULE ldb_show_deleted
 ################################################
 
@@ -213,7 +211,7 @@ ldb_show_deleted_OBJ_FILES = dsdb/samdb/ldb_modules/show_deleted.o
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
-INIT_FUNCTION = &ldb_partition_module_ops
+INIT_FUNCTION = LDB_MODULE(partition)
 # End MODULE ldb_partition
 ################################################
 
@@ -225,7 +223,7 @@ ldb_partition_OBJ_FILES = dsdb/samdb/ldb_modules/partition.o
 SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBLDB
-INIT_FUNCTION = &ldb_schema_module_ops
+INIT_FUNCTION = LDB_MODULE(schema)
 # End MODULE ldb_schema
 ################################################
 
@@ -238,7 +236,7 @@ SUBSYSTEM = LIBLDB
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC CREDENTIALS
 #Also depends on credentials, but that would loop
-INIT_FUNCTION = &ldb_update_kt_module_ops
+INIT_FUNCTION = LDB_MODULE(update_kt)
 # End MODULE ldb_update_kt
 ################################################
 
@@ -247,7 +245,7 @@ ldb_update_keytab_OBJ_FILES = dsdb/samdb/ldb_modules/update_keytab.o
 ################################################
 # Start MODULE ldb_objectclass
 [MODULE::ldb_objectclass]
-INIT_FUNCTION = &ldb_objectclass_module_ops
+INIT_FUNCTION = LDB_MODULE(objectclass)
 OUTPUT_TYPE = SHARED_LIBRARY
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY NDR_SECURITY SAMDB
@@ -260,7 +258,7 @@ ldb_objectclass_OBJ_FILES = dsdb/samdb/ldb_modules/objectclass.o
 ################################################
 # Start MODULE ldb_subtree_rename
 [MODULE::ldb_subtree_rename]
-INIT_FUNCTION = &ldb_subtree_rename_module_ops
+INIT_FUNCTION = LDB_MODULE(subtree_rename)
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
 SUBSYSTEM = LIBLDB
@@ -272,7 +270,7 @@ ldb_subtree_rename_OBJ_FILES = dsdb/samdb/ldb_modules/subtree_rename.o
 ################################################
 # Start MODULE ldb_subtree_rename
 [MODULE::ldb_subtree_delete]
-INIT_FUNCTION = &ldb_subtree_delete_module_ops
+INIT_FUNCTION = LDB_MODULE(subtree_delete)
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
 SUBSYSTEM = LIBLDB
@@ -284,7 +282,7 @@ ldb_subtree_delete_OBJ_FILES = dsdb/samdb/ldb_modules/subtree_delete.o
 ################################################
 # Start MODULE ldb_linked_attributes
 [MODULE::ldb_linked_attributes]
-INIT_FUNCTION = &ldb_linked_attributes_module_ops
+INIT_FUNCTION = LDB_MODULE(linked_attributes)
 CFLAGS = -Ilib/ldb/include
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
@@ -297,7 +295,7 @@ ldb_linked_attributes_OBJ_FILES = dsdb/samdb/ldb_modules/linked_attributes.o
 ################################################
 # Start MODULE ldb_ranged_results
 [MODULE::ldb_ranged_results]
-INIT_FUNCTION = &ldb_ranged_results_module_ops
+INIT_FUNCTION = LDB_MODULE(ranged_results)
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
 SUBSYSTEM = LIBLDB
@@ -309,7 +307,7 @@ ldb_ranged_results_OBJ_FILES = dsdb/samdb/ldb_modules/ranged_results.o
 ################################################
 # Start MODULE ldb_anr
 [MODULE::ldb_anr]
-INIT_FUNCTION = &ldb_anr_module_ops
+INIT_FUNCTION = LDB_MODULE(anr)
 CFLAGS = -Ilib/ldb/include
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
@@ -322,7 +320,7 @@ ldb_anr_OBJ_FILES = dsdb/samdb/ldb_modules/anr.o
 ################################################
 # Start MODULE ldb_normalise
 [MODULE::ldb_normalise]
-INIT_FUNCTION = &ldb_normalise_module_ops
+INIT_FUNCTION = LDB_MODULE(normalise)
 CFLAGS = -Ilib/ldb/include
 OUTPUT_TYPE = SHARED_LIBRARY
 PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
@@ -335,10 +333,10 @@ ldb_normalise_OBJ_FILES = dsdb/samdb/ldb_modules/normalise.o
 ################################################
 # Start MODULE ldb_instancetype
 [MODULE::ldb_instancetype]
-INIT_FUNCTION = &ldb_instancetype_module_ops
+INIT_FUNCTION = LDB_MODULE(instancetype)
 CFLAGS = -Ilib/ldb/include
 OUTPUT_TYPE = SHARED_LIBRARY
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
 SUBSYSTEM = LIBLDB
 # End MODULE ldb_instancetype
 ################################################
index 3b67ca19d35b2c55434770ebba90cfa07a0feb60..88590f306beddbf2a6712f5ca49202f727b2af39 100644 (file)
@@ -484,8 +484,7 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
        return ret;
 }
 
-static int samldb_fill_user_or_computer_object(struct ldb_module *module, const struct ldb_message *msg,
-                                                              struct ldb_message **ret_msg)
+static int samldb_fill_user_or_computer_object(struct ldb_module *module, const struct ldb_message *msg, struct ldb_message **ret_msg)
 {
        int ret;
        char *name;
index 54362dcfd47157b4fac33f57cddd4de6969e5cf1..b36c2c9b71443f20ef0454b9142c79df7f0b69da 100644 (file)
@@ -90,7 +90,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet
        }
 
        cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm"));
-       status = cli_credentials_set_secrets(item->creds, ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter);
+       status = cli_credentials_set_secrets(item->creds, ldb_get_opaque(module->ldb, "EventContext"), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter);
        talloc_free(filter);
        if (NT_STATUS_IS_OK(status)) {
                if (delete) {
@@ -158,7 +158,7 @@ static int update_kt_end_trans(struct ldb_module *module)
        struct dn_list *p;
        for (p=data->changed_dns; p; p = p->next) {
                int kret;
-               kret = cli_credentials_update_keytab(p->creds, ldb_get_opaque(module->ldb, "loadparm"));
+               kret = cli_credentials_update_keytab(p->creds, ldb_get_opaque(module->ldb, "EventContext"), ldb_get_opaque(module->ldb, "loadparm"));
                if (kret != 0) {
                        talloc_free(data->changed_dns);
                        data->changed_dns = NULL;
index a01e4425878a4e134c75b6b6f55f6d9fb5fb8eb7..9154f5382ba6eebd7ef93598247be6a4c9e68414 100644 (file)
@@ -37,6 +37,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "dsdb/common/flags.h"
 #include "param/param.h"
+#include "lib/events/events.h"
 
 char *samdb_relative_path(struct ldb_context *ldb,
                                 TALLOC_CTX *mem_ctx, 
@@ -71,11 +72,12 @@ char *samdb_relative_path(struct ldb_context *ldb,
   return an opaque context pointer on success, or NULL on failure
  */
 struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx, 
+                                 struct event_context *ev_ctx,
                                  struct loadparm_context *lp_ctx,
                                  struct auth_session_info *session_info)
 {
        struct ldb_context *ldb;
-       ldb = ldb_wrap_connect(mem_ctx, lp_ctx, 
+       ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, 
                               lp_sam_url(lp_ctx), session_info,
                               NULL, 0, NULL);
        if (!ldb) {
@@ -98,6 +100,8 @@ int samdb_copy_template(struct ldb_context *ldb,
        struct ldb_context *templates_ldb;
        char *templates_ldb_path; 
        struct ldb_dn *basedn;
+       struct event_context *event_ctx;
+       struct loadparm_context *lp_ctx;
 
        templates_ldb = talloc_get_type(ldb_get_opaque(ldb, "templates_ldb"), struct ldb_context);
 
@@ -109,8 +113,17 @@ int samdb_copy_template(struct ldb_context *ldb,
                        *errstring = talloc_asprintf(msg, "samdb_copy_template: ERROR: Failed to contruct path for template db");
                        return LDB_ERR_OPERATIONS_ERROR;
                }
+               
+               event_ctx = (struct event_context *)ldb_get_opaque(ldb, "EventContext");
+               lp_ctx = (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm");
+
+               /* FIXME: need to remove this wehn we finally pass the event
+                * context around in ldb */
+               if (event_ctx == NULL) {
+                       event_ctx = event_context_init(templates_ldb);
+               }
 
-               templates_ldb = ldb_wrap_connect(ldb, (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm")
+               templates_ldb = ldb_wrap_connect(ldb, event_ctx, lp_ctx
                                                templates_ldb_path, NULL,
                                                NULL, 0, NULL);
                talloc_free(templates_ldb_path);
@@ -184,6 +197,7 @@ int samdb_copy_template(struct ldb_context *ldb,
  Create the SID list for this user.
 ****************************************************************************/
 NTSTATUS security_token_create(TALLOC_CTX *mem_ctx, 
+                              struct event_context *ev_ctx, 
                               struct loadparm_context *lp_ctx,
                               struct dom_sid *user_sid,
                               struct dom_sid *group_sid, 
@@ -242,7 +256,7 @@ NTSTATUS security_token_create(TALLOC_CTX *mem_ctx,
        }
 
        /* setup the privilege mask for this token */
-       status = samdb_privilege_setup(lp_ctx, ptoken);
+       status = samdb_privilege_setup(ev_ctx, lp_ctx, ptoken);
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(ptoken);
                return status;
index 5d8694d2d499fbc839a790f2ebd2b0fe4b4296d2..8370857aba325f5d87ceaa37718a0331ccf69265 100644 (file)
@@ -27,6 +27,7 @@ struct dsdb_control_current_partition;
 struct dsdb_extended_replicated_object;
 struct dsdb_extended_replicated_objects;
 struct loadparm_context;
+struct event_context;
 
 #include "librpc/gen_ndr/security.h"
 #include "lib/ldb/include/ldb.h"
@@ -36,6 +37,7 @@ struct loadparm_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 {
index 5c2de81816c97b26e8a92328a37badd1eebe4da6..688d1ef9de3da4586d3337f2fbee4573a85c7c48 100644 (file)
@@ -73,7 +73,8 @@ static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx,
   setup the privilege mask for this security token based on our
   local SAM
 */
-NTSTATUS samdb_privilege_setup(struct loadparm_context *lp_ctx, struct security_token *token)
+NTSTATUS samdb_privilege_setup(struct event_context *ev_ctx, 
+                              struct loadparm_context *lp_ctx, struct security_token *token)
 {
        void *samctx;
        TALLOC_CTX *mem_ctx;
@@ -97,7 +98,7 @@ NTSTATUS samdb_privilege_setup(struct loadparm_context *lp_ctx, struct security_
        }
 
        mem_ctx = talloc_new(token);
-       samctx = samdb_connect(mem_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
+       samctx = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
        if (samctx == NULL) {
                talloc_free(mem_ctx);
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
index 487d924036ce6d2468bd3de5f542a492e62fd4b5..f365911c6a0ffc630546f43d2d372952cec82e1b 100644 (file)
@@ -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 $@
+
index fbfc56e127436ac923caf319ff5c105dd6844f8e..91e28b2a1abc6a4c41c0afa600c042dff5609052 100644 (file)
@@ -44,7 +44,7 @@ rpc_server/common/common.h: dcerpc_server/common.h
 libcli/auth/credentials.h: domain_credentials.h
 lib/charset/charset.h: charset.h
 libcli/ldap/ldap.h: ldap.h
-torture/torture.h: torture.h
+lib/torture/torture.h: torture.h
 libcli/libcli.h: client.h
 librpc/gen_ndr/nbt.h: gen_ndr/nbt.h
 librpc/gen_ndr/svcctl.h: gen_ndr/svcctl.h
@@ -60,7 +60,7 @@ lib/util/asn1.h: samba/asn1.h
 libcli/util/error.h: core/error.h
 lib/tdb_wrap.h: tdb_wrap.h
 lib/ldb_wrap.h: ldb_wrap.h
-torture/ui.h: torture/ui.h
+torture/smbtorture.h: smbtorture.h
 librpc/gen_ndr/winbind.h: gen_ndr/winbind.h
 param/share.h: share.h
 lib/util/util_tdb.h: util_tdb.h
@@ -71,3 +71,4 @@ lib/events/events_internal.h: events/events_internal.h
 libcli/ldap/ldap_ndr.h: ldap_ndr.h
 lib/events/events.h: events.h
 lib/events/events_internal.h: events_internal.h
+auth/session.h: samba/session.h
index 33d2edb67bdb7e30c135249d27d720606f53420a..a4f24c90266ec13e22217f67566ca9329dbeb276 100644 (file)
@@ -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,210 +65,210 @@ 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
 
 
 #######################
 # Start SUBSYSTEM HEIMDAL_KRB5
 [SUBSYSTEM::HEIMDAL_KRB5]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 
+CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/asn1 -Iheimdal/lib/com_err 
 PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_PKINIT_ASN1 HEIMDAL_WIND
 PUBLIC_DEPENDENCIES = HEIMDAL_KRB5_ASN1 HEIMDAL_GLUE HEIMDAL_HX509 HEIMDAL_HCRYPTO
 # End SUBSYSTEM HEIMDAL_KRB5
 #######################
 
 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
index 94ba933e573bbf1574ce0b7eff1f0200dbfa791a..b3b8b216f07f95d567a1f6c4dea562402d32b932 100644 (file)
@@ -4,23 +4,23 @@
 # Start SUBSYSTEM KDC
 [MODULE::KDC]
 INIT_FUNCTION = server_service_kdc_init
-SUBSYSTEM = service
+SUBSYSTEM = smbd
 PRIVATE_DEPENDENCIES = \
                LIBLDB HEIMDAL HEIMDAL_KDC HEIMDAL_HDB SAMDB
 # 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)))
index d983b77b40dc01efaa1610b01457faa4ed9da994..9c7b1f6457a85dbec24008f67de1bfb435220d6f 100644 (file)
@@ -50,6 +50,7 @@
 #include "librpc/gen_ndr/ndr_drsblobs.h"
 #include "libcli/auth/libcli_auth.h"
 #include "param/param.h"
+#include "events/events.h"
 
 enum hdb_ldb_ent_type 
 { HDB_LDB_ENT_TYPE_CLIENT, HDB_LDB_ENT_TYPE_SERVER, 
@@ -1106,6 +1107,7 @@ static krb5_error_code LDB_destroy(krb5_context context, HDB *db)
  * code */
 
 NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx, 
+                           struct event_context *ev_ctx, 
                            struct loadparm_context *lp_ctx,
                            krb5_context context, struct HDB **db, const char *arg)
 {
@@ -1137,7 +1139,7 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx,
                                           CRED_DONT_USE_KERBEROS);
 
        /* Setup the link to LDB */
-       (*db)->hdb_db = samdb_connect(*db, lp_ctx, session_info);
+       (*db)->hdb_db = samdb_connect(*db, ev_ctx, lp_ctx, session_info);
        if ((*db)->hdb_db == NULL) {
                DEBUG(1, ("hdb_ldb_create: Cannot open samdb for KDC backend!"));
                return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
@@ -1168,7 +1170,7 @@ krb5_error_code hdb_ldb_create(krb5_context context, struct HDB **db, const char
 {
        NTSTATUS nt_status;
        /* The global kdc_mem_ctx and kdc_lp_ctx, Disgusting, ugly hack, but it means one less private hook */
-       nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, kdc_lp_ctx, 
+       nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, event_context_find(kdc_mem_ctx), kdc_lp_ctx, 
                                       context, db, arg);
 
        if (NT_STATUS_IS_OK(nt_status)) {
index 72b5bb14a93c531b266d67a105def35e45632119..84d9d45f5768310705877707a41dbf33f3d578d8 100644 (file)
@@ -624,7 +624,7 @@ static void kdc_task_init(struct task_server *task)
        }
        kdc->config->num_db = 1;
                
-       status = kdc_hdb_ldb_create(kdc, task->lp_ctx, 
+       status = kdc_hdb_ldb_create(kdc, task->event_ctx, task->lp_ctx, 
                                    kdc->smb_krb5_context->krb5_context, 
                                    &kdc->config->db[0], NULL);
        if (!NT_STATUS_IS_OK(status)) {
index f468fea6c4466a532c0116ceb15c05a09ca01953..1d49a8a4bd23d726fe56754cd6fd6cd3fbfe63b1 100644 (file)
@@ -180,7 +180,7 @@ static bool kpasswdd_change_password(struct kdc_server *kdc,
        struct samr_DomInfo1 *dominfo;
        struct ldb_context *samdb;
 
-       samdb = samdb_connect(mem_ctx, kdc->task->lp_ctx, system_session(mem_ctx, kdc->task->lp_ctx));
+       samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx, system_session(mem_ctx, kdc->task->lp_ctx));
        if (!samdb) {
                return kpasswdd_make_error_reply(kdc, mem_ctx, 
                                                KRB5_KPASSWD_HARDERROR,
@@ -310,7 +310,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
                
                krb5_free_principal(context, principal);
                
-               samdb = samdb_connect(mem_ctx, kdc->task->lp_ctx, session_info);
+               samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx, session_info);
                if (!samdb) {
                        return kpasswdd_make_error_reply(kdc, mem_ctx, 
                                                         KRB5_KPASSWD_HARDERROR,
@@ -474,7 +474,7 @@ bool kpasswdd_process(struct kdc_server *kdc,
         * we already have, rather than a new context */        
        cli_credentials_set_krb5_context(server_credentials, kdc->smb_krb5_context);
        cli_credentials_set_conf(server_credentials, kdc->task->lp_ctx);
-       nt_status = cli_credentials_set_stored_principal(server_credentials, kdc->task->lp_ctx, "kadmin/changepw");
+       nt_status = cli_credentials_set_stored_principal(server_credentials, kdc->task->event_ctx, kdc->task->lp_ctx, "kadmin/changepw");
        if (!NT_STATUS_IS_OK(nt_status)) {
                ret = kpasswdd_make_unauth_error_reply(kdc, mem_ctx, 
                                                       KRB5_KPASSWD_HARDERROR,
index 03cc41d69d2ff1f8abe3e0ef887765d4bcab1774..65f5b17f9a350956e84e8020aa8866e4dedca8e1 100644 (file)
@@ -4,8 +4,7 @@
 # Start SUBSYSTEM LDAP
 [MODULE::LDAP]
 INIT_FUNCTION = server_service_ldap_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = proto.h
+SUBSYSTEM = smbd
 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)))
index 9b43d7bd742ca757cc76089d1ab5c214b2bb60fe..9047773529906a5a55a138e3d3a8c3095b90a303 100644 (file)
@@ -27,6 +27,7 @@
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
+#include "smbd/service_stream.h"
 
 #define VALID_DN_SYNTAX(dn,i) do {\
        if (!(dn)) {\
@@ -56,6 +57,7 @@ static int map_ldb_error(struct ldb_context *ldb, int err, const char **errstrin
 NTSTATUS ldapsrv_backend_Init(struct ldapsrv_connection *conn) 
 {
        conn->ldb = ldb_wrap_connect(conn, 
+                                    conn->connection->event.ctx,
                                     conn->lp_ctx,
                                     lp_sam_url(conn->lp_ctx), 
                                     conn->session_info,
index f2c974ae3f76eab52f89f82a409e772e8dabc88e..f37ef31c0adb15057e77e75bfca0a449072e5384 100644 (file)
@@ -44,7 +44,7 @@ static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
 
        DEBUG(10, ("BindSimple dn: %s\n",req->dn));
 
-       status = crack_auto_name_to_nt4_name(call, call->conn->lp_ctx, req->dn, &nt4_domain, &nt4_account);
+       status = crack_auto_name_to_nt4_name(call, call->conn->connection->event.ctx, call->conn->lp_ctx, req->dn, &nt4_domain, &nt4_account);
        if (NT_STATUS_IS_OK(status)) {
                status = authenticate_username_pw(call,
                                                  call->conn->connection->event.ctx,
index 11cb63e07bf2f3d753b11c9cfb576f345cb5f349..197f84692c14bb82cdce6cdba01acc61b3dc7110 100644 (file)
@@ -409,7 +409,7 @@ static void ldapsrv_accept(struct stream_connection *c)
        conn->server_credentials = server_credentials;
 
        /* Connections start out anonymous */
-       if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, conn->lp_ctx, &conn->session_info))) {
+       if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, c->event.ctx, conn->lp_ctx, &conn->session_info))) {
                ldapsrv_terminate_connection(conn, "failed to setup anonymous session info");
                return;
        }
@@ -478,7 +478,8 @@ static NTSTATUS add_socket(struct event_context *event_context,
        }
 
        /* Load LDAP database */
-       ldb = samdb_connect(ldap_service, lp_ctx, system_session(ldap_service, lp_ctx));
+       ldb = samdb_connect(ldap_service, ldap_service->task->event_ctx, 
+                           lp_ctx, system_session(ldap_service, lp_ctx));
        if (!ldb) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
index c0bba35ba5dc2fa34600c2db01eeb9f7d9c8d40f..4d27b69fb5d3bba4cfcc3fc4193d3b1af2989e15 100644 (file)
@@ -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)
index 52b23608aa7e403846355e4be88c67c2b747f35b..381815eb231a9c83cdabdc73def1d6c7bbf3bcc4 100644 (file)
@@ -31,6 +31,7 @@
 
 #include       "miniMpr.h"
 #include "param/param.h"
+#include "lib/events/events.h"
 
 /************************************ Code ************************************/
 #if !BLD_APPWEB
@@ -50,6 +51,11 @@ void *mprMemCtx(void)
        return mpr_ctx;
 }
 
+struct event_context *mprEventCtx(void)
+{
+       return event_context_find(mprMemCtx());
+}
+
 /* return the loadparm context being used for all ejs variables */
 struct loadparm_context *mprLpCtx(void)
 {
index 15ce30c8df9d52eef3d723ee41d888fe197465dc..2b8ff0af6a98c79682ec980d0b3a5573c3efcff2 100644 (file)
@@ -274,6 +274,8 @@ extern void mprSetCtx(void *ctx);
 extern void *mprMemCtx(void);
 struct loadparm_context;
 extern struct loadparm_context *mprLpCtx(void);
+struct event_context;
+extern struct event_context *mprEventCtx(void);
 
 /* This function needs to be provided by anyone using ejs */
 void ejs_exception(const char *reason);
index a02151282c798a0edef582ce34d6e5bed42e8882..b86df5dc9f48d3443c9f65bd2acbad8a2131a30c 100644 (file)
@@ -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 policy/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
-
 [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)
index e5e5bd4560e7e1bcea8b34ced532c680b7dd4ca7..12c2f5f321f6b2506e5c15ce247b82492bfc3602 100644 (file)
@@ -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)))
index f8a971a0630b069eaadd2e039efdf2a5e6de7fb2..4434ff3701a18cd073b4dfa9c272e74511115556 100644 (file)
@@ -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)))
index 82dbe4a4cb30c3b2732e8c030bdc80e486fa3c11..b9a7f7cb9ec962809fc056a5ca6e9709714455fc 100644 (file)
@@ -4,16 +4,16 @@
 # 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)
 
 
 [MODULE::TORTURE_LIBCRYPTO]
-SUBSYSTEM = torture
+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)))
index 0e943bd74d7584368ab9cb65da22858987b65cb8..77777642771e3b4b93b854fbb0e3b836658ed77d 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 #include "includes.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
 
 #include "lib/crypto/crypto.h"
 
index 9038873d326f96f11aaef7cca7e3a97ecb65ec8c..34e2629b162f0ef5afefd409e8239599a1132977 100644 (file)
@@ -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/source/lib/events/Makefile.in b/source/lib/events/Makefile.in
new file mode 100644 (file)
index 0000000..0a0df9b
--- /dev/null
@@ -0,0 +1,66 @@
+#!gmake
+#
+# Makefile for tdb directory
+#
+
+CC = @CC@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+includedir = @includedir@
+libdir = @libdir@
+VPATH = @srcdir@:@tallocdir@:@libreplacedir@
+srcdir = @srcdir@
+builddir = @builddir@
+CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I.
+LDFLAGS = @LDFLAGS@
+EXEEXT = @EXEEXT@
+SHLD = @SHLD@
+SHLD_FLAGS = @SHLD_FLAGS@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PICFLAG = @PICFLAG@
+SHLIBEXT = @SHLIBEXT@
+SWIG = swig
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@
+PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@
+PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@
+LIB_PATH_VAR = @LIB_PATH_VAR@
+eventsdir = @eventsdir@
+tallocdir = @tallocdir@
+
+TALLOC_LIBS = @TALLOC_LIBS@
+TALLOC_CFLAGS = @TALLOC_CFLAGS@
+TALLOC_OBJ = @TALLOC_OBJ@
+
+CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) @CFLAGS@
+
+EVENTS_OBJ = @EVENTS_OBJ@ $(TALLOC_OBJ) @LIBREPLACEOBJ@
+
+default: all
+
+include $(eventsdir)/events.mk
+include $(eventsdir)/rules.mk
+
+all:: showflags dirs $(PROGS) $(LIBEVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET)
+
+install:: all
+$(LIBEVENTS_SOLIB): $(EVENTS_OBJ)
+       $(SHLD) $(SHLD_FLAGS) -o $@ $(EVENTS_OBJ) $(TALLOC_LIBS) @SONAMEFLAG@$(LIBEVENTS_SONAME)
+
+check: test
+
+test:: $(PYTHON_CHECK_TARGET)
+installcheck:: test install
+
+clean::
+       rm -f *.o *.a */*.o
+       rm -f $(TALLOC_OBJ)
+
+distclean:: clean
+       rm -f config.log config.status include/config.h config.cache
+       rm -f Makefile
+
+realdistclean:: distclean
+       rm -f configure include/config.h.in
diff --git a/source/lib/events/autogen.sh b/source/lib/events/autogen.sh
new file mode 100755 (executable)
index 0000000..b13a4b6
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+rm -rf autom4te.cache
+rm -f configure config.h.in
+
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
+IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
+autoconf $IPATHS || exit 1
+autoheader $IPATHS || exit 1
+
+rm -rf autom4te.cache
+
+swig -O -Wall -python -keyword events.i # Ignore errors for now
+
+echo "Now run ./configure and then make."
+exit 0
+
index e5a1316c47064318b6a607c625a07221a8e6f3da..9d579807c8cd65d3af3b4da56e14dce13869a42f 100644 (file)
@@ -1,3 +1,13 @@
+################################################
+# Start SUBSYSTEM LIBEVENTS
+[LIBRARY::LIBEVENTS]
+PUBLIC_DEPENDENCIES = LIBTALLOC
+OUTPUT_TYPE = STATIC_LIBRARY
+CFLAGS = -Ilib/events
+#
+# End SUBSYSTEM LIBEVENTS
+################################################
+
 ##############################
 [MODULE::EVENTS_AIO]
 PRIVATE_DEPENDENCIES = LIBAIO_LINUX
@@ -5,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]
@@ -13,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]
@@ -21,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]
@@ -29,21 +39,24 @@ 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
 [SUBSYSTEM::LIBEVENTS]
-PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
 # 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
+LIBRARY_REALNAME = samba/_events.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG
+
+swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o
+
+$(eval $(call python_py_module_template,samba/events.py,$(libeventssrcdir)/events.py))
 
-swig_events_OBJ_FILES = lib/events/events_wrap.o
+$(swig_events_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source/lib/events/configure.ac b/source/lib/events/configure.ac
new file mode 100644 (file)
index 0000000..4eb3575
--- /dev/null
@@ -0,0 +1,35 @@
+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(events, 1.0.0)
+AC_CONFIG_SRCDIR([events.c])
+AC_CONFIG_HEADER(config.h)
+AC_LIBREPLACE_ALL_CHECKS
+AC_LIBREPLACE_NETWORK_CHECKS
+
+m4_include(libtalloc.m4)
+
+AC_LD_EXPORT_DYNAMIC
+AC_LD_SONAMEFLAG
+AC_LD_PICFLAG
+AC_LD_SHLIBEXT
+AC_LIBREPLACE_SHLD
+AC_LIBREPLACE_SHLD_FLAGS
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+m4_include(libevents.m4)
+AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config])
+AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python])
+
+PYTHON_BUILD_TARGET="build-python"
+PYTHON_INSTALL_TARGET="install-python"
+PYTHON_CHECK_TARGET="check-python"
+AC_SUBST(PYTHON_BUILD_TARGET)
+AC_SUBST(PYTHON_INSTALL_TARGET)
+AC_SUBST(PYTHON_CHECK_TARGET)
+if test -z "$PYTHON_CONFIG"; then
+       PYTHON_BUILD_TARGET=""
+       PYTHON_INSTALL_TARGET=""
+       PYTHON_CHECK_TARGET=""
+fi
+AC_OUTPUT(Makefile events.pc)
index 568aadc31e1f1e6c3c2398cd8216860b950e2c07..ccc62b4c83ce77ba69df9b7c2206bfe9334e752d 100644 (file)
   forever.
 
 */
-
+#if _SAMBA_BUILD_
 #include "includes.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
 #include "lib/util/dlinklist.h"
 #include "param/param.h"
-#if _SAMBA_BUILD_
-#include "build.h"
+#else
+#include "replace.h"
+#include "events_util.h"
 #endif
+#include "events.h"
+#include "events_internal.h"
 
 struct event_ops_list {
        struct event_ops_list *next, *prev;
@@ -207,6 +208,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char
 */
 struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
 {
+       DEBUG(0, ("New event context requested. Parent: [%s:%p]\n",
+                 mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx));
        return event_context_init_byname(mem_ctx, NULL);
 }
 
@@ -286,7 +289,7 @@ struct signal_event *event_add_signal(struct event_context *ev, TALLOC_CTX *mem_
 /*
   do a single event loop using the events defined in ev 
 */
-_PUBLIC_ int event_loop_once(struct event_context *ev)
+int event_loop_once(struct event_context *ev)
 {
        return ev->ops->loop_once(ev);
 }
index 263605b176ce8d98063ae77ffc9d61281dc00aa6..7de8aec79d08539b4f7db14232ad0b8299ca658f 100644 (file)
 %import "../talloc/talloc.i";
 
 %{
-#include "lib/events/events.h"
+#include "events.h"
 typedef struct event_context event;
 %}
 
 typedef struct event_context {
     %extend {
+        %feature("docstring") event "S.__init__()";
         event(TALLOC_CTX *mem_ctx) { return event_context_init(mem_ctx); }
+        %feature("docstring") loop_once "S.loop_once() -> int";
         int loop_once(void);
+        %feature("docstring") loop_wait "S.loop_wait() -> int";
         int loop_wait(void);
     }
 } event;
@@ -44,6 +47,8 @@ typedef struct event_context {
 
 struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
 
+%feature("docstring") event_backend_list "event_backend_list() -> list";
 const char **event_backend_list(TALLOC_CTX *mem_ctx);
+%feature("docstring") event_set_default_backend "event_set_default_backend(name) -> None";
 %rename(set_default_backend) event_set_default_backend;
 void event_set_default_backend(const char *backend);
diff --git a/source/lib/events/events.mk b/source/lib/events/events.mk
new file mode 100644 (file)
index 0000000..64d3fcb
--- /dev/null
@@ -0,0 +1,59 @@
+dirs::
+       @mkdir -p lib
+
+LIBEVENTS_SONAME = libevents.$(SHLIBEXT).0
+LIBEVENTS_SOLIB = libevents.$(SHLIBEXT).$(PACKAGE_VERSION)
+
+LIBEVENTS = libevents.a
+
+clean::
+       rm -f $(LIBEVENTS_SONAME) $(LIBEVENTS_SOLIB) libevents.a libevents.$(SHLIBEXT)
+       rm -f events.pc
+
+build-python:: _libevents.$(SHLIBEXT)
+
+events_wrap.o: $(eventsdir)/events_wrap.c
+       $(CC) $(PICFLAG) -c $(eventsdir)/events_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
+
+_libevents.$(SHLIBEXT): libevents.$(SHLIBEXT) events_wrap.o
+       $(SHLD) $(SHLD_FLAGS) -o $@ events_wrap.o -L. -levents `$(PYTHON_CONFIG) --libs`
+
+install:: installdirs installbin installheaders installlibs \
+                 $(PYTHON_INSTALL_TARGET)
+
+install-python:: build-python
+       mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
+               $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+       cp $(eventsdir)/events.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"`
+       cp _libevents.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+
+check-python:: build-python
+       $(LIB_PATH_VAR)=. PYTHONPATH=".:$(eventsdir)" $(PYTHON) $(eventsdir)/python/tests/simple.py
+
+install-swig::
+       mkdir -p $(DESTDIR)`$(SWIG) -swiglib`
+       cp events.i $(DESTDIR)`$(SWIG) -swiglib`
+
+clean::
+       rm -f _libevents.$(SHLIBEXT)
+
+installdirs::
+       mkdir -p $(DESTDIR)$(includedir)
+       mkdir -p $(DESTDIR)$(libdir)
+       mkdir -p $(DESTDIR)$(libdir)/pkgconfig
+
+installheaders:: installdirs
+       cp $(srcdir)/events.h $(DESTDIR)$(includedir)
+
+installlibs:: all installdirs
+       cp events.pc $(DESTDIR)$(libdir)/pkgconfig
+       cp libevents.a $(LIBEVENTS_SOLIB) $(DESTDIR)$(libdir)
+
+libevents.a: $(EVENTS_OBJ)
+       ar -rv libevents.a $(EVENTS_OBJ)
+
+libevents.$(SHLIBEXT): $(LIBEVENTS_SOLIB)
+       ln -fs $< $@
+
+$(LIBEVENTS_SONAME): $(LIBEVENTS_SOLIB)
+       ln -fs $< $@
diff --git a/source/lib/events/events.pc.in b/source/lib/events/events.pc.in
new file mode 100644 (file)
index 0000000..4a4c012
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: events
+Description: An event system library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -levents
+Cflags: -I${includedir} 
+URL: http://samba.org/
index d8f70f6319e138140e9ae3a6bbabbebb6e773816..264e0b7cdf9005b64cb1bfc297c3ec8b931a4be0 100644 (file)
@@ -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.
 
@@ -61,7 +61,16 @@ class event(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): 
+        """S.__init__()"""
         _events.event_swiginit(self,_events.new_event(*args, **kwargs))
+    def loop_once(*args, **kwargs):
+        """S.loop_once() -> int"""
+        return _events.event_loop_once(*args, **kwargs)
+
+    def loop_wait(*args, **kwargs):
+        """S.loop_wait() -> int"""
+        return _events.event_loop_wait(*args, **kwargs)
+
     __swig_destroy__ = _events.delete_event
 event.loop_once = new_instancemethod(_events.event_loop_once,None,event)
 event.loop_wait = new_instancemethod(_events.event_loop_wait,None,event)
@@ -69,7 +78,13 @@ event_swigregister = _events.event_swigregister
 event_swigregister(event)
 
 event_context_init_byname = _events.event_context_init_byname
-event_backend_list = _events.event_backend_list
-set_default_backend = _events.set_default_backend
+
+def event_backend_list(*args):
+  """event_backend_list() -> list"""
+  return _events.event_backend_list(*args)
+
+def set_default_backend(*args, **kwargs):
+  """event_set_default_backend(name) -> None"""
+  return _events.set_default_backend(*args, **kwargs)
 
 
index 109027eb1abbd49074724e7d009b6a44da3f2b58..07e66154fc6026027c147d5ea3cca81d68ac12de 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#if _SAMBA_BUILD_
 #include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
 #include "system/filesys.h"
 #include "system/network.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
 #include <sys/epoll.h>
 
 struct epoll_event_context {
@@ -56,9 +61,11 @@ struct epoll_event_context {
   called when a epoll call fails, and we should fallback
   to using select
 */
-_NORETURN_ static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
+static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
 {
+#if _SAMBA_BUILD_
        DEBUG(0,("%s (%s) - calling abort()\n", reason, strerror(errno)));
+#endif
        abort();
 }
 
index f4b7e4e5ebd1f67735a8c35b365dbcf55652a679..16fff71e4a591e1c688e2a64e890d9258d6e4976 100644 (file)
 
 */
 
+#if _SAMBA_BUILD_
 #include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
 #include "system/filesys.h"
 #include "system/select.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
 
 struct select_event_context {
        /* a pointer back to the generic event_context */
@@ -216,7 +221,9 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
                   made readable and that should have removed
                   the event, so this must be a bug. This is a
                   fatal error. */
+#if _SAMBA_BUILD_
                DEBUG(0,("ERROR: EBADF on select_event_loop_once\n"));
+#endif
                select_ev->exit_code = EBADF;
                return -1;
        }
index c0771cbe01fd6ede8f84dc770d999905cb4fc3cf..7128612fb03f572b4297a503c875904546646feb 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#if _SAMBA_BUILD_
 #include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include <signal.h>
+#include "replace.h"
+#include "events_util.h"
+#endif
 #include "system/filesys.h"
 #include "system/select.h"
-#include "system/wait.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
 
 #define NUM_SIGNALS 64
 
index 7b945b154d96780d1ff9a113b7f49afaa070991a..4e41c42206d541529de8ad0520ec2082caa97899 100644 (file)
     at runtime we fallback to select()
 */
 
+#if _SAMBA_BUILD_
 #include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
 #include "system/filesys.h"
 #include "system/network.h"
 #include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
 
 struct std_event_context {
        /* a pointer back to the generic event_context */
index 389c2cbbb7c7dd4349b93260a3f7853a34ee1955..79e4cde795009f723cf51f64990187b417fd1d12 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#if _SAMBA_BUILD_
 #include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
 #include "system/filesys.h"
 #include "system/select.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
 
 /*
   destroy a timed event
diff --git a/source/lib/events/events_util.c b/source/lib/events/events_util.c
new file mode 100644 (file)
index 0000000..74e1147
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 2005
+   Copyright (C) Jelmer Vernooij 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 "replace.h"
+#include "talloc.h"
+
+/**
+  return the number of elements in a string list
+*/
+static size_t str_list_length(const char **list)
+{
+       size_t ret;
+       for (ret=0;list && list[ret];ret++) /* noop */ ;
+       return ret;
+}
+
+/**
+  add an entry to a string list
+*/
+const char **str_list_add(const char **list, const char *s)
+{
+       size_t len = str_list_length(list);
+       const char **ret;
+
+       ret = talloc_realloc(NULL, list, const char *, len+2);
+       if (ret == NULL) return NULL;
+
+       ret[len] = talloc_strdup(ret, s);
+       if (ret[len] == NULL) return NULL;
+
+       ret[len+1] = NULL;
+
+       return ret;
+}
+
+/**
+  compare two timeval structures. 
+  Return -1 if tv1 < tv2
+  Return 0 if tv1 == tv2
+  Return 1 if tv1 > tv2
+*/
+static int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
+{
+       if (tv1->tv_sec  > tv2->tv_sec)  return 1;
+       if (tv1->tv_sec  < tv2->tv_sec)  return -1;
+       if (tv1->tv_usec > tv2->tv_usec) return 1;
+       if (tv1->tv_usec < tv2->tv_usec) return -1;
+       return 0;
+}
+
+/**
+  return a zero timeval
+*/
+struct timeval timeval_zero(void)
+{
+       struct timeval tv;
+       tv.tv_sec = 0;
+       tv.tv_usec = 0;
+       return tv;
+}
+
+/**
+  return true if a timeval is zero
+*/
+bool timeval_is_zero(const struct timeval *tv)
+{
+       return tv->tv_sec == 0 && tv->tv_usec == 0;
+}
+
+/**
+  return a timeval for the current time
+*/
+struct timeval timeval_current(void)
+{
+       struct timeval tv;
+       GetTimeOfDay(&tv);
+       return tv;
+}
+
+/**
+  return a timeval struct with the given elements
+*/
+struct timeval timeval_set(uint32_t secs, uint32_t usecs)
+{
+       struct timeval tv;
+       tv.tv_sec = secs;
+       tv.tv_usec = usecs;
+       return tv;
+}
+
+/**
+  return the difference between two timevals as a timeval
+  if tv1 comes after tv2, then return a zero timeval
+  (this is *tv2 - *tv1)
+*/
+struct timeval timeval_until(const struct timeval *tv1,
+                            const struct timeval *tv2)
+{
+       struct timeval t;
+       if (timeval_compare(tv1, tv2) >= 0) {
+               return timeval_zero();
+       }
+       t.tv_sec = tv2->tv_sec - tv1->tv_sec;
+       if (tv1->tv_usec > tv2->tv_usec) {
+               t.tv_sec--;
+               t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec);
+       } else {
+               t.tv_usec = tv2->tv_usec - tv1->tv_usec;
+       }
+       return t;
+}
+
diff --git a/source/lib/events/events_util.h b/source/lib/events/events_util.h
new file mode 100644 (file)
index 0000000..401df89
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 1998-2005
+   Copyright (C) Jelmer Vernooij 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/>.
+*/
+
+/* To use these macros you must have a structure containing a next and
+   prev pointer */
+
+#ifndef _DLINKLIST_H
+#define _DLINKLIST_H
+
+
+/* hook into the front of the list */
+#define DLIST_ADD(list, p) \
+do { \
+        if (!(list)) { \
+               (list) = (p); \
+               (p)->next = (p)->prev = NULL; \
+       } else { \
+               (list)->prev = (p); \
+               (p)->next = (list); \
+               (p)->prev = NULL; \
+               (list) = (p); \
+       }\
+} while (0)
+
+/* remove an element from a list - element doesn't have to be in list. */
+#define DLIST_REMOVE(list, p) \
+do { \
+       if ((p) == (list)) { \
+               (list) = (p)->next; \
+               if (list) (list)->prev = NULL; \
+       } else { \
+               if ((p)->prev) (p)->prev->next = (p)->next; \
+               if ((p)->next) (p)->next->prev = (p)->prev; \
+       } \
+       if ((p) != (list)) (p)->next = (p)->prev = NULL; \
+} while (0)
+
+/* promote an element to the top of the list */
+#define DLIST_PROMOTE(list, p) \
+do { \
+          DLIST_REMOVE(list, p); \
+          DLIST_ADD(list, p); \
+} while (0)
+
+/* hook into the end of the list - needs a tmp pointer */
+#define DLIST_ADD_END(list, p, type) \
+do { \
+               if (!(list)) { \
+                       (list) = (p); \
+                       (p)->next = (p)->prev = NULL; \
+               } else { \
+                       type tmp; \
+                       for (tmp = (list); tmp->next; tmp = tmp->next) ; \
+                       tmp->next = (p); \
+                       (p)->next = NULL; \
+                       (p)->prev = tmp; \
+               } \
+} while (0)
+
+/* insert 'p' after the given element 'el' in a list. If el is NULL then
+   this is the same as a DLIST_ADD() */
+#define DLIST_ADD_AFTER(list, p, el) \
+do { \
+        if (!(list) || !(el)) { \
+               DLIST_ADD(list, p); \
+       } else { \
+               p->prev = el; \
+               p->next = el->next; \
+               el->next = p; \
+               if (p->next) p->next->prev = p; \
+       }\
+} while (0)
+
+/* demote an element to the end of the list, needs a tmp pointer */
+#define DLIST_DEMOTE(list, p, tmp) \
+do { \
+               DLIST_REMOVE(list, p); \
+               DLIST_ADD_END(list, p, tmp); \
+} while (0)
+
+/* concatenate two lists - putting all elements of the 2nd list at the
+   end of the first list */
+#define DLIST_CONCATENATE(list1, list2, type) \
+do { \
+               if (!(list1)) { \
+                       (list1) = (list2); \
+               } else { \
+                       type tmp; \
+                       for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
+                       tmp->next = (list2); \
+                       if (list2) { \
+                               (list2)->prev = tmp;    \
+                       } \
+               } \
+} while (0)
+
+#endif /* _DLINKLIST_H */
+
+const char **str_list_add(const char **list, const char *s);
+struct timeval timeval_zero(void);
+bool timeval_is_zero(const struct timeval *tv);
+struct timeval timeval_current(void);
+struct timeval timeval_set(uint32_t secs, uint32_t usecs);
+struct timeval timeval_until(const struct timeval *tv1,
+                            const struct timeval *tv2);
+
index b220d320cf3204aa0085c7f290f79660cac5728e..ccaeab7ad6a868913c69852b89cf82cefc7bd613 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2493,7 +2511,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
 
 #define SWIG_name    "_events"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2501,7 +2519,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
 #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) 
 
 
-#include "lib/events/events.h"
+#include "events.h"
 typedef struct event_context event;
 
 SWIGINTERN event *new_event(TALLOC_CTX *mem_ctx){ return event_context_init(mem_ctx); }
@@ -2755,15 +2773,15 @@ fail:
 
 
 static PyMethodDef SwigMethods[] = {
-        { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, NULL},
-        { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, NULL},
-        { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, NULL},
+        { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, (char *)"S.__init__()"},
+        { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, (char *)"S.loop_once() -> int"},
+        { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, (char *)"S.loop_wait() -> int"},
         { (char *)"delete_event", (PyCFunction)_wrap_delete_event, METH_O, NULL},
         { (char *)"event_swigregister", event_swigregister, METH_VARARGS, NULL},
         { (char *)"event_swiginit", event_swiginit, METH_VARARGS, NULL},
         { (char *)"event_context_init_byname", (PyCFunction) _wrap_event_context_init_byname, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, NULL},
-        { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, (char *)"event_backend_list() -> list"},
+        { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, (char *)"event_set_default_backend(name) -> None"},
         { NULL, NULL, 0, NULL }
 };
 
@@ -2860,7 +2878,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -2870,6 +2888,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 */
@@ -2898,6 +2919,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);
index 99a47dcc547e3691e82d5a2095577e3d4333e621..483ab861fb9509ad5f8cf196aa05df9025a3266f 100644 (file)
@@ -1,11 +1,28 @@
-EVENTS_OBJ="lib/events/events.o lib/events/events_select.o lib/events/events_signal.o lib/events/events_timed.o lib/events/events_standard.o"
+dnl find the events sources. This is meant to work both for
+dnl standalone builds, and builds of packages using libevents
+eventsdir=""
+eventspaths="$srcdir $srcdir/lib/events $srcdir/events $srcdir/../events"
+for d in $eventspaths; do
+       if test -f "$d/events.c"; then
+               eventsdir="$d"
+               AC_SUBST(eventsdir)
+               break;
+       fi
+done
+if test x"$eventsdir" = "x"; then
+   AC_MSG_ERROR([cannot find libevents source in $eventspaths])
+fi
+
+EVENTS_OBJ="events.o events_select.o events_signal.o events_timed.o events_standard.o events_util.o"
+AC_SUBST(LIBREPLACEOBJ)
 
 AC_CHECK_HEADERS(sys/epoll.h)
 AC_CHECK_FUNCS(epoll_create)
 
 if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes"; then
-   EVENTS_OBJ="$EVENTS_OBJ lib/events/events_epoll.o"
+   EVENTS_OBJ="$EVENTS_OBJ events_epoll.o"
    AC_DEFINE(HAVE_EVENTS_EPOLL, 1, [Whether epoll available])
 fi
 
 AC_SUBST(EVENTS_OBJ)
+
index b14f7e625087088af8aa091fc97693b7db527f6f..006426207eed8aca000d985f07cf03a15adae044 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import events
+from samba import events
 import unittest
 
 # Just test the bindings are there and that calling them doesn't crash
index 6a0b842fffead78c3e3511d90bf753e1bccb9c7a..84007f3833a7e6fc7ff2341fcedeb4fe3c4cad4b 100644 (file)
@@ -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)))
 
index eece9af5f775affa253e94d9573146e5e906a8df..ddbe0f23a60cee35c904c92f20eff172b728836b 100644 (file)
@@ -35,7 +35,6 @@
 
 #if (_SAMBA_BUILD_ >= 4)
 #include "includes.h"
-#include "build.h"
 #endif
 
 #define LDB_MODULE_PREFIX      "modules:"
index 25219eb8b0fe3110b58e861bf94ec7b8463827d0..e8852980f634e989d5a681ab3eba5894a914c788 100644 (file)
@@ -3,7 +3,7 @@
 [MODULE::ldb_asq]
 PRIVATE_DEPENDENCIES = LIBTALLOC
 CFLAGS = -Ilib/ldb/include
-INIT_FUNCTION = &ldb_asq_module_ops
+INIT_FUNCTION = LDB_MODULE(asq)
 SUBSYSTEM = LIBLDB
 
 ldb_asq_OBJ_FILES = lib/ldb/modules/asq.o
@@ -15,7 +15,7 @@ ldb_asq_OBJ_FILES = lib/ldb/modules/asq.o
 [MODULE::ldb_server_sort]
 PRIVATE_DEPENDENCIES = LIBTALLOC
 CFLAGS = -Ilib/ldb/include
-INIT_FUNCTION = &ldb_server_sort_module_ops
+INIT_FUNCTION = LDB_MODULE(server_sort)
 SUBSYSTEM = LIBLDB
 
 # End MODULE ldb_sort
@@ -25,7 +25,7 @@ ldb_server_sort_OBJ_FILES = lib/ldb/modules/sort.o
 ################################################
 # Start MODULE ldb_paged_results
 [MODULE::ldb_paged_results]
-INIT_FUNCTION = &ldb_paged_results_module_ops
+INIT_FUNCTION = LDB_MODULE(paged_results)
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
 SUBSYSTEM = LIBLDB
@@ -37,7 +37,7 @@ ldb_paged_results_OBJ_FILES = lib/ldb/modules/paged_results.o
 ################################################
 # Start MODULE ldb_paged_results
 [MODULE::ldb_paged_searches]
-INIT_FUNCTION = &ldb_paged_searches_module_ops
+INIT_FUNCTION = LDB_MODULE(paged_searches)
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
 SUBSYSTEM = LIBLDB
@@ -52,7 +52,7 @@ ldb_paged_searches_OBJ_FILES = lib/ldb/modules/paged_searches.o
 SUBSYSTEM = LIBLDB
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_operational_module_ops
+INIT_FUNCTION = LDB_MODULE(operational)
 # End MODULE ldb_operational
 ################################################
 
@@ -64,29 +64,23 @@ ldb_operational_OBJ_FILES = lib/ldb/modules/operational.o
 SUBSYSTEM = LIBLDB
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_rdn_name_module_ops
+INIT_FUNCTION = LDB_MODULE(rdn_name)
 # End MODULE ldb_rdn_name
 ################################################
 
 ldb_rdn_name_OBJ_FILES = lib/ldb/modules/rdn_name.o
 
-################################################
-# Start MODULE ldb_map
-[SUBSYSTEM::ldb_map]
-PRIVATE_DEPENDENCIES = LIBTALLOC
-CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_map
-# End MODULE ldb_map
-################################################
-
 ldb_map_OBJ_FILES = $(addprefix lib/ldb/ldb_map/, ldb_map_inbound.o ldb_map_outbound.o ldb_map.o)
 
+$(ldb_map_OBJ_FILES): CFLAGS+=-Ilib/ldb/ldb_map
+
 ################################################
 # Start MODULE ldb_skel
 [MODULE::ldb_skel]
 SUBSYSTEM = LIBLDB
 CFLAGS = -Ilib/ldb/include
 PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_skel_module_ops
+INIT_FUNCTION = LDB_MODULE(skel)
 # End MODULE ldb_skel
 ################################################
 
@@ -134,7 +128,7 @@ PC_FILES += $(ldbdir)/ldb.pc
 LIBLDB_VERSION = 0.0.1
 LIBLDB_SOVERSION = 0
 
-LIBLDB_OBJ_FILES = $(addprefix lib/ldb/common/, ldb.o ldb_ldif.o ldb_parse.o ldb_msg.o ldb_utf8.o ldb_debug.o ldb_modules.o ldb_match.o ldb_attributes.o attrib_handlers.o ldb_dn.o ldb_controls.o qsort.o)
+LIBLDB_OBJ_FILES = $(addprefix lib/ldb/common/, ldb.o ldb_ldif.o ldb_parse.o ldb_msg.o ldb_utf8.o ldb_debug.o ldb_modules.o ldb_match.o ldb_attributes.o attrib_handlers.o ldb_dn.o ldb_controls.o qsort.o) $(ldb_map_OBJ_FILES)
 
 PUBLIC_HEADERS += $(ldbdir)/include/ldb.h $(ldbdir)/include/ldb_errors.h
 
index 6b94f19cb5b565f68e07cb87abc68f9e63ba618e..061d13a2ddc8de0281f42d577e3ae44d3e193053 100644 (file)
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-%module ldb
+%define DOCSTRING
+"An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server."
+%enddef
+
+%module(docstring=DOCSTRING) ldb
 
 %{
 
@@ -40,7 +44,7 @@ typedef struct ldb_message ldb_msg;
 typedef struct ldb_context ldb;
 typedef struct ldb_dn ldb_dn;
 typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_msg_element;
+typedef struct ldb_message_element ldb_message_element;
 typedef int ldb_error;
 typedef int ldb_int_error;
 
@@ -194,8 +198,11 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
 %rename(__cmp__) ldb_dn::compare;
 %rename(__len__) ldb_dn::get_comp_num;
 %rename(Dn) ldb_dn;
+%feature("docstring") ldb_dn "A LDB distinguished name.";
 typedef struct ldb_dn {
     %extend {
+        %feature("docstring") ldb_dn "S.__init__(ldb, string)\n" \
+                 "Create a new DN.";
         ldb_dn(ldb *ldb_ctx, const char *str)
         {
             ldb_dn *ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
@@ -210,25 +217,49 @@ fail:
             return ret;
         }
         ~ldb_dn() { talloc_free($self); }
+        %feature("docstring") validate "S.validate() -> bool\n" \
+                                       "Validate DN is correct.";
         bool validate();
         const char *get_casefold();
         const char *get_linearized();
+        %feature("docstring") parent "S.parent() -> dn\n" \
+                                     "Get the parent for this DN.";
         ldb_dn *parent() { return ldb_dn_get_parent(NULL, $self); }
         int compare(ldb_dn *other);
         bool is_valid();
+        %feature("docstring") is_special "S.is_special() -> bool\n" \
+                                         "Check whether this is a special LDB DN.";
         bool is_special();
+        %feature("docstring") is_null "S.is_null() -> bool\n" \
+                                         "Check whether this is a null DN.";
         bool is_null();
         bool check_special(const char *name);
         int get_comp_num();
+        %feature("docstring") add_child "S.add_child(dn) -> None\n" \
+                                         "Add a child DN to this DN.";
         bool add_child(ldb_dn *child);
+        %feature("docstring") add_base "S.add_base(dn) -> None\n" \
+                                         "Add a base DN to this DN.";
         bool add_base(ldb_dn *base);
+        %feature("docstring") canonical_str "S.canonical_str() -> string\n" \
+                                         "Canonical version of this DN (like a posix path).";
         const char *canonical_str() {
             return ldb_dn_canonical_string($self, $self);
         }
+        %feature("docstring") canonical_ex_str "S.canonical_ex_str() -> string\n" \
+                                               "Canonical version of this DN (like a posix path, with terminating newline).";
         const char *canonical_ex_str() {
             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);
@@ -281,7 +312,7 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
     return ret;
 }
 
-ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
+ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
                                                PyObject *set_obj, int flags,
                                                const char *attr_name)
 {
@@ -312,7 +343,7 @@ ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
 }
 
 PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, 
-                                 ldb_msg_element *me)
+                                 ldb_message_element *me)
 {
     int i;
     PyObject *result;
@@ -332,11 +363,16 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
 #endif
 
 /* ldb_message_element */
-%rename(__cmp__) ldb_message_element::compare;
-%rename(MessageElement) ldb_msg_element;
+%rename(MessageElement) ldb_message_element;
+%feature("docstring") ldb_message_element "Message element.";
 typedef struct ldb_message_element {
     %extend {
 #ifdef SWIGPYTHON
+        int __cmp__(ldb_message_element *other)
+        {
+            return ldb_msg_element_compare($self, other);
+        }
+
         PyObject *__iter__(void)
         {
             return PyObject_GetIter(ldb_msg_element_to_set(NULL, $self));
@@ -347,7 +383,7 @@ typedef struct ldb_message_element {
             return ldb_msg_element_to_set(NULL, $self);
         }
 
-        ldb_msg_element(PyObject *set_obj, int flags=0, const char *name = NULL)
+        ldb_message_element(PyObject *set_obj, int flags=0, const char *name = NULL)
         {
             return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
         }
@@ -366,8 +402,7 @@ typedef struct ldb_message_element {
             return ldb_val_to_py_object(NULL, $self, &$self->values[i]);
         }
 
-        ~ldb_msg_element() { talloc_free($self); }
-        int compare(ldb_msg_element *);
+        ~ldb_message_element() { talloc_free($self); }
     }
     %pythoncode {
         def __getitem__(self, i):
@@ -376,6 +411,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
@@ -387,30 +425,34 @@ typedef struct ldb_message_element {
                     return False
             return True
     }
-} ldb_msg_element;
+} ldb_message_element;
 
 /* ldb_message */
 
+%feature("docstring") ldb_message "Message.";
 %rename(Message) ldb_message;
 #ifdef SWIGPYTHON
 %rename(__delitem__) ldb_message::remove_attr;
-%typemap(out) ldb_msg_element * {
+%typemap(out) ldb_message_element * {
        if ($1 == NULL)
                PyErr_SetString(PyExc_KeyError, "no such 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;
     }
 }
@@ -427,10 +469,10 @@ typedef struct ldb_message {
             return ret;
         }
         ~ldb_msg() { talloc_free($self); }
-        ldb_msg_element *find_element(const char *name);
+        ldb_message_element *find_element(const char *name);
         
 #ifdef SWIGPYTHON
-        void __setitem__(const char *attr_name, ldb_msg_element *val)
+        void __setitem__(const char *attr_name, ldb_message_element *val)
         {
             struct ldb_message_element *el;
             
@@ -466,6 +508,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;
 
@@ -562,6 +626,7 @@ PyObject *PyExc_LdbError;
 }
 
 %rename(Ldb) ldb_context;
+%feature("docstring") ldb_context "Connection to a LDB database.";
 
 %typemap(in,noblock=1) struct ldb_dn * {
     if (ldb_dn_from_pyobject(NULL, $input, arg1, &$1) != 0) {
@@ -575,7 +640,7 @@ PyObject *PyExc_LdbError;
 
 %typemap(in,numinputs=1) ldb_msg *add_msg {
     Py_ssize_t dict_pos, msg_pos;
-    ldb_msg_element *msgel;
+    ldb_message_element *msgel;
     PyObject *key, *value;
 
     if (PyDict_Check($input)) {
@@ -622,6 +687,8 @@ typedef struct ldb_context {
     %extend {
         ldb(void) { return ldb_init(NULL); }
 
+        %feature("docstring") connect "S.connect(url,flags=0,options=None) -> None\n" \
+                                      "Connect to a LDB URL.";
         ldb_error connect(const char *url, unsigned int flags = 0, 
             const char *options[] = NULL);
 
@@ -669,11 +736,19 @@ typedef struct ldb_context {
             return ret;
         }
 
+        %feature("docstring") delete "S.delete(dn) -> None\n" \
+                                     "Remove an entry.";
         ldb_error delete(ldb_dn *dn);
+        %feature("docstring") rename "S.rename(old_dn, new_dn) -> None\n" \
+                                     "Rename an entry.";
         ldb_error rename(ldb_dn *olddn, ldb_dn *newdn);
         struct ldb_control **parse_control_strings(TALLOC_CTX *mem_ctx, 
                                                    const char * const*control_strings);
+        %feature("docstring") add "S.add(message) -> None\n" \
+                                  "Add an entry.";
         ldb_error add(ldb_msg *add_msg);
+        %feature("docstring") modify "S.modify(message) -> None\n" \
+                                  "Modify an entry.";
         ldb_error modify(ldb_msg *message);
         ldb_dn *get_config_basedn();
         ldb_dn *get_root_basedn();
@@ -709,20 +784,39 @@ typedef struct ldb_context {
         }
 
         const char *errstring();
+        %feature("docstring") set_create_perms "S.set_create_perms(mode) -> None\n" \
+                                               "Set mode to use when creating new LDB files.";
         void set_create_perms(unsigned int perms);
+        %feature("docstring") set_modules_dir "S.set_modules_dir(path) -> None\n" \
+                                              "Set path LDB should search for modules";
         void set_modules_dir(const char *path);
+        %feature("docstring") set_debug "S.set_debug(callback) -> None\n" \
+                                        "Set callback for LDB debug messages.\n" \
+                                        "The callback should accept a debug level and debug text.";
         ldb_error set_debug(void (*debug)(void *context, enum ldb_debug_level level, 
                                           const char *fmt, va_list ap),
                             void *context);
+        %feature("docstring") set_opaque "S.set_opaque(name, value) -> None\n" \
+            "Set an opaque value on this LDB connection. \n"
+            ":note: Passing incorrect values may cause crashes.";
         ldb_error set_opaque(const char *name, void *value);
+        %feature("docstring") get_opaque "S.get_opaque(name) -> value\n" \
+            "Get an opaque value set on this LDB connection. \n"
+            ":note: The returned value may not be useful in Python.";
         void *get_opaque(const char *name);
+        %feature("docstring") transaction_start "S.transaction_start() -> None\n" \
+                                                "Start a new transaction.";
         ldb_error transaction_start();
+        %feature("docstring") transaction_commit "S.transaction_commit() -> None\n" \
+                                                 "Commit currently active transaction.";
         ldb_error transaction_commit();
+        %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n" \
+                                                 "Cancel currently active transaction.";
         ldb_error transaction_cancel();
         void schema_attribute_remove(const char *name);
         ldb_error schema_attribute_add(const char *attribute, unsigned flags, const char *syntax);
-       ldb_error setup_wellknown_attributes(void);
-       
+        ldb_error setup_wellknown_attributes(void);
 #ifdef SWIGPYTHON
         %typemap(in,numinputs=0,noblock=1) struct ldb_result **result_as_bool (struct ldb_result *tmp) { $1 = &tmp; }
         %typemap(argout,noblock=1) struct ldb_result **result_as_bool { $result = ((*$1)->count > 0)?Py_True:Py_False; }
@@ -733,6 +827,9 @@ typedef struct ldb_context {
                              result_as_bool);
         }
 
+        %feature("docstring") parse_ldif "S.parse_ldif(ldif) -> iter(messages)\n" \
+            "Parse a string formatted using LDIF.";
+
         PyObject *parse_ldif(const char *s)
         {
             PyObject *list = PyList_New(0);
@@ -743,16 +840,37 @@ 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 {
         def __init__(self, url=None, flags=0, options=None):
+            """Create a new LDB object.
+
+            Will also connect to the specified URL if one was given.
+            """
             _ldb.Ldb_swiginit(self,_ldb.new_Ldb())
             if url is not None:
                 self.connect(url, flags, options)
 
         def search(self, base=None, scope=SCOPE_DEFAULT, expression=None, 
                    attrs=None, controls=None):
+            """Search in a database.
+
+            :param base: Optional base DN to search
+            :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
+            :param expression: Optional search expression
+            :param attrs: Attributes to return (defaults to all)
+            :param controls: Optional list of controls
+            :return: Iterator over Message objects
+            """
+            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)
@@ -770,10 +888,15 @@ typedef struct ldb_context {
 %nodefault Dn;
 
 %rename(valid_attr_name) ldb_valid_attr_name;
+%feature("docstring") ldb_valid_attr_name "S.valid_attr_name(name) -> bool\n"
+                                          "Check whether the supplied name is a valid attribute name.";
 int ldb_valid_attr_name(const char *s);
 
 typedef unsigned long time_t;
 
+%feature("docstring") timestring "S.timestring(int) -> string\n"
+                                 "Generate a LDAP time string from a UNIX timestamp";
+
 %inline %{
 static char *timestring(time_t t)
 {
@@ -785,6 +908,8 @@ static char *timestring(time_t t)
 %}
 
 %rename(string_to_time) ldb_string_to_time;
+%feature("docstring") ldb_string_to_time "S.string_to_time(string) -> int\n"
+                                     "Parse a LDAP time string into a UNIX timestamp.";
 time_t ldb_string_to_time(const char *s);
 
 %typemap(in,noblock=1) const struct ldb_module_ops * {
@@ -793,5 +918,11 @@ time_t ldb_string_to_time(const char *s);
     $1->name = (char *)PyObject_GetAttrString($input, (char *)"name");
 }
 
+%feature("docstring") ldb_register_module "S.register_module(module) -> None\n"
+                                          "Register a LDB module.";
 %rename(register_module) ldb_register_module;
 ldb_int_error ldb_register_module(const struct ldb_module_ops *);
+
+%pythoncode {
+__docformat__ = "restructuredText"
+}
index cc920178bcfcf2e0501f9ec9fd3e578fed1a0b12..df11e9d2abb171485ef49bec395820de550748ee 100644 (file)
@@ -71,7 +71,7 @@ ldb_wrap.o: $(ldbdir)/ldb_wrap.c
        $(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
        
 _ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o
-       $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS)
+       $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags`
 
 install-python:: build-python
        mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
index b148782c63aac297bfc286f193f1cb3e6b2bb601..ae2c187367fdd455f03cb308a6cc87e36428e14a 100644 (file)
@@ -3,6 +3,10 @@
 #
 # Don't modify this file, modify the SWIG interface instead.
 
+"""
+An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server.
+"""
+
 import _ldb
 import new
 new_instancemethod = new.instancemethod
@@ -67,11 +71,71 @@ CHANGETYPE_DELETE = _ldb.CHANGETYPE_DELETE
 CHANGETYPE_MODIFY = _ldb.CHANGETYPE_MODIFY
 ldb_val_to_py_object = _ldb.ldb_val_to_py_object
 class Dn(object):
+    """A LDB distinguished name."""
     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): 
+        """
+        S.__init__(ldb, string)
+        Create a new DN.
+        """
         _ldb.Dn_swiginit(self,_ldb.new_Dn(*args, **kwargs))
     __swig_destroy__ = _ldb.delete_Dn
+    def validate(*args, **kwargs):
+        """
+        S.validate() -> bool
+        Validate DN is correct.
+        """
+        return _ldb.Dn_validate(*args, **kwargs)
+
+    def parent(*args, **kwargs):
+        """
+        S.parent() -> dn
+        Get the parent for this DN.
+        """
+        return _ldb.Dn_parent(*args, **kwargs)
+
+    def is_special(*args, **kwargs):
+        """
+        S.is_special() -> bool
+        Check whether this is a special LDB DN.
+        """
+        return _ldb.Dn_is_special(*args, **kwargs)
+
+    def is_null(*args, **kwargs):
+        """
+        S.is_null() -> bool
+        Check whether this is a null DN.
+        """
+        return _ldb.Dn_is_null(*args, **kwargs)
+
+    def add_child(*args, **kwargs):
+        """
+        S.add_child(dn) -> None
+        Add a child DN to this DN.
+        """
+        return _ldb.Dn_add_child(*args, **kwargs)
+
+    def add_base(*args, **kwargs):
+        """
+        S.add_base(dn) -> None
+        Add a base DN to this DN.
+        """
+        return _ldb.Dn_add_base(*args, **kwargs)
+
+    def canonical_str(*args, **kwargs):
+        """
+        S.canonical_str() -> string
+        Canonical version of this DN (like a posix path).
+        """
+        return _ldb.Dn_canonical_str(*args, **kwargs)
+
+    def canonical_ex_str(*args, **kwargs):
+        """
+        S.canonical_ex_str() -> string
+        Canonical version of this DN (like a posix path, with terminating newline).
+        """
+        return _ldb.Dn_canonical_ex_str(*args, **kwargs)
+
     def __eq__(self, other):
         if isinstance(other, self.__class__):
             return self.__cmp__(other) == 0
@@ -93,21 +157,28 @@ 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)
 
-class ldb_msg_element(object):
+class MessageElement(object):
+    """Message element."""
     thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
-    def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
     __repr__ = _swig_repr
-    __swig_destroy__ = _ldb.delete_ldb_msg_element
+    def __init__(self, *args, **kwargs): 
+        """Message element."""
+        _ldb.MessageElement_swiginit(self,_ldb.new_MessageElement(*args, **kwargs))
+    __swig_destroy__ = _ldb.delete_MessageElement
     def __getitem__(self, i):
         ret = self.get(i)
         if ret is None:
             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
@@ -119,27 +190,45 @@ class ldb_msg_element(object):
                 return False
         return True
 
-ldb_msg_element.__iter__ = new_instancemethod(_ldb.ldb_msg_element___iter__,None,ldb_msg_element)
-ldb_msg_element.__set__ = new_instancemethod(_ldb.ldb_msg_element___set__,None,ldb_msg_element)
-ldb_msg_element.__len__ = new_instancemethod(_ldb.ldb_msg_element___len__,None,ldb_msg_element)
-ldb_msg_element.get = new_instancemethod(_ldb.ldb_msg_element_get,None,ldb_msg_element)
-ldb_msg_element.__cmp__ = new_instancemethod(_ldb.ldb_msg_element___cmp__,None,ldb_msg_element)
-ldb_msg_element_swigregister = _ldb.ldb_msg_element_swigregister
-ldb_msg_element_swigregister(ldb_msg_element)
-
-def MessageElement(*args, **kwargs):
-    val = _ldb.new_MessageElement(*args, **kwargs)
-    return val
+MessageElement.__cmp__ = new_instancemethod(_ldb.MessageElement___cmp__,None,MessageElement)
+MessageElement.__iter__ = new_instancemethod(_ldb.MessageElement___iter__,None,MessageElement)
+MessageElement.__set__ = new_instancemethod(_ldb.MessageElement___set__,None,MessageElement)
+MessageElement.__len__ = new_instancemethod(_ldb.MessageElement___len__,None,MessageElement)
+MessageElement.get = new_instancemethod(_ldb.MessageElement_get,None,MessageElement)
+MessageElement_swigregister = _ldb.MessageElement_swigregister
+MessageElement_swigregister(MessageElement)
 
 ldb_msg_list_elements = _ldb.ldb_msg_list_elements
 class Message(object):
+    """Message."""
     thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
     __repr__ = _swig_repr
     dn = _swig_property(_ldb.Message_dn_get, _ldb.Message_dn_set)
     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)
@@ -190,18 +279,134 @@ LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED = _ldb.LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED
 LDB_ERR_AFFECTS_MULTIPLE_DSAS = _ldb.LDB_ERR_AFFECTS_MULTIPLE_DSAS
 LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER
 class Ldb(object):
+    """Connection to a LDB database."""
     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))
+    def connect(*args, **kwargs):
+        """
+        S.connect(url,flags=0,options=None) -> None
+        Connect to a LDB URL.
+        """
+        return _ldb.Ldb_connect(*args, **kwargs)
+
     __swig_destroy__ = _ldb.delete_Ldb
+    def delete(*args, **kwargs):
+        """
+        S.delete(dn) -> None
+        Remove an entry.
+        """
+        return _ldb.Ldb_delete(*args, **kwargs)
+
+    def rename(*args, **kwargs):
+        """
+        S.rename(old_dn, new_dn) -> None
+        Rename an entry.
+        """
+        return _ldb.Ldb_rename(*args, **kwargs)
+
+    def add(*args, **kwargs):
+        """
+        S.add(message) -> None
+        Add an entry.
+        """
+        return _ldb.Ldb_add(*args, **kwargs)
+
+    def modify(*args, **kwargs):
+        """
+        S.modify(message) -> None
+        Modify an entry.
+        """
+        return _ldb.Ldb_modify(*args, **kwargs)
+
+    def set_create_perms(*args, **kwargs):
+        """
+        S.set_create_perms(mode) -> None
+        Set mode to use when creating new LDB files.
+        """
+        return _ldb.Ldb_set_create_perms(*args, **kwargs)
+
+    def set_modules_dir(*args, **kwargs):
+        """
+        S.set_modules_dir(path) -> None
+        Set path LDB should search for modules
+        """
+        return _ldb.Ldb_set_modules_dir(*args, **kwargs)
+
+    def set_debug(*args, **kwargs):
+        """
+        S.set_debug(callback) -> None
+        Set callback for LDB debug messages.
+        The callback should accept a debug level and debug text.
+        """
+        return _ldb.Ldb_set_debug(*args, **kwargs)
+
+    def set_opaque(*args, **kwargs):
+        """
+        S.set_opaque(name, value) -> None
+        Set an opaque value on this LDB connection. 
+        :note: Passing incorrect values may cause crashes.
+        """
+        return _ldb.Ldb_set_opaque(*args, **kwargs)
+
+    def get_opaque(*args, **kwargs):
+        """
+        S.get_opaque(name) -> value
+        Get an opaque value set on this LDB connection. 
+        :note: The returned value may not be useful in Python.
+        """
+        return _ldb.Ldb_get_opaque(*args, **kwargs)
+
+    def transaction_start(*args, **kwargs):
+        """
+        S.transaction_start() -> None
+        Start a new transaction.
+        """
+        return _ldb.Ldb_transaction_start(*args, **kwargs)
+
+    def transaction_commit(*args, **kwargs):
+        """
+        S.transaction_commit() -> None
+        Commit currently active transaction.
+        """
+        return _ldb.Ldb_transaction_commit(*args, **kwargs)
+
+    def transaction_cancel(*args, **kwargs):
+        """
+        S.transaction_cancel() -> None
+        Cancel currently active transaction.
+        """
+        return _ldb.Ldb_transaction_cancel(*args, **kwargs)
+
+    def parse_ldif(*args, **kwargs):
+        """
+        S.parse_ldif(ldif) -> iter(messages)
+        Parse a string formatted using LDIF.
+        """
+        return _ldb.Ldb_parse_ldif(*args, **kwargs)
+
     def __init__(self, url=None, flags=0, options=None):
+        """Create a new LDB object.
+
+        Will also connect to the specified URL if one was given.
+        """
         _ldb.Ldb_swiginit(self,_ldb.new_Ldb())
         if url is not None:
             self.connect(url, flags, options)
 
     def search(self, base=None, scope=SCOPE_DEFAULT, expression=None, 
                attrs=None, controls=None):
+        """Search in a database.
+
+        :param base: Optional base DN to search
+        :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
+        :param expression: Optional search expression
+        :param attrs: Attributes to return (defaults to all)
+        :param controls: Optional list of controls
+        :return: Iterator over Message objects
+        """
+        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,12 +439,39 @@ 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)
 
-valid_attr_name = _ldb.valid_attr_name
-timestring = _ldb.timestring
-string_to_time = _ldb.string_to_time
-register_module = _ldb.register_module
+
+def valid_attr_name(*args, **kwargs):
+  """
+    S.valid_attr_name(name) -> bool
+    Check whether the supplied name is a valid attribute name.
+    """
+  return _ldb.valid_attr_name(*args, **kwargs)
+
+def timestring(*args, **kwargs):
+  """
+    S.timestring(int) -> string
+    Generate a LDAP time string from a UNIX timestamp
+    """
+  return _ldb.timestring(*args, **kwargs)
+
+def string_to_time(*args, **kwargs):
+  """
+    S.string_to_time(string) -> int
+    Parse a LDAP time string into a UNIX timestamp.
+    """
+  return _ldb.string_to_time(*args, **kwargs)
+
+def register_module(*args, **kwargs):
+  """
+    S.register_module(module) -> None
+    Register a LDB module.
+    """
+  return _ldb.register_module(*args, **kwargs)
+__docformat__ = "restructuredText"
+
 
 
index 79958a86eba121d6f7dc5dc9bfde6ea806757c18..6b50b2f5eba73a050f243d6d745c078a66a7cfb1 100644 (file)
@@ -737,6 +737,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        struct ildb_private *ildb;
        NTSTATUS status;
        struct cli_credentials *creds;
+       struct event_context *event_ctx;
 
        module = talloc(ldb, struct ldb_module);
        if (!module) {
@@ -756,8 +757,19 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        }
        module->private_data    = ildb;
        ildb->module            = module;
-       ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"), 
-                                         ldb_get_opaque(ldb, "EventContext"));
+
+       event_ctx = ldb_get_opaque(ldb, "EventContext");
+
+       /* FIXME: We must make the event context an explicit parameter, but we
+        * need to build the events library separately first. Hack a new event
+        * context so that CMD line utilities work until we have libevents for
+        * standalone builds ready */
+       if (event_ctx == NULL) {
+               event_ctx = event_context_init(NULL);
+       }
+
+       ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
+                                         event_ctx);
        if (!ildb->ldap) {
                ldb_oom(ldb);
                goto failed;
index d8776f48e254a53df309754a44f67acb3e1d98ac..1b6d9feed6117cd5175176c347540e560af54ca6 100644 (file)
@@ -545,7 +545,7 @@ static int ltdb_index_dn_one(struct ldb_module *module,
 
        /* the attribute is indexed. Pull the list of DNs that match the 
           search criterion */
-       val.data = (uint8_t *)((intptr_t)ldb_dn_get_casefold(parent_dn));
+       val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(parent_dn));
        val.length = strlen((char *)val.data);
        key = ltdb_index_key(ldb, LTDB_IDXONE, &val);
        if (!key) {
@@ -1140,7 +1140,7 @@ int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       val.data = (uint8_t *)((intptr_t)ldb_dn_get_casefold(pdn));
+       val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(pdn));
        if (val.data == NULL) {
                talloc_free(pdn);
                return LDB_ERR_OPERATIONS_ERROR;
index 390652eebe60db8ac125fe04109276fee106ed17..744033cbf6d4bb8ae0092e5f52ddfa715494e23a 100644 (file)
@@ -2554,7 +2554,7 @@ typedef struct ldb_message ldb_msg;
 typedef struct ldb_context ldb;
 typedef struct ldb_dn ldb_dn;
 typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_msg_element;
+typedef struct ldb_message_element ldb_message_element;
 typedef int ldb_error;
 typedef int ldb_int_error;
 
@@ -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);
@@ -2755,7 +2761,7 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
     return ret;
 }
 
-ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
+ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
                                                PyObject *set_obj, int flags,
                                                const char *attr_name)
 {
@@ -2786,7 +2792,7 @@ ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
 }
 
 PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, 
-                                 ldb_msg_element *me)
+                                 ldb_message_element *me)
 {
     int i;
     PyObject *result;
@@ -2803,10 +2809,13 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
 }
 
 
-SWIGINTERN PyObject *ldb_msg_element___iter__(ldb_msg_element *self){
+SWIGINTERN int ldb_message_element___cmp__(ldb_message_element *self,ldb_message_element *other){
+            return ldb_msg_element_compare(self, other);
+        }
+SWIGINTERN PyObject *ldb_message_element___iter__(ldb_message_element *self){
             return PyObject_GetIter(ldb_msg_element_to_set(NULL, self));
         }
-SWIGINTERN PyObject *ldb_msg_element___set__(ldb_msg_element *self){
+SWIGINTERN PyObject *ldb_message_element___set__(ldb_message_element *self){
             return ldb_msg_element_to_set(NULL, self);
         }
 
@@ -2954,26 +2963,32 @@ SWIG_AsVal_int (PyObject * obj, int *val)
   return res;
 }
 
-SWIGINTERN ldb_msg_element *new_ldb_msg_element(PyObject *set_obj,int flags,char const *name){
+SWIGINTERN ldb_message_element *new_ldb_message_element(PyObject *set_obj,int flags,char const *name){
             return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
         }
-SWIGINTERN int ldb_msg_element___len__(ldb_msg_element *self){
+SWIGINTERN int ldb_message_element___len__(ldb_message_element *self){
             return self->num_values;
         }
-SWIGINTERN PyObject *ldb_msg_element_get(ldb_msg_element *self,int i){
+SWIGINTERN PyObject *ldb_message_element_get(ldb_message_element *self,int i){
             if (i < 0 || i >= self->num_values)
                 return Py_None;
 
             return ldb_val_to_py_object(NULL, self, &self->values[i]);
         }
-SWIGINTERN void delete_ldb_msg_element(ldb_msg_element *self){ talloc_free(self); }
+SWIGINTERN void delete_ldb_message_element(ldb_message_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;
     }
 
@@ -2983,7 +2998,7 @@ SWIGINTERN ldb_msg *new_ldb_msg(ldb_dn *dn){
             return ret;
         }
 SWIGINTERN void delete_ldb_msg(ldb_msg *self){ talloc_free(self); }
-SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_msg_element *val){
+SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_message_element *val){
             struct ldb_message_element *el;
             
             ldb_msg_remove_attr(self, attr_name);
@@ -3188,6 +3203,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 +3698,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 ;
@@ -3723,9 +3766,43 @@ SWIGINTERN PyObject *Dn_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args)
   return SWIG_Python_InitShadowInstance(args);
 }
 
-SWIGINTERN PyObject *_wrap_ldb_msg_element___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
-  ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+  ldb_message_element *arg1 = (ldb_message_element *) 0 ;
+  ldb_message_element *arg2 = (ldb_message_element *) 0 ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  char *  kwnames[] = {
+    (char *) "self",(char *) "other", NULL 
+  };
+  
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___cmp__" "', argument " "1"" of type '" "ldb_message_element *""'"); 
+  }
+  arg1 = (ldb_message_element *)(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 |  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MessageElement___cmp__" "', argument " "2"" of type '" "ldb_message_element *""'"); 
+  }
+  arg2 = (ldb_message_element *)(argp2);
+  result = (int)ldb_message_element___cmp__(arg1,arg2);
+  resultobj = SWIG_From_int((int)(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_MessageElement___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  ldb_message_element *arg1 = (ldb_message_element *) 0 ;
   PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
@@ -3735,10 +3812,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___iter__(PyObject *SWIGUNUSEDPARM(sel
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___iter__" "', argument " "1"" of type '" "ldb_msg_element *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___iter__" "', argument " "1"" of type '" "ldb_message_element *""'"); 
   }
-  arg1 = (ldb_msg_element *)(argp1);
-  result = (PyObject *)ldb_msg_element___iter__(arg1);
+  arg1 = (ldb_message_element *)(argp1);
+  result = (PyObject *)ldb_message_element___iter__(arg1);
   resultobj = result;
   return resultobj;
 fail:
@@ -3746,9 +3823,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ldb_msg_element___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+  ldb_message_element *arg1 = (ldb_message_element *) 0 ;
   PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
@@ -3758,10 +3835,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___set__(PyObject *SWIGUNUSEDPARM(self
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___set__" "', argument " "1"" of type '" "ldb_msg_element *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___set__" "', argument " "1"" of type '" "ldb_message_element *""'"); 
   }
-  arg1 = (ldb_msg_element *)(argp1);
-  result = (PyObject *)ldb_msg_element___set__(arg1);
+  arg1 = (ldb_message_element *)(argp1);
+  result = (PyObject *)ldb_message_element___set__(arg1);
   resultobj = result;
   return resultobj;
 fail:
@@ -3774,7 +3851,7 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py
   PyObject *arg1 = (PyObject *) 0 ;
   int arg2 = (int) 0 ;
   char *arg3 = (char *) NULL ;
-  ldb_msg_element *result = 0 ;
+  ldb_message_element *result = 0 ;
   int val2 ;
   int ecode2 = 0 ;
   int res3 ;
@@ -3803,8 +3880,8 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py
     }
     arg3 = (char *)(buf3);
   }
-  result = (ldb_msg_element *)new_ldb_msg_element(arg1,arg2,(char const *)arg3);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_message_element, SWIG_POINTER_OWN |  0 );
+  result = (ldb_message_element *)new_ldb_message_element(arg1,arg2,(char const *)arg3);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_message_element, SWIG_POINTER_NEW |  0 );
   if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
   return resultobj;
 fail:
@@ -3813,9 +3890,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ldb_msg_element___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+  ldb_message_element *arg1 = (ldb_message_element *) 0 ;
   int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
@@ -3825,10 +3902,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___len__(PyObject *SWIGUNUSEDPARM(self
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___len__" "', argument " "1"" of type '" "ldb_msg_element *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___len__" "', argument " "1"" of type '" "ldb_message_element *""'"); 
   }
-  arg1 = (ldb_msg_element *)(argp1);
-  result = (int)ldb_msg_element___len__(arg1);
+  arg1 = (ldb_message_element *)(argp1);
+  result = (int)ldb_message_element___len__(arg1);
   resultobj = SWIG_From_int((int)(result));
   return resultobj;
 fail:
@@ -3836,9 +3913,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ldb_msg_element_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_MessageElement_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
-  ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+  ldb_message_element *arg1 = (ldb_message_element *) 0 ;
   int arg2 ;
   PyObject *result = 0 ;
   void *argp1 = 0 ;
@@ -3851,18 +3928,18 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element_get(PyObject *SWIGUNUSEDPARM(self), P
     (char *) "self",(char *) "i", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_msg_element_get",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement_get",kwnames,&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element_get" "', argument " "1"" of type '" "ldb_msg_element *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement_get" "', argument " "1"" of type '" "ldb_message_element *""'"); 
   }
-  arg1 = (ldb_msg_element *)(argp1);
+  arg1 = (ldb_message_element *)(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ldb_msg_element_get" "', argument " "2"" of type '" "int""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MessageElement_get" "', argument " "2"" of type '" "int""'");
   } 
   arg2 = (int)(val2);
-  result = (PyObject *)ldb_msg_element_get(arg1,arg2);
+  result = (PyObject *)ldb_message_element_get(arg1,arg2);
   resultobj = result;
   return resultobj;
 fail:
@@ -3870,9 +3947,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_delete_ldb_msg_element(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_MessageElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+  ldb_message_element *arg1 = (ldb_message_element *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject *swig_obj[1] ;
@@ -3881,10 +3958,10 @@ SWIGINTERN PyObject *_wrap_delete_ldb_msg_element(PyObject *SWIGUNUSEDPARM(self)
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ldb_msg_element" "', argument " "1"" of type '" "ldb_msg_element *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MessageElement" "', argument " "1"" of type '" "ldb_message_element *""'"); 
   }
-  arg1 = (ldb_msg_element *)(argp1);
-  delete_ldb_msg_element(arg1);
+  arg1 = (ldb_message_element *)(argp1);
+  delete_ldb_message_element(arg1);
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -3893,47 +3970,17 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ldb_msg_element___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
-  PyObject *resultobj = 0;
-  ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
-  ldb_msg_element *arg2 = (ldb_msg_element *) 0 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  char *  kwnames[] = {
-    (char *) "self",(char *)"arg2", NULL 
-  };
-  
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_msg_element___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___cmp__" "', argument " "1"" of type '" "ldb_msg_element *""'"); 
-  }
-  arg1 = (ldb_msg_element *)(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 |  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_msg_element___cmp__" "', argument " "2"" of type '" "ldb_msg_element *""'"); 
-  }
-  arg2 = (ldb_msg_element *)(argp2);
-  result = (int)ldb_msg_element_compare(arg1,arg2);
-  resultobj = SWIG_From_int((int)(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *ldb_msg_element_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *MessageElement_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_ldb_message_element, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
+SWIGINTERN PyObject *MessageElement_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  return SWIG_Python_InitShadowInstance(args);
+}
+
 SWIGINTERN PyObject *_wrap_ldb_msg_list_elements(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   ldb_msg *arg1 = (ldb_msg *) 0 ;
@@ -4074,11 +4121,11 @@ 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 ;
-  ldb_msg_element *result = 0 ;
+  ldb_message_element *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 ;
@@ -4090,21 +4137,21 @@ 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)
   SWIG_exception(SWIG_ValueError, 
     "Message can not be None");
-  result = (ldb_msg_element *)ldb_msg_find_element(arg1,(char const *)arg2);
+  result = (ldb_message_element *)ldb_msg_find_element(arg1,(char const *)arg2);
   {
     if (result == NULL)
     PyErr_SetString(PyExc_KeyError, "no such element");
@@ -4123,7 +4170,7 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
   PyObject *resultobj = 0;
   ldb_msg *arg1 = (ldb_msg *) 0 ;
   char *arg2 = (char *) 0 ;
-  ldb_msg_element *arg3 = (ldb_msg_element *) 0 ;
+  ldb_message_element *arg3 = (ldb_message_element *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 ;
@@ -4145,9 +4192,9 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
   arg2 = (char *)(buf2);
   res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ldb_message_element, 0 |  0 );
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_msg_element *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_message_element *""'"); 
   }
-  arg3 = (ldb_msg_element *)(argp3);
+  arg3 = (ldb_message_element *)(argp3);
   if (arg1 == NULL)
   SWIG_exception(SWIG_ValueError, 
     "Message can not be None");
@@ -4222,7 +4269,7 @@ check_1:
 fail:
   SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Message___setitem__'.\n"
     "  Possible C/C++ prototypes are:\n"
-    "    __setitem__(ldb_msg *,char const *,ldb_msg_element *)\n"
+    "    __setitem__(ldb_msg *,char const *,ldb_message_element *)\n"
     "    __setitem__(ldb_msg *,char const *,PyObject *)\n");
   return NULL;
 }
@@ -4747,7 +4794,7 @@ SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
   arg1 = (ldb *)(argp1);
   {
     Py_ssize_t dict_pos, msg_pos;
-    ldb_msg_element *msgel;
+    ldb_message_element *msgel;
     PyObject *key, *value;
     
     if (PyDict_Check(obj1)) {
@@ -5538,6 +5585,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;
@@ -5657,39 +5730,68 @@ fail:
 
 static PyMethodDef SwigMethods[] = {
         { (char *)"ldb_val_to_py_object", (PyCFunction) _wrap_ldb_val_to_py_object, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"new_Dn", (PyCFunction) _wrap_new_Dn, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"new_Dn", (PyCFunction) _wrap_new_Dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.__init__(ldb, string)\n"
+               "Create a new DN.\n"
+               ""},
         { (char *)"delete_Dn", (PyCFunction)_wrap_delete_Dn, METH_O, NULL},
-        { (char *)"Dn_validate", (PyCFunction)_wrap_Dn_validate, METH_O, NULL},
+        { (char *)"Dn_validate", (PyCFunction)_wrap_Dn_validate, METH_O, (char *)"\n"
+               "S.validate() -> bool\n"
+               "Validate DN is correct.\n"
+               ""},
         { (char *)"Dn_get_casefold", (PyCFunction)_wrap_Dn_get_casefold, METH_O, NULL},
         { (char *)"Dn___str__", (PyCFunction)_wrap_Dn___str__, METH_O, NULL},
-        { (char *)"Dn_parent", (PyCFunction)_wrap_Dn_parent, METH_O, NULL},
+        { (char *)"Dn_parent", (PyCFunction)_wrap_Dn_parent, METH_O, (char *)"\n"
+               "S.parent() -> dn\n"
+               "Get the parent for this DN.\n"
+               ""},
         { (char *)"Dn___cmp__", (PyCFunction) _wrap_Dn___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Dn_is_valid", (PyCFunction)_wrap_Dn_is_valid, METH_O, NULL},
-        { (char *)"Dn_is_special", (PyCFunction)_wrap_Dn_is_special, METH_O, NULL},
-        { (char *)"Dn_is_null", (PyCFunction)_wrap_Dn_is_null, METH_O, NULL},
+        { (char *)"Dn_is_special", (PyCFunction)_wrap_Dn_is_special, METH_O, (char *)"\n"
+               "S.is_special() -> bool\n"
+               "Check whether this is a special LDB DN.\n"
+               ""},
+        { (char *)"Dn_is_null", (PyCFunction)_wrap_Dn_is_null, METH_O, (char *)"\n"
+               "S.is_null() -> bool\n"
+               "Check whether this is a null DN.\n"
+               ""},
         { (char *)"Dn_check_special", (PyCFunction) _wrap_Dn_check_special, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Dn___len__", (PyCFunction)_wrap_Dn___len__, METH_O, NULL},
-        { (char *)"Dn_add_child", (PyCFunction) _wrap_Dn_add_child, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (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_add_child", (PyCFunction) _wrap_Dn_add_child, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.add_child(dn) -> None\n"
+               "Add a child DN to this DN.\n"
+               ""},
+        { (char *)"Dn_add_base", (PyCFunction) _wrap_Dn_add_base, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.add_base(dn) -> None\n"
+               "Add a base DN to this DN.\n"
+               ""},
+        { (char *)"Dn_canonical_str", (PyCFunction)_wrap_Dn_canonical_str, METH_O, (char *)"\n"
+               "S.canonical_str() -> string\n"
+               "Canonical version of this DN (like a posix path).\n"
+               ""},
+        { (char *)"Dn_canonical_ex_str", (PyCFunction)_wrap_Dn_canonical_ex_str, METH_O, (char *)"\n"
+               "S.canonical_ex_str() -> string\n"
+               "Canonical version of this DN (like a posix path, with terminating newline).\n"
+               ""},
+        { (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},
-        { (char *)"ldb_msg_element___iter__", (PyCFunction)_wrap_ldb_msg_element___iter__, METH_O, NULL},
-        { (char *)"ldb_msg_element___set__", (PyCFunction)_wrap_ldb_msg_element___set__, METH_O, NULL},
-        { (char *)"new_MessageElement", (PyCFunction) _wrap_new_MessageElement, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ldb_msg_element___len__", (PyCFunction)_wrap_ldb_msg_element___len__, METH_O, NULL},
-        { (char *)"ldb_msg_element_get", (PyCFunction) _wrap_ldb_msg_element_get, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"delete_ldb_msg_element", (PyCFunction)_wrap_delete_ldb_msg_element, METH_O, NULL},
-        { (char *)"ldb_msg_element___cmp__", (PyCFunction) _wrap_ldb_msg_element___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ldb_msg_element_swigregister", ldb_msg_element_swigregister, METH_VARARGS, NULL},
+        { (char *)"MessageElement___cmp__", (PyCFunction) _wrap_MessageElement___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"MessageElement___iter__", (PyCFunction)_wrap_MessageElement___iter__, METH_O, NULL},
+        { (char *)"MessageElement___set__", (PyCFunction)_wrap_MessageElement___set__, METH_O, NULL},
+        { (char *)"new_MessageElement", (PyCFunction) _wrap_new_MessageElement, METH_VARARGS | METH_KEYWORDS, (char *)"Message element."},
+        { (char *)"MessageElement___len__", (PyCFunction)_wrap_MessageElement___len__, METH_O, NULL},
+        { (char *)"MessageElement_get", (PyCFunction) _wrap_MessageElement_get, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"delete_MessageElement", (PyCFunction)_wrap_delete_MessageElement, METH_O, NULL},
+        { (char *)"MessageElement_swigregister", MessageElement_swigregister, METH_VARARGS, NULL},
+        { (char *)"MessageElement_swiginit", MessageElement_swiginit, METH_VARARGS, NULL},
         { (char *)"ldb_msg_list_elements", (PyCFunction) _wrap_ldb_msg_list_elements, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Message_dn_set", _wrap_Message_dn_set, METH_VARARGS, NULL},
         { (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},
@@ -5699,39 +5801,97 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL},
         { (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL},
-        { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.connect(url,flags=0,options=None) -> None\n"
+               "Connect to a LDB URL.\n"
+               ""},
         { (char *)"delete_Ldb", (PyCFunction)_wrap_delete_Ldb, METH_O, NULL},
         { (char *)"Ldb_search_ex", (PyCFunction) _wrap_Ldb_search_ex, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.delete(dn) -> None\n"
+               "Remove an entry.\n"
+               ""},
+        { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.rename(old_dn, new_dn) -> None\n"
+               "Rename an entry.\n"
+               ""},
         { (char *)"Ldb_parse_control_strings", (PyCFunction) _wrap_Ldb_parse_control_strings, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.add(message) -> None\n"
+               "Add an entry.\n"
+               ""},
+        { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.modify(message) -> None\n"
+               "Modify an entry.\n"
+               ""},
         { (char *)"Ldb_get_config_basedn", (PyCFunction)_wrap_Ldb_get_config_basedn, METH_O, NULL},
         { (char *)"Ldb_get_root_basedn", (PyCFunction)_wrap_Ldb_get_root_basedn, METH_O, NULL},
         { (char *)"Ldb_get_schema_basedn", (PyCFunction)_wrap_Ldb_get_schema_basedn, METH_O, NULL},
         { (char *)"Ldb_get_default_basedn", (PyCFunction)_wrap_Ldb_get_default_basedn, METH_O, NULL},
         { (char *)"Ldb_schema_format_value", (PyCFunction) _wrap_Ldb_schema_format_value, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Ldb_errstring", (PyCFunction)_wrap_Ldb_errstring, METH_O, NULL},
-        { (char *)"Ldb_set_create_perms", (PyCFunction) _wrap_Ldb_set_create_perms, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_set_modules_dir", (PyCFunction) _wrap_Ldb_set_modules_dir, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_set_debug", (PyCFunction) _wrap_Ldb_set_debug, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_set_opaque", (PyCFunction) _wrap_Ldb_set_opaque, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_get_opaque", (PyCFunction) _wrap_Ldb_get_opaque, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_transaction_start", (PyCFunction)_wrap_Ldb_transaction_start, METH_O, NULL},
-        { (char *)"Ldb_transaction_commit", (PyCFunction)_wrap_Ldb_transaction_commit, METH_O, NULL},
-        { (char *)"Ldb_transaction_cancel", (PyCFunction)_wrap_Ldb_transaction_cancel, METH_O, NULL},
+        { (char *)"Ldb_set_create_perms", (PyCFunction) _wrap_Ldb_set_create_perms, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_create_perms(mode) -> None\n"
+               "Set mode to use when creating new LDB files.\n"
+               ""},
+        { (char *)"Ldb_set_modules_dir", (PyCFunction) _wrap_Ldb_set_modules_dir, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_modules_dir(path) -> None\n"
+               "Set path LDB should search for modules\n"
+               ""},
+        { (char *)"Ldb_set_debug", (PyCFunction) _wrap_Ldb_set_debug, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_debug(callback) -> None\n"
+               "Set callback for LDB debug messages.\n"
+               "The callback should accept a debug level and debug text.\n"
+               ""},
+        { (char *)"Ldb_set_opaque", (PyCFunction) _wrap_Ldb_set_opaque, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_opaque(name, value) -> None\n"
+               "Set an opaque value on this LDB connection. \n"
+               ":note: Passing incorrect values may cause crashes.\n"
+               ""},
+        { (char *)"Ldb_get_opaque", (PyCFunction) _wrap_Ldb_get_opaque, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_opaque(name) -> value\n"
+               "Get an opaque value set on this LDB connection. \n"
+               ":note: The returned value may not be useful in Python.\n"
+               ""},
+        { (char *)"Ldb_transaction_start", (PyCFunction)_wrap_Ldb_transaction_start, METH_O, (char *)"\n"
+               "S.transaction_start() -> None\n"
+               "Start a new transaction.\n"
+               ""},
+        { (char *)"Ldb_transaction_commit", (PyCFunction)_wrap_Ldb_transaction_commit, METH_O, (char *)"\n"
+               "S.transaction_commit() -> None\n"
+               "Commit currently active transaction.\n"
+               ""},
+        { (char *)"Ldb_transaction_cancel", (PyCFunction)_wrap_Ldb_transaction_cancel, METH_O, (char *)"\n"
+               "S.transaction_cancel() -> None\n"
+               "Cancel currently active transaction.\n"
+               ""},
         { (char *)"Ldb_schema_attribute_remove", (PyCFunction) _wrap_Ldb_schema_attribute_remove, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Ldb_schema_attribute_add", (PyCFunction) _wrap_Ldb_schema_attribute_add, METH_VARARGS | METH_KEYWORDS, NULL},
         { (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_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.parse_ldif(ldif) -> iter(messages)\n"
+               "Parse a string formatted using LDIF.\n"
+               ""},
+        { (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},
-        { (char *)"timestring", (PyCFunction) _wrap_timestring, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"string_to_time", (PyCFunction) _wrap_string_to_time, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.valid_attr_name(name) -> bool\n"
+               "Check whether the supplied name is a valid attribute name.\n"
+               ""},
+        { (char *)"timestring", (PyCFunction) _wrap_timestring, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.timestring(int) -> string\n"
+               "Generate a LDAP time string from a UNIX timestamp\n"
+               ""},
+        { (char *)"string_to_time", (PyCFunction) _wrap_string_to_time, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.string_to_time(string) -> int\n"
+               "Parse a LDAP time string into a UNIX timestamp.\n"
+               ""},
+        { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.register_module(module) -> None\n"
+               "Register a LDB module.\n"
+               ""},
         { NULL, NULL, 0, NULL }
 };
 
@@ -5746,7 +5906,7 @@ static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_con
 static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_msg_element *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0};
index 448cc3ed60ffce9aa9918cf9860834561334cbec..89aba8f2766195cd1f1f36380be26c1940e513d0 100644 (file)
@@ -1,6 +1,10 @@
 [PYTHON::swig_ldb]
+LIBRARY_REALNAME = _ldb.$(SHLIBEXT)
 PUBLIC_DEPENDENCIES = LIBLDB
 CFLAGS = -Ilib/ldb/include
-SWIG_FILE = ldb.i
 
 swig_ldb_OBJ_FILES = lib/ldb/ldb_wrap.o
+
+$(eval $(call python_py_module_template,ldb.py,lib/ldb/ldb.py))
+
+$(swig_ldb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
index 5f3f727b5d18694a3cb75b6b8791d9e44c20fc7e..1ae3fde74464a05322203ecd56d3c2bd751506c2 100755 (executable)
@@ -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])
index ead5796b7b6ca9839606f4a857ea24d4da7f3c73..c76222c207d721379c35f29f7d32272ada02cd49 100755 (executable)
@@ -6,16 +6,18 @@ import getopt
 import optparse
 import sys
 
+sys.path.append("bin/python")
+
 import samba.getopt as options
 
-from auth import system_session
+from samba.auth import system_session
 from ldb import (SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError,
                  LDB_ERR_NO_SUCH_OBJECT, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS,
                  LDB_ERR_ENTRY_ALREADY_EXISTS, LDB_ERR_UNWILLING_TO_PERFORM,
                  LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, LDB_ERR_OTHER)
 from samba import Ldb
 from subunit import SubunitTestRunner
-import param
+from samba import param
 import unittest
 
 parser = optparse.OptionParser("ldap [options] <host>")
index 67b16dd06ed0e11a7b283e264a848cb973b5608d..0a89656fa2d9868109d784bc79bc9e950387159b 100644 (file)
@@ -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;
index 71ba37b4797300cc5f1d3bae133699f4087b9faf..f47d0d5d39202906126bc2c9da88bc988d1d8885 100644 (file)
@@ -44,7 +44,7 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
 static void ldb_wrap_debug(void *context, enum ldb_debug_level level, 
                           const char *fmt, va_list ap)
 {
-       int samba_level;
+       int samba_level = -1;
        char *s = NULL;
        switch (level) {
        case LDB_DEBUG_FATAL:
@@ -94,6 +94,7 @@ static int ldb_wrap_destructor(struct ldb_context *ldb)
   TODO:  We need an error_string parameter
  */
 struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
+                                    struct event_context *ev,
                                     struct loadparm_context *lp_ctx,
                                     const char *url,
                                     struct auth_session_info *session_info,
@@ -103,7 +104,6 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
 {
        struct ldb_context *ldb;
        int ret;
-       struct event_context *ev;
        char *real_url = NULL;
        size_t *startup_blocks;
 
@@ -115,10 +115,9 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
        ldb_set_modules_dir(ldb, 
                            talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
 
-       /* we want to use the existing event context if possible. This
-          relies on the fact that in smbd, everything is a child of
-          the main event_context */
-       ev = event_context_find(ldb);
+       if (ev == NULL) {
+               return NULL;
+       }
 
        if (ldb_set_opaque(ldb, "EventContext", ev)) {
                talloc_free(ldb);
index d3ff04b8808b0cd7eb8907043e50ab7197341e1d..e626b6ef8aa7d0797e59e4117553ed5a0a219365 100644 (file)
@@ -27,10 +27,12 @@ struct ldb_message;
 struct ldb_dn;
 struct cli_credentials;
 struct loadparm_context;
+struct event_context;
 
 char *wrap_casefold(void *context, void *mem_ctx, const char *s);
 
 struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
+                                    struct event_context *ev,
                                     struct loadparm_context *lp_ctx,
                                     const char *url,
                                     struct auth_session_info *session_info,
index 0a0097bdf35ccd15648e1ffb26c4d24f9233a4d3..eaf7e3581e1249cde11f1edd378f4e7e56ab1665 100644 (file)
@@ -13,5 +13,4 @@ PUBLIC_DEPENDENCIES = \
 # End SUBSYSTEM MESSAGING
 ################################################
 
-
-MESSAGING_OBJ_FILES = lib/messaging/messaging.o
+MESSAGING_OBJ_FILES = $(libmessagingsrcdir)/messaging.o
index 29d6e002477bc1376e5b1d004f88a765a4cb8bbe..e7b654894f0d0eebe055d1242d89571ddca71a5f 100644 (file)
@@ -544,6 +544,10 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct socket_address *path;
 
+       if (ev == NULL) {
+               return NULL;
+       }
+
        msg = talloc_zero(mem_ctx, struct messaging_context);
        if (msg == NULL) {
                return NULL;
@@ -556,10 +560,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       if (ev == NULL) {
-               ev = event_context_init(msg);
-       }
-
        /* create the messaging directory if needed */
        mkdir(dir, 0700);
 
@@ -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;
index 45b573518cc87d691b81c90686dda96c6af77bb7..f66b3a5b438728af4bc1c39222fbcb992740c66d 100644 (file)
@@ -134,7 +134,6 @@ static bool test_ping_speed(struct torture_context *tctx)
        talloc_free(msg_client_ctx);
        talloc_free(msg_server_ctx);
 
-       talloc_free(ev);
        return true;
 }
 
index 5f136a465de9a492e580d4286f32489417dd2886..015fbe511ce9c48362c43288db01456f4a5a18af 100644 (file)
@@ -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/source/lib/policy/adm.h b/source/lib/policy/adm.h
deleted file mode 100644 (file)
index c541ced..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
-   Copyright (C) 2006 Jelmer Vernooij <jelmer@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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef __ADM_H__
-#define __ADM_H__
-
-struct adm_file {
-       struct adm_class *classes;
-};
-
-struct adm_class {
-       struct adm_category *categories;
-};
-
-struct adm_category {
-       struct adm_category *subcategories;
-       struct adm_policy *policies;
-};
-
-struct adm_policy {
-       struct adm_part *parts;
-};
-
-struct adm_part {
-       int dummy;      
-};
-
-struct adm_file *adm_read_file(const char *);
-
-#endif /* __ADM_H__ */
diff --git a/source/lib/policy/config.mk b/source/lib/policy/config.mk
deleted file mode 100644 (file)
index 9a8e60b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[SUBSYSTEM::LIBPOLICY]
-CFLAGS = -Iheimdal/lib/roken
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBTALLOC CHARSET 
-
-LIBPOLICY_OBJ_FILES = lib/policy/lex.o lib/policy/parse_adm.o 
-
-lib/policy/lex.l: lib/policy/parse_adm.h
-
-lib/policy/parse_adm.h: lib/policy/parse_adm.c
-
-[BINARY::dumpadm]
-PRIVATE_DEPENDENCIES = LIBPOLICY LIBPOPT LIBSAMBA-HOSTCONFIG LIBTALLOC LIBSAMBA-UTIL CHARSET
-
-dumpadm_OBJ_FILES = lib/policy/dumpadm.o
diff --git a/source/lib/policy/dumpadm.c b/source/lib/policy/dumpadm.c
deleted file mode 100644 (file)
index 2ed5abf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
-   Copyright (C) 2006 Jelmer Vernooij <jelmer@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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "lib/popt/popt.h"
-#include "lib/policy/adm.h"
-
-int main(int argc, char **argv) 
-{
-       bool ret = true;
-       poptContext pc;
-       struct poptOption long_options[] = {
-               POPT_AUTOHELP
-               { 0, 0, 0, 0 }
-       };
-       
-       pc = poptGetContext(argv[0], argc, (const char **)argv, long_options, 0);
-       
-       poptSetOtherOptionHelp(pc, "<ADM-FILE> ...");
-
-       while ((poptGetNextOpt(pc) != -1)) 
-
-       if(!poptPeekArg(pc)) { 
-               poptPrintUsage(pc, stderr, 0);
-               exit(1);
-       }
-       
-       while (poptPeekArg(pc)) {
-               const char *name = poptGetArg(pc);
-
-               adm_read_file(name);
-       }
-
-       poptFreeContext(pc);
-
-       return ret;
-}
diff --git a/source/lib/policy/lex.c b/source/lib/policy/lex.c
deleted file mode 100644 (file)
index 6d52444..0000000
+++ /dev/null
@@ -1,2085 +0,0 @@
-#include "config.h"
-
-#line 3 "lex.yy.c"
-
-#define  YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with  platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types. 
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t; 
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN               (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN              (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN              (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX               (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX              (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX              (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX              (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX             (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX             (4294967295U)
-#endif
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else  /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index.  If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition.  This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state.  The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin  )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-    #define YY_LESS_LINENO(n)
-    
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
-       do \
-               { \
-               /* Undo effects of setting up yytext. */ \
-        int yyless_macro_arg = (n); \
-        YY_LESS_LINENO(yyless_macro_arg);\
-               *yy_cp = (yy_hold_char); \
-               YY_RESTORE_YY_MORE_OFFSET \
-               (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
-               YY_DO_BEFORE_ACTION; /* set up yytext again */ \
-               } \
-       while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr)  )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
-       {
-       FILE *yy_input_file;
-
-       char *yy_ch_buf;                /* input buffer */
-       char *yy_buf_pos;               /* current position in input buffer */
-
-       /* Size of input buffer in bytes, not including room for EOB
-        * characters.
-        */
-       yy_size_t yy_buf_size;
-
-       /* Number of characters read into yy_ch_buf, not including EOB
-        * characters.
-        */
-       int yy_n_chars;
-
-       /* Whether we "own" the buffer - i.e., we know we created it,
-        * and can realloc() it to grow it, and should free() it to
-        * delete it.
-        */
-       int yy_is_our_buffer;
-
-       /* Whether this is an "interactive" input source; if so, and
-        * if we're using stdio for input, then we want to use getc()
-        * instead of fread(), to make sure we stop fetching input after
-        * each newline.
-        */
-       int yy_is_interactive;
-
-       /* Whether we're considered to be at the beginning of a line.
-        * If so, '^' rules will be active on the next match, otherwise
-        * not.
-        */
-       int yy_at_bol;
-
-    int yy_bs_lineno; /**< The line count. */
-    int yy_bs_column; /**< The column count. */
-    
-       /* Whether to try to fill the input buffer when we reach the
-        * end of it.
-        */
-       int yy_fill_buffer;
-
-       int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
-       /* When an EOF's been seen but there's still some text to process
-        * then we mark the buffer as YY_EOF_PENDING, to indicate that we
-        * shouldn't try reading from the input source any more.  We might
-        * still have a bunch of tokens to match, though, because of
-        * possible backing-up.
-        *
-        * When we actually see the EOF, we change the status to "new"
-        * (via yyrestart()), so that the user can continue scanning by
-        * just pointing yyin at a new input file.
-        */
-#define YY_BUFFER_EOF_PENDING 2
-
-       };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
-                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
-                          : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static int yy_n_chars;         /* number of characters read into yy_ch_buf */
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0;                /* whether we need to initialize */
-static int yy_start = 0;       /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin.  A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart (FILE *input_file  );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
-void yy_delete_buffer (YY_BUFFER_STATE b  );
-void yy_flush_buffer (YY_BUFFER_STATE b  );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
-void yypop_buffer_state (void );
-
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len  );
-
-void *yyalloc (yy_size_t  );
-void *yyrealloc (void *,yy_size_t  );
-void yyfree (void *  );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
-       { \
-       if ( ! YY_CURRENT_BUFFER ){ \
-        yyensure_buffer_stack (); \
-               YY_CURRENT_BUFFER_LVALUE =    \
-            yy_create_buffer(yyin,YY_BUF_SIZE ); \
-       } \
-       YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
-       }
-
-#define yy_set_bol(at_bol) \
-       { \
-       if ( ! YY_CURRENT_BUFFER ){\
-        yyensure_buffer_stack (); \
-               YY_CURRENT_BUFFER_LVALUE =    \
-            yy_create_buffer(yyin,YY_BUF_SIZE ); \
-       } \
-       YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
-       }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-
-int yylineno = 1;
-
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[]  );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
-       (yytext_ptr) = yy_bp; \
-       yyleng = (size_t) (yy_cp - yy_bp); \
-       (yy_hold_char) = *yy_cp; \
-       *yy_cp = '\0'; \
-       (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 38
-#define YY_END_OF_BUFFER 39
-/* This struct is not used in this scanner,
-   but its presence is necessary. */
-struct yy_trans_info
-       {
-       flex_int32_t yy_verify;
-       flex_int32_t yy_nxt;
-       };
-static yyconst flex_int16_t yy_accept[185] =
-    {   0,
-        0,    0,   39,   38,   34,   35,   38,   38,   31,   38,
-       29,   32,   32,   32,   32,   32,   32,   32,   32,   32,
-       32,   32,   32,   32,   32,   32,   38,   34,    0,    0,
-       31,    0,   36,   32,   32,   32,   32,   32,   32,   32,
-       32,   32,   32,   32,   32,   32,   32,   32,   32,   32,
-       32,   32,   32,   32,   32,   32,   32,    0,   33,   37,
-       32,   32,   32,   32,   32,   32,   32,   32,    9,   32,
-       32,   32,   32,   15,   14,   32,   32,   32,   32,   32,
-       32,   32,   32,   32,   32,    0,   33,   32,   32,   32,
-       32,   32,   32,   32,   32,   32,   32,   32,   32,   16,
-
-       32,   18,   32,   32,   21,   32,   23,   24,   32,    0,
-       32,   32,   32,    4,   32,   32,   32,   32,   32,   32,
-       32,   32,   32,   32,   32,   32,   25,    0,   32,   32,
-       32,   32,    5,   32,   32,   32,   32,   32,   32,   32,
-       19,   32,   32,   32,   32,    0,   32,   32,   32,    6,
-       32,   32,   10,   32,   12,   13,   17,   32,   32,   32,
-       32,   27,    0,   32,    2,    3,   32,    8,   11,   20,
-       32,   32,   28,    0,   32,   32,   22,   26,   30,    1,
-       32,   32,    7,    0
-    } ;
-
-static yyconst flex_int32_t yy_ec[256] =
-    {   0,
-        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    2,    4,    5,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    6,    1,    1,    7,    7,    7,
-        7,    7,    7,    7,    7,    7,    7,    1,    8,    1,
-        9,    1,    1,    1,   10,   11,   12,   13,   14,   15,
-       16,   17,   18,   19,   20,   21,   22,   23,   24,   25,
-       26,   27,   28,   29,   30,   31,   32,   33,   34,   19,
-       35,   36,   37,    1,    6,    1,   19,   19,   19,   19,
-
-       19,   19,   38,   19,   39,   19,   19,   19,   19,   40,
-       19,   19,   19,   41,   42,   43,   19,   19,   19,   19,
-       19,   19,   36,    1,   36,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1
-    } ;
-
-static yyconst flex_int32_t yy_meta[44] =
-    {   0,
-        1,    1,    2,    1,    1,    3,    3,    1,    1,    4,
-        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4,    1,    5,    1,    4,    4,    4,
-        4,    4,    4
-    } ;
-
-static yyconst flex_int16_t yy_base[190] =
-    {   0,
-        0,    0,  213,  214,  210,  214,  207,    0,  203,  206,
-      214,  196,    0,   34,   31,   33,  178,  192,   39,   37,
-       38,  191,   29,  190,  175,  192,  159,  198,    0,  196,
-      191,  194,  214,    0,  167,  166,  180,  183,   48,  168,
-      173,  177,  164,  174,  153,   38,  163,  163,  162,  156,
-      161,  155,  162,  154,  145,  163,  155,  132,    0,  214,
-      156,  159,  160,  143,  160,  155,  143,  138,    0,  145,
-      143,  141,  146,    0,    0,  148,  147,  131,  141,  128,
-      134,  131,  126,  127,  123,  111,    0,  127,  134,  129,
-      120,  117,  117,  132,  115,  133,  121,  131,  122,    0,
-
-      112,    0,  126,  119,    0,  112,    0,    0,  121,   95,
-      110,  108,  120,    0,  109,  115,  104,  113,  108,  107,
-      102,  100,  104,   87,   93,   92,   29,   78,   96,   89,
-       91,   85,    0,   81,   79,   88,   82,   95,   94,   95,
-        0,   92,   76,   94,   45,   65,   84,   67,   67,    0,
-       76,   69,    0,   68,    0,    0,    0,   83,   81,   72,
-       78,    0,   50,   63,    0,    0,   69,    0,    0,    0,
-       76,   74,    0,   50,   44,   52,    0,    0,  214,    0,
-       37,   35,    0,  214,   71,   76,   79,   57,   82
-    } ;
-
-static yyconst flex_int16_t yy_def[190] =
-    {   0,
-      184,    1,  184,  184,  184,  184,  184,  185,  184,  186,
-      184,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  184,  184,  188,  185,
-      184,  186,  184,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  184,  189,  184,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  184,  189,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  184,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  184,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  184,  187,  187,  187,  187,
-      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  184,  187,  187,  187,  187,  187,  187,  187,
-      187,  187,  187,  184,  187,  187,  187,  187,  184,  187,
-      187,  187,  187,    0,  184,  184,  184,  184,  184
-    } ;
-
-static yyconst flex_int16_t yy_nxt[258] =
-    {   0,
-        4,    5,    6,    7,    8,    4,    9,   10,   11,   12,
-       13,   14,   15,   16,   13,   13,   13,   17,   13,   18,
-       13,   19,   20,   13,   21,   13,   22,   23,   24,   25,
-       26,   13,   13,   13,   27,   13,    4,   13,   13,   13,
-       13,   13,   13,   36,   39,   41,   48,   50,   46,   73,
-       37,  144,  145,   53,   38,   42,   47,   40,   54,  161,
-       59,   51,   65,  183,  182,   43,   49,  162,   66,  181,
-       74,   30,  180,   30,   30,   30,   32,   32,   32,   32,
-       32,   34,   34,   34,   87,   87,  179,  178,  177,  176,
-      175,  174,  173,  172,  171,  170,  169,  168,  167,  166,
-
-      165,  164,  163,  160,  159,  158,  157,  156,  155,  154,
-      153,  152,  151,  150,  149,  148,  147,  146,  143,  142,
-      141,  140,  139,  138,  137,  136,  135,  134,  133,  132,
-      131,  130,  129,  128,  127,  126,  125,  124,  123,  122,
-      121,  120,  119,  118,  117,  116,  115,  114,  113,  112,
-      111,  110,  109,  108,  107,  106,  105,  104,  103,  102,
-      101,  100,   99,   98,   97,   96,   95,   94,   93,   92,
-       91,   90,   89,   88,   86,   85,   84,   83,   82,   81,
-       80,   79,   78,   77,   76,   75,   72,   71,   70,   69,
-       68,   67,   64,   63,   62,   61,   33,   31,   60,   28,
-
-       58,   57,   56,   55,   52,   45,   44,   35,   33,   31,
-       29,   28,  184,    3,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184
-    } ;
-
-static yyconst flex_int16_t yy_chk[258] =
-    {   0,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,   14,   15,   16,   20,   21,   19,   46,
-       14,  127,  127,   23,   14,   16,   19,   15,   23,  145,
-      188,   21,   39,  182,  181,   16,   20,  145,   39,  176,
-       46,  185,  175,  185,  185,  185,  186,  186,  186,  186,
-      186,  187,  187,  187,  189,  189,  174,  172,  171,  167,
-      164,  163,  161,  160,  159,  158,  154,  152,  151,  149,
-
-      148,  147,  146,  144,  143,  142,  140,  139,  138,  137,
-      136,  135,  134,  132,  131,  130,  129,  128,  126,  125,
-      124,  123,  122,  121,  120,  119,  118,  117,  116,  115,
-      113,  112,  111,  110,  109,  106,  104,  103,  101,   99,
-       98,   97,   96,   95,   94,   93,   92,   91,   90,   89,
-       88,   86,   85,   84,   83,   82,   81,   80,   79,   78,
-       77,   76,   73,   72,   71,   70,   68,   67,   66,   65,
-       64,   63,   62,   61,   58,   57,   56,   55,   54,   53,
-       52,   51,   50,   49,   48,   47,   45,   44,   43,   42,
-       41,   40,   38,   37,   36,   35,   32,   31,   30,   28,
-
-       27,   26,   25,   24,   22,   18,   17,   12,   10,    9,
-        7,    5,    3,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
-      184,  184,  184,  184,  184,  184,  184
-    } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "lex.l"
-/* 
-   Unix SMB/CIFS implementation.
-   Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
-   Copyright (C) 2006 Jelmer Vernooij <jelmer@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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#line 23 "lex.l"
-#include "includes.h"
-#include "lib/policy/parse_adm.h"
-#include "param/param.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-
-static int lineno = 1;
-static bool utf16 = false;
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
-       if (utf16) { \
-               uint16_t v; \
-               if (fread(&v, 2, 1, yyin) < 1) \
-                       result = YY_NULL; \
-               else \
-                       result = push_codepoint(lp_iconv_convenience(global_loadparm), buf, v); \
-       } else { \
-               int c = getc(yyin); \
-               result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
-       } \
-}
-
-#line 610 "lex.yy.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (void );
-#else
-extern int yywrap (void );
-#endif
-#endif
-
-    static void yyunput (int c,char *buf_ptr  );
-    
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
-       if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
-               { \
-               int c = '*'; \
-               size_t n; \
-               for ( n = 0; n < max_size && \
-                            (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
-                       buf[n] = (char) c; \
-               if ( c == '\n' ) \
-                       buf[n++] = (char) c; \
-               if ( c == EOF && ferror( yyin ) ) \
-                       YY_FATAL_ERROR( "input in flex scanner failed" ); \
-               result = n; \
-               } \
-       else \
-               { \
-               errno=0; \
-               while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
-                       { \
-                       if( errno != EINTR) \
-                               { \
-                               YY_FATAL_ERROR( "input in flex scanner failed" ); \
-                               break; \
-                               } \
-                       errno=0; \
-                       clearerr(yyin); \
-                       } \
-               }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
-       YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
-       register yy_state_type yy_current_state;
-       register char *yy_cp, *yy_bp;
-       register int yy_act;
-    
-#line 47 "lex.l"
-
-
-#line 766 "lex.yy.c"
-
-       if ( !(yy_init) )
-               {
-               (yy_init) = 1;
-
-#ifdef YY_USER_INIT
-               YY_USER_INIT;
-#endif
-
-               if ( ! (yy_start) )
-                       (yy_start) = 1; /* first start state */
-
-               if ( ! yyin )
-                       yyin = stdin;
-
-               if ( ! yyout )
-                       yyout = stdout;
-
-               if ( ! YY_CURRENT_BUFFER ) {
-                       yyensure_buffer_stack ();
-                       YY_CURRENT_BUFFER_LVALUE =
-                               yy_create_buffer(yyin,YY_BUF_SIZE );
-               }
-
-               yy_load_buffer_state( );
-               }
-
-       while ( 1 )             /* loops until end-of-file is reached */
-               {
-               yy_cp = (yy_c_buf_p);
-
-               /* Support of yytext. */
-               *yy_cp = (yy_hold_char);
-
-               /* yy_bp points to the position in yy_ch_buf of the start of
-                * the current run.
-                */
-               yy_bp = yy_cp;
-
-               yy_current_state = (yy_start);
-yy_match:
-               do
-                       {
-                       register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
-                       if ( yy_accept[yy_current_state] )
-                               {
-                               (yy_last_accepting_state) = yy_current_state;
-                               (yy_last_accepting_cpos) = yy_cp;
-                               }
-                       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-                               {
-                               yy_current_state = (int) yy_def[yy_current_state];
-                               if ( yy_current_state >= 185 )
-                                       yy_c = yy_meta[(unsigned int) yy_c];
-                               }
-                       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-                       ++yy_cp;
-                       }
-               while ( yy_base[yy_current_state] != 214 );
-
-yy_find_action:
-               yy_act = yy_accept[yy_current_state];
-               if ( yy_act == 0 )
-                       { /* have to back up */
-                       yy_cp = (yy_last_accepting_cpos);
-                       yy_current_state = (yy_last_accepting_state);
-                       yy_act = yy_accept[yy_current_state];
-                       }
-
-               YY_DO_BEFORE_ACTION;
-
-do_action:     /* This label is used only to access EOF actions. */
-
-               switch ( yy_act )
-       { /* beginning of action switch */
-                       case 0: /* must back up */
-                       /* undo the effects of YY_DO_BEFORE_ACTION */
-                       *yy_cp = (yy_hold_char);
-                       yy_cp = (yy_last_accepting_cpos);
-                       yy_current_state = (yy_last_accepting_state);
-                       goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 49 "lex.l"
-{ return ACTIONLIST; }
-       YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 50 "lex.l"
-{ return CATEGORY; }
-       YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 51 "lex.l"
-{ return CHECKBOX; }
-       YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 52 "lex.l"
-{ return CLASS; }
-       YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 53 "lex.l"
-{ return DEL; }
-       YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 54 "lex.l"
-{ return DEFAULT; }
-       YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 55 "lex.l"
-{ return DROPDOWNLIST; }
-       YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 56 "lex.l"
-{ return EDITTEXT; }
-       YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 57 "lex.l"
-{ return END; }
-       YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 58 "lex.l"
-{ return EXPLAIN; }
-       YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 59 "lex.l"
-{ return ITEMLIST; }
-       YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 60 "lex.l"
-{ return KEYNAME; }
-       YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 61 "lex.l"
-{ return CLASS_MACHINE; }
-       YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 62 "lex.l"
-{ return MINIMUM; }
-       YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 63 "lex.l"
-{ return MAXIMUM; }
-       YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 64 "lex.l"
-{ return NAME; }
-       YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 65 "lex.l"
-{ return NUMERIC; }
-       YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 66 "lex.l"
-{ return PART; }
-       YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 67 "lex.l"
-{ return POLICY; }
-       YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 68 "lex.l"
-{ return REQUIRED; }
-       YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 69 "lex.l"
-{ return SPIN; }
-       YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 70 "lex.l"
-{ return SUPPORTED; }
-       YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 71 "lex.l"
-{ return TEXT; }
-       YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 72 "lex.l"
-{ return CLASS_USER; }
-       YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 73 "lex.l"
-{ return VALUE; }
-       YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 74 "lex.l"
-{ return VALUENAME; }
-       YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 75 "lex.l"
-{ return VALUEON; }
-       YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 76 "lex.l"
-{ return VALUEOFF; }
-       YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 77 "lex.l"
-{ return EQUALS; }
-       YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 78 "lex.l"
-{ return STRINGSSECTION; }
-       YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 80 "lex.l"
-{
-       char *e, *y = yytext;
-       yylval.integer = strtol((const char *)yytext, &e, 0);
-       if(e == y)
-               error_message("malformed constant (%s)", yytext);
-       else
-               return INTEGER;
-               }
-       YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 89 "lex.l"
-{ 
-       yylval.text = strdup ((const char *)yytext);
-       return LITERAL;
-       }
-       YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 94 "lex.l"
-{
-       yylval.text = strdup ((const char *)yytext);
-       return LOOKUPLITERAL;
-       }
-       YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 98 "lex.l"
-
-       YY_BREAK
-case 35:
-/* rule 35 can match eol */
-YY_RULE_SETUP
-#line 99 "lex.l"
-{ lineno++; }
-       YY_BREAK
-case 36:
-/* rule 36 can match eol */
-YY_RULE_SETUP
-#line 100 "lex.l"
-{ lineno++; }
-       YY_BREAK
-case 37:
-/* rule 37 can match eol */
-YY_RULE_SETUP
-#line 101 "lex.l"
-{ lineno++; yylval.text = strdup((const char *)yytext); return LITERAL; }
-       YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 102 "lex.l"
-ECHO;
-       YY_BREAK
-#line 1055 "lex.yy.c"
-case YY_STATE_EOF(INITIAL):
-       yyterminate();
-
-       case YY_END_OF_BUFFER:
-               {
-               /* Amount of text matched not including the EOB char. */
-               int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
-               /* Undo the effects of YY_DO_BEFORE_ACTION. */
-               *yy_cp = (yy_hold_char);
-               YY_RESTORE_YY_MORE_OFFSET
-
-               if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
-                       {
-                       /* We're scanning a new file or input source.  It's
-                        * possible that this happened because the user
-                        * just pointed yyin at a new source and called
-                        * yylex().  If so, then we have to assure
-                        * consistency between YY_CURRENT_BUFFER and our
-                        * globals.  Here is the right place to do so, because
-                        * this is the first action (other than possibly a
-                        * back-up) that will match for the new input source.
-                        */
-                       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
-                       YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
-                       YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
-                       }
-
-               /* Note that here we test for yy_c_buf_p "<=" to the position
-                * of the first EOB in the buffer, since yy_c_buf_p will
-                * already have been incremented past the NUL character
-                * (since all states make transitions on EOB to the
-                * end-of-buffer state).  Contrast this with the test
-                * in input().
-                */
-               if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
-                       { /* This was really a NUL. */
-                       yy_state_type yy_next_state;
-
-                       (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
-                       yy_current_state = yy_get_previous_state(  );
-
-                       /* Okay, we're now positioned to make the NUL
-                        * transition.  We couldn't have
-                        * yy_get_previous_state() go ahead and do it
-                        * for us because it doesn't know how to deal
-                        * with the possibility of jamming (and we don't
-                        * want to build jamming into it because then it
-                        * will run more slowly).
-                        */
-
-                       yy_next_state = yy_try_NUL_trans( yy_current_state );
-
-                       yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
-                       if ( yy_next_state )
-                               {
-                               /* Consume the NUL. */
-                               yy_cp = ++(yy_c_buf_p);
-                               yy_current_state = yy_next_state;
-                               goto yy_match;
-                               }
-
-                       else
-                               {
-                               yy_cp = (yy_c_buf_p);
-                               goto yy_find_action;
-                               }
-                       }
-
-               else switch ( yy_get_next_buffer(  ) )
-                       {
-                       case EOB_ACT_END_OF_FILE:
-                               {
-                               (yy_did_buffer_switch_on_eof) = 0;
-
-                               if ( yywrap( ) )
-                                       {
-                                       /* Note: because we've taken care in
-                                        * yy_get_next_buffer() to have set up
-                                        * yytext, we can now set up
-                                        * yy_c_buf_p so that if some total
-                                        * hoser (like flex itself) wants to
-                                        * call the scanner after we return the
-                                        * YY_NULL, it'll still work - another
-                                        * YY_NULL will get returned.
-                                        */
-                                       (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
-                                       yy_act = YY_STATE_EOF(YY_START);
-                                       goto do_action;
-                                       }
-
-                               else
-                                       {
-                                       if ( ! (yy_did_buffer_switch_on_eof) )
-                                               YY_NEW_FILE;
-                                       }
-                               break;
-                               }
-
-                       case EOB_ACT_CONTINUE_SCAN:
-                               (yy_c_buf_p) =
-                                       (yytext_ptr) + yy_amount_of_matched_text;
-
-                               yy_current_state = yy_get_previous_state(  );
-
-                               yy_cp = (yy_c_buf_p);
-                               yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-                               goto yy_match;
-
-                       case EOB_ACT_LAST_MATCH:
-                               (yy_c_buf_p) =
-                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
-                               yy_current_state = yy_get_previous_state(  );
-
-                               yy_cp = (yy_c_buf_p);
-                               yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-                               goto yy_find_action;
-                       }
-               break;
-               }
-
-       default:
-               YY_FATAL_ERROR(
-                       "fatal flex scanner internal error--no action found" );
-       } /* end of action switch */
-               } /* end of scanning one token */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- *     EOB_ACT_LAST_MATCH -
- *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- *     EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
-       register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
-       register char *source = (yytext_ptr);
-       register int number_to_move, i;
-       int ret_val;
-
-       if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
-               YY_FATAL_ERROR(
-               "fatal flex scanner internal error--end of buffer missed" );
-
-       if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
-               { /* Don't try to fill the buffer, so this is an EOF. */
-               if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
-                       {
-                       /* We matched a single character, the EOB, so
-                        * treat this as a final EOF.
-                        */
-                       return EOB_ACT_END_OF_FILE;
-                       }
-
-               else
-                       {
-                       /* We matched some text prior to the EOB, first
-                        * process it.
-                        */
-                       return EOB_ACT_LAST_MATCH;
-                       }
-               }
-
-       /* Try to read more data. */
-
-       /* First move last chars to start of buffer. */
-       number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
-       for ( i = 0; i < number_to_move; ++i )
-               *(dest++) = *(source++);
-
-       if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
-               /* don't do the read, it's not guaranteed to return an EOF,
-                * just force an EOF
-                */
-               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
-       else
-               {
-                       int num_to_read =
-                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
-               while ( num_to_read <= 0 )
-                       { /* Not enough room in the buffer - grow it. */
-
-                       /* just a shorter name for the current buffer */
-                       YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
-                       int yy_c_buf_p_offset =
-                               (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
-                       if ( b->yy_is_our_buffer )
-                               {
-                               int new_size = b->yy_buf_size * 2;
-
-                               if ( new_size <= 0 )
-                                       b->yy_buf_size += b->yy_buf_size / 8;
-                               else
-                                       b->yy_buf_size *= 2;
-
-                               b->yy_ch_buf = (char *)
-                                       /* Include room in for 2 EOB chars. */
-                                       yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
-                               }
-                       else
-                               /* Can't grow it, we don't own it. */
-                               b->yy_ch_buf = 0;
-
-                       if ( ! b->yy_ch_buf )
-                               YY_FATAL_ERROR(
-                               "fatal error - scanner input buffer overflow" );
-
-                       (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
-                       num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
-                                               number_to_move - 1;
-
-                       }
-
-               if ( num_to_read > YY_READ_BUF_SIZE )
-                       num_to_read = YY_READ_BUF_SIZE;
-
-               /* Read in more data. */
-               YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
-                       (yy_n_chars), (size_t) num_to_read );
-
-               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
-               }
-
-       if ( (yy_n_chars) == 0 )
-               {
-               if ( number_to_move == YY_MORE_ADJ )
-                       {
-                       ret_val = EOB_ACT_END_OF_FILE;
-                       yyrestart(yyin  );
-                       }
-
-               else
-                       {
-                       ret_val = EOB_ACT_LAST_MATCH;
-                       YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
-                               YY_BUFFER_EOF_PENDING;
-                       }
-               }
-
-       else
-               ret_val = EOB_ACT_CONTINUE_SCAN;
-
-       (yy_n_chars) += number_to_move;
-       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
-       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
-       (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
-       return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-    static yy_state_type yy_get_previous_state (void)
-{
-       register yy_state_type yy_current_state;
-       register char *yy_cp;
-    
-       yy_current_state = (yy_start);
-
-       for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
-               {
-               register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
-               if ( yy_accept[yy_current_state] )
-                       {
-                       (yy_last_accepting_state) = yy_current_state;
-                       (yy_last_accepting_cpos) = yy_cp;
-                       }
-               while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-                       {
-                       yy_current_state = (int) yy_def[yy_current_state];
-                       if ( yy_current_state >= 185 )
-                               yy_c = yy_meta[(unsigned int) yy_c];
-                       }
-               yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-               }
-
-       return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- *     next_state = yy_try_NUL_trans( current_state );
- */
-    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
-{
-       register int yy_is_jam;
-       register char *yy_cp = (yy_c_buf_p);
-
-       register YY_CHAR yy_c = 1;
-       if ( yy_accept[yy_current_state] )
-               {
-               (yy_last_accepting_state) = yy_current_state;
-               (yy_last_accepting_cpos) = yy_cp;
-               }
-       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-               {
-               yy_current_state = (int) yy_def[yy_current_state];
-               if ( yy_current_state >= 185 )
-                       yy_c = yy_meta[(unsigned int) yy_c];
-               }
-       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-       yy_is_jam = (yy_current_state == 184);
-
-       return yy_is_jam ? 0 : yy_current_state;
-}
-
-    static void yyunput (int c, register char * yy_bp )
-{
-       register char *yy_cp;
-    
-    yy_cp = (yy_c_buf_p);
-
-       /* undo effects of setting up yytext */
-       *yy_cp = (yy_hold_char);
-
-       if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
-               { /* need to shift things up to make room */
-               /* +2 for EOB chars. */
-               register int number_to_move = (yy_n_chars) + 2;
-               register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
-                                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
-               register char *source =
-                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
-               while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
-                       *--dest = *--source;
-
-               yy_cp += (int) (dest - source);
-               yy_bp += (int) (dest - source);
-               YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
-                       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
-               if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
-                       YY_FATAL_ERROR( "flex scanner push-back overflow" );
-               }
-
-       *--yy_cp = (char) c;
-
-       (yytext_ptr) = yy_bp;
-       (yy_hold_char) = *yy_cp;
-       (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-    static int yyinput (void)
-#else
-    static int input  (void)
-#endif
-
-{
-       int c;
-    
-       *(yy_c_buf_p) = (yy_hold_char);
-
-       if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
-               {
-               /* yy_c_buf_p now points to the character we want to return.
-                * If this occurs *before* the EOB characters, then it's a
-                * valid NUL; if not, then we've hit the end of the buffer.
-                */
-               if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
-                       /* This was really a NUL. */
-                       *(yy_c_buf_p) = '\0';
-
-               else
-                       { /* need more input */
-                       int offset = (yy_c_buf_p) - (yytext_ptr);
-                       ++(yy_c_buf_p);
-
-                       switch ( yy_get_next_buffer(  ) )
-                               {
-                               case EOB_ACT_LAST_MATCH:
-                                       /* This happens because yy_g_n_b()
-                                        * sees that we've accumulated a
-                                        * token and flags that we need to
-                                        * try matching the token before
-                                        * proceeding.  But for input(),
-                                        * there's no matching to consider.
-                                        * So convert the EOB_ACT_LAST_MATCH
-                                        * to EOB_ACT_END_OF_FILE.
-                                        */
-
-                                       /* Reset buffer status. */
-                                       yyrestart(yyin );
-
-                                       /*FALLTHROUGH*/
-
-                               case EOB_ACT_END_OF_FILE:
-                                       {
-                                       if ( yywrap( ) )
-                                               return EOF;
-
-                                       if ( ! (yy_did_buffer_switch_on_eof) )
-                                               YY_NEW_FILE;
-#ifdef __cplusplus
-                                       return yyinput();
-#else
-                                       return input();
-#endif
-                                       }
-
-                               case EOB_ACT_CONTINUE_SCAN:
-                                       (yy_c_buf_p) = (yytext_ptr) + offset;
-                                       break;
-                               }
-                       }
-               }
-
-       c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
-       *(yy_c_buf_p) = '\0';   /* preserve yytext */
-       (yy_hold_char) = *++(yy_c_buf_p);
-
-       return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- * 
- * @note This function does not reset the start condition to @c INITIAL .
- */
-    void yyrestart  (FILE * input_file )
-{
-    
-       if ( ! YY_CURRENT_BUFFER ){
-        yyensure_buffer_stack ();
-               YY_CURRENT_BUFFER_LVALUE =
-            yy_create_buffer(yyin,YY_BUF_SIZE );
-       }
-
-       yy_init_buffer(YY_CURRENT_BUFFER,input_file );
-       yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- * 
- */
-    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
-{
-    
-       /* TODO. We should be able to replace this entire function body
-        * with
-        *              yypop_buffer_state();
-        *              yypush_buffer_state(new_buffer);
-     */
-       yyensure_buffer_stack ();
-       if ( YY_CURRENT_BUFFER == new_buffer )
-               return;
-
-       if ( YY_CURRENT_BUFFER )
-               {
-               /* Flush out information for old buffer. */
-               *(yy_c_buf_p) = (yy_hold_char);
-               YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
-               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
-               }
-
-       YY_CURRENT_BUFFER_LVALUE = new_buffer;
-       yy_load_buffer_state( );
-
-       /* We don't actually know whether we did this switch during
-        * EOF (yywrap()) processing, but the only time this flag
-        * is looked at is after yywrap() is called, so it's safe
-        * to go ahead and always set it.
-        */
-       (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state  (void)
-{
-       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
-       (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
-       yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
-       (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- * 
- * @return the allocated buffer state.
- */
-    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
-{
-       YY_BUFFER_STATE b;
-    
-       b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
-       if ( ! b )
-               YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
-       b->yy_buf_size = size;
-
-       /* yy_ch_buf has to be 2 characters longer than the size given because
-        * we need to put in 2 end-of-buffer characters.
-        */
-       b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
-       if ( ! b->yy_ch_buf )
-               YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
-       b->yy_is_our_buffer = 1;
-
-       yy_init_buffer(b,file );
-
-       return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- * 
- */
-    void yy_delete_buffer (YY_BUFFER_STATE  b )
-{
-    
-       if ( ! b )
-               return;
-
-       if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
-               YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
-       if ( b->yy_is_our_buffer )
-               yyfree((void *) b->yy_ch_buf  );
-
-       yyfree((void *) b  );
-}
-
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-    
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
-    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
-
-{
-       int oerrno = errno;
-    
-       yy_flush_buffer(b );
-
-       b->yy_input_file = file;
-       b->yy_fill_buffer = 1;
-
-    /* If b is the current buffer, then yy_init_buffer was _probably_
-     * called from yyrestart() or through yy_get_next_buffer.
-     * In that case, we don't want to reset the lineno or column.
-     */
-    if (b != YY_CURRENT_BUFFER){
-        b->yy_bs_lineno = 1;
-        b->yy_bs_column = 0;
-    }
-
-        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-    
-       errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- * 
- */
-    void yy_flush_buffer (YY_BUFFER_STATE  b )
-{
-       if ( ! b )
-               return;
-
-       b->yy_n_chars = 0;
-
-       /* We always need two end-of-buffer characters.  The first causes
-        * a transition to the end-of-buffer state.  The second causes
-        * a jam in that state.
-        */
-       b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
-       b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
-       b->yy_buf_pos = &b->yy_ch_buf[0];
-
-       b->yy_at_bol = 1;
-       b->yy_buffer_status = YY_BUFFER_NEW;
-
-       if ( b == YY_CURRENT_BUFFER )
-               yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- *  the current state. This function will allocate the stack
- *  if necessary.
- *  @param new_buffer The new state.
- *  
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
-       if (new_buffer == NULL)
-               return;
-
-       yyensure_buffer_stack();
-
-       /* This block is copied from yy_switch_to_buffer. */
-       if ( YY_CURRENT_BUFFER )
-               {
-               /* Flush out information for old buffer. */
-               *(yy_c_buf_p) = (yy_hold_char);
-               YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
-               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
-               }
-
-       /* Only push if top exists. Otherwise, replace top. */
-       if (YY_CURRENT_BUFFER)
-               (yy_buffer_stack_top)++;
-       YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
-       /* copied from yy_switch_to_buffer. */
-       yy_load_buffer_state( );
-       (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- *  The next element becomes the new top.
- *  
- */
-void yypop_buffer_state (void)
-{
-       if (!YY_CURRENT_BUFFER)
-               return;
-
-       yy_delete_buffer(YY_CURRENT_BUFFER );
-       YY_CURRENT_BUFFER_LVALUE = NULL;
-       if ((yy_buffer_stack_top) > 0)
-               --(yy_buffer_stack_top);
-
-       if (YY_CURRENT_BUFFER) {
-               yy_load_buffer_state( );
-               (yy_did_buffer_switch_on_eof) = 1;
-       }
-}
-
-/* Allocates the stack if it does not exist.
- *  Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
-       int num_to_alloc;
-    
-       if (!(yy_buffer_stack)) {
-
-               /* First allocation is just for 2 elements, since we don't know if this
-                * scanner will even need a stack. We use 2 instead of 1 to avoid an
-                * immediate realloc on the next call.
-         */
-               num_to_alloc = 1;
-               (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
-                                                               (num_to_alloc * sizeof(struct yy_buffer_state*)
-                                                               );
-               
-               memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-                               
-               (yy_buffer_stack_max) = num_to_alloc;
-               (yy_buffer_stack_top) = 0;
-               return;
-       }
-
-       if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
-               /* Increase the buffer to prepare for a possible push. */
-               int grow_size = 8 /* arbitrary grow size */;
-
-               num_to_alloc = (yy_buffer_stack_max) + grow_size;
-               (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
-                                                               ((yy_buffer_stack),
-                                                               num_to_alloc * sizeof(struct yy_buffer_state*)
-                                                               );
-
-               /* zero only the new slots.*/
-               memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
-               (yy_buffer_stack_max) = num_to_alloc;
-       }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- * 
- * @return the newly allocated buffer state object. 
- */
-YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
-{
-       YY_BUFFER_STATE b;
-    
-       if ( size < 2 ||
-            base[size-2] != YY_END_OF_BUFFER_CHAR ||
-            base[size-1] != YY_END_OF_BUFFER_CHAR )
-               /* They forgot to leave room for the EOB's. */
-               return 0;
-
-       b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
-       if ( ! b )
-               YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
-       b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
-       b->yy_buf_pos = b->yy_ch_buf = base;
-       b->yy_is_our_buffer = 0;
-       b->yy_input_file = 0;
-       b->yy_n_chars = b->yy_buf_size;
-       b->yy_is_interactive = 0;
-       b->yy_at_bol = 1;
-       b->yy_fill_buffer = 0;
-       b->yy_buffer_status = YY_BUFFER_NEW;
-
-       yy_switch_to_buffer(b  );
-
-       return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- * 
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- *       yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
-{
-    
-       return yy_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- * 
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
-{
-       YY_BUFFER_STATE b;
-       char *buf;
-       yy_size_t n;
-       int i;
-    
-       /* Get memory for full buffer, including space for trailing EOB's. */
-       n = _yybytes_len + 2;
-       buf = (char *) yyalloc(n  );
-       if ( ! buf )
-               YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
-       for ( i = 0; i < _yybytes_len; ++i )
-               buf[i] = yybytes[i];
-
-       buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
-       b = yy_scan_buffer(buf,n );
-       if ( ! b )
-               YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
-       /* It's okay to grow etc. this buffer, and we should throw it
-        * away when we're done.
-        */
-       b->yy_is_our_buffer = 1;
-
-       return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
-       (void) fprintf( stderr, "%s\n", msg );
-       exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
-       do \
-               { \
-               /* Undo effects of setting up yytext. */ \
-        int yyless_macro_arg = (n); \
-        YY_LESS_LINENO(yyless_macro_arg);\
-               yytext[yyleng] = (yy_hold_char); \
-               (yy_c_buf_p) = yytext + yyless_macro_arg; \
-               (yy_hold_char) = *(yy_c_buf_p); \
-               *(yy_c_buf_p) = '\0'; \
-               yyleng = yyless_macro_arg; \
-               } \
-       while ( 0 )
-
-/* Accessor  methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- * 
- */
-int yyget_lineno  (void)
-{
-        
-    return yylineno;
-}
-
-/** Get the input stream.
- * 
- */
-FILE *yyget_in  (void)
-{
-        return yyin;
-}
-
-/** Get the output stream.
- * 
- */
-FILE *yyget_out  (void)
-{
-        return yyout;
-}
-
-/** Get the length of the current token.
- * 
- */
-int yyget_leng  (void)
-{
-        return yyleng;
-}
-
-/** Get the current token.
- * 
- */
-
-char *yyget_text  (void)
-{
-        return yytext;
-}
-
-/** Set the current line number.
- * @param line_number
- * 
- */
-void yyset_lineno (int  line_number )
-{
-    
-    yylineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- * 
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE *  in_str )
-{
-        yyin = in_str ;
-}
-
-void yyset_out (FILE *  out_str )
-{
-        yyout = out_str ;
-}
-
-int yyget_debug  (void)
-{
-        return yy_flex_debug;
-}
-
-void yyset_debug (int  bdebug )
-{
-        yy_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
-        /* Initialization is the same as for the non-reentrant scanner.
-     * This function is called from yylex_destroy(), so don't allocate here.
-     */
-
-    (yy_buffer_stack) = 0;
-    (yy_buffer_stack_top) = 0;
-    (yy_buffer_stack_max) = 0;
-    (yy_c_buf_p) = (char *) 0;
-    (yy_init) = 0;
-    (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
-    yyin = stdin;
-    yyout = stdout;
-#else
-    yyin = (FILE *) 0;
-    yyout = (FILE *) 0;
-#endif
-
-    /* For future reference: Set errno on error, since we are called by
-     * yylex_init()
-     */
-    return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy  (void)
-{
-    
-    /* Pop the buffer stack, destroying each element. */
-       while(YY_CURRENT_BUFFER){
-               yy_delete_buffer(YY_CURRENT_BUFFER  );
-               YY_CURRENT_BUFFER_LVALUE = NULL;
-               yypop_buffer_state();
-       }
-
-       /* Destroy the stack itself. */
-       yyfree((yy_buffer_stack) );
-       (yy_buffer_stack) = NULL;
-
-    /* Reset the globals. This is important in a non-reentrant scanner so the next time
-     * yylex() is called, initialization will occur. */
-    yy_init_globals( );
-
-    return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
-       register int i;
-       for ( i = 0; i < n; ++i )
-               s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
-       register int n;
-       for ( n = 0; s[n]; ++n )
-               ;
-
-       return n;
-}
-#endif
-
-void *yyalloc (yy_size_t  size )
-{
-       return (void *) malloc( size );
-}
-
-void *yyrealloc  (void * ptr, yy_size_t  size )
-{
-       /* The cast to (char *) in the following accommodates both
-        * implementations that use char* generic pointers, and those
-        * that use void* generic pointers.  It works with the latter
-        * because both ANSI C and C++ allow castless assignment from
-        * any pointer type to void*, and deal with argument conversions
-        * as though doing an assignment.
-        */
-       return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr )
-{
-       free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 102 "lex.l"
-
-
-
-#ifndef yywrap /* XXX */
-int
-yywrap () 
-{
-     return 1;
-}
-#endif
-
-
-void
-error_message (const char *format, ...)
-{
-       va_list args;
-
-       va_start (args, format);
-       fprintf (stderr, "%d:", lineno);
-       vfprintf (stderr, format, args);
-       va_end (args);
-}
-
-struct adm_file *adm_read_file(const char *file)
-{
-       uint8_t c[2];
-       yyin = fopen(file, "r");
-       if (yyin == NULL)
-               return NULL;
-
-       c[0] = getc(yyin);
-       c[1] = getc(yyin);
-       if (c[0] == 0xff && c[1] == 0xfe) {
-               utf16 = true;
-       } else {
-               rewind(yyin);
-       }
-
-       yyparse();
-
-       return NULL; /* FIXME */
-}
-
diff --git a/source/lib/policy/lex.l b/source/lib/policy/lex.l
deleted file mode 100644 (file)
index dc1f0aa..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
-   Copyright (C) 2006 Jelmer Vernooij <jelmer@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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-%{
-#include "includes.h"
-#include "lib/policy/parse_adm.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-
-static int lineno = 1;
-static bool utf16 = false;
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
-       if (utf16) { \
-               uint16_t v; \
-               if (fread(&v, 2, 1, yyin) < 1) \
-                       result = YY_NULL; \
-               else \
-                       result = push_codepoint(buf, v); \
-       } else { \
-               int c = getc(yyin); \
-               result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
-       } \
-}
-
-%}
-
-%%
-
-ACTIONLIST { return ACTIONLIST; }
-CATEGORY { return CATEGORY; }
-CHECKBOX { return CHECKBOX; }
-CLASS { return CLASS; }
-DELETE { return DEL; }
-DEFAULT { return DEFAULT; }
-DROPDOWNLIST { return DROPDOWNLIST; }
-EDITTEXT { return EDITTEXT; }
-END { return END; }
-EXPLAIN { return EXPLAIN; }
-ITEMLIST { return ITEMLIST; }
-KEYNAME { return KEYNAME; }
-MACHINE { return CLASS_MACHINE; }
-MIN { return MINIMUM; }
-MAX { return MAXIMUM; }
-NAME { return NAME; }
-NUMERIC { return NUMERIC; }
-PART { return PART; }
-POLICY { return POLICY; }
-REQUIRED { return REQUIRED; }
-SPIN { return SPIN; }
-SUPPORTED { return SUPPORTED; }
-TEXT { return TEXT; }
-USER { return CLASS_USER; }
-VALUE { return VALUE; }
-VALUENAME { return VALUENAME; }
-VALUEON { return VALUEON; }
-VALUEOFF { return VALUEOFF; }
-=              { return EQUALS; }
-\[strings\]    { return STRINGSSECTION; }
-
-[0-9]+ {
-       char *e, *y = yytext;
-       yylval.integer = strtol((const char *)yytext, &e, 0);
-       if(e == y)
-               error_message("malformed constant (%s)", yytext);
-       else
-               return INTEGER;
-               }
-
-[A-Za-z\\{}][{}\-\\A-Za-z0-9_]* { 
-       yylval.text = strdup ((const char *)yytext);
-       return LITERAL;
-       }
-
-"!!"[A-Za-z][-A-Za-z0-9_]*  {
-       yylval.text = strdup ((const char *)yytext);
-       return LOOKUPLITERAL;
-       }
-[ \t]+
-\n                     { lineno++; }
-;[^\n]*\n              { lineno++; }
-\"([^\n]+)\n           { lineno++; yylval.text = strdup((const char *)yytext); return LITERAL; }
-%%
-
-#ifndef yywrap /* XXX */
-int
-yywrap () 
-{
-     return 1;
-}
-#endif
-
-
-void
-error_message (const char *format, ...)
-{
-       va_list args;
-
-       va_start (args, format);
-       fprintf (stderr, "%d:", lineno);
-       vfprintf (stderr, format, args);
-       va_end (args);
-}
-
-struct adm_file *adm_read_file(const char *file)
-{
-       uint8_t c[2];
-       yyin = fopen(file, "r");
-       if (yyin == NULL)
-               return NULL;
-
-       c[0] = getc(yyin);
-       c[1] = getc(yyin);
-       if (c[0] == 0xff && c[1] == 0xfe) {
-               utf16 = true;
-       } else {
-               rewind(yyin);
-       }
-
-       yyparse();
-
-       return NULL; /* FIXME */
-}
diff --git a/source/lib/policy/parse_adm.c b/source/lib/policy/parse_adm.c
deleted file mode 100644 (file)
index c68e2db..0000000
+++ /dev/null
@@ -1,1726 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3.  */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
-   Free Software Foundation, Inc.
-
-   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 2, 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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
-
-/* As a special exception, you may create a larger work that contains
-   part or all of the Bison parser skeleton and distribute that work
-   under terms of your choice, so long as that work isn't itself a
-   parser generator using the skeleton or a modified version thereof
-   as a parser skeleton.  Alternatively, if you modify or redistribute
-   the parser skeleton itself, you may (at your option) remove this
-   special exception, which will cause the skeleton and the resulting
-   Bison output files to be licensed under the GNU General Public
-   License without this special exception.
-
-   This special exception was added by the Free Software Foundation in
-   version 2.2 of Bison.  */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
-   simplifying the original so-called "semantic" parser.  */
-
-/* All symbols defined below should begin with yy or YY, to avoid
-   infringing on user name space.  This should be done even for local
-   variables, as they might otherwise be expanded by user macros.
-   There are some unavoidable exceptions within include files to
-   define necessary library symbols; they are noted "INFRINGES ON
-   USER NAME SPACE" below.  */
-
-/* Identify Bison output.  */
-#define YYBISON 1
-
-/* Bison version.  */
-#define YYBISON_VERSION "2.3"
-
-/* Skeleton name.  */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers.  */
-#define YYPURE 0
-
-/* Using locations.  */
-#define YYLSP_NEEDED 0
-
-
-
-/* Tokens.  */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
-      know about them.  */
-   enum yytokentype {
-     CATEGORY = 258,
-     CLASS = 259,
-     CLASS_USER = 260,
-     CLASS_MACHINE = 261,
-     POLICY = 262,
-     KEYNAME = 263,
-     EXPLAIN = 264,
-     VALUENAME = 265,
-     VALUEON = 266,
-     VALUEOFF = 267,
-     PART = 268,
-     ITEMLIST = 269,
-     NAME = 270,
-     VALUE = 271,
-     NUMERIC = 272,
-     EDITTEXT = 273,
-     TEXT = 274,
-     DROPDOWNLIST = 275,
-     CHECKBOX = 276,
-     MINIMUM = 277,
-     MAXIMUM = 278,
-     DEFAULT = 279,
-     END = 280,
-     ACTIONLIST = 281,
-     DEL = 282,
-     SUPPORTED = 283,
-     LITERAL = 284,
-     INTEGER = 285,
-     LOOKUPLITERAL = 286,
-     CLIENTEXT = 287,
-     REQUIRED = 288,
-     NOSORT = 289,
-     SPIN = 290,
-     EQUALS = 291,
-     STRINGSSECTION = 292
-   };
-#endif
-/* Tokens.  */
-#define CATEGORY 258
-#define CLASS 259
-#define CLASS_USER 260
-#define CLASS_MACHINE 261
-#define POLICY 262
-#define KEYNAME 263
-#define EXPLAIN 264
-#define VALUENAME 265
-#define VALUEON 266
-#define VALUEOFF 267
-#define PART 268
-#define ITEMLIST 269
-#define NAME 270
-#define VALUE 271
-#define NUMERIC 272
-#define EDITTEXT 273
-#define TEXT 274
-#define DROPDOWNLIST 275
-#define CHECKBOX 276
-#define MINIMUM 277
-#define MAXIMUM 278
-#define DEFAULT 279
-#define END 280
-#define ACTIONLIST 281
-#define DEL 282
-#define SUPPORTED 283
-#define LITERAL 284
-#define INTEGER 285
-#define LOOKUPLITERAL 286
-#define CLIENTEXT 287
-#define REQUIRED 288
-#define NOSORT 289
-#define SPIN 290
-#define EQUALS 291
-#define STRINGSSECTION 292
-
-
-
-
-/* Copy the first part of user declarations.  */
-#line 24 "lib/policy/parse_adm.y"
-
-#include "config.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-void yyerror (const char *s);
-extern int yylex (void);
-
-
-
-/* Enabling traces.  */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-/* Enabling verbose error messages.  */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* Enabling the token table.  */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
-#endif
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 33 "lib/policy/parse_adm.y"
-{
-       char *text;
-       int integer;
-}
-/* Line 187 of yacc.c.  */
-#line 184 "lib/policy/parse_adm.y"
-       YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations.  */
-
-
-/* Line 216 of yacc.c.  */
-#line 197 "lib/policy/parse_adm.y"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-#  define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-#  define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-#  define YYSIZE_T size_t
-# else
-#  define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if YYENABLE_NLS
-#  if ENABLE_NLS
-#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-#   define YY_(msgid) dgettext ("bison-runtime", msgid)
-#  endif
-# endif
-# ifndef YY_
-#  define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E.  */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions.  */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int i)
-#else
-static int
-YYID (i)
-    int i;
-#endif
-{
-  return i;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols.  */
-
-# ifdef YYSTACK_USE_ALLOCA
-#  if YYSTACK_USE_ALLOCA
-#   ifdef __GNUC__
-#    define YYSTACK_ALLOC __builtin_alloca
-#   elif defined __BUILTIN_VA_ARG_INCR
-#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-#   elif defined _AIX
-#    define YYSTACK_ALLOC __alloca
-#   elif defined _MSC_VER
-#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-#    define alloca _alloca
-#   else
-#    define YYSTACK_ALLOC alloca
-#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-#     ifndef _STDLIB_H
-#      define _STDLIB_H 1
-#     endif
-#    endif
-#   endif
-#  endif
-# endif
-
-# ifdef YYSTACK_ALLOC
-   /* Pacify GCC's `empty if-body' warning.  */
-#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-#  ifndef YYSTACK_ALLOC_MAXIMUM
-    /* The OS might guarantee only one guard page at the bottom of the stack,
-       and a page size can be as small as 4096 bytes.  So we cannot safely
-       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
-       to allow for a few compiler-allocated temporary stack slots.  */
-#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-#  endif
-# else
-#  define YYSTACK_ALLOC YYMALLOC
-#  define YYSTACK_FREE YYFREE
-#  ifndef YYSTACK_ALLOC_MAXIMUM
-#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-#  endif
-#  if (defined __cplusplus && ! defined _STDLIB_H \
-       && ! ((defined YYMALLOC || defined malloc) \
-            && (defined YYFREE || defined free)))
-#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-#   ifndef _STDLIB_H
-#    define _STDLIB_H 1
-#   endif
-#  endif
-#  ifndef YYMALLOC
-#   define YYMALLOC malloc
-#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-#   endif
-#  endif
-#  ifndef YYFREE
-#   define YYFREE free
-#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-#   endif
-#  endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
-     && (! defined __cplusplus \
-        || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member.  */
-union yyalloc
-{
-  yytype_int16 yyss;
-  YYSTYPE yyvs;
-  };
-
-/* The size of the maximum gap between one aligned stack and the next.  */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
-   N elements.  */
-# define YYSTACK_BYTES(N) \
-     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
-      + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO.  The source and destination do
-   not overlap.  */
-# ifndef YYCOPY
-#  if defined __GNUC__ && 1 < __GNUC__
-#   define YYCOPY(To, From, Count) \
-      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-#  else
-#   define YYCOPY(To, From, Count)             \
-      do                                       \
-       {                                       \
-         YYSIZE_T yyi;                         \
-         for (yyi = 0; yyi < (Count); yyi++)   \
-           (To)[yyi] = (From)[yyi];            \
-       }                                       \
-      while (YYID (0))
-#  endif
-# endif
-
-/* Relocate STACK from its old location to the new one.  The
-   local variables YYSIZE and YYSTACKSIZE give the old and new number of
-   elements in the stack, and YYPTR gives the new location of the
-   stack.  Advance YYPTR to a properly aligned location for the next
-   stack.  */
-# define YYSTACK_RELOCATE(Stack)                                       \
-    do                                                                 \
-      {                                                                        \
-       YYSIZE_T yynewbytes;                                            \
-       YYCOPY (&yyptr->Stack, Stack, yysize);                          \
-       Stack = &yyptr->Stack;                                          \
-       yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
-       yyptr += yynewbytes / sizeof (*yyptr);                          \
-      }                                                                        \
-    while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  8
-/* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   112
-
-/* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  38
-/* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  38
-/* YYNRULES -- Number of rules.  */
-#define YYNRULES  78
-/* YYNRULES -- Number of states.  */
-#define YYNSTATES  119
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
-#define YYUNDEFTOK  2
-#define YYMAXUTOK   292
-
-#define YYTRANSLATE(YYX)                                               \
-  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
-static const yytype_uint8 yytranslate[] =
-{
-       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
-       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
-      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
-      35,    36,    37
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
-   YYRHS.  */
-static const yytype_uint8 yyprhs[] =
-{
-       0,     0,     3,     6,     7,    10,    14,    16,    18,    19,
-      22,    24,    26,    32,    34,    36,    38,    40,    43,    44,
-      50,    52,    54,    56,    58,    60,    62,    64,    66,    68,
-      70,    73,    74,    76,    78,    80,    82,    84,    91,    94,
-      96,    98,   100,   102,   104,   106,   108,   110,   112,   114,
-     117,   118,   121,   124,   127,   130,   132,   135,   138,   141,
-     144,   147,   152,   155,   158,   160,   162,   164,   166,   167,
-     170,   173,   178,   181,   184,   185,   189,   192,   193
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
-static const yytype_int8 yyrhs[] =
-{
-      39,     0,    -1,    40,    75,    -1,    -1,    41,    40,    -1,
-       4,    42,    43,    -1,     5,    -1,     6,    -1,    -1,    45,
-      43,    -1,    29,    -1,    31,    -1,     3,    44,    47,    25,
-       3,    -1,    59,    -1,    45,    -1,    48,    -1,    64,    -1,
-      46,    47,    -1,    -1,     7,    44,    50,    25,     7,    -1,
-      59,    -1,    64,    -1,    63,    -1,    61,    -1,    62,    -1,
-      56,    -1,    57,    -1,    58,    -1,    70,    -1,    52,    -1,
-      49,    50,    -1,    -1,    17,    -1,    18,    -1,    19,    -1,
-      20,    -1,    21,    -1,    13,    44,    51,    55,    25,    13,
-      -1,    35,    30,    -1,    64,    -1,    63,    -1,    61,    -1,
-      62,    -1,    56,    -1,    57,    -1,    58,    -1,    65,    -1,
-      33,    -1,    53,    -1,    54,    55,    -1,    -1,    22,    30,
-      -1,    23,    30,    -1,    24,    30,    -1,     9,    44,    -1,
-      27,    -1,    17,    30,    -1,    11,    60,    -1,    12,    60,
-      -1,    10,    44,    -1,     8,    44,    -1,    14,    69,    25,
-      14,    -1,    15,    44,    -1,    16,    60,    -1,    66,    -1,
-      67,    -1,    24,    -1,    71,    -1,    -1,    68,    69,    -1,
-      28,    44,    -1,    26,    72,    25,    26,    -1,    63,    72,
-      -1,    67,    72,    -1,    -1,    29,    36,    29,    -1,    73,
-      74,    -1,    -1,    37,    74,    -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const yytype_uint8 yyrline[] =
-{
-       0,    71,    71,    73,    73,    75,    76,    76,    78,    78,
-      80,    80,    82,    84,    84,    84,    84,    85,    85,    87,
-      88,    88,    88,    88,    88,    88,    88,    88,    88,    88,
-      89,    89,    91,    91,    91,    91,    91,    93,    95,    97,
-      97,    97,    97,    97,    97,    97,    97,    97,    97,    98,
-      98,   100,   101,   102,   104,   105,   105,   107,   108,   110,
-     111,   113,   114,   115,   117,   117,   117,   117,   118,   118,
-     120,   122,   123,   123,   123,   125,   126,   126,   127
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
-   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
-static const char *const yytname[] =
-{
-  "$end", "error", "$undefined", "CATEGORY", "CLASS", "CLASS_USER",
-  "CLASS_MACHINE", "POLICY", "KEYNAME", "EXPLAIN", "VALUENAME", "VALUEON",
-  "VALUEOFF", "PART", "ITEMLIST", "NAME", "VALUE", "NUMERIC", "EDITTEXT",
-  "TEXT", "DROPDOWNLIST", "CHECKBOX", "MINIMUM", "MAXIMUM", "DEFAULT",
-  "END", "ACTIONLIST", "DEL", "SUPPORTED", "LITERAL", "INTEGER",
-  "LOOKUPLITERAL", "CLIENTEXT", "REQUIRED", "NOSORT", "SPIN", "EQUALS",
-  "STRINGSSECTION", "$accept", "admfile", "classes", "class", "classvalue",
-  "categories", "string", "category", "categoryitem", "categoryitems",
-  "policy", "policyitem", "policyitems", "valuetype", "part", "spin",
-  "partitem", "partitems", "min", "max", "defaultvalue", "explain",
-  "value", "valueon", "valueoff", "valuename", "keyname", "itemlist",
-  "itemname", "itemvalue", "item", "items", "supported", "actionlist",
-  "actions", "variable", "variables", "strings", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
-   token YYLEX-NUM.  */
-static const yytype_uint16 yytoknum[] =
-{
-       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
-     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
-     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
-     285,   286,   287,   288,   289,   290,   291,   292
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
-static const yytype_uint8 yyr1[] =
-{
-       0,    38,    39,    40,    40,    41,    42,    42,    43,    43,
-      44,    44,    45,    46,    46,    46,    46,    47,    47,    48,
-      49,    49,    49,    49,    49,    49,    49,    49,    49,    49,
-      50,    50,    51,    51,    51,    51,    51,    52,    53,    54,
-      54,    54,    54,    54,    54,    54,    54,    54,    54,    55,
-      55,    56,    57,    58,    59,    60,    60,    61,    62,    63,
-      64,    65,    66,    67,    68,    68,    68,    68,    69,    69,
-      70,    71,    72,    72,    72,    73,    74,    74,    75
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
-static const yytype_uint8 yyr2[] =
-{
-       0,     2,     2,     0,     2,     3,     1,     1,     0,     2,
-       1,     1,     5,     1,     1,     1,     1,     2,     0,     5,
-       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       2,     0,     1,     1,     1,     1,     1,     6,     2,     1,
-       1,     1,     1,     1,     1,     1,     1,     1,     1,     2,
-       0,     2,     2,     2,     2,     1,     2,     2,     2,     2,
-       2,     4,     2,     2,     1,     1,     1,     1,     0,     2,
-       2,     4,     2,     2,     0,     3,     2,     0,     2
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
-   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
-   means the default is an error.  */
-static const yytype_uint8 yydefact[] =
-{
-       3,     0,     0,     0,     3,     6,     7,     8,     1,    77,
-       2,     4,     0,     5,     8,     0,    77,    78,    10,    11,
-      18,     9,     0,    76,     0,     0,     0,    14,    18,     0,
-      15,    13,    16,    75,    31,    60,    54,    17,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,    31,     0,    29,
-      25,    26,    27,    20,    23,    24,    22,    21,    28,    12,
-      59,     0,    55,    57,    58,     0,    51,    52,    53,    70,
-      30,     0,    56,    32,    33,    34,    35,    36,    50,    19,
-      68,    47,     0,    48,    50,     0,    43,    44,    45,    41,
-      42,    40,    39,    46,     0,     0,    66,    74,    64,    65,
-      68,     0,    67,    38,    49,     0,    62,    63,    74,    74,
-       0,    69,     0,    37,    72,    73,     0,    61,    71
-};
-
-/* YYDEFGOTO[NTERM-NUM].  */
-static const yytype_int8 yydefgoto[] =
-{
-      -1,     2,     3,     4,     7,    13,    20,    14,    28,    29,
-      30,    47,    48,    78,    49,    83,    84,    85,    50,    51,
-      52,    31,    63,    54,    55,   108,    32,    93,    98,   109,
-     100,   101,    58,   102,   110,    16,    17,    10
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
-   STATE-NUM.  */
-#define YYPACT_NINF -61
-static const yytype_int8 yypact[] =
-{
-      30,    46,    36,    12,    30,   -61,   -61,    70,   -61,    10,
-     -61,   -61,   -22,   -61,    70,    45,    10,   -61,   -61,   -61,
-      55,   -61,    53,   -61,   -22,   -22,   -22,   -61,    55,    58,
-     -61,   -61,   -61,   -61,    19,   -61,   -61,   -61,    81,   -22,
-       6,     6,   -22,    56,    57,    60,   -22,    19,    63,   -61,
-     -61,   -61,   -61,   -61,   -61,   -61,   -61,   -61,   -61,   -61,
-     -61,    61,   -61,   -61,   -61,    59,   -61,   -61,   -61,   -61,
-     -61,    78,   -61,   -61,   -61,   -61,   -61,   -61,     2,   -61,
-      29,   -61,    62,   -61,     2,    64,   -61,   -61,   -61,   -61,
-     -61,   -61,   -61,   -61,   -22,     6,   -61,    -5,   -61,   -61,
-      29,    68,   -61,   -61,   -61,    82,   -61,   -61,    -5,    -5,
-      69,   -61,    83,   -61,   -61,   -61,    72,   -61,   -61
-};
-
-/* YYPGOTO[NTERM-NUM].  */
-static const yytype_int8 yypgoto[] =
-{
-     -61,   -61,    92,   -61,   -61,    85,   -24,    18,   -61,    73,
-     -61,   -61,    65,   -61,   -61,   -61,   -61,    16,   -19,   -18,
-     -17,   -26,   -38,   -10,    -9,   -30,   -28,   -61,   -61,   -60,
-     -61,     3,   -61,   -61,   -37,   -61,    86,   -61
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
-   positive, shift that token.  If negative, reduce the rule which
-   number is the opposite.  If zero, do what YYDEFACT says.
-   If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -1
-static const yytype_uint8 yytable[] =
-{
-      34,    35,    36,    64,    56,    39,    57,    18,    53,    19,
-      25,    95,    39,    40,    41,    60,    80,    56,    65,    57,
-      99,    53,    69,    61,    43,    44,    45,    25,    26,    39,
-      40,    41,    42,    62,     1,    81,     8,    82,    27,    15,
-      99,    43,    44,    45,    94,    95,    27,    46,    91,     9,
-      92,     5,     6,    96,    91,    97,    92,   107,    12,    86,
-      87,    88,    24,    25,    26,    86,    87,    88,    89,    90,
-     106,   114,   115,    12,    89,    90,    73,    74,    75,    76,
-      77,    22,    33,    38,    59,    79,    66,    67,    71,   105,
-      68,    72,   103,   112,   116,   113,    11,   117,   118,    21,
-     104,    37,    23,   111,     0,     0,     0,     0,     0,     0,
-       0,     0,    70
-};
-
-static const yytype_int8 yycheck[] =
-{
-      24,    25,    26,    41,    34,    10,    34,    29,    34,    31,
-       8,    16,    10,    11,    12,    39,    14,    47,    42,    47,
-      80,    47,    46,    17,    22,    23,    24,     8,     9,    10,
-      11,    12,    13,    27,     4,    33,     0,    35,    20,    29,
-     100,    22,    23,    24,    15,    16,    28,    28,    78,    37,
-      78,     5,     6,    24,    84,    26,    84,    95,     3,    78,
-      78,    78,     7,     8,     9,    84,    84,    84,    78,    78,
-      94,   108,   109,     3,    84,    84,    17,    18,    19,    20,
-      21,    36,    29,    25,     3,     7,    30,    30,    25,    25,
-      30,    30,    30,    25,    25,    13,     4,    14,    26,    14,
-      84,    28,    16,   100,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    47
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
-   symbol of state STATE-NUM.  */
-static const yytype_uint8 yystos[] =
-{
-       0,     4,    39,    40,    41,     5,     6,    42,     0,    37,
-      75,    40,     3,    43,    45,    29,    73,    74,    29,    31,
-      44,    43,    36,    74,     7,     8,     9,    45,    46,    47,
-      48,    59,    64,    29,    44,    44,    44,    47,    25,    10,
-      11,    12,    13,    22,    23,    24,    28,    49,    50,    52,
-      56,    57,    58,    59,    61,    62,    63,    64,    70,     3,
-      44,    17,    27,    60,    60,    44,    30,    30,    30,    44,
-      50,    25,    30,    17,    18,    19,    20,    21,    51,     7,
-      14,    33,    35,    53,    54,    55,    56,    57,    58,    61,
-      62,    63,    64,    65,    15,    16,    24,    26,    66,    67,
-      68,    69,    71,    30,    55,    25,    44,    60,    63,    67,
-      72,    69,    25,    13,    72,    72,    25,    14,    26
-};
-
-#define yyerrok                (yyerrstatus = 0)
-#define yyclearin      (yychar = YYEMPTY)
-#define YYEMPTY                (-2)
-#define YYEOF          0
-
-#define YYACCEPT       goto yyacceptlab
-#define YYABORT                goto yyabortlab
-#define YYERROR                goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror.  This remains here temporarily
-   to ease the transition to the new meaning of YYERROR, for GCC.
-   Once GCC version 2 has supplanted version 1, this can go.  */
-
-#define YYFAIL         goto yyerrlab
-
-#define YYRECOVERING()  (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value)                                 \
-do                                                             \
-  if (yychar == YYEMPTY && yylen == 1)                         \
-    {                                                          \
-      yychar = (Token);                                                \
-      yylval = (Value);                                                \
-      yytoken = YYTRANSLATE (yychar);                          \
-      YYPOPSTACK (1);                                          \
-      goto yybackup;                                           \
-    }                                                          \
-  else                                                         \
-    {                                                          \
-      yyerror (YY_("syntax error: cannot back up")); \
-      YYERROR;                                                 \
-    }                                                          \
-while (YYID (0))
-
-
-#define YYTERROR       1
-#define YYERRCODE      256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
-   If N is 0, then set CURRENT to the empty location which ends
-   the previous symbol: RHS[0] (always defined).  */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N)                               \
-    do                                                                 \
-      if (YYID (N))                                                    \
-       {                                                               \
-         (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
-         (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
-         (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
-         (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
-       }                                                               \
-      else                                                             \
-       {                                                               \
-         (Current).first_line   = (Current).last_line   =              \
-           YYRHSLOC (Rhs, 0).last_line;                                \
-         (Current).first_column = (Current).last_column =              \
-           YYRHSLOC (Rhs, 0).last_column;                              \
-       }                                                               \
-    while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
-   This macro was not mandated originally: define only if we know
-   we won't break user code: when these are the locations we know.  */
-
-#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
-#  define YY_LOCATION_PRINT(File, Loc)                 \
-     fprintf (File, "%d.%d-%d.%d",                     \
-             (Loc).first_line, (Loc).first_column,     \
-             (Loc).last_line,  (Loc).last_column)
-# else
-#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments.  */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested.  */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-#  define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args)                       \
-do {                                           \
-  if (yydebug)                                 \
-    YYFPRINTF Args;                            \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                   \
-do {                                                                     \
-  if (yydebug)                                                           \
-    {                                                                    \
-      YYFPRINTF (stderr, "%s ", Title);                                          \
-      yy_symbol_print (stderr,                                           \
-                 Type, Value); \
-      YYFPRINTF (stderr, "\n");                                                  \
-    }                                                                    \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT.  |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
-    FILE *yyoutput;
-    int yytype;
-    YYSTYPE const * const yyvaluep;
-#endif
-{
-  if (!yyvaluep)
-    return;
-# ifdef YYPRINT
-  if (yytype < YYNTOKENS)
-    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
-  YYUSE (yyoutput);
-# endif
-  switch (yytype)
-    {
-      default:
-       break;
-    }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT.  |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
-    FILE *yyoutput;
-    int yytype;
-    YYSTYPE const * const yyvaluep;
-#endif
-{
-  if (yytype < YYNTOKENS)
-    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
-  else
-    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
-  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
-  YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included).                                                   |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
-#else
-static void
-yy_stack_print (bottom, top)
-    yytype_int16 *bottom;
-    yytype_int16 *top;
-#endif
-{
-  YYFPRINTF (stderr, "Stack now");
-  for (; bottom <= top; ++bottom)
-    YYFPRINTF (stderr, " %d", *bottom);
-  YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top)                           \
-do {                                                           \
-  if (yydebug)                                                 \
-    yy_stack_print ((Bottom), (Top));                          \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced.  |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
-    YYSTYPE *yyvsp;
-    int yyrule;
-#endif
-{
-  int yynrhs = yyr2[yyrule];
-  int yyi;
-  unsigned long int yylno = yyrline[yyrule];
-  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
-            yyrule - 1, yylno);
-  /* The symbols being reduced.  */
-  for (yyi = 0; yyi < yynrhs; yyi++)
-    {
-      fprintf (stderr, "   $%d = ", yyi + 1);
-      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
-                      &(yyvsp[(yyi + 1) - (yynrhs)])
-                                      );
-      fprintf (stderr, "\n");
-    }
-}
-
-# define YY_REDUCE_PRINT(Rule)         \
-do {                                   \
-  if (yydebug)                         \
-    yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace.  It is left uninitialized so that
-   multiple parsers can coexist.  */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks.  */
-#ifndef        YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
-   if the built-in stack extension method is used).
-
-   Do not make this value too large; the results are undefined if
-   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
-   evaluated with infinite-precision integer arithmetic.  */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-\f
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-#  if defined __GLIBC__ && defined _STRING_H
-#   define yystrlen strlen
-#  else
-/* Return the length of YYSTR.  */
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
-    const char *yystr;
-#endif
-{
-  YYSIZE_T yylen;
-  for (yylen = 0; yystr[yylen]; yylen++)
-    continue;
-  return yylen;
-}
-#  endif
-# endif
-
-# ifndef yystpcpy
-#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-#   define yystpcpy stpcpy
-#  else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
-   YYDEST.  */
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
-    char *yydest;
-    const char *yysrc;
-#endif
-{
-  char *yyd = yydest;
-  const char *yys = yysrc;
-
-  while ((*yyd++ = *yys++) != '\0')
-    continue;
-
-  return yyd - 1;
-}
-#  endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
-   quotes and backslashes, so that it's suitable for yyerror.  The
-   heuristic is that double-quoting is unnecessary unless the string
-   contains an apostrophe, a comma, or backslash (other than
-   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
-   null, do not copy; instead, return the length of what the result
-   would have been.  */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
-  if (*yystr == '"')
-    {
-      YYSIZE_T yyn = 0;
-      char const *yyp = yystr;
-
-      for (;;)
-       switch (*++yyp)
-         {
-         case '\'':
-         case ',':
-           goto do_not_strip_quotes;
-
-         case '\\':
-           if (*++yyp != '\\')
-             goto do_not_strip_quotes;
-           /* Fall through.  */
-         default:
-           if (yyres)
-             yyres[yyn] = *yyp;
-           yyn++;
-           break;
-
-         case '"':
-           if (yyres)
-             yyres[yyn] = '\0';
-           return yyn;
-         }
-    do_not_strip_quotes: ;
-    }
-
-  if (! yyres)
-    return yystrlen (yystr);
-
-  return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
-   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
-   including the terminating null byte.  If YYRESULT is null, do not
-   copy anything; just return the number of bytes that would be
-   copied.  As a special case, return 0 if an ordinary "syntax error"
-   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
-   size calculation.  */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
-  int yyn = yypact[yystate];
-
-  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
-    return 0;
-  else
-    {
-      int yytype = YYTRANSLATE (yychar);
-      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
-      YYSIZE_T yysize = yysize0;
-      YYSIZE_T yysize1;
-      int yysize_overflow = 0;
-      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
-      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
-      int yyx;
-
-# if 0
-      /* This is so xgettext sees the translatable formats that are
-        constructed on the fly.  */
-      YY_("syntax error, unexpected %s");
-      YY_("syntax error, unexpected %s, expecting %s");
-      YY_("syntax error, unexpected %s, expecting %s or %s");
-      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
-      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
-      char *yyfmt;
-      char const *yyf;
-      static char const yyunexpected[] = "syntax error, unexpected %s";
-      static char const yyexpecting[] = ", expecting %s";
-      static char const yyor[] = " or %s";
-      char yyformat[sizeof yyunexpected
-                   + sizeof yyexpecting - 1
-                   + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
-                      * (sizeof yyor - 1))];
-      char const *yyprefix = yyexpecting;
-
-      /* Start YYX at -YYN if negative to avoid negative indexes in
-        YYCHECK.  */
-      int yyxbegin = yyn < 0 ? -yyn : 0;
-
-      /* Stay within bounds of both yycheck and yytname.  */
-      int yychecklim = YYLAST - yyn + 1;
-      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
-      int yycount = 1;
-
-      yyarg[0] = yytname[yytype];
-      yyfmt = yystpcpy (yyformat, yyunexpected);
-
-      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
-       if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
-         {
-           if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
-             {
-               yycount = 1;
-               yysize = yysize0;
-               yyformat[sizeof yyunexpected - 1] = '\0';
-               break;
-             }
-           yyarg[yycount++] = yytname[yyx];
-           yysize1 = yysize + yytnamerr (0, yytname[yyx]);
-           yysize_overflow |= (yysize1 < yysize);
-           yysize = yysize1;
-           yyfmt = yystpcpy (yyfmt, yyprefix);
-           yyprefix = yyor;
-         }
-
-      yyf = YY_(yyformat);
-      yysize1 = yysize + yystrlen (yyf);
-      yysize_overflow |= (yysize1 < yysize);
-      yysize = yysize1;
-
-      if (yysize_overflow)
-       return YYSIZE_MAXIMUM;
-
-      if (yyresult)
-       {
-         /* Avoid sprintf, as that infringes on the user's name space.
-            Don't have undefined behavior even if the translation
-            produced a string with the wrong number of "%s"s.  */
-         char *yyp = yyresult;
-         int yyi = 0;
-         while ((*yyp = *yyf) != '\0')
-           {
-             if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
-               {
-                 yyp += yytnamerr (yyp, yyarg[yyi++]);
-                 yyf += 2;
-               }
-             else
-               {
-                 yyp++;
-                 yyf++;
-               }
-           }
-       }
-      return yysize;
-    }
-}
-#endif /* YYERROR_VERBOSE */
-\f
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol.  |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
-    const char *yymsg;
-    int yytype;
-    YYSTYPE *yyvaluep;
-#endif
-{
-  YYUSE (yyvaluep);
-
-  if (!yymsg)
-    yymsg = "Deleting";
-  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
-  switch (yytype)
-    {
-
-      default:
-       break;
-    }
-}
-\f
-
-/* Prevent warnings from -Wmissing-prototypes.  */
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The look-ahead symbol.  */
-int yychar;
-
-/* The semantic value of the look-ahead symbol.  */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far.  */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse.  |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
-    void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-  
-  int yystate;
-  int yyn;
-  int yyresult;
-  /* Number of tokens to shift before error messages enabled.  */
-  int yyerrstatus;
-  /* Look-ahead token as an internal (translated) token number.  */
-  int yytoken = 0;
-#if YYERROR_VERBOSE
-  /* Buffer for error messages, and its allocated size.  */
-  char yymsgbuf[128];
-  char *yymsg = yymsgbuf;
-  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-  /* Three stacks and their tools:
-     `yyss': related to states,
-     `yyvs': related to semantic values,
-     `yyls': related to locations.
-
-     Refer to the stacks thru separate pointers, to allow yyoverflow
-     to reallocate them elsewhere.  */
-
-  /* The state stack.  */
-  yytype_int16 yyssa[YYINITDEPTH];
-  yytype_int16 *yyss = yyssa;
-  yytype_int16 *yyssp;
-
-  /* The semantic value stack.  */
-  YYSTYPE yyvsa[YYINITDEPTH];
-  YYSTYPE *yyvs = yyvsa;
-  YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
-
-  YYSIZE_T yystacksize = YYINITDEPTH;
-
-  /* The variables used to return semantic value and location from the
-     action routines.  */
-  YYSTYPE yyval;
-
-
-  /* The number of symbols on the RHS of the reduced rule.
-     Keep to zero when no symbol should be popped.  */
-  int yylen = 0;
-
-  YYDPRINTF ((stderr, "Starting parse\n"));
-
-  yystate = 0;
-  yyerrstatus = 0;
-  yynerrs = 0;
-  yychar = YYEMPTY;            /* Cause a token to be read.  */
-
-  /* Initialize stack pointers.
-     Waste one element of value and location stack
-     so that they stay on the same level as the state stack.
-     The wasted elements are never initialized.  */
-
-  yyssp = yyss;
-  yyvsp = yyvs;
-
-  goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate.  |
-`------------------------------------------------------------*/
- yynewstate:
-  /* In all cases, when you get here, the value and location stacks
-     have just been pushed.  So pushing a state here evens the stacks.  */
-  yyssp++;
-
- yysetstate:
-  *yyssp = yystate;
-
-  if (yyss + yystacksize - 1 <= yyssp)
-    {
-      /* Get the current used size of the three stacks, in elements.  */
-      YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
-      {
-       /* Give user a chance to reallocate the stack.  Use copies of
-          these so that the &'s don't force the real ones into
-          memory.  */
-       YYSTYPE *yyvs1 = yyvs;
-       yytype_int16 *yyss1 = yyss;
-
-
-       /* Each stack pointer address is followed by the size of the
-          data in use in that stack, in bytes.  This used to be a
-          conditional around just the two extra args, but that might
-          be undefined if yyoverflow is a macro.  */
-       yyoverflow (YY_("memory exhausted"),
-                   &yyss1, yysize * sizeof (*yyssp),
-                   &yyvs1, yysize * sizeof (*yyvsp),
-
-                   &yystacksize);
-
-       yyss = yyss1;
-       yyvs = yyvs1;
-      }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
-      goto yyexhaustedlab;
-# else
-      /* Extend the stack our own way.  */
-      if (YYMAXDEPTH <= yystacksize)
-       goto yyexhaustedlab;
-      yystacksize *= 2;
-      if (YYMAXDEPTH < yystacksize)
-       yystacksize = YYMAXDEPTH;
-
-      {
-       yytype_int16 *yyss1 = yyss;
-       union yyalloc *yyptr =
-         (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
-       if (! yyptr)
-         goto yyexhaustedlab;
-       YYSTACK_RELOCATE (yyss);
-       YYSTACK_RELOCATE (yyvs);
-
-#  undef YYSTACK_RELOCATE
-       if (yyss1 != yyssa)
-         YYSTACK_FREE (yyss1);
-      }
-# endif
-#endif /* no yyoverflow */
-
-      yyssp = yyss + yysize - 1;
-      yyvsp = yyvs + yysize - 1;
-
-
-      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
-                 (unsigned long int) yystacksize));
-
-      if (yyss + yystacksize - 1 <= yyssp)
-       YYABORT;
-    }
-
-  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
-  goto yybackup;
-
-/*-----------.
-| yybackup.  |
-`-----------*/
-yybackup:
-
-  /* Do appropriate processing given the current state.  Read a
-     look-ahead token if we need one and don't already have one.  */
-
-  /* First try to decide what to do without reference to look-ahead token.  */
-  yyn = yypact[yystate];
-  if (yyn == YYPACT_NINF)
-    goto yydefault;
-
-  /* Not known => get a look-ahead token if don't already have one.  */
-
-  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
-  if (yychar == YYEMPTY)
-    {
-      YYDPRINTF ((stderr, "Reading a token: "));
-      yychar = YYLEX;
-    }
-
-  if (yychar <= YYEOF)
-    {
-      yychar = yytoken = YYEOF;
-      YYDPRINTF ((stderr, "Now at end of input.\n"));
-    }
-  else
-    {
-      yytoken = YYTRANSLATE (yychar);
-      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
-    }
-
-  /* If the proper action on seeing token YYTOKEN is to reduce or to
-     detect an error, take that action.  */
-  yyn += yytoken;
-  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
-    goto yydefault;
-  yyn = yytable[yyn];
-  if (yyn <= 0)
-    {
-      if (yyn == 0 || yyn == YYTABLE_NINF)
-       goto yyerrlab;
-      yyn = -yyn;
-      goto yyreduce;
-    }
-
-  if (yyn == YYFINAL)
-    YYACCEPT;
-
-  /* Count tokens shifted since error; after three, turn off error
-     status.  */
-  if (yyerrstatus)
-    yyerrstatus--;
-
-  /* Shift the look-ahead token.  */
-  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
-  /* Discard the shifted token unless it is eof.  */
-  if (yychar != YYEOF)
-    yychar = YYEMPTY;
-
-  yystate = yyn;
-  *++yyvsp = yylval;
-
-  goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state.  |
-`-----------------------------------------------------------*/
-yydefault:
-  yyn = yydefact[yystate];
-  if (yyn == 0)
-    goto yyerrlab;
-  goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction.  |
-`-----------------------------*/
-yyreduce:
-  /* yyn is the number of a rule to reduce with.  */
-  yylen = yyr2[yyn];
-
-  /* If YYLEN is nonzero, implement the default value of the action:
-     `$$ = $1'.
-
-     Otherwise, the following line sets YYVAL to garbage.
-     This behavior is undocumented and Bison
-     users should not rely upon it.  Assigning to YYVAL
-     unconditionally makes the parser a bit smaller, and it avoids a
-     GCC warning that YYVAL may be used uninitialized.  */
-  yyval = yyvsp[1-yylen];
-
-
-  YY_REDUCE_PRINT (yyn);
-  switch (yyn)
-    {
-      
-/* Line 1267 of yacc.c.  */
-#line 1502 "lib/policy/parse_adm.y"
-      default: break;
-    }
-  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
-  YYPOPSTACK (yylen);
-  yylen = 0;
-  YY_STACK_PRINT (yyss, yyssp);
-
-  *++yyvsp = yyval;
-
-
-  /* Now `shift' the result of the reduction.  Determine what state
-     that goes to, based on the state we popped back to and the rule
-     number reduced by.  */
-
-  yyn = yyr1[yyn];
-
-  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
-  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
-    yystate = yytable[yystate];
-  else
-    yystate = yydefgoto[yyn - YYNTOKENS];
-
-  goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
-  /* If not already recovering from an error, report this error.  */
-  if (!yyerrstatus)
-    {
-      ++yynerrs;
-#if ! YYERROR_VERBOSE
-      yyerror (YY_("syntax error"));
-#else
-      {
-       YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
-       if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
-         {
-           YYSIZE_T yyalloc = 2 * yysize;
-           if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
-             yyalloc = YYSTACK_ALLOC_MAXIMUM;
-           if (yymsg != yymsgbuf)
-             YYSTACK_FREE (yymsg);
-           yymsg = (char *) YYSTACK_ALLOC (yyalloc);
-           if (yymsg)
-             yymsg_alloc = yyalloc;
-           else
-             {
-               yymsg = yymsgbuf;
-               yymsg_alloc = sizeof yymsgbuf;
-             }
-         }
-
-       if (0 < yysize && yysize <= yymsg_alloc)
-         {
-           (void) yysyntax_error (yymsg, yystate, yychar);
-           yyerror (yymsg);
-         }
-       else
-         {
-           yyerror (YY_("syntax error"));
-           if (yysize != 0)
-             goto yyexhaustedlab;
-         }
-      }
-#endif
-    }
-
-
-
-  if (yyerrstatus == 3)
-    {
-      /* If just tried and failed to reuse look-ahead token after an
-        error, discard it.  */
-
-      if (yychar <= YYEOF)
-       {
-         /* Return failure if at end of input.  */
-         if (yychar == YYEOF)
-           YYABORT;
-       }
-      else
-       {
-         yydestruct ("Error: discarding",
-                     yytoken, &yylval);
-         yychar = YYEMPTY;
-       }
-    }
-
-  /* Else will try to reuse look-ahead token after shifting the error
-     token.  */
-  goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR.  |
-`---------------------------------------------------*/
-yyerrorlab:
-
-  /* Pacify compilers like GCC when the user code never invokes
-     YYERROR and the label yyerrorlab therefore never appears in user
-     code.  */
-  if (/*CONSTCOND*/ 0)
-     goto yyerrorlab;
-
-  /* Do not reclaim the symbols of the rule which action triggered
-     this YYERROR.  */
-  YYPOPSTACK (yylen);
-  yylen = 0;
-  YY_STACK_PRINT (yyss, yyssp);
-  yystate = *yyssp;
-  goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR.  |
-`-------------------------------------------------------------*/
-yyerrlab1:
-  yyerrstatus = 3;     /* Each real token shifted decrements this.  */
-
-  for (;;)
-    {
-      yyn = yypact[yystate];
-      if (yyn != YYPACT_NINF)
-       {
-         yyn += YYTERROR;
-         if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
-           {
-             yyn = yytable[yyn];
-             if (0 < yyn)
-               break;
-           }
-       }
-
-      /* Pop the current state because it cannot handle the error token.  */
-      if (yyssp == yyss)
-       YYABORT;
-
-
-      yydestruct ("Error: popping",
-                 yystos[yystate], yyvsp);
-      YYPOPSTACK (1);
-      yystate = *yyssp;
-      YY_STACK_PRINT (yyss, yyssp);
-    }
-
-  if (yyn == YYFINAL)
-    YYACCEPT;
-
-  *++yyvsp = yylval;
-
-
-  /* Shift the error token.  */
-  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
-  yystate = yyn;
-  goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here.  |
-`-------------------------------------*/
-yyacceptlab:
-  yyresult = 0;
-  goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here.  |
-`-----------------------------------*/
-yyabortlab:
-  yyresult = 1;
-  goto yyreturn;
-
-#ifndef yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here.  |
-`-------------------------------------------------*/
-yyexhaustedlab:
-  yyerror (YY_("memory exhausted"));
-  yyresult = 2;
-  /* Fall through.  */
-#endif
-
-yyreturn:
-  if (yychar != YYEOF && yychar != YYEMPTY)
-     yydestruct ("Cleanup: discarding lookahead",
-                yytoken, &yylval);
-  /* Do not reclaim the symbols of the rule which action triggered
-     this YYABORT or YYACCEPT.  */
-  YYPOPSTACK (yylen);
-  YY_STACK_PRINT (yyss, yyssp);
-  while (yyssp != yyss)
-    {
-      yydestruct ("Cleanup: popping",
-                 yystos[*yyssp], yyvsp);
-      YYPOPSTACK (1);
-    }
-#ifndef yyoverflow
-  if (yyss != yyssa)
-    YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
-  if (yymsg != yymsgbuf)
-    YYSTACK_FREE (yymsg);
-#endif
-  /* Make sure YYID is used.  */
-  return YYID (yyresult);
-}
-
-
-#line 129 "lib/policy/parse_adm.y"
-
-
-void
-yyerror (const char *s)
-{
-     error_message ("%s\n", s);
-}
-
-
-
-
diff --git a/source/lib/policy/parse_adm.h b/source/lib/policy/parse_adm.h
deleted file mode 100644 (file)
index 372e4b9..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3.  */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
-   Free Software Foundation, Inc.
-
-   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 2, 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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
-
-/* As a special exception, you may create a larger work that contains
-   part or all of the Bison parser skeleton and distribute that work
-   under terms of your choice, so long as that work isn't itself a
-   parser generator using the skeleton or a modified version thereof
-   as a parser skeleton.  Alternatively, if you modify or redistribute
-   the parser skeleton itself, you may (at your option) remove this
-   special exception, which will cause the skeleton and the resulting
-   Bison output files to be licensed under the GNU General Public
-   License without this special exception.
-
-   This special exception was added by the Free Software Foundation in
-   version 2.2 of Bison.  */
-
-/* Tokens.  */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
-      know about them.  */
-   enum yytokentype {
-     CATEGORY = 258,
-     CLASS = 259,
-     CLASS_USER = 260,
-     CLASS_MACHINE = 261,
-     POLICY = 262,
-     KEYNAME = 263,
-     EXPLAIN = 264,
-     VALUENAME = 265,
-     VALUEON = 266,
-     VALUEOFF = 267,
-     PART = 268,
-     ITEMLIST = 269,
-     NAME = 270,
-     VALUE = 271,
-     NUMERIC = 272,
-     EDITTEXT = 273,
-     TEXT = 274,
-     DROPDOWNLIST = 275,
-     CHECKBOX = 276,
-     MINIMUM = 277,
-     MAXIMUM = 278,
-     DEFAULT = 279,
-     END = 280,
-     ACTIONLIST = 281,
-     DEL = 282,
-     SUPPORTED = 283,
-     LITERAL = 284,
-     INTEGER = 285,
-     LOOKUPLITERAL = 286,
-     CLIENTEXT = 287,
-     REQUIRED = 288,
-     NOSORT = 289,
-     SPIN = 290,
-     EQUALS = 291,
-     STRINGSSECTION = 292
-   };
-#endif
-/* Tokens.  */
-#define CATEGORY 258
-#define CLASS 259
-#define CLASS_USER 260
-#define CLASS_MACHINE 261
-#define POLICY 262
-#define KEYNAME 263
-#define EXPLAIN 264
-#define VALUENAME 265
-#define VALUEON 266
-#define VALUEOFF 267
-#define PART 268
-#define ITEMLIST 269
-#define NAME 270
-#define VALUE 271
-#define NUMERIC 272
-#define EDITTEXT 273
-#define TEXT 274
-#define DROPDOWNLIST 275
-#define CHECKBOX 276
-#define MINIMUM 277
-#define MAXIMUM 278
-#define DEFAULT 279
-#define END 280
-#define ACTIONLIST 281
-#define DEL 282
-#define SUPPORTED 283
-#define LITERAL 284
-#define INTEGER 285
-#define LOOKUPLITERAL 286
-#define CLIENTEXT 287
-#define REQUIRED 288
-#define NOSORT 289
-#define SPIN 290
-#define EQUALS 291
-#define STRINGSSECTION 292
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 33 "lib/policy/parse_adm.y"
-{
-       char *text;
-       int integer;
-}
-/* Line 1489 of yacc.c.  */
-#line 128 "lib/policy/parse_adm.y"
-       YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE yylval;
-
diff --git a/source/lib/policy/parse_adm.y b/source/lib/policy/parse_adm.y
deleted file mode 100644 (file)
index 23c5e77..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
-   Copyright (C) 2006 Jelmer Vernooij <jelmer@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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-   For more information on the .ADM file format:
-   http://msdn2.microsoft.com/en-us/library/aa372405.aspx 
-*/
-
-%{
-#include "config.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-void yyerror (const char *s);
-extern int yylex (void);
-
-%}
-
-%union {
-       char *text;
-       int integer;
-}
-
-%token CATEGORY
-%token CLASS
-%token CLASS_USER
-%token CLASS_MACHINE
-%token POLICY
-%token KEYNAME
-%token EXPLAIN
-%token VALUENAME
-%token VALUEON VALUEOFF
-%token PART
-%token ITEMLIST
-%token NAME
-%token VALUE
-%token NUMERIC EDITTEXT TEXT DROPDOWNLIST CHECKBOX
-%token MINIMUM MAXIMUM DEFAULT
-%token END
-%token ACTIONLIST
-%token DEL
-%token SUPPORTED
-%token <text> LITERAL
-%token <integer> INTEGER
-%token <text> LOOKUPLITERAL
-%token CLIENTEXT
-%token REQUIRED
-%token NOSORT
-%token SPIN
-%token EQUALS
-%token STRINGSSECTION
-
-%start admfile
-
-%% 
-
-admfile: classes strings;
-
-classes: /* empty */ | class classes;
-
-class: CLASS classvalue categories;
-classvalue: CLASS_USER|CLASS_MACHINE;
-
-categories: /* empty */ | category categories;
-
-string: LITERAL | LOOKUPLITERAL;
-
-category: CATEGORY string categoryitems END CATEGORY;
-
-categoryitem: explain | category | policy | keyname;
-categoryitems: categoryitem categoryitems | /* empty */ ;
-
-policy: POLICY string policyitems END POLICY;
-policyitem: explain | keyname | valuename | valueon | valueoff | min | max | defaultvalue | supported | part;
-policyitems: policyitem policyitems | /* empty */;
-
-valuetype: NUMERIC | EDITTEXT | TEXT | DROPDOWNLIST | CHECKBOX;
-
-part: PART string valuetype partitems END PART;
-
-spin: SPIN INTEGER;
-
-partitem: keyname | valuename | valueon | valueoff | min | max | defaultvalue | itemlist | REQUIRED | spin;
-partitems: partitem partitems | /* empty */;
-
-min: MINIMUM INTEGER;
-max: MAXIMUM INTEGER;
-defaultvalue: DEFAULT INTEGER;
-
-explain: EXPLAIN string;
-value: DEL | NUMERIC INTEGER;
-
-valueon: VALUEON value;
-valueoff: VALUEOFF value;
-
-valuename: VALUENAME string;
-keyname: KEYNAME string;
-
-itemlist: ITEMLIST items END ITEMLIST;
-itemname: NAME string;
-itemvalue: VALUE value;
-
-item: itemname | itemvalue | DEFAULT | actionlist;
-items: /* empty */ | item items;
-
-supported: SUPPORTED string;
-
-actionlist: ACTIONLIST actions END ACTIONLIST;
-actions: valuename actions | itemvalue actions | /* empty */;
-
-variable: LITERAL EQUALS LITERAL;
-variables: variable variables | /* empty */;
-strings: STRINGSSECTION variables;
-
-%%
-
-void
-yyerror (const char *s)
-{
-     error_message ("%s\n", s);
-}
-
-
-
index ce19d8512eb0b4ccfa8f64c80f7147686f8c946a..44adc535245e85a1f5930d1dc35d7495e2acdc86 100644 (file)
@@ -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,23 @@ 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]
+LIBRARY_REALNAME = samba/_registry.$(SHLIBEXT)
 PUBLIC_DEPENDENCIES = registry
-SWIG_FILE = registry.i
 
-swig_registry_OBJ_FILES = lib/registry/registry_wrap.o
+swig_registry_OBJ_FILES = $(libregistrysrcdir)/registry_wrap.o
+
+$(eval $(call python_py_module_template,samba/registry.py,lib/registry/registry.py))
+
+$(swig_registry_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
index 3bb5b566c916e9309b562f682806b374df7949a6..5105040f30618514e395cf4ad26e30d86b08486c 100644 (file)
@@ -28,6 +28,7 @@
 _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
                              struct auth_session_info *session_info,
                              struct cli_credentials *credentials,
+                             struct event_context *ev_ctx,
                              struct loadparm_context *lp_ctx,
                              struct hive_key **root)
 {
@@ -57,7 +58,7 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
        } else if (!strncmp(peek, "TDB file", 8)) {
                close(fd);
                return reg_open_ldb_file(parent_ctx, location, session_info,
-                                        credentials, lp_ctx, root);
+                                        credentials, ev_ctx, lp_ctx, root);
        }
 
        return WERR_BADFILE;
index 0678af52377cb7760588234b1fa5c4ed87c0f11a..c9b3b064470f3d49002a2f99622c6c452d161d37 100644 (file)
@@ -21,7 +21,6 @@
 #include "lib/util/dlinklist.h"
 #include "lib/registry/registry.h"
 #include "system/filesys.h"
-#include "build.h"
 
 
 /**
index a764ca6235322885b4d4049f4a0cfb2d66f41d72..a8a9ed597e47db51bdea97cc208aec5b62255055 100644 (file)
@@ -357,6 +357,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
                         struct auth_session_info *session_info,
                         struct cli_credentials *credentials,
+                        struct event_context *ev_ctx,
                         struct loadparm_context *lp_ctx,
                         struct hive_key **k)
 {
@@ -367,7 +368,7 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
        if (location == NULL)
                return WERR_INVALID_PARAM;
 
-       wrap = ldb_wrap_connect(parent_ctx, lp_ctx,
+       wrap = ldb_wrap_connect(parent_ctx, ev_ctx, lp_ctx,
                                location, session_info, credentials, 0, NULL);
 
        if (wrap == NULL) {
index da381cfbff39dcea613e4f4ace9a0b9f0a8d0c8d..4af95e2dd62d46fc9754bae51011934d675e9c45 100644 (file)
@@ -22,7 +22,6 @@
 #include "lib/util/dlinklist.h"
 #include "lib/registry/registry.h"
 #include "system/filesys.h"
-#include "build.h"
 
 struct reg_key_path {
        uint32_t predefined_key;
@@ -37,9 +36,6 @@ struct registry_local {
                struct hive_key *key;
                struct mountpoint *prev, *next;
        } *mountpoints;
-
-       struct auth_session_info *session_info;
-       struct cli_credentials *credentials;
 };
 
 struct local_key {
@@ -310,9 +306,7 @@ const static struct registry_operations local_ops = {
        .set_sec_desc = local_set_sec_desc,
 };
 
-WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
-                     struct auth_session_info *session_info,
-                     struct cli_credentials *credentials)
+WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx)
 {
        struct registry_local *ret = talloc_zero(mem_ctx,
                                                 struct registry_local);
@@ -320,8 +314,6 @@ WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
        W_ERROR_HAVE_NO_MEMORY(ret);
 
        ret->ops = &local_ops;
-       ret->session_info = session_info;
-       ret->credentials = credentials;
 
        *ctx = (struct registry_context *)ret;
 
index 6a98a6063362fdb9cad801ed0c485f59333e9bfb..e134e3e5321147ba3e3fbf99b43def8eea0226b2 100644 (file)
@@ -149,10 +149,12 @@ struct hive_operations {
 
 struct cli_credentials;
 struct auth_session_info;
+struct event_context;
 
 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
                     struct auth_session_info *session_info,
                     struct cli_credentials *credentials,
+                    struct event_context *ev_ctx,
                     struct loadparm_context *lp_ctx,
                     struct hive_key **root);
 WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
@@ -205,6 +207,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
                         struct auth_session_info *session_info,
                         struct cli_credentials *credentials,
+                        struct event_context *ev_ctx,
                         struct loadparm_context *lp_ctx,
                         struct hive_key **k);
 
@@ -361,12 +364,11 @@ struct loadparm_context;
  * Open the locally defined registry.
  */
 WERROR reg_open_local(TALLOC_CTX *mem_ctx,
-                     struct registry_context **ctx,
-                     struct auth_session_info *session_info,
-                     struct cli_credentials *credentials);
+                     struct registry_context **ctx);
 
 WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
                      struct registry_context **ctx,
+                     struct event_context *ev_ctx,
                      struct loadparm_context *lp_ctx,
                      struct auth_session_info *session_info,
                      struct cli_credentials *credentials);
index 8ab402d57d133d8929cc6cf9d8eee3bf937c0e4c..7dd02b344cd9766c4540fe61fa972c585d3f9ba2 100644 (file)
@@ -26,6 +26,7 @@
 #include "includes.h"
 #include "registry.h"
 #include "param/param.h"
+#include "events/events.h"
 
 typedef struct registry_context reg;
 typedef struct hive_key hive_key;
@@ -41,6 +42,7 @@ typedef struct hive_key hive_key;
 %import "../../auth/credentials/credentials.i"
 %import "../../libcli/util/errors.i"
 %import "../../param/param.i"
+%import "../events/events.i"
 
 /* Utility functions */
 
@@ -57,9 +59,7 @@ const char *str_regtype(int type);
 }
 
 %rename(Registry) reg_open_local;
-WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
-                      struct auth_session_info *session_info,
-                      struct cli_credentials *credentials);
+WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx);
 
 %typemap(in,noblock=1) const char ** {
   /* Check if is a list */
@@ -93,11 +93,20 @@ WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
 typedef struct registry_context {
     %extend {
 
+    %feature("docstring") get_predefined_key_by_name "S.get_predefined_key_by_name(name) -> key\n"
+                                                     "Find a predefined key by name";
     WERROR get_predefined_key_by_name(const char *name, 
                                       struct registry_key **key);
 
+    %feature("docstring") key_del_abs "S.key_del_abs(name) -> None\n"
+                                      "Delete a key by absolute path.";
     WERROR key_del_abs(const char *path);
+    %feature("docstring") get_predefined_key "S.get_predefined_key(hkey_id) -> key\n"
+                                      "Find a predefined key by id";
     WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
+    %feature("docstring") diff_apply "S.diff_apply(filename) -> None\n"
+                                      "Apply the diff from the specified file";
+
     WERROR diff_apply(const char *filename);
     WERROR generate_diff(struct registry_context *ctx2, const struct reg_diff_callbacks *callbacks,
                          void *callback_data);
@@ -106,6 +115,8 @@ typedef struct registry_context {
                       const char **elements=NULL);
 
     struct registry_key *import_hive_key(struct hive_key *hive, uint32_t predef_key, const char **elements);
+    %feature("docstring") mount_hive "S.mount_hive(key, predef_name) -> None\n"
+                                      "Mount the specified key at the specified path.";
     WERROR mount_hive(struct hive_key *key, const char *predef_name)
     {
         int i;
@@ -130,24 +141,30 @@ typedef struct registry_context {
     $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
 }
 
+%feature("docstring") reg_open_hive "S.__init__(location, session_info=None, credentials=None, loadparm_context=None)";
 %rename(hive_key) reg_open_hive;
 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
                      struct auth_session_info *session_info,
                      struct cli_credentials *credentials,
+                     struct event_context *ev_ctx,
                      struct loadparm_context *lp_ctx,
                      struct hive_key **root);
 
+%feature("docstring") reg_open_ldb_file "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key";
 %rename(open_ldb) reg_open_ldb_file;
 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
              struct auth_session_info *session_info,
              struct cli_credentials *credentials,
+             struct event_context *ev_ctx,
              struct loadparm_context *lp_ctx,
              struct hive_key **k);
 
+%feature("docstring") reg_create_directory "create_dir(location) -> key";
 %rename(create_dir) reg_create_directory;
 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
                 const char *location, struct hive_key **key);
 
+%feature("docstring") reg_open_directory "open_dir(location) -> key";
 %rename(open_dir) reg_open_directory;
 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
              const char *location, struct hive_key **key);
@@ -156,17 +173,27 @@ WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
 
 typedef struct hive_key {
     %extend {
+        %feature("docstring") del "S.del(name) -> None\n"
+                                  "Delete a subkey";
         WERROR del(const char *name);
+        %feature("docstring") flush "S.flush() -> None\n"
+                                  "Flush this key to disk";
         WERROR flush(void);
+        %feature("docstring") del_value "S.del_value(name) -> None\n"
+                                  "Delete a value";
         WERROR del_value(const char *name);
+        %feature("docstring") set_value "S.set_value(name, type, data) -> None\n"
+                                  "Set a value";
         WERROR set_value(const char *name, uint32_t type, const DATA_BLOB data);
     }
 } hive_key;
 
 %rename(open_samba) reg_open_samba;
 
+%feature("docstring") reg_open_samba "open_samba() -> reg";
 WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
                       struct registry_context **ctx,
+                      struct event_context *ev_ctx,
                       struct loadparm_context *lp_ctx,
                       struct auth_session_info *session_info,
                       struct cli_credentials *credentials);
index bf8ac604981537d0958b5aed2b430942c4a7bd20..4c6e735414bbb1cb3dd69cfdd6a1a72e679dbf9f 100644 (file)
@@ -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.
 
@@ -59,12 +59,48 @@ def _swig_setattr_nondynamic_method(set):
 
 import credentials
 import param
+import events
 reg_get_predef_name = _registry.reg_get_predef_name
 str_regtype = _registry.str_regtype
 Registry = _registry.Registry
 class reg(object):
     thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
     __repr__ = _swig_repr
+    def get_predefined_key_by_name(*args, **kwargs):
+        """
+        S.get_predefined_key_by_name(name) -> key
+        Find a predefined key by name
+        """
+        return _registry.reg_get_predefined_key_by_name(*args, **kwargs)
+
+    def key_del_abs(*args, **kwargs):
+        """
+        S.key_del_abs(name) -> None
+        Delete a key by absolute path.
+        """
+        return _registry.reg_key_del_abs(*args, **kwargs)
+
+    def get_predefined_key(*args, **kwargs):
+        """
+        S.get_predefined_key(hkey_id) -> key
+        Find a predefined key by id
+        """
+        return _registry.reg_get_predefined_key(*args, **kwargs)
+
+    def diff_apply(*args, **kwargs):
+        """
+        S.diff_apply(filename) -> None
+        Apply the diff from the specified file
+        """
+        return _registry.reg_diff_apply(*args, **kwargs)
+
+    def mount_hive(*args):
+        """
+        S.mount_hive(key, predef_name) -> None
+        Mount the specified key at the specified path.
+        """
+        return _registry.reg_mount_hive(*args)
+
     def __init__(self, *args, **kwargs): 
         _registry.reg_swiginit(self,_registry.new_reg(*args, **kwargs))
     __swig_destroy__ = _registry.delete_reg
@@ -78,11 +114,26 @@ reg.mount_hive = new_instancemethod(_registry.reg_mount_hive,None,reg)
 reg_swigregister = _registry.reg_swigregister
 reg_swigregister(reg)
 
-hive_key = _registry.hive_key
-open_ldb = _registry.open_ldb
-create_dir = _registry.create_dir
-open_dir = _registry.open_dir
-open_samba = _registry.open_samba
+
+def hive_key(*args, **kwargs):
+  """S.__init__(location, session_info=None, credentials=None, loadparm_context=None)"""
+  return _registry.hive_key(*args, **kwargs)
+
+def open_ldb(*args, **kwargs):
+  """open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key"""
+  return _registry.open_ldb(*args, **kwargs)
+
+def create_dir(*args, **kwargs):
+  """create_dir(location) -> key"""
+  return _registry.create_dir(*args, **kwargs)
+
+def open_dir(*args, **kwargs):
+  """open_dir(location) -> key"""
+  return _registry.open_dir(*args, **kwargs)
+
+def open_samba(*args, **kwargs):
+  """open_samba() -> reg"""
+  return _registry.open_samba(*args, **kwargs)
 HKEY_CLASSES_ROOT = _registry.HKEY_CLASSES_ROOT
 HKEY_CURRENT_USER = _registry.HKEY_CURRENT_USER
 HKEY_LOCAL_MACHINE = _registry.HKEY_LOCAL_MACHINE
index da09ecbe08dc68abda707c2930600646aaa13699..b066e42b41daacfe7e3cd7393222b8bac3a767a0 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2460,29 +2478,30 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
 #define SWIGTYPE_p_auth_session_info swig_types[1]
 #define SWIGTYPE_p_char swig_types[2]
 #define SWIGTYPE_p_cli_credentials swig_types[3]
-#define SWIGTYPE_p_hive_key swig_types[4]
-#define SWIGTYPE_p_int swig_types[5]
-#define SWIGTYPE_p_loadparm_context swig_types[6]
-#define SWIGTYPE_p_loadparm_service swig_types[7]
-#define SWIGTYPE_p_long_long swig_types[8]
-#define SWIGTYPE_p_p_char swig_types[9]
-#define SWIGTYPE_p_p_hive_key swig_types[10]
-#define SWIGTYPE_p_p_registry_context swig_types[11]
-#define SWIGTYPE_p_p_registry_key swig_types[12]
-#define SWIGTYPE_p_param_context swig_types[13]
-#define SWIGTYPE_p_param_opt swig_types[14]
-#define SWIGTYPE_p_param_section swig_types[15]
-#define SWIGTYPE_p_reg_diff_callbacks swig_types[16]
-#define SWIGTYPE_p_registry_context swig_types[17]
-#define SWIGTYPE_p_registry_key swig_types[18]
-#define SWIGTYPE_p_short swig_types[19]
-#define SWIGTYPE_p_signed_char swig_types[20]
-#define SWIGTYPE_p_unsigned_char swig_types[21]
-#define SWIGTYPE_p_unsigned_int swig_types[22]
-#define SWIGTYPE_p_unsigned_long_long swig_types[23]
-#define SWIGTYPE_p_unsigned_short swig_types[24]
-static swig_type_info *swig_types[26];
-static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0};
+#define SWIGTYPE_p_event_context swig_types[4]
+#define SWIGTYPE_p_hive_key swig_types[5]
+#define SWIGTYPE_p_int swig_types[6]
+#define SWIGTYPE_p_loadparm_context swig_types[7]
+#define SWIGTYPE_p_loadparm_service swig_types[8]
+#define SWIGTYPE_p_long_long swig_types[9]
+#define SWIGTYPE_p_p_char swig_types[10]
+#define SWIGTYPE_p_p_hive_key swig_types[11]
+#define SWIGTYPE_p_p_registry_context swig_types[12]
+#define SWIGTYPE_p_p_registry_key swig_types[13]
+#define SWIGTYPE_p_param_context swig_types[14]
+#define SWIGTYPE_p_param_opt swig_types[15]
+#define SWIGTYPE_p_param_section swig_types[16]
+#define SWIGTYPE_p_reg_diff_callbacks swig_types[17]
+#define SWIGTYPE_p_registry_context swig_types[18]
+#define SWIGTYPE_p_registry_key swig_types[19]
+#define SWIGTYPE_p_short swig_types[20]
+#define SWIGTYPE_p_signed_char swig_types[21]
+#define SWIGTYPE_p_unsigned_char swig_types[22]
+#define SWIGTYPE_p_unsigned_int swig_types[23]
+#define SWIGTYPE_p_unsigned_long_long swig_types[24]
+#define SWIGTYPE_p_unsigned_short swig_types[25]
+static swig_type_info *swig_types[27];
+static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -2514,7 +2533,7 @@ static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0};
 
 #define SWIG_name    "_registry"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2529,6 +2548,7 @@ static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0};
 #include "includes.h"
 #include "registry.h"
 #include "param/param.h"
+#include "events/events.h"
 
 typedef struct registry_context reg;
 typedef struct hive_key hive_key;
@@ -2910,44 +2930,17 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
   struct registry_context **arg2 = (struct registry_context **) 0 ;
-  struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
-  struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
   WERROR result;
   struct registry_context *tmp2 ;
-  void *argp3 = 0 ;
-  int res3 = 0 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  char *  kwnames[] = {
-    (char *) "session_info",(char *) "credentials", NULL 
-  };
   
-  arg3 = NULL;
-  arg4 = NULL;
   arg1 = NULL;
   arg2 = &tmp2;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Registry",kwnames,&obj0,&obj1)) SWIG_fail;
-  if (obj0) {
-    res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_auth_session_info, 0 |  0 );
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Registry" "', argument " "3"" of type '" "struct auth_session_info *""'"); 
-    }
-    arg3 = (struct auth_session_info *)(argp3);
-  }
-  if (obj1) {
-    res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_cli_credentials, 0 |  0 );
-    if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Registry" "', argument " "4"" of type '" "struct cli_credentials *""'"); 
-    }
-    arg4 = (struct cli_credentials *)(argp4);
-  }
-  result = reg_open_local(arg1,arg2,arg3,arg4);
+  if (!SWIG_Python_UnpackTuple(args,"Registry",0,0,0)) SWIG_fail;
+  result = reg_open_local(arg1,arg2);
   if (!W_ERROR_IS_OK(result)) {
     PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
     PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3410,7 +3403,10 @@ check_1:
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'reg_mount_hive'.\n  Possible C/C++ prototypes are:\n""    mount_hive(reg *,struct hive_key *,uint32_t,char const **)\n""    mount_hive(reg *,struct hive_key *,char const *)\n");
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'reg_mount_hive'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    mount_hive(reg *,struct hive_key *,uint32_t,char const **)\n"
+    "    mount_hive(reg *,struct hive_key *,char const *)\n");
   return NULL;
 }
 
@@ -3420,7 +3416,7 @@ SWIGINTERN PyObject *_wrap_new_reg(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
   reg *result = 0 ;
   
   if (!SWIG_Python_UnpackTuple(args,"new_reg",0,0,0)) SWIG_fail;
-  result = (reg *)(reg *) calloc(1, sizeof(reg));
+  result = (reg *)calloc(1, sizeof(reg));
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_registry_context, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -3468,8 +3464,9 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
   char *arg2 = (char *) 0 ;
   struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
   struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
-  struct loadparm_context *arg5 = (struct loadparm_context *) 0 ;
-  struct hive_key **arg6 = (struct hive_key **) 0 ;
+  struct event_context *arg5 = (struct event_context *) 0 ;
+  struct loadparm_context *arg6 = (struct loadparm_context *) 0 ;
+  struct hive_key **arg7 = (struct hive_key **) 0 ;
   WERROR result;
   int res2 ;
   char *buf2 = 0 ;
@@ -3480,21 +3477,25 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
   int res4 = 0 ;
   void *argp5 = 0 ;
   int res5 = 0 ;
-  struct hive_key *tmp6 ;
+  void *argp6 = 0 ;
+  int res6 = 0 ;
+  struct hive_key *tmp7 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   PyObject * obj3 = 0 ;
+  PyObject * obj4 = 0 ;
   char *  kwnames[] = {
-    (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL 
+    (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "ev_ctx",(char *) "lp_ctx", NULL 
   };
   
   arg3 = NULL;
   arg4 = NULL;
-  arg5 = loadparm_init(NULL);
+  arg5 = event_context_init(NULL);
+  arg6 = loadparm_init(NULL);
   arg1 = NULL;
-  arg6 = &tmp6;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:hive_key",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  arg7 = &tmp7;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:hive_key",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
   res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "hive_key" "', argument " "2"" of type '" "char const *""'");
@@ -3515,13 +3516,20 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
     arg4 = (struct cli_credentials *)(argp4);
   }
   if (obj3) {
-    res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_loadparm_context, 0 |  0 );
+    res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_event_context, 0 |  0 );
     if (!SWIG_IsOK(res5)) {
-      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "hive_key" "', argument " "5"" of type '" "struct loadparm_context *""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "hive_key" "', argument " "5"" of type '" "struct event_context *""'"); 
+    }
+    arg5 = (struct event_context *)(argp5);
+  }
+  if (obj4) {
+    res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_loadparm_context, 0 |  0 );
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "hive_key" "', argument " "6"" of type '" "struct loadparm_context *""'"); 
     }
-    arg5 = (struct loadparm_context *)(argp5);
+    arg6 = (struct loadparm_context *)(argp6);
   }
-  result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
+  result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);
   if (!W_ERROR_IS_OK(result)) {
     PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
     PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3530,7 +3538,7 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
     resultobj = Py_None;
   }
   Py_XDECREF(resultobj);
-  resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
+  resultobj = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_hive_key, 0);
   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
   return resultobj;
 fail:
@@ -3545,8 +3553,9 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
   char *arg2 = (char *) 0 ;
   struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
   struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
-  struct loadparm_context *arg5 = (struct loadparm_context *) 0 ;
-  struct hive_key **arg6 = (struct hive_key **) 0 ;
+  struct event_context *arg5 = (struct event_context *) 0 ;
+  struct loadparm_context *arg6 = (struct loadparm_context *) 0 ;
+  struct hive_key **arg7 = (struct hive_key **) 0 ;
   WERROR result;
   int res2 ;
   char *buf2 = 0 ;
@@ -3557,21 +3566,25 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
   int res4 = 0 ;
   void *argp5 = 0 ;
   int res5 = 0 ;
-  struct hive_key *tmp6 ;
+  void *argp6 = 0 ;
+  int res6 = 0 ;
+  struct hive_key *tmp7 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   PyObject * obj3 = 0 ;
+  PyObject * obj4 = 0 ;
   char *  kwnames[] = {
-    (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL 
+    (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "ev_ctx",(char *) "lp_ctx", NULL 
   };
   
   arg3 = NULL;
   arg4 = NULL;
-  arg5 = loadparm_init(NULL);
+  arg5 = event_context_init(NULL);
+  arg6 = loadparm_init(NULL);
   arg1 = NULL;
-  arg6 = &tmp6;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:open_ldb",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  arg7 = &tmp7;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:open_ldb",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
   res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "open_ldb" "', argument " "2"" of type '" "char const *""'");
@@ -3592,13 +3605,20 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
     arg4 = (struct cli_credentials *)(argp4);
   }
   if (obj3) {
-    res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_loadparm_context, 0 |  0 );
+    res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_event_context, 0 |  0 );
     if (!SWIG_IsOK(res5)) {
-      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_ldb" "', argument " "5"" of type '" "struct loadparm_context *""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_ldb" "', argument " "5"" of type '" "struct event_context *""'"); 
+    }
+    arg5 = (struct event_context *)(argp5);
+  }
+  if (obj4) {
+    res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_loadparm_context, 0 |  0 );
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "open_ldb" "', argument " "6"" of type '" "struct loadparm_context *""'"); 
     }
-    arg5 = (struct loadparm_context *)(argp5);
+    arg6 = (struct loadparm_context *)(argp6);
   }
-  result = reg_open_ldb_file(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
+  result = reg_open_ldb_file(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);
   if (!W_ERROR_IS_OK(result)) {
     PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
     PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3607,7 +3627,7 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
     resultobj = Py_None;
   }
   Py_XDECREF(resultobj);
-  resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
+  resultobj = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_hive_key, 0);
   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
   return resultobj;
 fail:
@@ -3702,9 +3722,10 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
   PyObject *resultobj = 0;
   TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
   struct registry_context **arg2 = (struct registry_context **) 0 ;
-  struct loadparm_context *arg3 = (struct loadparm_context *) 0 ;
-  struct auth_session_info *arg4 = (struct auth_session_info *) 0 ;
-  struct cli_credentials *arg5 = (struct cli_credentials *) 0 ;
+  struct event_context *arg3 = (struct event_context *) 0 ;
+  struct loadparm_context *arg4 = (struct loadparm_context *) 0 ;
+  struct auth_session_info *arg5 = (struct auth_session_info *) 0 ;
+  struct cli_credentials *arg6 = (struct cli_credentials *) 0 ;
   WERROR result;
   struct registry_context *tmp2 ;
   void *argp3 = 0 ;
@@ -3713,41 +3734,52 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
   int res4 = 0 ;
   void *argp5 = 0 ;
   int res5 = 0 ;
+  void *argp6 = 0 ;
+  int res6 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
   char *  kwnames[] = {
-    (char *) "lp_ctx",(char *) "session_info",(char *) "credentials", NULL 
+    (char *) "ev_ctx",(char *) "lp_ctx",(char *) "session_info",(char *) "credentials", NULL 
   };
   
-  arg3 = loadparm_init(NULL);
-  arg4 = NULL;
+  arg3 = event_context_init(NULL);
+  arg4 = loadparm_init(NULL);
   arg5 = NULL;
+  arg6 = NULL;
   arg1 = NULL;
   arg2 = &tmp2;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:open_samba",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOOO:open_samba",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
   if (obj0) {
-    res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_loadparm_context, 0 |  0 );
+    res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_event_context, 0 |  0 );
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "open_samba" "', argument " "3"" of type '" "struct loadparm_context *""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "open_samba" "', argument " "3"" of type '" "struct event_context *""'"); 
     }
-    arg3 = (struct loadparm_context *)(argp3);
+    arg3 = (struct event_context *)(argp3);
   }
   if (obj1) {
-    res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_auth_session_info, 0 |  0 );
+    res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_loadparm_context, 0 |  0 );
     if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "open_samba" "', argument " "4"" of type '" "struct auth_session_info *""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "open_samba" "', argument " "4"" of type '" "struct loadparm_context *""'"); 
     }
-    arg4 = (struct auth_session_info *)(argp4);
+    arg4 = (struct loadparm_context *)(argp4);
   }
   if (obj2) {
-    res5 = SWIG_ConvertPtr(obj2, &argp5,SWIGTYPE_p_cli_credentials, 0 |  0 );
+    res5 = SWIG_ConvertPtr(obj2, &argp5,SWIGTYPE_p_auth_session_info, 0 |  0 );
     if (!SWIG_IsOK(res5)) {
-      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_samba" "', argument " "5"" of type '" "struct cli_credentials *""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_samba" "', argument " "5"" of type '" "struct auth_session_info *""'"); 
     }
-    arg5 = (struct cli_credentials *)(argp5);
+    arg5 = (struct auth_session_info *)(argp5);
   }
-  result = reg_open_samba(arg1,arg2,arg3,arg4,arg5);
+  if (obj3) {
+    res6 = SWIG_ConvertPtr(obj3, &argp6,SWIGTYPE_p_cli_credentials, 0 |  0 );
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "open_samba" "', argument " "6"" of type '" "struct cli_credentials *""'"); 
+    }
+    arg6 = (struct cli_credentials *)(argp6);
+  }
+  result = reg_open_samba(arg1,arg2,arg3,arg4,arg5,arg6);
   if (!W_ERROR_IS_OK(result)) {
     PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
     PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3765,11 +3797,23 @@ fail:
 static PyMethodDef SwigMethods[] = {
         { (char *)"reg_get_predef_name", (PyCFunction) _wrap_reg_get_predef_name, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"str_regtype", (PyCFunction) _wrap_str_regtype, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Registry", (PyCFunction) _wrap_Registry, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"reg_key_del_abs", (PyCFunction) _wrap_reg_key_del_abs, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"reg_diff_apply", (PyCFunction) _wrap_reg_diff_apply, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Registry", (PyCFunction)_wrap_Registry, METH_NOARGS, NULL},
+        { (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_predefined_key_by_name(name) -> key\n"
+               "Find a predefined key by name\n"
+               ""},
+        { (char *)"reg_key_del_abs", (PyCFunction) _wrap_reg_key_del_abs, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.key_del_abs(name) -> None\n"
+               "Delete a key by absolute path.\n"
+               ""},
+        { (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.get_predefined_key(hkey_id) -> key\n"
+               "Find a predefined key by id\n"
+               ""},
+        { (char *)"reg_diff_apply", (PyCFunction) _wrap_reg_diff_apply, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.diff_apply(filename) -> None\n"
+               "Apply the diff from the specified file\n"
+               ""},
         { (char *)"reg_generate_diff", (PyCFunction) _wrap_reg_generate_diff, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"reg_import_hive_key", (PyCFunction) _wrap_reg_import_hive_key, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"reg_mount_hive", _wrap_reg_mount_hive, METH_VARARGS, NULL},
@@ -3777,11 +3821,11 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"delete_reg", (PyCFunction)_wrap_delete_reg, METH_O, NULL},
         { (char *)"reg_swigregister", reg_swigregister, METH_VARARGS, NULL},
         { (char *)"reg_swiginit", reg_swiginit, METH_VARARGS, NULL},
-        { (char *)"hive_key", (PyCFunction) _wrap_hive_key, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"open_ldb", (PyCFunction) _wrap_open_ldb, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"create_dir", (PyCFunction) _wrap_create_dir, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"open_dir", (PyCFunction) _wrap_open_dir, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"hive_key", (PyCFunction) _wrap_hive_key, METH_VARARGS | METH_KEYWORDS, (char *)"S.__init__(location, session_info=None, credentials=None, loadparm_context=None)"},
+        { (char *)"open_ldb", (PyCFunction) _wrap_open_ldb, METH_VARARGS | METH_KEYWORDS, (char *)"open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key"},
+        { (char *)"create_dir", (PyCFunction) _wrap_create_dir, METH_VARARGS | METH_KEYWORDS, (char *)"create_dir(location) -> key"},
+        { (char *)"open_dir", (PyCFunction) _wrap_open_dir, METH_VARARGS | METH_KEYWORDS, (char *)"open_dir(location) -> key"},
+        { (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, (char *)"open_samba() -> reg"},
         { NULL, NULL, 0, NULL }
 };
 
@@ -3792,6 +3836,7 @@ static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0
 static swig_type_info _swigt__p_auth_session_info = {"_p_auth_session_info", "struct auth_session_info *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_event_context = {"_p_event_context", "struct event_context *|event *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_hive_key = {"_p_hive_key", "struct hive_key *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
@@ -3819,6 +3864,7 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_auth_session_info,
   &_swigt__p_char,
   &_swigt__p_cli_credentials,
+  &_swigt__p_event_context,
   &_swigt__p_hive_key,
   &_swigt__p_int,
   &_swigt__p_loadparm_context,
@@ -3846,6 +3892,7 @@ static swig_cast_info _swigc__p_TALLOC_CTX[] = {  {&_swigt__p_TALLOC_CTX, 0, 0,
 static swig_cast_info _swigc__p_auth_session_info[] = {  {&_swigt__p_auth_session_info, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_cli_credentials[] = {  {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_event_context[] = {  {&_swigt__p_event_context, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_hive_key[] = {  {&_swigt__p_hive_key, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_loadparm_context[] = {  {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
@@ -3873,6 +3920,7 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_auth_session_info,
   _swigc__p_char,
   _swigc__p_cli_credentials,
+  _swigc__p_event_context,
   _swigc__p_hive_key,
   _swigc__p_int,
   _swigc__p_loadparm_context,
@@ -3962,7 +4010,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -3972,6 +4020,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 */
@@ -4000,6 +4051,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);
index 599385e73c210819a59d539aae946966fe4421ed..84a8112f17952c45233203fd061e35c3bb2a0a9c 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 static WERROR mount_samba_hive(struct registry_context *ctx,
+                              struct event_context *event_ctx,
                               struct loadparm_context *lp_ctx,
                               struct auth_session_info *auth_info,
                               struct cli_credentials *creds,
@@ -40,11 +41,11 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
                                   lp_private_dir(lp_ctx),
                                   name);
 
-       error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive);
+       error = reg_open_hive(ctx, location, auth_info, creds, event_ctx, lp_ctx, &hive);
 
        if (W_ERROR_EQUAL(error, WERR_BADFILE))
                error = reg_open_ldb_file(ctx, location, auth_info,
-                                         creds, lp_ctx, &hive);
+                                         creds, event_ctx, lp_ctx, &hive);
 
        if (!W_ERROR_IS_OK(error))
                return error;
@@ -55,29 +56,30 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
 
 _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
                               struct registry_context **ctx,
+                              struct event_context *ev_ctx,
                               struct loadparm_context *lp_ctx,
                               struct auth_session_info *session_info,
                               struct cli_credentials *credentials)
 {
        WERROR result;
 
-       result = reg_open_local(mem_ctx, ctx, session_info, credentials);
+       result = reg_open_local(mem_ctx, ctx);
        if (!W_ERROR_IS_OK(result)) {
                return result;
        }
 
-       mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+       mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
                         "hklm", HKEY_LOCAL_MACHINE);
 
-       mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+       mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
                         "hkcr", HKEY_CLASSES_ROOT);
 
        /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
         * current user */
-       mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+       mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
                         "hkcu", HKEY_CURRENT_USER);
 
-       mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+       mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
                         "hku", HKEY_USERS);
 
        /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
index 314cf778a1609a13f78a8b3b08ef6db5a9a27802..1fb5c70b70d5362747f4e0a0b6d16db1c85557e9 100644 (file)
@@ -19,7 +19,7 @@
 
 import os
 import unittest
-import registry
+from samba import registry
 import samba.tests
 
 class HelperTests(unittest.TestCase):
index 474704b5170bb3093c270225b51182334a2c7d86..edc97c2468ebe8ca774b2f6cd7c336af4406a64a 100644 (file)
@@ -69,14 +69,15 @@ static bool test_keyinfo_nums(struct torture_context *tctx, void *test_data)
        struct hive_key *root = (struct hive_key *)test_data;
        WERROR error;
        struct hive_key *subkey;
-       uint32_t data = 42;
+       char data[4];
+       SIVAL(data, 0, 42);
 
        error = hive_key_add_name(tctx, root, "Nested Keyll", NULL,
                                  NULL, &subkey);
        torture_assert_werr_ok(tctx, error, "hive_key_add_name");
 
        error = hive_key_set_value(root, "Answer", REG_DWORD,
-                              data_blob_talloc(tctx, &data, sizeof(data)));
+                              data_blob_talloc(tctx, data, sizeof(data)));
        torture_assert_werr_ok(tctx, error, "hive_key_set_value");
 
        /* This is a new backend. There should be no subkeys and no
@@ -120,7 +121,8 @@ static bool test_del_recursive(struct torture_context *tctx,
        struct hive_key *subkey2;
        const struct hive_key *root = (const struct hive_key *)test_data;
        TALLOC_CTX *mem_ctx = tctx;
-       uint32_t data = 42;
+       char data[4];
+       SIVAL(data, 0, 42);
 
        /* Create a new key under the root */
        error = hive_key_add_name(mem_ctx, root, "Parent Key", NULL,
@@ -134,7 +136,7 @@ static bool test_del_recursive(struct torture_context *tctx,
 
        /* Create a new value under "Child Key" */
        error = hive_key_set_value(subkey2, "Answer Recursive", REG_DWORD,
-                              data_blob_talloc(mem_ctx, &data, sizeof(data)));
+                              data_blob_talloc(mem_ctx, data, sizeof(data)));
        torture_assert_werr_ok(tctx, error, "hive_key_set_value");
 
        /* Deleting "Parent Key" will also delete "Child Key" and the value. */
@@ -180,14 +182,15 @@ static bool test_set_value(struct torture_context *tctx,
        struct hive_key *subkey;
        const struct hive_key *root = (const struct hive_key *)test_data;
        TALLOC_CTX *mem_ctx = tctx;
-       uint32_t data = 42;
+       char data[4];
+       SIVAL(data, 0, 42);
 
        error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL,
                                  NULL, &subkey);
        torture_assert_werr_ok(tctx, error, "hive_key_add_name");
 
        error = hive_key_set_value(subkey, "Answer", REG_DWORD,
-                              data_blob_talloc(mem_ctx, &data, sizeof(data)));
+                              data_blob_talloc(mem_ctx, data, sizeof(data)));
        torture_assert_werr_ok(tctx, error, "hive_key_set_value");
 
        return true;
@@ -199,10 +202,12 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
        struct hive_key *subkey;
        const struct hive_key *root = (const struct hive_key *)test_data;
        TALLOC_CTX *mem_ctx = tctx;
-       uint32_t data = 42;
+       char data[4];
        uint32_t type;
        DATA_BLOB value;
 
+       SIVAL(data, 0, 42);
+
        error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL,
                                  NULL, &subkey);
        torture_assert_werr_ok(tctx, error, "hive_key_add_name");
@@ -212,7 +217,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
                                  "getting missing value");
 
        error = hive_key_set_value(subkey, "Answer", REG_DWORD,
-                              data_blob_talloc(mem_ctx, &data, sizeof(data)));
+                              data_blob_talloc(mem_ctx, data, sizeof(data)));
        torture_assert_werr_ok(tctx, error, "hive_key_set_value");
 
        error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value);
@@ -233,16 +238,18 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data)
        struct hive_key *subkey;
        const struct hive_key *root = (const struct hive_key *)test_data;
        TALLOC_CTX *mem_ctx = tctx;
-       uint32_t data = 42;
+       char data[4];
        uint32_t type;
        DATA_BLOB value;
 
+       SIVAL(data, 0, 42);
+
        error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL,
                                                         NULL, &subkey);
        torture_assert_werr_ok(tctx, error, "hive_key_add_name");
 
        error = hive_key_set_value(subkey, "Answer", REG_DWORD,
-                              data_blob_talloc(mem_ctx, &data, sizeof(data)));
+                              data_blob_talloc(mem_ctx, data, sizeof(data)));
        torture_assert_werr_ok(tctx, error, "hive_key_set_value");
 
        error = hive_key_del_value(subkey, "Answer");
@@ -265,17 +272,19 @@ static bool test_list_values(struct torture_context *tctx,
        struct hive_key *subkey;
        const struct hive_key *root = (const struct hive_key *)test_data;
        TALLOC_CTX *mem_ctx = tctx;
-       uint32_t data = 42;
+       char data[4];
        uint32_t type;
        DATA_BLOB value;
        const char *name;
+       int data_val = 42;
+       SIVAL(data, 0, data_val);
 
        error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL,
                                  NULL, &subkey);
        torture_assert_werr_ok(tctx, error, "hive_key_add_name");
 
        error = hive_key_set_value(subkey, "Answer", REG_DWORD,
-                              data_blob_talloc(mem_ctx, &data, sizeof(data)));
+                              data_blob_talloc(mem_ctx, data, sizeof(data)));
        torture_assert_werr_ok(tctx, error, "hive_key_set_value");
 
        error = hive_get_value_by_index(mem_ctx, subkey, 0, &name,
@@ -288,7 +297,7 @@ static bool test_list_values(struct torture_context *tctx,
        torture_assert_int_equal(tctx, type, REG_DWORD, "value type");
        
        
-       torture_assert_int_equal(tctx, data, IVAL(value.data, 0), "value data");
+       torture_assert_int_equal(tctx, data_val, IVAL(value.data, 0), "value data");
 
        error = hive_get_value_by_index(mem_ctx, subkey, 1, &name,
                                        &type, &value);
@@ -416,7 +425,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data)
 
        rmdir(dirname);
 
-       error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->lp_ctx, &key);
+       error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->ev, tctx->lp_ctx, &key);
        if (!W_ERROR_IS_OK(error)) {
                fprintf(stderr, "Unable to initialize ldb hive\n");
                return false;
index 97c1190a684bbf08857e26d16cbfc6a52d89d184..7274bf009d1e09f641f38e31051d57564bda0afd 100644 (file)
@@ -281,7 +281,8 @@ static bool test_query_key_nums(struct torture_context *tctx, void *_data)
        struct registry_key *root, *subkey1, *subkey2;
        WERROR error;
        uint32_t num_subkeys, num_values;
-       uint32_t data = 42;
+       char data[4];
+       SIVAL(data, 0, 42);
 
        if (!create_test_key(tctx, rctx, "Berlin", &root, &subkey1))
                return false;
@@ -353,13 +354,15 @@ static bool test_set_value(struct torture_context *tctx, void *_data)
        struct registry_context *rctx = (struct registry_context *)_data;
        struct registry_key *subkey = NULL, *root;
        WERROR error;
-       uint32_t data = 42;
+       char data[4];
+
+       SIVAL(data, 0, 42);
 
        if (!create_test_key(tctx, rctx, "Dusseldorf", &root, &subkey))
                return false;
 
        error = reg_val_set(subkey, "Answer", REG_DWORD,
-                           data_blob_talloc(tctx, &data, sizeof(data)));
+                           data_blob_talloc(tctx, data, sizeof(data)));
        torture_assert_werr_ok (tctx, error, "setting value");
 
        return true;
@@ -408,8 +411,9 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
        struct registry_key *subkey = NULL, *root;
        WERROR error;
        DATA_BLOB data;
-       uint32_t value = 42;
+       char value[4];
        uint32_t type;
+       SIVAL(value, 0, 42);
 
        if (!create_test_key(tctx, rctx, "Duisburg", &root, &subkey))
                return false;
@@ -420,16 +424,16 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
                                  "getting missing value");
 
        error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
-                           data_blob_talloc(tctx, &value, 4));
+                           data_blob_talloc(tctx, value, sizeof(value)));
        torture_assert_werr_ok(tctx, error, "setting value");
 
        error = reg_key_get_value_by_name(tctx, subkey, __FUNCTION__, &type,
                                          &data);
        torture_assert_werr_ok(tctx, error, "getting value");
 
-       torture_assert_int_equal(tctx, 4, data.length, "value length ok");
-       torture_assert_mem_equal(tctx, data.data, &value, 4,
-                                   "value content ok");
+       torture_assert_int_equal(tctx, sizeof(value), data.length, "value length ok");
+       torture_assert_mem_equal(tctx, data.data, value, sizeof(value),
+                                "value content ok");
        torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
 
        return true;
@@ -444,8 +448,9 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
        struct registry_key *subkey = NULL, *root;
        WERROR error;
        DATA_BLOB data;
-       uint32_t value = 42;
        uint32_t type;
+       char value[4];
+       SIVAL(value, 0, 42);
 
        if (!create_test_key(tctx, rctx, "Warschau", &root, &subkey))
                return false;
@@ -456,7 +461,7 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
                                  "getting missing value");
 
        error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
-                           data_blob_talloc(tctx, &value, 4));
+                           data_blob_talloc(tctx, value, sizeof(value)));
        torture_assert_werr_ok (tctx, error, "setting value");
 
        error = reg_del_value(subkey, __FUNCTION__);
@@ -479,15 +484,16 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
        struct registry_key *subkey = NULL, *root;
        WERROR error;
        DATA_BLOB data;
-       uint32_t value = 42;
        uint32_t type;
        const char *name;
+       char value[4];
+       SIVAL(value, 0, 42);
 
        if (!create_test_key(tctx, rctx, "Bonn", &root, &subkey))
                return false;
 
        error = reg_val_set(subkey, "bar", REG_DWORD,
-                           data_blob_talloc(tctx, &value, 4));
+                           data_blob_talloc(tctx, value, sizeof(value)));
        torture_assert_werr_ok (tctx, error, "setting value");
 
        error = reg_key_get_value_by_index(tctx, subkey, 0, &name,
@@ -495,8 +501,8 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
        torture_assert_werr_ok(tctx, error, "getting value");
 
        torture_assert_str_equal(tctx, name, "bar", "value name");
-       torture_assert_int_equal(tctx, 4, data.length, "value length");
-       torture_assert_mem_equal(tctx, data.data, &value, 4,
+       torture_assert_int_equal(tctx, sizeof(value), data.length, "value length");
+       torture_assert_mem_equal(tctx, data.data, value, sizeof(value),
                       "value content");
        torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
 
@@ -517,14 +523,14 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
        struct hive_key *hive_key;
        const char *filename;
 
-       error = reg_open_local(tctx, &rctx, NULL, NULL);
+       error = reg_open_local(tctx, &rctx);
        torture_assert_werr_ok(tctx, error, "Opening local registry failed");
 
        status = torture_temp_dir(tctx, "registry-local", &tempdir);
        torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
 
        filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
-       error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->lp_ctx, &hive_key);
+       error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &hive_key);
        torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
 
        error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
index cec0f8b9066c31f65bccff63f0a786053ea0d355..3ea780de60ae22f15702de95d7e9838601461eb6 100644 (file)
@@ -42,6 +42,7 @@ struct registry_context *reg_common_open_remote(const char *remote,
 }
 
 struct registry_key *reg_common_open_file(const char *path,
+                                         struct event_context *ev_ctx,
                                          struct loadparm_context *lp_ctx,
                                          struct cli_credentials *creds)
 {
@@ -49,7 +50,7 @@ struct registry_key *reg_common_open_file(const char *path,
        struct registry_context *h = NULL;
        WERROR error;
 
-       error = reg_open_hive(NULL, path, NULL, creds, lp_ctx, &hive_root);
+       error = reg_open_hive(NULL, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
 
        if(!W_ERROR_IS_OK(error)) {
                fprintf(stderr, "Unable to open '%s': %s \n",
@@ -57,7 +58,7 @@ struct registry_key *reg_common_open_file(const char *path,
                return NULL;
        }
 
-       error = reg_open_local(NULL, &h, NULL, creds);
+       error = reg_open_local(NULL, &h);
        if (!W_ERROR_IS_OK(error)) {
                fprintf(stderr, "Unable to initialize local registry: %s\n",
                        win_errstr(error));
@@ -67,12 +68,14 @@ struct registry_key *reg_common_open_file(const char *path,
        return reg_import_hive_key(h, hive_root, -1, NULL);
 }
 
-struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx)
+struct registry_context *reg_common_open_local(struct cli_credentials *creds, 
+                                              struct event_context *ev_ctx, 
+                                              struct loadparm_context *lp_ctx)
 {
        WERROR error;
        struct registry_context *h = NULL;
 
-       error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds);
+       error = reg_open_samba(NULL, &h, ev_ctx, lp_ctx, NULL, creds);
 
        if(!W_ERROR_IS_OK(error)) {
                fprintf(stderr, "Unable to open local registry:%s \n",
index c94380efd2b0be46febaedbb11a81f953df77b32..9b49799bed90f7b7003cd492d8711d868c61ea75 100644 (file)
@@ -29,6 +29,7 @@
 enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL };
 
 static struct registry_context *open_backend(poptContext pc,
+                                            struct event_context *ev_ctx,
                                             struct loadparm_context *lp_ctx,
                                             enum reg_backend backend,
                                             const char *remote_host)
@@ -41,14 +42,14 @@ static struct registry_context *open_backend(poptContext pc,
                poptPrintUsage(pc, stderr, 0);
                return NULL;
        case REG_LOCAL:
-               error = reg_open_samba(NULL, &ctx, lp_ctx, NULL, cmdline_credentials);
+               error = reg_open_samba(NULL, &ctx, ev_ctx, lp_ctx, NULL, cmdline_credentials);
                break;
        case REG_REMOTE:
                error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx,
                                        remote_host, NULL);
                break;
        case REG_NULL:
-               error = reg_open_local(NULL, &ctx, NULL, cmdline_credentials);
+               error = reg_open_local(NULL, &ctx);
                break;
        }
 
@@ -82,6 +83,7 @@ int main(int argc, const char **argv)
        };
        TALLOC_CTX *ctx;
        void *callback_data;
+       struct event_context *ev_ctx;
        struct reg_diff_callbacks *callbacks;
 
        ctx = talloc_init("regdiff");
@@ -116,11 +118,13 @@ int main(int argc, const char **argv)
 
        }
 
-       h1 = open_backend(pc, cmdline_lp_ctx, backend1, remote1);
+       ev_ctx = event_context_init(NULL);
+
+       h1 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend1, remote1);
        if (h1 == NULL)
                return 1;
 
-       h2 = open_backend(pc, cmdline_lp_ctx, backend2, remote2);
+       h2 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend2, remote2);
        if (h2 == NULL)
                return 1;
 
index 98443e64566593ccb1001c9f26fbebc98e6436d8..9285459d8501db55b3fecbbaeb1525e5a1567ee7 100644 (file)
@@ -24,6 +24,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "lib/registry/tools/common.h"
 #include "param/param.h"
+#include "events/events.h"
 
 int main(int argc, char **argv)
 {
@@ -33,6 +34,7 @@ int main(int argc, char **argv)
        struct registry_context *h;
        const char *file = NULL;
        const char *remote = NULL;
+       struct event_context *ev;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
                {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL},
@@ -47,10 +49,12 @@ int main(int argc, char **argv)
        while((opt = poptGetNextOpt(pc)) != -1) {
        }
 
+       ev = event_context_init(NULL);
+
        if (remote) {
                h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials);
        } else {
-               h = reg_common_open_local (cmdline_credentials, cmdline_lp_ctx);
+               h = reg_common_open_local (cmdline_credentials, ev, cmdline_lp_ctx);
        }
 
        if (h == NULL)
index 58f64cb049b2f292d64ac81e0aa9f586800db6c0..80eafcc4a29a69edfed366c5293b53f0cbc77956 100644 (file)
@@ -498,6 +498,7 @@ int main(int argc, char **argv)
        poptContext pc;
        const char *remote = NULL;
        struct regshell_context *ctx;
+       struct event_context *ev_ctx;
        bool ret = true;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -516,17 +517,19 @@ int main(int argc, char **argv)
 
        ctx = talloc_zero(NULL, struct regshell_context);
 
+       ev_ctx = event_context_init(ctx);
+
        if (remote != NULL) {
                ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, 
                                                       cmdline_credentials);
        } else if (file != NULL) {
-               ctx->current = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
+               ctx->current = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials);
                if (ctx->current == NULL)
                        return 1;
                ctx->registry = ctx->current->context;
                ctx->path = talloc_strdup(ctx, "");
        } else {
-               ctx->registry = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx);
+               ctx->registry = reg_common_open_local(cmdline_credentials, ev_ctx, cmdline_lp_ctx);
        }
 
        if (ctx->registry == NULL)
index 424d3515e0cd2d5f0315977a2f234014887b738c..440399f7645470f8e761a63904a6e13816c6cf6f 100644 (file)
@@ -109,6 +109,7 @@ int main(int argc, char **argv)
        poptContext pc;
        struct registry_context *h = NULL;
        struct registry_key *start_key = NULL;
+       struct event_context *ev_ctx;
        WERROR error;
        bool fullpath = false, no_values = false;
        struct poptOption long_options[] = {
@@ -128,12 +129,14 @@ int main(int argc, char **argv)
        while((opt = poptGetNextOpt(pc)) != -1) {
        }
 
+       ev_ctx = event_context_init(NULL);
+
        if (remote != NULL) {
                h = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials);
        } else if (file != NULL) {
-               start_key = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
+               start_key = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials);
        } else {
-               h = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx);
+               h = reg_common_open_local(cmdline_credentials, ev_ctx, cmdline_lp_ctx);
        }
 
        if (h == NULL && start_key == NULL)
index 43f7b08572ff1412f52e3aab0f15fd27212d9ef1..4d94317c4b024f4d0f4f4abb9f99dff38d8d279a 100644 (file)
@@ -62,6 +62,8 @@ getnameinfo
 gai_strerror
 getifaddrs
 freeifaddrs
+utime
+utimes
 
 Types:
 bool
index 02dc08bf72c269e58ed15c6891347fbc1dd716aa..81997e09b7d00f46de3433a3031ffce32a025f2f 100644 (file)
@@ -6,6 +6,7 @@ AC_CONFIG_HEADER(config.h)
 CFLAGS="$CFLAGS -I$srcdir"
 
 AC_LIBREPLACE_ALL_CHECKS
+AC_LIBREPLACE_NETWORK_CHECKS
 
 if test "$ac_cv_prog_gcc" = yes; then
    CFLAGS="$CFLAGS -Wall"
diff --git a/source/lib/replace/getaddrinfo.m4 b/source/lib/replace/getaddrinfo.m4
deleted file mode 100644 (file)
index bc6e69e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-dnl test for getaddrinfo/getnameinfo
-AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[
-AC_TRY_LINK([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>
-#include <netdb.h>],
-[
-struct sockaddr sa;
-struct addrinfo *ai = NULL;
-int ret = getaddrinfo(NULL, NULL, NULL, &ai);
-if (ret != 0) {
-       const char *es = gai_strerror(ret);
-}
-freeaddrinfo(ai);
-ret = getnameinfo(&sa, sizeof(sa),
-               NULL, 0,
-               NULL, 0, 0);
-
-],
-libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)])
-if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
-       AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo])
-       AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo])
-       AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo])
-       AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror])
-else
-       LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o"
-fi
diff --git a/source/lib/replace/getifaddrs.m4 b/source/lib/replace/getifaddrs.m4
deleted file mode 100644 (file)
index 927bc67..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-AC_CHECK_HEADERS([ifaddrs.h])
-
-dnl Used when getifaddrs is not available
-AC_CHECK_MEMBERS([struct sockaddr.sa_len], 
-        [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])],
-        [],
-        [#include <sys/socket.h>])
-
-dnl test for getifaddrs and freeifaddrs
-AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-#include <netdb.h>],
-[
-struct ifaddrs *ifp = NULL;
-int ret = getifaddrs (&ifp);
-freeifaddrs(ifp);
-],
-libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)])
-if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then
-    AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
-    AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
-       AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available])
-fi
-
-##################
-# look for a method of finding the list of network interfaces
-#
-# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
-#
-old_LIBS=$LIBS
-LIBS="${LIBREPLACE_NETWORK_LIBS}"
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I$libreplacedir"
-iface=no;
-##################
-# look for a method of finding the list of network interfaces
-iface=no;
-AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
-AC_TRY_RUN([
-#define HAVE_IFACE_GETIFADDRS 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
-           libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
-    iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
-else
-       LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o"
-fi
-
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
-AC_TRY_RUN([
-#define HAVE_IFACE_AIX 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#undef _XOPEN_SOURCE_EXTENDED
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
-           libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
-    iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
-fi
-fi
-
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[
-AC_TRY_RUN([
-#define HAVE_IFACE_IFCONF 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
-           libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
-    iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
-fi
-fi
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[
-AC_TRY_RUN([
-#define HAVE_IFACE_IFREQ 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
-           libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
-    iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
-fi
-fi
-
-LIBS=$old_LIBS
-CPPFLAGS="$SAVE_CPPFLAGS"
-
diff --git a/source/lib/replace/inet_aton.m4 b/source/lib/replace/inet_aton.m4
deleted file mode 100644 (file)
index 853688e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"])
diff --git a/source/lib/replace/inet_ntoa.m4 b/source/lib/replace/inet_ntoa.m4
deleted file mode 100644 (file)
index 5aaa935..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"])
-
-AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
-AC_TRY_RUN([
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-main() { struct in_addr ip; ip.s_addr = 0x12345678;
-if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
-    strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
-exit(1);}],
-           libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
-if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
-    AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
-fi
diff --git a/source/lib/replace/inet_ntop.m4 b/source/lib/replace/inet_ntop.m4
deleted file mode 100644 (file)
index 6f39056..0000000
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"])
diff --git a/source/lib/replace/inet_pton.m4 b/source/lib/replace/inet_pton.m4
deleted file mode 100644 (file)
index 51de927..0000000
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"])
index 8e17258918bd30b957e040f1766e375db8d6b5a5..6a85ff5a82904fabfbe84e61a84f5adbc3a6bbe5 100644 (file)
@@ -96,65 +96,9 @@ fi
 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
 AC_CHECK_HEADERS(sys/time.h time.h)
 AC_CHECK_HEADERS(stdarg.h vararg.h)
-AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
-AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
-AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
 AC_CHECK_HEADERS(sys/mount.h mntent.h)
 AC_CHECK_HEADERS(stropts.h)
 
-dnl we need to check that net/if.h really can be used, to cope with hpux
-dnl where including it always fails
-AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
-       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-               AC_INCLUDES_DEFAULT
-               #if HAVE_SYS_SOCKET_H
-               # include <sys/socket.h>
-               #endif
-               #include <net/if.h>
-               int main(void) {return 0;}])],
-               [libreplace_cv_USABLE_NET_IF_H=yes],
-               [libreplace_cv_USABLE_NET_IF_H=no]
-       )
-])
-if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
-       AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
-fi
-
-AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
-AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
-AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
-AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
-AC_HAVE_TYPE([struct sockaddr_storage], [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-])
-AC_HAVE_TYPE([struct sockaddr_in6], [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-])
-
-if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then
-AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
-                AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),,
-                [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-               ])
-
-if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then
-AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
-                AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),,
-                [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-               ])
-fi
-fi
-
 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
@@ -326,15 +270,7 @@ m4_include(getpass.m4)
 m4_include(strptime.m4)
 m4_include(win32.m4)
 m4_include(timegm.m4)
-m4_include(socket.m4)
-m4_include(inet_ntop.m4)
-m4_include(inet_pton.m4)
-m4_include(inet_aton.m4)
-m4_include(inet_ntoa.m4)
-m4_include(getaddrinfo.m4)
 m4_include(repdir.m4)
-m4_include(getifaddrs.m4)
-m4_include(socketpair.m4)
 
 AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])])
 
@@ -361,5 +297,6 @@ CFLAGS="$CFLAGS -I$libreplacedir"
 
 m4_include(libreplace_cc.m4)
 m4_include(libreplace_ld.m4)
+m4_include(libreplace_network.m4)
 m4_include(libreplace_macros.m4)
 m4_include(autoconf-2.60.m4)
index bf5056838d0ca2a30539ca5bc75f1104f38bf562..0ce0958a96d34f8f8c066486d6ccfa69a254986f 100644 (file)
@@ -132,7 +132,8 @@ AC_CHECK_SIZEOF(off_t)
 AC_CHECK_SIZEOF(size_t)
 AC_CHECK_SIZEOF(ssize_t)
 
-AC_CHECK_TYPE(intptr_t, unsigned long long)
+AC_CHECK_TYPE(intptr_t, long long)
+AC_CHECK_TYPE(uintptr_t, unsigned long long)
 AC_CHECK_TYPE(ptrdiff_t, unsigned long long)
 
 if test x"$ac_cv_type_long_long" != x"yes";then
index f0d10c1e3e334b9feef3b1680052a7599edc7212..9995d69bbc0d6840ceb46c142ee8e3de19b5039b 100644 (file)
@@ -270,6 +270,9 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG],
                *darwin*)
                        LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup"
                        ;;
+               *aix*)
+                       LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry"
+                       ;;
        esac
 
        AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG)
diff --git a/source/lib/replace/libreplace_network.m4 b/source/lib/replace/libreplace_network.m4
new file mode 100644 (file)
index 0000000..4edb55c
--- /dev/null
@@ -0,0 +1,377 @@
+AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS,
+[
+echo "LIBREPLACE_NETWORK_CHECKS: START"
+
+AC_DEFINE(LIBREPLACE_NETWORK_CHECKS, 1, [LIBREPLACE_NETWORK_CHECKS were used])
+LIBREPLACE_NETWORK_OBJS=""
+LIBREPLACE_NETWORK_LIBS=""
+
+AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
+AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
+AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
+
+dnl we need to check that net/if.h really can be used, to cope with hpux
+dnl where including it always fails
+AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
+       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+               AC_INCLUDES_DEFAULT
+               #if HAVE_SYS_SOCKET_H
+               # include <sys/socket.h>
+               #endif
+               #include <net/if.h>
+               int main(void) {return 0;}])],
+               [libreplace_cv_USABLE_NET_IF_H=yes],
+               [libreplace_cv_USABLE_NET_IF_H=no]
+       )
+])
+if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
+       AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
+fi
+
+AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
+AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
+AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
+AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
+AC_HAVE_TYPE([struct sockaddr_storage], [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+])
+AC_HAVE_TYPE([struct sockaddr_in6], [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+])
+
+if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then
+AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
+                AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),,
+                [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+               ])
+
+if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then
+AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
+                AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),,
+                [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+               ])
+fi
+fi
+
+AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+               ],[
+struct sockaddr_in sock; sock.sin_len = sizeof(sock);
+               ],[
+               libreplace_cv_HAVE_SOCK_SIN_LEN=yes
+               ],[
+               libreplace_cv_HAVE_SOCK_SIN_LEN=no
+               ])
+])
+if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
+       AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
+fi
+
+############################################
+# check for unix domain sockets
+AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+               ],[
+struct sockaddr_un sunaddr;
+sunaddr.sun_family = AF_UNIX;
+               ],[
+               libreplace_cv_HAVE_UNIXSOCKET=yes
+               ],[
+               libreplace_cv_HAVE_UNIXSOCKET=no
+               ])
+])
+if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then
+       AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
+fi
+
+dnl The following test is roughl taken from the cvs sources.
+dnl
+dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
+dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
+dnl libsocket.so which has a bad implementation of gethostbyname (it
+dnl only looks in /etc/hosts), so we only look for -lsocket if we need
+dnl it.
+AC_CHECK_FUNCS(connect)
+if test x"$ac_cv_func_connect" = x"no"; then
+       AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
+       AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
+       AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
+       AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
+       dnl We can't just call AC_CHECK_FUNCS(connect) here,
+       dnl because the value has been cached.
+       if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
+               test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
+               test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
+               test x"$ac_cv_lib_ext_inet_connect" = x"yes"
+       then
+               AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
+       fi
+fi
+
+AC_CHECK_FUNCS(gethostbyname)
+if test x"$ac_cv_func_gethostbyname" = x"no"; then
+       AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+       AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+       AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+       dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
+       dnl because the value has been cached.
+       if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
+               test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
+               test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
+       then
+               AC_DEFINE(HAVE_GETHOSTBYNAME,1,
+                         [Whether the system has gethostbyname()])
+       fi
+fi
+
+dnl HP-UX has if_nametoindex in -lipv6
+AC_CHECK_FUNCS(if_nametoindex)
+if test x"$ac_cv_func_if_nametoindex" = x"no"; then
+       AC_CHECK_LIB_EXT(ipv6, LIBREPLACE_NETWORK_LIBS, if_nametoindex)
+       dnl We can't just call AC_CHECK_FUNCS(if_nametoindex) here,
+       dnl because the value has been cached.
+       if test x"$ac_cv_lib_ext_ipv6_if_nametoindex" = x"yes"
+       then
+               AC_DEFINE(HAVE_IF_NAMETOINDEX, 1,
+                         [Whether the system has if_nametoindex()])
+       fi
+fi
+
+# The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
+old_LIBS=$LIBS
+LIBS="${LIBREPLACE_NETWORK_LIBS}"
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$libreplacedir"
+
+AC_CHECK_FUNCS(socketpair,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} socketpair.o"])
+
+AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
+AC_TRY_RUN([
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+main() { struct in_addr ip; ip.s_addr = 0x12345678;
+if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
+    strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
+exit(1);}],
+           libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
+
+AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes])
+if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
+    AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
+    LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntoa.o"
+fi
+
+AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_aton.o"])
+
+AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntop.o"])
+
+AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_pton.o"])
+
+dnl test for getaddrinfo/getnameinfo
+AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[
+AC_TRY_LINK([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <sys/socket.h>
+#include <netdb.h>],
+[
+struct sockaddr sa;
+struct addrinfo *ai = NULL;
+int ret = getaddrinfo(NULL, NULL, NULL, &ai);
+if (ret != 0) {
+       const char *es = gai_strerror(ret);
+}
+freeaddrinfo(ai);
+ret = getnameinfo(&sa, sizeof(sa),
+               NULL, 0,
+               NULL, 0, 0);
+
+],
+libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)])
+if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
+       AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo])
+       AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo])
+       AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo])
+       AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror])
+else
+       LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getaddrinfo.o"
+fi
+
+AC_CHECK_HEADERS([ifaddrs.h])
+
+dnl Used when getifaddrs is not available
+AC_CHECK_MEMBERS([struct sockaddr.sa_len], 
+        [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])],
+        [],
+        [#include <sys/socket.h>])
+
+dnl test for getifaddrs and freeifaddrs
+AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <ifaddrs.h>
+#include <netdb.h>],
+[
+struct ifaddrs *ifp = NULL;
+int ret = getifaddrs (&ifp);
+freeifaddrs(ifp);
+],
+libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)])
+if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then
+    AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
+    AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
+       AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available])
+fi
+
+##################
+# look for a method of finding the list of network interfaces
+iface=no;
+AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
+AC_TRY_RUN([
+#define HAVE_IFACE_GETIFADDRS 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+           libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
+    iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
+else
+       LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getifaddrs.o"
+fi
+
+
+if test $iface = no; then
+AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
+AC_TRY_RUN([
+#define HAVE_IFACE_AIX 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#undef _XOPEN_SOURCE_EXTENDED
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+           libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
+    iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
+fi
+fi
+
+
+if test $iface = no; then
+AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[
+AC_TRY_RUN([
+#define HAVE_IFACE_IFCONF 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+           libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
+    iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
+fi
+fi
+
+if test $iface = no; then
+AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[
+AC_TRY_RUN([
+#define HAVE_IFACE_IFREQ 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+           libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
+    iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
+fi
+fi
+
+dnl test for ipv6
+AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[
+       AC_TRY_LINK([
+#include <stdlib.h> /* for NULL */
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netdb.h>
+               ],
+               [
+struct sockaddr_storage sa_store;
+struct addrinfo *ai = NULL;
+struct in6_addr in6addr;
+int idx = if_nametoindex("iface1");
+int s = socket(AF_INET6, SOCK_STREAM, 0);
+int ret = getaddrinfo(NULL, NULL, NULL, &ai);
+if (ret != 0) {
+       const char *es = gai_strerror(ret);
+}
+freeaddrinfo(ai);
+               ],[
+               libreplace_cv_HAVE_IPV6=yes
+               ],[
+               libreplace_cv_HAVE_IPV6=no
+               ])
+])
+if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then
+    AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support])
+fi
+
+LIBS=$old_LIBS
+CPPFLAGS="$SAVE_CPPFLAGS"
+
+LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}"
+
+echo "LIBREPLACE_NETWORK_CHECKS: END"
+]) dnl end AC_LIBREPLACE_NETWORK_CHECKS
index 6930f9b0791c057deeb8045be91b085d25f662ff..2c3f14c2dfb8694a0cda2581dffe465a4eb2eac9 100644 (file)
@@ -458,7 +458,7 @@ char *rep_strcasestr(const char *haystack, const char *needle)
        for (s=haystack;*s;s++) {
                if (toupper(*needle) == toupper(*s) &&
                    strncasecmp(s, needle, nlen) == 0) {
-                       return (char *)((intptr_t)s);
+                       return (char *)((uintptr_t)s);
                }
        }
        return NULL;
@@ -584,3 +584,30 @@ int rep_unsetenv(const char *name)
        return 0;
 }
 #endif
+
+#ifndef HAVE_UTIME
+int rep_utime(const char *filename, const struct utimbuf *buf)
+{
+       errno = ENOSYS;
+       return -1;
+}
+#endif
+
+#ifndef HAVE_UTIMES
+int rep_utimes(const char *filename, const struct timeval tv[2])
+{
+       struct utimbuf u;
+
+       u.actime = tv[0].tv_sec;
+       if (tv[0].tv_usec > 500000) {
+               u.actime += 1;
+       }
+
+       u.modtime = tv[1].tv_sec;
+       if (tv[1].tv_usec > 500000) {
+               u.modtime += 1;
+       }
+
+       return utime(filename, &u);
+}
+#endif
index 5fe79394ebf63fd4bb1d7bfeb96e9a163e38cfed..c69ea6cdac4d8ae873db163b4ceb6c1cbf73f792 100644 (file)
@@ -101,6 +101,16 @@ void *rep_memmove(void *dest,const void *src,int size);
 /* prototype is in "system/time.h" */
 #endif
 
+#ifndef HAVE_UTIME
+#define utime rep_utime
+/* prototype is in "system/time.h" */
+#endif
+
+#ifndef HAVE_UTIMES
+#define utimes rep_utimes
+/* prototype is in "system/time.h" */
+#endif
+
 #ifndef HAVE_STRLCPY
 #define strlcpy rep_strlcpy
 size_t rep_strlcpy(char *d, const char *s, size_t bufsize);
@@ -499,7 +509,7 @@ typedef int bool;
   Also, please call this via the discard_const_p() macro interface, as that
   makes the return type safe.
 */
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
 
 /** Type-safe version of discard_const */
 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
index 7984ef31db618183bbb8cdfcff321569e35bd88b..07c4d38887e079a93c1c9d1166e20edad6a5900b 100644 (file)
@@ -1,4 +1,5 @@
 AC_LIBREPLACE_BROKEN_CHECKS
+AC_LIBREPLACE_NETWORK_CHECKS
 
 SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}])
 SMB_ENABLE(LIBREPLACE_EXT)
diff --git a/source/lib/replace/socket.m4 b/source/lib/replace/socket.m4
deleted file mode 100644 (file)
index 984f81f..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-dnl The following test is roughl taken from the cvs sources.
-dnl
-dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
-dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
-dnl libsocket.so which has a bad implementation of gethostbyname (it
-dnl only looks in /etc/hosts), so we only look for -lsocket if we need
-dnl it.
-AC_CHECK_FUNCS(connect)
-if test x"$ac_cv_func_connect" = x"no"; then
-       AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
-       AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
-       AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
-       AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
-       dnl We can't just call AC_CHECK_FUNCS(connect) here,
-       dnl because the value has been cached.
-       if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
-               test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
-               test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
-               test x"$ac_cv_lib_ext_inet_connect" = x"yes"
-       then
-               AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
-       fi
-fi
-
-AC_CHECK_FUNCS(gethostbyname)
-if test x"$ac_cv_func_gethostbyname" = x"no"; then
-       AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
-       AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
-       AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
-       dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
-       dnl because the value has been cached.
-       if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
-               test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
-               test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
-       then
-               AC_DEFINE(HAVE_GETHOSTBYNAME,1,
-                         [Whether the system has gethostbyname()])
-       fi
-fi
diff --git a/source/lib/replace/socketpair.m4 b/source/lib/replace/socketpair.m4
deleted file mode 100644 (file)
index 7088334..0000000
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"])
index 66c2bd652a06f550a463d39b0b097f6ae9fa0b78..5c9b53d5c59086ae22229e1e1d098aa330fef877 100644 (file)
@@ -9,6 +9,7 @@ AC_CHECK_HEADERS(sys/select.h)
 # time
 AC_CHECK_HEADERS(sys/time.h utime.h)
 AC_HEADER_TIME
+AC_CHECK_FUNCS(utime utimes)
 
 # wait
 AC_HEADER_SYS_WAIT
index a5fb813aa15b3e4fd2689c7d9769b3196b4e13b3..077892a54e2d5d422d98d8daaff58c4ee93c3d54 100644 (file)
 
 */
 
+#ifndef LIBREPLACE_NETWORK_CHECKS
+#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure"
+#endif
+
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
index 036812ab8facfd841eded041d73526dc58294717..4abf295d1af819af2992e50f65355a690f122d84 100644 (file)
 
 #ifdef HAVE_UTIME_H
 #include <utime.h>
+#else
+struct utimbuf {
+       time_t actime;       /* access time */
+       time_t modtime;      /* modification time */
+};
 #endif
 
 #ifndef HAVE_MKTIME
@@ -51,4 +56,14 @@ time_t rep_mktime(struct tm *t);
 time_t rep_timegm(struct tm *tm);
 #endif
 
+#ifndef HAVE_UTIME
+/* define is in "replace.h" */
+int rep_utime(const char *filename, const struct utimbuf *buf);
+#endif
+
+#ifndef HAVE_UTIMES
+/* define is in "replace.h" */
+int rep_utimes(const char *filename, const struct timeval tv[2]);
+#endif
+
 #endif
index b53836036562b1df0ab99928184226108ff271e3..1e8290906e18b039505582769b3e59b4495649a3 100644 (file)
@@ -872,6 +872,149 @@ static int test_getifaddrs(void)
        return true;
 }
 
+static int test_utime(void)
+{
+       struct utimbuf u;
+       struct stat st1, st2, st3;
+       int fd;
+
+       printf("test: utime\n");
+       unlink(TESTFILE);
+
+       fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
+       if (fd == -1) {
+               printf("failure: utime [\n"
+                      "creating '%s' failed - %s\n]\n",
+                      TESTFILE, strerror(errno));
+               return false;
+       }
+
+       if (fstat(fd, &st1) != 0) {
+               printf("failure: utime [\n"
+                      "fstat (1) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+       u.actime = st1.st_atime + 300;
+       u.modtime = st1.st_mtime - 300;
+       if (utime(TESTFILE, &u) != 0) {
+               printf("failure: utime [\n"
+                      "utime(&u) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+       if (fstat(fd, &st2) != 0) {
+               printf("failure: utime [\n"
+                      "fstat (2) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+       if (utime(TESTFILE, NULL) != 0) {
+               printf("failure: utime [\n"
+                      "utime(NULL) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+       if (fstat(fd, &st3) != 0) {
+               printf("failure: utime [\n"
+                      "fstat (3) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+#define CMP_VAL(a,c,b) do { \
+       if (a c b) { \
+               printf("failure: utime [\n" \
+                      "%s: %s(%d) %s %s(%d)\n]\n", \
+                      __location__, \
+                      #a, (int)a, #c, #b, (int)b); \
+               return false; \
+       } \
+} while(0)
+#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b)
+#define GREATER_VAL(a,b) CMP_VAL(a,<=,b)
+#define LESSER_VAL(a,b) CMP_VAL(a,>=,b)
+
+       EQUAL_VAL(st2.st_atime, st1.st_atime + 300);
+       EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300);
+       LESSER_VAL(st3.st_atime, st2.st_atime);
+       GREATER_VAL(st3.st_mtime, st2.st_mtime);
+
+#undef CMP_VAL
+#undef EQUAL_VAL
+#undef GREATER_VAL
+#undef LESSER_VAL
+
+       unlink(TESTFILE);
+       printf("success: utime\n");
+       return true;
+}
+
+static int test_utimes(void)
+{
+       struct timeval tv[2];
+       struct stat st1, st2;
+       int fd;
+
+       printf("test: utimes\n");
+       unlink(TESTFILE);
+
+       fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
+       if (fd == -1) {
+               printf("failure: utimes [\n"
+                      "creating '%s' failed - %s\n]\n",
+                      TESTFILE, strerror(errno));
+               return false;
+       }
+
+       if (fstat(fd, &st1) != 0) {
+               printf("failure: utimes [\n"
+                      "fstat (1) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+       ZERO_STRUCT(tv);
+       tv[0].tv_sec = st1.st_atime + 300;
+       tv[1].tv_sec = st1.st_mtime - 300;
+       if (utimes(TESTFILE, tv) != 0) {
+               printf("failure: utimes [\n"
+                      "utimes(tv) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+       if (fstat(fd, &st2) != 0) {
+               printf("failure: utimes [\n"
+                      "fstat (2) failed - %s\n]\n",
+                      strerror(errno));
+               return false;
+       }
+
+#define EQUAL_VAL(a,b) do { \
+       if (a != b) { \
+               printf("failure: utimes [\n" \
+                      "%s: %s(%d) != %s(%d)\n]\n", \
+                      __location__, \
+                      #a, (int)a, #b, (int)b); \
+               return false; \
+       } \
+} while(0)
+
+       EQUAL_VAL(st2.st_atime, st1.st_atime + 300);
+       EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300);
+
+#undef EQUAL_VAL
+
+       unlink(TESTFILE);
+       printf("success: utimes\n");
+       return true;
+}
+
 struct torture_context;
 bool torture_local_replace(struct torture_context *ctx)
 {
@@ -920,6 +1063,8 @@ bool torture_local_replace(struct torture_context *ctx)
        ret &= test_socketpair();
        ret &= test_strptime();
        ret &= test_getifaddrs();
+       ret &= test_utime();
+       ret &= test_utimes();
 
        return ret;
 }
index d33b38cab0ba90f328cb6c6b974f0124b0678212..e089149393b89030c7467f037f23770e52d62c37 100644 (file)
@@ -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)))
index b40002b32114c699e8392c8a0c104f469b28c6f7..9c0072dd8ba9badb4a558863a7826c293be68228 100644 (file)
@@ -1,57 +1,19 @@
 AC_CHECK_FUNCS(writev)
 AC_CHECK_FUNCS(readv)
-
-AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>],
-[struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
-samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
-if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
-    AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
-fi
+AC_CHECK_FUNCS(gethostbyname2)
 
 ############################################
 # check for unix domain sockets
-AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
-    AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/socket.h>
-#include <sys/un.h>],
-[
-  struct sockaddr_un sunaddr; 
-  sunaddr.sun_family = AF_UNIX;
-],
-       samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
+# done by AC_LIBREPLACE_NETWORK_CHECKS
 SMB_ENABLE(socket_unix, NO)
-if test x"$samba_cv_unixsocket" = x"yes"; then
-    SMB_ENABLE(socket_unix, YES)
-    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
+if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then
+       SMB_ENABLE(socket_unix, YES)
 fi
 
-AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/unixsock.c"],
-          samba_cv_HAVE_WORKING_AF_LOCAL=yes,
-          samba_cv_HAVE_WORKING_AF_LOCAL=no,
-          samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
-if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
-then
-    AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
-fi
-
-dnl test for ipv6 using the gethostbyname2() function. That should be sufficient
-dnl for now
-AC_CHECK_FUNCS(gethostbyname2, have_ipv6=true, have_ipv6=false)
+############################################
+# check for ipv6
+# done by AC_LIBREPLACE_NETWORK_CHECKS
 SMB_ENABLE(socket_ipv6, NO)
-if $have_ipv6 = true; then
+if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then
     SMB_ENABLE(socket_ipv6, YES)
-    AC_DEFINE(HAVE_IPV6,1,[Whether the system has ipv6 support])
 fi
-dnl don't build ipv6 by default, unless the above test enables it, or
-dnl the configure uses --with-static-modules=socket_ipv6
-
-
-
-
index 240019017545e9daf352e99d442377230bc929ca..18aa806e41df591ce50d1e558543391be56aadce 100644 (file)
@@ -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)
 
index 813412c7bc83bb8eddc23859dbea17f7019dc5c0..2c25d8f491191f9533bb907b72cfe2c157bbd5b2 100644 (file)
@@ -124,7 +124,7 @@ static bool test_tcp(struct torture_context *tctx)
        DATA_BLOB blob, blob2;
        size_t sent, nread;
        TALLOC_CTX *mem_ctx = tctx;
-       struct event_context *ev = event_context_init(mem_ctx);
+       struct event_context *ev = tctx->ev;
        struct interface *ifaces;
 
        status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
index 2067d988cbea5e57eca7912b3f458e23fb0f7bd3..60cfb3209ad990d3b1e3fe026b474dff88dd7ffc 100644 (file)
@@ -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
index 52c85254830d7119ac9152fd183d4be6292aeb8c..56d117e7bd04cd74a76e3cdf1c44f9acb47b0bb3 100644 (file)
@@ -1,4 +1,4 @@
 [SUBSYSTEM::LIBPACKET]
 PRIVATE_DEPENDENCIES = LIBTLS
 
-LIBPACKET_OBJ_FILES = lib/stream/packet.o
+LIBPACKET_OBJ_FILES = $(libstreamsrcdir)/packet.o
index fedbda95aac23dbb86d2701a43385df04dbb023e..3f06eee5667d4b285afdcdbf6c1c986c297c6815 100644 (file)
@@ -48,7 +48,8 @@ static double timeval_elapsed(struct timeval *tv)
 }
 
 #define torture_assert_str_equal(test, arg1, arg2, desc) \
-       if (strcmp(arg1, arg2)) { \
+       if (arg1 == NULL && arg2 == NULL) {                             \
+       } else if (strcmp(arg1, arg2)) {                        \
                printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \
                   test, __location__, arg1, arg2, desc); \
                return false; \
index 07b0c238587eb85fe3945b61b71dbd9dd0729d58..69c81e6e98fd27b7a4d8d86c7c6f620e64cd552a 100644 (file)
@@ -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;
 }
index 9b16a82c339da5c0ecea7396f9ee7e6e46e1e7c6..eaf70d30b4470f757a5366e4de7fcb63264f13dd 100644 (file)
@@ -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
index 2d61545b7f69aa34aca228b48c13fe165100c0fa..83336e7b411e24dab1ab16940c23355c43f4cf7e 100644 (file)
@@ -1,5 +1,10 @@
 [PYTHON::swig_tdb]
-SWIG_FILE = tdb.i
+LIBRARY_REALNAME = _tdb.$(SHLIBEXT)
 PUBLIC_DEPENDENCIES = LIBTDB DYNCONFIG
 
 swig_tdb_OBJ_FILES = lib/tdb/tdb_wrap.o
+
+$(eval $(call python_py_module_template,tdb.py,lib/tdb/tdb.py))
+
+$(swig_tdb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
index 94407b6398134093e7e9372a1ec31bfdfafc4e92..7147718c91fa8fc5cd70798db34e6b3868be307e 100644 (file)
@@ -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()
 
index c82d2d0a6da2777999b54ab6c2c2a79aaae70c50..5f23568170d8a2e2f196d76bc07e9afc901298eb 100644 (file)
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-%module tdb
+%define DOCSTRING
+"TDB is a simple key-value database similar to GDBM that supports multiple writers."
+%enddef
+
+%module(docstring=DOCSTRING) tdb
 
 %{
 
@@ -138,7 +142,8 @@ enum TDB_ERROR {
     $1 = TDB_REPLACE;
 }
 
-%rename(Tdb) tdb;
+%rename(Tdb) tdb_context;
+%feature("docstring") tdb_context "A TDB file.";
 %typemap(out,noblock=1) tdb * {
     /* Throw an IOError exception from errno if tdb_open() returns NULL */
     if ($1 == NULL) {
@@ -150,40 +155,74 @@ enum TDB_ERROR {
 
 typedef struct tdb_context {
     %extend {
+        %feature("docstring") tdb "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
+                                  "Open a TDB file.";
         tdb(const char *name, int hash_size, int tdb_flags, int flags, mode_t mode) {
             return tdb_open(name, hash_size, tdb_flags, flags, mode);
         }
         enum TDB_ERROR error();
         ~tdb() { tdb_close($self); }
+        %feature("docstring") close "S.close() -> None\n"
+                                    "Close the TDB file.";
         int close();
         int append(TDB_DATA key, TDB_DATA new_dbuf);
+        %feature("docstring") errorstr "S.errorstr() -> errorstring\n"
+                                        "Obtain last error message.";
         const char *errorstr();
         %rename(get) fetch;
+        %feature("docstring") fetch "S.fetch(key) -> value\n"
+                                        "Fetch a value.";
         TDB_DATA fetch(TDB_DATA key);
+        %feature("docstring") delete "S.delete(key) -> None\n"
+                                        "Delete an entry.";
         int delete(TDB_DATA key);
+        %feature("docstring") store "S.store(key, value, flag=TDB_REPLACE) -> None\n"
+                                        "Store an entry.";
         int store(TDB_DATA key, TDB_DATA dbuf, int flag);
         int exists(TDB_DATA key);
+        %feature("docstring") firstkey "S.firstkey() -> data\n"
+                                        "Return the first key in this database.";
         TDB_DATA firstkey();
+        %feature("docstring") nextkey "S.nextkey(prev) -> data\n"
+                                        "Return the next key in this database.";
         TDB_DATA nextkey(TDB_DATA key);
+        %feature("docstring") lockall "S.lockall() -> bool";
         int lockall();
+        %feature("docstring") unlockall "S.unlockall() -> bool";
         int unlockall();
+        %feature("docstring") unlockall "S.lockall_read() -> bool";
         int lockall_read();
+        %feature("docstring") unlockall "S.unlockall_read() -> bool";
         int unlockall_read();
+        %feature("docstring") reopen "S.reopen() -> bool\n"
+                                        "Reopen this file.";
         int reopen();
+        %feature("docstring") transaction_start "S.transaction_start() -> None\n"
+                                        "Start a new transaction.";
         int transaction_start();
+        %feature("docstring") transaction_commit "S.transaction_commit() -> None\n"
+                                        "Commit the currently active transaction.";
         int transaction_commit();
+        %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n"
+                                        "Cancel the currently active transaction.";
         int transaction_cancel();
         int transaction_recover();
+        %feature("docstring") hash_size "S.hash_size() -> int";
         int hash_size();
+        %feature("docstring") map_size "S.map_size() -> int";
         size_t map_size();
+        %feature("docstring") get_flags "S.get_flags() -> int";
         int get_flags();
+        %feature("docstring") set_max_dead "S.set_max_dead(int) -> None";
         void set_max_dead(int max_dead);
+        %feature("docstring") name "S.name() -> path\n" \
+                                   "Return filename of this TDB file.";
         const char *name();
     }
 
     %pythoncode {
-    def __str__(self):
-        return self.name()
+    def __repr__(self):
+        return "Tdb('%s')" % self.name()
 
     # Random access to keys, values
     def __getitem__(self, key):
index 0e53927366941b9229a4b3da2b5c495da8d8c75d..fa8db6d34cfbf4380f7720d8c575e5967504f314 100644 (file)
@@ -39,7 +39,7 @@ tdb_wrap.o: $(tdbdir)/tdb_wrap.c
        $(CC) $(PICFLAG) -c $(tdbdir)/tdb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
 
 _tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o
-       $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --libs`
+       $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --ldflags`
 
 install:: installdirs installbin installheaders installlibs \
                  $(PYTHON_INSTALL_TARGET)
@@ -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::
index 0effa3ff98f02057795b001e0428683b63fce24a..a8c1d06e0d9717d731ce4c348dc13173d0def648 100644 (file)
@@ -1,8 +1,12 @@
 # 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.
 
+"""
+TDB is a simple key-value database similar to GDBM that supports multiple writers.
+"""
+
 import _tdb
 import new
 new_instancemethod = new.instancemethod
@@ -78,13 +82,127 @@ TDB_ERR_LOCK_TIMEOUT = _tdb.TDB_ERR_LOCK_TIMEOUT
 TDB_ERR_NOEXIST = _tdb.TDB_ERR_NOEXIST
 TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL
 TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY
-class tdb(object):
+class Tdb(object):
+    """A TDB file."""
     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"
     __repr__ = _swig_repr
-    __swig_destroy__ = _tdb.delete_tdb
-    def __str__(self):
-        return self.name()
+    def __init__(self, *args, **kwargs): 
+        """
+        S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)
+        Open a TDB file.
+        """
+        _tdb.Tdb_swiginit(self,_tdb.new_Tdb(*args, **kwargs))
+    __swig_destroy__ = _tdb.delete_Tdb
+    def close(*args, **kwargs):
+        """
+        S.close() -> None
+        Close the TDB file.
+        """
+        return _tdb.Tdb_close(*args, **kwargs)
+
+    def errorstr(*args, **kwargs):
+        """
+        S.errorstr() -> errorstring
+        Obtain last error message.
+        """
+        return _tdb.Tdb_errorstr(*args, **kwargs)
+
+    def get(*args, **kwargs):
+        """
+        S.fetch(key) -> value
+        Fetch a value.
+        """
+        return _tdb.Tdb_get(*args, **kwargs)
+
+    def delete(*args, **kwargs):
+        """
+        S.delete(key) -> None
+        Delete an entry.
+        """
+        return _tdb.Tdb_delete(*args, **kwargs)
+
+    def store(*args, **kwargs):
+        """
+        S.store(key, value, flag=TDB_REPLACE) -> None
+        Store an entry.
+        """
+        return _tdb.Tdb_store(*args, **kwargs)
+
+    def firstkey(*args, **kwargs):
+        """
+        S.firstkey() -> data
+        Return the first key in this database.
+        """
+        return _tdb.Tdb_firstkey(*args, **kwargs)
+
+    def nextkey(*args, **kwargs):
+        """
+        S.nextkey(prev) -> data
+        Return the next key in this database.
+        """
+        return _tdb.Tdb_nextkey(*args, **kwargs)
+
+    def lock_all(*args, **kwargs):
+        """S.lockall() -> bool"""
+        return _tdb.Tdb_lock_all(*args, **kwargs)
+
+    def unlock_all(*args, **kwargs):
+        """S.unlockall() -> bool"""
+        return _tdb.Tdb_unlock_all(*args, **kwargs)
+
+    def reopen(*args, **kwargs):
+        """
+        S.reopen() -> bool
+        Reopen this file.
+        """
+        return _tdb.Tdb_reopen(*args, **kwargs)
+
+    def transaction_start(*args, **kwargs):
+        """
+        S.transaction_start() -> None
+        Start a new transaction.
+        """
+        return _tdb.Tdb_transaction_start(*args, **kwargs)
+
+    def transaction_commit(*args, **kwargs):
+        """
+        S.transaction_commit() -> None
+        Commit the currently active transaction.
+        """
+        return _tdb.Tdb_transaction_commit(*args, **kwargs)
+
+    def transaction_cancel(*args, **kwargs):
+        """
+        S.transaction_cancel() -> None
+        Cancel the currently active transaction.
+        """
+        return _tdb.Tdb_transaction_cancel(*args, **kwargs)
+
+    def hash_size(*args, **kwargs):
+        """S.hash_size() -> int"""
+        return _tdb.Tdb_hash_size(*args, **kwargs)
+
+    def map_size(*args, **kwargs):
+        """S.map_size() -> int"""
+        return _tdb.Tdb_map_size(*args, **kwargs)
+
+    def get_flags(*args, **kwargs):
+        """S.get_flags() -> int"""
+        return _tdb.Tdb_get_flags(*args, **kwargs)
+
+    def set_max_dead(*args, **kwargs):
+        """S.set_max_dead(int) -> None"""
+        return _tdb.Tdb_set_max_dead(*args, **kwargs)
+
+    def name(*args, **kwargs):
+        """
+        S.name() -> path
+        Return filename of this TDB file.
+        """
+        return _tdb.Tdb_name(*args, **kwargs)
+
+    def __repr__(self):
+        return "Tdb('%s')" % self.name()
 
 
     def __getitem__(self, key):
@@ -178,36 +296,32 @@ class tdb(object):
 
 
 
-tdb.error = new_instancemethod(_tdb.tdb_error,None,tdb)
-tdb.close = new_instancemethod(_tdb.tdb_close,None,tdb)
-tdb.append = new_instancemethod(_tdb.tdb_append,None,tdb)
-tdb.errorstr = new_instancemethod(_tdb.tdb_errorstr,None,tdb)
-tdb.get = new_instancemethod(_tdb.tdb_get,None,tdb)
-tdb.delete = new_instancemethod(_tdb.tdb_delete,None,tdb)
-tdb.store = new_instancemethod(_tdb.tdb_store,None,tdb)
-tdb.exists = new_instancemethod(_tdb.tdb_exists,None,tdb)
-tdb.firstkey = new_instancemethod(_tdb.tdb_firstkey,None,tdb)
-tdb.nextkey = new_instancemethod(_tdb.tdb_nextkey,None,tdb)
-tdb.lock_all = new_instancemethod(_tdb.tdb_lock_all,None,tdb)
-tdb.unlock_all = new_instancemethod(_tdb.tdb_unlock_all,None,tdb)
-tdb.read_lock_all = new_instancemethod(_tdb.tdb_read_lock_all,None,tdb)
-tdb.read_unlock_all = new_instancemethod(_tdb.tdb_read_unlock_all,None,tdb)
-tdb.reopen = new_instancemethod(_tdb.tdb_reopen,None,tdb)
-tdb.transaction_start = new_instancemethod(_tdb.tdb_transaction_start,None,tdb)
-tdb.transaction_commit = new_instancemethod(_tdb.tdb_transaction_commit,None,tdb)
-tdb.transaction_cancel = new_instancemethod(_tdb.tdb_transaction_cancel,None,tdb)
-tdb.transaction_recover = new_instancemethod(_tdb.tdb_transaction_recover,None,tdb)
-tdb.hash_size = new_instancemethod(_tdb.tdb_hash_size,None,tdb)
-tdb.map_size = new_instancemethod(_tdb.tdb_map_size,None,tdb)
-tdb.get_flags = new_instancemethod(_tdb.tdb_get_flags,None,tdb)
-tdb.set_max_dead = new_instancemethod(_tdb.tdb_set_max_dead,None,tdb)
-tdb.name = new_instancemethod(_tdb.tdb_name,None,tdb)
-tdb_swigregister = _tdb.tdb_swigregister
-tdb_swigregister(tdb)
-
-def Tdb(*args, **kwargs):
-    val = _tdb.new_Tdb(*args, **kwargs)
-    return val
+Tdb.error = new_instancemethod(_tdb.Tdb_error,None,Tdb)
+Tdb.close = new_instancemethod(_tdb.Tdb_close,None,Tdb)
+Tdb.append = new_instancemethod(_tdb.Tdb_append,None,Tdb)
+Tdb.errorstr = new_instancemethod(_tdb.Tdb_errorstr,None,Tdb)
+Tdb.get = new_instancemethod(_tdb.Tdb_get,None,Tdb)
+Tdb.delete = new_instancemethod(_tdb.Tdb_delete,None,Tdb)
+Tdb.store = new_instancemethod(_tdb.Tdb_store,None,Tdb)
+Tdb.exists = new_instancemethod(_tdb.Tdb_exists,None,Tdb)
+Tdb.firstkey = new_instancemethod(_tdb.Tdb_firstkey,None,Tdb)
+Tdb.nextkey = new_instancemethod(_tdb.Tdb_nextkey,None,Tdb)
+Tdb.lock_all = new_instancemethod(_tdb.Tdb_lock_all,None,Tdb)
+Tdb.unlock_all = new_instancemethod(_tdb.Tdb_unlock_all,None,Tdb)
+Tdb.read_lock_all = new_instancemethod(_tdb.Tdb_read_lock_all,None,Tdb)
+Tdb.read_unlock_all = new_instancemethod(_tdb.Tdb_read_unlock_all,None,Tdb)
+Tdb.reopen = new_instancemethod(_tdb.Tdb_reopen,None,Tdb)
+Tdb.transaction_start = new_instancemethod(_tdb.Tdb_transaction_start,None,Tdb)
+Tdb.transaction_commit = new_instancemethod(_tdb.Tdb_transaction_commit,None,Tdb)
+Tdb.transaction_cancel = new_instancemethod(_tdb.Tdb_transaction_cancel,None,Tdb)
+Tdb.transaction_recover = new_instancemethod(_tdb.Tdb_transaction_recover,None,Tdb)
+Tdb.hash_size = new_instancemethod(_tdb.Tdb_hash_size,None,Tdb)
+Tdb.map_size = new_instancemethod(_tdb.Tdb_map_size,None,Tdb)
+Tdb.get_flags = new_instancemethod(_tdb.Tdb_get_flags,None,Tdb)
+Tdb.set_max_dead = new_instancemethod(_tdb.Tdb_set_max_dead,None,Tdb)
+Tdb.name = new_instancemethod(_tdb.Tdb_name,None,Tdb)
+Tdb_swigregister = _tdb.Tdb_swigregister
+Tdb_swigregister(Tdb)
 
 
 
index 6a5b7feffc25579a401bf59d8cb41cc0ccf36376..27da552d33a3569913b95ea1ca8dc55474657377 100644 (file)
@@ -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
 
 /* 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
 
 /* 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
 
 
@@ -2874,7 +2892,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   enum TDB_ERROR result;
@@ -2886,7 +2904,7 @@ SWIGINTERN PyObject *_wrap_tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *a
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_error" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_error" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (enum TDB_ERROR)tdb_error(arg1);
@@ -2897,7 +2915,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_delete_tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   void *argp1 = 0 ;
@@ -2908,7 +2926,7 @@ SWIGINTERN PyObject *_wrap_delete_tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_tdb" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Tdb" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   delete_tdb(arg1);
@@ -2920,7 +2938,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -2932,7 +2950,7 @@ SWIGINTERN PyObject *_wrap_tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *a
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_close" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_close" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_close(arg1);
@@ -2943,7 +2961,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA arg2 ;
@@ -2958,10 +2976,10 @@ SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *
     (char *) "self",(char *) "key",(char *) "new_dbuf", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_append" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_append" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   if (obj1 == Py_None) {
@@ -2992,7 +3010,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   char *result = 0 ;
@@ -3004,7 +3022,7 @@ SWIGINTERN PyObject *_wrap_tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_errorstr" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_errorstr" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (char *)tdb_errorstr(arg1);
@@ -3015,7 +3033,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA arg2 ;
@@ -3028,10 +3046,10 @@ SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
     (char *) "self",(char *) "key", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   if (obj1 == Py_None) {
@@ -3057,7 +3075,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA arg2 ;
@@ -3070,10 +3088,10 @@ SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
     (char *) "self",(char *) "key", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_delete" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_delete" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   if (obj1 == Py_None) {
@@ -3094,7 +3112,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA arg2 ;
@@ -3114,10 +3132,10 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
   };
   
   arg4 = TDB_REPLACE;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_store" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_store" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   if (obj1 == Py_None) {
@@ -3143,7 +3161,7 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
   if (obj3) {
     ecode4 = SWIG_AsVal_int(obj3, &val4);
     if (!SWIG_IsOK(ecode4)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "tdb_store" "', argument " "4"" of type '" "int""'");
+      SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Tdb_store" "', argument " "4"" of type '" "int""'");
     } 
     arg4 = (int)(val4);
   }
@@ -3155,7 +3173,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA arg2 ;
@@ -3168,10 +3186,10 @@ SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *
     (char *) "self",(char *) "key", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_exists" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_exists" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   if (obj1 == Py_None) {
@@ -3192,7 +3210,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA result;
@@ -3204,7 +3222,7 @@ SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_firstkey" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_firstkey" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = tdb_firstkey(arg1);
@@ -3220,7 +3238,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   TDB_DATA arg2 ;
@@ -3233,10 +3251,10 @@ SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject
     (char *) "self",(char *) "key", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_nextkey" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_nextkey" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   if (obj1 == Py_None) {
@@ -3262,7 +3280,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3274,7 +3292,7 @@ SWIGINTERN PyObject *_wrap_tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_lock_all" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_lock_all" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_lockall(arg1);
@@ -3285,7 +3303,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3297,7 +3315,7 @@ SWIGINTERN PyObject *_wrap_tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObje
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_unlockall(arg1);
@@ -3308,7 +3326,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3320,7 +3338,7 @@ SWIGINTERN PyObject *_wrap_tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyO
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_lockall_read(arg1);
@@ -3331,7 +3349,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3343,7 +3361,7 @@ SWIGINTERN PyObject *_wrap_tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), P
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_unlockall_read(arg1);
@@ -3354,7 +3372,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3366,7 +3384,7 @@ SWIGINTERN PyObject *_wrap_tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_reopen" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_reopen" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_reopen(arg1);
@@ -3377,7 +3395,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3389,7 +3407,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self),
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_transaction_start(arg1);
@@ -3400,7 +3418,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3412,7 +3430,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self)
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_transaction_commit(arg1);
@@ -3423,7 +3441,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3435,7 +3453,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self)
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_transaction_cancel(arg1);
@@ -3446,7 +3464,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3458,7 +3476,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_transaction_recover(arg1);
@@ -3469,7 +3487,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3481,7 +3499,7 @@ SWIGINTERN PyObject *_wrap_tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObjec
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_hash_size" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_hash_size" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_hash_size(arg1);
@@ -3492,7 +3510,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   size_t result;
@@ -3504,7 +3522,7 @@ SWIGINTERN PyObject *_wrap_tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_map_size" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_map_size" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = tdb_map_size(arg1);
@@ -3515,7 +3533,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int result;
@@ -3527,7 +3545,7 @@ SWIGINTERN PyObject *_wrap_tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObjec
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get_flags" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get_flags" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (int)tdb_get_flags(arg1);
@@ -3538,7 +3556,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   int arg2 ;
@@ -3552,15 +3570,15 @@ SWIGINTERN PyObject *_wrap_tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyOb
     (char *) "self",(char *) "max_dead", NULL 
   };
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
   } 
   arg2 = (int)(val2);
   tdb_set_max_dead(arg1,arg2);
@@ -3571,7 +3589,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   tdb *arg1 = (tdb *) 0 ;
   char *result = 0 ;
@@ -3583,7 +3601,7 @@ SWIGINTERN PyObject *_wrap_tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
   swig_obj[0] = args;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_name" "', argument " "1"" of type '" "tdb *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_name" "', argument " "1"" of type '" "tdb *""'"); 
   }
   arg1 = (tdb *)(argp1);
   result = (char *)tdb_name(arg1);
@@ -3594,41 +3612,85 @@ fail:
 }
 
 
-SWIGINTERN PyObject *tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *Tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_tdb_context, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
+SWIGINTERN PyObject *Tdb_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  return SWIG_Python_InitShadowInstance(args);
+}
+
 static PyMethodDef SwigMethods[] = {
-        { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_error", (PyCFunction)_wrap_tdb_error, METH_O, NULL},
-        { (char *)"delete_tdb", (PyCFunction)_wrap_delete_tdb, METH_O, NULL},
-        { (char *)"tdb_close", (PyCFunction)_wrap_tdb_close, METH_O, NULL},
-        { (char *)"tdb_append", (PyCFunction) _wrap_tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_errorstr", (PyCFunction)_wrap_tdb_errorstr, METH_O, NULL},
-        { (char *)"tdb_get", (PyCFunction) _wrap_tdb_get, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_delete", (PyCFunction) _wrap_tdb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_store", (PyCFunction) _wrap_tdb_store, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_exists", (PyCFunction) _wrap_tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_firstkey", (PyCFunction)_wrap_tdb_firstkey, METH_O, NULL},
-        { (char *)"tdb_nextkey", (PyCFunction) _wrap_tdb_nextkey, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_lock_all", (PyCFunction)_wrap_tdb_lock_all, METH_O, NULL},
-        { (char *)"tdb_unlock_all", (PyCFunction)_wrap_tdb_unlock_all, METH_O, NULL},
-        { (char *)"tdb_read_lock_all", (PyCFunction)_wrap_tdb_read_lock_all, METH_O, NULL},
-        { (char *)"tdb_read_unlock_all", (PyCFunction)_wrap_tdb_read_unlock_all, METH_O, NULL},
-        { (char *)"tdb_reopen", (PyCFunction)_wrap_tdb_reopen, METH_O, NULL},
-        { (char *)"tdb_transaction_start", (PyCFunction)_wrap_tdb_transaction_start, METH_O, NULL},
-        { (char *)"tdb_transaction_commit", (PyCFunction)_wrap_tdb_transaction_commit, METH_O, NULL},
-        { (char *)"tdb_transaction_cancel", (PyCFunction)_wrap_tdb_transaction_cancel, METH_O, NULL},
-        { (char *)"tdb_transaction_recover", (PyCFunction)_wrap_tdb_transaction_recover, METH_O, NULL},
-        { (char *)"tdb_hash_size", (PyCFunction)_wrap_tdb_hash_size, METH_O, NULL},
-        { (char *)"tdb_map_size", (PyCFunction)_wrap_tdb_map_size, METH_O, NULL},
-        { (char *)"tdb_get_flags", (PyCFunction)_wrap_tdb_get_flags, METH_O, NULL},
-        { (char *)"tdb_set_max_dead", (PyCFunction) _wrap_tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"tdb_name", (PyCFunction)_wrap_tdb_name, METH_O, NULL},
-        { (char *)"tdb_swigregister", tdb_swigregister, METH_VARARGS, NULL},
+        { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
+               "Open a TDB file.\n"
+               ""},
+        { (char *)"Tdb_error", (PyCFunction)_wrap_Tdb_error, METH_O, NULL},
+        { (char *)"delete_Tdb", (PyCFunction)_wrap_delete_Tdb, METH_O, NULL},
+        { (char *)"Tdb_close", (PyCFunction)_wrap_Tdb_close, METH_O, (char *)"\n"
+               "S.close() -> None\n"
+               "Close the TDB file.\n"
+               ""},
+        { (char *)"Tdb_append", (PyCFunction) _wrap_Tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Tdb_errorstr", (PyCFunction)_wrap_Tdb_errorstr, METH_O, (char *)"\n"
+               "S.errorstr() -> errorstring\n"
+               "Obtain last error message.\n"
+               ""},
+        { (char *)"Tdb_get", (PyCFunction) _wrap_Tdb_get, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.fetch(key) -> value\n"
+               "Fetch a value.\n"
+               ""},
+        { (char *)"Tdb_delete", (PyCFunction) _wrap_Tdb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.delete(key) -> None\n"
+               "Delete an entry.\n"
+               ""},
+        { (char *)"Tdb_store", (PyCFunction) _wrap_Tdb_store, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.store(key, value, flag=TDB_REPLACE) -> None\n"
+               "Store an entry.\n"
+               ""},
+        { (char *)"Tdb_exists", (PyCFunction) _wrap_Tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Tdb_firstkey", (PyCFunction)_wrap_Tdb_firstkey, METH_O, (char *)"\n"
+               "S.firstkey() -> data\n"
+               "Return the first key in this database.\n"
+               ""},
+        { (char *)"Tdb_nextkey", (PyCFunction) _wrap_Tdb_nextkey, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.nextkey(prev) -> data\n"
+               "Return the next key in this database.\n"
+               ""},
+        { (char *)"Tdb_lock_all", (PyCFunction)_wrap_Tdb_lock_all, METH_O, (char *)"S.lockall() -> bool"},
+        { (char *)"Tdb_unlock_all", (PyCFunction)_wrap_Tdb_unlock_all, METH_O, (char *)"S.unlockall() -> bool"},
+        { (char *)"Tdb_read_lock_all", (PyCFunction)_wrap_Tdb_read_lock_all, METH_O, NULL},
+        { (char *)"Tdb_read_unlock_all", (PyCFunction)_wrap_Tdb_read_unlock_all, METH_O, NULL},
+        { (char *)"Tdb_reopen", (PyCFunction)_wrap_Tdb_reopen, METH_O, (char *)"\n"
+               "S.reopen() -> bool\n"
+               "Reopen this file.\n"
+               ""},
+        { (char *)"Tdb_transaction_start", (PyCFunction)_wrap_Tdb_transaction_start, METH_O, (char *)"\n"
+               "S.transaction_start() -> None\n"
+               "Start a new transaction.\n"
+               ""},
+        { (char *)"Tdb_transaction_commit", (PyCFunction)_wrap_Tdb_transaction_commit, METH_O, (char *)"\n"
+               "S.transaction_commit() -> None\n"
+               "Commit the currently active transaction.\n"
+               ""},
+        { (char *)"Tdb_transaction_cancel", (PyCFunction)_wrap_Tdb_transaction_cancel, METH_O, (char *)"\n"
+               "S.transaction_cancel() -> None\n"
+               "Cancel the currently active transaction.\n"
+               ""},
+        { (char *)"Tdb_transaction_recover", (PyCFunction)_wrap_Tdb_transaction_recover, METH_O, NULL},
+        { (char *)"Tdb_hash_size", (PyCFunction)_wrap_Tdb_hash_size, METH_O, (char *)"S.hash_size() -> int"},
+        { (char *)"Tdb_map_size", (PyCFunction)_wrap_Tdb_map_size, METH_O, (char *)"S.map_size() -> int"},
+        { (char *)"Tdb_get_flags", (PyCFunction)_wrap_Tdb_get_flags, METH_O, (char *)"S.get_flags() -> int"},
+        { (char *)"Tdb_set_max_dead", (PyCFunction) _wrap_Tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, (char *)"S.set_max_dead(int) -> None"},
+        { (char *)"Tdb_name", (PyCFunction)_wrap_Tdb_name, METH_O, (char *)"\n"
+               "S.name() -> path\n"
+               "Return filename of this TDB file.\n"
+               ""},
+        { (char *)"Tdb_swigregister", Tdb_swigregister, METH_VARARGS, NULL},
+        { (char *)"Tdb_swiginit", Tdb_swiginit, METH_VARARGS, NULL},
         { NULL, NULL, 0, NULL }
 };
 
@@ -3753,7 +3815,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 +3825,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 +3856,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);
index 3e05f6c30c161ee5517879e44f7ee7e982efdc49..07506ec6472d7c0833d9fe2a6abe5fcd762494f9 100644 (file)
@@ -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
index e2d7cd517a730e57c7eb9af1f63be859de03f709..e01f79ce106897bfa3f405f6f944b5e6f5ade2d6 100644 (file)
@@ -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/source/lib/torture/config.mk b/source/lib/torture/config.mk
new file mode 100644 (file)
index 0000000..49e7b1a
--- /dev/null
@@ -0,0 +1,14 @@
+# TORTURE subsystem
+[LIBRARY::torture]
+PUBLIC_DEPENDENCIES = \
+               LIBSAMBA-HOSTCONFIG \
+               LIBSAMBA-UTIL \
+               LIBTALLOC
+
+torture_VERSION = 0.0.1
+torture_SOVERSION = 0
+
+PC_FILES += $(libtorturesrcdir)/torture.pc
+torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o)
+
+PUBLIC_HEADERS += $(libtorturesrcdir)/torture.h
similarity index 99%
rename from source/torture/ui.c
rename to source/lib/torture/torture.c
index efa584ebeaae2735fdc5d9f672c8fe35528d6521..33959ded16ec2f1c69c1e78be2c6676473ffdaed 100644 (file)
 */
 
 #include "includes.h"
-#include "torture/ui.h"
 #include "torture/torture.h"
 #include "lib/util/dlinklist.h"
 #include "param/param.h"
 #include "system/filesys.h"
-#include "auth/credentials/credentials.h"
-#include "lib/cmdline/popt_common.h"
 
 struct torture_context *torture_context_init(struct event_context *event_ctx, 
                                             const struct torture_ui_ops *ui_ops)
@@ -578,6 +575,3 @@ struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
 
        return test;
 }
-
-
-
index 5a4b831ed5047c084f8ca15d852b67ad261dd057..925713a53c1d55f889b199d3512a6769459460b1 100644 (file)
@@ -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
index a219ef0891dd8c993bc21470992a6e3bcd840755..3bd6a02fdc28ba384ff250e1c0e9640a194bb137 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #include "includes.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
 
 static bool test_string_sub_simple(struct torture_context *tctx)
 {
index a18188580619378fe91a6f863cb3a0aa391d663d..978d73cc0a1731319ef61a96b239dcfcf678cc93 100644 (file)
@@ -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);
index 1ab976ca78c1d3428abd461ac3e3028a003e02f2..e4008c57824e0b94936adba4d76340e35b617de2 100644 (file)
@@ -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
index 3bf6b98d2fb3f247ce9800ab5b835aab271935c3..ffe83c14b297d9573fc669e9b03fcaa4321b82cf 100644 (file)
@@ -64,7 +64,7 @@ extern const char *panic_action;
   makes the return type safe.
 */
 #ifndef discard_const
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
 #endif
 
 /** Type-safe version of discard_const */
index 85fc4ab527fff4f7f17b404d34ce59614931bf1f..498c2af258bf54cbdc507e5b24b6a98dcedbf766 100644 (file)
@@ -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)))
index d9910285d941058a70b3058477981d284371e184..860bd358d5ec2139fba33c4ea95052cf48e995ce 100644 (file)
@@ -250,11 +250,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
        cldap = talloc(mem_ctx, struct cldap_socket);
        if (cldap == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               cldap->event_ctx = event_context_init(cldap);
-       } else {
-               cldap->event_ctx = talloc_reference(cldap, event_ctx);
-       }
+       cldap->event_ctx = talloc_reference(cldap, event_ctx);
        if (cldap->event_ctx == NULL) goto failed;
 
        cldap->idr = idr_init(cldap);
@@ -599,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;
@@ -622,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;
 }
 
@@ -708,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;
index eb0191d0f4589bfad6e6fbb38a0578de8f80f587..7c2daf0ca235d92d0cc7258f2b310b36973582b3 100644 (file)
@@ -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);
index 4858a96110b7a46df9b3e99e88edeacdbcad7560..c20a7fd9353f9572f804c394463bbe939aaebbb9 100644 (file)
 */
 bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, 
                           const char **ports, 
+                          struct event_context *ev_ctx,
                           struct resolve_context *resolve_ctx,
                           struct smbcli_options *options)
 {
        struct smbcli_socket *sock;
 
-       sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx, 
-                                         NULL);
+       sock = smbcli_sock_connect_byname(server, ports, NULL,
+                                         resolve_ctx, ev_ctx);
 
        if (sock == NULL) return false;
        
index e59b7f9af3efbb6e1be5bb720443f07cd4606a38..2cf174060b7bf33d06d4f660524cb1427ef2bb15 100644 (file)
@@ -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);
index 26169e7838949aae14c88472cc9d86539d914c39..3e3f224f4754681356d2acd090aba3ee37038e85 100644 (file)
@@ -42,7 +42,11 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
        c = talloc_zero(mem_ctx, struct composite_context);
        if (!c) return NULL;
        c->state = COMPOSITE_STATE_IN_PROGRESS;
-       c->event_ctx = ev;
+       c->event_ctx = talloc_reference(c, ev);
+       if (!c->event_ctx) {
+               talloc_free(c);
+               return NULL;
+       }
 
        return c;
 }
@@ -65,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()
 
@@ -90,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);
        }
@@ -183,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,
index f1bed20361f1c56e0f86307798598cd27ed6bb24..28cd6a88dc04147b674b54e98f4afc12bb0228fe 100644 (file)
@@ -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__ */
index 95b45003bec8b655c109a6f6a66ff107ae018c37..b24f3eb4af9311f43fd5bce1605d336aa95c44c1 100644 (file)
@@ -5,117 +5,149 @@ 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
+LIBRARY_REALNAME = samba/_libcli_nbt.$(SHLIBEXT)
 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
+
+$(eval $(call python_py_module_template,samba/nbt.py,$(libclisrcdir)/swig/libcli_nbt.py))
+
+$(python_libcli_nbt_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
 
 [PYTHON::python_libcli_smb]
-SWIG_FILE = swig/libcli_smb.i
+LIBRARY_REALNAME = samba/_libcli_smb.$(SHLIBEXT)
 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
+
+$(eval $(call python_py_module_template,samba/smb.py,$(libclisrcdir)/swig/libcli_smb.py))
+
+$(python_libcli_smb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
 
 [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 +156,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
index 130d8ae870949df276fca6d4a419ac32ed0bc1f8..06b7bd57714bab1415dd379121a3f4b6d03a6021 100644 (file)
@@ -167,11 +167,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
        dgmsock = talloc(mem_ctx, struct nbt_dgram_socket);
        if (dgmsock == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               dgmsock->event_ctx = event_context_init(dgmsock);
-       } else {
-               dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
-       }
+       dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
        if (dgmsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
index 707cca8cc53a7bda769bc9b3956e598fd4ae269a..e1209e7a546f40eba7c5a71e269907a259beab05 100644 (file)
@@ -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,
index 5c7dedc7bb657202e234b5957b83d71520e2815a..b37d4a2ee6ce97eb9113e0c7ffe06099b6126ae2 100644 (file)
@@ -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/source/libcli/dgram/ntlogon.c b/source/libcli/dgram/ntlogon.c
deleted file mode 100644 (file)
index 7b26ed7..0000000
+++ /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;
-}
index 33e32c7417ea99f07c9a14ee2653b0ff1581abc5..02678eed7a3b2363f8e7c71d9dc4358841fd70a2 100644 (file)
@@ -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
index 2c04edf9505ba5150de6bf3ebb5b49c075493ca0..e1569e72963b0a869294bca2a1e9fccba05039c1 100644 (file)
@@ -200,7 +200,7 @@ static struct ldap_message *new_ldap_sasl_bind_msg(struct ldap_connection *conn,
 /*
   perform a sasl bind using the given credentials
 */
-_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, 
+_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
                        struct cli_credentials *creds,
                        struct loadparm_context *lp_ctx)
 {
@@ -223,7 +223,8 @@ _PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
 
        gensec_init(lp_ctx);
 
-       status = gensec_client_start(conn, &conn->gensec, NULL, lp_ctx);
+       status = gensec_client_start(conn, &conn->gensec,
+                                    conn->event.event_ctx, lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
                goto failed;
index 296a7b11f26905672a612454857e0fba4195e886..bca867b0332694db9720297a14a8afccd9cb5dd9 100644 (file)
@@ -48,17 +48,13 @@ _PUBLIC_ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx,
 {
        struct ldap_connection *conn;
 
-       conn = talloc_zero(mem_ctx, struct ldap_connection);
-       if (conn == NULL) {
+       if (ev == NULL) {
                return NULL;
        }
 
-       if (ev == NULL) {
-               ev = event_context_init(conn);
-               if (ev == NULL) {
-                       talloc_free(conn);
-                       return NULL;
-               }
+       conn = talloc_zero(mem_ctx, struct ldap_connection);
+       if (conn == NULL) {
+               return NULL;
        }
 
        conn->next_messageid  = 1;
index 14cec3a024b3229b966dfe5e0ec6710bddbbd63a..0b013655103c81228f99d04b2f3586fecf66753d 100644 (file)
@@ -330,7 +330,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
 
 
 NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *)
-NDR_SCALAR_PROTO(nbt_string, const char *);
+NDR_SCALAR_PROTO(nbt_string, const char *)
 NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
 NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
 
index 747127980ab14ead0336bfc0e5323e03c7a9a978..5d4611e2d95a32c508d3dd0b676889ec6f667906 100644 (file)
@@ -318,11 +318,7 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
        nbtsock = talloc(mem_ctx, struct nbt_name_socket);
        if (nbtsock == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               nbtsock->event_ctx = event_context_init(nbtsock);
-       } else {
-               nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
-       }
+       nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
        if (nbtsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
diff --git a/source/libcli/ndr_netlogon.c b/source/libcli/ndr_netlogon.c
new file mode 100644 (file)
index 0000000..504b3b0
--- /dev/null
@@ -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/source/libcli/netlogon.c b/source/libcli/netlogon.c
new file mode 100644 (file)
index 0000000..052d7cb
--- /dev/null
@@ -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/source/libcli/netlogon.h b/source/libcli/netlogon.h
new file mode 100644 (file)
index 0000000..177ed3a
--- /dev/null
@@ -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__ */
index 1dcf2d1c539151a302e7ea0d5de80549ecfd2d77..49838e8a1c1f1e41743f4ee11daf3ea7ceb6bf7f 100644 (file)
@@ -59,12 +59,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
        if (result == NULL) goto failed;
        result->state = COMPOSITE_STATE_IN_PROGRESS;
 
-       if (event_ctx != NULL) {
-               result->event_ctx = talloc_reference(result, event_ctx);
-       } else {
-               result->event_ctx = event_context_init(result);
-       }
-
+       result->event_ctx = talloc_reference(result, event_ctx);
        if (result->event_ctx == NULL) goto failed;
 
        state = talloc(result, struct sock_connect_state);
@@ -202,6 +197,11 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
        struct smbcli_socket *result;
 
+       if (event_ctx == NULL) {
+               DEBUG(0, ("Invalid NULL event context passed in as parameter\n"));
+               return NULL;
+       }
+
        if (tmp_ctx == NULL) {
                DEBUG(0, ("talloc_new failed\n"));
                return NULL;
@@ -214,16 +214,6 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
                return NULL;
        }
 
-       if (event_ctx == NULL) {
-               event_ctx = event_context_init(mem_ctx);
-       }
-
-       if (event_ctx == NULL) {
-               DEBUG(0, ("event_context_init failed\n"));
-               talloc_free(tmp_ctx);
-               return NULL;
-       }
-
        /* allow hostnames of the form NAME#xx and do a netbios lookup */
        if ((p = strchr(name, '#'))) {
                name_type = strtol(p+1, NULL, 16);
index d5075f9271dc23ebfb6216a91a729eb2555eeb8e..15cd70833c7c0b13810525ef7dfa4e632cde958a 100644 (file)
@@ -193,6 +193,11 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
        io.in.service_type = service_type;
        io.in.credentials = credentials;
        io.in.fallback_to_anonymous = false;
+
+       /* This workgroup gets sent out by the SPNEGO session setup.
+        * I don't know of any servers that look at it, so we might
+        * hardcode it to "" some day, when the war on global_loadparm
+        * is complete -- abartlet 2008-04-28 */
        io.in.workgroup = lp_workgroup(global_loadparm);
        io.in.options = *options;
        
index 61441b2cdc5f0a4269e086833fd7d23eb243dbf8..bae0e67b02e0b89ae359c9b3feae20c30c7fc6ad 100644 (file)
@@ -684,7 +684,8 @@ union smb_fileinfo {
                        uint32_t ea_size;
                        uint32_t access_mask;
                        uint64_t position;
-                       uint64_t mode;
+                       uint32_t mode;
+                       uint32_t alignment_requirement;
                        struct smb_wire_string fname;
                } out;
        } all_info2;
@@ -1587,6 +1588,14 @@ union smb_open {
 
                        /* optional list of extended attributes */
                        struct smb_ea_list eas;
+
+                       struct smb2_create_blobs {
+                               uint32_t num_blobs;
+                               struct smb2_create_blob {
+                                       const char *tag;
+                                       DATA_BLOB data;
+                               } *blobs;
+                       } blobs;
                } in;
                struct {
                        union smb_handle file;
@@ -1854,16 +1863,16 @@ enum smb_lock_level {
        RAW_LOCK_LOCK,
        RAW_LOCK_UNLOCK,
        RAW_LOCK_LOCKX,
-       RAW_LOCK_SMB2
+       RAW_LOCK_SMB2,
+       RAW_LOCK_SMB2_BREAK
 };
 
-/* the generic interface is defined to be equal to the lockingX interface */
-#define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
+#define        RAW_LOCK_GENERIC RAW_LOCK_LOCKX
 
 /* union for lock() backend call 
 */
 union smb_lock {
-       /* SMBlockingX (and generic) interface */
+       /* SMBlockingX and generic interface */
        struct {
                enum smb_lock_level level;
                struct {
@@ -1878,7 +1887,7 @@ union smb_lock {
                                uint64_t count;
                        } *locks; /* unlocks are first in the arrray */
                } in;
-       } lockx, generic;
+       } generic, lockx;
 
        /* SMBlock and SMBunlock interface */
        struct {
@@ -1898,25 +1907,42 @@ union smb_lock {
 
                        /* static body buffer 48 (0x30) bytes */
                        /* uint16_t buffer_code;  0x30 */
-                       uint16_t unknown1; /* must be 0x0001 */
-                       uint32_t unknown2;
+                       uint16_t lock_count;
+                       uint32_t reserved;
                        /* struct smb2_handle handle; */
-                       uint64_t offset;
-                       uint64_t count;
-                       uint32_t unknown5;
+                       struct smb2_lock_element {
+                               uint64_t offset;
+                               uint64_t length;
+/* these flags are the same as the SMB2 lock flags */
 #define SMB2_LOCK_FLAG_NONE            0x00000000
 #define SMB2_LOCK_FLAG_SHARED          0x00000001
-#define SMB2_LOCK_FLAG_EXCLUSIV                0x00000002
+#define SMB2_LOCK_FLAG_EXCLUSIVE       0x00000002
 #define SMB2_LOCK_FLAG_UNLOCK          0x00000004
-#define SMB2_LOCK_FLAG_NO_PENDING      0x00000010
-                       uint32_t flags;
+#define SMB2_LOCK_FLAG_FAIL_IMMEDIATELY        0x00000010
+                               uint32_t flags;
+                               uint32_t reserved;
+                       } *locks;
                } in;
                struct {
                        /* static body buffer 4 (0x04) bytes */
                        /* uint16_t buffer_code;  0x04 */
-                       uint16_t unknown1;
+                       uint16_t reserved;
                } out;
        } smb2;
+
+       /* SMB2 Break */
+       struct smb2_break {
+               enum smb_lock_level level;
+               struct {
+                       union smb_handle file;
+
+                       /* static body buffer 24 (0x18) bytes */
+                       uint8_t oplock_level;
+                       uint8_t reserved;
+                       uint32_t reserved2;
+                       /* struct smb2_handle handle; */
+               } in, out;
+       } smb2_break;
 };
 
 
@@ -2131,8 +2157,12 @@ union smb_flush {
                enum smb_flush_level level;
                struct {
                        union smb_handle file;
-                       uint32_t unknown;
+                       uint16_t reserved1;
+                       uint32_t reserved2;
                } in;
+               struct {
+                       uint16_t reserved;
+               } out;
        } smb2;
 };
 
@@ -2331,10 +2361,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 {
@@ -2347,7 +2378,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; */
index 8ea8e621c9fedcab98f0d3e9f621987e6a15fbb1..07b517ade3f24bec4fdfc8622bc13a9b0e6dbac0 100644 (file)
@@ -54,13 +54,13 @@ static uint_t ea_name_list_size(uint_t num_names, struct ea_name *eas)
   This assumes the names are strict ascii, which should be a
   reasonable assumption
 */
-size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas)
+size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas, unsigned alignment)
 {
        uint_t total = 0;
        int i;
        for (i=0;i<num_eas;i++) {
                uint_t len = 8 + strlen(eas[i].name.s)+1 + eas[i].value.length;
-               len = (len + 3) & ~3;
+               len = (len + (alignment-1)) & ~(alignment-1);
                total += len;
        }
        return total;
@@ -96,14 +96,15 @@ void ea_put_list(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
   put a chained ea_list into a pre-allocated buffer - buffer must be
   at least of size ea_list_size()
 */
-void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
+void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas,
+                        unsigned alignment)
 {
        int i;
 
        for (i=0;i<num_eas;i++) {
                uint_t nlen = strlen(eas[i].name.s);
                uint32_t len = 8+nlen+1+eas[i].value.length;
-               uint_t pad = ((len + 3) & ~3) - len;
+               uint_t pad = ((len + (alignment-1)) & ~(alignment-1)) - len;
                if (i == num_eas-1) {
                        SIVAL(data, 0, 0);
                } else {
index 3c5c1b742bd09dfe6f465e15017021d4d311e334..d39c61551be7b0b2f4158c04b01160dddb45c242 100644 (file)
@@ -314,14 +314,14 @@ static struct smbcli_request *smb_raw_nttrans_create_send(struct smbcli_tree *tr
 
        if (parms->ntcreatex.in.ea_list) {
                uint32_t ea_size = ea_list_size_chained(parms->ntcreatex.in.ea_list->num_eas,
-                                                       parms->ntcreatex.in.ea_list->eas);
+                                                       parms->ntcreatex.in.ea_list->eas, 4);
                ea_blob = data_blob_talloc(mem_ctx, NULL, ea_size);
                if (ea_blob.data == NULL) {
                        return NULL;
                }
                ea_put_list_chained(ea_blob.data, 
                                    parms->ntcreatex.in.ea_list->num_eas,
-                                   parms->ntcreatex.in.ea_list->eas);
+                                   parms->ntcreatex.in.ea_list->eas, 4);
        }
 
        nt.in.params = data_blob_talloc(mem_ctx, NULL, 53);
index 71900be49cde5ccb5a29f6695f876d68706260a0..0ea5a93606d23ed6408a0ae2209fbfe3a219e922 100644 (file)
@@ -243,7 +243,8 @@ NTSTATUS smb_raw_fileinfo_passthru_parse(const DATA_BLOB *blob, TALLOC_CTX *mem_
                parms->all_info2.out.ea_size        = IVAL(blob->data, 0x48);
                parms->all_info2.out.access_mask    = IVAL(blob->data, 0x4C);
                parms->all_info2.out.position       = BVAL(blob->data, 0x50);
-               parms->all_info2.out.mode           = BVAL(blob->data, 0x58);
+               parms->all_info2.out.mode           = IVAL(blob->data, 0x58);
+               parms->all_info2.out.alignment_requirement = IVAL(blob->data, 0x5C);
                smbcli_blob_pull_string(NULL, mem_ctx, blob,
                                        &parms->all_info2.out.fname, 0x60, 0x64, STR_UNICODE);
                return NT_STATUS_OK;
index a42c71054718b1fb67268cbb31beda22498ba8e9..ef856c6ea1d0c5799d72d879694d2f3aa7dcc6e2 100644 (file)
@@ -700,10 +700,10 @@ DATA_BLOB smbcli_req_pull_blob(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_
 static bool smbcli_req_data_oob(struct request_bufinfo *bufinfo, const uint8_t *ptr, uint32_t count)
 {
        /* be careful with wraparound! */
-       if (ptr < bufinfo->data ||
-           ptr >= bufinfo->data + bufinfo->data_size ||
+       if ((uintptr_t)ptr < (uintptr_t)bufinfo->data ||
+           (uintptr_t)ptr >= (uintptr_t)bufinfo->data + bufinfo->data_size ||
            count > bufinfo->data_size ||
-           ptr + count > bufinfo->data + bufinfo->data_size) {
+           (uintptr_t)ptr + count > (uintptr_t)bufinfo->data + bufinfo->data_size) {
                return true;
        }
        return false;
index 29881afd2bc2ff7be350842ef36304a50b63c9e9..0f15b2151b6046452b0a1519c3e780875b9d7386 100644 (file)
@@ -40,10 +40,10 @@ static bool raw_trans_oob(struct smbcli_request *req,
        ptr = req->in.hdr + offset;
        
        /* be careful with wraparound! */
-       if (ptr < req->in.data ||
-           ptr >= req->in.data + req->in.data_size ||
+       if ((uintptr_t)ptr < (uintptr_t)req->in.data ||
+           (uintptr_t)ptr >= (uintptr_t)req->in.data + req->in.data_size ||
            count > req->in.data_size ||
-           ptr + count > req->in.data + req->in.data_size) {
+           (uintptr_t)ptr + count > (uintptr_t)req->in.data + req->in.data_size) {
                return true;
        }
        return false;   
index e054ed6522406bdaed6a80ae346e314a98bfc048..74869e8a45fed7aec00a53b9017edea81c90b741 100644 (file)
 #define FILE_ATTRIBUTE_OFFLINE         0x1000
 #define FILE_ATTRIBUTE_NONINDEXED      0x2000
 #define FILE_ATTRIBUTE_ENCRYPTED       0x4000
+#define FILE_ATTRIBUTE_ALL_MASK        0x7FFF
 
 /* Flags - combined with attributes. */
 #define FILE_FLAG_WRITE_THROUGH    0x80000000L
index 4b8f3f955388e83d93b83df6de02915106873add..1a695432eecbd2b3b13932bec3f69d2a700b8bde 100644 (file)
@@ -135,7 +135,6 @@ struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx,
        c = composite_create(mem_ctx, event_ctx);
        if (c == NULL) return NULL;
 
-       c->event_ctx = talloc_reference(c, event_ctx);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct host_state);
index 887bdd7ecf7376568c5d32b5e95d453c7fb9164f..8f085c5404078a16ef0c6742d800373b5ef3d864 100644 (file)
@@ -110,10 +110,9 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
        struct nbtlist_state *state;
        int i;
 
-       c = composite_create(event_ctx, event_ctx);
+       c = composite_create(mem_ctx, event_ctx);
        if (c == NULL) return NULL;
 
-       c->event_ctx = talloc_reference(c, event_ctx);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct nbtlist_state);
index 33ace094432a261726926cbaf30fb4c3220d172e..d89b50e430fd1fd6428df74cc90dab873185930d 100644 (file)
@@ -136,19 +136,13 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx,
        struct composite_context *c;
        struct resolve_state *state;
 
-       c = composite_create(event_ctx, event_ctx);
-       if (c == NULL) return NULL;
-
-       if (ctx == NULL) {
-               composite_error(c, NT_STATUS_INVALID_PARAMETER);
-               return c;
+       if (ctx == NULL || event_ctx == NULL) {
+               return NULL;
        }
 
-       if (event_ctx == NULL) {
-               c->event_ctx = event_context_init(c);
-       } else {
-               c->event_ctx = talloc_reference(c, event_ctx);
-       }
+       c = composite_create(ctx, event_ctx);
+       if (c == NULL) return NULL;
+
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct resolve_state);
index fde065aa347da496e23b3bbb2b7da0bcf8b5d6d6..f2883d1ede094535fc99fa0d42be5735694105e1 100644 (file)
@@ -1,14 +1,18 @@
 [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
+LIBRARY_REALNAME = samba/_security.$(SHLIBEXT)
 PRIVATE_DEPENDENCIES = LIBSECURITY
 
-swig_security_OBJ_FILES = libcli/security/security_wrap.o
+swig_security_OBJ_FILES = $(libclisrcdir)/security/security_wrap.o
+
+$(eval $(call python_py_module_template,samba/security.py,$(libclisrcdir)/security/security.py))
+
+$(swig_security_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
index 10b263b27b2602fb7f64c3173736e23a1238aef8..7e56e22cefac594d264dd9efbb3c8e4495d4230a 100644 (file)
@@ -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.
 
index eb9e4c45d98582487092e294a0198a15c834fb15..aabf6c27eebf7404611d927212007925ba6daec2 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2503,7 +2521,7 @@ static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0};
 
 #define SWIG_name    "_security"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -3674,7 +3692,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -3684,6 +3702,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 */
@@ -3712,6 +3733,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);
index 59a5e69640019ebfb172c53e248b436afd6e43c8..82ce7aeba8939580d1be3ecf443b5a7627ac3938 100644 (file)
@@ -18,7 +18,7 @@
 #
 
 import unittest
-import security
+from samba import security
 
 class SecurityTokenTests(unittest.TestCase):
     def setUp(self):
diff --git a/source/libcli/smb2/break.c b/source/libcli/smb2/break.c
new file mode 100644 (file)
index 0000000..fe0cceb
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   SMB2 client oplock break handling
+
+   Copyright (C) Stefan Metzmacher 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/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+
+/*
+  send a break request
+*/
+struct smb2_request *smb2_break_send(struct smb2_tree *tree, struct smb2_break *io)
+{
+       struct smb2_request *req;
+
+       req = smb2_request_init_tree(tree, SMB2_OP_BREAK, 0x18, false, 0);
+       if (req == NULL) return NULL;
+
+       SCVAL(req->out.body, 0x02, io->in.oplock_level);
+       SCVAL(req->out.body, 0x03, io->in.reserved);
+       SIVAL(req->out.body, 0x04, io->in.reserved2);
+       smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
+
+       smb2_transport_send(req);
+
+       return req;
+}
+
+
+/*
+  recv a break reply
+*/
+NTSTATUS smb2_break_recv(struct smb2_request *req, struct smb2_break *io)
+{
+       if (!smb2_request_receive(req) ||
+           !smb2_request_is_ok(req)) {
+               return smb2_request_destroy(req);
+       }
+
+       SMB2_CHECK_PACKET_RECV(req, 0x18, false);
+
+       io->out.oplock_level    = CVAL(req->in.body, 0x02);
+       io->out.reserved        = CVAL(req->in.body, 0x03);
+       io->out.reserved2       = IVAL(req->in.body, 0x04);
+       smb2_pull_handle(req->in.body+0x08, &io->out.file.handle);
+
+       return smb2_request_destroy(req);
+}
+
+/*
+  sync flush request
+*/
+NTSTATUS smb2_break(struct smb2_tree *tree, struct smb2_break *io)
+{
+       struct smb2_request *req = smb2_break_send(tree, io);
+       return smb2_break_recv(req, io);
+}
index e95997db54980b4cb1f95a8ee60a8a43bc6c4d7c..00b6305def59bc32a379a1494a8dc031f2ea6d2d 100644 (file)
@@ -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)
+       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)))
index d68b85ad540fd3684380c1e94bc831cfe17e6ff3..eabfa410adc6b9ed5567bd22fe4e07eaa07c91ef 100644 (file)
@@ -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;
 
@@ -121,7 +124,7 @@ static void continue_socket(struct composite_context *creq)
        struct smbcli_socket *sock;
        struct smb2_transport *transport;
        struct smb2_request *req;
-       uint16_t dialects[1];
+       uint16_t dialects[2];
 
        c->status = smbcli_sock_connect_recv(creq, state, &sock);
        if (!composite_is_ok(c)) return;
@@ -130,18 +133,19 @@ static void continue_socket(struct composite_context *creq)
        if (composite_nomem(transport, c)) return;
 
        ZERO_STRUCT(state->negprot);
-       state->negprot.in.dialect_count = 1;
+       state->negprot.in.dialect_count = 2;
        state->negprot.in.security_mode = 0;
        state->negprot.in.capabilities  = 0;
        unix_to_nt_time(&state->negprot.in.start_time, time(NULL));
-       dialects[0] = SMB2_DIALECT_REVISION;
+       dialects[0] = 0;
+       dialects[1] = SMB2_DIALECT_REVISION;
        state->negprot.in.dialects = dialects;
 
        req = smb2_negprot_send(transport, &state->negprot);
        if (composite_nomem(req, c)) return;
 
        req->async.fn = continue_negprot;
-       req->async.private = c;
+       req->async.private_data = c;
 }
 
 
index 999c10ab085c44b37c5146e41bf77fd08435eacc..b1b8b0ccfaf85a1a4e004d0eaaf6ccff91ce221c 100644 (file)
 /*
   add a blob to a smb2_create attribute blob
 */
-NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, 
-                             const char *tag,
-                             DATA_BLOB add, bool last)
+static NTSTATUS smb2_create_blob_push_one(TALLOC_CTX *mem_ctx, DATA_BLOB *buffer,
+                                         const struct smb2_create_blob *blob,
+                                         bool last)
 {
-       uint32_t ofs = blob->length;
-       size_t tag_length = strlen(tag);
-       uint8_t pad = smb2_padding_size(add.length+tag_length, 8);
-       if (!data_blob_realloc(mem_ctx, blob, 
-                              blob->length + 0x14 + tag_length + add.length + pad))
+       uint32_t ofs = buffer->length;
+       size_t tag_length = strlen(blob->tag);
+       uint8_t pad = smb2_padding_size(blob->data.length+tag_length, 4);
+
+       if (!data_blob_realloc(mem_ctx, buffer,
+                              buffer->length + 0x14 + tag_length + blob->data.length + pad))
                return NT_STATUS_NO_MEMORY;
-       
+
        if (last) {
-               SIVAL(blob->data, ofs+0x00, 0);
+               SIVAL(buffer->data, ofs+0x00, 0);
        } else {
-               SIVAL(blob->data, ofs+0x00, 0x14 + tag_length + add.length + pad);
+               SIVAL(buffer->data, ofs+0x00, 0x14 + tag_length + blob->data.length + pad);
        }
-       SSVAL(blob->data, ofs+0x04, 0x10); /* offset of tag */
-       SIVAL(blob->data, ofs+0x06, tag_length); /* tag length */
-       SSVAL(blob->data, ofs+0x0A, 0x14 + tag_length); /* offset of data */
-       SIVAL(blob->data, ofs+0x0C, add.length);
-       memcpy(blob->data+ofs+0x10, tag, tag_length);
-       SIVAL(blob->data, ofs+0x10+tag_length, 0); /* pad? */
-       memcpy(blob->data+ofs+0x14+tag_length, add.data, add.length);
-       memset(blob->data+ofs+0x14+tag_length+add.length, 0, pad);
+       SSVAL(buffer->data, ofs+0x04, 0x10); /* offset of tag */
+       SIVAL(buffer->data, ofs+0x06, tag_length); /* tag length */
+       SSVAL(buffer->data, ofs+0x0A, 0x14 + tag_length); /* offset of data */
+       SIVAL(buffer->data, ofs+0x0C, blob->data.length);
+       memcpy(buffer->data+ofs+0x10, blob->tag, tag_length);
+       SIVAL(buffer->data, ofs+0x10+tag_length, 0); /* pad? */
+       memcpy(buffer->data+ofs+0x14+tag_length, blob->data.data, blob->data.length);
+       memset(buffer->data+ofs+0x14+tag_length+blob->data.length, 0, pad);
+
+       return NT_STATUS_OK;
+}
+
+NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, struct smb2_create_blobs *b,
+                             const char *tag, DATA_BLOB data)
+{
+       struct smb2_create_blob *array;
+
+       array = talloc_realloc(mem_ctx, b->blobs,
+                              struct smb2_create_blob,
+                              b->num_blobs + 1);
+       NT_STATUS_HAVE_NO_MEMORY(array);
+       b->blobs = array;
+
+       b->blobs[b->num_blobs].tag = talloc_strdup(b->blobs, tag);
+       NT_STATUS_HAVE_NO_MEMORY(b->blobs[b->num_blobs].tag);
+
+       if (data.data) {
+               b->blobs[b->num_blobs].data = data_blob_talloc(b->blobs,
+                                                              data.data,
+                                                              data.length);
+               NT_STATUS_HAVE_NO_MEMORY(b->blobs[b->num_blobs].data.data);
+       } else {
+               b->blobs[b->num_blobs].data = data_blob(NULL, 0);
+       }
+
+       b->num_blobs += 1;
 
        return NT_STATUS_OK;
 }
@@ -64,6 +93,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
        struct smb2_request *req;
        NTSTATUS status;
        DATA_BLOB blob = data_blob(NULL, 0);
+       uint32_t i;
 
        req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0);
        if (req == NULL) return NULL;
@@ -87,9 +117,10 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
 
        if (io->in.eas.num_eas != 0) {
                DATA_BLOB b = data_blob_talloc(req, NULL, 
-                                              ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
-               ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas);
-               status = smb2_create_blob_add(req, &blob, SMB2_CREATE_TAG_EXTA, b, false);
+                                              ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas, 4));
+               ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas, 4);
+               status = smb2_create_blob_add(req, &io->in.blobs,
+                                             SMB2_CREATE_TAG_EXTA, b);
                if (!NT_STATUS_IS_OK(status)) {
                        talloc_free(req);
                        return NULL;
@@ -99,13 +130,30 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
 
        /* an empty MxAc tag seems to be used to ask the server to
           return the maximum access mask allowed on the file */
-       status = smb2_create_blob_add(req, &blob, SMB2_CREATE_TAG_MXAC, 
-                                     data_blob(NULL, 0), true);
-
+       status = smb2_create_blob_add(req, &io->in.blobs,
+                                     SMB2_CREATE_TAG_MXAC, data_blob(NULL, 0));
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(req);
                return NULL;
        }
+
+       for (i=0; i < io->in.blobs.num_blobs; i++) {
+               bool last = false;
+               const struct smb2_create_blob *c;
+
+               if ((i + 1) == io->in.blobs.num_blobs) {
+                       last = true;
+               }
+
+               c = &io->in.blobs.blobs[i];
+               status = smb2_create_blob_push_one(req, &blob,
+                                                  c, last);
+               if (!NT_STATUS_IS_OK(status)) {
+                       talloc_free(req);
+                       return NULL;
+               }
+       }
+
        status = smb2_push_o32s32_blob(&req->out, 0x30, blob);
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(req);
index 6b4902a026c6c2e49dc0e6bbcf5056814fec0579..8ebfd81bcd1d18580aaddbcd13be8c7b9fa0a1c1 100644 (file)
@@ -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);
index 116068ed6ebe96747475ed3b8cce8094f2fbc512..577d1ba1ba78845af00efd52ac78d132320bad4e 100644 (file)
@@ -33,8 +33,8 @@ struct smb2_request *smb2_flush_send(struct smb2_tree *tree, struct smb2_flush *
        req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, false, 0);
        if (req == NULL) return NULL;
 
-       SSVAL(req->out.body, 0x02, 0); /* pad? */
-       SIVAL(req->out.body, 0x04, io->in.unknown);
+       SSVAL(req->out.body, 0x02, io->in.reserved1);
+       SIVAL(req->out.body, 0x04, io->in.reserved2);
        smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
 
        smb2_transport_send(req);
@@ -55,6 +55,8 @@ NTSTATUS smb2_flush_recv(struct smb2_request *req, struct smb2_flush *io)
 
        SMB2_CHECK_PACKET_RECV(req, 0x04, false);
 
+       io->out.reserved = SVAL(req->in.body, 0x02);
+
        return smb2_request_destroy(req);
 }
 
index d71a337d5621502d7b4046238a68f33848a3c15d..62c6e5dba7479d5e160127a975b2ba5815fee7ed 100644 (file)
 struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io)
 {
        struct smb2_request *req;
+       int i;
 
-       req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, false, 0);
+       req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 
+                                    24 + io->in.lock_count*24, false, 0);
        if (req == NULL) return NULL;
 
-       SSVAL(req->out.body, 0x02, io->in.unknown1);
-       SIVAL(req->out.body, 0x04, io->in.unknown2);
+       /* this is quite bizarre - the spec says we must lie about the length! */
+       SSVAL(req->out.body, 0, 0x30);
+
+       SSVAL(req->out.body, 0x02, io->in.lock_count);
+       SIVAL(req->out.body, 0x04, io->in.reserved);
        smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
-       SBVAL(req->out.body, 0x18, io->in.offset);
-       SBVAL(req->out.body, 0x20, io->in.count);
-       SIVAL(req->out.body, 0x24, io->in.unknown5);
-       SIVAL(req->out.body, 0x28, io->in.flags);
+
+       for (i=0;i<io->in.lock_count;i++) {
+               SBVAL(req->out.body, 0x18 + i*24, io->in.locks[i].offset);
+               SBVAL(req->out.body, 0x20 + i*24, io->in.locks[i].length);
+               SIVAL(req->out.body, 0x28 + i*24, io->in.locks[i].flags);
+               SIVAL(req->out.body, 0x2C + i*24, io->in.locks[i].reserved);
+       }
 
        smb2_transport_send(req);
 
@@ -59,7 +67,7 @@ NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io)
 
        SMB2_CHECK_PACKET_RECV(req, 0x04, false);
 
-       io->out.unknown1 = SVAL(req->in.body, 0x02);
+       io->out.reserved = SVAL(req->in.body, 0x02);
 
        return smb2_request_destroy(req);
 }
index 2471fcaa4ddae7342679e789153b101fb18c74e5..64d427f889c196de06b554b4576f0ef20d60c9b4 100644 (file)
@@ -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;
 }
@@ -211,10 +220,10 @@ bool smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
                return false;
        }
        /* be careful with wraparound! */
-       if (ptr < buf->body ||
-           ptr >= buf->body + buf->body_size ||
+       if ((uintptr_t)ptr < (uintptr_t)buf->body ||
+           (uintptr_t)ptr >= (uintptr_t)buf->body + buf->body_size ||
            size > buf->body_size ||
-           ptr + size > buf->body + buf->body_size) {
+           (uintptr_t)ptr + size > (uintptr_t)buf->body + buf->body_size) {
                return true;
        }
        return false;
@@ -669,7 +678,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf,
        }
 
        if (*str == 0) {
-               blob.data = str;
+               blob.data = discard_const(str);
                blob.length = 0;
                return smb2_push_o16s16_blob(buf, ofs, blob);
        }
index 18fe3486a4d1666f7aa9d240a37928364cf0883c..29af6652f2d845c6baaf9d66cfe855f5aec9dfa7 100644 (file)
@@ -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;
        }
 
index 726df64090f318c823f9e49e1eeea6fe63b75e09..b55da05e21f30436b48201ee36c59f86eb246999 100644 (file)
    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;
+
 struct smb2_options {
        uint32_t timeout;
 };
@@ -30,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 */
@@ -58,6 +65,15 @@ struct smb2_transport {
                void *private;
                uint_t period;
        } idle;
+
+       struct {
+               /* a oplock break request handler */
+               bool (*handler)(struct smb2_transport *transport,
+                               const struct smb2_handle *handle,
+                               uint8_t level, void *private_data);
+               /* private data passed to the oplock handler */
+               void *private_data;
+       } oplock;
 };
 
 
@@ -154,7 +170,7 @@ struct smb2_request {
        */
        struct {
                void (*fn)(struct smb2_request *);
-               void *private;
+               void *private_data;
        } async;
 };
 
@@ -271,3 +287,5 @@ struct smb2_request {
                return NT_STATUS_INVALID_PARAMETER; \
        } \
 } while (0)
+
+#endif
index af19fcb0a9cbd0489d853f80a4097fa09cc1f5a3..8eb60a06f132c9a76216d762cc63bae093c76970 100644 (file)
@@ -140,6 +140,44 @@ void smb2_transport_dead(struct smb2_transport *transport, NTSTATUS status)
        }
 }
 
+static bool smb2_handle_oplock_break(struct smb2_transport *transport,
+                                    const DATA_BLOB *blob)
+{
+       uint8_t *hdr;
+       uint16_t opcode;
+       uint64_t seqnum;
+
+       hdr = blob->data+NBT_HDR_SIZE;
+
+       if (blob->length < (SMB2_MIN_SIZE+0x18)) {
+               DEBUG(1,("Discarding smb2 oplock reply of size %u\n",
+                        blob->length));
+               return false;
+       }
+
+       opcode  = SVAL(hdr, SMB2_HDR_OPCODE);
+       seqnum  = BVAL(hdr, SMB2_HDR_MESSAGE_ID);
+
+       if ((opcode != SMB2_OP_BREAK) ||
+           (seqnum != UINT64_MAX)) {
+               return false;
+       }
+
+       if (transport->oplock.handler) {
+               uint8_t *body = hdr+SMB2_HDR_BODY;
+               struct smb2_handle h;
+               uint8_t level;
+
+               level = CVAL(body, 0x02);
+               smb2_pull_handle(body+0x08, &h);
+
+               transport->oplock.handler(transport, &h, level,
+                                         transport->oplock.private_data);
+       }
+
+       return true;
+}
+
 /*
   we have a full request in our receive buffer - match it to a pending request
   and process
@@ -167,6 +205,11 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
                goto error;
        }
 
+       if (smb2_handle_oplock_break(transport, &blob)) {
+               talloc_free(buffer);
+               return NT_STATUS_OK;
+       }
+
        flags   = IVAL(hdr, SMB2_HDR_FLAGS);
        seqnum  = BVAL(hdr, SMB2_HDR_MESSAGE_ID);
 
diff --git a/source/libcli/smb2/util.c b/source/libcli/smb2/util.c
new file mode 100644 (file)
index 0000000..9eb344e
--- /dev/null
@@ -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;
+}
index c44c62f86899f877db5178b82c60d838c0c3894b..e56339f96bf2d6a8b624ab437a1ee0604ab979fd 100644 (file)
@@ -38,7 +38,9 @@ enum connect_stage {CONNECT_RESOLVE,
                    CONNECT_NEGPROT,
                    CONNECT_SESSION_SETUP,
                    CONNECT_SESSION_SETUP_ANON,
-                   CONNECT_TCON};
+                   CONNECT_TCON,
+                   CONNECT_DONE
+};
 
 struct connect_state {
        enum connect_stage stage;
@@ -56,25 +58,6 @@ struct connect_state {
 static void request_handler(struct smbcli_request *);
 static void composite_handler(struct composite_context *);
 
-/*
-  setup a negprot send 
-*/
-static NTSTATUS connect_send_negprot(struct composite_context *c, 
-                                    struct smb_composite_connect *io)
-{
-       struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
-
-       state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol);
-       NT_STATUS_HAVE_NO_MEMORY(state->req);
-
-       state->req->async.fn = request_handler;
-       state->req->async.private = c;
-       state->stage = CONNECT_NEGPROT;
-       
-       return NT_STATUS_OK;
-}
-
-
 /*
   a tree connect request has completed
 */
@@ -97,8 +80,7 @@ static NTSTATUS connect_tcon(struct composite_context *c,
                                                      state->io_tcon->tconx.out.fs_type);
        }
 
-       /* all done! */
-       c->state = COMPOSITE_STATE_DONE;
+       state->stage = CONNECT_DONE;
 
        return NT_STATUS_OK;
 }
@@ -121,9 +103,6 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c,
        state->session->vuid = state->io_setup->out.vuid;
        
        /* setup for a tconx */
-       io->out.tree = smbcli_tree_init(state->session, state, true);
-       NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
-
        state->io_tcon = talloc(c, union smb_tcon);
        NT_STATUS_HAVE_NO_MEMORY(state->io_tcon);
 
@@ -203,9 +182,12 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
        
        state->session->vuid = state->io_setup->out.vuid;
        
-       /* setup for a tconx */
-       io->out.tree = smbcli_tree_init(state->session, state, true);
-       NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
+       /* If we don't have a remote share name then this indicates that
+        * we don't want to do a tree connect */
+       if (!io->in.service) {
+               state->stage = CONNECT_DONE;
+               return NT_STATUS_OK;
+       }
 
        state->io_tcon = talloc(c, union smb_tcon);
        NT_STATUS_HAVE_NO_MEMORY(state->io_tcon);
@@ -254,6 +236,18 @@ static NTSTATUS connect_negprot(struct composite_context *c,
        /* next step is a session setup */
        state->session = smbcli_session_init(state->transport, state, true);
        NT_STATUS_HAVE_NO_MEMORY(state->session);
+       
+       /* setup for a tconx (or at least have the structure ready to
+        * return, if we won't go that far) */
+       io->out.tree = smbcli_tree_init(state->session, state, true);
+       NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
+
+       /* If we don't have any credentials then this indicates that
+        * we don't want to do a session setup */
+       if (!io->in.credentials) {
+               state->stage = CONNECT_DONE;
+               return NT_STATUS_OK;
+       }
 
        state->io_setup = talloc(c, struct smb_composite_sesssetup);
        NT_STATUS_HAVE_NO_MEMORY(state->io_setup);
@@ -272,11 +266,30 @@ static NTSTATUS connect_negprot(struct composite_context *c,
 
        state->creq->async.fn = composite_handler;
        state->creq->async.private_data = c;
+
        state->stage = CONNECT_SESSION_SETUP;
        
        return NT_STATUS_OK;
 }
 
+/*
+  setup a negprot send 
+*/
+static NTSTATUS connect_send_negprot(struct composite_context *c, 
+                                    struct smb_composite_connect *io)
+{
+       struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
+
+       state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol);
+       NT_STATUS_HAVE_NO_MEMORY(state->req);
+
+       state->req->async.fn = request_handler;
+       state->req->async.private = c;
+       state->stage = CONNECT_NEGPROT;
+       
+       return NT_STATUS_OK;
+}
+
 
 /*
   a session request operation has completed
@@ -405,13 +418,11 @@ static void state_handler(struct composite_context *c)
                break;
        }
 
-       if (!NT_STATUS_IS_OK(c->status)) {
-               c->state = COMPOSITE_STATE_ERROR;
-       }
-
-       if (c->state >= COMPOSITE_STATE_DONE &&
-           c->async.fn) {
-               c->async.fn(c);
+       if (state->stage == CONNECT_DONE) {
+               /* all done! */
+               composite_done(c);
+       } else {
+               composite_is_ok(c);
        }
 }
 
@@ -451,17 +462,15 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
        c = talloc_zero(mem_ctx, struct composite_context);
        if (c == NULL) goto failed;
 
+       c->event_ctx = talloc_reference(c, event_ctx);
+       if (c->event_ctx == NULL) goto failed;
+
        state = talloc_zero(c, struct connect_state);
        if (state == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               event_ctx = event_context_init(mem_ctx);
-       }
-
        state->io = io;
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
-       c->event_ctx = talloc_reference(c, event_ctx);
        c->private_data = state;
 
        state->stage = CONNECT_RESOLVE;
index d8d7481270fbb573367e2fc8c49a171dc2c76fde..9cd02a51f457b5f45299b2147418b0e52ac428fd 100644 (file)
@@ -62,7 +62,6 @@ static NTSTATUS fetchfile_connect(struct composite_context *c,
        state->creq->async.fn = fetchfile_composite_handler;
 
        state->stage = FETCHFILE_READ;
-       c->event_ctx = talloc_reference(c, state->creq->event_ctx);
 
        return NT_STATUS_OK;
 }
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->stage = FETCHFILE_CONNECT;
-       c->event_ctx = talloc_reference(c, state->creq->event_ctx);
        c->private_data = state;
 
        return c;
index 2ec13df9b6bf79edf87e363fa8675d83fcdcd647..270d71f5185be629951f6e1ca588010e6971a054 100644 (file)
@@ -52,7 +52,6 @@ static NTSTATUS fsinfo_connect(struct composite_context *c,
        state->req->async.fn = fsinfo_raw_handler;
 
        state->stage = FSINFO_QUERY;
-       c->event_ctx = talloc_reference(c, state->req->session->transport->socket->event.ctx);
 
        return NT_STATUS_OK;
 }
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->stage = FSINFO_CONNECT;
-       c->event_ctx = talloc_reference(c, tree->session->transport->socket->event.ctx);
        c->private_data = state;
 
        state->creq = smb_composite_connect_send(state->connect, state,
index 1427fe525b4dbe185c9d11f8c3f146a9e4c3f21a..11ac37e257abbb668c539377291dd2a41ab9eae5 100644 (file)
@@ -224,7 +224,6 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
 {
        NTSTATUS nt_status;
        struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
-       const char *password = cli_credentials_get_password(io->in.credentials);
        DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
        DATA_BLOB session_key;
        int flags = CLI_CRED_NTLM_AUTH;
@@ -266,6 +265,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
                
                data_blob_free(&session_key);
        } else if (session->options.plaintext_auth) {
+               const char *password = cli_credentials_get_password(io->in.credentials);
                state->setup.nt1.in.password1 = data_blob_talloc(state, password, strlen(password));
                state->setup.nt1.in.password2 = data_blob(NULL, 0);
        } else {
diff --git a/source/libcli/smb_composite/smb2.c b/source/libcli/smb_composite/smb2.c
new file mode 100644 (file)
index 0000000..6e005e0
--- /dev/null
@@ -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);  
+}
index e7e131869c95decb5e59583ea823fca05a282e32..7f4b9d73e4b48da338817e9558b39018119b6a25 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "libcli/raw/signing.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/smb2/smb2.h"
 
 
 /*
@@ -83,8 +84,8 @@ struct smb_composite_savefile {
     - socket establishment
     - session request
     - negprot
-    - session setup
-    - tree connect
+    - session setup (if credentials are not NULL)
+    - tree connect (if service is not NULL)
 */
 struct smb_composite_connect {
        struct {
index b49e240bc287bbaf358b91fb815e958f6359391e..a26aa6092ebaf05478dad558568320fae4bb56a1 100644 (file)
@@ -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.
 
index e0bdb27cfc9563730bb9fc4533c4210b9fa0b54d..2deec98cb58ca7f9cc498f7b36f8f03e0b23502b 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2507,7 +2525,7 @@ static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0};
 
 #define SWIG_name    "_libcli_nbt"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -3134,7 +3152,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name(PyObject *SWIGUNUSEDPARM(self), PyObject
   struct nbt_name *result = 0 ;
   
   if (!SWIG_Python_UnpackTuple(args,"new_nbt_name",0,0,0)) SWIG_fail;
-  result = (struct nbt_name *)(struct nbt_name *) calloc(1, sizeof(struct nbt_name));
+  result = (struct nbt_name *)calloc(1, sizeof(struct nbt_name));
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -3227,7 +3245,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name_query(PyObject *SWIGUNUSEDPARM(self), Py
   struct nbt_name_query *result = 0 ;
   
   if (!SWIG_Python_UnpackTuple(args,"new_nbt_name_query",0,0,0)) SWIG_fail;
-  result = (struct nbt_name_query *)(struct nbt_name_query *) calloc(1, sizeof(struct nbt_name_query));
+  result = (struct nbt_name_query *)calloc(1, sizeof(struct nbt_name_query));
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_query, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -3493,7 +3511,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name_query_out(PyObject *SWIGUNUSEDPARM(self)
   nbt_name_query_out *result = 0 ;
   
   if (!SWIG_Python_UnpackTuple(args,"new_nbt_name_query_out",0,0,0)) SWIG_fail;
-  result = (nbt_name_query_out *)(nbt_name_query_out *) calloc(1, sizeof(nbt_name_query_out));
+  result = (nbt_name_query_out *)calloc(1, sizeof(nbt_name_query_out));
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_query_out, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -3865,7 +3883,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name_query_in(PyObject *SWIGUNUSEDPARM(self),
   nbt_name_query_in *result = 0 ;
   
   if (!SWIG_Python_UnpackTuple(args,"new_nbt_name_query_in",0,0,0)) SWIG_fail;
-  result = (nbt_name_query_in *)(nbt_name_query_in *) calloc(1, sizeof(nbt_name_query_in));
+  result = (nbt_name_query_in *)calloc(1, sizeof(nbt_name_query_in));
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_query_in, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -4280,7 +4298,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -4290,6 +4308,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 */
@@ -4318,6 +4339,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);
index 80c40402375782acfbf97e383aab74432baff343..6e4fe036c799538d644827807f6159f1e456976f 100644 (file)
@@ -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.
 
index 8b71f2c3be5b69c671ea6a96aabab98c883bc9c9..de8e6ba1e4ce79fbcd1fdfa4e9d58006aaa8b32a 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2495,7 +2513,7 @@ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0};
 
 #define SWIG_name    "_libcli_smb"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2769,7 +2787,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -2779,6 +2797,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 */
@@ -2807,6 +2828,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);
index 94e30d44f11a70dcfd7b79e4c50b1d81a14d0b8d..00df5dbb22d298925498a5faa049f5781c0fea79 100644 (file)
@@ -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
index 3e7793c0c7113750ad31765e518aed8d878b548e..0a4e52bd7baff71c912d89262516cb6458cf8e2e 100644 (file)
@@ -172,11 +172,7 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
        wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
        if (!wrepl_socket) return NULL;
 
-       if (event_ctx == NULL) {
-               wrepl_socket->event.ctx = event_context_init(wrepl_socket);
-       } else {
-               wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
-       }
+       wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
        if (!wrepl_socket->event.ctx) goto failed;
 
        wrepl_socket->iconv_convenience = iconv_convenience;
index 243fc1813a0da5206363fc93c28cc421ec134afb..fac8af18b777280b2bc9afdf16f6d76751c8d88c 100644 (file)
@@ -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,10 @@ 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]
+LIBRARY_REALNAME = samba/net.$(SHLIBEXT)
 PRIVATE_DEPENDENCIES = LIBSAMBA-NET
 
-python_net_OBJ_FILES = libnet/py_net.o
+python_net_OBJ_FILES = $(libnetsrcdir)/py_net.o
index c4f9cabb1166411c0284a3a119c7c7e9fc78b9c4..1c4c1d073222d3167a59e9166546fa0dc9fdec33 100644 (file)
@@ -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);
 }
@@ -793,7 +795,7 @@ static NTSTATUS becomeDC_ldap_connect(struct libnet_BecomeDC_state *s,
        url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
        NT_STATUS_HAVE_NO_MEMORY(url);
 
-       ldap->ldb = ldb_wrap_connect(s, s->libnet->lp_ctx, url,
+       ldap->ldb = ldb_wrap_connect(s, s->libnet->event_ctx, s->libnet->lp_ctx, url,
                                     NULL,
                                     s->libnet->cred,
                                     0, NULL);
index 4549cd6e9349c05096c890d18011fa1873f35f1f..b5b28df81d128385822c2f195e68d9e7d9a8c0c2 100644 (file)
@@ -230,7 +230,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                return NT_STATUS_NO_MEMORY;
        }
 
-       remote_ldb = ldb_wrap_connect(tmp_ctx, ctx->lp_ctx, 
+       remote_ldb = ldb_wrap_connect(tmp_ctx, ctx->event_ctx, ctx->lp_ctx, 
                                      remote_ldb_url, 
                                      NULL, ctx->cred, 0, NULL);
        if (!remote_ldb) {
index c25cb4d9c56fbf3c83b762ebda33c0ff7762f177..0c4d3e5c595342720675227f4988f63a43a297f8 100644 (file)
 #include "auth/credentials/credentials.h"
 #include "auth/credentials/credentials_krb5.h"
 #include "param/param.h"
+#include "lib/events/events.h"
 
 static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
+                                          struct event_context *event_ctx,
                                           struct loadparm_context *lp_ctx,
                                            const char *keytab_name,
                                            struct netr_DELTA_ENUM *delta) 
@@ -53,12 +55,12 @@ static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
         * pass a value in here */
        cli_credentials_set_kvno(credentials, 0);
        cli_credentials_set_nt_hash(credentials, &user->ntpassword, CRED_SPECIFIED);
-       ret = cli_credentials_set_keytab_name(credentials, lp_ctx, keytab_name, CRED_SPECIFIED);
+       ret = cli_credentials_set_keytab_name(credentials, event_ctx, lp_ctx, keytab_name, CRED_SPECIFIED);
        if (ret) {
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       ret = cli_credentials_update_keytab(credentials, lp_ctx);
+       ret = cli_credentials_update_keytab(credentials, event_ctx, lp_ctx);
        if (ret) {
                return NT_STATUS_UNSUCCESSFUL;
        }
@@ -82,6 +84,7 @@ static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx,
                /* not interested in builtin users */
                if (database == SAM_DATABASE_DOMAIN) {
                        nt_status = samdump_keytab_handle_user(mem_ctx, 
+                                                              event_context_find(mem_ctx),
                                                               global_loadparm,
                                                               keytab_name,
                                                               delta);
index a60b05189b0bcff5f5c3d6ce900219ecb2f370ec..85e5dea2d72cac6215c8086474df1ba89214c443 100644 (file)
@@ -1194,6 +1194,7 @@ static NTSTATUS libnet_samsync_ldb_init(TALLOC_CTX *mem_ctx,
                ldap_url = talloc_asprintf(state, "ldap://%s", server);
                
                state->remote_ldb = ldb_wrap_connect(mem_ctx, 
+                                                    state->samsync_state->machine_net_ctx->event_ctx,
                                                     state->samsync_state->machine_net_ctx->lp_ctx, 
                                                     ldap_url, 
                                                     NULL, state->samsync_state->machine_net_ctx->cred,
@@ -1222,6 +1223,7 @@ NTSTATUS libnet_samsync_ldb(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, str
        state->trusted_domains = NULL;
 
        state->sam_ldb         = ldb_wrap_connect(mem_ctx, 
+                                                 ctx->event_ctx,
                                                  ctx->lp_ctx, 
                                                  lp_sam_url(ctx->lp_ctx), 
                                                  r->in.session_info,
index dabd23a5bee7594249327f564ec0f4b7e3673fd5..bb65de1f54be4837d24ae67df656f1d11a42a15e 100644 (file)
@@ -30,7 +30,7 @@
  * 1. Setup a CLDAP socket.
  * 2. Lookup the default Site-Name.
  */
-NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
+NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct libnet_JoinSite *r)
 {
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
@@ -53,11 +53,12 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
        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, NULL, lp_iconv_convenience(global_loadparm));
+       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_JoinSite *r)
                }
        } 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);
@@ -148,7 +149,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
        }
 
        make_nbt_name_client(&name, libnet_r->out.samr_binding->host);
-       status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, NULL);
+       status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, ctx->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string = NULL;
                talloc_free(tmp_ctx);
@@ -161,7 +162,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
        r->in.domain_dn_str = libnet_r->out.domain_dn_str;
        r->in.cldap_port = lp_cldap_port(ctx->lp_ctx);
 
-       status = libnet_FindSite(tmp_ctx, r);
+       status = libnet_FindSite(tmp_ctx, ctx, r);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string =
                        talloc_steal(libnet_r, r->out.error_string);
index 5d346ac166fdd0c0df20c31f3fe049f8e81be822..cff919018a6e0dec6e1c6de47b2296bb45fa74ce 100644 (file)
@@ -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);
 }
@@ -310,7 +311,7 @@ static NTSTATUS unbecomeDC_ldap_connect(struct libnet_UnbecomeDC_state *s)
        url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
        NT_STATUS_HAVE_NO_MEMORY(url);
 
-       s->ldap.ldb = ldb_wrap_connect(s, s->libnet->lp_ctx, url,
+       s->ldap.ldb = ldb_wrap_connect(s, s->libnet->event_ctx, s->libnet->lp_ctx, url,
                                       NULL,
                                       s->libnet->cred,
                                       0, NULL);
index 678c7a226e601ce96f1c21913bcceb500b18156f..dce7320c736061980e7340463254e0bbad73a825 100644 (file)
@@ -597,7 +597,9 @@ NTSTATUS libnet_ModifyUser(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
 struct user_info_state {
        struct libnet_context *ctx;
        const char *domain_name;
+       enum libnet_UserInfo_level level;
        const char *user_name;
+       const char *sid_string;
        struct libnet_LookupName lookup;
        struct libnet_DomainOpen domopen;
        struct libnet_rpc_userinfo userinfo;
@@ -628,7 +630,7 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
 {
        struct composite_context *c;
        struct user_info_state *s;
-       struct composite_context *lookup_req;
+       struct composite_context *lookup_req, *info_req;
        bool prereq_met = false;
 
        /* composite context allocation and setup */
@@ -644,23 +646,54 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
        s->monitor_fn = monitor;
        s->ctx = ctx;
        s->domain_name = talloc_strdup(c, r->in.domain_name);
-       s->user_name = talloc_strdup(c, r->in.user_name);
+       s->level = r->in.level;
+       switch (s->level) {
+       case USER_INFO_BY_NAME:
+               s->user_name = talloc_strdup(c, r->in.data.user_name);
+               s->sid_string = NULL;
+               break;
+       case USER_INFO_BY_SID:
+               s->user_name = NULL;
+               s->sid_string = dom_sid_string(c, r->in.data.user_sid);
+               break;
+       }
 
        /* prerequisite: make sure the domain is opened */
        prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,
                                        continue_domain_open_info, monitor);
        if (!prereq_met) return c;
 
-       /* prepare arguments for LookupName call */
-       s->lookup.in.domain_name = s->domain_name;
-       s->lookup.in.name        = s->user_name;
-
-       /* send the request */
-       lookup_req = libnet_LookupName_send(ctx, c, &s->lookup, s->monitor_fn);
-       if (composite_nomem(lookup_req, c)) return c;
+       switch (s->level) {
+       case USER_INFO_BY_NAME:
+               /* prepare arguments for LookupName call */
+               s->lookup.in.domain_name = s->domain_name;
+               s->lookup.in.name        = s->user_name;
+
+               /* send the request */
+               lookup_req = libnet_LookupName_send(ctx, c, &s->lookup,
+                                                   s->monitor_fn);
+               if (composite_nomem(lookup_req, c)) return c;
+
+               /* set the next stage */
+               composite_continue(c, lookup_req, continue_name_found, c);
+               break;
+       case USER_INFO_BY_SID:
+               /* prepare arguments for UserInfo call */
+               s->userinfo.in.domain_handle = s->ctx->samr.handle;
+               s->userinfo.in.sid = s->sid_string;
+               s->userinfo.in.level = 21;
+
+               /* send the request */
+               info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe,
+                                                   &s->userinfo,
+                                                   s->monitor_fn);
+               if (composite_nomem(info_req, c)) return c;
+
+               /* set the next stage */
+               composite_continue(c, info_req, continue_info_received, c);
+               break;
+       }
 
-       /* set the next stage */
-       composite_continue(c, lookup_req, continue_name_found, c);
        return c;
 }
 
@@ -673,7 +706,7 @@ static void continue_domain_open_info(struct composite_context *ctx)
 {
        struct composite_context *c;
        struct user_info_state *s;
-       struct composite_context *lookup_req;
+       struct composite_context *lookup_req, *info_req;
        struct monitor_msg msg;
 
        c = talloc_get_type(ctx->async.private_data, struct composite_context);
@@ -686,16 +719,36 @@ static void continue_domain_open_info(struct composite_context *ctx)
        /* send monitor message */
        if (s->monitor_fn) s->monitor_fn(&msg);
 
-       /* prepare arguments for LookupName call */
-       s->lookup.in.domain_name = s->domain_name;
-       s->lookup.in.name        = s->user_name;
-       
-       /* send the request */
-       lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
-       if (composite_nomem(lookup_req, c)) return;
-
-       /* set the next stage */
-       composite_continue(c, lookup_req, continue_name_found, c);
+       switch (s->level) {
+       case USER_INFO_BY_NAME:
+               /* prepare arguments for LookupName call */
+               s->lookup.in.domain_name = s->domain_name;
+               s->lookup.in.name        = s->user_name;
+
+               /* send the request */
+               lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
+               if (composite_nomem(lookup_req, c)) return;
+
+               /* set the next stage */
+               composite_continue(c, lookup_req, continue_name_found, c);
+               break;
+
+       case USER_INFO_BY_SID:
+               /* prepare arguments for UserInfo call */
+               s->userinfo.in.domain_handle = s->ctx->samr.handle;
+               s->userinfo.in.sid = s->sid_string;
+               s->userinfo.in.level = 21;
+
+               /* send the request */
+               info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe,
+                                                   &s->userinfo,
+                                                   s->monitor_fn);
+               if (composite_nomem(info_req, c)) return;
+
+               /* set the next stage */
+               composite_continue(c, info_req, continue_info_received, c);
+               break;
+       }
 }
 
 
index 94aa38464f649eaf982599d7fe97132ce9381e19..7095160004541c6da79d4087bb95035559c7abf5 100644 (file)
@@ -99,11 +99,19 @@ struct libnet_ModifyUser {
                }                                       \
        }
 
+enum libnet_UserInfo_level {
+       USER_INFO_BY_NAME=0,
+       USER_INFO_BY_SID
+};
 
 struct libnet_UserInfo {
        struct {
-               const char *user_name;
                const char *domain_name;
+               enum libnet_UserInfo_level level;
+               union {
+                       const char *user_name;
+                       const struct dom_sid *user_sid;
+               } data;
        } in;
        struct {
                struct dom_sid *user_sid;
@@ -123,7 +131,6 @@ struct libnet_UserInfo {
                struct timeval *last_logoff;
                struct timeval *last_password_change;
                uint32_t acct_flags;
-               
                const char *error_string;
        } out;
 };
index 1cc63a3fb0cbe8404c92be131d0db2985675252d..56a8ebe034c386467feacfb176678a711f619c58 100644 (file)
@@ -70,6 +70,7 @@ struct vampire_state {
        const char *targetdir;
 
        struct loadparm_context *lp_ctx;
+       struct event_context *event_ctx;
 };
 
 static NTSTATUS vampire_prepare_db(void *private_data,
@@ -335,7 +336,7 @@ static NTSTATUS vampire_apply_schema(struct vampire_state *s,
        s->schema = NULL;
 
        DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema\n"));
-       s->ldb = samdb_connect(s, s->lp_ctx, 
+       s->ldb = samdb_connect(s, s->event_ctx, s->lp_ctx, 
                               system_session(s, s->lp_ctx));
        if (!s->ldb) {
                DEBUG(0,("Failed to reopen sam.ldb\n"));
@@ -569,7 +570,6 @@ NTSTATUS libnet_Vampire(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
        struct libnet_JoinDomain *join;
        struct libnet_set_join_secrets *set_secrets;
        struct libnet_BecomeDC b;
-       struct libnet_UnbecomeDC u;
        struct vampire_state *s;
        struct ldb_message *msg;
        int ldb_ret;
@@ -581,12 +581,13 @@ NTSTATUS libnet_Vampire(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
        
        r->out.error_string = NULL;
 
-       s = talloc_zero(mem_ctx , struct vampire_state);
+       s = talloc_zero(mem_ctx, struct vampire_state);
        if (!s) {
                return NT_STATUS_NO_MEMORY;
        }
 
        s->lp_ctx = ctx->lp_ctx;
+       s->event_ctx = ctx->event_ctx;
 
        join = talloc_zero(s, struct libnet_JoinDomain);
        if (!join) {
index cf81d8070dc239622a995b25339d8c1ee5611bd8..443da299c7ca7d915c603d4321a96deb10008bcb 100644 (file)
@@ -71,8 +71,11 @@ static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
        return result;
 }
 
+static char py_net_join_doc[] = "join(domain_name, netbios_name, join_type, level) -> (join_password, domain_sid, domain_name)\n\n" \
+"Join the domain with the specified name.";
+
 static struct PyMethodDef net_methods[] = {
-       {"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS},
+       {"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc},
        {NULL }
 };
 
index 11a320a583bf2ac737dde45bba2103b536970c9b..c7cbf2766731c804f16d7bda4b31738400512950 100644 (file)
@@ -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,211 +592,131 @@ 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)
 
 
-[MODULE::RPC_EJS_ECHO]
-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
-
-[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
-
-[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
-
-[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
-
-[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
-
-[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
-
-[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
-
-[MODULE::RPC_EJS_SPOOLSS]
-INIT_FUNCTION = ejs_init_spoolss
-SUBSYSTEM = smbcalls
-ENABLE = NO
-PRIVATE_DEPENDENCIES = dcerpc NDR_SPOOLSS EJSRPC
-
-RPC_EJS_SPOOLSS_OBJ_FILES = librpc/gen_ndr/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
-
-[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
-
-[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
-
-[MODULE::RPC_EJS_WINREG]
-INIT_FUNCTION = ejs_init_winreg
-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
-
-[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
-
-[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
-
-[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
-
-[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
-
 [PYTHON::swig_dcerpc]
-SWIG_FILE = rpc/dcerpc.i
+LIBRARY_REALNAME = samba/dcerpc/_dcerpc.$(SHLIBEXT)
 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
+
+$(eval $(call python_py_module_template,samba/dcerpc/__init__.py,$(dcerpcsrcdir)/dcerpc.py))
+
+$(swig_dcerpc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
 
 [PYTHON::python_echo]
-PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC
+LIBRARY_REALNAME = samba/dcerpc/echo.$(SHLIBEXT)
+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
+LIBRARY_REALNAME = samba/dcerpc/winreg.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc PYTALLOC param swig_credentials python_dcerpc_misc python_lsa
 
-python_winreg_OBJ_FILES = librpc/gen_ndr/py_winreg.o
+python_winreg_OBJ_FILES = $(gen_ndrsrcdir)/py_winreg.o
 
 [PYTHON::python_dcerpc_misc]
+LIBRARY_REALNAME = samba/dcerpc/misc.$(SHLIBEXT)
 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
+LIBRARY_REALNAME = samba/dcerpc/initshutdown.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials python_lsa python_dcerpc_security
 
-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
+LIBRARY_REALNAME = samba/dcerpc/epmapper.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES =  dcerpc PYTALLOC param swig_credentials python_dcerpc_misc
 
-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
+LIBRARY_REALNAME = samba/dcerpc/mgmt.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials dcerpc python_dcerpc_misc
 
-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
+LIBRARY_REALNAME = samba/dcerpc/atsvc.$(SHLIBEXT)
+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
+LIBRARY_REALNAME = samba/dcerpc/samr.$(SHLIBEXT)
+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
+LIBRARY_REALNAME = samba/dcerpc/svcctl.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials python_dcerpc_misc
 
-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
+LIBRARY_REALNAME = samba/dcerpc/lsa.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials python_dcerpc_security
 
-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
+LIBRARY_REALNAME = samba/dcerpc/wkssvc.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials python_lsa python_dcerpc_security
 
-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
+LIBRARY_REALNAME = samba/dcerpc/dfs.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials python_dcerpc_misc
 
-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
+LIBRARY_REALNAME = samba/dcerpc/unixinfo.$(SHLIBEXT)
+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
+LIBRARY_REALNAME = samba/dcerpc/drsuapi.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc_security
 
-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
+LIBRARY_REALNAME = samba/dcerpc/security.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = PYTALLOC python_dcerpc_misc
+
+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
+
 
-python_dcerpc_security_OBJ_FILES = librpc/gen_ndr/py_security.o
index d5bfe0b2ece2b2dc27ec0e5b6e0422e9b2112b90..e630ee4f61f398c3f0ec57ed1c80c2bcb7471e3a 100755 (executable)
@@ -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) {
index b2c67542f5188fba9ae8d9d8f323739771d61ac9..e228d85c464df93bd9522659c1c6142f330b7d69 100644 (file)
@@ -116,6 +116,7 @@ interface dcerpc
                uint16 context_id;
                uint8 cancel_count;
                uint32 status;
+               [flag(NDR_REMAINING)] DATA_BLOB _pad;
        } dcerpc_fault;
 
        /* the auth types we know about */
index 96525716689fd1204374dcda98a07661d620a870..2f48287233cf882b59dd811d5fb4f5cc9b16f61a 100644 (file)
@@ -849,7 +849,7 @@ interface drsuapi
                [case(1)] drsuapi_DsNameCtr1 *ctr1;
        } drsuapi_DsNameCtr;
 
-       [todo] WERROR drsuapi_DsCrackNames(
+       WERROR drsuapi_DsCrackNames(
                [in] policy_handle *bind_handle,
                [in, out] int32 level,
                [in,switch_is(level)] drsuapi_DsNameRequest req,
index aa8836088258342a45240273f6c9189bf5166043..783f04eb4214d2cdf129718585a4bf1b3aa68b07 100644 (file)
@@ -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,108 +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_sid(&sid, ndr->flags))] uint32 sid_size;
-               [flag(NDR_ALIGN4)] DATA_BLOB _pad2;
-               dom_sid          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;
@@ -507,86 +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_sid(&sid, ndr->flags))] uint32 sid_size;
-               [flag(NDR_ALIGN4)]   DATA_BLOB _pad;
-               dom_sid              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                   */
index 295b70a2a1dddc89550e6290a3511e2434c26b02..ab137faf2798c85bdd671311cc4e75dba2801ec2 100644 (file)
@@ -9,5 +9,5 @@
 {
        /*****************/
        /* Function 0x00 */
-       WERROR policyagent_Dummy();
+       [todo] WERROR policyagent_Dummy();
 }
index 753fad85cf96ee009877fcab00ddcc71d2f38aa9..314846c53f29b2ca00a9c8d1f082396ae5f883a1 100644 (file)
@@ -22,6 +22,9 @@ cpp_quote("#define dom_sid2 dom_sid")
 /* same struct as dom_sid but inside a 28 bytes fixed buffer in NDR */
 cpp_quote("#define dom_sid28 dom_sid")
 
+/* same struct as dom_sid but in a variable byte buffer, which is maybe empty in NDR */
+cpp_quote("#define dom_sid0 dom_sid")
+
 [
        pointer_default(unique)
 ]
index 7e73baee7d77f38dd9ed22efaa788aaa2ef5a543..2010d51ce10fc2562ed6b64f44cf47ad3937299d 100644 (file)
@@ -31,8 +31,14 @@ interface xattr
                NTTIME change_time;
        } xattr_DosInfo1;
 
-       const int XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME = 0x1;
+/*
+       We use xattrDosInfo1 again when we store values.
+       Because the sticky write time is now stored in the opendb
+       and xattr_DosInfo2Old is only present to parse existing
+       values from disk.
 
+       const int XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME = 0x1;
+*/
        typedef struct {
                uint32     flags;
                uint32     attrib;
@@ -43,11 +49,11 @@ interface xattr
                NTTIME     change_time;
                NTTIME     write_time; /* only used when sticky write time is set */
                utf8string name;
-       } xattr_DosInfo2;
+       } xattr_DosInfo2Old;
 
        typedef [switch_type(uint16)] union {
                [case(1)] xattr_DosInfo1 info1;
-               [case(2)] xattr_DosInfo2 info2;
+               [case(2)] xattr_DosInfo2Old oldinfo2;
        } xattr_DosInfo;
 
        typedef [public] struct {
index 2439c386db81fe1e3fd3796abd42c9f7afe9e39c..b719be2bab68c064347585c2e6ddcd05050bc1b7 100644 (file)
@@ -336,6 +336,10 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
 enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid);
 void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
 size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags);
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid);
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid);
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags);
 void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip);
 void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
 enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn);
index 93a177f94e5f127698e14652cbbe2a02edd53fbd..1d2b47c850b4e246c47f6ad07723fad79c35903b 100644 (file)
@@ -196,7 +196,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, u
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
 {
-       intptr_t h;
+       uintptr_t h;
        NDR_PULL_ALIGN(ndr, sizeof(h));
        NDR_PULL_NEED_BYTES(ndr, sizeof(h));
        memcpy(&h, ndr->data+ndr->offset, sizeof(h));
@@ -393,7 +393,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, u
 */
 _PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
 {
-       intptr_t h = (intptr_t)v;
+       uintptr_t h = (intptr_t)v;
        NDR_PUSH_ALIGN(ndr, sizeof(h));
        NDR_PUSH_NEED_BYTES(ndr, sizeof(h));
        memcpy(ndr->data+ndr->offset, &h, sizeof(h));
index 5a0178bd25bbee897b5b8731060b0821ce5b2b6e..1256d7dd2d26769948ceaaef7ceeada42fbb351c 100644 (file)
@@ -48,6 +48,11 @@ size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags)
        return 8 + 4*sid->num_auths;
 }
 
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags)
+{
+       return ndr_size_dom_sid28(sid, flags);
+}
+
 /*
   return the wire size of a security_ace
 */
@@ -128,6 +133,11 @@ void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct d
        ndr_print_dom_sid(ndr, name, sid);
 }
 
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
+{
+       ndr_print_dom_sid(ndr, name, sid);
+}
+
 
 /*
   parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field
@@ -225,3 +235,44 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
        return NDR_ERR_SUCCESS;
 }
 
+/*
+  parse a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid)
+{
+       if (!(ndr_flags & NDR_SCALARS)) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       if (ndr->data_size == ndr->offset) {
+               ZERO_STRUCTP(sid);
+               return NDR_ERR_SUCCESS;
+       }
+
+       return ndr_pull_dom_sid(ndr, ndr_flags, sid);
+}
+
+/*
+  push a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid)
+{
+       struct dom_sid zero_sid;
+
+       if (!(ndr_flags & NDR_SCALARS)) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       if (!sid) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       ZERO_STRUCT(zero_sid);
+
+       if (memcmp(&zero_sid, sid, sizeof(zero_sid)) == 0) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       return ndr_push_dom_sid(ndr, ndr_flags, sid);
+}
+
index 5e32f6f5bf21ec795cf948e4ca7a3fe9ff7c6a04..4758189d3b38f3cf42d9e1958702ce8d4d2e993b 100644 (file)
@@ -67,22 +67,15 @@ static struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       if (ev == NULL) {
-               ev = event_context_init(c);
-               if (ev == NULL) {
-                       talloc_free(c);
-                       return NULL;
-               }
-       }
-
        c->iconv_convenience = talloc_reference(c, ic);
 
-       c->event_ctx = ev;
-       
-       if (!talloc_reference(c, ev)) {
+       c->event_ctx = talloc_reference(c, ev);
+
+       if (c->event_ctx == NULL) {
                talloc_free(c);
                return NULL;
        }
+
        c->call_id = 1;
        c->security_state.auth_info = NULL;
        c->security_state.session_key = dcerpc_generic_session_key;
index 7e4d82d7c42b308cd0f0a4ceed26dd7d236a6cf6..db5b95cee8e0918e293573a0002a094326764b8d 100644 (file)
@@ -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.
 
@@ -57,8 +57,6 @@ def _swig_setattr_nondynamic_method(set):
     return set_attr
 
 
-import credentials
-import param
 pipe_connect = _dcerpc.pipe_connect
 dcerpc_server_name = _dcerpc.dcerpc_server_name
 
index cc7f2ddbaa29b751f00c7667784bc7accbcbce07..a22cad9a4a561bf78687663f6418df96a150e405 100644 (file)
@@ -717,12 +717,6 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent
        struct pipe_connect_state *s;
        struct event_context *new_ev = NULL;
 
-       if (ev == NULL) {
-               new_ev = event_context_init(parent_ctx);
-               if (new_ev == NULL) return NULL;
-               ev = new_ev;
-       }
-
        /* composite context allocation and setup */
        c = composite_create(parent_ctx, ev);
        if (c == NULL) {
@@ -844,21 +838,12 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_c
        struct pipe_conn_state *s;
        struct dcerpc_binding *b;
        struct composite_context *pipe_conn_req;
-       struct event_context *new_ev = NULL;
-
-       if (ev == NULL) {
-               new_ev = event_context_init(parent_ctx);
-               if (new_ev == NULL) return NULL;
-               ev = new_ev;
-       }
 
        /* composite context allocation and setup */
        c = composite_create(parent_ctx, ev);
        if (c == NULL) {
-               talloc_free(new_ev);
                return NULL;
        }
-       talloc_steal(c, new_ev);
 
        s = talloc_zero(c, struct pipe_conn_state);
        if (composite_nomem(s, c)) return c;
index 8adca4caba5768f95f822323816ddaed0d0b5d91..4767165fba8dd62596f9d3689fa763776ec62a48 100644 (file)
@@ -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;
index 469c83788c99b8c8ce571bbf2c4deb03472509b5..71c6d5f2cc85d08e79ca65f972b47d1720d0876a 100644 (file)
@@ -209,32 +209,20 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
        struct epm_map_binding_state *s;
        struct composite_context *pipe_connect_req;
        struct cli_credentials *anon_creds;
-       struct event_context *new_ev = NULL;
 
        NTSTATUS status;
        struct dcerpc_binding *epmapper_binding;
        int i;
 
-       /* Try to find event context in memory context in case passed
-        * event_context (argument) was NULL. If there's none, just
-        * create a new one.
-        */
        if (ev == NULL) {
-               ev = event_context_find(mem_ctx);
-               if (ev == NULL) {
-                       new_ev = event_context_init(mem_ctx);
-                       if (new_ev == NULL) return NULL;
-                       ev = new_ev;
-               }
+               return NULL;
        }
 
        /* composite context allocation and setup */
        c = composite_create(mem_ctx, ev);
        if (c == NULL) {
-               talloc_free(new_ev);
                return NULL;
        }
-       talloc_steal(c, new_ev);
 
        s = talloc_zero(c, struct epm_map_binding_state);
        if (composite_nomem(s, c)) return c;
@@ -245,7 +233,6 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
 
        /* anonymous credentials for rpc connection used to get endpoint mapping */
        anon_creds = cli_credentials_init(mem_ctx);
-       cli_credentials_set_event_context(anon_creds, ev);
        cli_credentials_set_anonymous(anon_creds);
 
        /*
index bae41c2c22848b0db9bf9042ff013f3a53e5b4a1..ff5cdbd390dd4a06fadb47a98ffe503fc7da1993 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2510,7 +2528,7 @@ static swig_module_info swig_module = {swig_types, 21, 0, 0, 0, 0};
 
 #define SWIG_name    "_dcerpc"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2912,7 +2930,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -2922,6 +2940,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 */
@@ -2950,6 +2971,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);
similarity index 51%
rename from source/script/build_idl.sh
rename to source/librpc/scripts/build_idl.sh
index ea0cb78b0ecac90fdabc61bb8a696e21db3ee152..3f13b64a2e9117cfcc450838d181714f5d674524 100755 (executable)
@@ -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 --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
index b8364aca5a3ff35cf9a252db97d429e30e9d1ae8..5e31044c096ec8fcfa0dbcc487323bcd4e71ca46 100644 (file)
@@ -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
index cb2b47d15e9e1302b57f69da62153b191c810036..b17fd4ce521a93ae23285cceda3ebbc3896abf41 100644 (file)
@@ -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 = service
+SUBSYSTEM = smbd
 PRIVATE_DEPENDENCIES = NBT_SERVER process_model
 
 service_nbtd_OBJ_FILES = \
-               nbt_server/nbt_server.o
+               $(nbt_serversrcdir)/nbt_server.o
index 46bfaa9381fbc2f6be3e5d423f45d84392ee195a..5e263a585471314759336effe26a2caedc519d47 100644 (file)
@@ -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
 #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 */
@@ -54,12 +56,17 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
                return;
        }
 
-       samctx = samdb_connect(packet, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->lp_ctx));
+       samctx = samdb_connect(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx));
        if (samctx == NULL) {
                DEBUG(2,("Unable to open sam in getdc reply\n"));
                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;
@@ -125,96 +126,36 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
                return;
        }
 
-       samctx = samdb_connect(packet, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->lp_ctx));
+       samctx = samdb_connect(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx));
        if (samctx == NULL) {
                DEBUG(2,("Unable to open sam in getdc reply\n"));
                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", 
index 205a5442092adea2eefec67eb02a38a5e0f8d656..277b64741d1890adb7e8f1c706958e9e48a9ad37 100644 (file)
@@ -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 }
 };
 
index 8f2f7fc2c2e98de414f8cf4cc331501748113213..8f1f74afcf2bfe1d391c077fb78d8ac7e60b7eb7 100644 (file)
@@ -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)));
index 2ac1fb4ef3fb2cc766b7507269d1998261e56185..832bbe0103924f30797face6553fee1f6125146c 100644 (file)
@@ -66,7 +66,7 @@ static void nbtd_task_init(struct task_server *task)
                return;
        }
 
-       nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->lp_ctx, anonymous_session(nbtsrv, task->lp_ctx));
+       nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->event_ctx, task->lp_ctx, anonymous_session(nbtsrv, task->event_ctx, task->lp_ctx));
        if (nbtsrv->sam_ctx == NULL) {
                task_server_terminate(task, "nbtd failed to open samdb");
                return;
index 7de5bba468d30289ac426440c8e071dd33c86299..c84b01f2b20571d667162ab27383e5243881f45a 100644 (file)
@@ -945,7 +945,8 @@ failed:
        return NBT_RCODE_SVR;
 }
 
-static bool winsdb_check_or_add_module_list(struct loadparm_context *lp_ctx, struct winsdb_handle *h)
+static bool winsdb_check_or_add_module_list(struct event_context *ev_ctx, 
+                                           struct loadparm_context *lp_ctx, struct winsdb_handle *h)
 {
        int trans;
        int ret;
@@ -992,7 +993,7 @@ static bool winsdb_check_or_add_module_list(struct loadparm_context *lp_ctx, str
                flags |= LDB_FLG_NOSYNC;
        }
 
-       h->ldb = ldb_wrap_connect(h, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
+       h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
                                  NULL, NULL, flags, NULL);
        if (!h->ldb) goto failed;
 
@@ -1010,7 +1011,9 @@ failed:
        return false;
 }
 
-struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, 
+                                    struct event_context *ev_ctx,
+                                    struct loadparm_context *lp_ctx,
                                     const char *owner,
                                     enum winsdb_handle_caller caller)
 {
@@ -1026,7 +1029,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_contex
                flags |= LDB_FLG_NOSYNC;
        }
 
-       h->ldb = ldb_wrap_connect(h, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
+       h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
                                  NULL, NULL, flags, NULL);
        if (!h->ldb) goto failed;       
 
@@ -1037,7 +1040,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_contex
        if (!h->local_owner) goto failed;
 
        /* make sure the module list is available and used */
-       ret = winsdb_check_or_add_module_list(lp_ctx, h);
+       ret = winsdb_check_or_add_module_list(ev_ctx, lp_ctx, h);
        if (!ret) goto failed;
 
        ldb_err = ldb_set_opaque(h->ldb, "winsdb_handle", h);
index f116c458981723e391d6d4d78068e75d1d06afa9..f8901ce09d2943bcb3b3747a56d30f2f0184b5a1 100644 (file)
@@ -985,7 +985,8 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
                owner = iface_n_ip(ifaces, 0);
        }
 
-       nbtsrv->winssrv->wins_db     = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->lp_ctx,
+       nbtsrv->winssrv->wins_db     = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->event_ctx, 
+                                                     nbtsrv->task->lp_ctx,
                                                      owner, WINSDB_HANDLE_CALLER_NBTD);
        if (!nbtsrv->winssrv->wins_db) {
                return NT_STATUS_INTERNAL_DB_ERROR;
index a0ceff00331daca062a1c1e3253c9a4e43e51b6c..e8b9600882f1715f7cbbf19fb85dcd251f2a76ec 100644 (file)
@@ -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
index dda4c2944476e1a672c5eba808a705423adeeb7a..71b3bc05a8af8b2d8e9fe22c77485e3128de9353 100644 (file)
@@ -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)))
index 3e95c3c5e1c0cca0e6a52eac8ea55d389e38303a..7138a2fdfba81a0a5912dd62b4ad76021e6a6a75 100644 (file)
@@ -220,6 +220,7 @@ struct ntptr_ops {
 struct ntptr_context {
        const struct ntptr_ops *ops;
        void *private_data;
+       struct event_context *ev_ctx;
        struct loadparm_context *lp_ctx;
 };
 
index 0000337cb0f22d9d7f5a6de35b424c5b8105cf80..a7004be90ba289a25f8e6e0ca912be4870098da1 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "includes.h"
 #include "ntptr/ntptr.h"
-#include "build.h"
 #include "param/param.h"
 
 /* the list of currently registered NTPTR backends */
@@ -120,7 +119,8 @@ const struct ntptr_critical_sizes *ntptr_interface_version(void)
 /*
   create a ntptr_context with a specified NTPTR backend
 */
-NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx,
+                           struct loadparm_context *lp_ctx,
                            const char *providor, struct ntptr_context **_ntptr)
 {
        NTSTATUS status;
@@ -134,6 +134,7 @@ NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx
        NT_STATUS_HAVE_NO_MEMORY(ntptr);
        ntptr->private_data     = NULL;
        ntptr->ops              = ntptr_backend_byname(providor);
+       ntptr->ev_ctx           = ev_ctx;
        ntptr->lp_ctx           = lp_ctx;
 
        if (!ntptr->ops) {
index 47f3c0ddf0e326c9143537c2c847996ce64abacc..3573fac3eadcfbd94b272cc2346260bddd34f72d 100644 (file)
@@ -42,9 +42,9 @@
   connect to the SPOOLSS database
   return a ldb_context pointer on success, or NULL on failure
  */
-static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx, struct loadparm_context *lp_ctx)
 {
-       return ldb_wrap_connect(mem_ctx, lp_ctx, lp_spoolss_url(lp_ctx), system_session(mem_ctx, lp_ctx), 
+       return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, lp_spoolss_url(lp_ctx), system_session(mem_ctx, lp_ctx), 
                                NULL, 0, NULL);
 }
 
@@ -87,7 +87,7 @@ static int sptr_db_search(struct ldb_context *ldb,
 
 static NTSTATUS sptr_init_context(struct ntptr_context *ntptr)
 {
-       struct ldb_context *sptr_db = sptr_db_connect(ntptr, ntptr->lp_ctx);
+       struct ldb_context *sptr_db = sptr_db_connect(ntptr, ntptr->ev_ctx, ntptr->lp_ctx);
        NT_STATUS_HAVE_NO_MEMORY(sptr_db);
 
        ntptr->private_data = sptr_db;
index 2feb1a0efe33a3a8379dcce1a032987e14aa55b9..2b6126873372dfe03fa21a57f6e47a3425ebabfe 100644 (file)
@@ -171,7 +171,6 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
                if (!credentials) {
                        return NT_STATUS_NO_MEMORY;
                }
-               cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
                cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
                cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
                if (domain) {
@@ -181,7 +180,6 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
        } else if (machine_account) {
                DEBUG(5, ("CIFS backend: Using machine account\n"));
                credentials = cli_credentials_init(private);
-               cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
                cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
                if (domain) {
                        cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
index c66257b73f73ba87eb036f3c7749025d90ade0a9..1fe093bb69d5d44b124e9a41e42871d354309dc2 100644 (file)
@@ -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)))
 
index 23aa3fb6687290de637a9941ff64d4b6eb9357af..9055d6ece330304cde63b80a0da369b8d35f9fcc 100644 (file)
@@ -93,6 +93,10 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
                return NULL;
        }
 
+       if (ev == NULL) {
+               return NULL;
+       }
+
        notify = talloc(mem_ctx, struct notify_context);
        if (notify == NULL) {
                return NULL;
index 93cbf64d8f0b4dbed570cf5461a0717888bf8e8c..bf34c4082abec6ad54c215725703a90839ae1101 100644 (file)
@@ -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
 ################################################
index faf48705c466cc27630c809fe755de68e33939f5..4969f1a79100f766ef2763be439ee1da45a151dd 100644 (file)
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "libcli/raw/interfaces.h"
 #include "libcli/rap/rap.h"
+#include "events/events.h"
 #include "ntvfs/ipc/proto.h"
 #include "librpc/ndr/libndr.h"
 #include "param/param.h"
@@ -100,11 +101,14 @@ struct rap_call {
 
        struct ndr_pull *ndr_pull_param;
        struct ndr_pull *ndr_pull_data;
+
+       struct event_context *event_ctx;
 };
 
 #define RAPNDR_FLAGS (LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
 
 static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
+                                        struct event_context *ev_ctx,
                                         struct loadparm_context *lp_ctx,
                                         struct smb_trans2 *trans)
 {
@@ -118,6 +122,7 @@ static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
        ZERO_STRUCTP(call);
 
        call->lp_ctx = talloc_reference(call, lp_ctx);
+       call->event_ctx = ev_ctx;
 
        call->mem_ctx = mem_ctx;
 
@@ -271,7 +276,7 @@ static NTSTATUS _rap_netshareenum(struct rap_call *call)
                break;
        }
 
-       result = rap_netshareenum(call, call->lp_ctx, &r);
+       result = rap_netshareenum(call, call->event_ctx, call->lp_ctx, &r);
 
        if (!NT_STATUS_IS_OK(result))
                return result;
@@ -430,7 +435,7 @@ static const struct
        {NULL, -1, api_Unsupported}
 };
 
-NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, struct loadparm_context *lp_ctx,
                      struct smb_trans2 *trans)
 {
        int i;
@@ -440,7 +445,7 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        struct ndr_push *final_param;
        struct ndr_push *final_data;
 
-       call = new_rap_srv_call(mem_ctx, lp_ctx, trans);
+       call = new_rap_srv_call(mem_ctx, event_ctx, lp_ctx, trans);
 
        if (call == NULL)
                return NT_STATUS_NO_MEMORY;
index 633f0bf36e3abb7d27a14db55da2fa2bd0204712..d9fb7e21b23fef2567fe97551cb7b5d188a7247c 100644 (file)
@@ -29,6 +29,7 @@
  * idea. */
 
 NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
+                         struct event_context *event_ctx,
                          struct loadparm_context *lp_ctx,
                          struct rap_NetShareEnum *r)
 {
@@ -42,7 +43,7 @@ NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
        r->out.available = 0;
        r->out.info = NULL;
 
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), event_ctx, lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return nterr;
        }
index 92f0eadae1de74379a97b70b11f3cf6030509bab..ea7b54ae6ac29a4228119df81d3db141b057bb7f 100644 (file)
@@ -805,7 +805,7 @@ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs,
        NTSTATUS status;
 
        if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN"))
-               return ipc_rap_call(req, ntvfs->ctx->lp_ctx, trans);
+               return ipc_rap_call(req, ntvfs->ctx->event_ctx, ntvfs->ctx->lp_ctx, trans);
 
                if (trans->in.setup_count != 2) {
                return NT_STATUS_INVALID_PARAMETER;
index 8f574fa96bb821ab594c8952fc98d7446bae75eb..6de13e4a0a0446cec572b85b551fe70534bb86aa 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "includes.h"
 #include "lib/util/dlinklist.h"
-#include "build.h"
 #include "ntvfs/ntvfs.h"
 #include "param/param.h"
 
@@ -206,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);
index fee3269eaf3032bfe240fcabcc873df4efdb78cf..62a142740536086206f475287d929270ba8bfcae 100644 (file)
@@ -208,7 +208,21 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
 
        case RAW_OPEN_SMB2:
                io->smb2.out.file.ntvfs         = io2->generic.out.file.ntvfs;
-               io->smb2.out.oplock_level       = 0;
+               switch (io2->generic.out.oplock_level) {
+               case BATCH_OPLOCK_RETURN:
+                       io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+                       break;
+               case EXCLUSIVE_OPLOCK_RETURN:
+                       io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_EXCLUSIVE;
+                       break;
+               case LEVEL_II_OPLOCK_RETURN:
+                       io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_II;
+                       break;
+               default:
+                       io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_NONE;
+                       break;
+               }
+               io->smb2.out.reserved           = 0;
                io->smb2.out.create_action      = io2->generic.out.create_action;
                io->smb2.out.create_time        = io2->generic.out.create_time;
                io->smb2.out.access_time        = io2->generic.out.access_time;
@@ -484,7 +498,18 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                status = ntvfs->ops->open(ntvfs, req, io2);
                break;
        case RAW_OPEN_SMB2:
-               io2->generic.in.flags           = 0;
+               switch (io->smb2.in.oplock_level) {
+               case SMB2_OPLOCK_LEVEL_BATCH:
+                       io2->generic.in.flags = NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK |
+                                               NTCREATEX_FLAGS_REQUEST_OPLOCK;
+                       break;
+               case SMB2_OPLOCK_LEVEL_EXCLUSIVE:
+                       io2->generic.in.flags = NTCREATEX_FLAGS_REQUEST_OPLOCK;
+                       break;
+               default:
+                       io2->generic.in.flags = 0;
+                       break;
+               }
                io2->generic.in.root_fid        = 0;
                io2->generic.in.access_mask     = io->smb2.in.desired_access;
                io2->generic.in.alloc_size      = 0;
@@ -986,37 +1011,72 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
                locks->count = lck->unlock.in.count;
                break;
 
-       case RAW_LOCK_SMB2:
-               if (lck->smb2.in.unknown1 != 1) {
+       case RAW_LOCK_SMB2: {
+               /* this is only approximate! We need to change the
+                  generic structure to fix this properly */
+               int i;
+               if (lck->smb2.in.lock_count < 1) {
                        return NT_STATUS_INVALID_PARAMETER;
                }
 
                lck2->generic.level = RAW_LOCK_GENERIC;
                lck2->generic.in.file.ntvfs= lck->smb2.in.file.ntvfs;
-               if (lck->smb2.in.flags & SMB2_LOCK_FLAG_EXCLUSIV) {
-                       lck2->generic.in.mode = 0;
-               } else {
-                       lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
+               lck2->generic.in.timeout = UINT32_MAX;
+               lck2->generic.in.mode = 0;
+               lck2->generic.in.lock_cnt = 0;
+               lck2->generic.in.ulock_cnt = 0;
+               lck2->generic.in.locks = talloc_zero_array(lck2, struct smb_lock_entry, 
+                                                          lck->smb2.in.lock_count);
+               if (lck2->generic.in.locks == NULL) {
+                       return NT_STATUS_NO_MEMORY;
                }
-               if (lck->smb2.in.flags & SMB2_LOCK_FLAG_NO_PENDING) {
-                       lck2->generic.in.timeout = 0;
-               } else {
-                       lck2->generic.in.timeout = UINT32_MAX;
+               for (i=0;i<lck->smb2.in.lock_count;i++) {
+                       if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) {
+                               int j = lck2->generic.in.ulock_cnt;
+                               lck2->generic.in.ulock_cnt++;
+                               lck2->generic.in.locks[j].pid = 0;
+                               lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
+                               lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
+                               lck2->generic.in.locks[j].pid = 0;
+                       }
                }
-               if (lck->smb2.in.flags & SMB2_LOCK_FLAG_UNLOCK) {
-                       lck2->generic.in.ulock_cnt = 1;
-                       lck2->generic.in.lock_cnt = 0;
-               } else {
-                       lck2->generic.in.ulock_cnt = 0;
-                       lck2->generic.in.lock_cnt = 1;
+               for (i=0;i<lck->smb2.in.lock_count;i++) {
+                       if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) {
+                               int j = lck2->generic.in.ulock_cnt + 
+                                       lck2->generic.in.lock_cnt;
+                               lck2->generic.in.lock_cnt++;
+                               lck2->generic.in.locks[j].pid = 0;
+                               lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
+                               lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
+                               lck2->generic.in.locks[j].pid = 0;
+                               if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) {
+                                       lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
+                               }
+                               if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) {
+                                       lck2->generic.in.timeout = 0;
+                               }
+                       }
                }
-               lck2->generic.in.locks = locks;
-               locks->pid = 0;
-               locks->offset = lck->smb2.in.offset;
-               locks->count = lck->smb2.in.count;
+               /* initialize output value */
+               lck->smb2.out.reserved = 0;
+               break;
+       }
+
+       case RAW_LOCK_SMB2_BREAK:
+               lck2->generic.level             = RAW_LOCK_GENERIC;
+               lck2->generic.in.file.ntvfs     = lck->smb2_break.in.file.ntvfs;
+               lck2->generic.in.mode           = LOCKING_ANDX_OPLOCK_RELEASE |
+                                                 ((lck->smb2_break.in.oplock_level << 8) & 0xFF00);
+               lck2->generic.in.timeout        = 0;
+               lck2->generic.in.ulock_cnt      = 0;
+               lck2->generic.in.lock_cnt       = 0;
+               lck2->generic.in.locks          = NULL;
 
                /* initialize output value */
-               lck->smb2.out.unknown1 = 0;
+               lck->smb2_break.out.oplock_level= lck->smb2_break.in.oplock_level;
+               lck->smb2_break.out.reserved    = lck->smb2_break.in.reserved;
+               lck->smb2_break.out.reserved2   = lck->smb2_break.in.reserved2;
+               lck->smb2_break.out.file        = lck->smb2_break.in.file;
                break;
        }
 
@@ -1216,6 +1276,11 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs,
                rd->smb2.out.data.length= rd2->generic.out.nread;
                rd->smb2.out.remaining  = 0;
                rd->smb2.out.reserved   = 0;
+               if (NT_STATUS_IS_OK(status) &&
+                   rd->smb2.out.data.length == 0 &&
+                   rd->smb2.in.length != 0) {
+                       status = NT_STATUS_END_OF_FILE;
+               }
                break;
        default:
                return NT_STATUS_INVALID_LEVEL;
index 865a0ffd4a3941d67b01eceb8af3f30aaf21edd4..0ee3e3be16271211c936ccf53e2adaed956603d7 100644 (file)
@@ -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)))
+
index 2393a2e7a3c2d3bb19895c3dcf8c8b14d0cc0323..f1e469f7909fdb9b8b394cd36687fea606fa844f 100644 (file)
@@ -135,7 +135,7 @@ static NTSTATUS pvfs_default_acl(struct pvfs_state *pvfs,
        }
        sd = *psd;
 
-       ids = talloc_array(sd, struct id_mapping, 2);
+       ids = talloc_zero_array(sd, struct id_mapping, 2);
        NT_STATUS_HAVE_NO_MEMORY(ids);
 
        ids[0].unixid = talloc(ids, struct unixid);
index 4c383ed45d721263c77ea280f06b3b879eda8cd1..04f6ad78d0f8e44e1ca32cd3970e5a7602dcd23f 100644 (file)
@@ -58,6 +58,8 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
        if (S_ISDIR(name->st.st_mode)) {
                name->st.st_size = 0;
                name->st.st_nlink = 1;
+       } else if (name->stream_id == 0) {
+               name->stream_name = NULL;
        }
 
        /* for now just use the simple samba mapping */
@@ -75,6 +77,11 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
        name->dos.alloc_size = pvfs_round_alloc_size(pvfs, name->st.st_size);
        name->dos.nlink = name->st.st_nlink;
        name->dos.ea_size = 4;
+       if (pvfs->ntvfs->ctx->protocol == PROTOCOL_SMB2) {
+               /* SMB2 represents a null EA with zero bytes */
+               name->dos.ea_size = 0;
+       }
+       
        name->dos.file_id = (((uint64_t)name->st.st_dev)<<32) | name->st.st_ino;
        name->dos.flags = 0;
 
index 6e77cb7c756d9f64790f5338935bd82442d4aab5..926c99d37ed0c807fc20aa6eea5996e69d625a95 100644 (file)
@@ -182,12 +182,19 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
        bool del_on_close;
        uint32_t create_options;
        uint32_t share_access;
+       bool forced;
 
        create_options = io->generic.in.create_options;
        share_access   = io->generic.in.share_access;
 
+       forced = (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)?true:false;
+
        if (name->stream_name) {
-               return NT_STATUS_NOT_A_DIRECTORY;
+               if (forced) {
+                       return NT_STATUS_NOT_A_DIRECTORY;
+               } else {
+                       return NT_STATUS_FILE_IS_A_DIRECTORY;
+               }
        }
 
        /* if the client says it must be a directory, and it isn't,
@@ -262,7 +269,6 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
        f->handle->position          = 0;
        f->handle->mode              = 0;
        f->handle->oplock            = NULL;
-       f->handle->sticky_write_time = false;
        f->handle->open_completed    = false;
 
        if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
@@ -416,16 +422,6 @@ cleanup_delete:
 */
 static int pvfs_handle_destructor(struct pvfs_file_handle *h)
 {
-       /* the write time is no longer sticky */
-       if (h->sticky_write_time) {
-               NTSTATUS status;
-               status = pvfs_dosattrib_load(h->pvfs, h->name, h->fd);
-               if (NT_STATUS_IS_OK(status)) {
-                       h->name->dos.flags &= ~XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME;
-                       pvfs_dosattrib_save(h->pvfs, h->name, h->fd);
-               }
-       }
-       
        if ((h->create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
            h->name->stream_name) {
                NTSTATUS status;
@@ -559,6 +555,10 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
        bool allow_level_II_oplock = false;
 
+       if (io->ntcreatex.in.file_attr & ~FILE_ATTRIBUTE_ALL_MASK) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+           
        if ((io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) &&
            (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
                return NT_STATUS_CANNOT_DELETE;
@@ -707,7 +707,6 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        f->handle->mode              = 0;
        f->handle->oplock            = NULL;
        f->handle->have_opendb_entry = true;
-       f->handle->sticky_write_time = false;
        f->handle->open_completed    = false;
 
        status = odb_open_file(lck, f->handle, name->full_name,
@@ -1129,6 +1128,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)) {
@@ -1257,7 +1270,6 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
        f->handle->mode              = 0;
        f->handle->oplock            = NULL;
        f->handle->have_opendb_entry = false;
-       f->handle->sticky_write_time = false;
        f->handle->open_completed    = false;
 
        /* form the lock context used for byte range locking and
@@ -1479,10 +1491,6 @@ NTSTATUS pvfs_close(struct ntvfs_module_context *ntvfs,
                unix_times.actime = 0;
                unix_times.modtime = io->close.in.write_time;
                utime(f->handle->name->full_name, &unix_times);
-       } else if (f->handle->sticky_write_time) {
-               unix_times.actime = 0;
-               unix_times.modtime = nt_time_to_unix(f->handle->name->dos.write_time);
-               utime(f->handle->name->full_name, &unix_times);
        }
 
        talloc_free(f);
index 6bc21e5e3e90a507b101cc9deb3cdc68e9121564..6e3092b744fc1aa2d4ceaaad92d3e6be7ba52a61 100644 (file)
@@ -301,7 +301,14 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs,
                info->all_info2.out.access_mask    = 0; /* only set by qfileinfo */
                info->all_info2.out.position       = 0; /* only set by qfileinfo */
                info->all_info2.out.mode           = 0; /* only set by qfileinfo */
-               info->all_info2.out.fname.s        = name->original_name;
+               /* windows wants the full path on disk for this
+                  result, but I really don't want to expose that on
+                  the wire, so I'll give the path with a share
+                  prefix, which is a good approximation */
+               info->all_info2.out.fname.s = talloc_asprintf(req, "\\%s\\%s",
+                                                             pvfs->share_name, 
+                                                             name->original_name);
+               NT_STATUS_HAVE_NO_MEMORY(info->all_info2.out.fname.s);
                return NT_STATUS_OK;
        }
 
index 325bc74f8f00180cc764747bcc60d61509284e1b..2e97925c494e735557980eda4d809030e8963998 100644 (file)
@@ -202,7 +202,13 @@ static NTSTATUS parse_stream_name(struct pvfs_filename *name, const char *s)
        }
        *p = 0;
        if (strcmp(name->stream_name, "") == 0) {
-               name->stream_name = NULL;
+               /*
+                * we don't set stream_name to NULL, here
+                * as this would be wrong for directories
+                *
+                * pvfs_fill_dos_info() will set it to NULL
+                * if it's not a directory.
+                */
                name->stream_id = 0;
        } else {
                name->stream_id = pvfs_name_hash(name->stream_name, 
index ad47fe90c9bf643ae3e01c5a1b64d984e2aca4cc..0beca75ead8c3bb102774afb6d37423d39e0dcf0 100644 (file)
@@ -342,8 +342,6 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
                }
                if (!null_nttime(info->basic_info.in.write_time)) {
                        newstats.dos.write_time = info->basic_info.in.write_time;
-                       newstats.dos.flags |= XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME;
-                       h->sticky_write_time = true;
                }
                if (!null_nttime(info->basic_info.in.change_time)) {
                        newstats.dos.change_time = info->basic_info.in.change_time;
index 7e6173ef2faf0c033ed7cfc38d90c74892fa2812..3cd9952fd5bcc73d308daa601c629f7af05d34a2 100644 (file)
@@ -36,6 +36,13 @@ NTSTATUS pvfs_stream_information(struct pvfs_state *pvfs,
        int i;
        NTSTATUS status;
 
+       /* directories don't have streams */
+       if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+               info->num_streams = 0;
+               info->streams = NULL;
+               return NT_STATUS_OK;
+       }
+
        streams = talloc(mem_ctx, struct xattr_DosStreams);
        if (streams == NULL) {
                return NT_STATUS_NO_MEMORY;
index 3043b80538a9a418683d922e21dfcc9601e4229f..3cbbcbe92f638a721c5c112f6ea23bf7183fb14c 100644 (file)
@@ -162,7 +162,7 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
        struct xattr_DosAttrib attrib;
        TALLOC_CTX *mem_ctx = talloc_new(name);
        struct xattr_DosInfo1 *info1;
-       struct xattr_DosInfo2 *info2;
+       struct xattr_DosInfo2Old *info2;
 
        if (name->stream_name != NULL) {
                name->stream_exists = false;
@@ -210,7 +210,11 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
                break;
 
        case 2:
-               info2 = &attrib.info.info2;
+               /*
+                * Note: This is only used to parse existing values from disk
+                *       We use xattr_DosInfo1 again for storing new values
+                */
+               info2 = &attrib.info.oldinfo2;
                name->dos.attrib = pvfs_attrib_normalise(info2->attrib, 
                                                         name->st.st_mode);
                name->dos.ea_size = info2->ea_size;
@@ -225,9 +229,6 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
                        name->dos.change_time = info2->change_time;
                }
                name->dos.flags = info2->flags;
-               if (name->dos.flags & XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME) {
-                       name->dos.write_time = info2->write_time;
-               }
                break;
 
        default:
@@ -250,26 +251,23 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
 NTSTATUS pvfs_dosattrib_save(struct pvfs_state *pvfs, struct pvfs_filename *name, int fd)
 {
        struct xattr_DosAttrib attrib;
-       struct xattr_DosInfo2 *info2;
+       struct xattr_DosInfo1 *info1;
 
        if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
                return NT_STATUS_OK;
        }
 
-       attrib.version = 2;
-       info2 = &attrib.info.info2;
+       attrib.version = 1;
+       info1 = &attrib.info.info1;
 
        name->dos.attrib = pvfs_attrib_normalise(name->dos.attrib, name->st.st_mode);
 
-       info2->attrib      = name->dos.attrib;
-       info2->ea_size     = name->dos.ea_size;
-       info2->size        = name->st.st_size;
-       info2->alloc_size  = name->dos.alloc_size;
-       info2->create_time = name->dos.create_time;
-       info2->change_time = name->dos.change_time;
-       info2->write_time  = name->dos.write_time;
-       info2->flags       = name->dos.flags;
-       info2->name        = "";
+       info1->attrib      = name->dos.attrib;
+       info1->ea_size     = name->dos.ea_size;
+       info1->size        = name->st.st_size;
+       info1->alloc_size  = name->dos.alloc_size;
+       info1->create_time = name->dos.create_time;
+       info1->change_time = name->dos.change_time;
 
        return pvfs_xattr_ndr_save(pvfs, name->full_name, fd, 
                                   XATTR_DOSATTRIB_NAME, &attrib, 
index ebc2d88e701034c102ec770b5cdc649c84383ea6..14b5210fd0e6ced1db9d99cd944b5cf13a2e984b 100644 (file)
@@ -219,7 +219,7 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
                                           pvfs->ntvfs->ctx->server_id,  
                                           pvfs->ntvfs->ctx->msg_ctx, 
                                           pvfs->ntvfs->ctx->lp_ctx, 
-                                          event_context_find(pvfs),
+                                          pvfs->ntvfs->ctx->event_ctx,
                                           pvfs->ntvfs->ctx->config);
 
        pvfs->wbc_ctx = wbc_init(pvfs,
index 441424142f933555b19fe82b1c179770582de3f8..c194698b64e23510ee486791702d284500b6520a 100644 (file)
@@ -169,9 +169,6 @@ struct pvfs_file_handle {
        /* we need this hook back to our parent for lock destruction */
        struct pvfs_state *pvfs;
 
-       /* have we set a sticky write time that we should remove on close */
-       bool sticky_write_time;
-
        /* the open went through to completion */
        bool open_completed;
 };
diff --git a/source/ntvfs/smb2/vfs_smb2.c b/source/ntvfs/smb2/vfs_smb2.c
new file mode 100644 (file)
index 0000000..cc09daf
--- /dev/null
@@ -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;
+}
index de445bff7bb71c30015552c16cb231be5187f060..1122d5c39dc9fcc9459ac5d4bc8f1db114a9f071 100644 (file)
@@ -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,13 +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
 
-[MODULE::sys_lease_linux]
-SUBSYSTEM = sys_lease
+[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
index b8a165aa519b087cc63a664aa8bc9f1004ad868b..a0322bbcc1adcfce448bd6bdebc3a5e5b2a57707 100644 (file)
@@ -28,7 +28,6 @@
 #include "lib/events/events.h"
 #include "lib/util/dlinklist.h"
 #include "param/param.h"
-#include "build.h"
 
 /* list of registered backends */
 static struct sys_lease_ops *backends;
@@ -55,7 +54,7 @@ _PUBLIC_ struct sys_lease_context *sys_lease_context_create(struct share_config
        }
 
        if (ev == NULL) {
-               ev = event_context_find(mem_ctx);
+               return NULL;
        }
 
        ctx = talloc_zero(mem_ctx, struct sys_lease_context);
@@ -109,6 +108,10 @@ _PUBLIC_ NTSTATUS sys_lease_register(const struct sys_lease_ops *backend)
        return NT_STATUS_OK;
 }
 
+#ifndef STATIC_sys_lease_MODULES 
+#define STATIC_sys_lease_MODULES NULL
+#endif
+
 _PUBLIC_ NTSTATUS sys_lease_init(void)
 {
        static bool initialized = false;
index eb5cc3793f65bfd56a54e4c162b43e7d625f260c..9770323c3fa0ec343b9aed4f72098ede9b9cb1a1 100644 (file)
@@ -28,7 +28,6 @@
 #include "lib/events/events.h"
 #include "lib/util/dlinklist.h"
 #include "param/param.h"
-#include "build.h"
 
 /* list of registered backends */
 static struct sys_notify_backend *backends;
@@ -52,7 +51,7 @@ _PUBLIC_ struct sys_notify_context *sys_notify_context_create(struct share_confi
        }
 
        if (ev == NULL) {
-               ev = event_context_find(mem_ctx);
+               return NULL;
        }
 
        ctx = talloc_zero(mem_ctx, struct sys_notify_context);
index 968e56bde467c4ac0e052b5a7b150193ee15dbd3..6377657cec9e151eeea7d3f621f1a1f04509294e 100644 (file)
@@ -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
index 42cb6f3c1c643c88d1c8e92a57a46e920c2f0a59..02474d50b91d9c19f5ab6252face611d19aaf827 100644 (file)
@@ -3,31 +3,30 @@ PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL
 PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET
 
 LIBSAMBA-HOSTCONFIG_VERSION = 0.0.1
-LIBSAMBA-HOSTCONFIG-SOVERSION = 0
+LIBSAMBA-HOSTCONFIG_SOVERSION = 0
 
-LIBSAMBA-HOSTCONFIG_OBJ_FILES = param/loadparm.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
 
@@ -40,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
@@ -51,15 +50,19 @@ 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
+LIBRARY_REALNAME = samba/_param.$(SHLIBEXT)
 PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG
 
-param_OBJ_FILES = param/param_wrap.o
+param_OBJ_FILES = $(paramsrcdir)/param_wrap.o
+
+$(eval $(call python_py_module_template,samba/param.py,$(paramsrcdir)/param.py))
+
+$(param_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
index 77d781d6ffe32293e8cb0038636aca330dee7055..2c15f8f5e385a16c20fd66760d055aa19d22b00f 100644 (file)
@@ -50,22 +50,36 @@ typedef struct loadparm_context {
     %extend {
         loadparm_context(TALLOC_CTX *mem_ctx) { return loadparm_init(mem_ctx); }
         struct loadparm_service *default_service() { return lp_default_service($self); }
+        %feature("docstring") load "S.load(filename) -> None\n" \
+                                   "Load specified file.";
         bool load(const char *filename) { return lp_load($self, filename); }
+        %feature("docstring") load_default "S.load_default() -> None\n" \
+                                   "Load default smb.conf file.";
         bool load_default() { return lp_load_default($self); }
 #ifdef SWIGPYTHON
         int __len__() { return lp_numservices($self); }
         struct loadparm_service *__getitem__(const char *name) { return lp_service($self, name); }
 #endif
+        %feature("docstring") configfile "S.configfile() -> string\n" \
+                                   "Return name of last config file that was loaded.";
         const char *configfile() { return lp_configfile($self); }
+        %feature("docstring") is_mydomain "S.is_mydomain(domain_name) -> bool\n" \
+                                   "Check whether the specified name matches our domain name.";
         bool is_mydomain(const char *domain) { return lp_is_mydomain($self, domain); }
+        %feature("docstring") is_myname "S.is_myname(netbios_name) -> bool\n" \
+                                   "Check whether the specified name matches one of our netbios names.";
         bool is_myname(const char *name) { return lp_is_myname($self, name); }
         int use(struct param_context *param_ctx) { return param_use($self, param_ctx); }
+        %feature("docstring") set "S.set(name, value) -> bool\n" \
+                                   "Change a parameter.";
         bool set(const char *parm_name, const char *parm_value) {
             if (parm_value == NULL)
                 return false;
             return lp_set_cmdline($self, parm_name, parm_value);
         }
 
+        %feature("docstring") set "S.get(name, service_name) -> value\n" \
+                                   "Find specified parameter.";
         PyObject *get(const char *param_name, const char *service_name)
         {
             struct parm_struct *parm = NULL;
@@ -180,7 +194,11 @@ typedef struct loadparm_service {
 typedef struct param_context {
     %extend { 
         param(TALLOC_CTX *mem_ctx) { return param_init(mem_ctx); }
+        %feature("docstring") add_section "S.get_section(name) -> section\n"
+                                          "Get an existing section.";
         struct param_section *get_section(const char *name);
+        %feature("docstring") add_section "S.add_section(name) -> section\n"
+                                          "Add a new section.";
         struct param_section *add_section(const char *name);
         struct param_opt *get(const char *name, const char *section_name="global");
         const char *get_string(const char *name, const char *section_name="global");
@@ -198,10 +216,18 @@ typedef struct param_context {
         
 #endif
 
+        %feature("docstring") first_section "S.first_section() -> section\n"
+                                          "Find first section";
         struct param_section *first_section() { return $self->sections; }
+        %feature("docstring") next_section "S.next_section(prev) -> section\n"
+                                          "Find next section";
         struct param_section *next_section(struct param_section *s) { return s->next; }
 
+        %feature("docstring") read "S.read(filename) -> bool\n"
+                                          "Read a filename.";
         int read(const char *fn);
+        %feature("docstring") read "S.write(filename) -> bool\n"
+                                          "Write this object to a file.";
         int write(const char *fn);
     }
     %pythoncode {
@@ -307,6 +333,15 @@ struct loadparm_context *lp_from_py_object(PyObject *py_obj)
         return lp_ctx;
     }
 
+    if (py_obj == Py_None) {
+        lp_ctx = loadparm_init(NULL);
+        if (!lp_load_default(lp_ctx)) {
+            talloc_free(lp_ctx);
+            return NULL;
+        }
+        return lp_ctx;
+    }
+
     if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 |  0 ) < 0)
         return NULL;
     return lp_ctx;
index 025acc6be1e556d9cf161cdf67ad93faecb1d23b..3aebaf0e021a4253384ed12d3b5eb9aeb17eb443 100644 (file)
@@ -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.
 
@@ -62,6 +62,48 @@ class LoadParm(object):
     __repr__ = _swig_repr
     def __init__(self, *args, **kwargs): 
         _param.LoadParm_swiginit(self,_param.new_LoadParm(*args, **kwargs))
+    def load(*args, **kwargs):
+        """
+        S.load(filename) -> None
+        Load specified file.
+        """
+        return _param.LoadParm_load(*args, **kwargs)
+
+    def load_default(*args, **kwargs):
+        """
+        S.load_default() -> None
+        Load default smb.conf file.
+        """
+        return _param.LoadParm_load_default(*args, **kwargs)
+
+    def configfile(*args, **kwargs):
+        """
+        S.configfile() -> string
+        Return name of last config file that was loaded.
+        """
+        return _param.LoadParm_configfile(*args, **kwargs)
+
+    def is_mydomain(*args, **kwargs):
+        """
+        S.is_mydomain(domain_name) -> bool
+        Check whether the specified name matches our domain name.
+        """
+        return _param.LoadParm_is_mydomain(*args, **kwargs)
+
+    def is_myname(*args, **kwargs):
+        """
+        S.is_myname(netbios_name) -> bool
+        Check whether the specified name matches one of our netbios names.
+        """
+        return _param.LoadParm_is_myname(*args, **kwargs)
+
+    def set(*args, **kwargs):
+        """
+        S.set(name, value) -> bool
+        Change a parameter.
+        """
+        return _param.LoadParm_set(*args, **kwargs)
+
     __swig_destroy__ = _param.delete_LoadParm
 LoadParm.default_service = new_instancemethod(_param.LoadParm_default_service,None,LoadParm)
 LoadParm.load = new_instancemethod(_param.LoadParm_load,None,LoadParm)
@@ -79,7 +121,7 @@ LoadParm_swigregister(LoadParm)
 
 class loadparm_service(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
 loadparm_service.volume_label = new_instancemethod(_param.loadparm_service_volume_label,None,loadparm_service)
 loadparm_service.printername = new_instancemethod(_param.loadparm_service_printername,None,loadparm_service)
@@ -92,6 +134,34 @@ class ParamFile(object):
     __repr__ = _swig_repr
     def __init__(self, *args, **kwargs): 
         _param.ParamFile_swiginit(self,_param.new_ParamFile(*args, **kwargs))
+    def add_section(*args, **kwargs):
+        """
+        S.add_section(name) -> section
+        Add a new section.
+        """
+        return _param.ParamFile_add_section(*args, **kwargs)
+
+    def first_section(*args, **kwargs):
+        """
+        S.first_section() -> section
+        Find first section
+        """
+        return _param.ParamFile_first_section(*args, **kwargs)
+
+    def next_section(*args, **kwargs):
+        """
+        S.next_section(prev) -> section
+        Find next section
+        """
+        return _param.ParamFile_next_section(*args, **kwargs)
+
+    def read(*args, **kwargs):
+        """
+        S.read(filename) -> bool
+        Read a filename.
+        """
+        return _param.ParamFile_read(*args, **kwargs)
+
     def __getitem__(self, name):
         ret = self.get_section(name)
         if ret is None:
@@ -137,7 +207,7 @@ ParamFile_swigregister(ParamFile)
 
 class param_opt(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
     key = _swig_property(_param.param_opt_key_get)
     value = _swig_property(_param.param_opt_value_get)
index e74f902645329fe1cc84134a25f74f09eb57bed8..aff239312d5414a67656fae4188c27409af3341f 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2504,7 +2522,7 @@ static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0};
 
 #define SWIG_name    "_param"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -2776,6 +2794,15 @@ struct loadparm_context *lp_from_py_object(PyObject *py_obj)
         return lp_ctx;
     }
 
+    if (py_obj == Py_None) {
+        lp_ctx = loadparm_init(NULL);
+        if (!lp_load_default(lp_ctx)) {
+            talloc_free(lp_ctx);
+            return NULL;
+        }
+        return lp_ctx;
+    }
+
     if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 |  0 ) < 0)
         return NULL;
     return lp_ctx;
@@ -4073,7 +4100,7 @@ SWIGINTERN PyObject *_wrap_new_param_section(PyObject *SWIGUNUSEDPARM(self), PyO
   param_section *result = 0 ;
   
   if (!SWIG_Python_UnpackTuple(args,"new_param_section",0,0,0)) SWIG_fail;
-  result = (param_section *)(param_section *) calloc(1, sizeof(param_section));
+  result = (param_section *)calloc(1, sizeof(param_section));
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -4141,15 +4168,33 @@ SWIGINTERN PyObject *Swig_var_default_config_get(void) {
 static PyMethodDef SwigMethods[] = {
         { (char *)"new_LoadParm", (PyCFunction)_wrap_new_LoadParm, METH_NOARGS, NULL},
         { (char *)"LoadParm_default_service", (PyCFunction) _wrap_LoadParm_default_service, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.load(filename) -> None\n"
+               "Load specified file.\n"
+               ""},
+        { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.load_default() -> None\n"
+               "Load default smb.conf file.\n"
+               ""},
         { (char *)"LoadParm___len__", (PyCFunction) _wrap_LoadParm___len__, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"LoadParm___getitem__", (PyCFunction) _wrap_LoadParm___getitem__, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.configfile() -> string\n"
+               "Return name of last config file that was loaded.\n"
+               ""},
+        { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.is_mydomain(domain_name) -> bool\n"
+               "Check whether the specified name matches our domain name.\n"
+               ""},
+        { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.is_myname(netbios_name) -> bool\n"
+               "Check whether the specified name matches one of our netbios names.\n"
+               ""},
         { (char *)"LoadParm_use", (PyCFunction) _wrap_LoadParm_use, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set(name, value) -> bool\n"
+               "Change a parameter.\n"
+               ""},
         { (char *)"LoadParm_get", (PyCFunction) _wrap_LoadParm_get, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL},
@@ -4160,14 +4205,26 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"loadparm_service_swigregister", loadparm_service_swigregister, METH_VARARGS, NULL},
         { (char *)"new_ParamFile", (PyCFunction)_wrap_new_ParamFile, METH_NOARGS, NULL},
         { (char *)"ParamFile_get_section", (PyCFunction) _wrap_ParamFile_get_section, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.add_section(name) -> section\n"
+               "Add a new section.\n"
+               ""},
         { (char *)"ParamFile_get", (PyCFunction) _wrap_ParamFile_get, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"ParamFile_get_string", (PyCFunction) _wrap_ParamFile_get_string, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"ParamFile_set_string", (PyCFunction) _wrap_ParamFile_set_string, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"ParamFile_set", (PyCFunction) _wrap_ParamFile_set, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, NULL},
-        { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, (char *)"\n"
+               "S.first_section() -> section\n"
+               "Find first section\n"
+               ""},
+        { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.next_section(prev) -> section\n"
+               "Find next section\n"
+               ""},
+        { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.read(filename) -> bool\n"
+               "Read a filename.\n"
+               ""},
         { (char *)"ParamFile_write", (PyCFunction) _wrap_ParamFile_write, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
         { (char *)"ParamFile_swigregister", ParamFile_swigregister, METH_VARARGS, NULL},
@@ -4325,7 +4382,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -4335,6 +4392,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 */
@@ -4363,6 +4423,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);
index 51134d897037c7e076529feccca86b0afce026ed..47aea55751b41d687d2efc4ba69d2a6e81c763b3 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "includes.h"
 #include "param/share.h"
-#include "build.h"
 #include "param/param.h"
 
 const char *share_string_option(struct share_config *scfg, const char *opt_name, const char *defval)
@@ -127,6 +126,7 @@ NTSTATUS share_register(const struct share_ops *ops)
 }
 
 NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name,
+                                  struct event_context *event_ctx, 
                                   struct loadparm_context *lp_ctx,
                                   struct share_context **ctx)
 {
@@ -138,7 +138,7 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name
                return NT_STATUS_INTERNAL_ERROR;
        }
 
-       return ops->init(mem_ctx, ops, lp_ctx, ctx);
+       return ops->init(mem_ctx, ops, event_ctx, lp_ctx, ctx);
 }
 
 /*
index 9f9cbdce5bed8ed447f37ffa68c9fa8bb6c97d0d..2a85fd4fbbffb94fed518f4540f17ddb9c237aa9 100644 (file)
@@ -47,9 +47,12 @@ struct share_info {
        void *value;
 };
 
+struct event_context;
+
 struct share_ops {
        const char *name;
-       NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct loadparm_context *lp_ctx,
+       NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct event_context *ev_ctx,
+                        struct loadparm_context *lp_ctx,
                         struct share_context **);
        const char *(*string_option)(struct share_config *, const char *, const char *);
        int (*int_option)(struct share_config *, const char *, int);
index c3adc4473c789d2a7dc68edae1c5a3cdd240c2a5..bac1aac2d78f33ca82312a53cb8599af31309ad6 100644 (file)
@@ -25,6 +25,7 @@
 
 static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, 
                              const struct share_ops *ops, 
+                             struct event_context *event_ctx,
                              struct loadparm_context *lp_ctx,
                              struct share_context **ctx)
 {
index fb40f1e9bfe8be040e3480ea91dd26eccebc1787..eba1665cc9f5654fe22f47e56bb95c005a83eaa7 100644 (file)
@@ -27,7 +27,9 @@
 #include "param/share.h"
 #include "param/param.h"
 
-static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, struct loadparm_context *lp_ctx,
+static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, 
+                         struct event_context *ev_ctx,
+                         struct loadparm_context *lp_ctx,
                          struct share_context **ctx)
 {
        struct ldb_context *sdb;
@@ -38,7 +40,7 @@ static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, stru
                return NT_STATUS_NO_MEMORY;
        }
        
-       sdb = ldb_wrap_connect(*ctx, lp_ctx, 
+       sdb = ldb_wrap_connect(*ctx, ev_ctx, lp_ctx, 
                               private_path(*ctx, lp_ctx, "share.ldb"),
                               system_session(*ctx, lp_ctx),
                               NULL, 0, NULL);
index 0dd186b9dfb1ed06befd74a3588b9b079ed05f08..d1d71e4485e50b1fd8aba6ea8525ba59f1cc2b4e 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import param
+from samba import param
 import unittest
 
 class LoadParmTestCase(unittest.TestCase):
index 6d03b4e0492459afb0e786cc418870979a52d0c5..c64b5c607a53ef13638cd974952dc84c1d814caf 100644 (file)
@@ -182,12 +182,12 @@ static void tcase_add_share_tests(struct torture_tcase *tcase)
 
 static bool setup_ldb(struct torture_context *tctx, void **data)
 {
-       return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->lp_ctx, (struct share_context **)data));
+       return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->ev, tctx->lp_ctx, (struct share_context **)data));
 }
 
 static bool setup_classic(struct torture_context *tctx, void **data)
 {
-       return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->lp_ctx, (struct share_context **)data));
+       return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->ev, tctx->lp_ctx, (struct share_context **)data));
 }
 
 static bool teardown(struct torture_context *tctx, void *data)
index f1cca0ab230088e209b510f47e527921b8fd4eca..bc5c49a46fde49ee1a7944c5c85a9e85edab6c05 100644 (file)
@@ -1,6 +1,3 @@
-- EJS output backend shouldn't use the NDR levels stuff but instead 
-  as the "C levels" and NDR levels don't necessarily match.
-
 - true multiple dimension array / strings in arrays support
 
 - compatibility mode for generating MIDL-readable data:
  - remove NDR_AUTO_REF_ALLOC flag
 
 - automatic test generator based on IDL pointer types
+
+- support converting structs to tuples in Python rather than objects
+- convert structs with a single mattering member to that member directly, e.g.:
+  struct bar {
+    int size;
+       [size_is(size)] uint32 *array;
+  };
+
+  should be converted to an array of uint32's
+
+- python: fill in size members automatically in some places if the struct isn't being returned
+  (so we don't have to cope with the array growing)
index 25cea495a76d6113141a373efe5511b5d82a82c7..07c8647ecd4d26f8221b75d4e62958cd3c4b06a5 100644 (file)
@@ -1,12 +1,14 @@
-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) \
-                                          INSTALLVENDORLIB=$(libdir) \
+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) \
                                                                   INSTALLVENDORMAN1DIR=$(mandir)/man1 \
@@ -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
-
 
index e9c158e93323b93152e7df011f91ad98a7a2cd78..f8209be654b4134ddf06915cf082f70c22970231 100644 (file)
@@ -7,6 +7,7 @@
 package Parse::Pidl::Samba4::NDR::Client;
 
 use Parse::Pidl::Samba4 qw(choose_header is_intree);
+use Parse::Pidl::Util qw(has_property);
 
 use vars qw($VERSION);
 $VERSION = '0.01';
@@ -15,30 +16,45 @@ use strict;
 
 my($res,$res_hdr);
 
-#####################################################################
-# parse a function
-sub ParseFunction($$)
+sub ParseFunctionSend($$$)
 {
-       my ($interface, $fn) = @_;
-       my $name = $fn->{NAME};
+       my ($interface, $fn, $name) = @_;
        my $uname = uc $name;
 
-       $res_hdr .= "\nstruct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);
-NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);
-";
+       my $proto = "struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
 
-       $res .= "
-struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
-{
+       $res_hdr .= "\n$proto;\n";
+
+       $res .= "$proto\n{\n";
+
+       if (has_property($fn, "todo")) {
+               $res .= "\treturn NULL;\n";
+       } else {
+               $res .= "
        if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
                NDR_PRINT_IN_DEBUG($name, r);
        }
        
        return dcerpc_ndr_request_send(p, NULL, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, r);
+";
+       }
+
+       $res .= "}\n\n";
 }
 
-NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
+sub ParseFunctionSync($$$)
 {
+       my ($interface, $fn, $name) = @_;
+
+       my $proto = "NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
+
+       $res_hdr .= "\n$proto;\n";
+       $res .= "$proto\n{\n";
+
+       if (has_property($fn, "todo")) {
+               $res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n";
+       } else {
+               $res .= "
        struct rpc_request *req;
        NTSTATUS status;
        
@@ -58,8 +74,20 @@ NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *
        $res .= 
 "
        return status;
-}
 ";
+       }
+
+       $res .= "}\n\n";
+}
+
+#####################################################################
+# parse a function
+sub ParseFunction($$)
+{
+       my ($interface, $fn) = @_;
+
+       ParseFunctionSend($interface, $fn, $fn->{NAME});
+       ParseFunctionSync($interface, $fn, $fn->{NAME});
 }
 
 my %done;
index 2d12da358ce8eff04f8bcca0c3b7da3d266a7883..440b1bff978930331e8aa26597e0651b651393c1 100644 (file)
@@ -203,7 +203,7 @@ sub PythonStruct($$$$$$)
                        $self->pidl("return 0;");
                        $self->deindent;
                        $self->pidl("}");
-               $self->pidl("");
+                       $self->pidl("");
                }
 
                $getsetters = "py_$name\_getsetters";
@@ -253,6 +253,20 @@ sub PythonStruct($$$$$$)
        return "&$typeobject";
 }
 
+sub get_metadata_var($)
+{
+       my ($e) = @_;
+       sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
+
+        if (has_property($e, "length_is")) {
+               return get_var($e->{PROPERTIES}->{length_is});
+        } elsif (has_property($e, "size_is")) {
+               return get_var($e->{PROPERTIES}->{size_is});
+        }
+
+        return undef;
+}
+
 sub PythonFunctionBody($$$)
 {
        my ($self, $fn, $iface, $prettyname) = @_;
@@ -274,17 +288,10 @@ sub PythonFunctionBody($$$)
 
        my $metadata_args = { in => {}, out => {} };
 
-       sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
-
        # Determine arguments that are metadata for other arguments (size_is/length_is)
        foreach my $e (@{$fn->{ELEMENTS}}) {
                foreach my $dir (@{$e->{DIRECTION}}) {
-                        my $main = undef;
-                        if (has_property($e, "length_is")) {
-                               $main = get_var($e->{PROPERTIES}->{length_is});
-                        } elsif (has_property($e, "size_is")) {
-                               $main = get_var($e->{PROPERTIES}->{size_is});
-                        }
+                        my $main = get_metadata_var($e);
                         if ($main) { 
                                 $metadata_args->{$dir}->{$main} = $e->{NAME}; 
                         }
@@ -597,8 +604,9 @@ sub Interface($$$)
                $self->pidl("const char *binding_string;");
                $self->pidl("struct cli_credentials *credentials;");
                $self->pidl("struct loadparm_context *lp_ctx = NULL;");
-               $self->pidl("PyObject *py_lp_ctx = NULL, *py_credentials = Py_None;");
+               $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None;");
                $self->pidl("TALLOC_CTX *mem_ctx = NULL;");
+               $self->pidl("struct event_context *event_ctx;");
                $self->pidl("NTSTATUS status;");
                $self->pidl("");
                $self->pidl("const char *kwnames[] = {");
@@ -609,14 +617,12 @@ sub Interface($$$)
                $self->pidl("extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);");
                $self->pidl("extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);");
                $self->pidl("");
-               $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"sO|O:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials)) {");
+               $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials)) {");
                $self->indent;
                $self->pidl("return NULL;");
                $self->deindent;
                $self->pidl("}");
                $self->pidl("");
-               $self->pidl("if (py_lp_ctx != NULL) {");
-               $self->indent;
                $self->pidl("lp_ctx = lp_from_py_object(py_lp_ctx);");
                $self->pidl("if (lp_ctx == NULL) {");
                $self->indent;
@@ -624,8 +630,6 @@ sub Interface($$$)
                $self->pidl("return NULL;");
                $self->deindent;
                $self->pidl("}");
-               $self->deindent;
-               $self->pidl("}");
                $self->pidl("");
 
                $self->pidl("credentials = cli_credentials_from_py_object(py_credentials);");
@@ -638,9 +642,11 @@ sub Interface($$$)
 
                $self->pidl("ret = PyObject_New($interface->{NAME}_InterfaceObject, &$interface->{NAME}_InterfaceType);");
                $self->pidl("");
+               $self->pidl("event_ctx = event_context_init(mem_ctx);");
+               $self->pidl("");
 
                $self->pidl("status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, ");
-               $self->pidl("             &ndr_table_$interface->{NAME}, credentials, NULL, lp_ctx);");
+               $self->pidl("             &ndr_table_$interface->{NAME}, credentials, event_ctx, lp_ctx);");
                $self->handle_ntstatus("status", "NULL", "mem_ctx");
 
                $self->pidl("ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;");
@@ -652,7 +658,7 @@ sub Interface($$$)
                $self->pidl("");
 
                my $signature = 
-"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> Connection to DCE/RPC interface.\\n\"
+"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
 \"\\n\"
 \"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\\n\"
 \"lp_ctx should be a path to a smb.conf file or a param.LoadParm object\\n\"
@@ -1024,6 +1030,7 @@ sub Parse($$$$$)
 #include \"librpc/rpc/dcerpc.h\"
 #include \"scripting/python/pytalloc.h\"
 #include \"scripting/python/pyrpc.h\"
+#include \"lib/events/events.h\"
 #include \"$hdr\"
 #include \"$ndr_hdr\"
 #include \"$py_hdr\"
index 646879ad0d5ddb9dbaa65698ab27da87dfa5d06e..da034e85ea5c53e69ed14335db99a53dc4f5fda0 100644 (file)
@@ -82,7 +82,7 @@ uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct loadparm_co
 }
 
 /* This hardcoded value should go into a ldb database! */
-uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
+uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, struct dcesrv_context *dce_ctx)
 {
        int default_server_announce = 0;
        default_server_announce |= SV_TYPE_WORKSTATION;
@@ -118,7 +118,7 @@ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dcesrv_contex
                                break;
                        }
                        /* open main ldb */
-                       samctx = samdb_connect(tmp_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, dce_ctx->lp_ctx));
+                       samctx = samdb_connect(tmp_ctx, event_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, event_ctx, dce_ctx->lp_ctx));
                        if (samctx == NULL) {
                                DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
                        } else {
index 807853fa165b6998bdb00988c5c72affc009ce31..6b1813544ec4ac77e51869a09be229c7abc60a96 100644 (file)
@@ -3,79 +3,82 @@
 ################################################
 # 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
 [MODULE::dcerpc_rpcecho]
 INIT_FUNCTION = dcerpc_server_rpcecho_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 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
 [MODULE::dcerpc_epmapper]
 INIT_FUNCTION = dcerpc_server_epmapper_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 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
 [MODULE::dcerpc_remote]
 INIT_FUNCTION = dcerpc_server_remote_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                LIBCLI_SMB NDR_TABLE
 # 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 = dcerpc_server
+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
 [MODULE::dcerpc_wkssvc]
 INIT_FUNCTION = dcerpc_server_wkssvc_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                DCERPC_COMMON NDR_WKSSVC
 # 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
 [MODULE::dcerpc_unixinfo]
 INIT_FUNCTION = dcerpc_server_unixinfo_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                DCERPC_COMMON \
                SAMDB \
@@ -85,14 +88,13 @@ 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 = dcerpc_server
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                SAMDB \
                DCERPC_COMMON \
@@ -100,26 +102,28 @@ 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
 [MODULE::dcerpc_winreg]
 INIT_FUNCTION = dcerpc_server_winreg_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 OUTPUT_TYPE = MERGED_OBJ
 PRIVATE_DEPENDENCIES = \
                registry NDR_WINREG
 # 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
 [MODULE::dcerpc_netlogon]
 INIT_FUNCTION = dcerpc_server_netlogon_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                DCERPC_COMMON \
                SCHANNELDB \
@@ -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 = dcerpc_server
-PRIVATE_PROTO_HEADER= lsa/proto.h
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                SAMDB \
                DCERPC_COMMON \
@@ -145,14 +148,16 @@ 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)))
 
 
 ################################################
 # Start MODULE dcerpc_spoolss
 [MODULE::dcerpc_spoolss]
 INIT_FUNCTION = dcerpc_server_spoolss_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 OUTPUT_TYPE = MERGED_OBJ
 PRIVATE_DEPENDENCIES = \
                DCERPC_COMMON \
@@ -162,13 +167,13 @@ 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
 [MODULE::dcerpc_drsuapi]
 INIT_FUNCTION = dcerpc_server_drsuapi_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
 PRIVATE_DEPENDENCIES = \
                SAMDB \
                DCERPC_COMMON \
@@ -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 = service
+SUBSYSTEM = smbd
 PRIVATE_DEPENDENCIES = dcerpc_server
 
-DCESRV_OBJ_FILES = rpc_server/service_rpc.o
+DCESRV_OBJ_FILES = $(rpc_serversrcdir)/service_rpc.o
index beb795ea222b292ef87e4f92636a8dff6630f394..e0351bb259e335c237e6502430d8f7a7aebf70d7 100644 (file)
@@ -34,7 +34,6 @@
 #include "smbd/service.h"
 #include "system/filesys.h"
 #include "libcli/security/security.h"
-#include "build.h"
 #include "param/param.h"
 
 extern const struct dcesrv_interface dcesrv_mgmt_interface;
@@ -446,6 +445,7 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
 {
        struct ncacn_packet pkt;
        struct data_blob_list_item *rep;
+       uint8_t zeros[4];
        NTSTATUS status;
 
        /* setup a bind_ack */
@@ -459,6 +459,9 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
        pkt.u.fault.cancel_count = 0;
        pkt.u.fault.status = fault_code;
 
+       ZERO_STRUCT(zeros);
+       pkt.u.fault._pad = data_blob_const(zeros, sizeof(zeros));
+
        rep = talloc(call, struct data_blob_list_item);
        if (!rep) {
                return NT_STATUS_NO_MEMORY;
@@ -685,6 +688,7 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_
        struct dcesrv_connection_context *context;
        const struct dcesrv_interface *iface;
        struct GUID uuid, *transfer_syntax_uuid;
+       NTSTATUS status;
 
        if_version = call->pkt.u.alter.ctx_list[0].abstract_syntax.if_version;
        uuid = call->pkt.u.alter.ctx_list[0].abstract_syntax.uuid;
@@ -718,6 +722,13 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_
        DLIST_ADD(call->conn->contexts, context);
        call->context = context;
 
+       if (iface) {
+               status = iface->bind(call, iface);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+       }
+
        return NT_STATUS_OK;
 }
 
index a97b93a051a3bae29fb6931968f6843ca9091cf6..e0a222e7675be23856c24fa7c54bba80d47ae414 100644 (file)
@@ -58,7 +58,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
        /*
         * connect to the samdb
         */
-       b_state->sam_ctx = samdb_connect(b_state, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
+       b_state->sam_ctx = samdb_connect(b_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
        if (!b_state->sam_ctx) {
                return WERR_FOOBAR;
        }
index 4dcd6064353b1554423ca55f91feb3e3f332dc5c..0dc21fd9c502c2dcdf650b701ede05d31ec8f5d5 100644 (file)
@@ -50,7 +50,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
        }
 
        /* make sure the sam database is accessible */
-       state->sam_ldb = samdb_connect(state, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
+       state->sam_ldb = samdb_connect(state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
        if (state->sam_ldb == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index c6b9e3bd406c78eeca6147ab5da4418ae3feff7c..30bceb813903059fd9620ffb1f529fdd48127870 100644 (file)
@@ -195,7 +195,8 @@ static NTSTATUS lookup_well_known_sids(TALLOC_CTX *mem_ctx,
 /*
   lookup a SID for 1 name
 */
-static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
+static NTSTATUS dcesrv_lsa_lookup_name(struct event_context *ev_ctx, 
+                                      struct loadparm_context *lp_ctx,
                                       struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
                                const char *name, const char **authority_name, 
                                struct dom_sid **sid, enum lsa_SidType *rtype)
@@ -218,7 +219,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
                }
                username = p + 1;
        } else if (strchr_m(name, '@')) {
-               status = crack_name_to_nt4_name(mem_ctx, lp_ctx, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, name, &domain, &username);
+               status = crack_name_to_nt4_name(mem_ctx, ev_ctx, lp_ctx, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, name, &domain, &username);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(3, ("Failed to crack name %s into an NT4 name: %s\n", name, nt_errstr(status)));
                        return status;
@@ -265,7 +266,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
                if (!name) {
                        return NT_STATUS_NO_MEMORY;
                }
-               status = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
+               status = dcesrv_lsa_lookup_name(ev_ctx, lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
                if (NT_STATUS_IS_OK(status)) {
                        return status;
                }
@@ -275,7 +276,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
                if (!name) {
                        return NT_STATUS_NO_MEMORY;
                }
-               status = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
+               status = dcesrv_lsa_lookup_name(ev_ctx, lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
                if (NT_STATUS_IS_OK(status)) {
                        return status;
                }
@@ -285,7 +286,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
                if (!name) {
                        return NT_STATUS_NO_MEMORY;
                }
-               status = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
+               status = dcesrv_lsa_lookup_name(ev_ctx, lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
                if (NT_STATUS_IS_OK(status)) {
                        return status;
                }
@@ -721,7 +722,7 @@ NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call,
                r->out.sids->sids[i].sid_index   = 0xFFFFFFFF;
                r->out.sids->sids[i].unknown     = 0;
 
-               status2 = dcesrv_lsa_lookup_name(lp_ctx, policy_state, mem_ctx, name, &authority_name, &sid, &rtype);
+               status2 = dcesrv_lsa_lookup_name(dce_call->event_ctx, lp_ctx, policy_state, mem_ctx, name, &authority_name, &sid, &rtype);
                if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
                        continue;
                }
@@ -854,7 +855,7 @@ NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call,
                r->out.sids->sids[i].sid_index   = 0xFFFFFFFF;
                r->out.sids->sids[i].unknown     = 0;
 
-               status2 = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, 
+               status2 = dcesrv_lsa_lookup_name(dce_call->event_ctx, lp_ctx, state, mem_ctx, name, 
                                                 &authority_name, &sid, &rtype);
                if (!NT_STATUS_IS_OK(status2)) {
                        continue;
index 37e6351864093e818895bb788c04837791f28514..d9ae92c0fa7002c918de4c29bf8a53d49b4592f4 100644 (file)
@@ -93,7 +93,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, 
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, 
                                system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
@@ -176,7 +176,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
 
 
        /* remember this session key state */
-       nt_status = schannel_store_session_key(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, creds);
+       nt_status = schannel_store_session_key(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, creds);
 
        return nt_status;
 }
@@ -236,7 +236,8 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate2(struct dcesrv_call_state *dce_ca
   the caller needs some of that information.
 
 */
-static NTSTATUS dcesrv_netr_creds_server_step_check(struct loadparm_context *lp_ctx,
+static NTSTATUS dcesrv_netr_creds_server_step_check(struct event_context *event_ctx, 
+                                                   struct loadparm_context *lp_ctx,
                                                    const char *computer_name,
                                             TALLOC_CTX *mem_ctx, 
                                             struct netr_Authenticator *received_authenticator,
@@ -248,7 +249,7 @@ static NTSTATUS dcesrv_netr_creds_server_step_check(struct loadparm_context *lp_
        struct ldb_context *ldb;
        int ret;
 
-       ldb = schannel_db_connect(mem_ctx, lp_ctx);
+       ldb = schannel_db_connect(mem_ctx, event_ctx, lp_ctx);
        if (!ldb) {
                return NT_STATUS_ACCESS_DENIED;
        }
@@ -300,13 +301,13 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call
        struct ldb_context *sam_ctx;
        NTSTATUS nt_status;
 
-       nt_status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+       nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
                                                        r->in.computer_name, mem_ctx, 
                                                 &r->in.credential, &r->out.return_authenticator,
                                                 &creds);
        NT_STATUS_NOT_OK_RETURN(nt_status);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -339,13 +340,13 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
 
        struct samr_CryptPassword password_buf;
 
-       nt_status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+       nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
                                                        r->in.computer_name, mem_ctx, 
                                                 &r->in.credential, &r->out.return_authenticator,
                                                 &creds);
        NT_STATUS_NOT_OK_RETURN(nt_status);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -561,7 +562,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call,
 {
        NTSTATUS nt_status;
        struct creds_CredentialState *creds;
-       nt_status = schannel_fetch_session_key(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx), &creds);
+       nt_status = schannel_fetch_session_key(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx), &creds);
        if (!NT_STATUS_IS_OK(nt_status)) {
                return nt_status;
        }
@@ -589,7 +590,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogonWithFlags(struct dcesrv_call_state *dce
        return_authenticator = talloc(mem_ctx, struct netr_Authenticator);
        NT_STATUS_HAVE_NO_MEMORY(return_authenticator);
 
-       nt_status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+       nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
                                                        r->in.computer_name, mem_ctx, 
                                                 r->in.credential, return_authenticator,
                                                 &creds);
@@ -891,14 +892,14 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
 
        const char *local_domain;
 
-       status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+       status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
                                                     r->in.computer_name, mem_ctx, 
                                              r->in.credential, 
                                              r->out.return_authenticator,
                                              NULL);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -1003,7 +1004,7 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
 
        ZERO_STRUCT(r->out);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
        if (sam_ctx == NULL) {
                return WERR_DS_SERVICE_UNAVAILABLE;
        }
@@ -1165,7 +1166,7 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
 
        ZERO_STRUCT(r->out);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
        if (sam_ctx == NULL) {
                return WERR_GENERAL_FAILURE;
        }
index 0aa4d65d8c5ca22973bbed19bfce099b25157c6e..8ee77a6a30068342ed520be9ff5a4e5e854fce98 100644 (file)
@@ -156,7 +156,7 @@ static NTSTATUS dcesrv_samr_Connect(struct dcesrv_call_state *dce_call, TALLOC_C
        }
 
        /* make sure the sam database is accessible */
-       c_state->sam_ctx = samdb_connect(c_state, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
+       c_state->sam_ctx = samdb_connect(c_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
        if (c_state->sam_ctx == NULL) {
                talloc_free(c_state);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
@@ -4135,7 +4135,7 @@ static NTSTATUS dcesrv_samr_GetDomPwInfo(struct dcesrv_call_state *dce_call, TAL
 
        ZERO_STRUCT(r->out.info);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index ec91b8eadaf5491ad060becc18c2fb8ecd1d6fac..b78a9ceaa7b46c6cb9583da831f3832f0ac38e2f 100644 (file)
@@ -66,7 +66,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call,
        }
 
        /* To change a password we need to open as system */
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -205,7 +205,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
        }
 
        /* To change a password we need to open as system */
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -343,7 +343,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
        }
 
        /* To change a password we need to open as system */
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+       sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index e81b8cd0aaec0a1f3c822764b33d30447da04ba7..00f0d261ca5f0186c3a3538e72379420a1825880 100644 (file)
@@ -37,7 +37,6 @@
 #include "lib/messaging/irpc.h"
 #include "system/network.h"
 #include "lib/socket/netif.h"
-#include "build.h"
 #include "param/param.h"
 
 struct dcesrv_socket_context {
@@ -107,7 +106,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
        struct dcesrv_connection *dcesrv_conn = NULL;
        struct auth_session_info *session_info = NULL;
 
-       status = auth_anonymous_session_info(srv_conn, dcesrv_sock->dcesrv_ctx->lp_ctx, &session_info);
+       status = auth_anonymous_session_info(srv_conn, srv_conn->event.ctx, dcesrv_sock->dcesrv_ctx->lp_ctx, &session_info);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("dcesrv_sock_accept: auth_anonymous_session_info failed: %s\n", 
                        nt_errstr(status)));
@@ -471,7 +470,7 @@ NTSTATUS server_service_rpc_init(void)
        extern NTSTATUS dcerpc_server_samr_init(void);
        extern NTSTATUS dcerpc_server_remote_init(void);
        extern NTSTATUS dcerpc_server_lsa_init(void);
-       init_module_fn static_init[] = { STATIC_dcerpc_server_MODULES };
+       init_module_fn static_init[] = { STATIC_DCESRV_MODULES };
        init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
 
        run_init_functions(static_init);
index 7c701ec50a0ec0109bd5ac525fc460fa5957accc..28e30002e2d5d4461da3fac78abf62f528f3563a 100644 (file)
@@ -216,7 +216,7 @@ static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const st
        NTSTATUS status;
        struct ntptr_context *ntptr;
 
-       status = ntptr_init_context(dce_call->context, dce_call->conn->dce_ctx->lp_ctx,
+       status = ntptr_init_context(dce_call->context, dce_call->conn->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
                                    lp_ntptr_providor(dce_call->conn->dce_ctx->lp_ctx), &ntptr);
        NT_STATUS_NOT_OK_RETURN(status);
 
@@ -1156,7 +1156,8 @@ static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_
        creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */
 
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss, 
-                                 creds, NULL, dce_call->conn->dce_ctx->lp_ctx);
+                                      creds, dce_call->event_ctx,
+                                      dce_call->conn->dce_ctx->lp_ctx);
 
        if (NT_STATUS_IS_ERR(status)) {
                DEBUG(0, ("unable to call back to %s\n", r->in.str));
index 23e40d997653b95b16665536954f0d3d167b11cd..8dc42bf43b68a9604c85aed00cab5a063b588c1d 100644 (file)
@@ -445,7 +445,7 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL
                int count = 8;
                int i;
 
-               nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+               nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
                if (!NT_STATUS_IS_OK(nterr)) {
                        return ntstatus_to_werror(nterr);
                }
@@ -543,7 +543,7 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL
                int count = 10;
                int i;
 
-               nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+               nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
                if (!NT_STATUS_IS_OK(nterr)) {
                        return ntstatus_to_werror(nterr);
                }
@@ -735,7 +735,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
        /* TODO: - paging of results 
         */
 
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return ntstatus_to_werror(nterr);
        }
@@ -984,7 +984,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call,
                return WERR_INVALID_PARAM;
        }
 
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return ntstatus_to_werror(nterr);
        }
@@ -1238,7 +1238,7 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call,
                return WERR_INVALID_PARAM;
        }
 
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return ntstatus_to_werror(nterr);
        }
@@ -1415,7 +1415,7 @@ static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TA
        }
        all_string_sub(device, "\\", "/", 0);
 
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return ntstatus_to_werror(nterr);
        }
@@ -1499,7 +1499,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
 
                info101->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
                info101->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
-               info101->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
+               info101->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
                info101->comment        = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
                W_ERROR_HAVE_NO_MEMORY(info101->comment);
 
@@ -1519,7 +1519,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
 
                info102->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
                info102->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
-               info102->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
+               info102->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
                info102->comment        = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
                W_ERROR_HAVE_NO_MEMORY(info102->comment);
 
@@ -1829,7 +1829,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
        /* TODO: - paging of results 
         */
 
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return ntstatus_to_werror(nterr);
        }
@@ -2292,7 +2292,7 @@ static WERROR dcesrv_srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALL
        NTSTATUS nterr;
        struct share_context *sctx;
                
-       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(nterr)) {
                return ntstatus_to_werror(nterr);
        }
index 43fb24c0c36cc64d8574ffba42ed3ed3ccd2eeb3..f1cb35bdd8978339c3b5da7326d11263f30f90ce 100644 (file)
@@ -62,7 +62,7 @@ NTSTATUS srvsvc_create_ntvfs_context(struct dcesrv_call_state *dce_call,
        struct share_config *scfg;
        const char *sharetype;
 
-       status = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+       status = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
index 9993dc14c116630c4fb38faf3de3131cce7f0b09..22c60c354c5002b14a5469306212c5feb7f86360 100644 (file)
@@ -37,7 +37,7 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
        WERROR err;
 
        err = reg_open_samba(dce_call->context,
-                            &ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info,
+                            &ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info,
                             NULL);
 
        if (!W_ERROR_IS_OK(err)) {
index 496af316ec535bacc2c774dac3ae99c57078a1a5..1d8651c80b5c9e359355d8ea04842be5049cd95a 100644 (file)
@@ -33,3 +33,11 @@ rpc.netlogon.*.GetTrustPasswords
 base.charset.*.Testing partial surrogate
 .*net.api.delshare.*                           # DelShare isn't implemented yet
 rap.*netservergetinfo
+smb2.persistent.handles1
+samba4.winbind.struct.*.LIST_GROUPS       # Not yet working in winbind
+samba4.winbind.struct.*.SHOW_SEQUENCE     # Not yet working in winbind
+samba4.winbind.struct.*.GETPWENT          # Not yet working in winbind
+samba4.winbind.struct.*.SETPWENT          # Not yet working in winbind
+samba4.winbind.struct.*.LOOKUP_NAME_SID   # Not yet working in winbind
+
+
index 19ff924794d3c92969f1c66f418573f24398955d..4ac35a3c786d6ed6016dd79cbaa00c4f55071c14 100644 (file)
@@ -4,12 +4,13 @@ base.iometer
 base.casetable
 base.nttrans
 .*base.bench.holdcon.*                         # Very slow
+raw.bench.lookup       # Very slow
 base.scan.maxfid
-raw.hold.oplock
-raw.ping.pong
+raw.hold.oplock                # Not a test, but a way to block other clients for a test
+raw.ping.pong          # Needs second server to test
 rpc.samr_accessmask
 raw.scan.eamax
-raw.qfileinfo.ipc
+samba4.ntvfs.cifs.raw.qfileinfo.ipc
 base.utable
 base.smb
 smb2.notify
@@ -38,10 +39,14 @@ rpc.initshutdown                                    # Not provided by Samba 4
 rpc.svcctl                                                     # Not provided by Samba 4
 rpc.atsvc                                                      # Not provided by Samba 4
 rpc.frsapi                                                     # Not provided by Samba 4
-.*samba3.*                                                     # Samba3-specific test
+^samba4.base.samba3.*                                          # Samba3-specific test
+^samba4.ntvfs.cifs.base.samba3.*                               # Samba3-specific test
+^samba4.raw.samba3.*                                           # Samba3-specific test
+^samba4.ntvfs.cifs.raw.samba3.*                                        # Samba3-specific test
+samba4.ntvfs.cifs.raw.
+^samba4.rpc..*samba3.*                                         # Samba3-specific test
 ^samba4.net.domopen.*$                         # Hangs for some reason
 ^samba4.net.api.become.dc.*$                   # Fails
-winbind                                                        # FIXME: This should not be skipped
 nss.test                                               # Fails
 samba4.samba3sam.python                # Conversion from EJS not yet finished
 samba4.samdb.python                    # Not finished yet
index c14e4730e0099e58377bb1d8058d6f263ca7346b..9f2391ad6c30f4cfc390ed93fe569d7c6639b5ab 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 my $firstline = 1;
-
+my $error = 0;
 while(<STDIN>) {
        if ($firstline) {
                $firstline = 0;
@@ -10,6 +10,7 @@ while(<STDIN>) {
        if (/^not ok (\d+) - (.*)$/) {
                print "test: $2\n";
                print "failure: $2\n";
+               $error = 1;
        } elsif (/^ok (\d+) - (.*)$/) {
                print "test: $2\n";
                print "success: $2\n";
@@ -22,7 +23,10 @@ while(<STDIN>) {
        } elsif (/^not ok (\d+)$/) {
                print "test: $1\n";
                print "failure: $1\n";
+               $error = 1;
        } else {
                print;
        }
 }
+exit $error;
+
index d1f96b2592fb8cbd7831ba237968546032e0bdf3..6b10bde65f33775ec982c19a0cd7b47b60aadddf 100755 (executable)
@@ -60,6 +60,8 @@ sub install_header($$)
 
        while (<IN>) {
                $lineno++;
+               die("Will not install autogenerated header $src") if (/This file was automatically generated by mkproto.pl. DO NOT EDIT/);
+
                if (/^#include \"(.*)\"/) {
                        print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n";
                } else {
index fb9d7b05aa222687348a8ca8c65055354972445f..111557126d4032d18ab2cee255e146a9eaf4b640 100755 (executable)
@@ -4,6 +4,12 @@
 #
 
 import optparse
+
+import os, sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
 import samba
 from samba import getopt as options
 import sys
index 34efafdf730cdef7106479a2dde0b358e069ceae..aba4f9ddb3e666c647802e15c139317052a88fc0 100755 (executable)
@@ -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
index 8f56d423d8cef16ef84a0af2ba75af9b249f638f..d89667233f154635bd9d263c673c5b6e8edccd40 100755 (executable)
@@ -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/source/scripting/bin/samr.py b/source/scripting/bin/samr.py
new file mode 100755 (executable)
index 0000000..e91b5bc
--- /dev/null
@@ -0,0 +1,114 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# Copyright Â© Jelmer Vernooij <jelmer@samba.org> 2008
+#
+# Based on samr.js Â© Andrew Tridgell <tridge@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/>.
+#
+
+import sys
+
+sys.path.insert(0, "bin/python")
+
+from samba.dcerpc import samr, security, lsa
+
+def FillUserInfo(samr, dom_handle, users, level):
+    """fill a user array with user information from samrQueryUserInfo"""
+    for i in range(len(users)):
+        user_handle = samr.OpenUser(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, users[i].idx)
+        info = samr.QueryUserInfo(user_handle, level)
+        info.name = users[i].name
+        info.idx  = users[i].idx
+        users[i] = info
+        samr.Close(user_handle)
+
+def toArray((handle, array, num_entries)):
+    ret = []
+    for x in range(num_entries):
+        ret.append((array.entries[x].idx, array.entries[x].name))
+    return ret
+    
+
+def test_Connect(samr):
+    """test the samr_Connect interface"""
+    print "Testing samr_Connect"
+    return samr.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+def test_LookupDomain(samr, handle, domain):
+    """test the samr_LookupDomain interface"""
+    print "Testing samr_LookupDomain"
+    return samr.LookupDomain(handle, domain)
+
+def test_OpenDomain(samr, handle, sid):
+    """test the samr_OpenDomain interface"""
+    print "Testing samr_OpenDomain"
+    return samr.OpenDomain(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, sid)
+
+def test_EnumDomainUsers(samr, dom_handle):
+    """test the samr_EnumDomainUsers interface"""
+    print "Testing samr_EnumDomainUsers"
+    users = toArray(samr.EnumDomainUsers(dom_handle, 0, 0, -1))
+    print "Found %d users" % len(users)
+    for idx, user in users:
+        print "\t%s\t(%d)" % (user, idx)
+
+def test_EnumDomainGroups(samr, dom_handle):
+    """test the samr_EnumDomainGroups interface"""
+    print "Testing samr_EnumDomainGroups"
+    groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0))
+    print "Found %d groups" % len(groups)
+    for idx, group in groups:
+        print "\t%s\t(%d)" % (group, idx)
+
+def test_domain_ops(samr, dom_handle):
+    """test domain specific ops"""
+    test_EnumDomainUsers(samr, dom_handle)
+    test_EnumDomainGroups(samr, dom_handle)
+
+def test_EnumDomains(samr, handle):
+    """test the samr_EnumDomains interface"""
+    print "Testing samr_EnumDomains"
+
+    domains = toArray(samr.EnumDomains(handle, 0, -1))
+    print "Found %d domains" % len(domains)
+    for idx, domain in domains:
+        print "\t%s (%d)" % (domain, idx)
+    for idx, domain in domains:
+        print "Testing domain %s" % domain
+        sid = samr.LookupDomain(handle, domain)
+        dom_handle = test_OpenDomain(samr, handle, sid)
+        test_domain_ops(samr, dom_handle)
+        samr.Close(dom_handle)
+
+if len(sys.argv) != 2:
+   print "Usage: samr.js <BINDING>"
+   sys.exit(1)
+
+binding = sys.argv[1]
+
+print "Connecting to " + binding
+try:
+    samr = samr.samr(binding)
+except Exception, e:
+    print "Failed to connect to %s: %s" % (binding, e.message)
+    sys.exit(1)
+
+handle = test_Connect(samr)
+test_EnumDomains(samr, handle)
+samr.Close(handle)
+
+print "All OK"
index fbbffde42cd5840473c0307a6bbe3d4c6a9f5155..6f1086ad376c653087cb703a78dd61dd2e351c35 100755 (executable)
 # 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
-import param
+from samba import param
 import samba.getopt as options
 import samba.tests
 
index 1e39ee8f78e41a25f0432e48e304993806d3afea..19d39e56ab3a37b36c6f8aed14c8aff4cf7b5d1b 100755 (executable)
@@ -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
index cadd71673ceceb71b060baf64bca3d535e0c3464..c1a1ca1f0f7fcf904817a78a7c895a45a42fa8df 100644 (file)
@@ -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,41 +45,42 @@ 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
 SUBSYSTEM = smbcalls
 INIT_FUNCTION = smb_setup_ejs_auth
-PRIVATE_DEPENDENCIES = 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 = $(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 \
@@ -88,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 \
@@ -98,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]
@@ -105,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
index 85a5b2bf091fbaceecc8fa818354c35f33676acc..710221e37d11635a370262b7269c5fb96996916b 100644 (file)
@@ -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)))
index 99be1c4ef8e10166c19a8972c6ea82e795bedbe6..cbe163552e2653704d4abca508f56ca8f9798a5c 100644 (file)
@@ -50,7 +50,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
                ejsSetErrorMsg(eid, "talloc_new() failed");
                return -1;
        }
-       ev = event_context_find(event_mem_ctx);
+       ev = mprEventCtx();
 
        ctx = libnet_context_init(ev, mprLpCtx());
        /* IF we generated a new event context, it will be under here,
index 57e538d3b4de725b0476f506defa9c14200fc61a..0c32035c6cb827259ef8b291438047a08540ccb9 100644 (file)
@@ -268,8 +268,9 @@ static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
 
        /* call the libnet function */
        req.in.domain_name = userman_domain;
-       req.in.user_name   = username;
-       
+       req.in.data.user_name   = username;
+       req.in.level = USER_INFO_BY_NAME;
+
        status = libnet_UserInfo(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
                ejsSetErrorMsg(eid, "%s", req.out.error_string);
index b1a2f6a37b83eb2be267b9a5c2f14101722b984c..98d6be07bf9a8ebd03e474acce6d2738b8ec6528 100644 (file)
@@ -23,7 +23,6 @@
 #include "includes.h"
 #include "param/param.h"
 #include "scripting/ejs/smbcalls.h"
-#include "build.h"
 #include "version.h"
 
 /*
index 908a009159a09c4a0d118b3ba9401308c04d3940..b67bb7ed5bde10163bdce0f9e4750a5627bf4fd5 100644 (file)
@@ -55,7 +55,7 @@ static int ejs_doauth(MprVarHandle eid,
                msg = c->msg_ctx;
        } else {
                /* Hope we can find the event context somewhere up there... */
-               ev = event_context_find(tmp_ctx);
+               ev = mprEventCtx();
                msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, mprLpCtx()), 
                                            lp_iconv_convenience(mprLpCtx()), ev);
        }
@@ -109,7 +109,7 @@ static int ejs_doauth(MprVarHandle eid,
                goto done;
        }
 
-       nt_status = auth_generate_session_info(tmp_ctx, mprLpCtx(), server_info, &session_info);
+       nt_status = auth_generate_session_info(tmp_ctx, mprEventCtx(), mprLpCtx(), server_info, &session_info);
        if (!NT_STATUS_IS_OK(nt_status)) {
                mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
                mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
index f47920b9bb5fd04d306c40ff88fc7ddcfd625f84..4a157945af5cdf9184792e3187addc87e05b2454 100644 (file)
@@ -453,7 +453,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv)
 
        dbfile = argv[0];
 
-       ldb = ldb_wrap_connect(mprMemCtx(), mprLpCtx(), dbfile, 
+       ldb = ldb_wrap_connect(mprMemCtx(), mprEventCtx(), mprLpCtx(), dbfile, 
                               session_info, creds,
                               0, (const char **)(argv+1));
        if (ldb == NULL) {
index 67a85414caf718fbf110c6203531487688e32da2..8c555bf821ca702b4ae34caa2b68677310b13782 100644 (file)
@@ -70,7 +70,7 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
 
        result = 0;
 
-       nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, event_context_find(tmp_ctx));
+       nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, mprEventCtx());
 
        if (NT_STATUS_IS_OK(nt_status)) {
                mprSetPropertyValue(argv[0], "value", mprString(reply_addr));
index e20d91ad2eeef7b5dec0566a6f4f78b4cdcd7711..ed8653d3a7b3b46c3faefde2a8c7eb05bc2bb900 100644 (file)
@@ -70,7 +70,7 @@ static int ejs_reg_open(MprVarHandle eid, int argc, struct MprVar **argv)
        struct registry_context *rctx;
        WERROR error;
 
-       error = reg_open_samba(mprMemCtx(), &rctx, mprLpCtx(), NULL, NULL);
+       error = reg_open_samba(mprMemCtx(), &rctx, mprEventCtx(), mprLpCtx(), NULL, NULL);
        SMB_ASSERT(W_ERROR_IS_OK(error));
 
        mprSetPtrChild(reg, "registry", rctx);
index d1e49b4348a97823eab5fc498e4ada7c17a07c3c..94774d708bbb0008a6d9ea650fe4d02e9d9e6676 100644 (file)
@@ -73,7 +73,7 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
 
        p->server_name = argv[0];
 
-       ev = event_context_find(p);
+       ev = mprEventCtx();
 
        /* create a messaging context, looping as we have no way to
           allocate temporary server ids automatically */
@@ -158,7 +158,7 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
                cli_credentials_set_anonymous(creds);
        }
 
-       ev = event_context_find(mprMemCtx());
+       ev = mprEventCtx();
 
        status = dcerpc_pipe_connect(this, &p, binding, iface, creds, ev,
                                     mprLpCtx());
diff --git a/source/scripting/libjs/provision.js b/source/scripting/libjs/provision.js
deleted file mode 100644 (file)
index 51e2785..0000000
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*
-       backend code for provisioning a Samba4 server
-       Copyright Andrew Tridgell 2005
-       Released under the GNU GPL version 3 or later
-*/
-
-sys = sys_init();
-
-/*
-  return true if the current install seems to be OK
-*/
-function install_ok(session_info, credentials)
-{
-       var lp = loadparm_init();
-       var ldb = ldb_init();
-       ldb.session_info = session_info;
-       ldb.credentials = credentials;
-       if (lp.get("realm") == "") {
-               return false;
-       }
-       var ok = ldb.connect(lp.get("sam database"));
-       if (!ok) {
-               return false;
-       }
-       var res = ldb.search("(cn=Administrator)");
-       if (res.error != 0 || res.msgs.length != 1) {
-               return false;
-       }
-       return true;
-}
-
-/*
-  find a user or group from a list of possibilities
-*/
-function findnss()
-{
-       var i;
-       assert(arguments.length >= 2);
-       var nssfn = arguments[0];
-       for (i=1;i<arguments.length;i++) {
-               if (nssfn(arguments[i]) != undefined) {
-                       return arguments[i];
-               }
-       }
-       printf("Unable to find user/group for %s\n", arguments[1]);
-       assert(i<arguments.length);
-}
-
-/*
-   add a foreign security principle
- */
-function add_foreign(ldb, subobj, sid, desc)
-{
-       var add = sprintf("
-dn: CN=%s,CN=ForeignSecurityPrincipals,%s
-objectClass: top
-objectClass: foreignSecurityPrincipal
-description: %s
-",
-                         sid, subobj.DOMAINDN, desc);
-       /* deliberately ignore errors from this, as the records may
-          already exist */
-       ldb.add(add);
-}
-
-
-/*
-  setup a mapping between a sam name and a unix name
- */
-function setup_name_mapping(info, ldb, sid, unixname)
-{
-       var attrs = new Array("dn");
-       var res = ldb.search(sprintf("objectSid=%s", sid), 
-                            info.subobj.DOMAINDN, ldb.SCOPE_SUBTREE, attrs);
-       if (res.error != 0 || res.msgs.length != 1) {
-               info.message("Failed to find record for objectSid %s\n", sid);
-               return false;
-       }
-       var mod = sprintf("
-dn: %s
-changetype: modify
-replace: unixName
-unixName: %s
-",
-                         res.msgs[0].dn, unixname);
-       var ok = ldb.modify(mod);
-       if (ok.error != 0) {
-               info.message("name mapping for %s failed - %s\n",
-                            sid, ldb.errstring());
-               return false;
-       }
-       return true;
-}
-
-/*
-  return current time as a nt time string
-*/
-function nttime()
-{
-       return "" + sys.nttime();
-}
-
-/*
-  return current time as a ldap time string
-*/
-function ldaptime()
-{
-       return sys.ldaptime(sys.nttime());
-}
-
-/*
-  return a date string suitable for a dns zone serial number
-*/
-function datestring()
-{
-       var t = sys.ntgmtime(sys.nttime());
-       return sprintf("%04u%02u%02u%02u",
-                      t.tm_year+1900, t.tm_mon+1, t.tm_mday, t.tm_hour);
-}
-
-/*
-  return first host IP
-*/
-function hostip()
-{
-       var list = sys.interfaces();
-       return list[0];
-}
-
-
-/*
-  return first part of hostname
-*/
-function hostname()
-{
-       var s = split(".", sys.hostname());
-       return s[0];
-}
-
-/* the ldb is in bad shape, possibly due to being built from an
-   incompatible previous version of the code, so delete it
-   completely */
-function ldb_delete(info, ldb)
-{
-       info.message("Deleting " + ldb.filename + "\n");
-       var lp = loadparm_init();
-       sys.unlink(sprintf("%s/%s", lp.get("private dir"), ldb.filename));
-       ldb.transaction_cancel();
-       ldb.close();
-       var ok = ldb.connect(ldb.filename);
-       ldb.transaction_start();
-       assert(ok);
-}
-
-/*
-  erase an ldb, removing all records
-*/
-function ldb_erase(info, ldb)
-{
-       var res;
-
-       /* delete the specials */
-       ldb.del("@INDEXLIST");
-       ldb.del("@ATTRIBUTES");
-       ldb.del("@OPTIONS");
-       ldb.del("@MODULES");
-       ldb.del("@PARTITION");
-       ldb.del("@KLUDGEACL");
-
-       /* and the rest */
-       attrs = new Array("dn");
-       var basedn = "";
-       var res = ldb.search("(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
-       var i;
-       if (res.error != 0) {
-               ldb_delete(info, ldb);
-               return;
-       }
-       for (i=0;i<res.msgs.length;i++) {
-               ldb.del(res.msgs[i].dn);
-       }
-
-       var res = ldb.search("(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
-       if (res.error != 0 || res.msgs.length != 0) {
-               ldb_delete(info, ldb);
-               return;
-       }
-       assert(res.msgs.length == 0);
-}
-
-/*
-  erase an ldb, removing all records
-*/
-function ldb_erase_partitions(info, ldb, ldapbackend)
-{
-       var rootDSE_attrs = new Array("namingContexts");
-       var lp = loadparm_init();
-       var j;
-
-       var res = ldb.search("(objectClass=*)", "", ldb.SCOPE_BASE, rootDSE_attrs);
-       if (res.error != 0) {
-               info.message("rootdse search failed: " + res.errstr + "\n");
-               assert(res.error == 0);
-       }
-       assert(res.msgs.length == 1);
-       if (typeof(res.msgs[0].namingContexts) == "undefined") {
-               return;
-       }       
-       for (j=0; j<res.msgs[0].namingContexts.length; j++) {
-               var anything = "(|(objectclass=*)(distinguishedName=*))";
-               var attrs = new Array("distinguishedName");
-               var basedn = res.msgs[0].namingContexts[j];
-               var k;
-               var previous_remaining = 1;
-               var current_remaining = 0;
-
-               if (ldapbackend && (basedn == info.subobj.DOMAINDN)) {
-                       /* Only delete objects that were created by provision */
-                       anything = "(objectcategory=*)";
-               }
-
-               for (k=0; k < 10 && (previous_remaining != current_remaining); k++) {
-                       /* and the rest */
-                       var res2 = ldb.search(anything, basedn, ldb.SCOPE_SUBTREE, attrs);
-                       var i;
-                       if (res2.error != 0) {
-                               if (res2.error == 32) {
-                                       break;
-                               } else {
-                                       info.message("ldb search(2) failed: " + res2.errstr + "\n");
-                                       continue;
-                               }
-                       }
-                       previous_remaining = current_remaining;
-                       current_remaining = res2.msgs.length;
-                       for (i=0;i<res2.msgs.length;i++) {
-                               ldb.del(res2.msgs[i].dn);
-                       }
-                       
-                       var res3 = ldb.search(anything, basedn, ldb.SCOPE_SUBTREE, attrs);
-                       if (res3.error != 0) {
-                               info.message("ldb search(3) failed: " + res3.errstr + "\n");
-                               continue;
-                       }
-                       if (res3.msgs.length != 0) {
-                               info.message("Failed to delete all records under " + basedn + ", " + res3.msgs.length + " records remaining\n");
-                       }
-               }
-       }
-}
-
-function open_ldb(info, dbname, erase)
-{
-       var ldb = ldb_init();
-       ldb.session_info = info.session_info;
-       ldb.credentials = info.credentials;
-       ldb.filename = dbname;
-
-       var connect_ok = ldb.connect(dbname);
-       if (!connect_ok) {
-               var lp = loadparm_init();
-               sys.unlink(sprintf("%s/%s", lp.get("private dir"), dbname));
-               connect_ok = ldb.connect(dbname);
-               assert(connect_ok);
-       }
-
-       ldb.transaction_start();
-
-       if (erase) {
-               ldb_erase(info, ldb);   
-       }
-       return ldb;
-}
-
-
-/*
-  setup a ldb in the private dir
- */
-function setup_add_ldif(ldif, info, ldb, failok)
-{
-       var lp = loadparm_init();
-       var src = lp.get("setup directory") + "/" + ldif;
-
-       var data = sys.file_load(src);
-       data = substitute_var(data, info.subobj);
-
-       var add_res = ldb.add(data);
-       if (add_res.error != 0) {
-               info.message("ldb load failed: " + add_res.errstr + "\n");
-               if (!failok) {
-                       assert(add_res.error == 0);
-               }
-       }
-       return (add_res.error == 0);
-}
-
-function setup_modify_ldif(ldif, info, ldb, failok)
-{
-       var lp = loadparm_init();
-       var src = lp.get("setup directory") + "/" + ldif;
-
-       var data = sys.file_load(src);
-       data = substitute_var(data, info.subobj);
-
-       var mod_res = ldb.modify(data);
-       if (mod_res.error != 0) {
-               info.message("ldb load failed: " + mod_res.errstr + "\n");
-               if (!failok) {
-                       assert(mod_res.error == 0);
-               }
-       }
-       return (mod_res.error == 0);
-}
-
-
-function setup_ldb(ldif, info, dbname) 
-{
-       var erase = true;
-       var failok = false;
-
-       if (arguments.length >= 4) {
-               erase = arguments[3];
-        }
-       if (arguments.length == 5) {
-               failok = arguments[4];
-        }
-       var ldb = open_ldb(info, dbname, erase);
-       if (setup_add_ldif(ldif, info, ldb, failok)) {
-               var commit_ok = ldb.transaction_commit();
-               if (!commit_ok) {
-                       info.message("ldb commit failed: " + ldb.errstring() + "\n");
-                       assert(commit_ok);
-               }
-       }
-}
-
-/*
-  setup a ldb in the private dir
- */
-function setup_ldb_modify(ldif, info, ldb)
-{
-       var lp = loadparm_init();
-
-       var src = lp.get("setup directory") + "/" + ldif;
-
-       var data = sys.file_load(src);
-       data = substitute_var(data, info.subobj);
-
-       var mod_res = ldb.modify(data);
-       if (mod_res.error != 0) {
-               info.message("ldb load failed: " + mod_res.errstr + "\n");
-               return (mod_res.error == 0);
-       }
-       return (mod_res.error == 0);
-}
-
-/*
-  setup a file in the private dir
- */
-function setup_file(template, message, fname, subobj)
-{
-       var lp = loadparm_init();
-       var f = fname;
-       var src = lp.get("setup directory") + "/" + template;
-
-       if (! sys.stat(src)) {
-               message("Template file not found: %s\n",src);
-               assert(0);
-       }
-
-       sys.unlink(f);
-
-       var data = sys.file_load(src);
-       data = substitute_var(data, subobj);
-
-       ok = sys.file_save(f, data);
-       if (!ok) {
-               message("failed to create file: " + f + "\n");
-               assert(ok);
-       }
-}
-
-function provision_default_paths(subobj)
-{
-       /* subobj.DNSDOMAIN isn't available at this point */
-       var dnsdomain = strlower(subobj.REALM);
-       var lp = loadparm_init();
-       var paths = new Object();
-       paths.smbconf = lp.filename()
-       paths.shareconf = lp.get("private dir") + "/" + "share.ldb";
-       paths.samdb = lp.get("sam database");
-       paths.idmapdb = lp.get("idmap database");
-       paths.secrets = lp.get("secrets database");
-       paths.templates = lp.get("private dir") + "/" + "templates.ldb";
-       paths.keytab = "secrets.keytab";
-       paths.dns_keytab = "dns.keytab";
-       paths.dns_keytab_abs = lp.get("private dir") + "/" + paths.dns_keytab;
-       paths.dns = lp.get("private dir") + "/" + dnsdomain + ".zone";
-       paths.named_conf = lp.get("private dir") + "/named.conf";
-       paths.winsdb = "wins.ldb";
-       paths.ldapdir = lp.get("private dir") + "/ldap";
-
-       paths.s4_ldapi_socket = lp.get("private dir") + "/ldapi";
-       paths.phpldapadminconfig = lp.get("private dir") + "/phpldapadmin-config.php";
-
-       paths.sysvol = lp.get("sysvol", "path");
-
-       if (paths.sysvol == undefined) {
-               paths.sysvol = lp.get("lock dir") + "/sysvol";
-       }
-       
-       paths.netlogon = lp.get("netlogon", "path");
-       
-       if (paths.netlogon == undefined) {
-               paths.netlogon = paths.sysvol + "/" + dnsdomain + "/scripts";
-       }
-
-       return paths;
-}
-
-
-/*
-  setup reasonable name mappings for sam names to unix names
-*/
-function setup_name_mappings(info, ldb)
-{
-       var lp = loadparm_init();
-       var attrs = new Array("objectSid");
-       var subobj = info.subobj;
-
-       res = ldb.search("objectSid=*", subobj.DOMAINDN, ldb.SCOPE_BASE, attrs);
-       assert(res.error == 0);
-       assert(res.msgs.length == 1 && res.msgs[0].objectSid != undefined);
-       var sid = res.msgs[0].objectSid;
-
-       /* add some foreign sids if they are not present already */
-       add_foreign(ldb, subobj, "S-1-5-7",  "Anonymous");
-       add_foreign(ldb, subobj, "S-1-1-0",  "World");
-       add_foreign(ldb, subobj, "S-1-5-2",  "Network");
-       add_foreign(ldb, subobj, "S-1-5-18", "System");
-       add_foreign(ldb, subobj, "S-1-5-11", "Authenticated Users");
-
-       /* some well known sids */
-       setup_name_mapping(info, ldb, "S-1-5-7",  subobj.NOBODY);
-       setup_name_mapping(info, ldb, "S-1-1-0",  subobj.NOGROUP);
-       setup_name_mapping(info, ldb, "S-1-5-2",  subobj.NOGROUP);
-       setup_name_mapping(info, ldb, "S-1-5-18", subobj.ROOT);
-       setup_name_mapping(info, ldb, "S-1-5-11", subobj.USERS);
-       setup_name_mapping(info, ldb, "S-1-5-32-544", subobj.WHEEL);
-       setup_name_mapping(info, ldb, "S-1-5-32-545", subobj.USERS);
-       setup_name_mapping(info, ldb, "S-1-5-32-546", subobj.NOGROUP);
-       setup_name_mapping(info, ldb, "S-1-5-32-551", subobj.BACKUP);
-
-       /* and some well known domain rids */
-       setup_name_mapping(info, ldb, sid + "-500", subobj.ROOT);
-       setup_name_mapping(info, ldb, sid + "-518", subobj.WHEEL);
-       setup_name_mapping(info, ldb, sid + "-519", subobj.WHEEL);
-       setup_name_mapping(info, ldb, sid + "-512", subobj.WHEEL);
-       setup_name_mapping(info, ldb, sid + "-513", subobj.USERS);
-       setup_name_mapping(info, ldb, sid + "-520", subobj.WHEEL);
-
-       return true;
-}
-
-function provision_fix_subobj(subobj, paths)
-{
-       var ldb = ldb_init();
-       
-       subobj.REALM       = strupper(subobj.REALM);
-       subobj.HOSTNAME    = strlower(subobj.HOSTNAME);
-       subobj.DOMAIN      = strupper(subobj.DOMAIN);
-       subobj.NETBIOSNAME = strupper(subobj.HOSTNAME);
-       subobj.DNSDOMAIN    = strlower(subobj.REALM);
-       subobj.DNSNAME      = sprintf("%s.%s", 
-                                     strlower(subobj.HOSTNAME), 
-                                     subobj.DNSDOMAIN);
-       var rdn_list = split(".", subobj.DNSDOMAIN);
-       subobj.DOMAINDN     = "DC=" + join(",DC=", rdn_list);
-       subobj.ROOTDN       = subobj.DOMAINDN;
-       subobj.CONFIGDN     = "CN=Configuration," + subobj.ROOTDN;
-       subobj.SCHEMADN     = "CN=Schema," + subobj.CONFIGDN;
-
-       subobj.MACHINEPASS_B64 = ldb.encode(subobj.MACHINEPASS);
-       subobj.KRBTGTPASS_B64  = ldb.encode(subobj.KRBTGTPASS);
-       subobj.ADMINPASS_B64   = ldb.encode(subobj.ADMINPASS);
-       subobj.DNSPASS_B64     = ldb.encode(subobj.DNSPASS);
-
-       subobj.SAM_LDB          = "tdb://" + paths.samdb;
-       subobj.SECRETS_KEYTAB   = paths.keytab;
-       subobj.DNS_KEYTAB       = paths.dns_keytab;
-       subobj.DNS_KEYTAB_ABS   = paths.dns_keytab_abs;
-
-       subobj.LDAPDIR = paths.ldapdir;
-       var ldap_path_list = split("/", paths.ldapdir);
-       subobj.LDAPI_URI = "ldapi://" + join("%2F", ldap_path_list) + "%2Fldapi";
-
-       var s4ldap_path_list = split("/", paths.s4_ldapi_socket);
-       subobj.S4_LDAPI_URI = "ldapi://" + join("%2F", s4ldap_path_list);
-
-       subobj.LDAPMANAGERDN = "cn=Manager," + subobj.DOMAINDN;
-
-       subobj.NETLOGONPATH = paths.netlogon;
-       subobj.SYSVOLPATH = paths.sysvol;
-
-       if (subobj.DOMAIN_CONF == undefined) {
-               subobj.DOMAIN_CONF = subobj.DOMAIN;
-       }
-       if (subobj.REALM_CONF == undefined) {
-               subobj.REALM_CONF = subobj.REALM;
-       }
-       if (strlower(subobj.SERVERROLE) != strlower("domain controller")) {
-               subobj.REALM = subobj.HOSTNAME;
-               subobj.DOMAIN = subobj.HOSTNAME;
-       }
-
-       return true;
-}
-
-function provision_become_dc(subobj, message, erase, paths, session_info)
-{
-       var lp = loadparm_init();
-       var sys = sys_init();
-       var info = new Object();
-
-       var ok = provision_fix_subobj(subobj, paths);
-       assert(ok);
-
-       if (subobj.BACKEND_MOD == undefined) {
-               subobj.BACKEND_MOD = "repl_meta_data";
-       }
-
-       info.subobj = subobj;
-       info.message = message;
-       info.session_info = session_info;
-
-       message("Setting up templates into " + paths.templates + "\n");
-       setup_ldb("provision_templates.ldif", info, paths.templates);
-
-       /* Also wipes the database */
-       message("Setting up " + paths.samdb + " partitions\n");
-       setup_ldb("provision_partitions.ldif", info, paths.samdb);
-
-       var samdb = open_ldb(info, paths.samdb, false);
-
-       message("Setting up " + paths.samdb + " attributes\n");
-       setup_add_ldif("provision_init.ldif", info, samdb, false);
-
-       message("Setting up " + paths.samdb + " rootDSE\n");
-       setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
-
-       if (erase) {
-               message("Erasing data from partitions\n");
-               ldb_erase_partitions(info, samdb, undefined);
-       }
-
-       message("Setting up " + paths.samdb + " indexes\n");
-       setup_add_ldif("provision_index.ldif", info, samdb, false);
-
-       ok = samdb.transaction_commit();
-       assert(ok);
-
-       message("Setting up " + paths.secrets + "\n");
-       setup_ldb("secrets_init.ldif", info, paths.secrets);
-
-       setup_ldb("secrets.ldif", info, paths.secrets, false);
-
-       setup_ldb("secrets_dc.ldif", info, paths.secrets, false);
-
-       return true;
-}
-
-function load_schema(subobj, message, samdb)
-{
-       var lp = loadparm_init();
-       var src = lp.get("setup directory") + "/" + "schema.ldif";
-
-       if (! sys.stat(src)) {
-               message("Template file not found: %s\n",src);
-               assert(0);
-       }
-
-       var schema_data = sys.file_load(src);
-
-       src = lp.get("setup directory") + "/" + "schema_samba4.ldif";
-
-       if (! sys.stat(src)) {
-               message("Template file not found: %s\n",src);
-               assert(0);
-       }
-
-       schema_data = schema_data + sys.file_load(src);
-
-       schema_data = substitute_var(schema_data, subobj);
-
-       src = lp.get("setup directory") + "/" + "provision_schema_basedn_modify.ldif";
-
-       if (! sys.stat(src)) {
-               message("Template file not found: %s\n",src);
-               assert(0);
-       }
-
-       var head_data = sys.file_load(src);
-       head_data = substitute_var(head_data, subobj);
-
-       var ok = samdb.attach_dsdb_schema_from_ldif(head_data, schema_data);
-       return ok;
-}
-
-
-/*
-  provision samba4 - caution, this wipes all existing data!
-*/
-function provision(subobj, message, blank, paths, session_info, credentials, ldapbackend)
-{
-       var lp = loadparm_init();
-       var sys = sys_init();
-       var info = new Object();
-       random_init(local);
-
-       var ok = provision_fix_subobj(subobj, paths);
-       assert(ok);
-
-       if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
-               if (subobj.BACKEND_MOD == undefined) {
-                       subobj.BACKEND_MOD = "repl_meta_data";
-               }
-       } else {
-               if (subobj.BACKEND_MOD == undefined) {
-                       subobj.BACKEND_MOD = "objectguid";
-               }
-       }
-
-       if (subobj.DOMAINGUID != undefined) {
-               subobj.DOMAINGUID_MOD = sprintf("replace: objectGUID\nobjectGUID: %s\n-", subobj.DOMAINGUID);
-       } else {
-               subobj.DOMAINGUID_MOD = "";
-       }
-
-       if (subobj.HOSTGUID != undefined) {
-               subobj.HOSTGUID_ADD = sprintf("objectGUID: %s", subobj.HOSTGUID);
-       } else {
-               subobj.HOSTGUID_ADD = "";
-       }
-
-       info.subobj = subobj;
-       info.message = message;
-       info.credentials = credentials;
-       info.session_info = session_info;
-
-       /* only install a new smb.conf if there isn't one there already */
-       var st = sys.stat(paths.smbconf);
-       if (st == undefined) {
-               var smbconfsuffix;
-               if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
-                       smbconfsuffix = "dc";
-               } else if (strlower(subobj.SERVERROLE) == strlower("member server")) {
-                       smbconfsuffix = "member";
-               } else {
-                       smbconfsuffix = subobj.SERVERROLE;
-               }
-               message("Setting up " + paths.smbconf +"\n");
-               setup_file("provision.smb.conf." + smbconfsuffix, info.message, paths.smbconf, subobj);
-               lp.reload();
-       }
-       /* only install a new shares config db if there is none */
-       st = sys.stat(paths.shareconf);
-       if (st == undefined) {
-               message("Setting up share.ldb\n");
-               setup_ldb("share.ldif", info, paths.shareconf);
-       }
-
-       message("Setting up " + paths.secrets + "\n");
-       setup_ldb("secrets_init.ldif", info, paths.secrets);
-       setup_ldb("secrets.ldif", info, paths.secrets, false);
-
-       message("Setting up the registry\n");
-       var reg = reg_open();
-       reg.apply_patchfile(lp.get("setup directory") + "/provision.reg")
-
-       message("Setting up templates into " + paths.templates + "\n");
-       setup_ldb("provision_templates.ldif", info, paths.templates);
-
-       message("Setting up " + paths.idmapdb +"\n");
-       setup_ldb("idmap_init.ldif", info, paths.idmapdb);
-
-       message("Setting up sam.ldb partitions\n");
-       /* Also wipes the database */
-       setup_ldb("provision_partitions.ldif", info, paths.samdb);
-
-       var samdb = open_ldb(info, paths.samdb, false);
-
-       message("Setting up sam.ldb attributes\n");
-       setup_add_ldif("provision_init.ldif", info, samdb, false);
-
-       message("Setting up sam.ldb rootDSE\n");
-       setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
-
-       message("Erasing data from partitions\n");
-       ldb_erase_partitions(info, samdb, ldapbackend);
-       
-       // (hack) Reload, now we have the partitions and rootdse loaded.  
-       var commit_ok = samdb.transaction_commit();
-       if (!commit_ok) {
-               info.message("samdb commit failed: " + samdb.errstring() + "\n");
-               assert(commit_ok);
-       }
-       samdb.close();
-
-       message("Pre-loading the Samba4 and AD schema\n");
-       
-       samdb = open_ldb(info, paths.samdb, false);
-
-       samdb.set_domain_sid(subobj.DOMAINSID);
-
-       if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
-               if (subobj.INVOCATIONID == undefined) {
-                       subobj.INVOCATIONID = randguid();
-               }
-               samdb.set_ntds_invocationId(subobj.INVOCATIONID);
-               if (subobj.BACKEND_MOD == undefined) {
-                       subobj.BACKEND_MOD = "repl_meta_data";
-               }
-       } else {
-               if (subobj.BACKEND_MOD == undefined) {
-                       subobj.BACKEND_MOD = "objectguid";
-               }
-       }
-
-       var load_schema_ok = load_schema(subobj, message, samdb);
-       assert(load_schema_ok.is_ok);
-
-       message("Adding DomainDN: " + subobj.DOMAINDN + " (permitted to fail)\n");
-       var add_ok = setup_add_ldif("provision_basedn.ldif", info, samdb, true);
-       message("Modifying DomainDN: " + subobj.DOMAINDN + "\n");
-       var modify_basedn_ok = setup_ldb_modify("provision_basedn_modify.ldif", info, samdb);
-       if (!modify_basedn_ok) {
-               if (!add_ok) {
-                       message("%s", "Failed to both add and modify " + subobj.DOMAINDN + " in target " + subobj.DOMAINDN_LDB + ": " + samdb.errstring() + "\n");
-                       message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); 
-               };
-               assert(modify_basedn_ok);
-       };
-
-       message("Adding configuration container (permitted to fail)\n");
-       var add_config_ok = setup_add_ldif("provision_configuration_basedn.ldif", info, samdb, true);
-       message("Modifying configuration container\n");
-       var modify_config_ok = setup_ldb_modify("provision_configuration_basedn_modify.ldif", info, samdb);
-       if (!modify_config_ok) {
-               if (!add_config_ok) {
-                       message("%s", "Failed to both add and modify " + subobj.CONFIGDN + " in target " + subobj.CONFIGDN_LDB + ": " + samdb.errstring() + "\n");
-                       message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); 
-               }
-               assert(modify_config_ok);
-       }
-
-       message("Adding schema container (permitted to fail)\n");
-       var add_schema_ok = setup_add_ldif("provision_schema_basedn.ldif", info, samdb, true);
-       message("Modifying schema container\n");
-       var modify_schema_ok = setup_ldb_modify("provision_schema_basedn_modify.ldif", info, samdb);
-       if (!modify_schema_ok) {
-               if (!add_schema_ok) {
-                       message("%s", "Failed to both add and modify " + subobj.SCHEMADN + " in target " + subobj.SCHEMADN_LDB + ": " + samdb.errstring() + "\n");
-                       message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); 
-               }
-               message("Failed to modify the schema container: " + samdb.errstring() + "\n");
-               assert(modify_schema_ok);
-       }
-
-       message("Setting up sam.ldb Samba4 schema\n");
-       setup_add_ldif("schema_samba4.ldif", info, samdb, false);
-       message("Setting up sam.ldb AD schema\n");
-       setup_add_ldif("schema.ldif", info, samdb, false);
-
-       message("Setting up sam.ldb configuration data\n");
-       setup_add_ldif("provision_configuration.ldif", info, samdb, false);
-
-       message("Setting up display specifiers\n");
-       setup_add_ldif("display_specifiers.ldif", info, samdb, false);
-
-       message("Adding users container (permitted to fail)\n");
-       var add_users_ok = setup_add_ldif("provision_users_add.ldif", info, samdb, true);
-       message("Modifying users container\n");
-       var modify_users_ok = setup_ldb_modify("provision_users_modify.ldif", info, samdb);
-       if (!modify_users_ok) {
-               if (!add_users_ok) {
-                       message("Failed to both add and modify the users container\n");
-               }
-               assert(modify_users_ok);
-       }
-       message("Adding computers container (permitted to fail)\n");
-       var add_computers_ok = setup_add_ldif("provision_computers_add.ldif", info, samdb, true);
-       message("Modifying computers container\n");
-       var modify_computers_ok = setup_ldb_modify("provision_computers_modify.ldif", info, samdb);
-       if (!modify_computers_ok) {
-               if (!add_computers_ok) {
-                       message("Failed to both add and modify the computers container\n");
-               }
-               assert(modify_computers_ok);
-       }
-
-       message("Setting up sam.ldb data\n");
-       setup_add_ldif("provision.ldif", info, samdb, false);
-
-       if (blank != false) {
-               message("Setting up sam.ldb index\n");
-               setup_add_ldif("provision_index.ldif", info, samdb, false);
-
-               message("Setting up sam.ldb rootDSE marking as syncronized\n");
-               setup_modify_ldif("provision_rootdse_modify.ldif", info, samdb, false);
-
-               var commit_ok = samdb.transaction_commit();
-               if (!commit_ok) {
-                       info.message("ldb commit failed: " + samdb.errstring() + "\n");
-                       assert(commit_ok);
-               }
-               return true;
-       }
-
-//     message("Activate schema module");
-//     setup_modify_ldif("schema_activation.ldif", info, samdb, false);
-//
-//     // (hack) Reload, now we have the schema loaded.  
-//     var commit_ok = samdb.transaction_commit();
-//     if (!commit_ok) {
-//             info.message("samdb commit failed: " + samdb.errstring() + "\n");
-//             assert(commit_ok);
-//     }
-//     samdb.close();
-//
-//     samdb = open_ldb(info, paths.samdb, false);
-//
-       message("Setting up sam.ldb users and groups\n");
-       setup_add_ldif("provision_users.ldif", info, samdb, false);
-
-       if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
-               message("Setting up self join\n");
-               setup_add_ldif("provision_self_join.ldif", info, samdb, false);
-               setup_add_ldif("provision_group_policy.ldif", info, samdb, false);
-
-               sys.mkdir(paths.sysvol, 0755);
-               sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN, 0755);
-               sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies", 0755);
-               sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}", 0755);
-               sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}/Machine", 0755);
-               sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}/User", 0755);
-
-               sys.mkdir(paths.netlogon, 0755);
-
-               setup_ldb("secrets_dc.ldif", info, paths.secrets, false);
-
-       }
-
-       if (setup_name_mappings(info, samdb) == false) {
-               return false;
-       }
-
-       message("Setting up sam.ldb index\n");
-       setup_add_ldif("provision_index.ldif", info, samdb, false);
-
-       message("Setting up sam.ldb rootDSE marking as syncronized\n");
-       setup_modify_ldif("provision_rootdse_modify.ldif", info, samdb, false);
-
-       var commit_ok = samdb.transaction_commit();
-       if (!commit_ok) {
-               info.message("samdb commit failed: " + samdb.errstring() + "\n");
-               assert(commit_ok);
-       }
-
-       message("Setting up phpLDAPadmin configuration\n");
-       setup_file("phpldapadmin-config.php", info.message, paths.phpldapadminconfig, subobj);
-       message("Please install the phpLDAPadmin configuration located at " + paths.phpldapadminconfig + " into /etc/phpldapadmin/config.php\n");
-
-       return true;
-}
-
-/*
-  provision just the schema into a temporary ldb, so we can run ad2oLschema on it
-*/
-function provision_schema(subobj, message, tmp_schema_path, paths)
-{
-       var lp = loadparm_init();
-       var sys = sys_init();
-       var info = new Object();
-
-       var ok = provision_fix_subobj(subobj, paths);
-       assert(ok);
-
-       info.subobj = subobj;
-       info.message = message;
-
-       message("Setting up sam.ldb partitions\n");
-
-       /* This will erase anything in the tmp db */
-       var samdb = open_ldb(info, tmp_schema_path, true);
-
-       message("Setting up sam.ldb attributes\n");
-       setup_add_ldif("provision_init.ldif", info, samdb, false);
-
-       message("Setting up sam.ldb rootDSE\n");
-       setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
-
-       message("Adding schema container (permitted to fail)\n");
-       var add_ok = setup_add_ldif("provision_schema_basedn.ldif", info, samdb, true);
-       message("Modifying schema container\n");
-       var modify_ok = setup_ldb_modify("provision_schema_basedn_modify.ldif", info, samdb);
-       if (!modify_ok) {
-               if (!add_ok) {
-                       message("Failed to both add and modify schema dn: " + samdb.errstring() + "\n");
-                       message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); 
-                       assert(modify_ok);
-               }
-               message("Failed to modify the schema container: " + samdb.errstring() + "\n");
-               assert(modify_ok);
-       }
-
-       message("Setting up sam.ldb Samba4 schema\n");
-       setup_add_ldif("schema_samba4.ldif", info, samdb, false);
-       message("Setting up sam.ldb AD schema\n");
-       setup_add_ldif("schema.ldif", info, samdb, false);
-
-       var commit_ok = samdb.transaction_commit();
-       if (!commit_ok) {
-               info.message("samdb commit failed: " + samdb.errstring() + "\n");
-               assert(commit_ok);
-       }
-       samdb.close();
-}
-
-/* Write out a DNS zone file, from the info in the current database */
-function provision_dns(subobj, message, paths, session_info, credentials)
-{
-       var lp = loadparm_init();
-       if (strlower(subobj.SERVERROLE) != strlower("domain controller")) {
-               message("No DNS zone required for role %s\n", subobj.SERVERROLE);
-               return;
-       }
-       message("Setting up DNS zone: " + subobj.DNSDOMAIN + " \n");
-       var ldb = ldb_init();
-       ldb.session_info = session_info;
-       ldb.credentials = credentials;
-
-       /* connect to the sam */
-       var ok = ldb.connect(paths.samdb);
-       assert(ok);
-
-       /* These values may have changed, due to an incoming SamSync,
-           or may not have been specified, so fetch them from the database */
-
-       var attrs = new Array("objectGUID");
-       res = ldb.search("objectGUID=*", subobj.DOMAINDN, ldb.SCOPE_BASE, attrs);
-       assert(res.error == 0);
-       assert(res.msgs.length == 1);
-       assert(res.msgs[0].objectGUID != undefined);
-       subobj.DOMAINGUID = res.msgs[0].objectGUID;
-
-       subobj.HOSTGUID = searchone(ldb, subobj.DOMAINDN, "(&(objectClass=computer)(cn=" + subobj.NETBIOSNAME + "))", "objectGUID");
-       assert(subobj.HOSTGUID != undefined);
-
-       setup_file("provision.zone", 
-                  message, paths.dns, 
-                  subobj);
-
-       setup_file("named.conf", 
-                  message, paths.named_conf, 
-                  subobj);
-
-       message("Please install the zone located in " + paths.dns + " into your DNS server.  A sample BIND configuration snippit is at " + paths.named_conf + "\n");
-}
-
-
-/*
-  guess reasonably default options for provisioning
-*/
-function provision_guess()
-{
-       var subobj = new Object();
-       var nss = nss_init();
-       var lp = loadparm_init();
-       var rdn_list;
-       random_init(local);
-
-       subobj.SERVERROLE   = strlower(lp.get("server role"));
-       subobj.REALM        = strupper(lp.get("realm"));
-       subobj.DOMAIN       = lp.get("workgroup");
-       subobj.HOSTNAME     = hostname();
-
-       assert(subobj.REALM);
-       assert(subobj.DOMAIN);
-       assert(subobj.HOSTNAME);
-       
-       subobj.VERSION      = version();
-       subobj.HOSTIP       = hostip();
-       subobj.DOMAINSID    = randsid();
-       subobj.POLICYGUID   = randguid();
-       subobj.KRBTGTPASS   = randpass(12);
-       subobj.MACHINEPASS  = randpass(12);
-       subobj.DNSPASS  = randpass(12);
-       subobj.ADMINPASS    = randpass(12);
-       subobj.LDAPMANAGERPASS     = randpass(12);
-       subobj.DEFAULTSITE  = "Default-First-Site-Name";
-       subobj.DATESTRING   = datestring;
-       subobj.ROOT         = findnss(nss.getpwnam, "root");
-       subobj.NOBODY       = findnss(nss.getpwnam, "nobody");
-       subobj.NOGROUP      = findnss(nss.getgrnam, "nogroup", "nobody");
-       subobj.WHEEL        = findnss(nss.getgrnam, "wheel", "root", "staff", "adm");
-       subobj.BACKUP       = findnss(nss.getgrnam, "backup", "wheel", "root", "staff");
-       subobj.USERS        = findnss(nss.getgrnam, "users", "guest", "other", "unknown", "usr");
-
-       //Add modules to the list to activate them by default
-       //beware often order is important
-       //
-       // Some Known ordering constraints:
-       // - rootdse must be first, as it makes redirects from "" -> cn=rootdse
-       // - objectclass must be before password_hash, because password_hash checks
-       //   that the objectclass is of type person (filled in by the objectclass 
-       //   module when expanding the objectclass list)
-       // - partition must be last
-       // - each partition has its own module list then
-       var modules_list     = new Array("rootdse",
-                                        "paged_results",
-                                        "ranged_results",
-                                        "anr",
-                                        "server_sort",
-                                        "extended_dn",
-                                        "asq",
-                                        "samldb",
-                                        "rdn_name",
-                                        "objectclass",
-                                        "kludge_acl",
-                                        "operational");
-       var tdb_modules_list = new Array("subtree_rename",
-                                        "subtree_delete",
-                                        "linked_attributes");
-       var modules_list2    = new Array("show_deleted",
-                                        "partition");
-       subobj.MODULES_LIST = join(",", modules_list);
-       subobj.TDB_MODULES_LIST = "," + join(",", tdb_modules_list);
-       subobj.MODULES_LIST2 = join(",", modules_list2);
-       subobj.DOMAINDN_LDB = "users.ldb";
-       subobj.CONFIGDN_LDB = "configuration.ldb";
-       subobj.SCHEMADN_LDB = "schema.ldb";
-       subobj.DOMAINDN_MOD = "pdc_fsmo,password_hash,instancetype";
-       subobj.CONFIGDN_MOD = "naming_fsmo,instancetype";
-       subobj.SCHEMADN_MOD = "schema_fsmo,instancetype";
-
-       subobj.ACI              = "# no aci for local ldb";
-
-       return subobj;
-}
-
-/*
-  search for one attribute as a string
- */
-function searchone(ldb, basedn, expression, attribute)
-{
-       var attrs = new Array(attribute);
-       res = ldb.search(expression, basedn, ldb.SCOPE_SUBTREE, attrs);
-       if (res.error != 0 ||
-           res.msgs.length != 1 ||
-           res.msgs[0][attribute] == undefined) {
-               return undefined;
-       }
-       return res.msgs[0][attribute];
-}
-
-/*
-  modify an account to remove the 
-*/
-function enable_account(ldb, user_dn)
-{
-       var attrs = new Array("userAccountControl");
-       var res = ldb.search(NULL, user_dn, ldb.SCOPE_ONELEVEL, attrs);
-       assert(res.error == 0);
-       assert(res.msgs.length == 1);
-       var userAccountControl = res.msgs[0].userAccountControl;
-       userAccountControl = userAccountControl - 2; /* remove disabled bit */
-       var mod = sprintf("
-dn: %s
-changetype: modify
-replace: userAccountControl
-userAccountControl: %u
-", 
-                         user_dn, userAccountControl);
-       var ok = ldb.modify(mod);
-       return (ok.error == 0); 
-}
-
-
-/*
-  add a new user record
-*/
-function newuser(username, unixname, password, message, session_info, credentials)
-{
-       var lp = loadparm_init();
-       var samdb = lp.get("sam database");
-       var ldb = ldb_init();
-       random_init(local);
-       ldb.session_info = session_info;
-       ldb.credentials = credentials;
-
-       /* connect to the sam */
-       var ok = ldb.connect(samdb);
-       assert(ok);
-
-       ldb.transaction_start();
-
-       /* find the DNs for the domain and the domain users group */
-       var attrs = new Array("defaultNamingContext");
-       res = ldb.search("defaultNamingContext=*", "", ldb.SCOPE_BASE, attrs);
-       assert(res.error == 0);
-       assert(res.msgs.length == 1 && res.msgs[0].defaultNamingContext != undefined);
-       var domain_dn = res.msgs[0].defaultNamingContext;
-       assert(domain_dn != undefined);
-       var dom_users = searchone(ldb, domain_dn, "name=Domain Users", "dn");
-       assert(dom_users != undefined);
-
-       var user_dn = sprintf("CN=%s,CN=Users,%s", username, domain_dn);
-
-
-       /*
-         the new user record. note the reliance on the samdb module to fill
-         in a sid, guid etc
-       */
-       var ldif = sprintf("
-dn: %s
-sAMAccountName: %s
-unixName: %s
-sambaPassword: %s
-objectClass: user
-",
-                          user_dn, username,
-                          unixname, password);
-       /*
-         add the user to the users group as well
-       */
-       var modgroup = sprintf("
-dn: %s
-changetype: modify
-add: member
-member: %s
-",
-                              dom_users, user_dn);
-
-
-       /*
-         now the real work
-       */
-       message("Adding user %s\n", user_dn);
-       ok = ldb.add(ldif);
-       if (ok.error != 0) {
-               message("Failed to add %s - %s\n", user_dn, ok.errstr);
-               return false;
-       }
-
-       message("Modifying group %s\n", dom_users);
-       ok = ldb.modify(modgroup);
-       if (ok.error != 0) {
-               message("Failed to modify %s - %s\n", dom_users, ok.errstr);
-               return false;
-       }
-
-       /*
-         modify the userAccountControl to remove the disabled bit
-       */
-       ok = enable_account(ldb, user_dn);
-       if (ok) {
-               ldb.transaction_commit();
-       }
-       return ok;
-}
-
-// Check whether a name is valid as a NetBIOS name. 
-// FIXME: There are probably more constraints here. 
-// crh has a paragraph on this in his book (1.4.1.1)
-function valid_netbios_name(name)
-{
-       if (strlen(name) > 15) return false;
-       return true;
-}
-
-function provision_validate(subobj, message)
-{
-       var lp = loadparm_init();
-
-       if (!valid_netbios_name(subobj.DOMAIN)) {
-               message("Invalid NetBIOS name for domain\n");
-               return false;
-       }
-
-       if (!valid_netbios_name(subobj.NETBIOSNAME)) {
-               message("Invalid NetBIOS name for host\n");
-               return false;
-       }
-
-
-       if (strupper(lp.get("workgroup")) != strupper(subobj.DOMAIN_CONF)) {
-               message("workgroup '%s' in smb.conf must match chosen domain '%s'\n",
-                       lp.get("workgroup"), subobj.DOMAIN_CONF);
-               return false;
-       }
-
-       if (strupper(lp.get("realm")) != strupper(subobj.REALM_CONF)) {
-               message("realm '%s' in smb.conf must match chosen realm '%s'\n",
-                       lp.get("realm"), subobj.REALM_CONF);
-               return false;
-       }
-
-       if (strlower(lp.get("server role")) != strlower(subobj.SERVERROLE)) {
-               message("server role '%s' in smb.conf must match chosen role '%s'\n",
-                       lp.get("server role"), subobj.SERVERROLE);
-               return false;
-       }
-
-       return true;
-}
-
-function join_domain(domain, netbios_name, join_type, creds, message) 
-{
-       var ctx = NetContext(creds);
-       var joindom = new Object();
-       joindom.domain = domain;
-       joindom.join_type = join_type;
-       joindom.netbios_name = netbios_name;
-       if (!ctx.JoinDomain(joindom)) {
-               message("Domain Join failed: " + joindom.error_string);
-               return false;
-       }
-       return true;
-}
-
-/* Vampire a remote domain.  Session info and credentials are required for for
- * access to our local database (might be remote ldap)
- */ 
-
-function vampire(domain, session_info, credentials, message) {
-       var ctx = NetContext(credentials);
-       var vampire_ctx = new Object();
-       var machine_creds = credentials_init();
-       machine_creds.set_domain(form.DOMAIN);
-       if (!machine_creds.set_machine_account()) {
-               message("Failed to access domain join information!");
-               return false;
-       }
-       vampire_ctx.machine_creds = machine_creds;
-       vampire_ctx.session_info = session_info;
-       if (!ctx.SamSyncLdb(vampire_ctx)) {
-               message("Migration of remote domain to Samba failed: " + vampire_ctx.error_string);
-               return false;
-       }
-
-       return true;
-}
-
-return 0;
diff --git a/source/scripting/libjs/samr.js b/source/scripting/libjs/samr.js
deleted file mode 100644 (file)
index 6e8c70a..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-       samr rpc utility functions 
-       Copyright Andrew Tridgell 2005
-       released under the GNU GPL version 3 or later
-*/     
-
-if (global["HAVE_SAMR_JS"] != undefined) {
-   return;
-}
-HAVE_SAMR_JS=1
-
-/*
-  return a list of names and indexes from a samArray
-*/
-function samArray(output)
-{
-       var list = new Array(output.num_entries);
-       if (output.sam == NULL) {
-               return list;
-       }
-       var i, entries = output.sam.entries;
-       for (i=0;i<output.num_entries;i++) {
-               list[i] = new Object();
-                list[i].name = entries[i].name;
-                list[i].idx  = entries[i].idx;
-       }
-       return list;
-}
-
-/*
-       connect to the sam database
-*/
-function samrConnect(conn)
-{
-       security_init(conn);
-       var io = irpcObj();
-       io.input.system_name = NULL;
-       io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
-       var status = conn.samr_Connect2(io);
-       check_status_ok(status);
-       return io.output.connect_handle;
-}
-
-/*
-       close a handle
-*/
-function samrClose(conn, handle)
-{
-       var io = irpcObj();
-       io.input.handle = handle;
-       var status = conn.samr_Close(io);
-       check_status_ok(status);
-}
-
-/*
-   get the sid for a domain
-*/
-function samrLookupDomain(conn, handle, domain)
-{
-       var io = irpcObj();
-       io.input.connect_handle = handle;
-       io.input.domain_name = domain;
-       var status = conn.samr_LookupDomain(io);
-       check_status_ok(status);
-       return io.output.sid;
-}
-
-/*
-  open a domain by sid
-*/
-function samrOpenDomain(conn, handle, sid)
-{
-       var io = irpcObj();
-       io.input.connect_handle = handle;
-       io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
-       io.input.sid = sid;
-       var status = conn.samr_OpenDomain(io);
-       check_status_ok(status);
-       return io.output.domain_handle;
-}
-
-/*
-  open a user by rid
-*/
-function samrOpenUser(conn, handle, rid)
-{
-       var io = irpcObj();
-       io.input.domain_handle = handle;
-       io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
-       io.input.rid = rid;
-       var status = conn.samr_OpenUser(io);
-       check_status_ok(status);
-       return io.output.user_handle;
-}
-
-/*
-  return a list of all users
-*/
-function samrEnumDomainUsers(conn, dom_handle)
-{
-       var io = irpcObj();
-       io.input.domain_handle = dom_handle;
-       io.input.resume_handle = 0;
-       io.input.acct_flags = 0;
-       io.input.max_size = -1;
-       var status = conn.samr_EnumDomainUsers(io);
-       check_status_ok(status);
-       return samArray(io.output);
-}
-
-/*
-  return a list of all groups
-*/
-function samrEnumDomainGroups(conn, dom_handle)
-{
-       var io = irpcObj();
-       io.input.domain_handle = dom_handle;
-       io.input.resume_handle = 0;
-       io.input.acct_flags = 0;
-       io.input.max_size = -1;
-       var status = conn.samr_EnumDomainGroups(io);
-       check_status_ok(status);
-       return samArray(io.output);
-}
-
-/*
-  return a list of domains
-*/
-function samrEnumDomains(conn, handle)
-{
-       var io = irpcObj();
-       io.input.connect_handle = handle;
-       io.input.resume_handle = 0;
-       io.input.buf_size = -1;
-       var status = conn.samr_EnumDomains(io);
-       check_status_ok(status);
-       return samArray(io.output);
-}
-
-/*
-  return information about a user
-*/
-function samrQueryUserInfo(conn, user_handle, level)
-{
-       var r, io = irpcObj();
-       io.input.user_handle = user_handle;
-       io.input.level = level;
-       var status = conn.samr_QueryUserInfo(io);
-       check_status_ok(status);
-       return io.output.info.info3;
-}
-
-
-/*
-  fill a user array with user information from samrQueryUserInfo
-*/
-function samrFillUserInfo(conn, dom_handle, users, level)
-{
-       var i;
-       for (i=0;i<users.length;i++) {
-               var r, user_handle, info;
-               user_handle = samrOpenUser(conn, dom_handle, users[i].idx);
-               info = samrQueryUserInfo(conn, user_handle, level);
-               info.name = users[i].name;
-               info.idx  = users[i].idx;
-               users[i] = info;
-               samrClose(conn, user_handle);
-       }
-}
-
diff --git a/source/scripting/libjs/winreg.js b/source/scripting/libjs/winreg.js
deleted file mode 100644 (file)
index 9db4156..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
-       winreg rpc utility functions 
-       Copyright Andrew Tridgell 2005
-       released under the GNU GPL version 3 or later
-*/     
-
-libinclude("base.js");
-
-/*
-  close a handle
-*/
-function __winreg_close(handle)
-{
-       var io = irpcObj();
-       io.input.handle = handle;
-       this.winreg_CloseKey(io);
-}
-
-
-/*
-  open a hive
-*/
-function __winreg_open_hive(hive)
-{
-       var io = irpcObj();
-       io.input.system_name = NULL;
-       io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
-       var status;
-       if (hive == "HKLM") {
-               status = this.winreg_OpenHKLM(io);
-       } else if (hive == "HKCR") {
-               status = this.winreg_OpenHKCR(io);
-       } else if (hive == "HKPD") {
-               status = this.winreg_OpenHKPD(io);
-       } else if (hive == "HKU") {
-               status = this.winreg_OpenHKU(io);
-       } else {
-               this._last_error = "Unknown hive " + hive;
-               return undefined;
-       }
-       if (!status.is_ok) {
-               return undefined;
-       }
-       return io.output.handle;
-}
-
-/*
-  open a handle to a path
-*/
-function __winreg_open_path(path)
-{
-       var s = string_init();
-       var i, components = s.split('\\', path);
-
-       /* cope with a leading slash */
-       if (components[0] == '') {
-               for (i=0;i<(components.length-1);i++) {
-                       components[i] = components[i+1];
-               }
-               delete(components[i]);
-       }
-       
-       if (components.length == 0) {
-               return undefined;
-       }
-
-       var handle = this.open_hive(components[0]);
-       if (handle == undefined) {
-               return undefined;
-       }
-
-       if (components.length == 1) {
-               return handle;
-       }
-
-       var hpath = components[1];
-
-       for (i=2;i<components.length;i++) {
-               hpath = hpath + "\\" + components[i];
-       }
-
-       io = irpcObj();
-       io.input.parent_handle  = handle;
-       io.input.keyname = hpath;
-       io.input.unknown = 0;
-       io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
-       var status = this.winreg_OpenKey(io);
-
-       this.close(handle);
-
-       if (!status.is_ok) {
-               return undefined;
-       }
-       if (io.output.result != "WERR_OK") {
-               return undefined;
-       }
-       
-       return io.output.handle;
-}
-
-/*
-       return a list of keys for a winreg server given a path
-       usage:
-          list = reg.enum_path(path);
-*/
-function __winreg_enum_path(path)
-{
-       var list = new Array(0);
-
-       if (path == null || path == "\\" || path == "") {
-               return new Array("HKLM", "HKU");
-       }
-       
-       var handle = this.open_path(path);
-       if (handle == undefined) {
-               return undefined;
-       }
-
-       var io = irpcObj();
-       io.input.handle            = handle;
-       io.input.name = new Object();
-       io.input.name.length = 0;
-       io.input.name.size   = 32;
-       io.input.name.name   = NULL;
-       io.input.keyclass = new Object();
-       io.input.keyclass.length = 0;
-       io.input.keyclass.size   = 1024;
-       io.input.keyclass.name   = NULL;
-       io.input.last_changed_time = 0;
-
-       var idx = 0;
-       for (idx=0;idx >= 0;idx++) {
-               io.input.enum_index = idx;
-               var status = this.winreg_EnumKey(io);
-               if (!status.is_ok) {
-                       this.close(handle);
-                       return list;
-               }
-               var out = io.output;
-               if (out.result == "WERR_MORE_DATA") {
-                       io.input.name.size = io.input.name.size * 2;
-                       idx--;
-                       if (io.input.name.size > 32000) {
-                               this.close(handle);
-                               return list;
-                       }
-                       continue;
-               }
-               if (out.result != "WERR_OK") {
-                       this.close(handle);
-                       return list;
-               }
-               list[list.length] = out.name.name;
-       }
-
-       this.close(handle);
-       return list;
-}
-
-
-/*
-       return a list of values for a winreg server given a path
-       usage:
-          list = reg.enum_values(path);
-
-       each returned list element is an object containing a name, a
-       type and a value
-*/
-function __winreg_enum_values(path)
-{
-       var data = datablob_init();
-       var list = new Array(0);
-
-       var handle = this.open_path(path);
-       if (handle == undefined) {
-               return undefined;
-       }
-
-       var io = irpcObj();
-       io.input.handle      = handle;
-       io.input.name        = new Object();
-       io.input.name.length = 0;
-       io.input.name.size   = 128;
-       io.input.name.name   = "";
-       io.input.type        = 0;
-       io.input.value       = new Array(0);
-       io.input.size        = 1024;
-       io.input.length      = 0;
-
-       var idx;
-       for (idx=0;idx >= 0;idx++) {
-               io.input.enum_index = idx;
-               var status = this.winreg_EnumValue(io);
-               if (!status.is_ok) {
-                       this.close(handle);
-                       return list;
-               }
-               var out = io.output;
-               if (out.result == "WERR_MORE_DATA") {
-                       io.input.size = io.input.size * 2;
-                       io.input.name.size = io.input.name.size * 2;
-                       idx--;
-                       /* limit blobs to 1M */
-                       if (io.input.size > 1000000) {
-                               this.close(handle);
-                               return list;
-                       }
-                       continue;
-               }
-               if (out.result != "WERR_OK") {
-                       this.close(handle);
-                       return list;
-               }
-               var el   = new Object();
-               el.name  = out.name.name;
-               el.type  = out.type;
-               el.rawvalue = out.value;
-               el.value = data.regToVar(el.rawvalue, el.type);
-               el.size  = out.size;
-               list[list.length] = el;
-       }
-
-       this.close(handle);
-       return list;
-}
-
-
-/*
-  create a new key
-    ok = reg.create_key(path, key);
-*/
-function __winreg_create_key(path, key)
-{
-       var handle = this.open_path(path);
-       if (handle == undefined) {
-               return undefined;
-       }
-
-       var io = irpcObj();
-       io.input.handle = handle;
-       io.input.name = key;
-       io.input.keyclass = NULL;
-       io.input.options = 0;
-       io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
-       io.input.secdesc = NULL;
-       io.input.action_taken = 0;      
-
-       var status = this.winreg_CreateKey(io);
-       this.close(handle);
-       if (!status.is_ok) {
-               return false;
-       }
-       if (io.output.result != "WERR_OK") {
-               return false;
-       }
-       this.close(io.output.new_handle);
-       return true;
-}
-
-
-/*
-  return a string for a winreg type
-*/
-function __winreg_typestring(type)
-{
-       return this.typenames[type];
-}
-
-/*
-  initialise the winreg lib, returning an object
-*/
-function winregObj()
-{
-       var reg = winreg_init();
-       security_init(reg);
-
-       reg.typenames = new Array("REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY", 
-                                 "REG_DWORD", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ",
-                                 "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR", 
-                                 "REG_RESOURCE_REQUIREMENTS_LIST", "REG_QWORD");
-
-       reg.close       = __winreg_close;
-       reg.open_hive   = __winreg_open_hive;
-       reg.open_path   = __winreg_open_path;
-       reg.enum_path   = __winreg_enum_path;
-       reg.enum_values = __winreg_enum_values;
-       reg.create_key  = __winreg_create_key;
-       reg.typestring  = __winreg_typestring;
-
-       return reg;
-}
index 3790071ba88cc3148b517e78147ae3b1dcba5196..b599aaefb03ccec9dc5ec2c659b0d014b0fd2c6e 100644 (file)
@@ -5,7 +5,7 @@ AC_ARG_VAR([PYTHON_VERSION],[The installed Python
        will be appended to the Python interpreter
        canonical name.])
 
-AC_PROG_SWIG(1.3.31)
+AC_PROG_SWIG(1.3.35)
 
 AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
 if test -z "$PYTHON"; then
@@ -64,10 +64,14 @@ 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
        AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.])
 fi
 
+AC_MSG_CHECKING(python library directory)
+pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1, 0, '\\${prefix}')"`
+AC_MSG_RESULT($pythondir)
+
+AC_SUBST(pythondir)
index 59f628fe184964fbaf1b8b79691ecdfdf37c9550..b494ee6e8d4fc968eedb287a93558601d56bd36f 100644 (file)
@@ -1,29 +1,37 @@
-[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 pytalloc.o)
+LIBPYTHON_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, modules.o)
+
+[SUBSYSTEM::PYTALLOC]
+PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON LIBTALLOC
+
+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]
+LIBRARY_REALNAME = samba/_misc.$(SHLIBEXT)
 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
+
+$(python_misc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
+_PY_FILES = $(shell find $(pyscriptsrcdir)/samba $(pyscriptsrcdir)/subunit -name "*.py")
+
+$(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst $(pyscriptsrcdir)/%,%,$(pyfile)),$(pyfile))))
+
+$(eval $(call python_py_module_template,samba/misc.py,$(pyscriptsrcdir)/misc.py))
+
+EPYDOC_OPTIONS = --no-private --url http://www.samba.org/ --no-sourcecode
 
-PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py
+epydoc:: pythonmods
+       PYTHONPATH=$(pythonbuilddir) epydoc $(EPYDOC_OPTIONS) samba tdb ldb subunit
 
-installpython:: pythonmods
-       @$(SHELL) $(srcdir)/script/installpython.sh \
-               $(INSTALLPERMS) \
-               $(DESTDIR)$(PYTHONDIR) \
-               scripting/python bin/python
+install:: installpython
index 6fa3bc93e34066f42a5972a673e045f18dad622b..9a4c12412169e83b6da50cafeb3a9380e9cc699d 100644 (file)
 %rename(random_password) generate_random_str;
 char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
 
+%feature("docstring") ldb_set_credentials "S.set_credentials(credentials)\n"
+                                          "Set credentials to use when connecting.";
+
+%feature("docstring") ldb_set_session_info "S.set_session_info(session_info)\n"
+                                          "Set session info to use when connecting.";
+
+%feature("docstring") ldb_set_loadparm "S.set_loadparm(session_info)\n"
+                                          "Set loadparm context to use when connecting.";
+
 %inline %{
 void ldb_set_credentials(struct ldb_context *ldb, struct cli_credentials *creds)
 {
@@ -58,14 +67,20 @@ void ldb_set_loadparm(struct ldb_context *ldb, struct loadparm_context *lp_ctx)
 
 %}
 
+%feature("docstring") samdb_set_domain_sid "S.set_domain_sid(sid)\n"
+                                          "Set SID of domain to use.";
 bool samdb_set_domain_sid(struct ldb_context *ldb, 
                           const struct dom_sid *dom_sid_in);
 
 WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf, const char *df);
 
+%feature("docstring") samba_version_string "version()\n"
+                                          "Obtain the Samba version.";
 %rename(version) samba_version_string;
 const char *samba_version_string(void);
 int dsdb_set_global_schema(struct ldb_context *ldb);
+%feature("docstring") ldb_register_samba_handlers "register_samba_handlers()\n"
+                                          "Register Samba-specific LDB modules and schemas.";
 int ldb_register_samba_handlers(struct ldb_context *ldb);
 
 %inline %{
index f1da4c687a1a0529245b3b951ebcce6275542030..25e8d2de8c39a3a5b95cbc07537a1a28375809d0 100644 (file)
@@ -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.
 
@@ -62,14 +62,50 @@ import credentials
 import param
 import security
 random_password = _misc.random_password
-ldb_set_credentials = _misc.ldb_set_credentials
-ldb_set_session_info = _misc.ldb_set_session_info
-ldb_set_loadparm = _misc.ldb_set_loadparm
-samdb_set_domain_sid = _misc.samdb_set_domain_sid
+
+def ldb_set_credentials(*args, **kwargs):
+  """
+    S.set_credentials(credentials)
+    Set credentials to use when connecting.
+    """
+  return _misc.ldb_set_credentials(*args, **kwargs)
+
+def ldb_set_session_info(*args, **kwargs):
+  """
+    S.set_session_info(session_info)
+    Set session info to use when connecting.
+    """
+  return _misc.ldb_set_session_info(*args, **kwargs)
+
+def ldb_set_loadparm(*args, **kwargs):
+  """
+    S.set_loadparm(session_info)
+    Set loadparm context to use when connecting.
+    """
+  return _misc.ldb_set_loadparm(*args, **kwargs)
+
+def samdb_set_domain_sid(*args, **kwargs):
+  """
+    S.set_domain_sid(sid)
+    Set SID of domain to use.
+    """
+  return _misc.samdb_set_domain_sid(*args, **kwargs)
 dsdb_attach_schema_from_ldif_file = _misc.dsdb_attach_schema_from_ldif_file
-version = _misc.version
+
+def version(*args):
+  """
+    version()
+    Obtain the Samba version.
+    """
+  return _misc.version(*args)
 dsdb_set_global_schema = _misc.dsdb_set_global_schema
-ldb_register_samba_handlers = _misc.ldb_register_samba_handlers
+
+def ldb_register_samba_handlers(*args, **kwargs):
+  """
+    register_samba_handlers()
+    Register Samba-specific LDB modules and schemas.
+    """
+  return _misc.ldb_register_samba_handlers(*args, **kwargs)
 dsdb_set_ntds_invocation_id = _misc.dsdb_set_ntds_invocation_id
 private_path = _misc.private_path
 
index 4944515d15e1f202f615fbe3eb45426e405e667b..22a072fc6f9acdfada5f8b4ab0783e20ecbae1fc 100644 (file)
@@ -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
 
 /* 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
 
 /* 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;
     }
@@ -2519,7 +2537,7 @@ static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
 
 #define SWIG_name    "_misc"
 
-#define SWIGVERSION 0x010333 
+#define SWIGVERSION 0x010335 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -3199,14 +3217,32 @@ fail:
 
 static PyMethodDef SwigMethods[] = {
         { (char *)"random_password", (PyCFunction) _wrap_random_password, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ldb_set_session_info", (PyCFunction) _wrap_ldb_set_session_info, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ldb_set_loadparm", (PyCFunction) _wrap_ldb_set_loadparm, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"samdb_set_domain_sid", (PyCFunction) _wrap_samdb_set_domain_sid, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_credentials(credentials)\n"
+               "Set credentials to use when connecting.\n"
+               ""},
+        { (char *)"ldb_set_session_info", (PyCFunction) _wrap_ldb_set_session_info, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_session_info(session_info)\n"
+               "Set session info to use when connecting.\n"
+               ""},
+        { (char *)"ldb_set_loadparm", (PyCFunction) _wrap_ldb_set_loadparm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_loadparm(session_info)\n"
+               "Set loadparm context to use when connecting.\n"
+               ""},
+        { (char *)"samdb_set_domain_sid", (PyCFunction) _wrap_samdb_set_domain_sid, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "S.set_domain_sid(sid)\n"
+               "Set SID of domain to use.\n"
+               ""},
         { (char *)"dsdb_attach_schema_from_ldif_file", (PyCFunction) _wrap_dsdb_attach_schema_from_ldif_file, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"version", (PyCFunction)_wrap_version, METH_NOARGS, NULL},
+        { (char *)"version", (PyCFunction)_wrap_version, METH_NOARGS, (char *)"\n"
+               "version()\n"
+               "Obtain the Samba version.\n"
+               ""},
         { (char *)"dsdb_set_global_schema", (PyCFunction) _wrap_dsdb_set_global_schema, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"ldb_register_samba_handlers", (PyCFunction) _wrap_ldb_register_samba_handlers, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"ldb_register_samba_handlers", (PyCFunction) _wrap_ldb_register_samba_handlers, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+               "register_samba_handlers()\n"
+               "Register Samba-specific LDB modules and schemas.\n"
+               ""},
         { (char *)"dsdb_set_ntds_invocation_id", (PyCFunction) _wrap_dsdb_set_ntds_invocation_id, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"private_path", (PyCFunction) _wrap_private_path, METH_VARARGS | METH_KEYWORDS, NULL},
         { NULL, NULL, 0, NULL }
@@ -3225,7 +3261,7 @@ static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_con
 static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_msg_element *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
@@ -3397,7 +3433,7 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found;
+  int found, init;
   
   clientdata = clientdata;
   
@@ -3407,6 +3443,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 */
@@ -3435,6 +3474,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);
index 6cd975c1a90622b772e95dec142b247c61fc501d..0fe15b2fdab549f72a62087ae21831fc50283b62 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "includes.h"
 #include <Python.h>
-#include "build.h"
 
 extern void init_ldb(void);
 extern void init_security(void);
@@ -40,12 +39,10 @@ extern void initdrsuapi(void);
 extern void initwinreg(void);
 extern void initepmapper(void);
 extern void initinitshutdown(void);
-static void initdcerpc_misc(void) {} 
 extern void initmgmt(void);
 extern void initnet(void);
 extern void initatsvc(void);
 extern void initsamr(void);
-static void initdcerpc_security(void) {}
 extern void initlsa(void);
 extern void initsvcctl(void);
 extern void initwkssvc(void);
index f4d0f37c39410e00dc565d580be196f0e5ba1fb4..93d583c10a4041c3b6990bcc82372f62a57aaad6 100644 (file)
@@ -17,6 +17,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifndef _PYRPC_H_
+#define _PYRPC_H_
+
 #define PY_CHECK_TYPE(type, var, fail) \
        if (!type ## _Check(var)) {\
                PyErr_Format(PyExc_TypeError, "Expected type %s", type ## _Type.tp_name); \
@@ -32,3 +35,5 @@
 #ifndef PyAPI_DATA
 #   define PyAPI_DATA(RTYPE) extern RTYPE
 #endif
+
+#endif /* _PYRPC_H_ */
index aa0ae9bf90742864ad4b480279a038eeaf149c3c..ca476e9604552f0582614a1adfb61f5525292879 100644 (file)
@@ -24,6 +24,7 @@ void py_talloc_dealloc(PyObject* self)
 {
        py_talloc_Object *obj = (py_talloc_Object *)self;
        talloc_free(obj->talloc_ctx);
+       obj->talloc_ctx = NULL;
        PyObject_Del(self);
 }
 
@@ -31,7 +32,13 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
                                                   void *ptr)
 {
        py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type);
-       ret->talloc_ctx = talloc_reference(NULL, mem_ctx); 
+       ret->talloc_ctx = talloc_new(NULL);
+       if (ret->talloc_ctx == NULL) {
+               return NULL;
+       }
+       if (talloc_reference(ret->talloc_ctx, mem_ctx) == NULL) {
+               return NULL;
+       }
        ret->ptr = ptr;
        return (PyObject *)ret;
 }
@@ -41,5 +48,5 @@ PyObject *py_talloc_default_repr(PyObject *py_obj)
        py_talloc_Object *obj = (py_talloc_Object *)py_obj;
        PyTypeObject *type = (PyTypeObject*)PyObject_Type((PyObject *)obj);
 
-       return PyString_FromFormat("<%s>", type->tp_name);
+       return PyString_FromFormat("<%s talloc object at 0x%x>", type->tp_name, (intptr_t)py_obj);
 }
index b9d81c6c3c42cc0b371942b9c0df81485e029fa4..94f9e4d0055b1d32e97b0dca4e966a6885dcab6f 100644 (file)
@@ -20,6 +20,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+__docformat__ = "restructuredText"
+
 import os
 
 def _in_source_tree():
@@ -33,6 +35,8 @@ if _in_source_tree():
     srcdir = "%s/../../.." % os.path.dirname(__file__)
     sys.path.append("%s/bin/python" % srcdir)
     default_ldb_modules_dir = "%s/bin/modules/ldb" % srcdir
+else:
+    default_ldb_modules_dir = None
 
 
 import ldb
@@ -69,15 +73,15 @@ class Ldb(ldb.Ldb):
             self.set_modules_dir(default_ldb_modules_dir)
 
         if credentials is not None:
-            self.set_credentials(self, credentials)
+            self.set_credentials(credentials)
 
         if session_info is not None:
-            self.set_session_info(self, session_info)
+            self.set_session_info(session_info)
 
         assert misc.ldb_register_samba_handlers(self) == 0
 
         if lp is not None:
-            self.set_loadparm(self, lp)
+            self.set_loadparm(lp)
 
         def msg(l,text):
             print text
index 7ec684a9d6cb0c3f5ad7ccc4a4517850410b5de4..9ecb66e21c1830e4349ef8c92b0a9b771919c170 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+"""Support for parsing Samba-related command-line options."""
+
 import optparse
 from credentials import Credentials, AUTO_USE_KERBEROS, DONT_USE_KERBEROS, MUST_USE_KERBEROS
 
+__docformat__ = "restructuredText"
+
 class SambaOptions(optparse.OptionGroup):
+    """General Samba-related command line options."""
     def __init__(self, parser):
         optparse.OptionGroup.__init__(self, parser, "Samba Common Options")
         self.add_option("-s", "--configfile", action="callback",
@@ -29,12 +34,14 @@ class SambaOptions(optparse.OptionGroup):
         self._configfile = None
 
     def get_loadparm_path(self):
+        """Return the path to the smb.conf file specified on the command line.  """
         return self._configfile
 
     def _load_configfile(self, option, opt_str, arg, parser):
         self._configfile = arg
 
     def get_loadparm(self):
+        """Return a loadparm object with data specified on the command line.  """
         import os, param
         lp = param.LoadParm()
         if self._configfile is not None:
@@ -45,12 +52,15 @@ class SambaOptions(optparse.OptionGroup):
             lp.load_default()
         return lp
 
+
 class VersionOptions(optparse.OptionGroup):
+    """Command line option for printing Samba version."""
     def __init__(self, parser):
         optparse.OptionGroup.__init__(self, parser, "Version Options")
 
 
 class CredentialsOptions(optparse.OptionGroup):
+    """Command line options for specifying credentials."""
     def __init__(self, parser):
         self.no_pass = False
         optparse.OptionGroup.__init__(self, parser, "Credentials Options")
@@ -91,6 +101,11 @@ class CredentialsOptions(optparse.OptionGroup):
         self.creds.set_bind_dn(arg)
 
     def get_credentials(self, lp):
+        """Obtain the credentials set on the command-line.
+
+        :param lp: Loadparm object to use.
+        :return: Credentials object
+        """
         self.creds.guess(lp)
         if not self.no_pass:
             self.creds.set_cmdline_callbacks()
index 16efcd04709db45de02446b5ee8ca571611ce4bd..755ec52c7b4a66f9062a2bbc885772a86a42a952 100644 (file)
@@ -20,6 +20,8 @@
 
 """Convenience functions for using the idmap database."""
 
+__docformat__ = "restructuredText"
+
 import samba
 import misc
 import ldb
index 0e8840646cd652e553e188c9eaf734943e8087ee..68b43eff406fac615cc7ead99115ed69af095755 100644 (file)
@@ -43,6 +43,8 @@ from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \
 
 """Functions for setting up a Samba configuration."""
 
+__docformat__ = "restructuredText"
+
 DEFAULTSITE = "Default-First-Site-Name"
 
 class InvalidNetbiosName(Exception):
@@ -236,6 +238,8 @@ def provision_paths_from_lp(lp, dnsdomain):
     paths.secrets = os.path.join(paths.private_dir, lp.get("secrets database") or "secrets.ldb")
     paths.templates = os.path.join(paths.private_dir, "templates.ldb")
     paths.dns = os.path.join(paths.private_dir, dnsdomain + ".zone")
+    paths.namedconf = os.path.join(paths.private_dir, "named.conf")
+    paths.krb5conf = os.path.join(paths.private_dir, "krb5.conf")
     paths.winsdb = os.path.join(paths.private_dir, "wins.ldb")
     paths.s4_ldapi_path = os.path.join(paths.private_dir, "ldapi")
     paths.phpldapadminconfig = os.path.join(paths.private_dir, 
@@ -689,6 +693,7 @@ def setup_self_join(samdb, names,
                     domainsid, invocationid, setup_path,
                     policyguid):
     """Join a host to its own domain."""
+    assert isinstance(invocationid, str)
     setup_add_ldif(samdb, setup_path("provision_self_join.ldif"), { 
               "CONFIGDN": names.configdn, 
               "SCHEMADN": names.schemadn,
@@ -910,7 +915,7 @@ def provision(setup_dir, message, session_info,
         domainsid = security.Sid(domainsid)
 
     if policyguid is None:
-        policyguid = uuid.random()
+        policyguid = str(uuid.uuid4())
     if adminpass is None:
         adminpass = misc.random_password(12)
     if krbtgtpass is None:
@@ -960,7 +965,7 @@ def provision(setup_dir, message, session_info,
 
     assert serverrole in ("domain controller", "member server", "standalone")
     if invocationid is None and serverrole == "domain controller":
-        invocationid = uuid.random()
+        invocationid = str(uuid.uuid4())
 
     if not os.path.exists(paths.private_dir):
         os.mkdir(paths.private_dir)
@@ -1057,14 +1062,23 @@ def provision(setup_dir, message, session_info,
                                        expression="(&(objectClass=computer)(cn=%s))" % names.hostname,
                                        scope=SCOPE_SUBTREE)
             assert isinstance(hostguid, str)
-            
-            create_zone_file(paths.dns, setup_path, samdb, 
-                             hostname=names.hostname, hostip=hostip,
-                             hostip6=hostip6, dnsdomain=names.dnsdomain,
-                             domaindn=names.domaindn, dnspass=dnspass, realm=names.realm, 
+
+            create_zone_file(paths.dns, setup_path, dnsdomain=names.dnsdomain,
+                             domaindn=names.domaindn, hostip=hostip,
+                             hostip6=hostip6, hostname=names.hostname,
+                             dnspass=dnspass, realm=names.realm,
                              domainguid=domainguid, hostguid=hostguid)
             message("Please install the zone located in %s into your DNS server" % paths.dns)
-            
+
+            create_named_conf(paths.namedconf, setup_path, realm=names.realm,
+                              dnsdomain=names.dnsdomain, private_dir=paths.private_dir,
+                              keytab_name=paths.dns_keytab)
+            message("See %s for example configuration statements for secure GSS-TSIG updates" % paths.namedconf)
+
+            create_krb5_conf(paths.krb5conf, setup_path, dnsdomain=names.dnsdomain,
+                             hostname=names.hostname, realm=names.realm)
+            message("A Kerberos configuration suitable for Samba 4 has been generated at %s" % paths.krb5conf)
+
     create_phpldapadmin_config(paths.phpldapadminconfig, setup_path, 
                                ldapi_url)
 
@@ -1280,13 +1294,12 @@ def create_phpldapadmin_config(path, setup_path, ldapi_uri):
             {"S4_LDAPI_URI": ldapi_uri})
 
 
-def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn, 
-                  hostip, hostip6, hostname, dnspass, realm, domainguid, hostguid):
+def create_zone_file(path, setup_path, dnsdomain, domaindn, 
+                     hostip, hostip6, hostname, dnspass, realm, domainguid, hostguid):
     """Write out a DNS zone file, from the info in the current database.
-    
-    :param path: Path of the new file.
-    :param setup_path": Setup path function.
-    :param samdb: SamDB object
+
+    :param path: Path of the new zone file.
+    :param setup_path: Setup path function.
     :param dnsdomain: DNS Domain name
     :param domaindn: DN of the Domain
     :param hostip: Local IPv4 IP
@@ -1320,6 +1333,44 @@ def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
             "HOSTIP6_HOST_LINE": hostip6_host_line,
         })
 
+def create_named_conf(path, setup_path, realm, dnsdomain,
+                      private_dir, keytab_name):
+    """Write out a file containing zone statements suitable for inclusion in a
+    named.conf file (including GSS-TSIG configuration).
+    
+    :param path: Path of the new named.conf file.
+    :param setup_path: Setup path function.
+    :param realm: Realm name
+    :param dnsdomain: DNS Domain name
+    :param private_dir: Path to private directory
+    :param keytab_name: File name of DNS keytab file
+    """
+
+    setup_file(setup_path("named.conf"), path, {
+            "DNSDOMAIN": dnsdomain,
+            "REALM": realm,
+            "REALM_WC": "*." + ".".join(realm.split(".")[1:]),
+            "DNS_KEYTAB": keytab_name,
+            "DNS_KEYTAB_ABS": os.path.join(private_dir, keytab_name),
+        })
+
+def create_krb5_conf(path, setup_path, dnsdomain, hostname, realm):
+    """Write out a file containing zone statements suitable for inclusion in a
+    named.conf file (including GSS-TSIG configuration).
+    
+    :param path: Path of the new named.conf file.
+    :param setup_path: Setup path function.
+    :param dnsdomain: DNS Domain name
+    :param hostname: Local hostname
+    :param realm: Realm name
+    """
+
+    setup_file(setup_path("krb5.conf"), path, {
+            "DNSDOMAIN": dnsdomain,
+            "HOSTNAME": hostname,
+            "REALM": realm,
+        })
+
 def load_schema(setup_path, samdb, schemadn, netbiosname, configdn, sitename):
     """Load schema for the SamDB.
     
index cffedb54af7f8d67136f3740a1494280ec4c2e59..c1340b7760b6852b0928fc5b56e25b17d4ef29a5 100644 (file)
@@ -19,6 +19,8 @@
 
 """Support for reading Samba 3 data files."""
 
+__docformat__ = "restructuredText"
+
 REGISTRY_VALUE_PREFIX = "SAMBA_REGVAL"
 REGISTRY_DB_VERSION = 1
 
@@ -307,6 +309,7 @@ class ShareInfoDatabase(TdbDatabase):
 
 
 class Shares:
+    """Container for share objects."""
     def __init__(self, lp, shareinfo):
         self.lp = lp
         self.shareinfo = shareinfo
@@ -492,6 +495,7 @@ class TdbSam(TdbDatabase):
         assert self.version in (0, 1, 2)
 
     def usernames(self):
+        """Iterate over the usernames in this Tdb database."""
         for k in self.tdb.keys():
             if k.startswith(TDBSAM_USER_PREFIX):
                 yield k[len(TDBSAM_USER_PREFIX):].rstrip("\0")
@@ -633,6 +637,7 @@ class WinsDatabase:
         return iter(self.entries)
 
     def items(self):
+        """Return the entries in this WINS database."""
         return self.entries.items()
 
     def close(self): # for consistency
index 198d1e9f5cb8c12a0858344754241e6088b45593..6465f495191f5c8f8c72bf43a801fbfc151ebc11 100644 (file)
@@ -28,6 +28,8 @@ import ldb
 from samba.idmap import IDmapDB
 import pwd
 
+__docformat__ = "restructuredText"
+
 class SamDB(samba.Ldb):
     """The SAM database."""
 
index 1afdc582a7efccbf031e1924c0a057de73069723..81133ff6413491ec8f5b7a1763bbde0f8e79ead7 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import winreg
+from samba.dcerpc import winreg
 import unittest
 from samba.tests import RpcInterfaceTestCase
 
index 6c43632d970e39f77f1e4dee721a2440d69971b5..3b37f8a9bc19773dba535fd933f2e2f98c0e2c60 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import echo
+from samba.dcerpc import echo
 import unittest
 from samba.tests import RpcInterfaceTestCase
 
index 8ef12dad86700720eaf562ca4c439c47bb0ef62c..50e00a3f9ecc65859239ac93268fb6ef123d3e20 100644 (file)
@@ -1,7 +1,8 @@
 #!/usr/bin/python
+# -*- coding: utf-8 -*-
 
 # Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+# Copyright Â© Jelmer Vernooij <jelmer@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
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import samr
+from samba.dcerpc import samr, security
 from samba.tests import RpcInterfaceTestCase
 
+# FIXME: Pidl should be doing this for us
+def toArray((handle, array, num_entries)):
+    ret = []
+    for x in range(num_entries):
+        ret.append((array.entries[x].idx, array.entries[x].name))
+    return ret
+
+
 class SamrTests(RpcInterfaceTestCase):
     def setUp(self):
         self.conn = samr.samr("ncalrpc:", self.get_loadparm())
 
     def test_connect5(self):
         (level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
+
+    def test_connect2(self):
+        handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+    def test_EnumDomains(self):
+        handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+        domains = toArray(self.conn.EnumDomains(handle, 0, -1))
+        self.conn.Close(handle)
+
index 43978ac9dcaef72cda9a45262e4d01be7c337971..aa47b71b1691adfe6d2c17dbdda81959119ba968 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import unixinfo
+from samba.dcerpc import unixinfo
 from samba.tests import RpcInterfaceTestCase
 
 class UnixinfoTests(RpcInterfaceTestCase):
@@ -27,8 +27,8 @@ class UnixinfoTests(RpcInterfaceTestCase):
     def test_getpwuid(self):
         infos = self.conn.GetPWUid(range(512))
         self.assertEquals(512, len(infos))
-        self.assertEquals("", infos[0].shell)
-        self.assertEquals("", infos[0].homedir)
+        self.assertEquals("/bin/false", infos[0].shell)
+        self.assertTrue(isinstance(infos[0].homedir, unicode))
 
     def test_gidtosid(self):
         self.conn.GidToSid(1000)
index b9e0e16d3cac11142821d71ffec3e1492a9b7dba..76c10145f0a39b277c1f92940e2ee691927b3f5b 100644 (file)
@@ -21,7 +21,7 @@ import os
 from samba.provision import setup_secretsdb, secretsdb_become_dc, findnss
 import samba.tests
 from ldb import Dn
-import param
+from samba import param
 import unittest
 
 lp = samba.tests.cmdline_loadparm
index 0e175bf936addc5b77cb4fbcf9882a9e01b1d788..0d4f7bde0e9e9919045d20f2a512bc4c861205a9 100644 (file)
@@ -29,18 +29,18 @@ import uuid
 class SamDBTestCase(TestCaseInTempDir):
     def setUp(self):
         super(SamDBTestCase, self).setUp()
-        invocationid = uuid.random()
+        invocationid = str(uuid.uuid4())
         domaindn = "DC=COM,DC=EXAMPLE"
         self.domaindn = domaindn
         configdn = "CN=Configuration," + domaindn
         schemadn = "CN=Schema," + configdn
-        domainguid = uuid.random()
-        policyguid = uuid.random()
+        domainguid = str(uuid.uuid4())
+        policyguid = str(uuid.uuid4())
         setup_path = lambda x: os.path.join("setup", x)
         creds = Credentials()
         creds.set_anonymous()
         domainsid = security.random_sid()
-        hostguid = uuid.random()
+        hostguid = str(uuid.uuid4())
         path = os.path.join(self.tempdir, "samdb.ldb")
         self.samdb = setup_samdb(path, setup_path, system_session(), creds, 
                                  cmdline_loadparm, schemadn, configdn, 
index f40f2cffe7f5ac58a655290d0cb3e6729c3fd1f5..0c83604e827503dc5abbdd82f9ab64b53bd0fed2 100644 (file)
@@ -7,6 +7,8 @@
 
 """Support code for upgrading from Samba 3 to Samba 4."""
 
+__docformat__ = "restructuredText"
+
 from provision import findnss, provision, FILL_DRS
 import grp
 import ldb
diff --git a/source/scripting/python/smbpython.c b/source/scripting/python/smbpython.c
deleted file mode 100644 (file)
index c5de53f..0000000
+++ /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);
-}
index 18cfb6ce3295908619b3c940bbde8f9f89543aef..98ef9adaa9c6a981e3e8703dcafa7e7ee7e3e9d5 100644 (file)
@@ -46,7 +46,7 @@ static PyObject *uuid_random(PyObject *self, PyObject *args)
 }
 
 static PyMethodDef methods[] = {
-       { "random", (PyCFunction)uuid_random, METH_VARARGS, NULL},
+       { "uuid4", (PyCFunction)uuid_random, METH_VARARGS, NULL},
        { NULL, NULL }
 };
 
index e8e87c8b3f4b01a823f3d61a88f3aacf3352132e..f8be20a569c787a97ea7d049649093aea345d89e 100644 (file)
@@ -3,15 +3,70 @@
 This directory contains test scripts that are useful for running a
 bunch of tests all at once. 
 
-===============
-Available tests
-===============
-The available tests are obtained from a script, usually 
-selftest/samba{3,4}_tests.sh. This script should for each test output 
+Available testsuites
+====================
+The available testsuites are obtained from a script, usually 
+selftest/samba{3,4}_tests.sh. This script should for each testsuite output 
 the name of the test, the command to run and the environment that should be 
-provided.
+provided. Use the included "plantest" function to generate the required output.
+
+Testsuite behaviour
+================================
+
+Exit code
+------------
+The testsuites should exit with a non-zero exit code if at least one 
+test failed. Skipped tests should not influence the exit code.
+
+Output format
+-------------
+Testsuites can simply use the exit code to indicate whether all of their 
+tests have succeeded or one or more have failed. It is also possible to 
+provide more granular information using the Subunit protocol. 
+
+This protocol works by writing simple messages to standard output. Any 
+messages that can not be interpreted by this protocol are considered comments 
+for the last announced test.
+
+Accepted commands are:
+
+test
+~~~~~~~~~~~~
+test: <NAME>
+
+Announce that a new test with the specified name is starting
+
+success
+~~~~~~~~~~~~~~~
+success: <NAME> 
+
+Announce that the test with the specified name is done and ran successfully.
+
+failure
+~~~~~~~~~~~~~~~
+failure: <NAME> 
+failure: <NAME> [ REASON ]
+
+Announce that the test with the specified name failed. Optionally, it is 
+possible to specify a reason it failed.
+
+skip
+~~~~~~~~~~~~
+skip: <NAME>
+skip: <NAME> [ REASON ]
+
+Announce that the test with the specified name was skipped. Optionally a 
+reason can be specified.
+
+knownfail
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+knownfail: <NAME>
+knownfail: <NAME> [ REASON ]
+
+Announce that the test with the specified name was run and failed as expected.
+Alternatively it is also possible to simply return "failure:" here but 
+specify in the samba4-knownfailures file that it is failing.
 
-============
 Environments
 ============
 Tests often need to run against a server with particular things set up, 
@@ -23,6 +78,7 @@ The following environments are currently available:
  - none: No server set up, no variables set.
  - dc: Domain controller set up. The following environment variables will 
    be set:
+
      * USERNAME: Administrator user name
         * PASSWORD: Administrator password
         * DOMAIN: Domain name
@@ -34,6 +90,7 @@ The following environments are currently available:
 
  - member: Domain controller and member server that is joined to it set up. The
    following environment variables will be set:
+
      * USERNAME: Domain administrator user name
         * PASSWORD: Domain administrator password
         * DOMAIN: Domain name
@@ -41,22 +98,22 @@ The following environments are currently available:
         * SERVER: Name of the member server
 
 
-=============
 Running tests
 =============
 
-To run all the tests use:
+To run all the tests use::
 
    make test
 
-To run a quick subset (aiming for about 1 minute of testing) run:
+To run a quick subset (aiming for about 1 minute of testing) run::
 
    make quicktest
 
-To run a specific test, use this syntax
+To run a specific test, use this syntax::
 
    make test TESTS=testname
 
-for example
+for example::
 
    make test TESTS=samba4.BASE-DELETE
+
index e5c61ca9ba748ce92e0bc2ebc753da45d295e581..05e51da541206ad2c475de4be255fb9c8cc2dc65 100644 (file)
@@ -20,15 +20,22 @@ sub parse_results($$$$$)
                        $msg_ops->control_msg($_);
                        $msg_ops->start_test($open_tests, $1);
                        push (@$open_tests, $1);
-               } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) {
+               } elsif (/^(success|successful|failure|skip|knownfail|error): (.*?)( \[)?([ \t]*)\n/) {
                        $msg_ops->control_msg($_);
                        my $reason = undef;
                        if ($3) {
                                $reason = "";
                                # reason may be specified in next lines
+                               my $terminated = 0;
                                while(<$fh>) {
                                        $msg_ops->control_msg($_);
-                                       if ($_ eq "]\n") { last; } else { $reason .= $_; }
+                                       if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
+                               }
+                               
+                               unless ($terminated) {
+                                       $statistics->{TESTS_ERROR}++;
+                                       $msg_ops->end_test($open_tests, $2, $1, 1, "reason interrupted");
+                                       return 1;
                                }
                        }
                        my $result = $1;
@@ -53,6 +60,10 @@ sub parse_results($$$$$)
                                        $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
                                        $unexpected_fail++;
                                }
+                       } elsif ($1 eq "knownfail") {
+                               pop(@$open_tests); #FIXME: Check that popped value == $2
+                               $statistics->{TESTS_EXPECTED_FAIL}++;
+                               $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
                        } elsif ($1 eq "skip") {
                                $statistics->{TESTS_SKIP}++;
                                pop(@$open_tests); #FIXME: Check that popped value == $2
index 25ff74792e518f01e0a010ab8b8d8fbbdb52419c..f14e26b38d435cfddd5063230be1088d016d593e 100644 (file)
@@ -81,6 +81,9 @@ sub end_testsuite($$$$$)
        my $out = "";
 
        if ($unexpected) {
+               if ($result eq "success" and not defined($reason)) {
+                       $reason = "Expected negative exit code, got positive exit code";
+               } 
                $self->output_msg("ERROR: $reason\n");
                push (@{$self->{suitesfailed}}, $name);
        } else {
index 3a3e1f91b175d754bff7fa3f7caf3c513c1e7984..36cf2adccbbdd0ca92717b38605d66888723b959 100755 (executable)
@@ -64,8 +64,7 @@ SCRIPTDIR=$samba4srcdir/../testprogs/ejs
 smb4torture="$samba4bindir/smbtorture $TORTURE_OPTIONS"
 
 plantest "js.base" dc "$SCRIPTDIR/base.js" $CONFIGURATION
-plantest "js.samr" dc "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
-plantest "js.echo" dc "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
+plantest "samr.python" dc "$samba4bindir/../scripting/bin/samr.py" ncalrpc: 
 #plantest "ejsnet.js" dc "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U\$USERNAME%\$PASSWORD \$DOMAIN ejstestuser
 plantest "js.ldb" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION -d 10
 plantest "js.winreg" dc $samba4srcdir/scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U\$USERNAME%\$PASSWORD
@@ -219,13 +218,16 @@ plantest "rpc.echo on ncacn_np over smb2" dc $smb4torture ncacn_np:"\$SERVER[smb
 # Tests against the NTVFS POSIX backend
 NTVFSARGS="--option=torture:sharedelay=100000 --option=torture:oplocktimeout=3"
 smb2=`$smb4torture --list | grep "^SMB2-" | xargs`
-raw=`$smb4torture --list | grep "^RAW-" | xargs`
+#The QFILEINFO-IPC test needs to be on ipc$
+raw=`$smb4torture --list | grep "^RAW-" | grep -v "RAW-QFILEINFO-IPC"| xargs`
 base=`$smb4torture --list | grep "^BASE-" | xargs`
 
 for t in $base $raw $smb2; do
     plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS
 done
 
+plansmbtorturetest "RAW-QFILEINFO-IPC" dc $ADDARGS //\$SERVER/ipc$ -U"\$USERNAME"%"\$PASSWORD"
+
 rap=`$smb4torture --list | grep "^RAP-" | xargs`
 for t in $rap; do
     plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/IPC\\\$ -U"\$USERNAME"%"\$PASSWORD"
@@ -274,6 +276,8 @@ plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh
 plantest "blackbox.locktest" dc $bbdir/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
 plantest "blackbox.masktest" dc $bbdir/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
 plantest "blackbox.gentest" dc $bbdir/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.wbinfo" dc $bbdir/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc"
+plantest "blackbox.wbinfo" member $bbdir/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member"
 
 # Tests using the "Simple" NTVFS backend
 
@@ -283,7 +287,7 @@ done
 
 DATADIR=$samba4srcdir/../testdata
 
-plantest "js.samba3sam" none $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
+plantest "js.samba3sam" none $samba4bindir/smbscript $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
 
 # Domain Member Tests
 
@@ -292,7 +296,6 @@ plantest "rpc.echo against member server with domain creds" member $VALGRIND $sm
 plantest "rpc.samr against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR" "$*"
 plantest "rpc.samr.users against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-USERS" "$*"
 plantest "rpc.samr.passwords against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-PASSWORDS" "$*"
-plantest "wbinfo -a against member server with domain creds" member $VALGRIND $samba4bindir/wbinfo -a "\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD"
 
 NBT_TESTS=`$smb4torture --list | grep "^NBT-" | xargs`
 
@@ -300,7 +303,7 @@ for t in $NBT_TESTS; do
        plansmbtorturetest "$t" dc //\$SERVER/_none_ -U\$USERNAME%\$PASSWORD 
 done
 
-WB_OPTS="--option=\"torture:strict mode=yes\""
+WB_OPTS="--option=\"torture:strict mode=no\""
 WB_OPTS="${WB_OPTS} --option=\"torture:timelimit=1\""
 WB_OPTS="${WB_OPTS} --option=\"torture:winbindd separator=/\""
 WB_OPTS="${WB_OPTS} --option=\"torture:winbindd private pipe dir=\$WINBINDD_PRIV_PIPE_DIR\""
@@ -324,7 +327,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
@@ -347,7 +350,9 @@ plantest "winreg.python" dc $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcer
 plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN
 plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3
 rm -rf $PREFIX/upgrade
-plantest "blackbox.upgrade" none $PYTHON setup/upgrade.py $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf
+plantest "blackbox.upgrade" none $PYTHON setup/upgrade $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf
 rm -rf $PREFIX/provision
 mkdir $PREFIX/provision
 plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX/provision" "$CONFIGURATION" 
+plantest "blackbox.setpassword.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_setpassword.sh "$PREFIX/provision" "$CONFIGURATION" 
+plantest "blackbox.newuser.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_newuser.sh "$PREFIX/provision" "$CONFIGURATION" 
index 39a1b5a45089be203d4da12aa4dd4730f3a0b6b6..5854a94b8d1369ef9ac312f8b9464b8fee2016c9 100755 (executable)
@@ -238,7 +238,13 @@ sub run_testsuite($$$$$$)
 
        $msg_ops->start_test([], $name);
 
-       open(RESULT, "$cmd 2>&1|");
+       unless (open(RESULT, "$cmd 2>&1|")) {
+               $statistics->{TESTS_ERROR}++;
+               $msg_ops->end_test([], $name, "error", 1, "Unable to run $cmd: $!");
+               $statistics->{SUITES_FAIL}++;
+               return 0;
+       }
+
        my $expected_ret = parse_results(
                $msg_ops, $statistics, *RESULT, \&expecting_failure, [$name]);
 
@@ -250,17 +256,17 @@ sub run_testsuite($$$$$$)
        my $ret = close(RESULT);
        $ret = 0 unless $ret == 1;
 
+       my $exitcode = $? >> 8;
+
        if ($ret == 1) {
-               $msg_ops->end_test([], $name, "success", $expected_ret != $ret, undef);
+               $msg_ops->end_test([], $name, "success", $expected_ret != $ret, undef); 
        } else {
-               $msg_ops->end_test([], $name, "failure", $expected_ret != $ret, 
-                                              "Returned $ret");
+               $msg_ops->end_test([], $name, "failure", $expected_ret != $ret, "Exit code was $exitcode");
        }
 
        cleanup_pcap($pcap_file, $expected_ret, $ret);
 
-       if (not $opt_socket_wrapper_keep_pcap and 
-               defined($pcap_file)) {
+       if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
                $msg_ops->output_msg("PCAP FILE: $pcap_file\n");
        }
 
@@ -401,13 +407,19 @@ my $tls_enabled = not $opt_quick;
 $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
 $ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb";
 $ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules";
-if (defined($ENV{PKG_CONFIG_PATH})) {
-       $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}";
-} else { 
-       $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig";
+sub prefix_pathvar($$)
+{
+       my ($name, $newpath) = @_;
+       if (defined($ENV{$name})) {
+               $ENV{$name} = "$newpath:$ENV{$name}";
+       } else {
+               $ENV{$name} = $newpath;
+       }
 }
+prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig");
 # Required for smbscript:
-$ENV{PATH} = "$old_pwd/bin:$old_pwd:$ENV{PATH}";
+prefix_pathvar("PATH", "$old_pwd/bin");
+prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python");
 
 if ($opt_socket_wrapper_keep_pcap) {
        # Socket wrapper keep pcap implies socket wrapper pcap
index 069aff73cfb013f00b743cf7167a3ec967449015..a12939b0a173e74f1fc19e90090b9b5b3e24f15a 100644 (file)
@@ -695,11 +695,17 @@ nogroup:x:65534:nobody
        my @provision_options = ();
        push (@provision_options, "NSS_WRAPPER_PASSWD=\"$nsswrap_passwd\"");
        push (@provision_options, "NSS_WRAPPER_GROUP=\"$nsswrap_group\"");
+       if (defined($ENV{GDB_PROVISION})) {
+               push (@provision_options, "gdb --args");
+       }
+       if (defined($ENV{VALGRIND_PROVISION})) {
+               push (@provision_options, "valgrind");
+       }
        if (defined($ENV{PROVISION_EJS})) {
                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));
old mode 100644 (file)
new mode 100755 (executable)
index 849b515..061997b
@@ -5,17 +5,19 @@
 #      Copyright Jelmer Vernooij 2008
 #      Released under the GNU GPL version 3 or later
 #
+import os, sys
+
+sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), "../bin/python"))
 
 import samba.getopt as options
 import optparse
 import pwd
-import sys
 import ldb
 
-from auth import system_session
+from samba.auth import system_session
 from samba.samdb import SamDB
 
-parser = optparse.OptionParser("setpassword [username] [options]")
+parser = optparse.OptionParser("enableaccount [username] [options]")
 sambaopts = options.SambaOptions(parser)
 parser.add_option_group(sambaopts)
 parser.add_option_group(options.VersionOptions(parser))
index a397cfd0d221a9ccf660a40aabf9529a5719d8e6..43e5b655625932ed7f04dd7a9bd4edebf746c5ea 100644 (file)
@@ -1,5 +1,4 @@
 dn: CN=CONFIG
 cn: CONFIG
-lowerBound: 10000
-upperBound: 20000
-
+lowerBound: 3000000
+upperBound: 4000000
diff --git a/source/setup/krb5.conf b/source/setup/krb5.conf
new file mode 100644 (file)
index 0000000..7dad63d
--- /dev/null
@@ -0,0 +1,17 @@
+[libdefaults]
+       default_realm = ${REALM}
+       dns_lookup_realm = false
+       dns_lookup_kdc = false
+       ticket_lifetime = 24h
+       forwardable = yes
+
+[realms]
+       ${REALM} = {
+               kdc = ${HOSTNAME}.${DNSDOMAIN}:88
+               admin_server = ${HOSTNAME}.${DNSDOMAIN}:749
+               default_domain = ${DNSDOMAIN}
+       }
+
+[domain_realm]
+       .${DNSDOMAIN} = ${REALM}
+       ${DNSDOMAIN} = ${REALM}
index 025788093ef6cf5b6d342a121310ab522a1fb3b3..4f98bbd91488995793c3b48ede1bf9281f28f1e6 100644 (file)
 # the BIND nameserver.
 #
 
-# If you have a very recent BIND, supporting GSS-TSIG, 
-# insert this into options {}  (otherwise omit, it is not required if we don't accept updates)
-tkey-gssapi-credential "DNS/${DNSDOMAIN}";
-tkey-domain "${REALM}";
-
-# You should always include the actual zone configuration reference:
+# You should always include the actual forward zone configuration:
 zone "${DNSDOMAIN}." IN {
-        type master;
-        file "${DNSDOMAIN}.zone";
+       type master;
+       file "${DNSDOMAIN}.zone";
        update-policy {
-               /* use ANY only for Domain controllers for now */
-               /* for normal machines A AAAA PTR is probbaly all is needed */
-               grant ${HOSTNAME}.${DNSDOMAIN}@${REALM} name ${HOSTNAME}.${DNSDOMAIN} ANY;
+               /*
+                * A rather long description here, as the "ms-self" option does
+                * not appear in any docs yet (it can only be found in the
+                * source code).
+                *
+                * The short of it is that each host is allowed to update its
+                * own A and AAAA records, when the update request is properly
+                * signed by the host itself.
+                *
+                * The long description is (look at the
+                * dst_gssapi_identitymatchesrealmms() call in lib/dns/ssu.c and
+                * its definition in lib/dns/gssapictx.c for details):
+                *
+                * A GSS-TSIG update request will be signed by a given signer
+                * (e.g. machine-name$@${REALM}).  The signer name is split into
+                * the machine component (e.g. "machine-name") and the realm
+                * component (e.g. "${REALM}").  The update is allowed if the
+                * following conditions are met:
+                *
+                * 1) The machine component of the signer name matches the first
+                * (host) component of the FQDN that is being updated.
+                *
+                * 2) The realm component of the signer name matches the realm
+                * in the grant statement below (${REALM}).
+                *
+                * 3) The domain component of the FQDN that is being updated
+                * matches the realm in the grant statement below.
+                *
+                * If the 3 conditions above are satisfied, the update succeeds.
+                */
+               grant ${REALM} ms-self * A AAAA;
        };
 };
 
-# Also, you need to change your init scripts to set this environment variable
-# for named: KRB5_KTNAME so that it points to the keytab generated.
-# In RedHat derived systems such RHEL/CentOS/Fedora you can add the following
-# line to the /etc/sysconfig/named file:
-# export KRB5_KTNAME=${DNS_KEYTAB_ABS}
-#
-# Please note that most distributions have BIND configured to run under
-# a non-root user account.  For example, Fedora Core 6 (FC6) runs BIND as
-# the user "named" once the daemon relinquishes its rights.  Therefore,
-# the file "${DNS_KEYTAB}" must be readable by the user that BIND run as.
-# If BIND is running as a non-root user, the "${DNS_KEYTAB}" file must have its
-# permissions altered to allow the daemon to read it.  In the FC6
-# example, execute the commands:
-# 
-# chgrp named ${DNS_KEYTAB_ABS}
-# chmod g+r ${DNS_KEYTAB_ABS}
+# The reverse zone configuration is optional.  The following example assumes a
+# subnet of 192.168.123.0/24:
+zone "123.168.192.in-addr.arpa" in {
+       type master;
+       file "123.168.192.in-addr.arpa.zone";
+       update-policy {
+               grant ${REALM_WC} wildcard *.123.168.192.in-addr.arpa. PTR;
+       };
+};
+# Note that the reverse zone file is not created during the provision process.
+
+# The most recent BIND version (9.5.0a5 or later) supports secure GSS-TSIG
+# updates.  If you are running an earlier version of BIND, or if you do not wish
+# to use secure GSS-TSIG updates, you may remove the update-policy sections in
+# both examples above.
+
+# If you are running a capable version of BIND and you wish to support secure
+# GSS-TSIG updates, you must make the following configuration changes:
+
+# - Insert the following lines into the options {} section of your named.conf
+# file:
+tkey-gssapi-credential "DNS/${DNSDOMAIN}";
+tkey-domain "${REALM}";
+
+# - Modify BIND init scripts to pass the location of the generated keytab file.
+# Fedora 8 & later provide a variable named KEYTAB_FILE in /etc/sysconfig/named
+# for this purpose:
+KEYTAB_FILE="${DNS_KEYTAB_ABS}"
+# Note that the Fedora scripts translate KEYTAB_FILE behind the scenes into a
+# variable named KRB5_KTNAME, which is ultimately passed to the BIND daemon.  If
+# your distribution does not provide a variable like KEYTAB_FILE to pass a
+# keytab file to the BIND daemon, a workaround is to place the following line in
+# BIND's sysconfig file or in the init script for BIND:
+export KRB5_KTNAME="${DNS_KEYTAB_ABS}"
+
+# - Set appropriate ownership and permissions on the ${DNS_KEYTAB} file.  Note
+# that most distributions have BIND configured to run under a non-root user
+# account.  For example, Fedora 9 runs BIND as the user "named" once the daemon
+# relinquishes its rights.  Therefore, the file ${DNS_KEYTAB} must be readable
+# by the user that BIND run as.  If BIND is running as a non-root user, the
+# "${DNS_KEYTAB}" file must have its permissions altered to allow the daemon to
+# read it.  Under Fedora 9, execute the following commands:
+chgrp named ${DNS_KEYTAB_ABS}
+chmod g+r ${DNS_KEYTAB_ABS}
+
+# - Ensure the BIND zone file(s) that will be dynamically updated are in a
+# directory where the BIND daemon can write.  When BIND performs dynamic
+# updates, it not only needs to update the zone file itself but it must also
+# create a journal (.jnl) file to track the dynamic updates as they occur.
+# Under Fedora 9, the /var/named directory can not be written to by the "named"
+# user.  However, the directory /var/named/dynamic directory does provide write
+# access.  Therefore the zone files were placed under the /var/named/dynamic
+# directory.  The file directives in both example zone statements at the
+# beginning of this file were changed by prepending the directory "dynamic/".
+
+# - If SELinux is enabled, ensure that all files have the appropriate SELinux
+# file contexts.  The ${DNS_KEYTAB} file must be accessible by the BIND daemon
+# and should have a SELinux type of named_conf_t.  This can be set with the
+# following command:
+chcon -t named_conf_t ${DNS_KEYTAB_ABS}
index 04a5440ee1a205650f7cb3d6f1fd0f0391a25c30..991afa36d8e712470176a7e5ea7f733aa7cabec9 100755 (executable)
@@ -6,12 +6,16 @@
 #      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.auth import system_session
 from samba.samdb import SamDB
 
 parser = optparse.OptionParser("newuser [options] <username> [<password>]")
index 259bd814a4be20e07cdd2c48ac4fdb36b947ccbb..c1d6cd157aa857601dec1ba1363c00652f4e57ae 100755 (executable)
@@ -26,15 +26,20 @@ 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
 
-from auth import system_session
+from samba.auth import system_session
 import samba.getopt as options
+from samba import param
 from samba.provision import (provision, 
                              FILL_FULL, FILL_NT4SYNC,
                              FILL_DRS)
 
+# how do we make this case insensitive??
+
 parser = optparse.OptionParser("provision [options]")
 sambaopts = options.SambaOptions(parser)
 parser.add_option_group(sambaopts)
index 4f222c467a197ec0d1b1cfc05d5b01bfd4dde392..54dc5839bfaf27d0f79078cce06e7df7102f2a08 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+import os, sys
+
+sys.path.insert(0, "bin/python")
+
 import getopt
 import optparse
-import os, sys
 
 import samba
-import param
+from samba import param
 
-from auth import system_session
+from samba.auth import system_session
 import samba.getopt as options
 from samba.provision import (provision_backend)
 
diff --git a/source/setup/provision-backend.js b/source/setup/provision-backend.js
deleted file mode 100644 (file)
index 9482d8c..0000000
+++ /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;
index f5e1bb5add6aef7bbcb413aac797750444763787..63332e937b2a72b3930c53506014951047c686fa 100644 (file)
@@ -75,6 +75,6 @@ subRefs: ${CONFIGDN}
 subRefs: ${SCHEMADN}
 -
 replace: gPLink
-gPLink: [LDAP://CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN};2]
+gPLink: [LDAP://CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN};0]
 -
 ${DOMAINGUID_MOD}
index 71c7fc2f5b97afffbf4557ecda1872eb642ab013..abc5860cf7cae767889c2cb16d60130065dafaa4 100644 (file)
@@ -33,6 +33,7 @@ objectClass: secret
 objectClass: kerberosSecret
 realm: ${REALM}
 servicePrincipalName: DNS/${DNSDOMAIN}
+msDS-KeyVersionNumber: 1
 privateKeytab: ${DNS_KEYTAB}
 secret:: ${DNSPASS_B64}
 
index 977a6a5ee89011c0f540378d3193812ddcbe0188..65770e1f4d8b913d6b6253da3f9660e858a8f549 100644 (file)
@@ -6,12 +6,17 @@
 #      Released under the GNU GPL version 3 or later
 #
 
+import os, 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.auth import system_session
 from samba.samdb import SamDB
 
 parser = optparse.OptionParser("setpassword [username] [options]")
diff --git a/source/setup/tests/blackbox_newuser.sh b/source/setup/tests/blackbox_newuser.sh
new file mode 100755 (executable)
index 0000000..fed5f7d
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: blackbox_newuser.sh PREFIX CONFIGURATION
+EOF
+exit 1;
+fi
+
+PREFIX="$1"
+CONFIGURATION="$2"
+shift 2
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+
+testit "simple-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
+
+testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass
+
+exit $failed
index 19f37cef2df062a026914b199604bc08dd36de45..2afa9dc9525b3208211d5a8a2cf5ef278fc8b70d 100755 (executable)
@@ -11,21 +11,7 @@ PREFIX="$1"
 CONFIGURATION="$2"
 shift 2
 
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-               failed=`expr $failed + 1`
-       fi
-       return $status
-}
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
 
 testit "simple-default" $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-default
 testit "simple-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
@@ -34,9 +20,6 @@ testit "simple-standalone" $PYTHON ./setup/provision $CONFIGURATION --server-rol
 testit "blank-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/blank-dc --blank
 testit "partitions-only-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/partitions-only-dc --partitions-only
 
-testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass
-testit "setpassword" $PYTHON ./setup/setpassword --configfile=$PREFIX/simple-dc/etc/smb.conf testuser --newpassword=testpass
-
 reprovision() {
        $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision"
        $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision"
diff --git a/source/setup/tests/blackbox_setpassword.sh b/source/setup/tests/blackbox_setpassword.sh
new file mode 100755 (executable)
index 0000000..7254661
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: blackbox_setpassword.sh PREFIX CONFIGURATION
+EOF
+exit 1;
+fi
+
+PREFIX="$1"
+CONFIGURATION="$2"
+shift 2
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+testit "simple-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
+
+testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass
+
+testit "setpassword" $PYTHON ./setup/setpassword --configfile=$PREFIX/simple-dc/etc/smb.conf testuser --newpassword=testpass
+
+exit $failed
similarity index 92%
rename from source/setup/upgrade.py
rename to source/setup/upgrade
index 3bcc57ab64770169ca7d13b7fd2ee5a8259d1cf4..03c6747d4e7cdb1c892ef25de5d74579a8fcfb0e 100755 (executable)
@@ -7,10 +7,14 @@
 import getopt
 import optparse
 import os, sys
-import param
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
 import samba
 import samba.getopt as options
-from auth import system_session
+from samba import param
+from samba.auth import system_session
 
 parser = optparse.OptionParser("upgrade [options] <libdir> <smbconf>")
 sambaopts = options.SambaOptions(parser)
diff --git a/source/setup/vampire.py b/source/setup/vampire.py
deleted file mode 100755 (executable)
index 728c531..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/python
-
-# Unix SMB/CIFS implementation.
-# Vampire a remote domain
-# 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/>.
-#
-
-from net import libnet
-import optparse
-import samba.getopt as options
-import param
-from auth import system_session
-import sys
-
-parser = optparse.OptionParser("vampire [options] <domain>")
-sambaopts = options.SambaOptions(parser)
-parser.add_option_group(sambaopts)
-parser.add_option_group(options.VersionOptions(parser))
-credopts = options.CredentialsOptions(parser)
-parser.add_option_group(credopts)
-
-opts, args = parser.parse_args()
-
-if len(args) < 1:
-    parser.print_usage()
-    sys.exit(1)
-
-def vampire(domain, session_info, credentials, lp):
-    ctx = libnet(lp_ctx=lp)
-    ctx.cred = credentials
-    machine_creds = Credentials();
-    machine_creds.set_domain(domain);
-    if not machine_creds.set_machine_account():
-        raise Exception("Failed to access domain join information!")
-    ctx.samsync_ldb(vampire_ctx, machine_creds=machine_creds, 
-                    session_info=session_info)
-
-lp = sambaopts.get_loadparm()
-vampire(args[0], session_info=system_session(), 
-        credentials=credopts.get_credentials(), lp=lp)
index 8834c4483c1e2b2562d1ff8c6ca1c0848454ec45..368b81d18e5cf9d29929aa04161c9e3d2d05f934 100644 (file)
@@ -476,12 +476,12 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
                }
 
                list_size = ea_list_size_chained(st->all_eas.out.num_eas,
-                                                st->all_eas.out.eas);
+                                                st->all_eas.out.eas, 4);
                BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx, blob, list_size));
 
                ea_put_list_chained(blob->data,
                                    st->all_eas.out.num_eas,
-                                   st->all_eas.out.eas);
+                                   st->all_eas.out.eas, 4);
                return NT_STATUS_OK;
 
        case RAW_FILEINFO_SMB2_ALL_INFORMATION:
@@ -503,7 +503,8 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
                SIVAL(blob->data,       0x48, st->all_info2.out.ea_size);
                SIVAL(blob->data,       0x4C, st->all_info2.out.access_mask);
                SBVAL(blob->data,       0x50, st->all_info2.out.position);
-               SBVAL(blob->data,       0x58, st->all_info2.out.mode);
+               SIVAL(blob->data,       0x58, st->all_info2.out.mode);
+               SIVAL(blob->data,       0x5C, st->all_info2.out.alignment_requirement);
                BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob,
                                                     st->all_info2.out.fname.s,
                                                     0x60, default_str_flags,
index 8b6ae308f9362066f6133235076ebb847fed8d5c..e11968a1004a28456b33e09bd48c79887842ca04 100644 (file)
@@ -2,16 +2,16 @@
 #
 [MODULE::SERVICE_SMB]
 INIT_FUNCTION = server_service_smb_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = service_smb_proto.h
+SUBSYSTEM = smbd
 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
index 3d4aa8ba3860e3c75b6f0c323b5bb070636876a3..9adf3348501713ca107cb87db2e98676388d6516 100644 (file)
@@ -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)))
index e3d247cbc08cee893f23f2922fc61c79a3198e07..0afa3a652d5d02486fe4da10490c237b8325fa55 100644 (file)
@@ -65,111 +65,16 @@ NTSTATUS smbsrv_send_oplock_break(void *p, struct ntvfs_handle *ntvfs, uint8_t l
 
 static void switch_message(int type, struct smbsrv_request *req);
 
-/****************************************************************************
-receive a SMB request header from the wire, forming a request_context
-from the result
-****************************************************************************/
-NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
-{
-       struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection);
-       struct smbsrv_request *req;
-       struct timeval cur_time = timeval_current();
-       uint8_t command;
-
-       smb_conn->statistics.last_request_time = cur_time;
-
-       /* see if its a special NBT packet */
-       if (CVAL(blob.data, 0) != 0) {
-               req = smbsrv_init_request(smb_conn);
-               NT_STATUS_HAVE_NO_MEMORY(req);
-
-               ZERO_STRUCT(req->in);
-
-               req->in.buffer = talloc_steal(req, blob.data);
-               req->in.size = blob.length;
-               req->request_time = cur_time;
-
-               smbsrv_reply_special(req);
-               return NT_STATUS_OK;
-       }
-
-       if ((NBT_HDR_SIZE + MIN_SMB_SIZE) > blob.length) {
-               DEBUG(2,("Invalid SMB packet: length %ld\n", (long)blob.length));
-               smbsrv_terminate_connection(smb_conn, "Invalid SMB packet");
-               return NT_STATUS_OK;
-       }
-
-       /* Make sure this is an SMB packet */
-       if (IVAL(blob.data, NBT_HDR_SIZE) != SMB_MAGIC) {
-               DEBUG(2,("Non-SMB packet of length %ld. Terminating connection\n",
-                        (long)blob.length));
-               smbsrv_terminate_connection(smb_conn, "Non-SMB packet");
-               return NT_STATUS_OK;
-       }
-
-       req = smbsrv_init_request(smb_conn);
-       NT_STATUS_HAVE_NO_MEMORY(req);
-
-       req->in.buffer = talloc_steal(req, blob.data);
-       req->in.size = blob.length;
-       req->request_time = cur_time;
-       req->chained_fnum = -1;
-       req->in.allocated = req->in.size;
-       req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
-       req->in.vwv = req->in.hdr + HDR_VWV;
-       req->in.wct = CVAL(req->in.hdr, HDR_WCT);
-       if (req->in.vwv + VWV(req->in.wct) <= req->in.buffer + req->in.size) {
-               req->in.data = req->in.vwv + VWV(req->in.wct) + 2;
-               req->in.data_size = SVAL(req->in.vwv, VWV(req->in.wct));
-
-               /* the bcc length is only 16 bits, but some packets
-                  (such as SMBwriteX) can be much larger than 64k. We
-                  detect this by looking for a large non-chained NBT
-                  packet (at least 64k bigger than what is
-                  specified). If it is detected then the NBT size is
-                  used instead of the bcc size */
-               if (req->in.data_size + 0x10000 <= 
-                   req->in.size - PTR_DIFF(req->in.data, req->in.buffer) &&
-                   (req->in.wct < 1 || SVAL(req->in.vwv, VWV(0)) == SMB_CHAIN_NONE)) {
-                       /* its an oversized packet! fun for all the family */
-                       req->in.data_size = req->in.size - PTR_DIFF(req->in.data,req->in.buffer);
-               }
-       }
-
-       if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct > req->in.size) {
-               DEBUG(2,("Invalid SMB word count %d\n", req->in.wct));
-               smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
-               return NT_STATUS_OK;
-       }
-       if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct + req->in.data_size > req->in.size) {
-               DEBUG(2,("Invalid SMB buffer length count %d\n", 
-                        (int)req->in.data_size));
-               smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
-               return NT_STATUS_OK;
-       }
-
-       req->flags2     = SVAL(req->in.hdr, HDR_FLG2);
-
-       /* fix the bufinfo */
-       smbsrv_setup_bufinfo(req);
-
-       if (!smbsrv_signing_check_incoming(req)) {
-               smbsrv_send_error(req, NT_STATUS_ACCESS_DENIED);
-               return NT_STATUS_OK;
-       }
-
-       command = CVAL(req->in.hdr, HDR_COM);
-       switch_message(command, req);
-       return NT_STATUS_OK;
-}
-
 /*
   These flags determine some of the permissions required to do an operation 
 */
 #define NEED_SESS              (1<<0)
 #define NEED_TCON              (1<<1)
 #define SIGNING_NO_REPLY       (1<<2)
+/* does VWV(0) of the request hold chaining information */
+#define AND_X                  (1<<3)
+/* The 64Kb question: are requests > 64K valid? */
+#define LARGE_REQUEST  (1<<4)
 
 /* 
    define a list of possible SMB messages and their corresponding
@@ -180,6 +85,7 @@ static const struct smb_message_struct
 {
        const char *name;
        void (*fn)(struct smbsrv_request *);
+#define message_flags(type) smb_messages[(type) & 0xff].flags
        int flags;
 }
  smb_messages[256] = {
@@ -219,7 +125,7 @@ static const struct smb_message_struct
 /* 0x21 */ { NULL, NULL, 0 },
 /* 0x22 */ { "SMBsetattrE",    smbsrv_reply_setattrE,          NEED_SESS|NEED_TCON },
 /* 0x23 */ { "SMBgetattrE",    smbsrv_reply_getattrE,          NEED_SESS|NEED_TCON },
-/* 0x24 */ { "SMBlockingX",    smbsrv_reply_lockingX,          NEED_SESS|NEED_TCON },
+/* 0x24 */ { "SMBlockingX",    smbsrv_reply_lockingX,          NEED_SESS|NEED_TCON|AND_X },
 /* 0x25 */ { "SMBtrans",       smbsrv_reply_trans,             NEED_SESS|NEED_TCON },
 /* 0x26 */ { "SMBtranss",      smbsrv_reply_transs,            NEED_SESS|NEED_TCON },
 /* 0x27 */ { "SMBioctl",       smbsrv_reply_ioctl,             NEED_SESS|NEED_TCON },
@@ -228,9 +134,9 @@ static const struct smb_message_struct
 /* 0x2a */ { "SMBmove",                NULL,                           NEED_SESS|NEED_TCON },
 /* 0x2b */ { "SMBecho",                smbsrv_reply_echo,              0 },
 /* 0x2c */ { "SMBwriteclose",  smbsrv_reply_writeclose,        NEED_SESS|NEED_TCON },
-/* 0x2d */ { "SMBopenX",       smbsrv_reply_open_and_X,        NEED_SESS|NEED_TCON },
-/* 0x2e */ { "SMBreadX",       smbsrv_reply_read_and_X,        NEED_SESS|NEED_TCON },
-/* 0x2f */ { "SMBwriteX",      smbsrv_reply_write_and_X,       NEED_SESS|NEED_TCON},
+/* 0x2d */ { "SMBopenX",       smbsrv_reply_open_and_X,        NEED_SESS|NEED_TCON|AND_X },
+/* 0x2e */ { "SMBreadX",       smbsrv_reply_read_and_X,        NEED_SESS|NEED_TCON|AND_X },
+/* 0x2f */ { "SMBwriteX",      smbsrv_reply_write_and_X,       NEED_SESS|NEED_TCON|AND_X|LARGE_REQUEST},
 /* 0x30 */ { NULL, NULL, 0 },
 /* 0x31 */ { NULL, NULL, 0 },
 /* 0x32 */ { "SMBtrans2",      smbsrv_reply_trans2,            NEED_SESS|NEED_TCON },
@@ -298,9 +204,9 @@ static const struct smb_message_struct
 /* 0x70 */ { "SMBtcon",                smbsrv_reply_tcon,              NEED_SESS },
 /* 0x71 */ { "SMBtdis",                smbsrv_reply_tdis,              NEED_TCON },
 /* 0x72 */ { "SMBnegprot",     smbsrv_reply_negprot,           0 },
-/* 0x73 */ { "SMBsesssetupX",  smbsrv_reply_sesssetup,         0 },
-/* 0x74 */ { "SMBulogoffX",    smbsrv_reply_ulogoffX,          NEED_SESS }, /* ulogoff doesn't give a valid TID */
-/* 0x75 */ { "SMBtconX",       smbsrv_reply_tcon_and_X,        NEED_SESS },
+/* 0x73 */ { "SMBsesssetupX",  smbsrv_reply_sesssetup,         AND_X },
+/* 0x74 */ { "SMBulogoffX",    smbsrv_reply_ulogoffX,          NEED_SESS|AND_X }, /* ulogoff doesn't give a valid TID */
+/* 0x75 */ { "SMBtconX",       smbsrv_reply_tcon_and_X,        NEED_SESS|AND_X },
 /* 0x76 */ { NULL, NULL, 0 },
 /* 0x77 */ { NULL, NULL, 0 },
 /* 0x78 */ { NULL, NULL, 0 },
@@ -343,9 +249,9 @@ static const struct smb_message_struct
 /* 0x9d */ { NULL, NULL, 0 },
 /* 0x9e */ { NULL, NULL, 0 },
 /* 0x9f */ { NULL, NULL, 0 },
-/* 0xa0 */ { "SMBnttrans",     smbsrv_reply_nttrans,           NEED_SESS|NEED_TCON },
+/* 0xa0 */ { "SMBnttrans",     smbsrv_reply_nttrans,           NEED_SESS|NEED_TCON|LARGE_REQUEST },
 /* 0xa1 */ { "SMBnttranss",    smbsrv_reply_nttranss,          NEED_SESS|NEED_TCON },
-/* 0xa2 */ { "SMBntcreateX",   smbsrv_reply_ntcreate_and_X,    NEED_SESS|NEED_TCON },
+/* 0xa2 */ { "SMBntcreateX",   smbsrv_reply_ntcreate_and_X,    NEED_SESS|NEED_TCON|AND_X },
 /* 0xa3 */ { NULL, NULL, 0 },
 /* 0xa4 */ { "SMBntcancel",    smbsrv_reply_ntcancel,          NEED_SESS|NEED_TCON|SIGNING_NO_REPLY },
 /* 0xa5 */ { "SMBntrename",    smbsrv_reply_ntrename,          NEED_SESS|NEED_TCON },
@@ -441,6 +347,111 @@ static const struct smb_message_struct
 /* 0xff */ { NULL, NULL, 0 }
 };
 
+/****************************************************************************
+receive a SMB request header from the wire, forming a request_context
+from the result
+****************************************************************************/
+NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
+{
+       struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection);
+       struct smbsrv_request *req;
+       struct timeval cur_time = timeval_current();
+       uint8_t command;
+
+       smb_conn->statistics.last_request_time = cur_time;
+
+       /* see if its a special NBT packet */
+       if (CVAL(blob.data, 0) != 0) {
+               req = smbsrv_init_request(smb_conn);
+               NT_STATUS_HAVE_NO_MEMORY(req);
+
+               ZERO_STRUCT(req->in);
+
+               req->in.buffer = talloc_steal(req, blob.data);
+               req->in.size = blob.length;
+               req->request_time = cur_time;
+
+               smbsrv_reply_special(req);
+               return NT_STATUS_OK;
+       }
+
+       if ((NBT_HDR_SIZE + MIN_SMB_SIZE) > blob.length) {
+               DEBUG(2,("Invalid SMB packet: length %ld\n", (long)blob.length));
+               smbsrv_terminate_connection(smb_conn, "Invalid SMB packet");
+               return NT_STATUS_OK;
+       }
+
+       /* Make sure this is an SMB packet */
+       if (IVAL(blob.data, NBT_HDR_SIZE) != SMB_MAGIC) {
+               DEBUG(2,("Non-SMB packet of length %ld. Terminating connection\n",
+                        (long)blob.length));
+               smbsrv_terminate_connection(smb_conn, "Non-SMB packet");
+               return NT_STATUS_OK;
+       }
+
+       req = smbsrv_init_request(smb_conn);
+       NT_STATUS_HAVE_NO_MEMORY(req);
+
+       req->in.buffer = talloc_steal(req, blob.data);
+       req->in.size = blob.length;
+       req->request_time = cur_time;
+       req->chained_fnum = -1;
+       req->in.allocated = req->in.size;
+       req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
+       req->in.vwv = req->in.hdr + HDR_VWV;
+       req->in.wct = CVAL(req->in.hdr, HDR_WCT);
+
+       command = CVAL(req->in.hdr, HDR_COM);
+
+       if (req->in.vwv + VWV(req->in.wct) <= req->in.buffer + req->in.size) {
+               req->in.data = req->in.vwv + VWV(req->in.wct) + 2;
+               req->in.data_size = SVAL(req->in.vwv, VWV(req->in.wct));
+
+               /* the bcc length is only 16 bits, but some packets
+                  (such as SMBwriteX) can be much larger than 64k. We
+                  detect this by looking for a large non-chained NBT
+                  packet (at least 64k bigger than what is
+                  specified). If it is detected then the NBT size is
+                  used instead of the bcc size */
+               if (req->in.data_size + 0x10000 <= 
+                   req->in.size - PTR_DIFF(req->in.data, req->in.buffer) &&
+                       ( message_flags(command) & LARGE_REQUEST) &&
+                       ( !(message_flags(command) & AND_X) ||
+                     (req->in.wct < 1 || SVAL(req->in.vwv, VWV(0)) == SMB_CHAIN_NONE) )
+                       ) {
+                       /* its an oversized packet! fun for all the family */
+                       req->in.data_size = req->in.size - PTR_DIFF(req->in.data,req->in.buffer);
+               }
+       }
+
+       if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct > req->in.size) {
+               DEBUG(2,("Invalid SMB word count %d\n", req->in.wct));
+               smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
+               return NT_STATUS_OK;
+       }
+       if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct + req->in.data_size > req->in.size) {
+               DEBUG(2,("Invalid SMB buffer length count %d\n", 
+                        (int)req->in.data_size));
+               smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
+               return NT_STATUS_OK;
+       }
+
+       req->flags2     = SVAL(req->in.hdr, HDR_FLG2);
+
+       /* fix the bufinfo */
+       smbsrv_setup_bufinfo(req);
+
+       if (!smbsrv_signing_check_incoming(req)) {
+               smbsrv_send_error(req, NT_STATUS_ACCESS_DENIED);
+               return NT_STATUS_OK;
+       }
+
+       command = CVAL(req->in.hdr, HDR_COM);
+       switch_message(command, req);
+       return NT_STATUS_OK;
+}
+
 /****************************************************************************
 return a string containing the function name of a SMB command
 ****************************************************************************/
@@ -497,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) {
index 87073517ddcdf799d2d230fff8ba8a1935ec708a..c7fa2d7d8abca1959b121b2c961d5c9bc20b90ef 100644 (file)
@@ -651,10 +651,10 @@ bool req_data_oob(struct request_bufinfo *bufinfo, const uint8_t *ptr, uint32_t
        }
        
        /* be careful with wraparound! */
-       if (ptr < bufinfo->data ||
-           ptr >= bufinfo->data + bufinfo->data_size ||
+       if ((uintptr_t)ptr < (uintptr_t)bufinfo->data ||
+           (uintptr_t)ptr >= (uintptr_t)bufinfo->data + bufinfo->data_size ||
            count > bufinfo->data_size ||
-           ptr + count > bufinfo->data + bufinfo->data_size) {
+           (uintptr_t)ptr + count > (uintptr_t)bufinfo->data + bufinfo->data_size) {
                return true;
        }
        return false;
index de2141b8086d2595f42f9c8a8826939e3cf4837e..2c4068bda5f0da029e5fb0c34b7b237914215d99 100644 (file)
@@ -70,7 +70,7 @@ static void sesssetup_old_send(struct auth_check_password_request *areq,
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
        /* This references server_info into session_info */
-       status = auth_generate_session_info(req, req->smb_conn->lp_ctx, 
+       status = auth_generate_session_info(req, req->smb_conn->connection->event.ctx, req->smb_conn->lp_ctx, 
                                            server_info, &session_info);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
@@ -166,7 +166,8 @@ static void sesssetup_nt1_send(struct auth_check_password_request *areq,
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
        /* This references server_info into session_info */
-       status = auth_generate_session_info(req, req->smb_conn->lp_ctx, 
+       status = auth_generate_session_info(req, req->smb_conn->connection->event.ctx, 
+                                           req->smb_conn->lp_ctx, 
                                            server_info, &session_info);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
index c9ba3269fac2bb9a59271d3e5484e6c6f8b05e6e..68ee6e58f640d19a6607f7fbd025e116fdf4013a 100644 (file)
@@ -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)))
index 8f8b4e771cbea2941e62f2d4f4eb9feae32df73a..5ab217bbfd687b036aa5c994f26099c605c391ac 100644 (file)
@@ -79,6 +79,7 @@ void smb2srv_create_recv(struct smb2srv_request *req)
        SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x30, &blob));
        /* TODO: parse the blob */
        ZERO_STRUCT(io->smb2.in.eas);
+       ZERO_STRUCT(io->smb2.in.blobs);
 
        /* the VFS backend does not yet handle NULL filenames */
        if (io->smb2.in.fname == NULL) {
@@ -134,7 +135,7 @@ static void smb2srv_flush_send(struct ntvfs_request *ntvfs)
        SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_flush);
        SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
 
-       SSVAL(req->out.body,    0x02,   0);
+       SSVAL(req->out.body,    0x02,   io->smb2.out.reserved);
 
        smb2srv_send_reply(req);
 }
@@ -142,15 +143,14 @@ static void smb2srv_flush_send(struct ntvfs_request *ntvfs)
 void smb2srv_flush_recv(struct smb2srv_request *req)
 {
        union smb_flush *io;
-       uint16_t _pad;
 
        SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
        SMB2SRV_TALLOC_IO_PTR(io, union smb_flush);
        SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_flush_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
 
        io->smb2.level                  = RAW_FLUSH_SMB2;
-       _pad                            = SVAL(req->in.body, 0x02);
-       io->smb2.in.unknown             = IVAL(req->in.body, 0x04);
+       io->smb2.in.reserved1           = SVAL(req->in.body, 0x02);
+       io->smb2.in.reserved2           = IVAL(req->in.body, 0x04);
        io->smb2.in.file.ntvfs          = smb2srv_pull_handle(req, req->in.body, 0x08);
 
        SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
@@ -246,7 +246,7 @@ static void smb2srv_lock_send(struct ntvfs_request *ntvfs)
        SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
        SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
 
-       SSVAL(req->out.body,    0x02,   io->smb2.out.unknown1);
+       SSVAL(req->out.body,    0x02,   io->smb2.out.reserved);
 
        smb2srv_send_reply(req);
 }
@@ -254,20 +254,34 @@ static void smb2srv_lock_send(struct ntvfs_request *ntvfs)
 void smb2srv_lock_recv(struct smb2srv_request *req)
 {
        union smb_lock *io;
+       int i;
 
        SMB2SRV_CHECK_BODY_SIZE(req, 0x30, false);
        SMB2SRV_TALLOC_IO_PTR(io, union smb_lock);
        SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_lock_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
 
        io->smb2.level                  = RAW_LOCK_SMB2;
-
-       io->smb2.in.unknown1            = SVAL(req->in.body, 0x02);
-       io->smb2.in.unknown2            = IVAL(req->in.body, 0x04);
+       io->smb2.in.lock_count          = SVAL(req->in.body, 0x02);
+       io->smb2.in.reserved            = IVAL(req->in.body, 0x04);
        io->smb2.in.file.ntvfs          = smb2srv_pull_handle(req, req->in.body, 0x08);
-       io->smb2.in.offset              = BVAL(req->in.body, 0x18);
-       io->smb2.in.count               = BVAL(req->in.body, 0x20);
-       io->smb2.in.unknown5            = IVAL(req->in.body, 0x24);
-       io->smb2.in.flags               = IVAL(req->in.body, 0x28);
+       if (req->in.body_size < 24 + 24*(uint64_t)io->smb2.in.lock_count) {
+               DEBUG(0,("%s: lock buffer too small\n", __location__));
+               smb2srv_send_error(req,  NT_STATUS_FOOBAR);
+               return;
+       }
+       io->smb2.in.locks = talloc_array(io, struct smb2_lock_element, 
+                                        io->smb2.in.lock_count);
+       if (io->smb2.in.locks == NULL) {
+               smb2srv_send_error(req, NT_STATUS_NO_MEMORY);
+               return;
+       }
+
+       for (i=0;i<io->smb2.in.lock_count;i++) {
+               io->smb2.in.locks[i].offset     = BVAL(req->in.body, 24 + i*24);
+               io->smb2.in.locks[i].length     = BVAL(req->in.body, 32 + i*24);
+               io->smb2.in.locks[i].flags      = IVAL(req->in.body, 40 + i*24);
+               io->smb2.in.locks[i].reserved   = IVAL(req->in.body, 44 + i*24);
+       }
 
        SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
        SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io));
@@ -409,7 +423,36 @@ void smb2srv_notify_recv(struct smb2srv_request *req)
        SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_notify(req->ntvfs, io));
 }
 
+static void smb2srv_break_send(struct ntvfs_request *ntvfs)
+{
+       struct smb2srv_request *req;
+       union smb_lock *io;
+
+       SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
+       SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x18, false, 0));
+
+       SCVAL(req->out.body,    0x02,   io->smb2_break.out.oplock_level);
+       SCVAL(req->out.body,    0x03,   io->smb2_break.out.reserved);
+       SIVAL(req->out.body,    0x04,   io->smb2_break.out.reserved2);
+       smb2srv_push_handle(req->out.body, 0x08,io->smb2_break.out.file.ntvfs);
+
+       smb2srv_send_reply(req);
+}
+
 void smb2srv_break_recv(struct smb2srv_request *req)
 {
-       smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
+       union smb_lock *io;
+
+       SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
+       SMB2SRV_TALLOC_IO_PTR(io, union smb_lock);
+       SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_break_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
+
+       io->smb2_break.level            = RAW_LOCK_SMB2_BREAK;
+       io->smb2_break.in.oplock_level  = CVAL(req->in.body, 0x02);
+       io->smb2_break.in.reserved      = CVAL(req->in.body, 0x03);
+       io->smb2_break.in.reserved2     = IVAL(req->in.body, 0x04);
+       io->smb2_break.in.file.ntvfs    = smb2srv_pull_handle(req, req->in.body, 0x08);
+
+       SMB2SRV_CHECK_FILE_HANDLE(io->smb2_break.in.file.ntvfs);
+       SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io));
 }
index 6018f1958f8d192aba2d213a7055fe6b637fc142..32b280c5c2e4ffca3b722f856b0907c1647fc607 100644 (file)
@@ -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);
index e7352f7c423972410fa728d7bdd44c64ce6ac8cb..4479ae2da1d7ff9d234acbc3ffed6118193980f2 100644 (file)
@@ -114,9 +114,12 @@ static NTSTATUS smb2srv_negprot_backend(struct smb2srv_request *req, struct smb2
        io->out.security_mode      = 0; /* no signing yet */
        io->out.dialect_revision   = SMB2_DIALECT_REVISION;
        io->out.capabilities       = 0;
-       io->out.max_transact_size  = 0x10000;
-       io->out.max_read_size      = 0x10000;
-       io->out.max_write_size     = 0x10000;
+       io->out.max_transact_size  = lp_parm_ulong(req->smb_conn->lp_ctx, NULL, 
+                                                  "smb2", "max transaction size", 0x10000);
+       io->out.max_read_size      = lp_parm_ulong(req->smb_conn->lp_ctx, NULL, 
+                                                  "smb2", "max read size", 0x10000);
+       io->out.max_write_size     = lp_parm_ulong(req->smb_conn->lp_ctx, NULL, 
+                                                  "smb2", "max write size", 0x10000);
        io->out.system_time        = timeval_to_nttime(&current_time);
        io->out.server_start_time  = timeval_to_nttime(&boot_time);
        io->out.reserved2          = 0;
index 2f347d387618f5e813bb426eaf7a7bc053d99ce7..ae4abbd71e1b440cdadff6cd849447ff0baef649 100644 (file)
@@ -70,7 +70,7 @@ struct smbsrv_request;
 
 #include "smb_server/smb2/smb2_proto.h"
 
-/* useful way of catching wct errors with file and line number */
+/* useful way of catching field size errors with file and line number */
 #define SMB2SRV_CHECK_BODY_SIZE(req, size, dynamic) do { \
        size_t is_size = req->in.body_size; \
        uint16_t field_size = SVAL(req->in.body, 0); \
@@ -78,13 +78,13 @@ struct smbsrv_request;
        if (is_size < (size)) { \
                DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \
                         __location__, (unsigned)is_size, (unsigned)want_size)); \
-               smb2srv_send_error(req,  NT_STATUS_FOOBAR); \
+               smb2srv_send_error(req,  NT_STATUS_INVALID_PARAMETER); \
                return; \
        }\
        if (field_size != want_size) { \
                DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \
                         __location__, (unsigned)field_size, (unsigned)want_size)); \
-               smb2srv_send_error(req,  NT_STATUS_FOOBAR); \
+               smb2srv_send_error(req,  NT_STATUS_INVALID_PARAMETER); \
                return; \
        } \
 } while (0)
index 4f8e628f7414762761c1e10b2cac04d8d4a50c7b..367557dbb7422ff75b556f827ff2a1380b064a2e 100644 (file)
@@ -157,6 +157,7 @@ static void smbsrv_accept(struct stream_connection *conn)
        smbsrv_management_init(smb_conn);
 
        if (!NT_STATUS_IS_OK(share_get_context_by_name(smb_conn, lp_share_backend(smb_conn->lp_ctx), 
+                                                      smb_conn->connection->event.ctx,
                                                       smb_conn->lp_ctx, &(smb_conn->share_context)))) {
                smbsrv_terminate_connection(smb_conn, "share_init failed!");
                return;
@@ -206,7 +207,7 @@ static void smbsrv_preopen_ldb(struct task_server *task)
        /* yes, this looks strange. It is a hack to preload the
           schema. I'd like to share most of the ldb context with the
           child too. That will come later */
-       talloc_free(samdb_connect(task, task->lp_ctx, NULL));
+       talloc_free(samdb_connect(task, task->event_ctx, task->lp_ctx, NULL));
 }
 
 /*
index 006135f818a763f321aa7597b76b5d0fd4147707..e60f444456e40dbc447af3dbd1f20681d8683b09 100644 (file)
@@ -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
 #################################
index 2cb551a520d32bd230db98eccbc5837fb13da932..e631975b37613d7b29a9c30ada7f4e4e9d017ac1 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "includes.h"
 #include "smbd/process_model.h"
-#include "build.h"
 #include "param/param.h"
 
 /*
index 48899078f7803c4912c08bedbed7e35aed9c8cae..5ed8471a9d265cd1e9f4c621329d39d937de59a2 100644 (file)
@@ -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)))
index 3f6cb480135b6ca2a6b1e1eb6f50432bcf1fac7a..e1ebd133ce19ebd3c0ea59ad72f9a20649b14b08 100644 (file)
@@ -28,7 +28,6 @@
 #include "lib/cmdline/popt_common.h"
 #include "system/dir.h"
 #include "system/filesys.h"
-#include "build.h"
 #include "ldb/include/ldb.h"
 #include "registry/registry.h"
 #include "ntvfs/ntvfs.h"
@@ -199,7 +198,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        extern NTSTATUS server_service_smb_init(void);
        extern NTSTATUS server_service_drepl_init(void);
        extern NTSTATUS server_service_rpc_init(void);
-       init_module_fn static_init[] = { STATIC_service_MODULES };
+       init_module_fn static_init[] = { STATIC_smbd_MODULES };
        init_module_fn *shared_init;
        struct event_context *event_ctx;
        NTSTATUS status;
index 9f744efa812e4b7e6fab84e308fff11eccbce25d..e27d87ec750c709852365e5b1480ac2d9d1ac89b 100644 (file)
@@ -119,6 +119,7 @@ void stream_io_handler_callback(void *private, uint16_t flags)
   a server connection
 */
 NTSTATUS stream_new_connection_merge(struct event_context *ev,
+                                    struct loadparm_context *lp_ctx,
                                     const struct model_ops *model_ops,
                                     struct socket_context *sock,
                                     const struct stream_server_ops *stream_ops,
@@ -140,6 +141,7 @@ NTSTATUS stream_new_connection_merge(struct event_context *ev,
        srv_conn->ops           = stream_ops;
        srv_conn->msg_ctx       = msg_ctx;
        srv_conn->event.ctx     = ev;
+       srv_conn->lp_ctx        = lp_ctx;
        srv_conn->event.fde     = event_add_fd(ev, srv_conn, socket_get_fd(sock),
                                               EVENT_FD_READ, 
                                               stream_io_handler_fde, srv_conn);
index 04d23a56f26897c87f50d765fcbf3ec94a74dc47..d57a54cdc9090cb136fd98b4dfe19b1ef8e7e064 100644 (file)
@@ -50,6 +50,12 @@ struct stream_connection {
        struct messaging_context *msg_ctx;
        struct loadparm_context *lp_ctx;
 
+       /*
+        * this transport layer session info, normally NULL
+        * which means the same as an anonymous session info
+        */
+       struct auth_session_info *session_info;
+
        bool processing;
        const char *terminate;
 };
index a442b0102527c086d15d5fb5867e2d207c562244..7eb8fa10feec847211e67bb332615f150489fdd0 100644 (file)
@@ -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
index 917a24ad598b6379c29136918979d3d38109b7b2..739a048d29a790a8ce5c50b6c168e47fba0fd493 100644 (file)
@@ -33,7 +33,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
        TALLOC_CTX *mem_ctx = tctx;
 
        torture_assert_ntstatus_ok(tctx, 
-               gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+               gensec_client_start(mem_ctx, &gensec_security,
+                                   tctx->ev, tctx->lp_ctx),
                "gensec client start");
 
        gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -87,7 +88,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
        talloc_free(gensec_security);
 
        torture_assert_ntstatus_ok(tctx, 
-               gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+               gensec_client_start(mem_ctx, &gensec_security,
+                                   tctx->ev, tctx->lp_ctx),
                "Failed to start GENSEC for NTLMSSP");
 
        gensec_set_credentials(gensec_security, cmdline_credentials);
index 3a3a7c2fd5998ce028b2bdd92f18ee6a11eb90ca..2ab3f9ca91640068b68b2ff179084f6ec052249b 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/basic/proto.h"
 #include "libcli/libcli.h"
 #include "libcli/raw/raw_proto.h"
@@ -55,7 +55,8 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
 
        lp_smbcli_options(tctx->lp_ctx, &options);
 
-       if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), &options)) {
+       if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), tctx->ev,
+                                  lp_resolve_context(tctx->lp_ctx), &options)) {
                torture_comment(tctx, "Failed to connect with %s\n", host);
                goto failed;
        }
index 2e2585b9766d55533ebed7e5d20c2302fe2f468f..3f399c97efd386457c393644131b99c4aefb6177 100644 (file)
@@ -23,9 +23,8 @@
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
 #include "libcli/libcli.h"
-#include "torture/ui.h"
+#include "torture/smbtorture.h"
 #include "torture/util.h"
-#include "torture/torture.h"
 #include "system/time.h"
 #include "system/filesys.h"
 
index 188fc1bc69b437849cad8a3e1e1053658321565a..24e0324bc3e303bbe5fc6554b2565e2de3527d44 100644 (file)
@@ -30,7 +30,7 @@
 #include "libcli/resolve/resolve.h"
 #include "auth/credentials/credentials.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/util.h"
 #include "libcli/smb_composite/smb_composite.h"
 #include "libcli/composite/composite.h"
index e6c54022c286b0390467f4c250b55a571e3013e7..2857b99582b80340c10ae9c56aa8ad0be783a0e9 100644 (file)
@@ -1,30 +1,14 @@
-# TORTURE subsystem
-[LIBRARY::torture]
-PRIVATE_PROTO_HEADER = proto.h
-PUBLIC_DEPENDENCIES = \
-               LIBSAMBA-HOSTCONFIG \
-               LIBSAMBA-UTIL \
-               LIBTALLOC \
-               LIBPOPT
-
-PC_FILES += torture/torture.pc
-torture_OBJ_FILES = $(addprefix torture/, torture.o ui.o)
-
-PUBLIC_HEADERS += torture/torture.h torture/ui.h
-
 [SUBSYSTEM::TORTURE_UTIL]
 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 = torture
+SUBSYSTEM = smbtorture
 INIT_FUNCTION = torture_base_init
-PRIVATE_PROTO_HEADER = \
-               basic/proto.h
 PRIVATE_DEPENDENCIES = \
                LIBCLI_SMB POPT_CREDENTIALS \
                TORTURE_UTIL LIBCLI_RAW \
@@ -32,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 \
@@ -52,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 = torture
+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 \
@@ -86,6 +69,8 @@ TORTURE_RAW_OBJ_FILES = $(addprefix torture/raw/, \
                lock.o \
                pingpong.o \
                lockbench.o \
+               lookuprate.o \
+               tconrate.o \
                openbench.o \
                rename.o \
                eas.o \
@@ -98,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 = torture
+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 \
@@ -124,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 \
@@ -133,99 +118,97 @@ 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 = torture
+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 = torture
-PRIVATE_PROTO_HEADER = \
-               auth/proto.h
+SUBSYSTEM = smbtorture
 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
 
 #################################
 # Start MODULE TORTURE_NBENCH
 [MODULE::TORTURE_NBENCH]
-SUBSYSTEM = torture
+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
 [MODULE::TORTURE_UNIX]
-SUBSYSTEM = torture
+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 = torture
+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 = torture
+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 = torture
+SUBSYSTEM = smbtorture
 INIT_FUNCTION = torture_net_init
-PRIVATE_PROTO_HEADER = \
-               libnet/proto.h
 PRIVATE_DEPENDENCIES = \
                LIBSAMBA-NET \
                POPT_CREDENTIALS \
@@ -233,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
@@ -254,9 +238,10 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY smbtorture
 #################################
 
-smbtorture_OBJ_FILES = torture/smbtorture.o
+smbtorture_OBJ_FILES = $(torturesrcdir)/smbtorture.o $(torturesrcdir)/torture.o 
 
-MANPAGES += torture/man/smbtorture.1
+PUBLIC_HEADERS += $(torturesrcdir)/smbtorture.h
+MANPAGES += $(torturesrcdir)/man/smbtorture.1
 
 #################################
 # Start BINARY gentest
@@ -273,9 +258,26 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY gentest
 #################################
 
-gentest_OBJ_FILES = torture/gentest.o
+gentest_OBJ_FILES = $(torturesrcdir)/gentest.o
 
-MANPAGES += torture/man/gentest.1
+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
+#################################
+
+gentest_smb2_OBJ_FILES = $(torturesrcdir)/gentest_smb2.o
 
 #################################
 # Start BINARY masktest
@@ -291,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
@@ -309,36 +311,44 @@ 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
 
-COV_TARGET = test
+GCOV=0
 
-COV_VARS = \
-       CFLAGS="$(CFLAGS) --coverage" \
-       LDFLAGS="$(LDFLAGS) --coverage"
+ifeq ($(MAKECMDGOALS),gcov)
+GCOV=1
+endif
 
-test_cov:
-       -$(MAKE) $(COV_TARGET) $(COV_VARS)
+ifeq ($(MAKECMDGOALS),lcov)
+GCOV=1
+endif
 
-gcov: test_cov
+ifeq ($(MAKECMDGOALS),testcov-html)
+GCOV=1
+endif
+
+ifeq ($(GCOV),1)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+endif
+
+COV_TARGET = test
+
+gcov: test
        for I in $(sort $(dir $(ALL_OBJS))); \
                do $(GCOV) -p -o $$I $$I/*.c; \
        done
 
-lcov-split: 
-       rm -f samba.info
-       @$(MAKE) $(COV_TARGET) $(COV_VARS) \
-               TEST_OPTIONS="--analyse-cmd=\"lcov --base-directory `pwd` --directory . --capture --output-file samba.info -t\""
+samba.info: test
        -rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
-       -rm lib/policy/*/{lex,parse}.{gcda,gcno}
-       genhtml -o coverage samba.info
-
-lcov: test_cov
-       -rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
-       -rm lib/policy/*/{lex,parse}.{gcda,gcno}
        lcov --base-directory `pwd` --directory . --capture --output-file samba.info
-       genhtml -o coverage samba.info
+
+lcov: samba.info
+       genhtml -o coverage $<
 
 testcov-html:: lcov
+
+clean::
+       @rm -f samba.info
index d5fc855f175fbd32cc9fb4b10349351b59e8d012..ae18fe809c93e55753b52ad8ac2a34408a3c8609 100644 (file)
@@ -19,6 +19,7 @@
 
 #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"
 
 /* global options */
 static struct gentest_options {
-       bool showall;
-       bool analyze;
-       bool analyze_always;
-       bool analyze_continuous;
+       int showall;
+       int analyze;
+       int analyze_always;
+       int analyze_continuous;
        uint_t max_open_handles;
        uint_t seed;
        uint_t numops;
-       bool use_oplocks;
+       int use_oplocks;
        char **ignore_patterns;
        const char *seeds_file;
-       bool use_preset_seeds;
-       bool fast_reconnect;
+       int use_preset_seeds;
+       int fast_reconnect;
 } options;
 
 /* mapping between open handles on the server and local handles */
@@ -154,7 +155,8 @@ static bool connect_servers_fast(void)
 /***************************************************** 
 connect to the servers
 *******************************************************/
-static bool connect_servers(struct loadparm_context *lp_ctx)
+static bool connect_servers(struct event_context *ev,
+                           struct loadparm_context *lp_ctx)
 {
        int i, j;
 
@@ -193,7 +195,7 @@ static bool connect_servers(struct loadparm_context *lp_ctx)
                                                        servers[i].share_name, NULL, 
                                                        servers[i].credentials, 
                                                        lp_resolve_context(lp_ctx), 
-                                                       NULL, &smb_options);
+                                                       ev, &smb_options);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
@@ -1937,11 +1939,11 @@ static struct {
   run the test with the current set of op_parms parameters
   return the number of operations that completed successfully
 */
-static int run_test(struct loadparm_context *lp_ctx)
+static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
 {
        int op, i;
 
-       if (!connect_servers(lp_ctx)) {
+       if (!connect_servers(ev, lp_ctx)) {
                printf("Failed to connect to servers\n");
                exit(1);
        }
@@ -2018,7 +2020,8 @@ static int run_test(struct loadparm_context *lp_ctx)
    perform a backtracking analysis of the minimal set of operations
    to generate an error
 */
-static void backtrack_analyze(struct loadparm_context *lp_ctx)
+static void backtrack_analyze(struct event_context *ev,
+                             struct loadparm_context *lp_ctx)
 {
        int chunk, ret;
 
@@ -2039,7 +2042,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
                        }
                        printf("Testing %d ops with %d-%d disabled\n", 
                               options.numops, base, max-1);
-                       ret = run_test(lp_ctx);
+                       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;
@@ -2071,7 +2074,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
        } while (chunk > 0);
 
        printf("Reduced to %d ops\n", options.numops);
-       ret = run_test(lp_ctx);
+       ret = run_test(ev, lp_ctx);
        if (ret != options.numops - 1) {
                printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
        }
@@ -2080,7 +2083,8 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
 /* 
    start the main gentest process
 */
-static bool start_gentest(struct loadparm_context *lp_ctx)
+static bool start_gentest(struct event_context *ev,
+                         struct loadparm_context *lp_ctx)
 {
        int op;
        int ret;
@@ -2116,15 +2120,15 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
                }
        }
 
-       ret = run_test(lp_ctx);
+       ret = run_test(ev, lp_ctx);
 
        if (ret != options.numops && options.analyze) {
                options.numops = ret+1;
-               backtrack_analyze(lp_ctx);
+               backtrack_analyze(ev, lp_ctx);
        } else if (options.analyze_always) {
-               backtrack_analyze(lp_ctx);
+               backtrack_analyze(ev, lp_ctx);
        } else if (options.analyze_continuous) {
-               while (run_test(lp_ctx) == options.numops) ;
+               while (run_test(ev, lp_ctx) == options.numops) ;
        }
 
        return ret == options.numops;
@@ -2171,6 +2175,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
        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;
@@ -2278,9 +2283,11 @@ static bool split_unc_name(const char *unc, char **server, char **share)
 
        printf("seed=%u\n", options.seed);
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(lp_ctx);
 
-       ret = start_gentest(lp_ctx);
+       ret = start_gentest(ev, lp_ctx);
 
        if (ret) {
                printf("gentest completed - no errors\n");
diff --git a/source/torture/gentest_smb2.c b/source/torture/gentest_smb2.c
new file mode 100644 (file)
index 0000000..6546ba6
--- /dev/null
@@ -0,0 +1,1907 @@
+/* 
+   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;
+       int mask_indexing;
+       int no_eas;
+} 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 < 5) {
+               if (gen_chance(90)) 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 set of lock flags
+*/
+static uint16_t gen_lock_flags(void)
+{
+       if (gen_chance(5))  return gen_bits_mask(0xFFFF);
+       if (gen_chance(20)) return gen_bits_mask(0x1F);
+       if (gen_chance(50)) return SMB2_LOCK_FLAG_UNLOCK;
+       return gen_bits_mask(SMB2_LOCK_FLAG_SHARED | 
+                            SMB2_LOCK_FLAG_EXCLUSIVE | 
+                            SMB2_LOCK_FLAG_FAIL_IMMEDIATELY);
+}
+
+/*
+  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(70)) return SEC_FLAG_MAXIMUM_ALLOWED;
+       if (gen_chance(70)) 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(50)) return NTCREATEX_DISP_OPEN_IF;
+       if (gen_chance(10)) return gen_bits_mask(0xFFFFFFFF);
+       return gen_int_range(0, 5);
+}
+
+/*
+  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;
+}
+
+/*
+  generate an ea_struct
+*/
+static struct smb_ea_list gen_ea_list(void)
+{
+       struct smb_ea_list eas;
+       int i;
+       if (options.no_eas) {
+               ZERO_STRUCT(eas);
+               return eas;
+       }
+       eas.num_eas = gen_int_range(0, 3);
+       eas.eas = talloc_array(current_op.mem_ctx, struct ea_struct, eas.num_eas);
+       for (i=0;i<eas.num_eas;i++) {
+               eas.eas[i] = gen_ea_struct();
+       }
+       return eas;
+}
+
+/*
+  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%llx 0x%llx\n", #field, \
+                      (unsigned long long)parm[0].field, (unsigned long long)parm[1].field); \
+               return false; \
+       } \
+} while(0)
+
+#define CHECK_ATTRIB(field) do { \
+               if (!options.mask_indexing) { \
+               CHECK_EQUAL(field); \
+       } else if ((~FILE_ATTRIBUTE_NONINDEXED & parm[0].field) != (~FILE_ATTRIBUTE_NONINDEXED & 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_create(int instance)
+{
+       struct smb2_create parm[NSERVERS];
+       NTSTATUS status[NSERVERS];
+
+       ZERO_STRUCT(parm[0]);
+       parm[0].in.security_flags             = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFF);
+       parm[0].in.oplock_level               = gen_bits_levels(3, 90, 0x0, 70, 0x9, 100, 0xFF);
+       parm[0].in.impersonation_level        = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFFFFFFFF);
+       parm[0].in.create_flags               = gen_bits_levels(2, 90, 0x0, 100, 0xFFFFFFFF);
+       if (gen_chance(2)) {
+               parm[0].in.create_flags       |= gen_bits_mask(0xFFFFFFFF);
+       }
+       parm[0].in.reserved                   = gen_bits_levels(2, 95, 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);
+       parm[0].in.eas                        = gen_ea_list();
+
+       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_ATTRIB(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_ATTRIB(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;
+}
+
+/*
+  generate lockingx operations
+*/
+static bool handler_lock(int instance)
+{
+       struct smb2_lock parm[NSERVERS];
+       NTSTATUS status[NSERVERS];
+       int n;
+
+       parm[0].level = RAW_LOCK_LOCKX;
+       parm[0].in.file.handle.data[0] = gen_fnum(instance);
+       parm[0].in.lock_count = gen_lock_count();
+       parm[0].in.reserved = gen_bits_mask2(0, 0xFFFFFFFF);
+       
+       parm[0].in.locks = talloc_array(current_op.mem_ctx,
+                                       struct smb2_lock_element,
+                                       parm[0].in.lock_count);
+       for (n=0;n<parm[0].in.lock_count;n++) {
+               parm[0].in.locks[n].offset = gen_offset();
+               parm[0].in.locks[n].length = gen_io_count();
+               /* don't yet cope with async replies */
+               parm[0].in.locks[n].flags  = gen_lock_flags() | 
+                       SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
+               parm[0].in.locks[n].reserved = gen_bits_mask2(0x0, 0xFFFFFFFF);
+       }
+
+       GEN_COPY_PARM;
+       GEN_SET_FNUM(in.file.handle);
+       GEN_CALL(smb2_lock(tree, &parm[i]));
+
+       return true;
+}
+
+/*
+  generate flush operations
+*/
+static bool handler_flush(int instance)
+{
+       struct smb2_flush parm[NSERVERS];
+       NTSTATUS status[NSERVERS];
+
+       ZERO_STRUCT(parm[0]);
+       parm[0].in.file.handle.data[0] = gen_fnum(instance);
+       parm[0].in.reserved1  = gen_bits_mask2(0x0, 0xFFFF);
+       parm[0].in.reserved2  = gen_bits_mask2(0x0, 0xFFFFFFFF);
+
+       GEN_COPY_PARM;
+       GEN_SET_FNUM(in.file.handle);
+       GEN_CALL(smb2_flush(tree, &parm[i]));
+
+       CHECK_EQUAL(out.reserved);
+
+       return true;
+}
+
+/*
+  generate echo operations
+*/
+static bool handler_echo(int instance)
+{
+       NTSTATUS status[NSERVERS];
+
+       GEN_CALL(smb2_keepalive(tree->session->transport));
+
+       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(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(SMB2_ALL_INFORMATION),
+               LVL(ALT_NAME_INFORMATION), LVL(STREAM_INFORMATION), LVL(COMPRESSION_INFORMATION),
+               LVL(NETWORK_OPEN_INFORMATION), LVL(ATTRIBUTE_TAG_INFORMATION),
+               LVL(SMB2_ALL_EAS), LVL(SMB2_ALL_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_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_ATTRIB(basic_info.out.attrib);
+               break;
+
+       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_INFORMATION:
+               CHECK_EQUAL(ea_info.out.ea_size);
+               break;
+
+       case RAW_FILEINFO_NAME_INFORMATION:
+               CHECK_WSTR_EQUAL(name_info.out.fname);
+               break;
+
+       case RAW_FILEINFO_ALT_NAME_INFORMATION:
+               CHECK_WSTR_EQUAL(alt_name_info.out.fname);
+               break;
+
+       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_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_ATTRIB(network_open_information.out.attrib);
+               break;
+
+       case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION:
+               CHECK_ATTRIB(attribute_tag_information.out.attrib);
+               CHECK_EQUAL(attribute_tag_information.out.reparse_tag);
+               break;
+
+       case RAW_FILEINFO_ALL_INFORMATION:
+       case RAW_FILEINFO_SMB2_ALL_INFORMATION:
+               CHECK_NTTIMES_EQUAL(all_info2.out.create_time);
+               CHECK_NTTIMES_EQUAL(all_info2.out.access_time);
+               CHECK_NTTIMES_EQUAL(all_info2.out.write_time);
+               CHECK_NTTIMES_EQUAL(all_info2.out.change_time);
+               CHECK_ATTRIB(all_info2.out.attrib);
+               CHECK_EQUAL(all_info2.out.unknown1);
+               CHECK_EQUAL(all_info2.out.alloc_size);
+               CHECK_EQUAL(all_info2.out.size);
+               CHECK_EQUAL(all_info2.out.nlink);
+               CHECK_EQUAL(all_info2.out.delete_pending);
+               CHECK_EQUAL(all_info2.out.directory);
+               CHECK_EQUAL(all_info2.out.file_id);
+               CHECK_EQUAL(all_info2.out.ea_size);
+               CHECK_EQUAL(all_info2.out.access_mask);
+               CHECK_EQUAL(all_info2.out.position);
+               CHECK_EQUAL(all_info2.out.mode);
+               CHECK_EQUAL(all_info2.out.alignment_requirement);
+               CHECK_WSTR_EQUAL(all_info2.out.fname);
+               break;
+
+       case RAW_FILEINFO_SMB2_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;
+
+               /* 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_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.handle.data[0] = gen_fnum(instance);
+
+       gen_fileinfo(instance, &parm[0]);
+
+       GEN_COPY_PARM;
+       GEN_SET_FNUM(generic.in.file.handle);
+       GEN_CALL(smb2_getinfo_file(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[] = {
+               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_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_INFORMATION:
+               info->disposition_info.in.delete_on_close = gen_bool();
+               break;
+       case RAW_SFILEINFO_ALLOCATION_INFORMATION:
+               info->allocation_info.in.alloc_size = gen_alloc_size();
+               break;
+       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_1023:
+       case RAW_SFILEINFO_1025:
+       case RAW_SFILEINFO_1029:
+       case RAW_SFILEINFO_1032:
+       case RAW_SFILEINFO_1039:
+       case RAW_SFILEINFO_1040:
+               /* 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.handle);
+       GEN_CALL(smb2_setinfo_file(tree, &parm[i]));
+
+       return true;
+}
+
+/*
+  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[] = {
+       {"CREATE",     handler_create},
+       {"CLOSE",      handler_close},
+       {"READ",       handler_read},
+       {"WRITE",      handler_write},
+       {"LOCK",       handler_lock},
+       {"FLUSH",      handler_flush},
+       {"ECHO",       handler_echo},
+       {"QFILEINFO",  handler_qfileinfo},
+       {"SFILEINFO",  handler_sfileinfo},
+};
+
+
+/*
+  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]" },
+               {"maskindexing",  0, POPT_ARG_NONE,  &options.mask_indexing, 0, "mask out the indexed file attrib",     NULL},
+               {"noeas",  0, POPT_ARG_NONE,  &options.no_eas, 0,       "don't use extended attributes",        NULL},
+               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;
+}
index dbe9d2f9a44a044855b321300b86f442b62e35cc..5d4acd581b34c6175eb5306440b1821fc325305f 100644 (file)
 */
 static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
 {
-       struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       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;
 
+       cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        ZERO_STRUCT(search);
        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;
 
@@ -61,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");
@@ -80,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);
 
@@ -89,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");
 
@@ -98,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);
 
@@ -110,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");
 
@@ -119,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();
@@ -138,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;
@@ -173,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;
 }
@@ -244,13 +271,15 @@ static void cldap_dump_results(struct cldap_search *search)
 */
 static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
 {
-       struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        NTSTATUS status;
        struct cldap_search search;
        const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
        const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
        const char *attrs3[] = { "netlogon", NULL };
 
+       cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        ZERO_STRUCT(search);
        search.in.dest_address = dest;
        search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
index 83e505e164ee0210b607d0304f17c6fe95e757ac..df2a5b0551a47fe07939fba08dd54a3afd3d24d1 100644 (file)
@@ -51,7 +51,7 @@ static void request_handler(struct cldap_request *req)
 */
 static bool bench_cldap(struct torture_context *tctx, const char *address)
 {
-       struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        int num_sent=0;
        struct timeval tv = timeval_current();
        bool ret = true;
@@ -59,6 +59,8 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
        struct cldap_netlogon search;
        struct bench_state *state;
 
+       cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        state = talloc_zero(tctx, struct bench_state);
 
        ZERO_STRUCT(search);
@@ -116,7 +118,7 @@ bool torture_bench_cldap(struct torture_context *torture)
        make_nbt_name_server(&name, torture_setting_string(torture, "host", NULL));
 
        /* do an initial name resolution to find its IP */
-       status = resolve_name(lp_resolve_context(torture->lp_ctx), &name, torture, &address, event_context_find(torture));
+       status = resolve_name(lp_resolve_context(torture->lp_ctx), &name, torture, &address, torture->ev);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to resolve %s - %s\n",
                       name.name, nt_errstr(status));
index 65b02ed5e8e1fea277b73d546fbdc4eee68bac87..2c11de729c23f625dfee5ee03c1bc681f935769e 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "includes.h"
 #include "libcli/ldap/ldap_client.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/ldap/proto.h"
 
 NTSTATUS torture_ldap_bind(struct ldap_connection *conn, const char *userdn, const char *password)
@@ -65,7 +65,7 @@ NTSTATUS torture_ldap_connection(struct torture_context *tctx,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       *conn = ldap4_new_connection(tctx, tctx->lp_ctx, NULL);
+       *conn = ldap4_new_connection(tctx, tctx->lp_ctx, tctx->ev);
 
        status = ldap_connect(*conn, url);
        if (!NT_STATUS_IS_OK(status)) {
index 4cfce11eb5b0cacff204075a7d86685766c69d11..8437e7f79db13af5652b04815df1e48fa7b8eae8 100644 (file)
@@ -376,7 +376,7 @@ bool torture_ldap_schema(struct torture_context *torture)
 
        url = talloc_asprintf(torture, "ldap://%s/", host);
 
-       ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
+       ldb = ldb_wrap_connect(torture, torture->ev, torture->lp_ctx, url,
                               NULL,
                               cmdline_credentials,
                               0, NULL);
index cec330b2f6138b3ff9ad797642a5b73685ccc318..87b7e09e136276d2e13ef49ea5d2f20ba01bbfc8 100644 (file)
@@ -162,7 +162,7 @@ bool torture_ldap_uptodatevector(struct torture_context *torture)
        url = talloc_asprintf(torture, "ldap://%s/", host);
        if (!url) goto failed;
 
-       ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
+       ldb = ldb_wrap_connect(torture, torture->ev, torture->lp_ctx, url,
                               NULL,
                               cmdline_credentials,
                               0, NULL);
index ff1fbcab7885e11b1a66100d82c46044edb1a56d..ab7846e5e11a04f32b514353fe65a9c92fc23dd3 100644 (file)
@@ -74,7 +74,6 @@ bool torture_domainopen(struct torture_context *torture)
 {
        NTSTATUS status;
        struct libnet_context *net_ctx;
-       struct event_context *evt_ctx;
        TALLOC_CTX *mem_ctx;
        bool ret = true;
        struct policy_handle h;
@@ -82,8 +81,7 @@ bool torture_domainopen(struct torture_context *torture)
 
        mem_ctx = talloc_init("test_domain_open");
 
-       evt_ctx = event_context_find(torture);
-       net_ctx = libnet_context_init(evt_ctx, torture->lp_ctx);
+       net_ctx = libnet_context_init(torture->ev, torture->lp_ctx);
 
        status = torture_rpc_connection(torture, 
                                        &net_ctx->samr.pipe,
index 3a75ffcae3e345ae0c63ad80977b28b086d4dea5..8c8353e8d6b700d89a14e9d8586e2254c9ff3a63 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "librpc/rpc/dcerpc.h"
 #include "librpc/gen_ndr/security.h"
 #include "librpc/gen_ndr/lsa.h"
index 4d57a84582874a8182a9097202b0d51dac827235..bc92b4ebc2e29edc6a924a8931690e3844e20cfc 100644 (file)
@@ -322,7 +322,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
 
        sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
        DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", sam_ldb_path));
-       s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, sam_ldb_path,
+       s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->tctx->lp_ctx, sam_ldb_path,
                                  system_session(s, s->tctx->lp_ctx),
                                  NULL, 0, NULL);
        if (!s->ldb) {
@@ -654,7 +654,7 @@ bool torture_net_become_dc(struct torture_context *torture)
 
        sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
        DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", sam_ldb_path));
-       s->ldb = ldb_wrap_connect(s, s->lp_ctx, sam_ldb_path,
+       s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->lp_ctx, sam_ldb_path,
                                  system_session(s, s->lp_ctx),
                                  NULL, 0, NULL);
        if (!s->ldb) {
index eb6abc45d5967fab0ac6db815a85ddb418798af1..7d5be368c2cc9a3c0d339b9c65471b9473f7c12b 100644 (file)
@@ -201,7 +201,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
 
        mem_ctx = talloc_init("torture_domain_close_lsa");
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
-                                    cmdline_credentials, NULL, torture->lp_ctx);
+                                    cmdline_credentials, torture->ev, torture->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
@@ -330,7 +330,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
 
        mem_ctx = talloc_init("torture_domain_close_samr");
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
-                                    ctx->cred, NULL, torture->lp_ctx);
+                                    ctx->cred, torture->ev, torture->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
index 15e3f035065d11eeffbb323ff64cf1125925bf8e..6d3e682976f3cceb2c69be68acd6f315d5f1ce9a 100644 (file)
@@ -530,7 +530,8 @@ bool torture_modifyuser(struct torture_context *torture)
 
                ZERO_STRUCT(user_req);
                user_req.in.domain_name = lp_workgroup(torture->lp_ctx);
-               user_req.in.user_name = name;
+               user_req.in.data.user_name = name;
+               user_req.in.level = USER_INFO_BY_NAME;
 
                status = libnet_UserInfo(ctx, torture, &user_req);
                if (!NT_STATUS_IS_OK(status)) {
@@ -642,7 +643,8 @@ bool torture_userinfo_api(struct torture_context *torture)
        ZERO_STRUCT(req);
        
        req.in.domain_name = domain_name.string;
-       req.in.user_name   = name;
+       req.in.data.user_name   = name;
+       req.in.level = USER_INFO_BY_NAME;
 
        status = libnet_UserInfo(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
index efdea7f66ad2a1543ef71c90b81eba6d856b1820..cd1c7b1422eb41b74e23080313fc8c32454cf32a 100644 (file)
@@ -1,10 +1,8 @@
 #################################
 # Start SUBSYSTEM TORTURE_LOCAL
 [MODULE::TORTURE_LOCAL]
-SUBSYSTEM = torture
+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)))
index 34083cd204fd3039886eed17a51a41021aa1595e..017c8568f4fbc91f3d9c745ffddd0ab7c45af117 100644 (file)
@@ -26,7 +26,7 @@
 #include "lib/ldb/include/ldb_errors.h"
 #include "lib/ldb_wrap.h"
 #include "lib/tdb_wrap.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "param/param.h"
 
 float tdb_speed;
@@ -176,7 +176,7 @@ static bool test_ldb_speed(struct torture_context *torture, const void *_data)
 
        torture_comment(torture, "Testing ldb speed for sidmap\n");
 
-       ldb = ldb_wrap_connect(tmp_ctx, torture->lp_ctx, "tdb://test.ldb", 
+       ldb = ldb_wrap_connect(tmp_ctx, torture->ev, torture->lp_ctx, "tdb://test.ldb", 
                                NULL, NULL, LDB_FLG_NOSYNC, NULL);
        if (!ldb) {
                unlink("./test.ldb");
index e4dfadd3d1c8122db2e37ddefe881bfbfaf24ff3..1c3274adcda745368540d12c632ee4b6abfe150c 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/local/proto.h"
 #include "torture/ndr/ndr.h"
 #include "torture/ndr/proto.h"
index 618568acf9ff138c618dc774109381b950571bac..8959232edb6149d8c6f033dbeb0a0c3bb83c3853 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
 #include "system/filesys.h"
 #include "system/time.h"
 #include "pstring.h"
@@ -107,7 +108,8 @@ static struct record *recorded;
 /***************************************************** 
 return a connection to a server
 *******************************************************/
-static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
+static struct smbcli_state *connect_one(struct event_context *ev,
+                                       struct loadparm_context *lp_ctx,
                                        char *share, int snum, int conn)
 {
        struct smbcli_state *c;
@@ -162,7 +164,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
                                                share, NULL,
                                                servers[snum], 
                                                lp_resolve_context(lp_ctx),
-                                               NULL, &options);
+                                               ev, &options);
                if (!NT_STATUS_IS_OK(status)) {
                        sleep(2);
                }
@@ -176,7 +178,8 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
 }
 
 
-static void reconnect(struct loadparm_context *lp_ctx,
+static void reconnect(struct event_context *ev,
+                     struct loadparm_context *lp_ctx,
                      struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
                      char *share[NSERVERS])
 {
@@ -193,7 +196,7 @@ static void reconnect(struct loadparm_context *lp_ctx,
                        }
                        talloc_free(cli[server][conn]);
                }
-               cli[server][conn] = connect_one(lp_ctx, share[server], 
+               cli[server][conn] = connect_one(ev, lp_ctx, share[server], 
                                                server, conn);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
@@ -396,7 +399,9 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
-static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct event_context *ev,
+                     struct loadparm_context *lp_ctx,
+                     char *share[NSERVERS])
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -447,7 +452,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
 #endif
        }
 
-       reconnect(lp_ctx, cli, fnum, share);
+       reconnect(ev, lp_ctx, cli, fnum, share);
        open_files(cli, fnum);
        n = retest(cli, fnum, numops);
 
@@ -465,7 +470,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
                n1 = n;
 
                close_files(cli, fnum);
-               reconnect(lp_ctx, cli, fnum, share);
+               reconnect(ev, lp_ctx, cli, fnum, share);
                open_files(cli, fnum);
 
                for (i=0;i<n-skip;i+=skip) {
@@ -503,7 +508,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
        }
 
        close_files(cli, fnum);
-       reconnect(lp_ctx, cli, fnum, share);
+       reconnect(ev, lp_ctx, cli, fnum, share);
        open_files(cli, fnum);
        showall = true;
        n1 = retest(cli, fnum, n);
@@ -543,6 +548,7 @@ static void usage(poptContext pc)
        int opt;
        int seed, server;
        int username_count=0;
+       struct event_context *ev;
        struct loadparm_context *lp_ctx;
        poptContext pc;
        int argc_new, i;
@@ -631,12 +637,14 @@ static void usage(poptContext pc)
                servers[1] = servers[0];
        }
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(lp_ctx);
 
        DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n", 
                 seed, lock_base, lock_range, min_length));
        srandom(seed);
 
-       return test_locks(lp_ctx, share);
+       return test_locks(ev, lp_ctx, share);
 }
 
index 0fe37253859fea62ab9e23471e5d62b1541c5c2a..1784a0a729490c11668b311dd20c845b2379b914 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "system/passwd.h"
+#include "lib/events/events.h"
 
 static fstring password;
 static fstring username;
@@ -137,7 +138,8 @@ static bool try_unlock(struct smbcli_state *c, int fstype,
 return a connection to a server
 *******************************************************/
 static struct smbcli_state *connect_one(char *share, const char **ports,
-                                       struct smb_options *options)
+                                       struct smb_options *optionsi,
+                                       struct event_context *ev)
 {
        struct smbcli_state *c;
        char *server_n;
@@ -165,7 +167,7 @@ static struct smbcli_state *connect_one(char *share, const char **ports,
 
        nt_status = smbcli_full_connection(NULL, 
                           &c, myname, server_n, ports, share, NULL,
-                          username, lp_workgroup(), password, NULL,
+                          username, lp_workgroup(), password, ev,
                           options);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
@@ -183,6 +185,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                      int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
                      const char **ports,
                      struct smbcli_options *options,
+                     struct event_context *ev,
                      char *share1, char *share2)
 {
        int server, conn, f, fstype;
@@ -201,7 +204,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                        smbcli_ulogoff(cli[server][conn]);
                        talloc_free(cli[server][conn]);
                }
-               cli[server][conn] = connect_one(share[server], ports, options);
+               cli[server][conn] = connect_one(share[server], ports, options, ev);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
                        exit(1);
@@ -347,7 +350,11 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
-static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options)
+static void test_locks(char *share1, char *share2,
+                       char *nfspath1, char *nfspath2,
+                       const char **ports,
+                       struct smbcli_options *options,
+                       struct event_context *ev)
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        char *nfs[NSERVERS];
@@ -376,7 +383,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
                recorded[n].needed = true;
        }
 
-       reconnect(cli, nfs, fnum, ports, options, share1, share2);
+       reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
        open_files(cli, nfs, fnum);
        n = retest(cli, nfs, fnum, numops);
 
@@ -387,7 +394,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
                n1 = n;
 
                close_files(cli, nfs, fnum);
-               reconnect(cli, nfs, fnum, ports, options, share1, share2);
+               reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
                open_files(cli, nfs, fnum);
 
                for (i=0;i<n-1;i++) {
@@ -414,7 +421,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
        }
 
        close_files(cli, nfs, fnum);
-       reconnect(cli, nfs, fnum, ports, options, share1, share2);
+       reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
        open_files(cli, nfs, fnum);
        showall = true;
        n1 = retest(cli, nfs, fnum, n);
@@ -466,6 +473,7 @@ static void usage(void)
        char *p;
        int seed;
        struct loadparm_context *lp_ctx;
+       struct event_context *ev;
 
        setlinebuf(stdout);
 
@@ -542,10 +550,12 @@ static void usage(void)
        DEBUG(0,("seed=%u\n", seed));
        srandom(seed);
 
+       ev = event_context_init(talloc_autofree_context());
+
        locking_init(1);
        lp_smbcli_options(lp_ctx, &options);
        test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx),
-                  &options);
+                  &options, ev);
 
        return(0);
 }
index ac7029aa50df861391f3956ab368d30567d17f79..39b1296dbe0da573afcc2a3e9e6717a90778e527 100644 (file)
@@ -30,6 +30,7 @@
 #include "param/param.h"
 #include "dynconfig.h"
 #include "libcli/resolve/resolve.h"
+#include "lib/events/events.h"
 
 static bool showall = false;
 static bool old_list = false;
@@ -73,6 +74,7 @@ static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name,
 return a connection to a server
 *******************************************************/
 static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx, 
+                                       struct event_context *ev,
                                        char *share, const char **ports,
                                        struct smbcli_options *options)
 {
@@ -92,7 +94,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
                                        server, 
                                        ports,
                                        share, NULL,
-                                       cmdline_credentials, resolve_ctx, NULL,
+                                       cmdline_credentials, resolve_ctx, ev,
                                        options);
 
        if (!NT_STATUS_IS_OK(status)) {
@@ -291,6 +293,7 @@ static void usage(poptContext pc)
        struct smbcli_state *cli;       
        int opt;
        int seed;
+       struct event_context *ev;
        struct loadparm_context *lp_ctx;
        struct smbcli_options options;
        poptContext pc;
@@ -352,11 +355,13 @@ static void usage(poptContext pc)
 
        lp_ctx = cmdline_lp_ctx;
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(lp_ctx);
 
        lp_smbcli_options(lp_ctx, &options);
 
-       cli = connect_one(lp_resolve_context(lp_ctx), share, 
+       cli = connect_one(lp_resolve_context(lp_ctx), ev, share, 
                          lp_smb_ports(lp_ctx), &options);
        if (!cli) {
                DEBUG(0,("Failed to connect to %s\n", share));
index e9bd32cce05eb3549d858ad41c862a6011b60ebf..96144c47735592b5af885c7371ce3e0588e133e5 100644 (file)
@@ -19,9 +19,8 @@
 
 #include "includes.h"
 #include "libcli/libcli.h"
-#include "torture/ui.h"
 #include "torture/util.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "system/filesys.h"
 #include "system/locale.h"
 #include "pstring.h"
index e609e7205513d4208a352e79e134def20ddc8818..a0e7b7d9caea75f670a41526dbc2f581ec2e817e 100644 (file)
@@ -40,7 +40,7 @@ bool torture_nbt_browse(struct torture_context *torture)
        name.scope = NULL;
 
        /* do an initial name resolution to find its IP */
-       status = resolve_name(&name, mem_ctx, &address, NULL);
+       status = resolve_name(&name, mem_ctx, &address, torture->ev);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to resolve %s - %s\n",
                       name.name, nt_errstr(status));
index e1680877e89539826c00d0e56e6cc2e66375b31d..887c6f32ab54b393f1c9cd01653eb731b06231b4 100644 (file)
@@ -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)++;
 }
 
 
@@ -64,15 +67,15 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
 static bool nbt_test_netlogon(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
-       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL
+       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        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,14 +83,14 @@ 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;
 
        /* do an initial name resolution to find its IP */
        torture_assert_ntstatus_ok(tctx, 
-                                  resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+                                  resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
                                   talloc_asprintf(tctx, "Failed to resolve %s", name.name));
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -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;
 }
 
@@ -147,15 +158,15 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
 static bool nbt_test_netlogon2(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
-       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        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;
@@ -170,7 +184,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
 
        /* do an initial name resolution to find its IP */
        torture_assert_ntstatus_ok(tctx, 
-                                  resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+                                  resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
                                   talloc_asprintf(tctx, "Failed to resolve %s", name.name));
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -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_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;
 }
 
 
@@ -257,19 +422,19 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
 static bool nbt_test_ntlogon(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
-       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
                                                                 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;
@@ -283,7 +448,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
 
        /* do an initial name resolution to find its IP */
        torture_assert_ntstatus_ok(tctx, 
-                                  resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)), 
+                                  resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
                                   talloc_asprintf(tctx, "Failed to resolve %s", name.name));
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -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;
 }
 
index 6cb9507398fc87844a643acde7c1d3b77243922a..422261884f661329487333b2c78067995f41302a 100644 (file)
@@ -21,7 +21,7 @@
 #include "libcli/nbt/libnbt.h"
 #include "torture/torture.h"
 #include "torture/nbt/proto.h"
-#include "torture/ui.h"
+#include "torture/smbtorture.h"
 #include "libcli/resolve/resolve.h"
 #include "param/param.h"
 
@@ -34,7 +34,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
 
        /* do an initial name resolution to find its IP */
        torture_assert_ntstatus_ok(tctx, 
-                                  resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, NULL), 
+                                  resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, tctx->ev), 
                                   talloc_asprintf(tctx, 
                                                   "Failed to resolve %s", name->name));
        
index 1ba6172e5ce50db04b6fa4007766a00de76de9d8..3f3a15cca542b53d8871b9f0f948c629e1be8e72 100644 (file)
@@ -47,7 +47,7 @@ static void increment_handler(struct nbt_name_request *req)
 */
 static bool bench_namequery(struct torture_context *tctx)
 {
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
                                                               lp_iconv_convenience(tctx->lp_ctx));
        int num_sent=0;
        struct result_struct *result;
index b9f06c479d0d7b6a2840f34623a1313f85b8eaed..a8681f828f7373e10b20fd5ffb642247f8164a7a 100644 (file)
@@ -44,7 +44,7 @@ static bool nbt_register_own(struct torture_context *tctx)
 {
        struct nbt_name_register io;
        NTSTATUS status;
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
                                                               lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *socket_address;
        struct nbt_name name;
@@ -114,7 +114,7 @@ static bool nbt_refresh_own(struct torture_context *tctx)
 {
        struct nbt_name_refresh io;
        NTSTATUS status;
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
                                                               lp_iconv_convenience(tctx->lp_ctx));
        const char *myaddress;
        struct socket_address *socket_address;
index 059b2dc91922daa01da3515ffea7b669aac60609..ae20de6e2f59244ea62f89e880f9627de834169d 100644 (file)
@@ -53,7 +53,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
        struct nbt_name_refresh_wins refresh;
        struct nbt_name_release release;
        NTSTATUS status;
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        const char *myaddress;
        struct socket_address *socket_address;
        struct interface *ifaces;
index ea4abaf21b5a11c773d422825c3f6e14ca0e067e..a0d90fb65333608f823a0cbd27d0c633f1de7c71 100644 (file)
@@ -225,7 +225,7 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state
 */
 static bool bench_wins(struct torture_context *tctx)
 {
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        int num_sent=0;
        struct timeval tv = timeval_current();
        bool ret = true;
index 470eee831003d9c20e66070ab2e530882e5d1977..ee7a1510d5b7347630390f517c5bfe5fdf4dc5c2 100644 (file)
@@ -103,8 +103,8 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
 
        torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
 
-       wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
-       wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket1 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
 
        torture_comment(tctx, "Setup 2 wrepl connections\n");
        status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -186,7 +186,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
 
        torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
 
-       wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -255,7 +255,7 @@ static bool test_wins_replication(struct torture_context *tctx)
 
        torture_comment(tctx, "Test one pull replication cycle\n");
 
-       wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -553,7 +553,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        if (!ctx) return NULL;
 
        ctx->address    = address;
-       ctx->pull       = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->pull       = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->pull) return NULL;
 
        torture_comment(tctx, "Setup wrepl conflict pull connection\n");
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
 
        talloc_free(pull_table.out.partners);
 
-       ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->nbtsock = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->nbtsock) return NULL;
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
        if (!NT_STATUS_IS_OK(status)) return NULL;
 
-       ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->nbtsock_srv = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->nbtsock_srv) return NULL;
 
        /* Make a port 137 version of ctx->myaddr */
@@ -645,7 +645,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        }
 
        if (ctx->myaddr2 && ctx->nbtsock_srv) {
-               ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+               ctx->nbtsock2 = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
                if (!ctx->nbtsock2) return NULL;
 
                status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
@@ -722,7 +722,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
        uint32_t assoc_ctx;
        NTSTATUS status;
 
-       wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
 
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
index 55b00d1fb80150496aacc81dbd1d6596eadd0ffc..63636f8c5f7856fead65b525a6d8b97a2b454d75 100644 (file)
@@ -21,7 +21,7 @@
 #include "includes.h"
 #include "torture/ndr/ndr.h"
 #include "torture/ndr/proto.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
 #include "util/dlinklist.h"
 #include "param/param.h"
 
index 4b5f4b582c581eb3a18d32db47d2b9092d503962..1ccd1254dddc4f996777029867659fdd9b92d4ed 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "libcli/libcli.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/util.h"
 #include "libcli/rap/rap.h"
 #include "libcli/raw/libcliraw.h"
index 1f31fbc51528e7530966b48164a6adc69d0a1098..d73ac1327e1b80c6556a7d7613846cb4b41688e5 100644 (file)
@@ -296,7 +296,7 @@ static bool test_appendacl(struct smbcli_state *cli, struct torture_context *tct
                c[i]->async.private_data = count;
        }
 
-       event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+       event_ctx = tctx->ev;
        printf("waiting for completion\n");
        while (*count != num_ops) {
                event_loop_once(event_ctx);
@@ -354,7 +354,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
 
        printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
 
-       event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+       event_ctx = tctx->ev;
        c = talloc_array(tctx, struct composite_context *, torture_numops);
 
        for (i=0; i<torture_numops; i++) {
index 86030c538abc3aff66ff4852d8bda88c4b45248e..21541d003b18eb9ad4ee13b496199eeb8881e8f7 100644 (file)
@@ -316,7 +316,6 @@ bool torture_bench_lock(struct torture_context *torture)
        int i;
        int timelimit = torture_setting_int(torture, "timelimit", 10);
        struct timeval tv;
-       struct event_context *ev = event_context_find(mem_ctx);
        struct benchlock_state *state;
        int total = 0, minops=0;
        struct smbcli_state *cli;
@@ -333,8 +332,8 @@ bool torture_bench_lock(struct torture_context *torture)
                state[i].tctx = torture;
                state[i].mem_ctx = talloc_new(state);
                state[i].client_num = i;
-               state[i].ev = ev;
-               if (!torture_open_connection_ev(&cli, i, torture, ev)) {
+               state[i].ev = torture->ev;
+               if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
                        return false;
                }
                talloc_steal(mem_ctx, state);
@@ -375,12 +374,12 @@ bool torture_bench_lock(struct torture_context *torture)
        tv = timeval_current(); 
 
        if (progress) {
-               event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state);
+               event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
        }
 
        printf("Running for %d seconds\n", timelimit);
        while (timeval_elapsed(&tv) < timelimit) {
-               event_loop_once(ev);
+               event_loop_once(torture->ev);
 
                if (lock_failed) {
                        DEBUG(0,("locking failed\n"));
diff --git a/source/torture/raw/lookuprate.c b/source/torture/raw/lookuprate.c
new file mode 100644 (file)
index 0000000..782cb1b
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+   File lookup rate test.
+
+   Copyright (C) James Peach 2006
+
+   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 "param/param.h"
+#include "system/filesys.h"
+#include "torture/smbtorture.h"
+#include "torture/basic/proto.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+
+#define BASEDIR "\\lookuprate"
+#define MISSINGNAME BASEDIR "\\foo"
+
+#define FUZZ_PERCENT 10
+
+#define usec_to_sec(s) ((s) / 1000000)
+#define sec_to_usec(s) ((s) * 1000000)
+
+struct rate_record
+{
+    unsigned   dirent_count;
+    unsigned   querypath_persec;
+    unsigned   findfirst_persec;
+};
+
+static struct rate_record records[] =
+{
+    { 0, 0, 0 },       /* Base (optimal) lookup rate. */
+    { 100, 0, 0},
+    { 1000, 0, 0},
+    { 10000, 0, 0},
+    { 100000, 0, 0}
+};
+
+typedef NTSTATUS lookup_function(struct smbcli_tree *tree, const char * path);
+
+/* Test whether rhs is within fuzz% of lhs. */
+static bool fuzzily_equal(unsigned lhs, unsigned rhs, int percent)
+{
+       double fuzz = (double)lhs * (double)percent/100.0;
+
+       if (((double)rhs >= ((double)lhs - fuzz)) &&
+           ((double)rhs <= ((double)lhs + fuzz))) {
+               return true;
+       }
+
+       return false;
+
+}
+
+static NTSTATUS fill_directory(struct smbcli_tree *tree,
+           const char * path, unsigned count)
+{
+       NTSTATUS        status;
+       char            *fname = NULL;
+       unsigned        i;
+       unsigned        current;
+
+       struct timeval start;
+       struct timeval now;
+
+       status = smbcli_mkdir(tree, path);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       printf("filling directory %s with %u files... ", path, count);
+       fflush(stdout);
+
+       current = random();
+       start = timeval_current();
+
+       for (i = 0; i < count; ++i) {
+               int fnum;
+
+               ++current;
+               fname = talloc_asprintf(NULL, "%s\\fill%u",
+                                   path, current);
+
+               fnum = smbcli_open(tree, fname, O_RDONLY|O_CREAT,
+                               OPENX_MODE_DENY_NONE);
+               if (fnum < 0) {
+                       talloc_free(fname);
+                       return smbcli_nt_error(tree);
+               }
+
+               smbcli_close(tree, fnum);
+               talloc_free(fname);
+       }
+
+       if (count) {
+               double rate;
+               now = timeval_current();
+               rate = (double)count / usec_to_sec((double)usec_time_diff(&now, &start));
+               printf("%u/sec\n", (unsigned)rate);
+       } else {
+               printf("done\n");
+       }
+
+       return NT_STATUS_OK;
+}
+
+static NTSTATUS squash_lookup_error(NTSTATUS status)
+{
+       if (NT_STATUS_IS_OK(status)) {
+               return NT_STATUS_OK;
+       }
+
+       /* We don't care if the file isn't there. */
+       if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+               return NT_STATUS_OK;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+               return NT_STATUS_OK;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) {
+               return NT_STATUS_OK;
+       }
+
+       return status;
+}
+
+/* Look up a pathname using TRANS2_QUERY_PATH_INFORMATION. */
+static NTSTATUS querypath_lookup(struct smbcli_tree *tree, const char * path)
+{
+       NTSTATUS        status;
+       time_t          ftimes[3];
+       size_t          fsize;
+       uint16_t        fmode;
+
+       status = smbcli_qpathinfo(tree, path, &ftimes[0], &ftimes[1], &ftimes[2],
+                       &fsize, &fmode);
+
+       return squash_lookup_error(status);
+}
+
+/* Look up a pathname using TRANS2_FIND_FIRST2. */
+static NTSTATUS findfirst_lookup(struct smbcli_tree *tree, const char * path)
+{
+       NTSTATUS status = NT_STATUS_OK;
+
+       if (smbcli_list(tree, path, 0, NULL, NULL) < 0) {
+               status = smbcli_nt_error(tree);
+       }
+
+       return squash_lookup_error(status);
+}
+
+static NTSTATUS lookup_rate_convert(struct smbcli_tree *tree,
+       lookup_function lookup, const char * path, unsigned * rate)
+{
+       NTSTATUS        status;
+
+       struct timeval  start;
+       struct timeval  now;
+       unsigned        count = 0;
+       int64_t         elapsed = 0;
+
+#define LOOKUP_PERIOD_SEC (2)
+
+       start = timeval_current();
+       while (elapsed < sec_to_usec(LOOKUP_PERIOD_SEC)) {
+
+               status = lookup(tree, path);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+
+               ++count;
+               now = timeval_current();
+               elapsed = usec_time_diff(&now, &start);
+       }
+
+#undef LOOKUP_PERIOD_SEC
+
+       *rate = (unsigned)((double)count / (double)usec_to_sec(elapsed));
+       return NT_STATUS_OK;
+}
+
+static bool remove_working_directory(struct smbcli_tree *tree,
+               const char * path)
+{
+       int tries;
+
+       /* Using smbcli_deltree to delete a very large number of files
+        * doesn't work against all servers. Work around this by
+        * retrying.
+        */
+       for (tries = 0; tries < 5; ) {
+               int ret;
+
+               ret = smbcli_deltree(tree, BASEDIR);
+               if (ret == -1) {
+                       tries++;
+                       printf("(%s) failed to deltree %s: %s\n",
+                               __location__, BASEDIR,
+                               smbcli_errstr(tree));
+                       continue;
+               }
+
+               return true;
+       }
+
+       return false;
+
+}
+
+/* Verify that looking up a file name takes constant time.
+ *
+ * This test samples the lookup rate for a non-existant filename in a
+ * directory, while varying the number of files in the directory. The
+ * lookup rate should continue to approximate the lookup rate for the
+ * empty directory case.
+ */
+bool torture_bench_lookup(struct torture_context *torture)
+{
+       NTSTATUS        status;
+       bool            result = false;
+
+       int i, tries;
+       struct smbcli_state *cli = NULL;
+
+       if (!torture_open_connection(&cli, torture, 0)) {
+               goto done;
+       }
+
+       remove_working_directory(cli->tree, BASEDIR);
+
+       for (i = 0; i < ARRAY_SIZE(records); ++i) {
+               printf("testing lookup rate with %u directory entries\n",
+                               records[i].dirent_count);
+
+               status = fill_directory(cli->tree, BASEDIR,
+                               records[i].dirent_count);
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("failed to fill directory: %s\n", nt_errstr(status));
+                       goto done;
+               }
+
+               status = lookup_rate_convert(cli->tree, querypath_lookup,
+                       MISSINGNAME, &records[i].querypath_persec);
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("querypathinfo of %s failed: %s\n",
+                               MISSINGNAME, nt_errstr(status));
+                       goto done;
+               }
+
+               status = lookup_rate_convert(cli->tree, findfirst_lookup,
+                       MISSINGNAME, &records[i].findfirst_persec);
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("findfirst of %s failed: %s\n",
+                               MISSINGNAME, nt_errstr(status));
+                       goto done;
+               }
+
+               printf("entries = %u, querypath = %u/sec, findfirst = %u/sec\n",
+                               records[i].dirent_count,
+                               records[i].querypath_persec,
+                               records[i].findfirst_persec);
+
+               if (!remove_working_directory(cli->tree, BASEDIR)) {
+                       goto done;
+               }
+       }
+
+       /* Ok. We have run all our tests. Walk through the records we
+        * accumulated and figure out whether the lookups took constant
+        * time of not.
+        */
+       for (i = 0; i < ARRAY_SIZE(records); ++i) {
+               if (!fuzzily_equal(records[0].querypath_persec,
+                                   records[i].querypath_persec,
+                                   FUZZ_PERCENT)) {
+                       printf("querypath rate for %d entries differed by "
+                               "more than %d%% from base rate\n",
+                               records[i].dirent_count, FUZZ_PERCENT);
+                       result = false;
+               }
+
+               if (!fuzzily_equal(records[0].findfirst_persec,
+                                   records[i].findfirst_persec,
+                                   FUZZ_PERCENT)) {
+                       printf("findfirst rate for %d entries differed by "
+                               "more than %d%% from base rate\n",
+                               records[i].dirent_count, FUZZ_PERCENT);
+                       result = false;
+               }
+       }
+
+done:
+       if (cli) {
+               remove_working_directory(cli->tree, BASEDIR);
+               talloc_free(cli);
+       }
+
+       return result;
+}
+
+/* vim: set sts=8 sw=8 : */
index 1340692faa741c2258535d4db646a17aaca8e10e..9c66c3be9c955b2b62cfc51afc99a60d619b90a5 100644 (file)
@@ -389,7 +389,6 @@ bool torture_test_offline(struct torture_context *torture)
        int i;
        int timelimit = torture_setting_int(torture, "timelimit", 10);
        struct timeval tv;
-       struct event_context *ev = event_context_find(mem_ctx);
        struct offline_state *state;
        struct smbcli_state *cli;
        bool progress;
@@ -404,8 +403,8 @@ bool torture_test_offline(struct torture_context *torture)
        for (i=0;i<nconnections;i++) {
                state[i].tctx = torture;
                state[i].mem_ctx = talloc_new(state);
-               state[i].ev = ev;
-               if (!torture_open_connection_ev(&cli, i, torture, ev)) {
+               state[i].ev = torture->ev;
+               if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
                        return false;
                }
                state[i].tree = cli->tree;
@@ -418,7 +417,7 @@ bool torture_test_offline(struct torture_context *torture)
        for (i=nconnections;i<numstates;i++) {
                state[i].tctx = torture;
                state[i].mem_ctx = talloc_new(state);
-               state[i].ev = ev;
+               state[i].ev = torture->ev;
                state[i].tree = state[i % nconnections].tree;
                state[i].client = i;
        }
@@ -468,12 +467,12 @@ bool torture_test_offline(struct torture_context *torture)
        tv = timeval_current(); 
 
        if (progress) {
-               event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state);
+               event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
        }
 
        printf("Running for %d seconds\n", timelimit);
        while (timeval_elapsed(&tv) < timelimit) {
-               event_loop_once(ev);
+               event_loop_once(torture->ev);
 
                if (test_failed) {
                        DEBUG(0,("test failed\n"));
@@ -487,7 +486,7 @@ bool torture_test_offline(struct torture_context *torture)
                while (state[i].loadfile || 
                       state[i].savefile ||
                       state[i].req) {
-                       event_loop_once(ev);
+                       event_loop_once(torture->ev);
                }
        }       
 
index d28a8bd14eb562726fddec07c7736b6f97ebe495..c6ba0d2571f361e0943471018c266261b794b7b2 100644 (file)
@@ -1350,21 +1350,19 @@ static bool test_raw_open_multi(struct torture_context *tctx)
        const char *host = torture_setting_string(tctx, "host", NULL);
        const char *share = torture_setting_string(tctx, "share", NULL);
        int i, num_files = 3;
-       struct event_context *ev;
        int num_ok = 0;
        int num_collision = 0;
        
-       ev = cli_credentials_get_event_context(cmdline_credentials);
        clients = talloc_array(mem_ctx, struct smbcli_state *, num_files);
        requests = talloc_array(mem_ctx, struct smbcli_request *, num_files);
        ios = talloc_array(mem_ctx, union smb_open, num_files);
-       if ((ev == NULL) || (clients == NULL) || (requests == NULL) ||
+       if ((tctx->ev == NULL) || (clients == NULL) || (requests == NULL) ||
            (ios == NULL)) {
                DEBUG(0, ("talloc failed\n"));
                return false;
        }
 
-       if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, ev)) {
+       if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, tctx->ev)) {
                return false;
        }
 
@@ -1372,7 +1370,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
 
        for (i=0; i<num_files; i++) {
                if (!torture_open_connection_share(mem_ctx, &(clients[i]),
-                                                  tctx, host, share, ev)) {
+                                                  tctx, host, share, tctx->ev)) {
                        DEBUG(0, ("Could not open %d'th connection\n", i));
                        return false;
                }
@@ -1441,7 +1439,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
                        break;
                }
 
-               if (event_loop_once(ev) != 0) {
+               if (event_loop_once(tctx->ev) != 0) {
                        DEBUG(0, ("event_loop_once failed\n"));
                        return false;
                }
index a5b1434a47417e2a2f27771493ec982ee2ca4b9b..26b862c33f1d1255387ab0fae2e27049e6dcee75 100644 (file)
@@ -369,7 +369,6 @@ bool torture_bench_open(struct torture_context *torture)
        int i;
        int timelimit = torture_setting_int(torture, "timelimit", 10);
        struct timeval tv;
-       struct event_context *ev = event_context_find(mem_ctx);
        struct benchopen_state *state;
        int total = 0;
        int total_retries = 0;
@@ -387,8 +386,8 @@ bool torture_bench_open(struct torture_context *torture)
                state[i].tctx = torture;
                state[i].mem_ctx = talloc_new(state);
                state[i].client_num = i;
-               state[i].ev = ev;
-               if (!torture_open_connection_ev(&state[i].cli, i, torture, ev)) {
+               state[i].ev = torture->ev;
+               if (!torture_open_connection_ev(&state[i].cli, i, torture, torture->ev)) {
                        return false;
                }
                talloc_steal(mem_ctx, state);
@@ -428,13 +427,13 @@ bool torture_bench_open(struct torture_context *torture)
        tv = timeval_current(); 
 
        if (progress) {
-               report_te = event_add_timed(ev, state, timeval_current_ofs(1, 0), 
+               report_te = event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), 
                                            report_rate, state);
        }
 
        printf("Running for %d seconds\n", timelimit);
        while (timeval_elapsed(&tv) < timelimit) {
-               event_loop_once(ev);
+               event_loop_once(torture->ev);
 
                if (open_failed) {
                        DEBUG(0,("open failed\n"));
index 1927a0f027df77b3697275faf3ce426ec78fb296..fd8d292980aa48c13eaf735440b1c7bfa31e2560 100644 (file)
@@ -2841,13 +2841,12 @@ bool torture_bench_oplock(struct torture_context *torture)
        int timelimit = torture_setting_int(torture, "timelimit", 10);
        union smb_open io;
        struct timeval tv;
-       struct event_context *ev = event_context_find(mem_ctx);
 
        cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs);
 
        torture_comment(torture, "Opening %d connections\n", torture_nprocs);
        for (i=0;i<torture_nprocs;i++) {
-               if (!torture_open_connection_ev(&cli[i], i, torture, ev)) {
+               if (!torture_open_connection_ev(&cli[i], i, torture, torture->ev)) {
                        return false;
                }
                talloc_steal(mem_ctx, cli[i]);
index bb3dde728fd44338d67e212b30d26b6abeb83cf2..0a7fc3ebfd8c3f5dfdc175973d86ba4bd58a732b 100644 (file)
 */
 
 #include "includes.h"
-#include "torture/torture.h"
 #include "libcli/raw/libcliraw.h"
-#include "torture/raw/proto.h"
 #include "torture/util.h"
+#include "torture/smbtorture.h"
+#include "torture/raw/proto.h"
 
 NTSTATUS torture_raw_init(void)
 {
@@ -33,6 +33,10 @@ NTSTATUS torture_raw_init(void)
        torture_suite_add_simple_test(suite, "PING-PONG", torture_ping_pong);
        torture_suite_add_simple_test(suite, "BENCH-LOCK", torture_bench_lock);
        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);
index 814b5f57f43bdebf1812e297d22299f2b5c1a775..1f1501045c1aab72157cfb4e860999f38db486b0 100644 (file)
@@ -136,7 +136,7 @@ bool torture_samba3_hide(struct torture_context *torture)
 
        if (!torture_open_connection_share(
                    torture, &cli, torture, torture_setting_string(torture, "host", NULL),
-                   torture_setting_string(torture, "share", NULL), NULL)) {
+                   torture_setting_string(torture, "share", NULL), torture->ev)) {
                d_printf("torture_open_connection_share failed\n");
                return false;
        }
index 15a7f6c4a32cbbe6a3bc11af774809600b0b0a91..27b4d42dd808937772dc28165314bcabbbbc896f 100644 (file)
@@ -56,7 +56,7 @@ bool torture_samba3_checkfsp(struct torture_context *torture)
 
        if (!torture_open_connection_share(
                    torture, &cli, torture, torture_setting_string(torture, "host", NULL),
-                   torture_setting_string(torture, "share", NULL), NULL)) {
+                   torture_setting_string(torture, "share", NULL), torture->ev)) {
                d_printf("torture_open_connection_share failed\n");
                ret = false;
                goto done;
index 1dab36c28b23b558a0cc918e43f4b98f24c6bc28..8b2d327653a720daeca108c1eda0cf145dc03b57 100644 (file)
@@ -135,6 +135,11 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
                goto fail;
        }
 
+       if (num_exp == 0) {
+               ret = true;
+               goto fail;
+       }
+
        exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp));
 
        if (exp_sort == NULL) {
@@ -170,7 +175,81 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
 }
 
 /*
-  test basic io on streams
+  test bahavior of streams on directories
+*/
+static bool test_stream_dir(struct torture_context *tctx,
+                          struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+{
+       NTSTATUS status;
+       union smb_open io;
+       const char *fname = BASEDIR "\\stream.txt";
+       const char *sname1;
+       bool ret = true;
+       const char *basedir_data;
+
+       basedir_data = talloc_asprintf(mem_ctx, "%s::$DATA", BASEDIR);
+       sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
+
+       printf("(%s) opening non-existant directory stream\n", __location__);
+       io.generic.level = RAW_OPEN_NTCREATEX;
+       io.ntcreatex.in.root_fid = 0;
+       io.ntcreatex.in.flags = 0;
+       io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+       io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+       io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+       io.ntcreatex.in.share_access = 0;
+       io.ntcreatex.in.alloc_size = 0;
+       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+       io.ntcreatex.in.security_flags = 0;
+       io.ntcreatex.in.fname = sname1;
+       status = smb_raw_open(cli->tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+       printf("(%s) opening basedir  stream\n", __location__);
+       io.generic.level = RAW_OPEN_NTCREATEX;
+       io.ntcreatex.in.root_fid = 0;
+       io.ntcreatex.in.flags = 0;
+       io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+       io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+       io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+       io.ntcreatex.in.share_access = 0;
+       io.ntcreatex.in.alloc_size = 0;
+       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+       io.ntcreatex.in.security_flags = 0;
+       io.ntcreatex.in.fname = basedir_data;
+       status = smb_raw_open(cli->tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+       printf("(%s) opening basedir ::$DATA stream\n", __location__);
+       io.generic.level = RAW_OPEN_NTCREATEX;
+       io.ntcreatex.in.root_fid = 0;
+       io.ntcreatex.in.flags = 0x10;
+       io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+       io.ntcreatex.in.create_options = 0;
+       io.ntcreatex.in.file_attr = 0;
+       io.ntcreatex.in.share_access = 0;
+       io.ntcreatex.in.alloc_size = 0;
+       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+       io.ntcreatex.in.security_flags = 0;
+       io.ntcreatex.in.fname = basedir_data;
+       status = smb_raw_open(cli->tree, mem_ctx, &io);
+       if (torture_setting_bool(tctx, "samba3", false)) {
+               CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+       } else {
+               CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
+       }
+
+       printf("(%s) list the streams on the basedir\n", __location__);
+       ret &= check_stream_list(cli, BASEDIR, 0, NULL);
+done:
+       return ret;
+}
+
+/*
+  test basic behavior of streams on directories
 */
 static bool test_stream_io(struct torture_context *tctx,
                           struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
@@ -191,12 +270,12 @@ static bool test_stream_io(struct torture_context *tctx,
        sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
        sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream");
 
-       printf("(%s) opening non-existant directory stream\n", __location__);
+       printf("(%s) creating a stream on a non-existant file\n", __location__);
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid = 0;
        io.ntcreatex.in.flags = 0;
        io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
-       io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+       io.ntcreatex.in.create_options = 0;
        io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
        io.ntcreatex.in.share_access = 0;
        io.ntcreatex.in.alloc_size = 0;
@@ -205,12 +284,6 @@ static bool test_stream_io(struct torture_context *tctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = sname1;
        status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
-
-       printf("(%s) creating a stream on a non-existant file\n", __location__);
-       io.ntcreatex.in.create_options = 0;
-       io.ntcreatex.in.fname = sname1;
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
        fnum = io.ntcreatex.out.file.fnum;
 
@@ -423,7 +496,7 @@ static bool test_stream_delete(struct torture_context *tctx,
 
        sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
 
-       printf("(%s) opening non-existant directory stream\n", __location__);
+       printf("(%s) opening non-existant file stream\n", __location__);
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid = 0;
        io.ntcreatex.in.flags = 0;
@@ -559,6 +632,8 @@ bool torture_raw_streams(struct torture_context *torture,
                return false;
        }
 
+       ret &= test_stream_dir(torture, cli, torture);
+       smb_raw_exit(cli->session);
        ret &= test_stream_io(torture, cli, torture);
        smb_raw_exit(cli->session);
        ret &= test_stream_sharemodes(torture, cli, torture);
diff --git a/source/torture/raw/tconrate.c b/source/torture/raw/tconrate.c
new file mode 100644 (file)
index 0000000..6f0ba0d
--- /dev/null
@@ -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 : */
index 1ca3c62df0af87b881213a78f70ed2c2889f252d..0ebbef1ce6fd44f03fe915c4b7abe95c2f0e9c4c 100644 (file)
@@ -39,7 +39,6 @@ bool torture_async_bind(struct torture_context *torture)
 {
        NTSTATUS status;
        TALLOC_CTX *mem_ctx;
-       struct event_context *evt_ctx;
        int i;
        const char *binding_string;
        struct cli_credentials *creds;
@@ -70,15 +69,11 @@ bool torture_async_bind(struct torture_context *torture)
        /* credentials */
        creds = cmdline_credentials;
 
-       /* event context */
-       evt_ctx = cli_credentials_get_event_context(creds);
-       if (evt_ctx == NULL) return false;
-
        /* send bind requests */
        for (i = 0; i < torture_numasync; i++) {
                table[i] = &ndr_table_lsarpc;
                bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
-                                                      table[i], creds, evt_ctx, torture->lp_ctx);
+                                                      table[i], creds, torture->ev, torture->lp_ctx);
        }
 
        /* recv bind requests */
index 56564769229e210053192cdd4370125731e9168c..1c81766ebe31a5db73e713e9fb954d836619985b 100644 (file)
@@ -124,7 +124,7 @@ static bool test_CreateDir(TALLOC_CTX *mem_ctx,
 {
        printf("Creating directory %s\n", dir);
 
-       if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, NULL)) {
+       if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, tctx->ev)) {
                return false;
        }
 
@@ -494,7 +494,7 @@ static void test_cleanup_stdroot(struct dcerpc_pipe *p,
 
        test_RemoveStdRoot(p, mem_ctx, host, sharename);
        test_NetShareDel(mem_ctx, tctx, host, sharename);
-       torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", NULL);
+       torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", tctx->ev);
        test_DeleteDir(cli, dir);
        torture_close_connection(cli);
 }
index b28e429a75746c4a0b590c25c127070de3cf532e..989a1faf27bd0ca56a498e45b4d3f69425dcd117 100644 (file)
@@ -178,12 +178,11 @@ static bool _test_DsBind(struct torture_context *tctx,
 {
        NTSTATUS status;
        bool ret = true;
-       struct event_context *event = NULL;
 
        status = dcerpc_pipe_connect_b(ctx,
                                       &b->pipe, ctx->drsuapi_binding, 
                                       &ndr_table_drsuapi,
-                                      credentials, event, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -254,10 +253,11 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
        struct drsuapi_DsCrackNames r;
        struct drsuapi_DsNameString names[1];
        bool ret = true;
-
-       struct cldap_socket *cldap = cldap_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        struct cldap_netlogon search;
-       
+
+       cldap = cldap_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        r.in.bind_handle                = &ctx->admin.drsuapi.bind_handle;
        r.in.level                      = 1;
        r.in.req.req1.codepage          = 1252; /* western european */
@@ -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;
index 849b9fd1e99904c243a74b2ddee693901f8c10e5..cd5eb32fa8196b6442df46a70709a5eb73f10553 100644 (file)
@@ -39,7 +39,7 @@ bool torture_rpc_join(struct torture_context *torture)
                                        "IPC$", NULL,
                                        machine_account,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
                          TORTURE_NETBIOS_NAME));
@@ -65,7 +65,7 @@ bool torture_rpc_join(struct torture_context *torture)
                                        "IPC$", NULL,
                                        machine_account,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
                          TORTURE_NETBIOS_NAME));
index 6e38d0465a413d904e8aa7d83df75b647eef5216..acc1220ccc94484fcef6b6748bb360434e6f9dc8 100644 (file)
@@ -23,7 +23,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "librpc/rpc/dcerpc.h"
 #include "torture/rpc/rpc.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "librpc/ndr/ndr_table.h"
 #include "lib/util/dlinklist.h"
 
@@ -83,7 +83,7 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
 
        status = dcerpc_pipe_connect_b(tctx, 
                                     p, binding, table,
-                                    cmdline_credentials, NULL, tctx->lp_ctx);
+                                    cmdline_credentials, tctx->ev, tctx->lp_ctx);
  
        if (NT_STATUS_IS_ERR(status)) {
                printf("Failed to connect to remote server: %s %s\n", 
@@ -113,7 +113,7 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
        binding->assoc_group_id = assoc_group_id;
 
        status = dcerpc_pipe_connect_b(tctx, p, binding, table,
-                                      cmdline_credentials, NULL, tctx->lp_ctx);
+                                      cmdline_credentials, tctx->ev, tctx->lp_ctx);
                                           
        if (NT_STATUS_IS_ERR(status)) {
                *p = NULL;
@@ -147,7 +147,7 @@ static bool torture_rpc_setup_machine(struct torture_context *tctx,
                                &(tcase_data->pipe),
                                binding,
                                tcase->table,
-                               tcase_data->credentials, NULL, tctx->lp_ctx);
+                               tcase_data->credentials, tctx->ev, tctx->lp_ctx);
 
        torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
 
@@ -205,7 +205,7 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
                                &(tcase_data->pipe),
                                binding,
                                tcase->table,
-                               tcase_data->credentials, NULL, tctx->lp_ctx);
+                               tcase_data->credentials, tctx->ev, tctx->lp_ctx);
 
        torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
 
@@ -399,6 +399,7 @@ NTSTATUS torture_rpc_init(void)
        torture_suite_add_simple_test(suite, "SAMSYNC", torture_rpc_samsync);
        torture_suite_add_simple_test(suite, "SCHANNEL", torture_rpc_schannel);
        torture_suite_add_simple_test(suite, "SCHANNEL2", torture_rpc_schannel2);
+       torture_suite_add_simple_test(suite, "BENCH-SCHANNEL1", torture_rpc_schannel_bench1);
        torture_suite_add_suite(suite, torture_rpc_srvsvc(suite));
        torture_suite_add_suite(suite, torture_rpc_svcctl(suite));
        torture_suite_add_suite(suite, torture_rpc_samr_accessmask(suite));
index d0a07277877887ab10703f2e3f6a49ec504c9fba..48db814b7a375ab56cd630843d3450bffdeb5088 100644 (file)
@@ -28,7 +28,7 @@
 #include "librpc/rpc/dcerpc.h"
 #include "libcli/raw/libcliraw.h"
 #include "torture/rpc/proto.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
 
 struct torture_rpc_tcase {
        struct torture_tcase tcase;
index 8eb1f54b4fd3d3bd9223e36e907a4660f108c4fd..17342f9b867eeb2493bb41cb1be3559227b1267a 100644 (file)
@@ -89,7 +89,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -303,7 +303,7 @@ bool torture_bind_samba3(struct torture_context *torture)
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -426,7 +426,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
                           "builtin") ? 1:0;
 
        l.in.connect_handle = &conn_handle;
-       domain_name.string = enumdom.out.sam->entries[0].name.string;
+       domain_name.string = enumdom.out.sam->entries[dom_idx].name.string;
        *domain = talloc_strdup(mem_ctx, domain_name.string);
        l.in.domain_name = &domain_name;
 
@@ -1220,7 +1220,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, anon_creds, 
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1307,7 +1307,7 @@ static bool test_join3(struct torture_context *tctx,
                                        lp_smb_ports(tctx->lp_ctx),
                                        "IPC$", NULL, smb_creds, 
                                        lp_resolve_context(tctx->lp_ctx),
-                                       NULL, &options);
+                                       tctx->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1682,7 +1682,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, cmdline_credentials, 
                lp_resolve_context(torture->lp_ctx),
-               NULL, &options);
+               torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1709,7 +1709,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, anon_creds, 
                lp_resolve_context(torture->lp_ctx),
-               NULL, &options);
+               torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) anon smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1924,7 +1924,7 @@ bool torture_samba3_rpc_srvsvc(struct torture_context *torture)
 
        if (!(torture_open_connection_share(
                      mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
-                     "IPC$", NULL))) {
+                     "IPC$", torture->ev))) {
                talloc_free(mem_ctx);
                return false;
        }
@@ -1986,7 +1986,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
        if (!(torture_open_connection_share(
                      mem_ctx, &cli,
                      torture, torture_setting_string(torture, "host", NULL),
-                     "IPC$", NULL))) {
+                     "IPC$", torture->ev))) {
                d_printf("IPC$ connection failed\n");
                goto done;
        }
@@ -2281,7 +2281,7 @@ bool torture_samba3_rpc_sharesec(struct torture_context *torture)
 
        if (!(torture_open_connection_share(
                      mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
-                     "IPC$", NULL))) {
+                     "IPC$", torture->ev))) {
                d_printf("IPC$ connection failed\n");
                talloc_free(mem_ctx);
                return false;
@@ -2329,7 +2329,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture)
 
        if (!(torture_open_connection_share(
                      mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
-                     "IPC$", NULL))) {
+                     "IPC$", torture->ev))) {
                d_printf("IPC$ connection failed\n");
                talloc_free(mem_ctx);
                return false;
@@ -2611,7 +2611,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture)
 
        if (!(torture_open_connection_share(
                      mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
-                     "IPC$", NULL))) {
+                     "IPC$", torture->ev))) {
                d_printf("IPC$ connection failed\n");
                talloc_free(mem_ctx);
                return false;
@@ -2797,7 +2797,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture)
 
        if (!(torture_open_connection_share(
                      mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
-                     "IPC$", NULL))) {
+                     "IPC$", torture->ev))) {
                d_printf("IPC$ connection failed\n");
                talloc_free(mem_ctx);
                return false;
index 24b2511bc75e98e77f1ce021ada80e327f6ee2d3..ab3283a952e05c597bdca4d36d8c9329c1514efb 100644 (file)
@@ -1602,7 +1602,7 @@ bool torture_rpc_samlogon(struct torture_context *torture)
 
        status = dcerpc_pipe_connect_b(mem_ctx, &p, b, 
                                       &ndr_table_netlogon,
-                                      machine_credentials, NULL, torture->lp_ctx);
+                                      machine_credentials, torture->ev, torture->lp_ctx);
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
index 3b152d92aa739ad083f22b0bc152ddff828747b1..9705f7b0de81d50b1478d47df972838027ac1abb 100644 (file)
@@ -1560,7 +1560,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
        status = dcerpc_pipe_connect_b(samsync_state,
                                       &samsync_state->p, b, 
                                           &ndr_table_netlogon,
-                                      credentials, NULL, torture->lp_ctx);
+                                      credentials, torture->ev, torture->lp_ctx);
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1598,7 +1598,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
                                       &samsync_state->p_netlogon_wksta, 
                                       b_netlogon_wksta, 
                                           &ndr_table_netlogon,
-                                      credentials_wksta, NULL, torture->lp_ctx);
+                                      credentials_wksta, torture->ev, torture->lp_ctx);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
index 19b871f9c092bb08639ab69ba94e7cdd76f86c4e..a8f70b2ea909d0ff4af57ecc58efad51630cc015 100644 (file)
@@ -33,6 +33,8 @@
 #include "param/param.h"
 #include "librpc/rpc/dcerpc_proto.h"
 #include "auth/gensec/gensec.h"
+#include "libcli/composite/composite.h"
+#include "lib/events/events.h"
 
 #define TEST_MACHINE_NAME "schannel"
 
@@ -258,7 +260,7 @@ static bool test_schannel(struct torture_context *tctx,
        b->flags |= dcerpc_flags;
 
        status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
-                                      credentials, NULL, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, 
                "Failed to connect with schannel");
 
@@ -270,7 +272,7 @@ static bool test_schannel(struct torture_context *tctx,
         * the second */
 
        /* Swap the binding details from SAMR to NETLOGON */
-       status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL, tctx->lp_ctx);
+       status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, "epm map");
 
        status = dcerpc_secondary_connection(p, &p_netlogon, 
@@ -296,7 +298,7 @@ static bool test_schannel(struct torture_context *tctx,
                "Failed to process schannel secured NETLOGON EX ops");
 
        /* Swap the binding details from SAMR to LSARPC */
-       status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, NULL, tctx->lp_ctx);
+       status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, "epm map");
 
        status = dcerpc_secondary_connection(p, &p_lsa, 
@@ -328,7 +330,7 @@ static bool test_schannel(struct torture_context *tctx,
        b->flags |= dcerpc_flags;
 
        status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
-                                      credentials, NULL, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, 
                "Failed to connect with schannel");
 
@@ -337,7 +339,7 @@ static bool test_schannel(struct torture_context *tctx,
                        "Failed to process schannel secured SAMR ops (on fresh connection)");
 
        /* Swap the binding details from SAMR to NETLOGON */
-       status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL, tctx->lp_ctx);
+       status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, "epm");
 
        status = dcerpc_secondary_connection(p_samr2, &p_netlogon2, 
@@ -370,7 +372,7 @@ static bool test_schannel(struct torture_context *tctx,
        b->flags &= ~DCERPC_AUTH_OPTIONS;
 
        status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
-                                      credentials, NULL, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
 
        torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
@@ -453,12 +455,12 @@ bool torture_rpc_schannel2(struct torture_context *torture)
 
        printf("Opening first connection\n");
        status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
-                                      credentials1, NULL, torture->lp_ctx);
+                                      credentials1, torture->ev, torture->lp_ctx);
        torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
 
        torture_comment(torture, "Opening second connection\n");
        status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
-                                      credentials2, NULL, torture->lp_ctx);
+                                      credentials2, torture->ev, torture->lp_ctx);
        torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
 
        credentials1->netlogon_creds = NULL;
@@ -484,3 +486,350 @@ bool torture_rpc_schannel2(struct torture_context *torture)
        return true;
 }
 
+struct torture_schannel_bench;
+
+struct torture_schannel_bench_conn {
+       struct torture_schannel_bench *s;
+       int index;
+       struct cli_credentials *wks_creds;
+       struct dcerpc_pipe *pipe;
+       struct netr_LogonSamLogonEx r;
+       struct netr_NetworkInfo ninfo;
+       TALLOC_CTX *tmp;
+       uint64_t total;
+       uint32_t count;
+};
+
+struct torture_schannel_bench {
+       struct torture_context *tctx;
+       bool progress;
+       int timelimit;
+       int nprocs;
+       int nconns;
+       struct torture_schannel_bench_conn *conns;
+       struct test_join *join_ctx1;
+       struct cli_credentials *wks_creds1;
+       struct test_join *join_ctx2;
+       struct cli_credentials *wks_creds2;
+       struct cli_credentials *user1_creds;
+       struct cli_credentials *user2_creds;
+       struct dcerpc_binding *b;
+       NTSTATUS error;
+       uint64_t total;
+       uint32_t count;
+       bool stopped;
+};
+
+static void torture_schannel_bench_connected(struct composite_context *c)
+{
+       struct torture_schannel_bench_conn *conn =
+               (struct torture_schannel_bench_conn *)c->async.private_data;
+       struct torture_schannel_bench *s = talloc_get_type(conn->s,
+                                          struct torture_schannel_bench);
+
+       s->error = dcerpc_pipe_connect_b_recv(c, s->conns, &conn->pipe);
+       torture_comment(s->tctx, "conn[%u]: %s\n", conn->index, nt_errstr(s->error));
+       if (NT_STATUS_IS_OK(s->error)) {
+               s->nconns++;
+       }
+}
+
+static void torture_schannel_bench_recv(struct rpc_request *req);
+
+static bool torture_schannel_bench_start(struct torture_schannel_bench_conn *conn)
+{
+       struct torture_schannel_bench *s = conn->s;
+       NTSTATUS status;
+       DATA_BLOB names_blob, chal, lm_resp, nt_resp;
+       int flags = CLI_CRED_NTLM_AUTH;
+       struct rpc_request *req;
+       struct cli_credentials *user_creds;
+
+       if (conn->total % 2) {
+               user_creds = s->user1_creds;
+       } else {
+               user_creds = s->user2_creds;
+       }
+
+       if (lp_client_lanman_auth(s->tctx->lp_ctx)) {
+               flags |= CLI_CRED_LANMAN_AUTH;
+       }
+
+       if (lp_client_ntlmv2_auth(s->tctx->lp_ctx)) {
+               flags |= CLI_CRED_NTLMv2_AUTH;
+       }
+
+       talloc_free(conn->tmp);
+       conn->tmp = talloc_new(s);
+       ZERO_STRUCT(conn->ninfo);
+       ZERO_STRUCT(conn->r);
+
+       cli_credentials_get_ntlm_username_domain(user_creds, conn->tmp,
+                                                &conn->ninfo.identity_info.account_name.string,
+                                                &conn->ninfo.identity_info.domain_name.string);
+
+       generate_random_buffer(conn->ninfo.challenge,
+                              sizeof(conn->ninfo.challenge));
+       chal = data_blob_const(conn->ninfo.challenge,
+                              sizeof(conn->ninfo.challenge));
+
+       names_blob = NTLMv2_generate_names_blob(conn->tmp, lp_iconv_convenience(s->tctx->lp_ctx),
+                                               cli_credentials_get_workstation(conn->wks_creds),
+                                               cli_credentials_get_domain(conn->wks_creds));
+
+       status = cli_credentials_get_ntlm_response(user_creds, conn->tmp,
+                                                  &flags,
+                                                  chal,
+                                                  names_blob,
+                                                  &lm_resp, &nt_resp,
+                                                  NULL, NULL);
+       torture_assert_ntstatus_ok(s->tctx, status,
+                                  "cli_credentials_get_ntlm_response failed");
+
+       conn->ninfo.lm.data = lm_resp.data;
+       conn->ninfo.lm.length = lm_resp.length;
+
+       conn->ninfo.nt.data = nt_resp.data;
+       conn->ninfo.nt.length = nt_resp.length;
+
+       conn->ninfo.identity_info.parameter_control = 0;
+       conn->ninfo.identity_info.logon_id_low = 0;
+       conn->ninfo.identity_info.logon_id_high = 0;
+       conn->ninfo.identity_info.workstation.string = cli_credentials_get_workstation(conn->wks_creds);
+
+       conn->r.in.server_name = talloc_asprintf(conn->tmp, "\\\\%s", dcerpc_server_name(conn->pipe));
+       conn->r.in.computer_name = cli_credentials_get_workstation(conn->wks_creds);
+       conn->r.in.logon_level = 2;
+       conn->r.in.logon.network = &conn->ninfo;
+       conn->r.in.flags = 0;
+       conn->r.in.validation_level = 2;
+
+       req = dcerpc_netr_LogonSamLogonEx_send(conn->pipe, conn->tmp, &conn->r);
+       torture_assert(s->tctx, req, "Failed to setup LogonSamLogonEx request");
+
+       req->async.callback = torture_schannel_bench_recv;
+       req->async.private_data = conn;
+
+       return true;
+}
+
+static void torture_schannel_bench_recv(struct rpc_request *req)
+{
+       bool ret;
+       struct torture_schannel_bench_conn *conn =
+               (struct torture_schannel_bench_conn *)req->async.private_data;
+       struct torture_schannel_bench *s = talloc_get_type(conn->s,
+                                          struct torture_schannel_bench);
+
+       s->error = dcerpc_ndr_request_recv(req);
+       if (!NT_STATUS_IS_OK(s->error)) {
+               return;
+       }
+
+       conn->total++;
+       conn->count++;
+
+       if (s->stopped) {
+               return;
+       }
+
+       ret = torture_schannel_bench_start(conn);
+       if (!ret) {
+               s->error = NT_STATUS_INTERNAL_ERROR;
+       }
+}
+
+/*
+  test multiple schannel connection in parallel
+ */
+bool torture_rpc_schannel_bench1(struct torture_context *torture)
+{
+       bool ret = true;
+       NTSTATUS status;
+       const char *binding = torture_setting_string(torture, "binding", NULL);
+       struct torture_schannel_bench *s;
+       struct timeval start;
+       struct timeval end;
+       int i;
+       const char *tmp;
+
+       s = talloc_zero(torture, struct torture_schannel_bench);
+       s->tctx = torture;
+       s->progress = torture_setting_bool(torture, "progress", true);
+       s->timelimit = torture_setting_int(torture, "timelimit", 10);
+       s->nprocs = torture_setting_int(torture, "nprocs", 4);
+       s->conns = talloc_zero_array(s, struct torture_schannel_bench_conn, s->nprocs);
+
+       s->user1_creds = (struct cli_credentials *)talloc_memdup(s,
+                                                                cmdline_credentials,
+                                                                sizeof(*s->user1_creds));
+       tmp = torture_setting_string(s->tctx, "extra_user1", NULL);
+       if (tmp) {
+               cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
+       }
+       s->user2_creds = (struct cli_credentials *)talloc_memdup(s,
+                                                                cmdline_credentials,
+                                                                sizeof(*s->user1_creds));
+       tmp = torture_setting_string(s->tctx, "extra_user2", NULL);
+       if (tmp) {
+               cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
+       }
+
+       s->join_ctx1 = torture_join_domain(s->tctx, talloc_asprintf(s, "%sb", TEST_MACHINE_NAME),
+                                          ACB_WSTRUST, &s->wks_creds1);
+       torture_assert(torture, s->join_ctx1 != NULL,
+                      "Failed to join domain with acct_flags=ACB_WSTRUST");
+       s->join_ctx2 = torture_join_domain(s->tctx, talloc_asprintf(s, "%sc", TEST_MACHINE_NAME),
+                                          ACB_WSTRUST, &s->wks_creds2);
+       torture_assert(torture, s->join_ctx2 != NULL,
+                      "Failed to join domain with acct_flags=ACB_WSTRUST");
+
+       cli_credentials_set_kerberos_state(s->wks_creds1, CRED_DONT_USE_KERBEROS);
+       cli_credentials_set_kerberos_state(s->wks_creds2, CRED_DONT_USE_KERBEROS);
+
+       for (i=0; i < s->nprocs; i++) {
+               s->conns[i].s = s;
+               s->conns[i].index = i;
+               s->conns[i].wks_creds = (struct cli_credentials *)talloc_memdup(
+                       s->conns, s->wks_creds1,sizeof(*s->wks_creds1));
+               if ((i % 2) && (torture_setting_bool(torture, "multijoin", false))) {
+                       memcpy(s->conns[i].wks_creds, s->wks_creds2,
+                              talloc_get_size(s->conns[i].wks_creds));
+               }
+               s->conns[i].wks_creds->netlogon_creds = NULL;
+       }
+
+       status = dcerpc_parse_binding(s, binding, &s->b);
+       torture_assert_ntstatus_ok(torture, status, "Bad binding string");
+       s->b->flags &= ~DCERPC_AUTH_OPTIONS;
+       s->b->flags |= DCERPC_SCHANNEL | DCERPC_SIGN;
+
+       torture_comment(torture, "Opening %d connections in parallel\n", s->nprocs);
+       for (i=0; i < s->nprocs; i++) {
+#if 1
+               s->error = dcerpc_pipe_connect_b(s->conns, &s->conns[i].pipe, s->b,
+                                                &ndr_table_netlogon,
+                                                s->conns[i].wks_creds,
+                                                torture->ev, torture->lp_ctx);
+               torture_assert_ntstatus_ok(torture, s->error, "Failed to connect with schannel");
+#else
+               /*
+                * This path doesn't work against windows,
+                * because of windows drops the connections
+                * which haven't reached a session setup yet
+                *
+                * The same as the reset on zero vc stuff.
+                */
+               struct composite_context *c;
+               c = dcerpc_pipe_connect_b_send(s->conns, s->b,
+                                              &ndr_table_netlogon,
+                                              s->conns[i].wks_creds,
+                                              torture->ev,
+                                              torture->lp_ctx);
+               torture_assert(torture, c != NULL, "Failed to setup connect");
+               c->async.fn = torture_schannel_bench_connected;
+               c->async.private_data = &s->conns[i];
+       }
+
+       while (NT_STATUS_IS_OK(s->error) && s->nprocs != s->nconns) {
+               int ev_ret = event_loop_once(torture->ev);
+               torture_assert(torture, ev_ret == 0, "event_loop_once failed");
+#endif
+       }
+       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++) {
+               ret = torture_schannel_bench_start(&s->conns[i]);
+               torture_assert(torture, ret, "Failed to setup LogonSamLogonEx");
+       }
+
+       start = timeval_current();
+       end = timeval_add(&start, s->timelimit, 0);
+
+       while (NT_STATUS_IS_OK(s->error) && !timeval_expired(&end)) {
+               int ev_ret = event_loop_once(torture->ev);
+               torture_assert(torture, ev_ret == 0, "event_loop_once failed");
+       }
+       torture_assert_ntstatus_ok(torture, s->error, "Failed some request");
+       s->stopped = true;
+       talloc_free(s->conns);
+
+       for (i=0; i < s->nprocs; i++) {
+               s->total += s->conns[i].total;
+       }
+
+       torture_comment(torture,
+                       "Total ops[%llu] (%u ops/s)\n",
+                       (unsigned long long)s->total,
+                       (unsigned)s->total/s->timelimit);
+
+       torture_leave_domain(s->join_ctx1);
+       torture_leave_domain(s->join_ctx2);
+       return true;
+}
index fcb828ddb2daa14e4c39b9eff4288bd7680c0048..0df7e576ee9175a66413a425c959186917cce506 100644 (file)
@@ -158,7 +158,11 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
        binding->flags |= settings->bindoptions;
 
        torture_assert_ntstatus_ok(torture, 
-                                  dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL, torture->lp_ctx),
+                                  dcerpc_pipe_connect_b(torture, &p, binding,
+                                                        &ndr_table_lsarpc,
+                                                        cmdline_credentials,
+                                                        torture->ev,
+                                                        torture->lp_ctx),
                                   "connect");
 
        if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
index 19cff53d8479d5dc90eed1923dd1d958513f9642..ab6309d55f8015eb5b7ed645d2603b575befd687 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "includes.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 #include "torture/rpc/rpc.h"
 #include "librpc/gen_ndr/ndr_spoolss_c.h"
 #include "rpc_server/dcerpc_server.h"
index 9e2921d406bfd120201b3a02babc85f55ac43c09..9ce9fb752637868e84fe48a85adb24c10f2103ce 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "includes.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 #include "torture/rpc/rpc.h"
 #include "librpc/gen_ndr/ndr_spoolss_c.h"
 #include "rpc_server/dcerpc_server.h"
index 100e7cead27ef9981faafccd9b81aa2bd7cb0295..51efd99bd8e84b2667996368dae10bc6ec2366d2 100644 (file)
@@ -508,9 +508,11 @@ _PUBLIC_ void torture_leave_domain(struct test_join *join)
        /* Delete machine account */                                                                                                                                                                                                                                                                                                                    
        status = dcerpc_samr_DeleteUser(join->p, join, &d);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Delete of machine account failed\n");
+               printf("Delete of machine account %s failed\n",
+                      join->netbios_name);
        } else {
-               printf("Delete of machine account was successful.\n");
+               printf("Delete of machine account %s was successful.\n",
+                      join->netbios_name);
        }
 
        if (join->libnet_r) {
index 379632f0e7aba5324c6614ee6a0e820d1efaa36d..11c4e1fa2c83d1e9e08d6cfb927af1b555b23bd2 100644 (file)
@@ -2,16 +2,14 @@
 #################################
 # Start SUBSYSTEM TORTURE_SMB2
 [MODULE::TORTURE_SMB2]
-SUBSYSTEM = torture
+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 \
@@ -20,5 +18,9 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix torture/smb2/, \
                find.o \
                lock.o \
                notify.o \
-               smb2.o)
+               smb2.o \
+               persistent_handles.o \
+               oplocks.o)
 
+
+$(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c)))
index c47a26277c47dde3ee78649abef6bd9bdfc249fa..906d6e4f8d57bb4e32d8d7082b1593097323c7de 100644 (file)
@@ -51,9 +51,9 @@ static struct {
  { LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
  { LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
  { LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
-/*  
-disabled until we know how the alignment now works
-{ LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) }, */
+/*
+ { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
+*/
  { LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
  { LEVEL(RAW_FILEINFO_SEC_DESC) }
 };
@@ -107,9 +107,6 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
                        file_levels[i].dinfo.query_secdesc.in.secinfo_flags = 0x7;
                }
                if (file_levels[i].level == RAW_FILEINFO_SMB2_ALL_EAS) {
-                       if (torture_setting_bool(tctx, "samba4", false)) {
-                               continue;
-                       }
                        file_levels[i].finfo.all_eas.in.continue_flags = 
                                SMB2_CONTINUE_FLAG_RESTART;
                        file_levels[i].dinfo.all_eas.in.continue_flags = 
@@ -183,6 +180,9 @@ bool torture_smb2_getinfo(struct torture_context *torture)
                return false;
        }
 
+       smb2_deltree(tree, FNAME);
+       smb2_deltree(tree, DNAME);
+
        status = torture_setup_complex_file(tree, FNAME);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
index 3cf2e93ee04bb864deda761fd8a5d97810fa6f2a..1a56cb9caddd13bcc85512a42e7ed8b6bd5f38e5 100644 (file)
@@ -51,6 +51,7 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
        struct smb2_handle h;
        uint8_t buf[200];
        struct smb2_lock lck;
+       struct smb2_lock_element el[1];
 
        ZERO_STRUCT(buf);
 
@@ -60,126 +61,132 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
        status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       lck.in.unknown1         = 0x0000;
-       lck.in.unknown2         = 0x00000000;
+       lck.in.locks            = el;
+
+       lck.in.lock_count       = 0x0000;
+       lck.in.reserved         = 0x00000000;
        lck.in.file.handle      = h;
-       lck.in.offset           = 0x0000000000000000;
-       lck.in.count            = 0x0000000000000000;
-       lck.in.unknown5         = 0x0000000000000000;
-       lck.in.flags            = 0x00000000;
+       el[0].offset            = 0x0000000000000000;
+       el[0].length            = 0x0000000000000000;
+       el[0].reserved          = 0x0000000000000000;
+       el[0].flags             = 0x00000000;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x00000000;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x00000000;
        lck.in.file.handle      = h;
-       lck.in.offset           = 0;
-       lck.in.count            = 0;
-       lck.in.unknown5         = 0x00000000;
-       lck.in.flags            = SMB2_LOCK_FLAG_NONE;
+       el[0].offset            = 0;
+       el[0].length            = 0;
+       el[0].reserved          = 0x00000000;
+       el[0].flags             = SMB2_LOCK_FLAG_NONE;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        lck.in.file.handle.data[0] +=1;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
        lck.in.file.handle.data[0] -=1;
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0xFFFFFFFF;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x123ab1;
        lck.in.file.handle      = h;
-       lck.in.offset           = UINT64_MAX;
-       lck.in.count            = UINT64_MAX;
-       lck.in.unknown5         = 0x00000000;
-       lck.in.flags            = SMB2_LOCK_FLAG_EXCLUSIV|SMB2_LOCK_FLAG_NO_PENDING;
+       el[0].offset            = UINT64_MAX;
+       el[0].length            = UINT64_MAX;
+       el[0].reserved          = 0x00000000;
+       el[0].flags             = SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
+       lck.in.reserved         = 0x123ab2;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
 
+       lck.in.reserved         = 0x123ab3;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
+       lck.in.reserved         = 0x123ab4;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
 
+       lck.in.reserved         = 0x123ab5;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x12345678;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x12345678;
        lck.in.file.handle      = h;
-       lck.in.offset           = UINT32_MAX;
-       lck.in.count            = UINT32_MAX;
-       lck.in.unknown5         = 0x87654321;
-       lck.in.flags            = SMB2_LOCK_FLAG_EXCLUSIV|SMB2_LOCK_FLAG_NO_PENDING;
+       el[0].offset            = UINT32_MAX;
+       el[0].length            = UINT32_MAX;
+       el[0].reserved          = 0x87654321;
+       el[0].flags             = SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
 
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
 
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
-       lck.in.flags            = 0x00000000;
+       el[0].flags             = 0x00000000;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
-       lck.in.flags            = 0x00000001;
+       el[0].flags             = 0x00000001;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x87654321;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x87654321;
        lck.in.file.handle      = h;
-       lck.in.offset           = 0x00000000FFFFFFFF;
-       lck.in.count            = 0x00000000FFFFFFFF;
-       lck.in.unknown5         = 0x12345678;
-       lck.in.flags            = SMB2_LOCK_FLAG_UNLOCK;
+       el[0].offset            = 0x00000000FFFFFFFF;
+       el[0].length            = 0x00000000FFFFFFFF;
+       el[0].reserved          = 0x1234567;
+       el[0].flags             = SMB2_LOCK_FLAG_UNLOCK;
        status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       CHECK_STATUS(status, NT_STATUS_OK);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x12345678;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x1234567;
        lck.in.file.handle      = h;
-       lck.in.offset           = 0x00000000FFFFFFFF;
-       lck.in.count            = 0x00000000FFFFFFFF;
-       lck.in.unknown5         = 0x00000000;
-       lck.in.flags            = SMB2_LOCK_FLAG_UNLOCK;
+       el[0].offset            = 0x00000000FFFFFFFF;
+       el[0].length            = 0x00000000FFFFFFFF;
+       el[0].reserved          = 0x00000000;
+       el[0].flags             = SMB2_LOCK_FLAG_UNLOCK;
        status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       CHECK_STATUS(status, NT_STATUS_OK);
 
        status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       CHECK_STATUS(status, NT_STATUS_OK);
        status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       CHECK_STATUS(status, NT_STATUS_OK);
        status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       CHECK_STATUS(status, NT_STATUS_OK);
 
 done:
        return ret;
@@ -206,6 +213,9 @@ static bool test_lock_read_write(struct torture_context *torture,
        struct smb2_create cr;
        struct smb2_write wr;
        struct smb2_read rd;
+       struct smb2_lock_element el[1];
+
+       lck.in.locks            = el;
 
        ZERO_STRUCT(buf);
 
@@ -215,27 +225,27 @@ static bool test_lock_read_write(struct torture_context *torture,
        status = smb2_util_write(tree, h1, buf, 0, ARRAY_SIZE(buf));
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x00000000;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x00000000;
        lck.in.file.handle      = h1;
-       lck.in.offset           = 0;
-       lck.in.count            = ARRAY_SIZE(buf)/2;
-       lck.in.unknown5         = 0x00000000;
-       lck.in.flags            = s->lock_flags;
+       el[0].offset            = 0;
+       el[0].length            = ARRAY_SIZE(buf)/2;
+       el[0].reserved          = 0x00000000;
+       el[0].flags             = s->lock_flags;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x00000000;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x00000000;
        lck.in.file.handle      = h1;
-       lck.in.offset           = ARRAY_SIZE(buf)/2;
-       lck.in.count            = ARRAY_SIZE(buf)/2;
-       lck.in.unknown5         = 0x00000000;
-       lck.in.flags            = s->lock_flags;
+       el[0].offset            = ARRAY_SIZE(buf)/2;
+       el[0].length            = ARRAY_SIZE(buf)/2;
+       el[0].reserved          = 0x00000000;
+       el[0].flags             = s->lock_flags;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        ZERO_STRUCT(cr);
        cr.in.oplock_level = 0;
@@ -286,16 +296,16 @@ static bool test_lock_read_write(struct torture_context *torture,
        status = smb2_read(tree, tree, &rd);
        CHECK_STATUS(status, s->read_h2_status);
 
-       lck.in.unknown1         = 0x0001;
-       lck.in.unknown2         = 0x00000000;
+       lck.in.lock_count       = 0x0001;
+       lck.in.reserved         = 0x00000000;
        lck.in.file.handle      = h1;
-       lck.in.offset           = ARRAY_SIZE(buf)/2;
-       lck.in.count            = ARRAY_SIZE(buf)/2;
-       lck.in.unknown5         = 0x00000000;
-       lck.in.flags            = SMB2_LOCK_FLAG_UNLOCK;
+       el[0].offset            = ARRAY_SIZE(buf)/2;
+       el[0].length            = ARRAY_SIZE(buf)/2;
+       el[0].reserved          = 0x00000000;
+       el[0].flags             = SMB2_LOCK_FLAG_UNLOCK;
        status = smb2_lock(tree, &lck);
        CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VALUE(lck.out.unknown1, 0);
+       CHECK_VALUE(lck.out.reserved, 0);
 
        ZERO_STRUCT(wr);
        wr.in.file.handle = h2;
@@ -349,7 +359,7 @@ static bool test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_t
 {
        struct test_lock_read_write_state s = {
                .fname                  = "lock_rw_exclusiv.dat",
-               .lock_flags             = SMB2_LOCK_FLAG_EXCLUSIV,
+               .lock_flags             = SMB2_LOCK_FLAG_EXCLUSIVE,
                .write_h1_status        = NT_STATUS_OK,
                .read_h1_status         = NT_STATUS_OK,
                .write_h2_status        = NT_STATUS_FILE_LOCK_CONFLICT,
diff --git a/source/torture/smb2/oplocks.c b/source/torture/smb2/oplocks.c
new file mode 100644 (file)
index 0000000..9a06ae1
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   test suite for SMB2 oplocks
+
+   Copyright (C) Stefan Metzmacher 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 "librpc/gen_ndr/security.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+
+#define CHECK_VAL(v, correct) do { \
+       if ((v) != (correct)) { \
+               torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+                               __location__, #v, (int)v, (int)correct); \
+               ret = false; \
+       }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+       if (!NT_STATUS_EQUAL(status, correct)) { \
+               torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+                      nt_errstr(status), nt_errstr(correct)); \
+               ret = false; \
+               goto done; \
+       }} while (0)
+
+static struct {
+       struct smb2_handle handle;
+       uint8_t level;
+       struct smb2_break br;
+       int count;
+       int failures;
+} break_info;
+
+static void torture_oplock_break_callback(struct smb2_request *req)
+{
+       NTSTATUS status;
+       struct smb2_break br;
+
+       ZERO_STRUCT(br);
+       status = smb2_break_recv(req, &break_info.br);
+       if (!NT_STATUS_IS_OK(status)) {
+               break_info.failures++;
+       }
+
+       return;
+}
+
+/* a oplock break request handler */
+static bool torture_oplock_handler(struct smb2_transport *transport,
+                                  const struct smb2_handle *handle,
+                                  uint8_t level, void *private_data)
+{
+       struct smb2_tree *tree = private_data;
+       const char *name;
+       struct smb2_request *req;
+
+       break_info.handle       = *handle;
+       break_info.level        = level;
+       break_info.count++;
+
+       switch (level) {
+       case SMB2_OPLOCK_LEVEL_II:
+               name = "level II";
+               break;
+       case SMB2_OPLOCK_LEVEL_NONE:
+               name = "none";
+               break;
+       default:
+               name = "unknown";
+               break_info.failures++;
+       }
+       printf("Acking to %s [0x%02X] in oplock handler\n",
+               name, level);
+
+       ZERO_STRUCT(break_info.br);
+       break_info.br.in.file.handle    = *handle;
+       break_info.br.in.oplock_level   = level;
+       break_info.br.in.reserved       = 0;
+       break_info.br.in.reserved2      = 0;
+
+       req = smb2_break_send(tree, &break_info.br);
+       req->async.fn = torture_oplock_break_callback;
+       req->async.private_data = NULL;
+
+       return true;
+}
+
+bool torture_smb2_oplock_batch1(struct torture_context *tctx,
+                               struct smb2_tree *tree)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_handle h1, h2;
+       struct smb2_create io;
+       NTSTATUS status;
+       const char *fname = "oplock.dat";
+       bool ret = true;
+
+       tree->session->transport->oplock.handler        = torture_oplock_handler;
+       tree->session->transport->oplock.private_data   = tree;
+
+       smb2_util_unlink(tree, fname);
+
+       ZERO_STRUCT(break_info);
+
+       ZERO_STRUCT(io);
+       io.in.security_flags            = 0x00;
+       io.in.oplock_level              = SMB2_OPLOCK_LEVEL_BATCH;
+       io.in.impersonation_level       = NTCREATEX_IMPERSONATION_IMPERSONATION;
+       io.in.create_flags              = 0x00000000;
+       io.in.reserved                  = 0x00000000;
+       io.in.desired_access            = SEC_RIGHTS_FILE_ALL;
+       io.in.file_attributes           = FILE_ATTRIBUTE_NORMAL;
+       io.in.share_access              = NTCREATEX_SHARE_ACCESS_READ |
+                                         NTCREATEX_SHARE_ACCESS_WRITE |
+                                         NTCREATEX_SHARE_ACCESS_DELETE;
+       io.in.create_disposition        = NTCREATEX_DISP_OPEN_IF;
+       io.in.create_options            = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
+                                         NTCREATEX_OPTIONS_ASYNC_ALERT |
+                                         NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
+                                         0x00200000;
+       io.in.fname                     = fname;
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+       /*CHECK_VAL(io.out.reserved, 0);*/
+       CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_CREATED);
+       CHECK_VAL(io.out.alloc_size, 0);
+       CHECK_VAL(io.out.size, 0);
+       CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_VAL(io.out.reserved2, 0);
+       CHECK_VAL(break_info.count, 0);
+
+       h1 = io.out.file.handle;
+
+       ZERO_STRUCT(io.in.blobs);
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_VAL(break_info.count, 1);
+       CHECK_VAL(break_info.failures, 0);
+       CHECK_VAL(break_info.level, SMB2_OPLOCK_LEVEL_II);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_II);
+       /*CHECK_VAL(io.out.reserved, 0);*/
+       CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED);
+       CHECK_VAL(io.out.alloc_size, 0);
+       CHECK_VAL(io.out.size, 0);
+       CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_VAL(io.out.reserved2, 0);
+
+       h2 = io.out.file.handle;
+
+done:
+       talloc_free(mem_ctx);
+
+       smb2_util_close(tree, h1);
+       smb2_util_close(tree, h2);
+       smb2_util_unlink(tree, fname);
+       return ret;
+}
diff --git a/source/torture/smb2/persistent_handles.c b/source/torture/smb2/persistent_handles.c
new file mode 100644 (file)
index 0000000..249ddd1
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   test suite for SMB2 persistent file handles
+
+   Copyright (C) Stefan Metzmacher 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 "librpc/gen_ndr/security.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+
+#define CHECK_VAL(v, correct) do { \
+       if ((v) != (correct)) { \
+               torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+                               __location__, #v, (int)v, (int)correct); \
+               ret = false; \
+       }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+       if (!NT_STATUS_EQUAL(status, correct)) { \
+               torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+                      nt_errstr(status), nt_errstr(correct)); \
+               ret = false; \
+               goto done; \
+       }} while (0)
+
+/* 
+   basic testing of SMB2 persistent file handles
+   regarding the position information on the handle
+*/
+bool torture_smb2_persistent_handles1(struct torture_context *tctx,
+                                     struct smb2_tree *tree1,
+                                     struct smb2_tree *tree2)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_handle h1, h2;
+       struct smb2_create io1, io2;
+       NTSTATUS status;
+       const char *fname = "persistent_handles.dat";
+       DATA_BLOB b;
+       union smb_fileinfo qfinfo;
+       union smb_setfileinfo sfinfo;
+       bool ret = true;
+       uint64_t pos;
+
+       smb2_util_unlink(tree1, fname);
+
+       ZERO_STRUCT(io1);
+       io1.in.security_flags           = 0x00;
+       io1.in.oplock_level             = SMB2_OPLOCK_LEVEL_BATCH;
+       io1.in.impersonation_level      = NTCREATEX_IMPERSONATION_IMPERSONATION;
+       io1.in.create_flags             = 0x00000000;
+       io1.in.reserved                 = 0x00000000;
+       io1.in.desired_access           = SEC_RIGHTS_FILE_ALL;
+       io1.in.file_attributes          = FILE_ATTRIBUTE_NORMAL;
+       io1.in.share_access             = NTCREATEX_SHARE_ACCESS_READ |
+                                         NTCREATEX_SHARE_ACCESS_WRITE |
+                                         NTCREATEX_SHARE_ACCESS_DELETE;
+       io1.in.create_disposition       = NTCREATEX_DISP_OPEN_IF;
+       io1.in.create_options           = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
+                                         NTCREATEX_OPTIONS_ASYNC_ALERT |
+                                         NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
+                                         0x00200000;
+       io1.in.fname                    = fname;
+
+       b = data_blob_talloc(mem_ctx, NULL, 16);
+       SBVAL(b.data, 0, 0);
+       SBVAL(b.data, 8, 0);
+
+       status = smb2_create_blob_add(tree1, &io1.in.blobs,
+                                     SMB2_CREATE_TAG_DHNQ,
+                                     b);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       status = smb2_create(tree1, mem_ctx, &io1);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(io1.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+       /*CHECK_VAL(io1.out.reserved, 0);*/
+       CHECK_VAL(io1.out.create_action, NTCREATEX_ACTION_CREATED);
+       CHECK_VAL(io1.out.alloc_size, 0);
+       CHECK_VAL(io1.out.size, 0);
+       CHECK_VAL(io1.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_VAL(io1.out.reserved2, 0);
+
+       /* TODO: check extra blob content */
+
+       h1 = io1.out.file.handle;
+
+       ZERO_STRUCT(qfinfo);
+       qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+       qfinfo.generic.in.file.handle = h1;
+       status = smb2_getinfo_file(tree1, mem_ctx, &qfinfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(qfinfo.position_information.out.position, 0);
+       pos = qfinfo.position_information.out.position;
+       torture_comment(tctx, "position: %llu\n",
+                       (unsigned long long)pos);
+
+       ZERO_STRUCT(sfinfo);
+       sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION;
+       sfinfo.generic.in.file.handle = h1;
+       sfinfo.position_information.in.position = 0x1000;
+       status = smb2_setinfo_file(tree1, &sfinfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       ZERO_STRUCT(qfinfo);
+       qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+       qfinfo.generic.in.file.handle = h1;
+       status = smb2_getinfo_file(tree1, mem_ctx, &qfinfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(qfinfo.position_information.out.position, 0x1000);
+       pos = qfinfo.position_information.out.position;
+       torture_comment(tctx, "position: %llu\n",
+                       (unsigned long long)pos);
+
+       talloc_free(tree1);
+       tree1 = NULL;
+
+       ZERO_STRUCT(qfinfo);
+       qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+       qfinfo.generic.in.file.handle = h1;
+       status = smb2_getinfo_file(tree2, mem_ctx, &qfinfo);
+       CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+
+       ZERO_STRUCT(io2);
+       io2.in.fname = fname;
+
+       b = data_blob_talloc(tctx, NULL, 16);
+       SBVAL(b.data, 0, h1.data[0]);
+       SBVAL(b.data, 8, h1.data[1]);
+
+       status = smb2_create_blob_add(tree2, &io2.in.blobs,
+                                     SMB2_CREATE_TAG_DHNC,
+                                     b);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       status = smb2_create(tree2, mem_ctx, &io2);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(io2.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+       CHECK_VAL(io2.out.reserved, 0x00);
+       CHECK_VAL(io2.out.create_action, NTCREATEX_ACTION_EXISTED);
+       CHECK_VAL(io2.out.alloc_size, 0);
+       CHECK_VAL(io2.out.size, 0);
+       CHECK_VAL(io2.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_VAL(io2.out.reserved2, 0);
+
+       h2 = io2.out.file.handle;
+
+       ZERO_STRUCT(qfinfo);
+       qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+       qfinfo.generic.in.file.handle = h2;
+       status = smb2_getinfo_file(tree2, mem_ctx, &qfinfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VAL(qfinfo.position_information.out.position, 0x1000);
+       pos = qfinfo.position_information.out.position;
+       torture_comment(tctx, "position: %llu\n",
+                       (unsigned long long)pos);
+
+       smb2_util_close(tree2, h2);
+
+       talloc_free(mem_ctx);
+
+       smb2_util_unlink(tree2, fname);
+done:
+       return ret;
+}
index 0f4c9fefdfea60d51d6ca59e38cf2653999de06e..889d343a497ebe0b3c6c5e3804f8b276563a2617 100644 (file)
@@ -207,7 +207,7 @@ bool torture_smb2_scan(struct torture_context *torture)
        status = smb2_connect(mem_ctx, host, share, 
                              lp_resolve_context(torture->lp_ctx), 
                              credentials, &tree, 
-                             event_context_find(mem_ctx));
+                             torture->ev);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Connection failed - %s\n", nt_errstr(status));
                return false;
@@ -224,7 +224,7 @@ bool torture_smb2_scan(struct torture_context *torture)
                        status = smb2_connect(mem_ctx, host, share, 
                                              lp_resolve_context(torture->lp_ctx), 
                                              credentials, &tree, 
-                                             event_context_find(mem_ctx));
+                                             torture->ev);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Connection failed - %s\n", nt_errstr(status));
                                return false;
index d07611264bcca226eb9b1d444f07459988b382a2..37eadcf7fd5b006d927e09cc1b8b409c95f88e3b 100644 (file)
@@ -21,7 +21,7 @@
 #include "libcli/smb2/smb2.h"
 #include "libcli/smb2/smb2_calls.h"
 
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/smb2/proto.h"
 #include "lib/util/dlinklist.h"
 
@@ -47,9 +47,9 @@ static bool wrap_simple_1smb2_test(struct torture_context *torture_ctx,
 }
 
 struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite,
-                                                          const char *name,
-                                                          bool (*run) (struct torture_context *,
-                                                                       struct smb2_tree *))
+                                                 const char *name,
+                                                 bool (*run)(struct torture_context *,
+                                                             struct smb2_tree *))
 {
        struct torture_test *test; 
        struct torture_tcase *tcase;
@@ -69,6 +69,61 @@ struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite,
        return test;
 }
 
+
+static bool wrap_simple_2smb2_test(struct torture_context *torture_ctx,
+                                  struct torture_tcase *tcase,
+                                  struct torture_test *test)
+{
+       bool (*fn) (struct torture_context *, struct smb2_tree *, struct smb2_tree *);
+       bool ret;
+
+       struct smb2_tree *tree1;
+       struct smb2_tree *tree2;
+       TALLOC_CTX *mem_ctx = talloc_new(torture_ctx);
+
+       if (!torture_smb2_connection(torture_ctx, &tree1) ||
+           !torture_smb2_connection(torture_ctx, &tree2)) {
+               return false;
+       }
+
+       talloc_steal(mem_ctx, tree1);
+       talloc_steal(mem_ctx, tree2);
+
+       fn = test->fn;
+
+       ret = fn(torture_ctx, tree1, tree2);
+
+       /* the test may already closed some of the connections */
+       talloc_free(mem_ctx);
+
+       return ret;
+}
+
+
+_PUBLIC_ struct torture_test *torture_suite_add_2smb2_test(struct torture_suite *suite,
+                                                          const char *name,
+                                                          bool (*run)(struct torture_context *,
+                                                                      struct smb2_tree *,
+                                                                      struct smb2_tree *))
+{
+       struct torture_test *test;
+       struct torture_tcase *tcase;
+
+       tcase = torture_suite_add_tcase(suite, name);
+
+       test = talloc(tcase, struct torture_test);
+
+       test->name = talloc_strdup(test, name);
+       test->description = NULL;
+       test->run = wrap_simple_2smb2_test;
+       test->fn = run;
+       test->dangerous = false;
+
+       DLIST_ADD_END(tcase->tests, test, struct torture_test *);
+
+       return test;
+}
+
 NTSTATUS torture_smb2_init(void)
 {
        struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "SMB2");
@@ -82,6 +137,8 @@ NTSTATUS torture_smb2_init(void)
        torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
        torture_suite_add_suite(suite, torture_smb2_lock_init());
        torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
+       torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);
+       torture_suite_add_1smb2_test(suite, "OPLOCK-BATCH1", torture_smb2_oplock_batch1);
 
        suite->description = talloc_strdup(suite, "SMB2-specific tests");
 
index f85b1c42ff9c56f6f6133463ceb96fcb8bdff10f..af4f345104f2c04e307c8ac0fe704e8b1d52eab5 100644 (file)
@@ -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"
 #include "torture/smb2/proto.h"
 
 
-/*
-  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
 */
@@ -314,7 +274,7 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr
        status = smb2_connect(tctx, host, share, 
                              lp_resolve_context(tctx->lp_ctx),
                              credentials, tree, 
-                             event_context_find(tctx));
+                             tctx->ev);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
                       host, share, nt_errstr(status));
index faae784e4b09db4418f01e16b080670e168f66df..418f933993f3b0b923a59d334cb46054712ecd03 100644 (file)
@@ -30,8 +30,7 @@
 #include "lib/events/events.h"
 #include "dynconfig.h"
 
-#include "torture/torture.h"
-#include "build.h"
+#include "torture/smbtorture.h"
 #include "lib/util/dlinklist.h"
 #include "librpc/rpc/dcerpc.h"
 #include "param/param.h"
@@ -675,7 +674,7 @@ int main(int argc,char *argv[])
                exit(1);
        }
 
-       torture = torture_context_init(cli_credentials_get_event_context(cmdline_credentials), ui_ops);
+       torture = torture_context_init(event_context_init(NULL), ui_ops);
        if (basedir != NULL) {
                if (basedir[0] != '/') {
                        fprintf(stderr, "Please specify an absolute path to --basedir\n");
similarity index 91%
rename from source/torture/torture.h
rename to source/torture/smbtorture.h
index 26ecdb567b4a7f77de8d537c056dbdd293df2c0e..3b5a573d83f0d9e36675c8ebc847d28a8ff65847 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef __TORTURE_H__
-#define __TORTURE_H__
+#ifndef __SMBTORTURE_H__
+#define __SMBTORTURE_H__
 
-#include "torture/ui.h"
+#include "torture/torture.h"
 
 struct smbcli_state;
 
@@ -37,5 +37,4 @@ struct torture_test;
 int torture_init(void);
 bool torture_register_suite(struct torture_suite *suite);
 
-
-#endif /* __TORTURE_H__ */
+#endif /* __SMBTORTURE_H__ */
index 8a41b722490724a76f8029cc809c67400169078d..54fe0ead2700da6fae9fdfbe3272c38cb40b3e4c 100644 (file)
@@ -21,7 +21,6 @@
 #include "includes.h"
 #include "system/time.h"
 #include "torture/torture.h"
-#include "build.h"
 #include "lib/util/dlinklist.h"
 #include "param/param.h"
 #include "lib/cmdline/popt_common.h"
@@ -60,7 +59,7 @@ _PUBLIC_ int torture_init(void)
        extern NTSTATUS torture_raw_init(void);
        extern NTSTATUS torture_unix_init(void);
        extern NTSTATUS torture_winbind_init(void);
-       init_module_fn static_init[] = { STATIC_torture_MODULES };
+       init_module_fn static_init[] = { STATIC_smbtorture_MODULES };
        init_module_fn *shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "torture");
 
        run_init_functions(static_init);
index 05ea27db026da67650e4f1168bcc3594dee86581..661e3372700185c71ecd9e578295855bbefc6a56 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/unix/proto.h"
 
 NTSTATUS torture_unix_init(void)
index c14be9e2d0726c38ce735d948f1af848db9b3def..d7482ddcf1f5e98b035435dedce835ce2b098da1 100644 (file)
@@ -63,8 +63,8 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
                                        lp_smb_ports(tctx->lp_ctx),
                                        share, NULL,
                                        cmdline_credentials, 
-                                       lp_resolve_context(tctx->lp_ctx), NULL, 
-                                       &options);
+                                       lp_resolve_context(tctx->lp_ctx),
+                                       tctx->ev, &options);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("failed to connect to //%s/%s: %s\n",
index a1333ac5bdfc91faaf5cbc63c4b16e366f562fd9..d4f19bb57a1ced02656c7a0283ee0294fc49f591 100644 (file)
@@ -84,7 +84,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx,
                                        lp_smb_ports(tctx->lp_ctx),
                                        share, NULL,
                                        creds, lp_resolve_context(tctx->lp_ctx),
-                                       NULL, &options);
+                                       tctx->ev, &options);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("failed to connect to //%s/%s: %s\n",
index 1009fcf9f11b120194559e232cb61487e50303f0..9dc948ade50232601908cce307968aec4c7fec64 100644 (file)
 #ifndef _TORTURE_PROVISION_H_
 #define _TORTURE_PROVISION_H_
 
+#include "torture/torture.h"
+
+struct smbcli_state;
+struct smbcli_tree;
+
 /**
   setup a directory ready for a test
 */
index c1a20094f385e520828823fd1c414df8f9d7c330..938e7d6c038f9b9af6a6fadd32fdd7990edaa7c0 100644 (file)
@@ -28,7 +28,6 @@
 #include "system/shmem.h"
 #include "system/wait.h"
 #include "system/time.h"
-#include "torture/ui.h"
 #include "torture/torture.h"
 #include "util/dlinklist.h"
 #include "auth/credentials/credentials.h"
index 155766a6774608a704cb07c27a48db9e4a60a72c..15bc51daba4571273eb016c95f7533479ca8d5fe 100644 (file)
@@ -2,14 +2,14 @@
 #################################
 # Start SUBSYSTEM TORTURE_WINBIND
 [MODULE::TORTURE_WINBIND]
-SUBSYSTEM = torture
+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)))
 
index 51ac0e622a12465a8ea9d2202c5faaed69d0ea43..31c5b8cf96b022e652eb0406800c4f169854abd0 100644 (file)
@@ -26,7 +26,7 @@
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/netlogon.h"
 #include "param/param.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
 
 #define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \
        NSS_STATUS __got, __expected = (expected); \
@@ -262,7 +262,7 @@ static bool torture_winbind_struct_check_machacc(struct torture_context *torture
 
        torture_assert_str_equal(torture,
                                 rep.data.auth.error_string,
-                                nt_errstr(NT_STATUS_OK),
+                                get_friendly_nt_error_msg(NT_STATUS_OK),
                                 "WINBINDD_CHECK_MACHACC ok: error_string");
 
        torture_assert_int_equal(torture,
@@ -295,6 +295,10 @@ static bool get_trusted_domains(struct torture_context *torture,
        DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
 
        extra_data = (char *)rep.extra_data.data;
+       if (!extra_data) {
+               return true;
+       }
+
        torture_assert(torture, extra_data, "NULL trust list");
 
        while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
@@ -356,7 +360,6 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
        DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
 
        list1 = (char *)rep.extra_data.data;
-       torture_assert(torture, list1, "NULL trust list");
 
        torture_comment(torture, "%s\n", list1);
 
@@ -368,7 +371,6 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
        DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
 
        list2 = (char *)rep.extra_data.data;
-       torture_assert(torture, list2, "NULL trust list");
 
        /*
         * The list_all_domains parameter should be ignored
@@ -381,7 +383,7 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
        ok = get_trusted_domains(torture, &listd);
        torture_assert(torture, ok, "failed to get trust list");
 
-       for (i=0; listd[i].netbios_name; i++) {
+       for (i=0; listd && listd[i].netbios_name; i++) {
                if (i == 0) {
                        struct dom_sid *builtin_sid;
 
@@ -424,7 +426,7 @@ static bool torture_winbind_struct_domain_info(struct torture_context *torture)
        ok = get_trusted_domains(torture, &listd);
        torture_assert(torture, ok, "failed to get trust list");
 
-       for (i=0; listd[i].netbios_name; i++) {
+       for (i=0; listd && listd[i].netbios_name; i++) {
                struct winbindd_request req;
                struct winbindd_response rep;
                struct dom_sid *sid;
@@ -485,14 +487,14 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture)
        bool ok;
        bool strict = torture_setting_bool(torture, "strict mode", false);
        struct torture_trust_domain *listd = NULL;
-       uint32_t i;
+       uint32_t i, count = 0;
 
        torture_comment(torture, "Running WINBINDD_GETDCNAME (struct based)\n");
 
        ok = get_trusted_domains(torture, &listd);
        torture_assert(torture, ok, "failed to get trust list");
 
-       for (i=0; listd[i].netbios_name; i++) {
+       for (i=0; listd && listd[i].netbios_name; i++) {
                struct winbindd_request req;
                struct winbindd_response rep;
 
@@ -512,8 +514,13 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture)
                /* TODO: check rep.data.dc_name; */
                torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n",
                                req.domain_name, rep.data.dc_name);
+               count++;
        }
 
+       if (strict) {
+               torture_assert(torture, count > 0,
+                              "WiNBINDD_GETDCNAME was not tested");
+       }
        return true;
 }
 
@@ -530,7 +537,7 @@ static bool torture_winbind_struct_dsgetdcname(struct torture_context *torture)
        ok = get_trusted_domains(torture, &listd);
        torture_assert(torture, ok, "failed to get trust list");
 
-       for (i=0; listd[i].netbios_name; i++) {
+       for (i=0; listd && listd[i].netbios_name; i++) {
                struct winbindd_request req;
                struct winbindd_response rep;
 
index e283602337637cabe0f68a803d72ed1aba41d873..b12e92552edf3464b43dbdb9808a97a372e92603 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "torture/winbind/proto.h"
 
 NTSTATUS torture_winbind_init(void)
index a7d82684e4305f232943251d2969374576b1a70b..d47b36ea7ca5b58307b851b15a349c5cee178e3e 100644 (file)
@@ -13,14 +13,15 @@ PRIVATE_DEPENDENCIES = \
                gensec \
                LIBCLI_RESOLVE \
                auth \
+               ntlm_check \
                MESSAGING \
                LIBEVENTS
 # 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
@@ -33,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
@@ -48,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
@@ -58,7 +59,7 @@ PRIVATE_DEPENDENCIES =
 # End BINARY setnttoken
 #################################
 
-setnttoken_OBJ_FILES = utils/setnttoken.o
+setnttoken_OBJ_FILES = $(utilssrcdir)/setnttoken.o
 
 #################################
 # Start BINARY nmblookup
@@ -75,7 +76,7 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY nmblookup
 #################################
 
-nmblookup_OBJ_FILES = utils/nmblookup.o
+nmblookup_OBJ_FILES = $(utilssrcdir)/nmblookup.o
 
 #################################
 # Start BINARY testparm
@@ -92,4 +93,4 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY testparm
 #################################
 
-testparm_OBJ_FILES = utils/testparm.o
+testparm_OBJ_FILES = $(utilssrcdir)/testparm.o
index 4423c44c15cafa13ff248eb0f08b0a9b4574c53d..93b51e1e288a7aec8498ab267cb016ba50310194 100644 (file)
@@ -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)))
index 6086a4ce32d98836d31aae821453dc7a378aab57..a87b2665681fa3c33b25f1e4dbe9838e7fb51934 100644 (file)
@@ -199,7 +199,7 @@ static int binary_net(int argc, const char **argv)
        ZERO_STRUCTP(ctx);
        ctx->lp_ctx = cmdline_lp_ctx;
        ctx->credentials = cmdline_credentials;
-       cli_credentials_set_event_context(ctx->credentials, ev);
+       ctx->event_ctx = ev;
 
        rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage);
 
index 17388079dd999489f281cda23265a15b2c175f7a..309bee277c3e5214d85ac69164b3bd4f821ae85c 100644 (file)
@@ -24,6 +24,7 @@
 struct net_context {
        struct cli_credentials *credentials;
        struct loadparm_context *lp_ctx;
+       struct event_context *event_ctx;
 };
 
 struct net_functable {
index 37b3c21fcf98d975c1cc5e4d1941ccc313339094..ad63340089907b550122218fdd5bb8e2ef440113 100644 (file)
@@ -58,7 +58,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
 
        domain_name = tmp;
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index 97bb467facde7c434fcbc0143778f12b47bd6c90..55f7c3c31d610898eb6b86cf5945fcc907006a15 100644 (file)
@@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
                new_password = getpass(password_prompt);
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
@@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
                new_password = getpass(password_prompt);
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index 12a8132ceaae294384850fbee1c90716832b0f72..92e6e7748192bd47a3430366697365bdf6fd0c73 100644 (file)
@@ -43,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
                return net_time_usage(ctx, argc, argv);
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index 57cef6b383a9620d3ce282ae5371723b1a775573..c4b8ecb0c2b3714baadf871cad0468e2eaeca25a 100644 (file)
@@ -44,7 +44,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
        }
 
        /* libnet context init and its params */
-       lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!lnet_ctx) return -1;
 
        lnet_ctx->cred = ctx->credentials;
@@ -84,7 +84,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv)
        }
 
        /* libnet context init and its params */
-       lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!lnet_ctx) return -1;
 
        lnet_ctx->cred = ctx->credentials;
index 38f05353ed639a306ae50e943eda0af0b56ec197..14f6a07e4bbe92ffbe5cc4939c5fa3b33c61cef8 100644 (file)
@@ -54,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar
                break;
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
@@ -100,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
                return rc;
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
@@ -142,7 +142,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv)
        struct libnet_context *libnetctx;
        struct libnet_samsync_ldb r;
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index fe03e0dbbeb23ddccf97969d05a7753e098160ae..980e06602d91f3be3c9faa6b599f3c17f1af45c5 100644 (file)
@@ -24,6 +24,7 @@
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
 #include "lib/socket/socket.h"
+#include "lib/events/events.h"
 #include "system/network.h"
 #include "system/locale.h"
 #include "lib/socket/netif.h"
@@ -180,7 +181,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
 }
 
 
-static bool process_one(struct loadparm_context *lp_ctx, 
+static bool process_one(struct loadparm_context *lp_ctx, struct event_context *ev,
                        struct interface *ifaces, const char *name, int nbt_port)
 {
        TALLOC_CTX *tmp_ctx = talloc_new(NULL);
@@ -211,7 +212,7 @@ static bool process_one(struct loadparm_context *lp_ctx,
                node_name = talloc_strdup(tmp_ctx, name);
        }
 
-       nbtsock = nbt_name_socket_init(tmp_ctx, NULL, lp_iconv_convenience(lp_ctx));
+       nbtsock = nbt_name_socket_init(tmp_ctx, ev, lp_iconv_convenience(lp_ctx));
        
        if (options.root_port) {
                all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name, 
@@ -271,6 +272,7 @@ int main(int argc, const char *argv[])
 {
        bool ret = true;
        struct interface *ifaces;
+       struct event_context *ev;
        poptContext pc;
        int opt;
        enum {
@@ -356,13 +358,17 @@ int main(int argc, const char *argv[])
        }
 
        load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
-       
+
+       ev = event_context_init(talloc_autofree_context());
+
        while (poptPeekArg(pc)) {
                const char *name = poptGetArg(pc);
 
-               ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
+               ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
        }
 
+       talloc_free(ev);
+
        talloc_free(ifaces);
 
        poptFreeContext(pc);
index 0c9a41fd70d7143cc550acc5783e7dfd81b3320c..95029deffa77aee114d8963c8d45f4e75c7e7a76 100644 (file)
@@ -30,6 +30,7 @@
 #include "auth/auth.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
 #include "auth/auth_sam.h"
+#include "auth/ntlm/ntlm_check.h"
 #include "pstring.h"
 #include "libcli/auth/libcli_auth.h"
 #include "libcli/security/security.h"
@@ -461,6 +462,10 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                return;
        }
 
+       ev = event_context_init(state);
+       if (!ev) {
+               exit(1);
+       }
        /* setup gensec */
        if (!(state->gensec_state)) {
                switch (stdio_helper_mode) {
@@ -468,7 +473,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                case NTLMSSP_CLIENT_1:
                        /* setup the client side */
 
-                       nt_status = gensec_client_start(NULL, &state->gensec_state, NULL, lp_ctx);
+                       nt_status = gensec_client_start(NULL, &state->gensec_state, ev, lp_ctx);
                        if (!NT_STATUS_IS_OK(nt_status)) {
                                exit(1);
                        }
@@ -476,10 +481,6 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                        break;
                case GSS_SPNEGO_SERVER:
                case SQUID_2_5_NTLMSSP:
-                       ev = event_context_init(state);
-                       if (!ev) {
-                               exit(1);
-                       }
                        msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx), 
                                                    lp_iconv_convenience(lp_ctx), ev);
                        if (!msg) {
index e218aa8ddcfb80d7c27d0f0dd7c16148847d2c6b..fe78687794743384ea0d94ad50f5fa43804e9121 100644 (file)
@@ -4,10 +4,11 @@
 # Start SUBSYSTEM WEB
 [MODULE::WEB]
 INIT_FUNCTION = server_service_web_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = proto.h
+SUBSYSTEM = smbd
 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)))
index 3165fc2d21477f5be3bd98f366a008b0f7a7c4c2..b5eb2c23f093af6f51c3e7e9eac81598c3ac7f06 100644 (file)
@@ -4,8 +4,7 @@
 # Start SUBSYSTEM WINBIND
 [MODULE::WINBIND]
 INIT_FUNCTION = server_service_winbind_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = wb_proto.h
+SUBSYSTEM = smbd
 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)))
index 0c729825dbb8a7bada0b79b2ce702dbed4fe9d7b..333a86445a244037ad5340e6c7ad1966b5e6c4b6 100644 (file)
@@ -158,6 +158,7 @@ static struct dom_sid *idmap_msg_get_dom_sid(TALLOC_CTX *mem_ctx,
  * \return allocated idmap_context on success, NULL on error
  */
 struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev_ctx,
                struct loadparm_context *lp_ctx)
 {
        struct idmap_context *idmap_ctx;
@@ -169,7 +170,7 @@ struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx,
 
        idmap_ctx->lp_ctx = lp_ctx;
 
-       idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, lp_ctx,
+       idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
                                              lp_idmap_url(lp_ctx),
                                              system_session(mem_ctx, lp_ctx),
                                              NULL, 0, NULL);
index 6eae92cc68c4ed0f7221ace5ecce031c0e7bc1f9..13dbe0b921455a3e8448e66443d4ac32b37c7632 100644 (file)
@@ -31,6 +31,8 @@ struct idmap_context {
        struct dom_sid *unix_users_sid;
 };
 
+struct event_context;
+
 #include "winbind/idmap_proto.h"
 
 #endif
index fb2dc197c9edfc4e1367e08c0861ed8e6973b4eb..7d821537f04d117d604abaf542b3879023c44cc7 100644 (file)
@@ -92,7 +92,8 @@ static void cmd_getpwnam_recv_domain(struct composite_context *ctx)
                return;
        }
 
-       user_info->in.user_name = user_name;
+       user_info->in.level = USER_INFO_BY_NAME;
+       user_info->in.data.user_name = user_name;
        user_info->in.domain_name = domain->libnet_ctx->samr.name;
        state->workgroup_name = talloc_strdup(state,
                        domain->libnet_ctx->samr.name);
index c250af1b5650e8745ad9141a9fdc8999ad48d570..15cc592cf69b7c74ed917a7665533aada9272e63 100644 (file)
@@ -34,6 +34,7 @@ struct cmd_getpwuid_state {
        struct composite_context *ctx;
        struct wbsrv_service *service;
        uid_t uid;
+       struct dom_sid *sid;
        char *workgroup;
        struct wbsrv_domain *domain;
 
@@ -81,14 +82,13 @@ static void cmd_getpwuid_recv_sid(struct composite_context *ctx)
        struct cmd_getpwuid_state *state =
                talloc_get_type(ctx->async.private_data,
                                struct cmd_getpwuid_state);
-       struct dom_sid *sid;
 
        DEBUG(5, ("cmd_getpwuid_recv_sid called %p\n", ctx->private_data));
 
-       state->ctx->status = wb_uid2sid_recv(ctx, state, &sid);
+       state->ctx->status = wb_uid2sid_recv(ctx, state, &state->sid);
        if (!composite_is_ok(state->ctx)) return;
 
-       ctx = wb_sid2domain_send(state, state->service, sid);
+       ctx = wb_sid2domain_send(state, state->service, state->sid);
 
        composite_continue(state->ctx, ctx, cmd_getpwuid_recv_domain, state);
 }
@@ -110,7 +110,8 @@ static void cmd_getpwuid_recv_domain(struct composite_context *ctx)
        user_info = talloc(state, struct libnet_UserInfo);
        if (composite_nomem(user_info, state->ctx)) return;
 
-       user_info->in.user_name = state->domain->libnet_ctx->cred->username;
+       user_info->in.level = USER_INFO_BY_SID;
+       user_info->in.data.user_sid = state->sid;
        user_info->in.domain_name = state->domain->libnet_ctx->samr.name;
 
        /* We need the workgroup later, so copy it  */
index 83bd517a02315ea93f6e689c312fab203cbe5b89..8d0c1bd947c17eff426f5cf5ed69b6fe7e74433f 100644 (file)
@@ -143,7 +143,8 @@ static void cmd_list_trustdoms_recv_doms(struct rpc_request *req)
        state->domains = talloc_realloc(state, state->domains,
                                        struct wb_dom_info *,
                                        state->num_domains);
-       if (composite_nomem(state->domains, state->ctx)) return;
+       if (state->num_domains && 
+           composite_nomem(state->domains, state->ctx)) return;
 
        for (i=0; i<state->r.out.domains->count; i++) {
                int j = i+old_num_domains;
index 61b123a5020c9c8e1b79e5584dd15b80a85a1aca..a728f8abe4545116ed99ff3ac950a4f8fe750872 100644 (file)
@@ -62,8 +62,11 @@ struct composite_context *wb_init_lsa_send(TALLOC_CTX *mem_ctx,
 
        /* this will make the secondary connection on the same IPC$ share, 
           secured with SPNEGO or NTLMSSP */
-       ctx = dcerpc_secondary_connection_send(domain->netlogon_pipe,
-                                              domain->lsa_binding);
+       ctx = dcerpc_secondary_auth_connection_send(domain->netlogon_pipe,
+                                                   domain->lsa_binding,
+                                                   &ndr_table_lsarpc,
+                                                   domain->libnet_ctx->cred,
+                                                   domain->libnet_ctx->lp_ctx);
        composite_continue(state->ctx, ctx, init_lsa_recv_pipe, state);
        return result;
        
@@ -79,8 +82,8 @@ static void init_lsa_recv_pipe(struct composite_context *ctx)
                talloc_get_type(ctx->async.private_data,
                                struct init_lsa_state);
 
-       state->ctx->status = dcerpc_secondary_connection_recv(ctx, 
-                                                             &state->lsa_pipe);
+       state->ctx->status = dcerpc_secondary_auth_connection_recv(ctx, state,
+                                                                  &state->lsa_pipe);
        if (!composite_is_ok(state->ctx)) return;
                        
        state->handle = talloc(state, struct policy_handle);
index fc35f11db629ab3f7a29963ef45075bd5b65c055..8b82ab711e366fb86dfdb0cd8402f863308cc826 100644 (file)
@@ -151,8 +151,6 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx,
        state->domain->libnet_ctx->cred = cli_credentials_init(state->domain);
        if (state->domain->libnet_ctx->cred == NULL) goto failed;
 
-       cli_credentials_set_event_context(state->domain->libnet_ctx->cred, service->task->event_ctx);
-
        cli_credentials_set_conf(state->domain->libnet_ctx->cred, service->task->lp_ctx);
 
        /* Connect the machine account to the credentials */
@@ -211,7 +209,6 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx)
                                                   &state->domain->netlogon_pipe);
        
        if (!composite_is_ok(state->ctx)) {
-               talloc_free(state->domain->netlogon_binding);
                return;
        }
        talloc_steal(state->domain->netlogon_pipe, state->domain->netlogon_binding);
index 8ae330df3527c0c21b5c7f5f71e66ef148d2d6cb..5ef0339ecb127ae9f047bf2958884a332aca4c51 100644 (file)
@@ -29,7 +29,7 @@
 #include "version.h"
 #include "librpc/gen_ndr/netlogon.h"
 #include "libcli/security/security.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
 #include "auth/credentials/credentials.h"
 #include "smbd/service_task.h"
 
@@ -43,13 +43,14 @@ static void wbsrv_samba3_async_auth_epilogue(NTSTATUS status,
        struct winbindd_response *resp = &s3call->response;
        if (!NT_STATUS_IS_OK(status)) {
                resp->result = WINBINDD_ERROR;
-               WBSRV_SAMBA3_SET_STRING(resp->data.auth.nt_status_string,
-                                       nt_errstr(status));
-               WBSRV_SAMBA3_SET_STRING(resp->data.auth.error_string,
-                                       get_friendly_nt_error_msg(status));
        } else {
                resp->result = WINBINDD_OK;
        }
+       
+       WBSRV_SAMBA3_SET_STRING(resp->data.auth.nt_status_string,
+                               nt_errstr(status));
+       WBSRV_SAMBA3_SET_STRING(resp->data.auth.error_string,
+                               get_friendly_nt_error_msg(status));
 
        resp->data.auth.pam_error = nt_status_to_pam(status);
        resp->data.auth.nt_status = NT_STATUS_V(status);
@@ -150,8 +151,6 @@ NTSTATUS wbsrv_samba3_check_machacc(struct wbsrv_samba3_call *s3call)
                return NT_STATUS_NO_MEMORY;
        }
 
-       cli_credentials_set_event_context(creds, service->task->event_ctx);
-
        cli_credentials_set_conf(creds, service->task->lp_ctx);
 
        /* Connect the machine account to the credentials */
@@ -721,6 +720,9 @@ static void list_users_recv(struct composite_context *ctx)
        if (NT_STATUS_IS_OK(status)) {
                s3call->response.extra_data.data = extra_data;
                s3call->response.length += extra_data_len;
+               if (extra_data) {
+                       s3call->response.length += 1;
+               }
        }
 
        wbsrv_samba3_async_epilogue(status, s3call);
index 99191f3c6ce6a957398ec1ec3b0b397d33b1457f..f84dece11c0feb3190950f630949c94f80ede9d4 100644 (file)
@@ -149,7 +149,7 @@ static void winbind_task_init(struct task_server *task)
                return;
        }
 
-       service->idmap_ctx = idmap_init(service, task->lp_ctx);
+       service->idmap_ctx = idmap_init(service, task->event_ctx, task->lp_ctx);
        if (service->idmap_ctx == NULL) {
                task_server_terminate(task, "Failed to load idmap database");
                return;
index e339d223aa229508918303ee4bb85e6c668f9e4d..235a897503289875f9e5460428d5b18441eaf5c5 100644 (file)
@@ -4,14 +4,13 @@
 # Start SUBSYSTEM WREPL_SRV
 [MODULE::WREPL_SRV]
 INIT_FUNCTION = server_service_wrepl_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = wrepl_server_proto.h
+SUBSYSTEM = smbd
 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)))
index 34d94d73a6b9e5323e489a6cc4d55c344326d280..25227481b8820aa07ddf0ae459f168bcc35c6c60 100644 (file)
@@ -230,7 +230,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
        wrepl_in->service       = service;
        wrepl_in->partner       = partner;
 
-       status = stream_new_connection_merge(service->task->event_ctx, model_ops,
+       status = stream_new_connection_merge(service->task->event_ctx, service->task->lp_ctx, model_ops,
                                             sock, &wreplsrv_stream_ops, service->task->msg_ctx,
                                             wrepl_in, &conn);
        NT_STATUS_NOT_OK_RETURN(status);
index e750d9355aeb3f5d6a78b70afcc4103e2bd9d394..b7030669869af7561d64bed1db8e6b73601b3b8d 100644 (file)
 #include "lib/socket/netif.h"
 
 static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx, 
+                                                 struct event_context *ev_ctx,
                                                  struct loadparm_context *lp_ctx)
 {
-       return ldb_wrap_connect(mem_ctx, lp_ctx, private_path(mem_ctx, 
+       return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, private_path(mem_ctx, 
                                lp_ctx, lp_wins_config_url(lp_ctx)),
                                system_session(mem_ctx, lp_ctx), NULL, 0, NULL);
 }
@@ -83,12 +84,12 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service,
                owner = iface_n_ip(ifaces, 0);
        }
 
-       service->wins_db     = winsdb_connect(service, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL);
+       service->wins_db     = winsdb_connect(service, service->task->event_ctx, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL);
        if (!service->wins_db) {
                return NT_STATUS_INTERNAL_DB_ERROR;
        }
 
-       service->config.ldb = wins_config_db_connect(service, lp_ctx);
+       service->config.ldb = wins_config_db_connect(service, service->task->event_ctx, lp_ctx);
        if (!service->config.ldb) {
                return NT_STATUS_INTERNAL_DB_ERROR;
        }
index 368c78d727a1d99938ece6128552819e62d6654f..4fe6571eef89a8c5d5d67aa8b7166fa0a9c013a0 100644 (file)
@@ -33,7 +33,6 @@ pwdLastSet: 0
 primaryGroupID: 513
 accountExpires: -1
 logonCount: 0
-sAMAccountType: 805306368
 objectCategory: CN=Person,CN=Schema,CN=Configuration,${BASEDN}
 
 dn: CN=TemplateComputer,CN=Templates
@@ -55,7 +54,6 @@ pwdLastSet: 0
 primaryGroupID: 513
 accountExpires: -1
 logonCount: 0
-sAMAccountType: 805306369
 objectCategory: CN=Computer,CN=Schema,CN=Configuration,${BASEDN}
 
 dn: CN=TemplateTrustingDomain,CN=Templates
@@ -74,7 +72,6 @@ lastLogon: 0
 primaryGroupID: 513
 accountExpires: -1
 logonCount: 0
-sAMAccountType: 805306370
 
 dn: CN=TemplateGroup,CN=Templates
 objectClass: top
@@ -83,7 +80,6 @@ objectClass: groupTemplate
 cn: TemplateGroup
 instanceType: 4
 groupType: -2147483646
-sAMAccountType: 268435456
 objectCategory: CN=Group,CN=Schema,CN=Configuration,${BASEDN}
 
 # Currently this isn't used, we don't have a way to detect it different from an incoming alias
@@ -95,7 +91,6 @@ objectCategory: CN=Group,CN=Schema,CN=Configuration,${BASEDN}
 # cn: TemplateAlias
 # instanceType: 4
 # groupType: -2147483644
-# sAMAccountType: 268435456
 
 dn: CN=TemplateForeignSecurityPrincipal,CN=Templates
 objectClass: top
diff --git a/testprogs/blackbox/subunit.sh b/testprogs/blackbox/subunit.sh
new file mode 100755 (executable)
index 0000000..100dfd1
--- /dev/null
@@ -0,0 +1,67 @@
+#
+#  subunit.sh: shell functions to report test status via the subunit protocol.
+#  Copyright (C) 2006  Robert Collins <robertc@robertcollins.net>
+#  Copyright (C) 2008  Jelmer Vernooij <jelmer@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 2 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, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+subunit_start_test () {
+  # emit the current protocol start-marker for test $1
+  echo "test: $1"
+}
+
+
+subunit_pass_test () {
+  # emit the current protocol test passed marker for test $1
+  echo "success: $1"
+}
+
+
+subunit_fail_test () {
+  # emit the current protocol fail-marker for test $1, and emit stdin as
+  # the error text.
+  # we use stdin because the failure message can be arbitrarily long, and this
+  # makes it convenient to write in scripts (using <<END syntax.
+  echo "failure: $1 ["
+  cat -
+  echo "]"
+}
+
+
+subunit_error_test () {
+  # emit the current protocol error-marker for test $1, and emit stdin as
+  # the error text.
+  # we use stdin because the failure message can be arbitrarily long, and this
+  # makes it convenient to write in scripts (using <<END syntax.
+  echo "error: $1 ["
+  cat -
+  echo "]"
+}
+
+testit () {
+       name="$1"
+       shift
+       cmdline="$*"
+       subunit_start_test "$name"
+       output=`$cmdline 2>&1`
+       status=$?
+       if [ x$status = x0 ]; then
+               subunit_pass_test "$name"
+       else
+               echo $output | subunit_fail_test "$name"
+       fi
+       return $status
+}
index 23df04c84c9aef95a3aeb6e9e1459cfe25867645..43564a0c77f3ba9601ecc1c4087e44181dfc535a 100755 (executable)
@@ -14,40 +14,24 @@ USERNAME=$2
 PASSWORD=$3
 DOMAIN=$4
 
+. `dirname $0`/subunit.sh
+
 samba4bindir=`dirname $0`/../../source/bin
 DD=$samba4bindir/cifsdd
 
 SHARE=tmp
 DEBUGLEVEL=1
 
-failed=0
-
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-               failed=`expr $failed + 1`
-       fi
-       return $status
-}
-
 runcopy() {
        message="$1"
        shift
        
        testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
-           "$@"
+           "$@" || failed=`expr $failed + 1`
 }
 
 compare() {
-    testit "$1" cmp "$2" "$3"
+    testit "$1" cmp "$2" "$3" || failed=`expr $failed + 1`
 }
 
 sourcepath=tempfile.src.$$
index 89cc8c2795b7971ceada30eb5f2bf52a31ea3040..ec6f0e422bc3d44f6c01d184b77201284af51a7e 100755 (executable)
@@ -20,20 +20,7 @@ failed=0
 samba4bindir=`dirname $0`/../../source/bin
 gentest=$samba4bindir/gentest
 
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-       fi
-       return $status
-}
+. `dirname $0`/subunit.sh
 
 cat <<EOF > st/gentest.ignore
 all_info.out.fname
index 29582055ee0832cfcc1350c4d7ac3b860504a8e6..d3cece0af70b8dc209560b89f4031274fa40d753 100755 (executable)
@@ -23,23 +23,9 @@ samba4bindir=`dirname $0`/../../source/bin
 smbclient=$samba4bindir/smbclient
 samba4kinit=$samba4bindir/samba4kinit
 net=$samba4bindir/net
-enableaccount="$samba4bindir/smbpython `dirname $0`/../../source/setup/enableaccount"
-
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-       fi
-       return $status
-}
+enableaccount="$PYTHON `dirname $0`/../../source/setup/enableaccount"
 
+. `dirname $0`/subunit.sh
 
 test_smbclient() {
        name="$1"
index 4067a7fc4331a873ff2ab3657855705b6b73ad4d..8e1af99719178cf7bf2c32ddc2a9a5d557fd82a6 100755 (executable)
@@ -14,6 +14,8 @@ PREFIX=$3
 shift 2
 options="$*"
 
+. `dirname $0`/subunit.sh
+
 check() {
        name="$1"
        shift
index c08b408107c0073d9d894d29385e9df6c22128e8..88fa0ef89242920d9022990eb8087c733cdcef69 100755 (executable)
@@ -21,20 +21,7 @@ failed=0
 samba4bindir=`dirname $0`/../../source/bin
 locktest=$samba4bindir/locktest
 
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-       fi
-       return $status
-}
+. `dirname $0`/subunit.sh
 
 testit "locktest" $VALGRIND $locktest //$SERVER/test1 //$SERVER/test2 --num-ops=100  -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
 
index ef429a1fb06b556af787591e5a3cbbff2853d8fe..c1f765c1dd7b2facb43aa208daea0669ac27d45e 100755 (executable)
@@ -21,20 +21,7 @@ failed=0
 samba4bindir=`dirname $0`/../../source/bin
 masktest=$samba4bindir/masktest
 
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-       fi
-       return $status
-}
+. `dirname $0`/subunit.sh
 
 testit "masktest" $VALGRIND $masktest //$SERVER/tmp --num-ops=200 --dieonerror -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
 
old mode 100644 (file)
new mode 100755 (executable)
index 38c33ad..089a7c3
@@ -4,27 +4,14 @@
 # Copyright (C) 2008 Andrew Bartlett
 # based on test_smbclient.sh
 
+. `dirname $0`/subunit.sh
+
 failed=0
 
 samba4bindir=`dirname $0`/../../source/bin
 ndrdump=$samba4bindir/ndrdump
 files=`dirname $0`/ndrdump
 
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-       fi
-       return $status
-}
-
 testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
 testit "ndrdump with out" $VALGRIND $ndrdump samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
 testit "ndrdump with --context-file" $VALGRIND $ndrdump --context-file $files/samr-CreateUser-in.dat samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
index 4df64cac947040995e6397d768689fe1f424ca88..d2c5c675e2ef7dafee77dac9241471b386453f74 100755 (executable)
@@ -21,20 +21,7 @@ failed=0
 samba4bindir=`dirname $0`/../../source/bin
 smbclient=$samba4bindir/smbclient
 
-testit() {
-       name="$1"
-       shift
-       cmdline="$*"
-       echo "test: $name"
-       $cmdline
-       status=$?
-       if [ x$status = x0 ]; then
-               echo "success: $name"
-       else
-               echo "failure: $name"
-       fi
-       return $status
-}
+. `dirname $0`/subunit.sh
 
 runcmd() {
        name="$1"
diff --git a/testprogs/blackbox/test_wbinfo.sh b/testprogs/blackbox/test_wbinfo.sh
new file mode 100755 (executable)
index 0000000..ec8b9eb
--- /dev/null
@@ -0,0 +1,187 @@
+#!/bin/sh
+# Blackbox test for wbinfo
+if [ $# -lt 4 ]; then
+cat <<EOF
+Usage: test_wbinfo.sh DOMAIN USERNAME PASSWORD TARGET
+EOF
+exit 1;
+fi
+
+DOMAIN=$1
+USERNAME=$2
+PASSWORD=$3
+TARGET=$4
+shift 4
+
+failed=0
+samba4bindir=`dirname $0`/../../source/bin
+wbinfo=$samba4bindir/wbinfo
+
+. `dirname $0`/subunit.sh
+
+testfail() {
+       name="$1"
+       shift
+       cmdline="$*"
+       echo "test: $name"
+       $cmdline
+       status=$?
+        if [ x$status = x0 ]; then
+                echo "failure: $name"
+        else
+                echo "success: $name"
+        fi
+        return $status
+}
+
+knownfail() {
+        name="$1"
+        shift
+        cmdline="$*"
+        echo "test: $name"
+        $cmdline
+        status=$?
+        if [ x$status = x0 ]; then
+                echo "failure: $name [unexpected success]"
+                               status=1
+        else
+                echo "knownfail: $name"
+                               status=0
+        fi
+        return $status
+}
+
+
+testit "wbinfo -u against $TARGET" $wbinfo -u || failed=`expr $failed + 1`
+# Does not work yet
+knownfail "wbinfo -g against $TARGET" $wbinfo -g || failed=`expr $failed + 1`
+knownfail "wbinfo -N against $TARGET" $wbinfo -N || failed=`expr $failed + 1`
+knownfail "wbinfo -I against $TARGET" $wbinfo -I || failed=`expr $failed + 1`
+testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
+admin_sid=`$wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1`
+echo "$DOMAIN/$USERNAME resolved to $admin_sid"
+
+testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=`expr $failed + 1`
+admin_name=`wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z`
+echo "$admin_sid resolved to $admin_name"
+
+tested_name=`echo $DOMAIN/$USERNAME | tr a-z A-Z`
+
+echo "test: wbinfo -s check for sane mapping"
+if test x$admin_name != x$tested_name; then
+       echo "$admin_name does not match $tested_name"
+       echo "failure: wbinfo -s check for sane mapping"
+       failed=`expr $failed + 1`
+else
+       echo "success: wbinfo -s check for sane mapping"
+fi
+
+testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed=`expr $failed + 1`
+test_sid=`$wbinfo -n $tested_name | cut -d " " -f1`
+
+echo "test: wbinfo -n check for sane mapping"
+if test x$admin_sid != x$test_sid; then
+       echo "$admin_sid does not match $test_sid"
+       echo "failure: wbinfo -n check for sane mapping"
+       failed=`expr $failed + 1`
+else
+       echo "success: wbinfo -n check for sane mapping"
+fi
+
+testit "wbinfo -U against $TARGET" $wbinfo -U 30000 || failed=`expr $failed + 1`
+
+echo "test: wbinfo -U check for sane mapping"
+sid_for_30000=`$wbinfo -U 30000`
+if test x$sid_for_30000 != "xS-1-22-1-30000"; then
+       echo "uid 30000 mapped to $sid_for_30000, not S-1-22-1-30000"
+       echo "failure: wbinfo -U check for sane mapping"
+       failed=`expr $failed + 1`
+else
+       echo "success: wbinfo -U check for sane mapping"
+fi
+
+admin_uid=`wbinfo -U $admin_sid`
+
+testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=`expr $failed + 1`
+
+echo "test: wbinfo -G check for sane mapping"
+sid_for_30000=`$wbinfo -G 30000`
+if test x$sid_for_30000 != "xS-1-22-2-30000"; then
+        echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
+       echo "failure: wbinfo -G check for sane mapping"
+       failed=`expr $failed + 1`
+else
+       echo "success: wbinfo -G check for sane mapping"
+fi
+
+testit "wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed=`expr $failed + 1`
+
+echo "test: wbinfo -S check for sane mapping"
+uid_for_sid=`$wbinfo -S S-1-22-1-30000`
+if test 0$uid_for_sid -ne 30000; then
+       echo "S-1-22-1-30000 mapped to $uid_for_sid, not 30000"
+       echo "failure: wbinfo -S check for sane mapping"
+       failed=`expr $failed + 1`
+else
+       echo "success: wbinfo -S check for sane mapping"
+fi
+
+testfail "wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed=`expr $failed + 1`
+
+testit "wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed=`expr $failed + 1`
+
+echo "test: wbinfo -Y check for sane mapping"
+gid_for_sid=`$wbinfo -Y S-1-22-2-30000`
+if test 0$gid_for_sid -ne 30000; then
+       echo "S-1-22-2-30000 mapped to $gid_for_sid, not 30000"
+       echo "failure: wbinfo -Y check for sane mapping"
+       failed=`expr $failed + 1`
+else
+       echo "success: wbinfo -Y check for sane mapping"
+fi
+
+testfail "wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed=`expr $failed + 1`
+
+testit "wbinfo -t against $TARGET" $wbinfo -t || failed=`expr $failed + 1`
+
+testit "wbinfo  --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
+testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
+testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1`
+
+echo "test: wbinfo --own-domain against $TARGET check output"
+own_domain=`wbinfo --own-domain`
+if test x$own_domain = x$DOMAIN; then
+       echo "success: wbinfo --own-domain against $TARGET check output"
+else
+       echo "Own domain reported as $own_domain instead of $DOMAIN"
+       echo "failure: wbinfo --own-domain against $TARGET check output"
+fi
+
+# this does not work
+knownfail "wbinfo --sequence against $TARGET" $wbinfo --sequence
+knownfail "wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed=`expr $failed + 1`
+
+testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
+
+# this does not work
+knownfail "wbinfo --uid-info against $TARGET" $wbinfo --uid-info $admin_sid
+knownfail "wbinfo --group-info against $TARGET" $wbinfo --group-info "S-1-22-2-0"
+knownfail "wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME"
+
+testit "wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed=`expr $failed + 1`
+
+testit "wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed=`expr $failed + 1`
+
+testit "wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
+
+# this does not work
+knwonfail "wbinfo --getdcname against $TARGET" $wbinfo --getdcname=$DOMAIN
+
+testit "wbinfo -p against $TARGET" $wbinfo -p || failed=`expr $failed + 1`
+
+testit "wbinfo -K against $TARGET with domain creds" $wbinfo -K "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
+
+testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=`expr $failed + 1`
+
+exit $failed
+
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js
deleted file mode 100755 (executable)
index 3750baf..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-#!/usr/bin/env smbscript
-/*
-       test echo pipe calls from ejs
-*/     
-
-var options = GetOptions(ARGV, 
-               "POPT_AUTOHELP",
-               "POPT_COMMON_SAMBA",
-               "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
-   println("Failed to parse options");
-   return -1;
-}
-
-libinclude("base.js");
-
-/*
-  generate a ramp as an integer array
- */
-function ramp_array(N)
-{
-       var a = new Array(N);
-       var data = datablob_init();
-       for (i=0;i<N;i++) {
-               a[i] = i;
-       }
-       return data.blobFromArray(a);
-}
-
-
-/*
-  test the echo_AddOne interface
-*/
-function test_AddOne(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_AddOne\n");
-
-       for (i=0;i<10;i++) {
-               io.input.in_data = i;
-               status = echo.echo_AddOne(io);
-               check_status_ok(status);
-               assert(io.output.out_data == i + 1);
-       }
-}
-
-/*
-  test the echo_EchoData interface
-*/
-function test_EchoData(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_EchoData\n");
-
-       for (i=0; i<30; i=i+5) {
-               io.input.len = i;
-               io.input.in_data = ramp_array(i);
-               status = echo.echo_EchoData(io);
-               check_status_ok(status);
-               assert(true == echo.blobCompare(io.input.in_data, io.output.out_data));
-       }
-}
-
-
-/*
-  test the echo_SinkData interface
-*/
-function test_SinkData(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_SinkData\n");
-
-       for (i=0; i<30; i=i+5) {
-               io.input.len = i;
-               io.input.data = ramp_array(i);
-               status = echo.echo_SinkData(io);
-               check_status_ok(status);
-       }
-}
-
-
-/*
-  test the echo_SourceData interface
-*/
-function test_SourceData(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_SourceData\n");
-
-       for (i=0; i<30; i=i+5) {
-               io.input.len = i;
-               status = echo.echo_SourceData(io);
-               check_status_ok(status);
-               correct = ramp_array(i);
-               assert(true == echo.blobCompare(correct, io.output.data));
-       }
-}
-
-
-/*
-  test the echo_TestCall interface
-*/
-function test_TestCall(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_TestCall\n");
-
-       io.input.s1 = "my test string";
-       status = echo.echo_TestCall(io);
-       check_status_ok(status);
-       assert("this is a test string" == io.output.s2);
-}
-
-/*
-  test the echo_TestCall2 interface
-*/
-function test_TestCall2(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_TestCall2\n");
-
-       for (i=1;i<=7;i++) {
-               io.input.level = i;
-               status = echo.echo_TestCall2(io);
-               check_status_ok(status);
-       }
-}
-
-/*
-  test the echo_TestSleep interface
-*/
-function test_TestSleep(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_TestSleep\n");
-
-       io.input.seconds = 1;
-       status = echo.echo_TestSleep(io);
-       check_status_ok(status);
-}
-
-/*
-  test the echo_TestEnum interface
-*/
-function test_TestEnum(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_TestEnum\n");
-
-       io.input.foo1 = echo.ECHO_ENUM1;
-       io.input.foo2 = new Object();
-       io.input.foo2.e1 = echo.ECHO_ENUM1;
-       io.input.foo2.e2 = echo.ECHO_ENUM1_32;
-       io.input.foo3 = new Object();
-       io.input.foo3.e1 = echo.ECHO_ENUM2;
-       status = echo.echo_TestEnum(io);
-       check_status_ok(status);
-       assert(io.output.foo1    == echo.ECHO_ENUM1);
-       assert(io.output.foo2.e1 == echo.ECHO_ENUM2);
-       assert(io.output.foo2.e2 == echo.ECHO_ENUM1_32);
-       assert(io.output.foo3.e1 == echo.ECHO_ENUM2);
-}
-
-/*
-  test the echo_TestSurrounding interface
-*/
-function test_TestSurrounding(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_TestSurrounding\n");
-       
-       io.input.data = new Object();
-       io.input.data.x = 10;
-       io.input.data.surrounding = new Array(10);
-       status = echo.echo_TestSurrounding(io);
-       check_status_ok(status);
-       assert(io.output.data.surrounding.length == 20);
-       check_array_zero(io.output.data.surrounding);
-}
-
-/*
-  test the echo_TestDoublePointer interface
-*/
-function test_TestDoublePointer(echo)
-{
-       var io = irpcObj();
-
-       print("Testing echo_TestDoublePointer\n");
-       
-       io.input.data = 7;
-       status = echo.echo_TestDoublePointer(io);
-       check_status_ok(status);
-       assert(io.input.data == io.input.data);
-}
-
-
-if (options.ARGV.length != 1) {
-   println("Usage: echo.js <BINDING>");
-   return -1;
-}
-var binding = options.ARGV[0];
-var echo = rpcecho_init();
-datablob_init(echo);
-
-print("Connecting to " + binding + "\n");
-status = echo.connect(binding);
-if (status.is_ok != true) {
-   printf("Failed to connect to %s - %s\n", binding, status.errstr);
-   return;
-}
-
-test_AddOne(echo);
-test_EchoData(echo);
-test_SinkData(echo);
-test_SourceData(echo);
-
-print("SKIPPING test_TestCall as pidl cannot generate code for it\n");
-/* test_TestCall(echo); */
-test_TestCall2(echo);
-test_TestSleep(echo);
-test_TestEnum(echo);
-test_TestSurrounding(echo);
-test_TestDoublePointer(echo);
-
-println("All OK\n");
-return 0;
diff --git a/testprogs/ejs/loadparm.js b/testprogs/ejs/loadparm.js
deleted file mode 100644 (file)
index f56ca9f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-       demonstrate access to loadparm functions from ejs
-*/     
-
-loadparm_init(local);
-
-function showParameter(name) {
-        print(name + ": ");
-        printVars(get(name));
-}
-
-for (v in ARGV) {
-    showParameter(ARGV[v]);
-}
-
-print("defined services: ");
-printVars(services());
-
-showParameter("server services");
-showParameter("netbios name");
-showParameter("security");
-showParameter("workgroup");
-showParameter("log level");
-showParameter("server signing");
-showParameter("interfaces");
diff --git a/testprogs/ejs/resolveName.js b/testprogs/ejs/resolveName.js
deleted file mode 100644 (file)
index 1619b69..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* 
-  Demonstrate use of resolveName() js function
-*/
-
-var result = new Object();
-
-res = resolveName(result, ARGV[0]);
-
-if (res.is_ok) {
-       println(result.value);
-} else {
-       println(res.errstr);
-}
diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js
deleted file mode 100755 (executable)
index fbdae97..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/env smbscript
-/*
-  test samr calls from ejs
-*/     
-
-var options = GetOptions(ARGV, 
-                        "POPT_AUTOHELP",
-                        "POPT_COMMON_SAMBA",
-                        "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
-   println("Failed to parse options");
-   return -1;
-}
-
-libinclude("base.js");
-libinclude("samr.js");
-
-
-/*
-  test the samr_Connect interface
-*/
-function test_Connect(samr)
-{
-       print("Testing samr_Connect\n");
-       return samrConnect(samr);
-}
-
-
-/*
-  test the samr_LookupDomain interface
-*/
-function test_LookupDomain(samr, handle, domain)
-{
-       print("Testing samr_LookupDomain\n");
-       return samrLookupDomain(samr, handle, domain);
-}
-
-/*
-  test the samr_OpenDomain interface
-*/
-function test_OpenDomain(samr, handle, sid)
-{
-       print("Testing samr_OpenDomain\n");
-       return samrOpenDomain(samr, handle, sid);
-}
-
-/*
-  test the samr_EnumDomainUsers interface
-*/
-function test_EnumDomainUsers(samr, dom_handle)
-{
-       var i, users;
-       print("Testing samr_EnumDomainUsers\n");
-       users = samrEnumDomainUsers(samr, dom_handle);
-       print("Found " + users.length + " users\n");
-       for (i=0;i<users.length;i++) {
-               println("\t" + users[i].name + "\t(" + users[i].idx + ")");
-       }
-}
-
-/*
-  test the samr_EnumDomainGroups interface
-*/
-function test_EnumDomainGroups(samr, dom_handle)
-{
-       print("Testing samr_EnumDomainGroups\n");
-       var i, groups = samrEnumDomainGroups(samr, dom_handle);
-       print("Found " + groups.length + " groups\n");
-       for (i=0;i<groups.length;i++) {
-               println("\t" + groups[i].name + "\t(" + groups[i].idx + ")");
-       }
-}
-
-/*
-  test domain specific ops
-*/
-function test_domain_ops(samr, dom_handle)
-{
-       test_EnumDomainUsers(samr, dom_handle);
-       test_EnumDomainGroups(samr, dom_handle);
-}
-
-
-
-/*
-  test the samr_EnumDomains interface
-*/
-function test_EnumDomains(samr, handle)
-{
-       var i, domains;
-       print("Testing samr_EnumDomains\n");
-
-       domains = samrEnumDomains(samr, handle);
-       print("Found " + domains.length + " domains\n");
-       for (i=0;i<domains.length;i++) {
-               print("\t" + domains[i].name + "\n");
-       }
-       for (i=0;i<domains.length;i++) {
-               print("Testing domain " + domains[i].name + "\n");
-               sid = samrLookupDomain(samr, handle, domains[i].name);
-               dom_handle = test_OpenDomain(samr, handle, sid);
-               test_domain_ops(samr, dom_handle);
-               samrClose(samr, dom_handle);
-       }
-}
-
-if (options.ARGV.length != 1) {
-   println("Usage: samr.js <BINDING>");
-   return -1;
-}
-var binding = options.ARGV[0];
-var samr = samr_init();
-
-print("Connecting to " + binding + "\n");
-status = samr.connect(binding);
-if (status.is_ok != true) {
-   print("Failed to connect to " + binding + " - " + status.errstr + "\n");
-   return -1;
-}
-
-handle = test_Connect(samr);
-test_EnumDomains(samr, handle);
-samrClose(samr, handle);
-
-print("All OK\n");
-return 0;